My question is the same as this one:
https://stackoverflow.com/questions/6631357/calling-functions-in-a-dll-loaded-by-another-process
I'm trying to call the Test function that is currently on a DLL load in a different process.
BOOL APIENTRY DllMain(HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
OutputDebugStringW(L"Loading Library...");
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
extern "C" __declspec(dllexport) LPCWSTR Test()
{
DWORD pid= GetCurrentProcessId();
WCHAR buf[255];
wsprintf(buf, L"Current PID: %d", pid);
OutputDebugString(buf);
return std::to_wstring(pid).c_str();
}
I already learned how to do an IPC mechanism using SendMessage and a window that can handle the messages received.
I'm trying to understand the other options described in that post, like CreateRemoteThread or named pipe.
Would like to ask if someone could share a working example for this use case.