 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Thu Dec 06, 2007 7:44 pm Post subject: Error with PostMessageX |
|
|
I'm gonna make a personal AC (i dont need full bot) using pmx.dll
I can load it and GetProcAddress but when i call i get a error violation
Code: | #define WINDOWS_LEAN_AND_MEAN
#include <windows.h>
#define ID_TIMER 2
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
typedef bool (__cdecl *MYPROC)(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
static char sClassName[] = "MyClass";
static HINSTANCE zhInstance = NULL;
HMODULE hDll;
MYPROC hhPostMessageA;
bool tbool = FALSE;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
int nCmdShow) {
WNDCLASSEX WndClass;
HWND hwnd;
MSG Msg;
zhInstance = hInstance;
WndClass.cbSize = sizeof(WNDCLASSEX);
WndClass.style = NULL;
WndClass.lpfnWndProc = WndProc;
WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
WndClass.hInstance = zhInstance;
WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
WndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
WndClass.lpszMenuName = NULL;
WndClass.lpszClassName = sClassName;
WndClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&WndClass)) {
MessageBox(0, "Error Registering Class!", "Error!", MB_ICONSTOP | MB_OK);
return 0;
}
hwnd = CreateWindowEx(WS_EX_STATICEDGE, sClassName, "Window", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
CW_USEDEFAULT,
100, 175, NULL, NULL, zhInstance, NULL);
if(hwnd == NULL) {
MessageBox(0, "Error Creating Window!", "Error!", MB_ICONSTOP | MB_OK);
return 0;
}
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&Msg, NULL, 0, 0)) {
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
switch(Message) {
case WM_CREATE:
if(!RegisterHotKey(hwnd, 1, MOD_CONTROL, VK_F11))
MessageBox(hwnd, "Hotkey F11 failed!", "Error", MB_OK);
if(!RegisterHotKey(hwnd, 2, MOD_CONTROL, VK_F12))
MessageBox(hwnd, "Hotkey F12 failed!", "Error", MB_OK);
hDll = LoadLibrary("hookHop.dll");
if(hDll == 0)
MessageBox(hwnd, "PMX.dll failed to load", "Error", MB_OK);
hhPostMessageA = (MYPROC)GetProcAddress(hDll, "hhPostMessageA");
if ( hhPostMessageA != NULL)
{
tbool = TRUE;
}
if(!FreeLibrary(hDll))
MessageBox(hwnd, "Error in FreeLibrary", "Error", MB_OK);
break;
case WM_HOTKEY:
if(wParam == 1)
SetTimer(hwnd, ID_TIMER, 2000, NULL);
if(wParam == 2)
KillTimer(hwnd, ID_TIMER);
break;
case WM_TIMER:
if(wParam == ID_TIMER)
{
if(tbool == TRUE)
{
(hhPostMessageA)(NULL, WM_KEYDOWN, 41,0x00);
}
}
break;
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
KillTimer(hwnd, ID_TIMER);
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, Message, wParam, lParam);
}
return 0;
}
|
_________________
Last edited by HomerSexual on Thu Dec 06, 2007 8:20 pm; edited 2 times in total |
|
Back to top |
|
 |
sponge I'm a spammer
Reputation: 1
Joined: 07 Nov 2006 Posts: 6009
|
Posted: Thu Dec 06, 2007 7:49 pm Post subject: |
|
|
Use hookHop. PMX is a bloated piece of shit. Not sure what C++ needs to import w/out LoadLibrary... but I have included a lib just in case.
_________________
|
|
Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Thu Dec 06, 2007 8:02 pm Post subject: |
|
|
Edited code to reflect hookHop and hhPostMessageA
The program crashes...
_________________
|
|
Back to top |
|
 |
sponge I'm a spammer
Reputation: 1
Joined: 07 Nov 2006 Posts: 6009
|
Posted: Thu Dec 06, 2007 8:04 pm Post subject: |
|
|
provide a binary... and shouldn't there be another way to link it... not load dll on runtime.. nvm about the typedef thing. i thought myproc = hhpostmessageA... but you call it as (hhpostmessageA) ...
not really sure... i dont know c well.
_________________
Last edited by sponge on Thu Dec 06, 2007 8:07 pm; edited 1 time in total |
|
Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Thu Dec 06, 2007 8:07 pm Post subject: |
|
|
Code: | typedef bool (__cdecl *MYPROC)(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
hDll = LoadLibrary("hookHop.dll");
if(hDll == 0)
MessageBox(hwnd, "PMX.dll failed to load", "Error", MB_OK);
hhPostMessageA = (MYPROC)GetProcAddress(hDll, "hhPostMessageA");
if ( hhPostMessageA != NULL)
{
tbool = TRUE;
}
if(!FreeLibrary(hDll))
MessageBox(hwnd, "Error in FreeLibrary", "Error", MB_OK);
|
That defines MYPROC as hWnd, Msg, wParam, lParam then defines hhPostMessageA as type MYPROC and then i call (hhPostMessageA)
_________________
|
|
Back to top |
|
 |
sponge I'm a spammer
Reputation: 1
Joined: 07 Nov 2006 Posts: 6009
|
Posted: Thu Dec 06, 2007 8:08 pm Post subject: |
|
|
Provide a binary? or just try stepping the code yourself... i dont have a compiler installed.
I am in no terms a C expert but just some quick googling... could you not do this?
Quote: |
C and C++
Make sure you include Example.lib file(assuming that Example.dll is generated) in the project (Add Existing Item option for Project!)before static linking. The file Example.lib is automatically generated by the compiler when compiling the DLL. Not executing the above statement would cause linking error as the linker would not know where to find the definition of AddNumbers. You also need to copy the DLL Example.dll to the location where the .exe file would be generated by the following code.
Code: | #include <windows.h>
#include <stdio.h>
// Import function that adds two numbers
extern "C" __declspec(dllimport) double AddNumbers(double a, double b);
int main(int argc, char **argv)
{
double result = AddNumbers(1, 2);
printf("The result was: %f\n", result);
return 0; |
|
_________________
|
|
Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Thu Dec 06, 2007 8:17 pm Post subject: |
|
|
Unhandled exception at 0x1000103a in AutoClickMaple.exe: 0xC0000005: Access violation.
Picture attached of call stack frame error
Description: |
|
Filesize: |
18.78 KB |
Viewed: |
8983 Time(s) |

|
_________________
|
|
Back to top |
|
 |
sponge I'm a spammer
Reputation: 1
Joined: 07 Nov 2006 Posts: 6009
|
|
Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Thu Dec 06, 2007 8:25 pm Post subject: |
|
|
Sponge, It's a Memory Error
You're functions are reading executable memory not readable. It's not vista compat?
_________________
|
|
Back to top |
|
 |
sponge I'm a spammer
Reputation: 1
Joined: 07 Nov 2006 Posts: 6009
|
Posted: Thu Dec 06, 2007 8:27 pm Post subject: |
|
|
It should be... the stack isn't a memory read violation. as far as i'm concerned... API header for vista is still the same. hookHop only reads within its own module.
once again a binary wouuld be most helpful in order to debug. because of the fact that my C knowledge is limited.
_________________
|
|
Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Thu Dec 06, 2007 8:30 pm Post subject: |
|
|
uploaded exe on top about 15 minutes ago?
_________________
|
|
Back to top |
|
 |
sponge I'm a spammer
Reputation: 1
Joined: 07 Nov 2006 Posts: 6009
|
Posted: Thu Dec 06, 2007 8:32 pm Post subject: |
|
|
blankrider wrote: | uploaded exe on top about 15 minutes ago? |
wow... i didnt even show up until i saw this post and even then i had to refresh like 20 times i cant open it in olly... is your compiler making it only for vista... or does debug info screw stuff up...
This isn't even a crash... the windows loader won't load it.
_________________
|
|
Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Thu Dec 06, 2007 8:43 pm Post subject: |
|
|
There are 2 errors
in FreeLibrary and my calling of hhPostMessageA in WM_TIMER
_________________
|
|
Back to top |
|
 |
sponge I'm a spammer
Reputation: 1
Joined: 07 Nov 2006 Posts: 6009
|
Posted: Thu Dec 06, 2007 8:48 pm Post subject: |
|
|
I really don't know what the problem is... first off mine won't even run... and i've tested my dll and it works perfectly. others have used it too.
_________________
|
|
Back to top |
|
 |
fl00d Newbie cheater
Reputation: 0
Joined: 21 Nov 2007 Posts: 14
|
Posted: Thu Dec 06, 2007 11:49 pm Post subject: |
|
|
I'm getting the same error...I'm also using function pointers to the hhPostMessageA. I'm gonna try to import the exports @ runtime 'cause usually these errors are because of incorrect pointer handling. I'll let you know...
|
|
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
|
|