3

This code compiled and worked a few years ago. It doesn't work anymore, and I'm still using detours v2.1, I've only upgraded the compiler from (I believe) VS 2010 to now (2013 & 2015).

Note that I'm adding a hook at the middle of a function, not at the start.

This is what detour would do when it used to work:

 1. adds a jmp to address 0x1000 [previously this was a mov ebx, 5]
 2. mov eax, 1 // my code
 3. mov ebx, 5 
 4. jump back at address 0x1004

Now what happens is

 1. adds a jmp to address 0x1000, [ this still works]
 2. mov eax, 1 // my code
 3. jump back at address 0x1000
 4. **Infinite loop.**

hook:

void __declspec(naked) New_Fn()
{
    __asm MOV EAX, 1
    JMP MidFun
}

DetourAttach(&(PVOID&)MidFun, New_Fn);

Any ideas?

Gam
  • 1,254
  • 1
  • 9
  • 18
  • Interesting, it looks like the compiler is definetely messing up on the return jmp. I also have some old code using detours lying around, but i have not compiled it in ages now... If i find it i will try it on VS2015 and see if i get the same issues. I will bookmark this question, out of interest, but for now i have no real idea, except maybe optimization going wrong? – Richard Tyregrim Jun 14 '16 at 08:35

0 Answers0