另类DLL加载方法 —— PEAnalyais
本文详细介绍了PE文件解析方法,C++源码示例介绍如何解析PE文件从而打造自己的GetProcAddress,从资源文件中调用dll函数(无需释放文件)
转载请注明出处:http://blog.csdn.net/wangningyu/article/details/8716586
先看图:
代码如下:
1、测试DLL
// 定义函数指针typedef BOOL (__stdcall *MSGBOX)(char *,char *);void Test(HMODULE hModule){if(hModule){MSGBOX pMsgBox = (MSGBOX)MyGetProcAddress(hModule,"MsgBox");if(pMsgBox){pMsgBox("Hello World","Hi");}FreeLibrary(hModule);}}// 从文件加载获取函数地址void CPEAnalyaisDlg::OnBnClickedButton1(){Test(LoadLibraryByFile("MsgBox.dll"));}// 从资源文件加载获取函数地址void CPEAnalyaisDlg::OnBnClickedButton2(){Test(LoadLibraryByResource(IDR_DLL_MSGBOX,"EXE"));}
完整工程下载:
http://download.csdn.net/detail/wangningyu/5178695