| View previous topic :: View next topic |
| Author |
Message |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Thu Aug 07, 2008 4:45 pm Post subject: Strange DLL Name... |
|
|
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 |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Thu Aug 07, 2008 4:48 pm Post subject: |
|
|
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 |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Thu Aug 07, 2008 5:13 pm Post subject: |
|
|
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 |
|
 |
jackyyll Expert Cheater
Reputation: 0
Joined: 28 Jan 2008 Posts: 143 Location: here
|
Posted: Thu Aug 07, 2008 5:25 pm Post subject: |
|
|
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 |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Thu Aug 07, 2008 6:28 pm Post subject: |
|
|
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 |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Thu Aug 07, 2008 8:15 pm Post subject: |
|
|
| 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 |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Fri Aug 08, 2008 2:38 am Post subject: |
|
|
| Use a C compiler.
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Fri Aug 08, 2008 2:42 am Post subject: |
|
|
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 |
|
 |
rapion124 Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Mar 2007 Posts: 1095
|
Posted: Fri Aug 08, 2008 7:39 am Post subject: |
|
|
| 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 |
|
 |
|