Original Post
Background info: I'm using C++ and Visual Studio 2008.
My program (Window Detective) injects code into remote processes. This code works fine in debug but crashes in release mode. I think it is because the generated assembly uses absolute addresses for function calls, which will not work in a remote process.
Assuming that this is indeed the cause of the crashing, is there any way i can force the compiler to use relative addressing? More specifically, i want a #pragma switch rather than a compiler or linker option. That way i can use this option only for the function that will be injected into the remote thread.
My program (Window Detective) injects code into remote processes. This code works fine in debug but crashes in release mode. I think it is because the generated assembly uses absolute addresses for function calls, which will not work in a remote process.
// Code snippet from release build01C30013 push edi 01C30014 push 43CFDCh 01C30019 call dword ptr ds:[43B050h] 01C3001F mov edi,dword ptr [esp+20h] 01C30023 lea ebp,[edi+54h] 01C30026 push ebp 01C30027 mov ebx,eax 01C30029 call dword ptr ds:[43B148h] // Code snippet from debug build00411036 mov eax,dword ptr [inj] 00411039 add eax,0Ch 0041103C push eax 0041103D mov ecx,dword ptr [inj] 00411040 mov edx,dword ptr [ecx] 00411042 call edx 00411044 mov dword ptr [dll],eax 00411047 cmp dword ptr [dll],0 Assuming that this is indeed the cause of the crashing, is there any way i can force the compiler to use relative addressing? More specifically, i want a #pragma switch rather than a compiler or linker option. That way i can use this option only for the function that will be injected into the remote thread.