I'm trying to install hook, but always game crashes with some weird exceptions
All what I do is:
1)Allocate memory
2)Write some instructions + first 5 bytes of EndScene + jmp back
3)Write jmp to allocated memory
Instructions:
Code:
string[] asm = new string[]
{
"pushfd",
"pushad",
"popad",
"popfd
}
(It is because earlier here was some logic that doesn't work)
Next I read first 5 bytes of EndScene and inject them after ASM bytecode:
Code:
Memory.Write(detourAddress + (uint)asmLength, Memory.Read(pEndScene, 5));
And then I write jump to (pEndScene + 5)
I write jump to my detour in pEndScene and game crashes with ACCESS_VIOLATION exception and gives me address of instruction at (pEndScene + 0xB)
I tried to fix that, swapped first 5 bytes of EndScene with my ASM bytecode, took 6 bytes and wrote jmp + nop, but it also gives exceptions
Last was also ACCESS_VIOLATION but now at (detourAddress + 0x76), although my code only 24-25 bytes length including jump back
Also in crash report I found that WoW uses D3D9 adapter.
What I did wrong?