You need to revisit what a pointer is. Adding multiple values to an offset does not dereference the value stored.
DWORD ammoAddress = *PDWORD( basePointer ) + 0x150;
Hey Community,
I've been trying to make a basic dll ammo hack for Assault Cube. Using Cheat Engine I found the basepointer that is also working everytime I use Cheat Engine to modify the Value but if im injecting my Dll file nothing is happening. :/
Here's my Code I hope someone can tell my what I did wrong(I'm total noob at hacking and C++ xD):
Code:#include <windows.h> DWORD FindAddress() { HMODULE hClient = GetModuleHandleA("ac_client.exe"); DWORD basePointer = (DWORD)hClient + 0x00109B74; DWORD ammoAddress = basePointer + 0x150; return ammoAddress; } void hackFunction(DWORD Address) { DWORD* pAddress = (DWORD*)Address; *pAddress = 1337; } DWORD WINAPI HackThread(LPVOID unused) { DWORD targetAddress = NULL; targetAddress = FindAddress(); BOOL hackEnabled = false; for (;;) { if (GetAsyncKeyState(VK_F1)) { if (hackEnabled == true) { hackEnabled = false; } else { hackEnabled = true; } Sleep(50); } if (hackEnabled == true) { hackFunction(targetAddress); } } } BOOL WINAPI DllMain(HINSTANCE mod, DWORD Attached, LPVOID res) { switch (Attached) { case DLL_PROCESS_ATTACH: MessageBoxA(0, "Loaded!", "Info", 0); CreateThread(0, 0, &HackThread, 0, 0, 0); break; case DLL_PROCESS_DETACH: MessageBoxA(0, "Not Loaded", "Info", 0); break; } return TRUE; }
You need to revisit what a pointer is. Adding multiple values to an offset does not dereference the value stored.
DWORD ammoAddress = *PDWORD( basePointer ) + 0x150;
D@nny (08-23-2016)
Thanks I will
Do not create a thread in DllMain . if u want create a thread .Use SetWindowLong or SetWindowsHookEx to hook the windowproc , then you can post a message to do it.
And you do not need for(;; ) to catch the keyboard message , do it on your windowproc function.
Last edited by xjay_cc; 09-16-2016 at 04:40 AM.
Best practice is to not do anything in DllMain, because libraries may be loaded as dependency for other libraries, or it might be loaded just for a single function call, so anything automatically happening upon loading is not something that is wanted.
However, since this is for gamehacking it doesn't matter, noone will ever be using your dll without intending for it to start up shit when it gets loaded(and the game itself won't be calling them functions for you)
~ Hell_Demon
Ah we-a blaze the fyah, make it bun dem!
You know ahead of time which libraries will be loaded and which libraries you need loaded. It's already been pointing out that you do not cause a dead lock simply by creating a thread in the main, which is perfectly fine. Yes it's unorthodox to do it this way, where as libraries are merely meant to export functions for the main module but this is "hacking" after-all and we can not be completely orthodox.
since this is for gamehacking it doesn't matter, noone will ever be using your dll without intending for it to start up shit when it gets loaded(and the game itself won't be calling them functions for you)