I need to extent the compatibility of my application to 64 bit exe.
__int64 GetGameFunctionAddress(std::string GameFileExe, std::string Address)
{
// Get integer value address of the original function hook
#if defined(_WIN64)
/// code to emulate GetModuleHandleA on 64 executible
#else
return (__int64)GetModuleHandleA(GameFileExe.c_str()) + std::strtoul(Address.c_str(), NULL, 16);
#end if
}
this function get Address to pass to IDA for hook a function of a game.
I call this function with this line:
Output.MainFunctHookAddressInt = GetGameFunctionAddress(Output.ExeFile, GameInfo.MainFunctHookAddressInt);
AddressOfHookSoundFunction = Output.MainFunctHookAddressInt;
and in a second time I pass it to detours:
DetourAttach(&(LPVOID&)AddressOfHookSoundFunction, HookMainFunction);
Unfortunately "GetModuleHandleA" work only on 32 bit games, but I need to extend the compatibility to 64 bit games too.
So I need to fix my 'GetGameFunctionAddress' function to add 64 bit compatibility.
Can you help me please ?
Update:
One user tell me:
According to this GetModuleHandleA does not work to get the base address if the process is 64bit. Why does getting the base address using GetModuleHandle work?