首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我可以有任何方法来检测驱动程序签名策略状态吗?

问我可以有任何方法来检测驱动程序签名策略状态吗?
EN

Stack Overflow用户
提问于 2016-10-17 10:32:26
回答 2查看 1.9K关注 0票数 0

我有一个修改过的驱动程序,必须在禁用驱动程序签名时安装,因此我希望检测到此状态,以提醒用户重新启动到SafeMode。我尝试了以下命令:Bcdedit.exe -set TESTSIGNING OFF,但失败并提示

设置元素数据时发生错误。该值受安全引导策略保护,不能修改或删除。

Umm..is有什么办法可以做到吗?

PS:事实上,我的笔记本电脑型号是MSI GS70 2PE。我不认为它是廉价的,即使是最新发布的GS73也不能支持完整的win10 gestures.And,它支持Windows10,但MSI确实没有发布我自己修改和使用的最新的driver.If,没有价值的mentioning.However,我想在论坛上分享它,以帮助其他普通用户使用。

我做错了什么吗?无法理解为什么有人在谈论其他事情。

EN

回答 2

Stack Overflow用户

发布于 2018-06-20 09:29:11

使用以下代码检测是否启用了TESTSIGNING:

代码语言:javascript
复制
#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

}
票数 1
EN

Stack Overflow用户

发布于 2018-07-08 08:28:34

我宁愿把它包装成一个更好的函数,如下所示:

代码语言:javascript
复制
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));
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40084077

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档