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 


Strange DLL Name...

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Thu Aug 07, 2008 4:45 pm    Post subject: Strange DLL Name... Reply with quote

I wanted to see if my c++ is still working so I made a postmessageA bypass. The function name is PostMessageX But it turned out as:
?PostMessageX@@YA_NPAUHWND__@@IIJ@Z

I tested the function and it works o.o so why is it turning up all weird?

Heres the files:
Code:

#include "stdafx.h"
#include "hook.h"

BOOL APIENTRY DllMain( HANDLE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                )
{
    switch (ul_reason_for_call)
   {
      case DLL_PROCESS_ATTACH:
      case DLL_THREAD_ATTACH:
      case DLL_THREAD_DETACH:
      case DLL_PROCESS_DETACH:
         break;
    }
    return TRUE;
}

DWORD PMA = (DWORD)GetProcAddress(LoadLibrary("USER32.DLL"), "PostMessageA")+5;
_declspec(naked) bool PostMessageX(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) {
   _asm {
      mov edi, edi
      push ebp
      mov ebp, esp
      jmp[PMA]
   }
}


and hook.h

Code:
#ifdef HOOK_EXPORTS
#define HOOK_API __declspec(dllexport)
#else
#define HOOK_API __declspec(dllimport)
#endif

__declspec(dllexport) bool PostMessageX(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);


And yes I know... I suck horribly at C++.
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Thu Aug 07, 2008 4:48 pm    Post subject: Reply with quote

What do you mean it "turned out as ?PostMessageX@@YA_NPAUHWND__@@IIJ@Z"?
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Thu Aug 07, 2008 5:13 pm    Post subject: Reply with quote

I made the function name PostMessageX Right?

When I compiled it and tryed it using the call to PostMessageX it didn't work and said cannot find entry.

SO I used a dll function export viewer. and saw that the function was baddly messed up like that.
Back to top
View user's profile Send private message
jackyyll
Expert Cheater
Reputation: 0

Joined: 28 Jan 2008
Posts: 143
Location: here

PostPosted: Thu Aug 07, 2008 5:25 pm    Post subject: Reply with quote

I think this
Code:

#ifdef HOOK_EXPORTS
#define HOOK_API __declspec(dllexport)
#else
#define HOOK_API __declspec(dllimport)
#endif

__declspec(dllexport) bool PostMessageX(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);


should be

Code:

#ifdef HOOK_EXPORTS
#define HOOK_API __declspec(dllexport)
#else
#define HOOK_API __declspec(dllimport)
#endif

__declspec(naked) bool PostMessageX(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
Back to top
View user's profile Send private message AIM Address MSN Messenger
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Thu Aug 07, 2008 5:59 pm    Post subject: Reply with quote

It's because C++ decorates the export names.

Look at this: http://support.microsoft.com/kb/126845
Back to top
View user's profile Send private message MSN Messenger
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Thu Aug 07, 2008 6:28 pm    Post subject: Reply with quote

Alternatively, you can create the DLL in a new project and compile it (without hook.h). And then you can use this code to use PostMessageX:

Code:

typedef bool(*PostMessageXPtr)(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
PostMessageXPtr LibMainPostMessageX = (PostMessageXPtr)GetProcAddress(LoadLibrary("hook.dll"), "PostMessageX");
//call LibMainPostMessageX with appropriate parameters

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Thu Aug 07, 2008 8:15 pm    Post subject: Reply with quote

jackyyll wrote:
I think this
Code:

#ifdef HOOK_EXPORTS
#define HOOK_API __declspec(dllexport)
#else
#define HOOK_API __declspec(dllimport)
#endif

__declspec(dllexport) bool PostMessageX(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);


should be

Code:

#ifdef HOOK_EXPORTS
#define HOOK_API __declspec(dllexport)
#else
#define HOOK_API __declspec(dllimport)
#endif

__declspec(naked) bool PostMessageX(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);


Wrong. Tryed that before I posted. C++ gave me an error.
Back to top
View user's profile Send private message
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Fri Aug 08, 2008 2:38 am    Post subject: Reply with quote

Use a C compiler.
Back to top
View user's profile Send private message MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Fri Aug 08, 2008 2:42 am    Post subject: Reply with quote

You created the ifdef then you didn't use it..?

You should be doing:

Code:
#ifdef HOOK_EXPORTS
#define HOOK_API __declspec(dllexport)
#else
#define HOOK_API __declspec(dllimport)
#endif

HOOK_API bool __stdcall PostMessageX( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );


Then, in your .cpp file:

Code:
HOOK_API bool __stdcall PostMessageX( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
//... code here...
}


Also be sure that you add HOOK_API to the preprocessor settings.
Project -> Properties -> Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
rapion124
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Fri Aug 08, 2008 7:39 am    Post subject: Reply with quote

You need to include a .def file in your project to stop C++ from decorating the exported functions, or you need to add EXTERN "C."
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