I want to call a function in a program. I do this from a DLL entry point. I opened the program in IDA together with its .pdb file. This is what the function looks like according to IDA:
void __fastcall Logger::log(LogLevel lvl, const char *msg)
(LogLevel is just an enum)
The parameters are obvious and not the problem.
But the problem is that I propably have the wrong address of it (I assume I need to get the address of the class first?) IDA gave me:
.text:00000001400981A0
for the function. This is what I tried:
BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved) {
if (dwReason == DLL_PROCESS_ATTACH) {
typedef void __fastcall func(int lvl, const char* msg);
func* loggerLog = (func*)(GetModuleHandle(0) + 0x1400981A0);
loggerLog(0, "test 123");
}
return 1;
}
Doing this the program just closes, no error.
I'm not sure where to start. What is the correct way and address? How would I get the address I need?