[Windows编程] 监视DLL装载/卸载

Windows 驱动开发库里面提供了函数 LdrRegisterDllNotification, LdrUnregisterDllNotification , 可以让你监视进程装载/卸载DLL 的事件。 当你想在某个DLL被加载的时候Hook它的函数; 或者当你想在某个DLL推出之前做一些保存清理工作; 或者当你想阻止某个DLL 被加载(比如外挂) …. 这个机制正可以派上用场 。

以下是代码示例如何使用 LdrRegisterDllNotification, LdrUnregisterDllNotification监听DLL装载/卸载。

运行程序, 输出如下。可以证实以上代码监听了 mshtml.dll 的装载和卸载。 而且系统自动装载的其他DLL也被监视到。

Dll Loaded: C:/Windows/system32/mshtml.dllDll Loaded: C:/Windows/system32/msls31.dllDll Loaded: C:/Windows/system32/VERSION.dllDll Unloaded: C:/Windows/system32/mshtml.dllDll Unloaded: C:/Windows/system32/VERSION.dllDll Unloaded: C:/Windows/system32/msls31.dll

>> 原创文章的版权属于作者,,转载请注明出处和作者信息(), 谢谢。 <<

属于自己的不要放弃,已经失去的留作回忆。

[Windows编程] 监视DLL装载/卸载

相关文章:

你感兴趣的文章:

标签云: