Windows 核心编程之Dll 延时加载

这篇博客探讨了Windows核心编程中的DLL延迟加载技术。通过创建工程并生成DLL与LIB,作者展示了如何实现动态卸载DLL,并解释了添加LIB文件在编译链接阶段确保找到导出函数的重要性。同时,提到了Delay Loaded DLLs的概念,指出哪些DLL可以支持这种加载方式。
摘要由CSDN通过智能技术生成

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 LoadLibra
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值