I'm trying to create a signature search that can find the address of whatever bytes you input. For example, if I set buffer to 0x04AF, the function will search through the process' memory untill it finds an address that holds that value. Unfotunatly, I've run into a lot of difficulty. Any Help would be greatly appreciated. Here is the full source code. The return value always seems to be zero, even when I know the buffer is equal to the memory.
#include
<windows.h>#include
<iostream>
using
namespace std;
DWORD* FindSignature(HANDLE hProcess, byte* signature, DWORD* dwStartAddress, unsigned int length);
BOOL CompareBytes(byte* buffer1, byte* buffer2, unsigned int length);
int
main(){
byte buffer[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
DWORD* test = FindSignature(GetCurrentProcess(), buffer, NULL, 1000);
system("pause");
}
DWORD* FindSignature(HANDLE hProcess, byte* signature, DWORD* dwStartAddress, unsigned int length)
{
if(dwStartAddress == NULL)
{
dwStartAddress = (DWORD*)0x00400000;
}
byte buffer[sizeof(signature)];
for(unsigned int i = 0; i < length; i++)
{
ReadProcessMemory(hProcess, (LPVOID)dwStartAddress, buffer, sizeof(signature), NULL);
if(CompareBytes(buffer, signature, sizeof(signature)))
{
cout << "Match Found";
return (DWORD*)(dwStartAddress + i);
}
}
return 0;
}
BOOL CompareBytes(byte* buffer1, byte* buffer2, unsigned int length)
{
for(unsigned int i = 0; i < length; i++)
{
if(buffer1[i] != buffer2[i])
{
return false;
}
}
return true;
}