我尝试从另一个位置加载 DLL 文件“bcryptprimitives.dll”(在我的例子中,最初位于“C:\Windows\syswow64\bcryptprimitives.dll”下),使用以下代码片段:
LoadLibraryW(L"<altered path>\\bcryptprimitives.dll");
但是,在执行这行代码后,我收到以下错误:
C:\Program Files (x86)\Notepad++\bcryptprimitives.dll 未设计为在 Windows 上运行,或者包含错误。尝试使用原始安装介质再次安装该程序,或者联系您的系统管理员或软件供应商以获得支持。错误状态 0xc0000428。
我在以下字典中搜索了 0xc0000428 NTSTATUS:https://msdn.microsoft.com/en-us/library/cc704588.aspx
显然这个状态意味着STATUS_INVALID_IMAGE_HASH
。
这个错误一开始是有道理的,因为我将图像 PE header 中的“LoaderFlags”字段从 0x00000000 更改为 0x00000001(这不需要影响任何内容,因为该字段已弃用),但即使我更改了该字段,我修正了PE校验和。
但是,LoadLibrary 仍然拒绝加载 DLL。
深入研究 ntdll
发现错误是从内核返回的:
这让我认为 DLL 是经过某种方式签名的,并且内核会检查 DLL 是否被更改。 那么就我而言,如何从另一个位置加载此 DLL 并删除符号检查?
最佳答案
如果 DLL 已签名,则更改文件中的单个字节将使签名无效。看来您正是通过修改 PE header 来做到这一点。
This blog post可能有兴趣更深入地了解该技术的工作原理:
Code Integrity is a feature that improves the security of the operating system by validating the integrity of a driver or system file each time it is loaded into memory. Code Integrity detects whether an unsigned driver or system file is being loaded into the kernel, or whether a system file has been modified by malicious software that is being run by a user account with administrative permissions. On x64-based versions of the operating system, kernel-mode drivers must be digitally signed.
关于c - 有效 PE 文件上的 STATUS_INVALID_IMAGE_HASH (0xc0000428),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38367847/