C++ DLL Problem - Program Crashing
So basically i've made a dll ready to inject into Garry's Mod (hl2.exe) but whenever i inject it into hl2.exe, hl2.exe crashes!
Could someone please tell me why my dll is making the program crash?
Here's my script for the dll:
Code:
#include <windows.h>
DWORD Base = (DWORD)GetModuleHandle((LPCTSTR)"client.dll") + (DWORD)0x5B5340;
DWORD* Address = (DWORD*)Base;
void mainthread() {
while(1) {
*Address = 2;
Sleep(250);
}
}
BOOL APIENTRY DllMain(HINSTANCE hDll, DWORD callReason, LPVOID lpReserved) {
if(callReason == DLL_PROCESS_ATTACH) {
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&mainthread, 0, 0, 0);
MessageBoxA(NULL,"Hack Injected Successfully!", "DLL Injection" ,NULL);
}
return 1;
}
Thanks in advance!
I'm not 100% percent sure, but I think Garry's Mod shuts down if it detects anything being edited from an exterior?
I'm not sure though.