Nummer How do I cheat?
Reputation: 0
Joined: 22 Jan 2015 Posts: 3
|
Posted: Thu May 21, 2015 7:18 am Post subject: [C#] Scanning memory |
|
|
I'm a very bad programmer, and I turned to scan a code signature
| Code: | public int findsignature(int PID, byte[] signature)
{
try
{
unsafe
{
long MaxAddr = 0x7fffffff;
long Addr = (long)Process.GetProcessById(PID).Modules[0].BaseAddress;
MEMORY_BASIC_INFORMATION m;
var handle = OpenProcess(0x001F0FFF, false, PID);
m.BaseAddress = IntPtr.Zero;
m.RegionSize = IntPtr.Zero;
byte[] buffer;
while (Addr <= MaxAddr)
{
VirtualQueryEx(handle, (IntPtr)Addr, out m, (uint)Marshal.SizeOf(typeof(MEMORY_BASIC_INFORMATION)));
buffer = new byte[(long)m.RegionSize];
int dammy = 0;
ReadProcessMemory(handle, m.BaseAddress, buffer, (int)m.RegionSize, out dammy);
if (Addr == (long)m.BaseAddress + (long)m.RegionSize)
break;
int count = 0;
Addr = (long)m.BaseAddress + (long)m.RegionSize;
if (buffer.Length > signature.Length)
{
for (int i = 0; i < buffer.Length; i++)
{
if (buffer[i] == signature[0])
{
for (int q = 0; q < signature.Length; q++)
{
try
{
if (buffer[i + q] == signature[q] || signature[q] == -1)
{
count++;
if (count == signature.Length)
{
return i + (int)m.BaseAddress;
}
}
else
{
count = 0;
}
}
catch { }
}
}
}
}
}
}
}
catch
{
return 0;
}
return 0;
} |
This code looks for very long signatures. Who can tell me how to do better? So he looked for the signature is correct, and could look for them on the type of string?
I am very grateful to all who help me.
Code should support the signature search of unknown bytes "??" .
Sorry for my English.
I used Google translator |
|