From b335b69368a642b0b57cfd63990313b34cb3ee31 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Mon, 19 Jul 2021 13:40:57 +0300 Subject: [PATCH] ntdll: Add SystemKernelDebuggerInformationEx info class to NtQuerySystemInformation(). Signed-off-by: Paul Gofman Signed-off-by: Alexandre Julliard --- dlls/ntdll/tests/info.c | 24 ++++++++++++++++++++++++ dlls/ntdll/unix/system.c | 18 ++++++++++++++++++ include/winternl.h | 6 ++++++ 3 files changed, 48 insertions(+) diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c index c873a224a7c..85e27e92663 100644 --- a/dlls/ntdll/tests/info.c +++ b/dlls/ntdll/tests/info.c @@ -979,6 +979,7 @@ static void test_query_kerndebug(void) { NTSTATUS status; ULONG ReturnLength; + SYSTEM_KERNEL_DEBUGGER_INFORMATION_EX skdi_ex; SYSTEM_KERNEL_DEBUGGER_INFORMATION skdi; status = pNtQuerySystemInformation(SystemKernelDebuggerInformation, &skdi, 0, &ReturnLength); @@ -991,6 +992,29 @@ static void test_query_kerndebug(void) status = pNtQuerySystemInformation(SystemKernelDebuggerInformation, &skdi, sizeof(skdi) + 2, &ReturnLength); ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status); ok( sizeof(skdi) == ReturnLength, "Inconsistent length %d\n", ReturnLength); + + status = pNtQuerySystemInformation(SystemKernelDebuggerInformationEx, &skdi_ex, 0, &ReturnLength); + ok( status == STATUS_INFO_LENGTH_MISMATCH + || status == STATUS_NOT_IMPLEMENTED /* before win7 */ + || status == STATUS_INVALID_INFO_CLASS /* wow64 on Win10 */, + "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status); + + if (status != STATUS_INFO_LENGTH_MISMATCH) + { + win_skip( "NtQuerySystemInformation(SystemKernelDebuggerInformationEx) is not implemented.\n" ); + } + else + { + status = pNtQuerySystemInformation(SystemKernelDebuggerInformationEx, &skdi_ex, + sizeof(skdi_ex), &ReturnLength); + ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status); + ok( sizeof(skdi_ex) == ReturnLength, "Inconsistent length %d\n", ReturnLength); + + status = pNtQuerySystemInformation(SystemKernelDebuggerInformationEx, &skdi_ex, + sizeof(skdi_ex) + 2, &ReturnLength); + ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status); + ok( sizeof(skdi_ex) == ReturnLength, "Inconsistent length %d\n", ReturnLength); + } } static void test_query_regquota(void) diff --git a/dlls/ntdll/unix/system.c b/dlls/ntdll/unix/system.c index 596eea251b6..fcc0fb6677e 100644 --- a/dlls/ntdll/unix/system.c +++ b/dlls/ntdll/unix/system.c @@ -2860,6 +2860,24 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class, break; } + case SystemKernelDebuggerInformationEx: /* 149 */ + { + SYSTEM_KERNEL_DEBUGGER_INFORMATION_EX skdi; + + skdi.DebuggerAllowed = FALSE; + skdi.DebuggerEnabled = FALSE; + skdi.DebuggerPresent = FALSE; + + len = sizeof(skdi); + if (size >= len) + { + if (!info) ret = STATUS_ACCESS_VIOLATION; + else memcpy( info, &skdi, len ); + } + else ret = STATUS_INFO_LENGTH_MISMATCH; + break; + } + case SystemCpuSetInformation: /* 175 */ return NtQuerySystemInformationEx(class, NULL, 0, info, size, ret_size); diff --git a/include/winternl.h b/include/winternl.h index f832729f985..c632328b322 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -2485,6 +2485,12 @@ typedef struct _SYSTEM_KERNEL_DEBUGGER_INFORMATION { BOOLEAN DebuggerNotPresent; } SYSTEM_KERNEL_DEBUGGER_INFORMATION, *PSYSTEM_KERNEL_DEBUGGER_INFORMATION; +typedef struct _SYSTEM_KERNEL_DEBUGGER_INFORMATION_EX { + BOOLEAN DebuggerAllowed; + BOOLEAN DebuggerEnabled; + BOOLEAN DebuggerPresent; +} SYSTEM_KERNEL_DEBUGGER_INFORMATION_EX, *PSYSTEM_KERNEL_DEBUGGER_INFORMATION_EX; + typedef struct _VM_COUNTERS { SIZE_T PeakVirtualSize;