I\'m creating a little dll to use in a DLL-INJECTION POC (proof-of-concept). I\'m using codeblocks\' c++ ide.
My dll\'s main (dllmain) looks like this:
See this question to read about the huge number of limitations in DllMain. It's not just security problems. Anything exported by user32 falls into this category.
In other words, you cannot use MessageBox in DllMain. Use something like OutputDebugString instead, which is in kernel32 and does not display any UI.
There's a lot of useful stuff that just can not be done in DllMain. Read all relating articles in Raymond Chen's blog for more info. Can't even delay execution with SetTimer, because that function is in user32.dll, and that library may not be loaded yet.