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 


[C++ and Delphi] Help with PostMessage Unhook

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

Joined: 06 Nov 2009
Posts: 9

PostPosted: Sun Nov 15, 2009 8:47 am    Post subject: [C++ and Delphi] Help with PostMessage Unhook Reply with quote

EXE:
Code:
...
...
implementation
{$R *.dfm}
function BulhufasPostMessageA(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): BOOL; stdcall; external 'BulhufasBypass.dll' name 'BulhufasPostMessageA';
...
...

BulhufasBypass.dll:
Code:

#include "stdafx.h"
#include "windows.h"
#include "winable.h"
#define EXPORTFUNC __declspec(dllexport)

DWORD dwOriginalAPI = NULL;
HMODULE hUser32;
...
...
__declspec(naked) EXPORTFUNC BOOL WINAPI BulhufasPostMessageA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
   dwOriginalAPI = (DWORD)GetProcAddress(hUser32, "PostMessageA");
   dwOriginalAPI += 5;
   __asm
    {
        mov    edi, edi
        push   ebp
        mov    ebp, esp
        jmp    dword ptr ds:[dwOriginalAPI]
    }
}
...
...
...
...
BOOL APIENTRY DllMain( HANDLE hModule,
                       DWORD  dwReason,
                       LPVOID lpReserved
                )
{
   if ( dwReason == DLL_PROCESS_ATTACH )
   {
      hUser32 = GetModuleHandle("user32.dll");
      if ( hUser32 == INVALID_HANDLE_VALUE )
         hUser32 = LoadLibrary("user32.dll");
      hGDI32 = GetModuleHandle("gdi32.dll");
      if ( hGDI32 == INVALID_HANDLE_VALUE )
         hGDI32 = LoadLibrary("gdi32.dll");
   }
   return TRUE;
}


Error: Windows says that couldn't find the entry point of BulhufasPostMessageA in BulhufasBypass.dll

Can anyone help me?

PS: I already used DLL Export Viewer and BulhufasPostMessageA is there.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25794
Location: The netherlands

PostPosted: Sun Nov 15, 2009 9:25 am    Post subject: Reply with quote

Are you sure BulhufasPostMessageA is in the dll export and not something like "BulhufasPostMessageA@s4889" ?

If it does have such a name, rename from .cpp to .c or use a .def file to define the exportnames

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
bulhufas
How do I cheat?
Reputation: 0

Joined: 06 Nov 2009
Posts: 9

PostPosted: Sun Nov 15, 2009 4:54 pm    Post subject: Reply with quote

How do I use a .DEF file?
Back to top
View user's profile Send private message
iPromise
Grandmaster Cheater
Reputation: -1

Joined: 27 Jun 2009
Posts: 529
Location: Canada

PostPosted: Wed Nov 18, 2009 8:35 pm    Post subject: Solution Reply with quote

To write a .DEF file

Open notepad, first put:

Code:

LIBRARY "BulhufasBypass.dll"


Under that put:

Code:

EXPORTS

BulhufasPostMessageA


So you'll have this:

Code:

LIBRARY "BulhufasBypass.dll"

EXPORTS

BulhufasPostMessageA


Go to File -> Save As:

Change "Text Documents (*.txt)" to "All Files". Name it as Bulhufas.DEF and save it in your projects main folder (Make sure its in the .dll folder and NOT in the Debug folder).

Now go to your Visual C++ Compiler, Project --> YourProject Properties --> Configuration Properties --> Linker --> Input, go to "Module Definition File: " and put Bulhufas.DEF.

About your hookhop

I think you should do this instead:

Code:

DWORD PostMessage_Address = (DWORD) GetProcAddress(GetModuleHandleA("user32.dll"), "PostMessage") + 5;

__declspec(void) BOOL PostMessage(HWND hWnd,  UINT Msg,  WPARAM wParam, LPARAM lParam)
{
   __asm {
   mov edi, edi
   push ebp
   push esp, ebp
   jmp [PostMessage_Address]
   }
}



Tell me if this works.
Back to top
View user's profile Send private message MSN Messenger
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