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 


GetProcAddress inline hooking doesn't work?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
&Vage
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Jul 2008
Posts: 1053

PostPosted: Thu Nov 20, 2008 9:20 pm    Post subject: GetProcAddress inline hooking doesn't work? Reply with quote

Code:

DWORD LL = (DWORD)GetProcAddress(GetModuleHandle("kernel32.dll"), "GetProcAddress");
FARPROC (__stdcall * RealGetProcAddress)(HMODULE hModule, LPCSTR lpProcName) = GetProcAddress;

FARPROC WINAPI MyGPA(HMODULE hModule, LPCSTR lpProcName){
   MessageBox(NULL,"GetProcAddress() called!", NULL, NULL);
   return RealGetProcAddress(hModule, lpProcName);
}

void WINAPI MainT(){
   for(;;Sleep(10)){
      newmem = new char[10];
      memcpy(newmem, (void*)LL, 5);
      if(MemSnapshot != newmem){
         *(PBYTE)LL = 0xE9;
         *(PDWORD)(LL+0x01) = (DWORD)MyGPA - (DWORD)LL - 5;
         MessageBox(NULL,"Lul GG tried to overwrite my hookz :3", NULL, NULL);
      }
      delete[] newmem;
   }
}

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                )
{
   switch (ul_reason_for_call)
   {
   case DLL_PROCESS_ATTACH:
      hWnd = FindWindow("MapleStoryClass","MapleStory");
      if(hWnd){
         MessageBox(NULL, "OKIEZ WE GOT MS", NULL, NULL);
         GetWindowThreadProcessId(hWnd, &pid);
         hProc = OpenProcess(PROCESS_ALL_ACCESS, false, pid);
         FixMemEx(hProc, (LPVOID)LL, 5, PAGE_EXECUTE_READWRITE, NULL);
         *(PBYTE)LL = 0xE9;
         *(PDWORD)(LL+0x01) = (DWORD)MyGPA - (DWORD)LL - 5;
         memcpy(MemSnapshot, (void*)LL, 10);
         DisableThreadLibraryCalls(hModule);
         CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)&MainT, NULL, NULL, 0);
      }


HMM? Doesn't seem to be getting the address...
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Thu Nov 20, 2008 9:48 pm    Post subject: Reply with quote

Your code is so ugly...
Anyways, are you injecting the dll at the ad?

Btw:
Use memcmp to compare the hook changes... not !=...

_________________


Last edited by lurc on Thu Nov 20, 2008 9:50 pm; edited 1 time in total
Back to top
View user's profile Send private message
&Vage
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Jul 2008
Posts: 1053

PostPosted: Thu Nov 20, 2008 9:50 pm    Post subject: Reply with quote

lurc wrote:
Your code is so ugly...
Anyways, are you injecting the dll at the ad?


It was a template, I was in a hurry to see if this method would work or not. Yeah I am.
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Thu Nov 20, 2008 9:53 pm    Post subject: Reply with quote

LoadLibrary(_T("Kernel32.dll"))

instead of GetModuleHandle?

And btw, your basically gonna end up in an infinite loop... cause you're jumping back to GetProcAddress's addy, which is now patched to your hook Wink

_________________
Back to top
View user's profile Send private message
&Vage
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Jul 2008
Posts: 1053

PostPosted: Thu Nov 20, 2008 9:56 pm    Post subject: Reply with quote

lurc wrote:
LoadLibrary(_T("Kernel32.dll"))

instead of GetModuleHandle?

And btw, your basically gonna end up in an infinite loop... cause you're jumping back to GetProcAddress's addy, which is now patched to your hook Wink


Lol there is only 1 infinite loop, and I put it there on purpose.
Back to top
View user's profile Send private message
nog_lorp
Grandmaster Cheater
Reputation: 0

Joined: 26 Feb 2006
Posts: 743

PostPosted: Fri Nov 21, 2008 2:36 pm    Post subject: Reply with quote

LdrGetProcedureAddress(IN HMODULE ModuleHandle, IN PANSI_STRING FunctionName OPTIONAL, IN WORD Oridinal OPTIONAL, OUT PVOID *FunctionAddress );

Is called by GetProcedureAddress; if it is hooked then hopping GPA won't help you anyways, if it ISN'T hooked you should just use it instead Very Happy. Note, it doesn't return the function adress so you have to use the FunctionAddress parameter.

This method will also work for GetPixel, but you want to use the syscall NtGdiGetPixel:
COLORREF NtGdiGetPixel(HDC hDC, INT XPos, INT YPos)

_________________
Mutilated lips give a kiss on the wrist of the worm-like tips of tentacles expanding in my mind
I'm fine accepting only fresh brine you can get another drop of this yeah you wish
Back to top
View user's profile Send private message
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