When I move after I injected this dll into wow, wow crashes with a memory error, the instruction at the offset XXXXXXXX referenced memory at XXXXXXXXX, the memory could not be read.Code:#include <windows.h> #include <cstring> DWORD DetourAddress = 0x760D90; DWORD dwOrig = DetourAddress+6; typedef struct callsturct { BYTE opCode; DWORD adress; }Tcallstruct; void __declspec(naked) NoFallDamage_Detour() { __asm { TEST DWORD PTR [ESI + 0x10], 0x1000 JNE RESET MOV ECX, DWORD PTR [EDI + 0x7C] CMP ECX, 0x38D JGE RETURN MOV DWORD PTR [ESI + 0x3C], ECX RETURN: PUSH dwOrig RET RESET: MOV ECX, DWORD PTR [EDI + 0x7C] MOV DWORD PTR [ESI + 0x3C], ECX JMP RETURN } } void nofalldmg(void) { Tcallstruct call={0xE8, PtrToUlong(NoFallDamage_Detour)}; DWORD oldprotect; VirtualProtectEx(GetCurrentProcess(),(LPVOID) DetourAddress, sizeof(call),PAGE_EXECUTE_READWRITE, &oldprotect); memcpy((PVOID)DetourAddress, &call, sizeof(call)); VirtualProtectEx(GetCurrentProcess(),(LPVOID) DetourAddress, sizeof(call), oldprotect, &oldprotect); } BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ , DWORD reason /* Reason this function is being called. */ , LPVOID reserved /* Not used. */ ) { switch (reason) { case DLL_PROCESS_ATTACH: nofalldmg(); break; case DLL_PROCESS_DETACH: break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; } /* Returns TRUE on success, FALSE on failure */ return TRUE; }
Edit:
I tried injecting the dll while ollydbg was attached to wow, olly told me that my dll is outside of the code segment of the PE or something like that, I'm quite sure my that's causing the crash, yet I've no Idea how to fix that issue :/.