开发者

injecting dll not working?

i have created a simple dll. I am injecting it in a process but it not showing message box.The code for mesg box is written in dll.

dll code:

//DLL TEST
#include <windows.h>

BOOL APIENTRY DllMain (HINSTANCE开发者_StackOverflow中文版 hInst, DWORD reason, LPVOID reserved) {
     if(callReason == DLL_PROCESS_ATTACH)
                   MessageBox(0, "Dll Injection Successful! ", "Dll Injector", MB_ICONEXCLAMATION | MB_OK);
     return TRUE;
}


First of all you don't posted the code which you use to inject the DLL or at least not described ich which way you do the injection.

Nevertheless your code have a large problem. You try to call MessageBox inside of DllMain. It is safe to use only functions from the Kernel32.dll and not form User32.dll which can not be initialized. On the MSDN you can read

Calling functions that require DLLs other than Kernel32.dll may result in problems that are difficult to diagnose. For example, calling User, Shell, and COM functions can cause access violation errors, because some functions load other system components.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜