Windows如何调用新创建的DLL的入口函数

1.Debug the MyNewDll project, try to know the calling style inwindows.

Windows如何调用新创建的DLL的入口函数_第1张图片

1. Calling stack

In SecMain.exe!SecNt32PeCoffRelocateImage, I call the LoadLibrary tocall the library.

In MyNewDll.dll!DllMain, it call the DllMain function in my MyNewDllproject.

 

Windows如何调用新创建的DLL的入口函数_第2张图片

2.Calling from _DllMainCRTStartup to __DllMainCRTStartup

 

Windows如何调用新创建的DLL的入口函数_第3张图片

3.Calling from __DllMainCRTStartup to DllMain

From the page 2-3, we can see the function name is hard code inwindows code, so you must use these names to make windows can find the functionit want to call when call LoadLibrary function.

 

In Our code, we just implement the _DllMainCRTStartup function andreturn TRUE to make the LoadLibrary function always return success.

 

Windows如何调用新创建的DLL的入口函数_第4张图片

4. PE header info (High light the entry point field)

Also in our test, when the function name is not _DllMainCRTStartupin PE's  Entry Point field, it also canbe call in. so in windows, it not hard code about the entry point functionname. I think it get the entry point name from this filed, so we just registerthe entry function name here to make windows can call in.

你可能感兴趣的:(Windows如何调用新创建的DLL的入口函数)