I am trying to create a DLL which can be executed with RunDLL32. I know that RunDLL32 is running correctly because if I execute the following command, it pops up a message box:
rundll32 printui.dll,PrintUIEntry
/.
However I cannot get it to execute a DLL that I created, which looks like this:
// dllmain.cpp : Defines the entry point for the DLL application.
#include "pch.h"
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
MessageBox(0, L"Hello1", 0, 0);
break;
case DLL_THREAD_ATTACH:
MessageBox(0, L"Hello2", 0, 0);
break;
case DLL_THREAD_DETACH:
MessageBox(0, L"Hello3", 0, 0);
break;
case DLL_PROCESS_DETACH:
MessageBox(0, L"Hello4", 0, 0);
break;
}
return TRUE;
}
The code compiles fine (In Visual Studio 2017, Release mode, x64) but when I execute
RunDLL32 MyDLL.dll
Nothing happens. There are no error messages, not output, and no message boxes. Why is that?