 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Skygen How do I cheat?
Reputation: 0
Joined: 10 Mar 2013 Posts: 2
|
Posted: Sun Mar 31, 2013 3:53 pm Post subject: Module Handle Problem |
|
|
Code: |
HMODULE GetModuleHandleExtern( char *szModuleName, DWORD dwProcessId )
{
if( !szModuleName || !dwProcessId ) { return NULL; } // invalid input
HANDLE hSnap = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, dwProcessId );
if( hSnap == INVALID_HANDLE_VALUE ) { return NULL; }
MODULEENTRY32 me;
me.dwSize = sizeof( MODULEENTRY32 );
if( Module32First( hSnap, &me ) ) // we go now
{
while( Module32Next( hSnap, &me ) ) // through all modules in the target process
{
if( !strcmp( me.szModule, szModuleName ) ) // is this the model we are looking for?
{
CloseHandle( hSnap );
return me.hModule; // this is our module, return it.
}
}
}
CloseHandle( hSnap );
return NULL; // counldn't find module
}
DWORD D2Client = (DWORD)GetModuleHandleExtern("Game.dll", ProcessId);
DWORD d, ds;
VirtualProtect((void*)(D2Client+0x465257), 3, PAGE_EXECUTE_READWRITE, &d);
//unsigned char newValue = 0xE9;
BYTE bytesJump1 = 0xE9;
WriteProcessMemory(h1, (void*)(D2Client+0x465257), (void*)&bytesJump1, 3, NULL);
VirtualProtect((void*)(D2Client+0x465257),3,d,&ds); |
My code can find Module Handle only if game has it (.dll). Why?
|
|
Back to top |
|
 |
TsTg Master Cheater
Reputation: 5
Joined: 12 Dec 2012 Posts: 340 Location: Somewhere....
|
Posted: Sun Mar 31, 2013 6:06 pm Post subject: |
|
|
Because TH32CS_SNAPMODULE is assigned to the CreateToolhelp32Snapshot function, you can use TH32CS_SNAPALL instead, this one snaps all processes, threads and dlls, the first snaps only link libraries.(if you specify a process id value, that process is the only one included in the snap, otherwise it will include all processes)
and if you want to find a process and not a library loaded into it, replace Module32Next and Module32First, with Process32Next and Process32First.
also replace MODULEENTRY32 structure with PROCESSENTRY32, also set dwProcessId value to zero.
you can read about the tool help usage with all other functions and structures here:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms686832
|
|
Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Mon Apr 01, 2013 7:13 am Post subject: |
|
|
The game has to have the DLL loaded in it in order for it to be found.
There is nothing wrong with what the code is doing, that is just how it works.
If the module isn't loaded, the API has nothing to find, it can't assume what Game.dll you are referring to.
_________________
- Retired. |
|
Back to top |
|
 |
|
|
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
|
|