seo 发表于 2022-3-9 11:09:40

【ntdll】LdrSetDllManifestProber回调Dll加载 [复制链接]

ntdll.dll!LdrSetDllManifestProber,我相信很多人听都没有听说过这个命令,实际上,我们用这个命令只是为了干一件事:替换LdrpManifestProberRoutine。
在系统初始化DllMain的时候(本质上是走到LdrpWalkImportDescriptor的时候),它会检查LdrpManifestProberRoutine是否有效,然后调用LdrpManifestProberRoutine,对此部分的预原注释是: Probe the DLL for its manifest. Some details are omitted(探测 DLL 的清单。 省略了一些细节)
LdrSetDllManifestProber是直接将LdrpManifestProberRoutine替换为我们的子程序,当调用LdrpWalkImportDescriptor时,便会触发回调,如图:
https://att.125.la/data/attachment/forum/202201/22/143526ek2usrlk2qdsnnw0.jpg
LdrpManifestProberRoutine原来的代码比较复杂(它原来的地址是BasepProbeForDllManifest),实际上这个命令原来的操作是调用RtlCreateActivationContext来Create the activation context。我测试了一下,没有成功复现BasepProbeForDllManifest,现在的例子可能会造成程序不稳定,就这样了吧!大佬拿去玩吧。
虽然都是实现Dll加载回调,但是这个的实现原理和LdrRegisterDllNotification有本质上的区别,具体我不展开说了,自己去了解吧!
            

            
            点我下载
            (已有 5 次下载)
            

            
            
      

      
               
            引用模块
            
            无
页: [1]
查看完整版本: 【ntdll】LdrSetDllManifestProber回调Dll加载 [复制链接]