Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


AOB Scanning

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
drlunar
How do I cheat?
Reputation: 0

Joined: 21 May 2011
Posts: 5

PostPosted: Mon Jul 16, 2012 10:01 pm    Post subject: AOB Scanning Reply with quote

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.
Back to top
View user's profile Send private message
n0 m3rcY
Cheater
Reputation: 0

Joined: 18 Jun 2012
Posts: 42

PostPosted: Tue Jul 17, 2012 2:18 pm    Post subject: Reply with quote

Code:
*(unsigned char*)(ulAddress + ucIndex) = ByteToWrite;

If you're not in a dll, you can't interact with an address that doesn't belong to your app, even if you virtualprotected it. You'll have to use WPM and get a handle for the process. Also, you're better off using a byte array and just writing that than having a thousand arguments in your function call, looks nicer too.

I'm assuming you're not using a dll because of the form.cpp snippet, however I can't see the entry point so I could be wrong Sad
Back to top
View user's profile Send private message
drlunar
How do I cheat?
Reputation: 0

Joined: 21 May 2011
Posts: 5

PostPosted: Tue Jul 17, 2012 2:52 pm    Post subject: Reply with quote

n0 m3rcY wrote:
Code:
*(unsigned char*)(ulAddress + ucIndex) = ByteToWrite;

If you're not in a dll, you can't interact with an address that doesn't belong to your app, even if you virtualprotected it. You'll have to use WPM and get a handle for the process. Also, you're better off using a byte array and just writing that than having a thousand arguments in your function call, looks nicer too.

I'm assuming you're not using a dll because of the form.cpp snippet, however I can't see the entry point so I could be wrong Sad


I currently am doing this in a .dll project, CLR :c.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sun Aug 26, 2012 2:16 am    Post subject: Reply with quote

Check the returns of the WriteProcessMemory calls to see if its failing. If it is, try using VirtualProtectEx to unprotect the memory before trying to write to it.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites