Windows 核心编程之Dll 延时加载
来源:互联网 发布:李天生sql视频教程 编辑:程序博客网 时间:2024/05/24 01:17
DLL和Lib自己建立个工程,自己生成吧
代码是控制台的
#include <iostream>#include <map>#include <Windows.h>#include <tchar.h>#include <process.h>#include <delayimp.h>#include "../../dynamic_DLL/dynamic_DLL/dynamic_DLL.h"//系统的lib#pragma comment(lib,"delayimp.lib")//自定义的lib#pragma comment(lib,"dynamic_DLL.lib")using namespace std;FARPROC WINAPI delayHook(unsigned dliNotify, PDelayLoadInfo pdli){switch (dliNotify) {case dliStartProcessing :// If you want to return control to the helper, return 0.// Otherwise, return a pointer to a FARPROC helper function// that will be used instead, thereby bypassing the rest // of the helper.break;case dliNotePreLoadLibrary :// If you want to return control to the helper, return 0.// Otherwise, return your own HMODULE to be used by the // helper instead of having it call LoadLibrary itself.break;case dliNotePreGetProcAddress :// If you want to return control to the helper, return 0.// If you choose you may supply your own FARPROC function // address and bypass the helper's call to GetProcAddress.break;case dliFailLoadLib : // LoadLibrary failed.// If you don't want to handle this failure yourself, return 0.// In this case the helper will raise an exception // (ERROR_MOD_NOT_FOUND) and exit.// If you want to handle the failure by loading an alternate // DLL (for example), then return the HMODULE for // the alternate DLL. The helper will continue execution with // this alternate DLL and attempt to find the// requested entrypoint via GetProcAddress.break;case dliFailGetProc :// GetProcAddress failed.// If you don't want to handle this failure yourself, return 0.// In this case the helper will raise an exception // (ERROR_PROC_NOT_FOUND) and exit.// If you choose you may handle the failure by returning // an alternate FARPROC function address.break;case dliNoteEndProcessing : // This notification is called after all processing is done. // There is no opportunity for modifying the helper's behavior// at this point except by longjmp()/throw()/RaiseException. // No return value is processed.break;default :return NULL;}return NULL;}PfnDliHook __pfnDliNotifyHook2 = delayHook ;PfnDliHook __pfnDliFailureHook2 = delayHook ;void IsDllExist(LPCSTR lpName){HMODULE hInt = GetModuleHandleA(lpName);if (NULL == hInt){printf("no\n");}else{printf("yes\n");}}char chDllName[]="dynamic_DLL.dll";int main(){IsDllExist(chDllName);MyAdd(1,2);IsDllExist(chDllName);__FUnloadDelayLoadedDLL2(chDllName);IsDllExist(chDllName);MyAdd(2,4);IsDllExist(chDllName);getchar();return 0;}
设置它,支持动态卸载DLL
添加lib是为了编译程序link时能找到导出的函数, Delay Loaded DLLs 表示哪些Dll支持延迟加载
- Windows 核心编程之Dll 延时加载
- Windows 核心编程之Dll注入
- Windows核心编程之DLL基础
- windows核心编程之DLL注入
- Windows核心编程:DLL基础
- Windows核心编程 DLL基础
- windows核心编程 DLL技术
- windows核心编程---DLL基础
- Windows核心编程Dll注入之远程线程
- 《Windows核心编程》之“DLL注入”(一)
- 《Windows核心编程》之”DLL注入“(二)
- 《Windows核心编程》之22远程线程注入DLL
- windows核心编程之DLL注入例子分析
- DLL 延时加载
- WINDOWS编程之DLL
- windows核心编程--DLL基本
- windows核心编程--DLL高级
- windows核心编程--DLL基本
- Easyui 多个标签联动
- jQuery bind命名空间
- oracle中监听程序当前无法识别连接描述符中请求服务 的解决方法
- javascript引擎PK:V8 vs Spidermonkey
- Java输出字符串的前n个字节
- Windows 核心编程之Dll 延时加载
- linux下发送外部邮件
- 如何在程序中嵌入google的V8 Javascript引擎
- java 得到项目路径
- dom4j
- V8 Javascript engine之所以快
- Python统计一个英文文档中各单词出现的行数
- IEEE754,浮点数的精度
- 常用的webservice接口