AOB Scanning

Posts 1–3 of 3 · Page 1 of 1
AOB Scanning
I'm using kitterz Find Pattern method, this is what I've got :

Functions.h
Code:
#include <Windows.h>
///////////////////////////////////////////////////////////////////////////////////////////////
//Memory Functions
//////////////////////////////////////////////////////////////////////////////////////////////
void WriteMemory( unsigned long ulAddress, unsigned char ucAmount, ...)   
{ 
     DWORD dwOldProtect; 
     VirtualProtect((void*)ulAddress, ucAmount, PAGE_EXECUTE_READWRITE, &dwOldProtect);
 
   va_list* va = new va_list; 
   va_start(*va, ucAmount); 
 
   for (unsigned char ByteToWrite = va_arg(*va, unsigned char), ucIndex = 0; ucIndex < ucAmount; ucIndex++, ByteToWrite = va_arg(*va, unsigned char)) 
   { 
      *(unsigned char*)(ulAddress + ucIndex) = ByteToWrite; 
   } 
 
   va_end(*va); 
   delete va; 
 
   VirtualProtect((void*)ulAddress, ucAmount, dwOldProtect, &dwOldProtect);
}
////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////
//AoB Scan
//////////////////////////////////////////////////////////////////////////////////////////////
bool Check(const BYTE* pData, const BYTE* bMask, const char* szMask)
{
    for(; *szMask; ++szMask, ++pData, ++bMask)
    if(*szMask != 'x' && *pData != *bMask )
    return false;

    return (*szMask) == NULL;
}

DWORD FindPattern(BYTE *bMask, char* szMask, DWORD dwOffset)
{
    DWORD dwAddress = 0x00400000;
    DWORD dwLen        = 0x7FFFFFFF;
    __try
    {
        for(DWORD i=0; i < dwLen; i++)
        if( Check ((BYTE*)( dwAddress + i ), bMask, szMask) )
        return (DWORD)(dwAddress + i + dwOffset);
    }
    __except(EXCEPTION_EXECUTE_HANDLER)
    {
        MessageBox(NULL, "Find Pattern Error", "Error", MB_OK);
    }

    return 0x00400000;
}
//////////////////////////////////////////////////////////////////////////////////////////////
This is how I'm using it :

Form1.cpp [ Snippet ]

Code:
unsigned char TestBytes[] = {0x53, 0x5F, 0x56, 0x6C, 0x61, 0x64, 0x69, 0x6D, 0x69, 0x72, 0x5F, 0x41, 0x5F, 0x4E, 0x6F, 0x72, 0x6D, 0x61, 0x6C, 0x2E, 0x78, 0x6D, 0x6C};

unsigned long TestAddress()
{
     return FindPattern((unsigned char*)TestBytes, "xxxxxxxxxxxxxxxxxxxxxxx", 0);
}

unsigned long Test = (unsigned long)TestAddress();

void Form1::button1_Click(System::Object^  sender, System::EventArgs^  e) {
	if (this->button1->Text == "Set Modification")
{
	this->button1->Text = "Remove Modification";
	WriteMemory(Test, 23, 0x6D, 0x65, 0x72, 0x63, 0x79, 0x5F, 0x72, 0x61, 0x74, 0x68, 0x65, 0x72, 0x5F, 0x30, 0x31, 0x32, 0x33, 0x00, 0x6C, 0x2E, 0x78, 0x6D, 0x6C);
}

else
{
	WriteMemory(Test, 23, 0x6D, 0x65, 0x72, 0x63, 0x79, 0x5F, 0x72, 0x61, 0x74, 0x68, 0x65, 0x72, 0x5F, 0x30, 0x31, 0x32, 0x33, 0x00, 0x6C, 0x2E, 0x78, 0x6D, 0x6C);
}
}
My issue standing, is that I can't write any bytes. I'm pretty sure I set it up just fine, but it isn't working.
[Update]
I have the pattern error fixed, but it doesn't write bytes.
Did u inject you hack into games?..
because i thing u cant use that write memory method if not injected into process..
if you want to write process memory from outside of process ( without inject it into process)..
u can use WriteProcessMemory API from windows..

if im not wrong, this way
*(unsigned char*)(ulAddress + ucIndex) = ByteToWrite;
is to write memory from injected hack??

CMIIW
Posts 1–3 of 3 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?