A simple function to search through a defined section of memory. This should not be used for large memory searches. This code assumes you are injected into the process.
Простой пример поиск определенного значения в памяти
DWORD __inline MemorySearch(DWORD dwSearchStart, int iSearchLength, BYTE *search, int iSearchSize)
{
unsigned char *ptr = (unsigned char *)dwSearchStart;
unsigned char *ss;
for (int i=0; i< (int) iSearchLength;i++)
{
if (memcmp(ptr+i,search,iSearchSize) == 0) {
return (i);
}
}
return NULL;
}
Simple code bit to retrieve a value using a pointer + offset model. This code assumes you are injected into the process.
Пример кода получения определенного значения из памяти через указатель
int static GetDword(DWOR charPtr, DWORD offset)
{
try{
DWORD *ptr = NULL;
ptr = (DWORD *)(charPtr+offset);
return *ptr;
}
catch( char * str ) {
return 1; // Return whatever error value you want.
}
}