c - 有效 PE 文件上的 STATUS_INVALID_IMAGE_HASH (0xc0000428)

标签 c windows winapi assembly internals

我尝试从另一个位置加载 DLL 文件“bcryptprimitives.dll”(在我的例子中,最初位于“C:\Windows\syswow64\bcryptprimitives.dll”下),使用以下代码片段:

LoadLibraryW(L"<altered path>\\bcryptprimitives.dll");

但是,在执行这行代码后,我收到以下错误:

enter image description here

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校验和。

enter image description here

如您所见:enter image description here

但是,LoadLibrary 仍然拒绝加载 DLL。 深入研究 ntdll 发现错误是从内核返回的:

enter image description here

这让我认为 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/

相关文章:

c - cc26xx 上的 TI sha256 返回错误值

C++ 预期类型说明符错误

windows - Tomcat 9 需要 1 分钟才能停止

windows - 通过 Windows 套接字发送大于 1 MB 的大数据,即使用 Send 函数

c++ - DLL 中的 XP 样式组合框

c++ - 如何添加透明 PNG 作为工具栏图标?

c - 嵌套模板 - OpenGL ES

c - 尝试使 C 中的指针无效时出现段错误

windows - 阻止非管理员在特定时间段内登录 Windows

winapi - Oracle OCI 函数 orlon 调用 SetUnhandledExceptionFilter