我可以有任何方法来检测驱动程序签名策略状态吗?
Can I have any way to detect the Driver Signing Policy status?
我有一个修改过的驱动程序,当驱动程序签名被禁用时必须安装,所以我想检测这个状态以提醒用户重新启动到SafeMode。我尝试了这个命令:Bcdedit.exe -set TESTSIGNING OFF
,但是失败了,提示
设置元素数据出错。受安全启动策略保护,不能修改和删除。
嗯. .有什么办法可以做到吗?
————————
PS:事实上,我的笔记本型号是MSI GS70 2PE。我不认为这是一个便宜的,即使是最新发布的GS73也不能支持完整的win10手势。它支持Windows10,但微星确实没有发布最新的驱动程序。如果只是我自己修改和使用,那就不值一提了。但是,我想在论坛上分享它,以帮助其他一般用户使用。
我做错了什么吗?我不明白为什么有人在谈论别的事情。
使用以下代码检测是否启用TESTSIGNING
:
#include <Winternl.h>
#pragma comment(lib, "ntdll.lib")
//Check if testsigning is enabled
SYSTEM_CODEINTEGRITY_INFORMATION sci = {0};
ULONG dwcbSz = 0;
sci.Length = sizeof(sci);
if(NtQuerySystemInformation(
/*SystemCodeIntegrityInformation*/ (SYSTEM_INFORMATION_CLASS)0x67,
&sci,
sizeof(sci),
&dwcbSz) >= 0 &&
dwcbSz == sizeof(sci))
{
BOOL bTestsigningEnabled = !!(sci.CodeIntegrityOptions & /*CODEINTEGRITY_OPTION_TESTSIGN*/ 0x2);
//Note that testsigning will play no role if bit CODEINTEGRITY_OPTION_ENABLED (or 0x1) is not set in sci.CodeIntegrityOptions
}
我宁愿把它包装成一个更好的函数,像这样:
bool IsSystemCodeIntegrityEnabled() {
typedef NTSTATUS(__stdcall* td_NtQuerySystemInformation)(
ULONG SystemInformationClass,
PVOID SystemInformation,
ULONG SystemInformationLength,
PULONG ReturnLength
);
struct SYSTEM_CODEINTEGRITY_INFORMATION {
ULONG Length;
ULONG CodeIntegrityOptions;
};
static td_NtQuerySystemInformation NtQuerySystemInformation = (td_NtQuerySystemInformation)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtQuerySystemInformation");
SYSTEM_CODEINTEGRITY_INFORMATION Integrity ={ sizeof(SYSTEM_CODEINTEGRITY_INFORMATION), 0 };
NTSTATUS status = NtQuerySystemInformation(103, &Integrity, sizeof(Integrity), NULL);
return (NT_SUCCESS(status) && (Integrity.CodeIntegrityOptions & 1));
}
相关文章:
- C++17中的并行执行策略
- Constexpr替代了新的放置方式,可以让内存中的对象保持未初始化状态
- 我不断收到 [错误] ID 返回 1 退出状态错误,但看不到问题所在
- OSX MetalKit CVMetalTextureCacheCreateTextureFromImage失败,状态:
- std::future_error:无关联状态
- 运行时执行策略不同
- 如何避免LED在循环状态变化中闪烁?
- boost 是否有按特殊类型值编码状态"compact optional"?
- 编译器上的策略数据结构不起作用
- 我应该在简单的策略游戏中为各个派系使用类吗 - C++
- 为什么系统函数总是在C++中返回已转移的退出状态?
- C++ 中的编译错误:未定义对"主"的引用 collect2:错误:ld 返回 1 个退出状态
- 当可输入框在窗口中处于活动状态时获得通知的任何方法
- 给定一个C++嵌套的私有结构类型,是否有从文件范围静态函数访问它的策略
- 检查两个节点在子节点上是否具有相同状态的更优雅的方法
- 正确使用朋友使用多种策略而不会丢失状态?
- 我可以有任何方法来检测驱动程序签名策略状态吗?
- 以有状态策略类为代价解耦宿主类和策略类,并且不遵循Effective c++的第26条
- 管理 OpenGL 状态机的策略
- 利用策略模式改变方法及其关联状态