From: Paul Gofman pgofman@codeweavers.com
--- dlls/ntdll/tests/info.c | 24 ++++++++++++++++++++++++ dlls/ntdll/unix/system.c | 3 ++- dlls/wow64/system.c | 11 ++++------- include/winternl.h | 14 +++++++++++++- 4 files changed, 43 insertions(+), 9 deletions(-)
diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c index 68a9f165bfd..4118aae5e91 100644 --- a/dlls/ntdll/tests/info.c +++ b/dlls/ntdll/tests/info.c @@ -46,6 +46,7 @@ static NTSTATUS (WINAPI * pNtSetInformationDebugObject)(HANDLE,DEBUGOBJECTINFOCL static NTSTATUS (WINAPI * pDbgUiConvertStateChangeStructure)(DBGUI_WAIT_STATE_CHANGE*,DEBUG_EVENT*); static HANDLE (WINAPI * pDbgUiGetThreadDebugObject)(void); static void (WINAPI * pDbgUiSetThreadDebugObject)(HANDLE); +static NTSTATUS (WINAPI * pNtSystemDebugControl)(SYSDBG_COMMAND,PVOID,ULONG,PVOID,ULONG,PULONG);
static BOOL is_wow64; static BOOL old_wow64; @@ -101,6 +102,7 @@ static void InitFunctionPtrs(void) NTDLL_GET_PROC(DbgUiConvertStateChangeStructure); NTDLL_GET_PROC(DbgUiGetThreadDebugObject); NTDLL_GET_PROC(DbgUiSetThreadDebugObject); + NTDLL_GET_PROC(NtSystemDebugControl);
if (!IsWow64Process( GetCurrentProcess(), &is_wow64 )) is_wow64 = FALSE;
@@ -3735,6 +3737,27 @@ static void test_ThreadIsTerminated(void) ok( status == STATUS_INVALID_HANDLE, "got %#lx.\n", status ); }
+static void test_system_debug_control(void) +{ + NTSTATUS status; + int class; + + for (class = 0; class <= SysDbgSetKdBlockEnable; ++class) + { + status = pNtSystemDebugControl( class, NULL, 0, NULL, 0, NULL ); + if (is_wow64) + { + /* Most of the calls return STATUS_NOT_IMPLEMENTED on wow64. */ + ok( status == STATUS_DEBUGGER_INACTIVE || status == STATUS_NOT_IMPLEMENTED || status == STATUS_INFO_LENGTH_MISMATCH, + "class %d, got %#lx.\n", class, status ); + } + else + { + ok( status == STATUS_DEBUGGER_INACTIVE || status == STATUS_ACCESS_DENIED, "class %d, got %#lx.\n", class, status ); + } + } +} + START_TEST(info) { char **argv; @@ -3810,4 +3833,5 @@ START_TEST(info)
test_ThreadEnableAlignmentFaultFixup(); test_process_instrumentation_callback(); + test_system_debug_control(); } diff --git a/dlls/ntdll/unix/system.c b/dlls/ntdll/unix/system.c index 879a5893758..e55ec9e1137 100644 --- a/dlls/ntdll/unix/system.c +++ b/dlls/ntdll/unix/system.c @@ -3461,7 +3461,8 @@ NTSTATUS WINAPI NtSystemDebugControl( SYSDBG_COMMAND command, void *in_buff, ULO { FIXME( "(%d, %p, %d, %p, %d, %p), stub\n", command, in_buff, (int)in_len, out_buff, (int)out_len, retlen ); - return STATUS_NOT_IMPLEMENTED; + + return STATUS_DEBUGGER_INACTIVE; }
diff --git a/dlls/wow64/system.c b/dlls/wow64/system.c index 7130039e07a..2ab8f81a883 100644 --- a/dlls/wow64/system.c +++ b/dlls/wow64/system.c @@ -748,14 +748,11 @@ NTSTATUS WINAPI wow64_NtShutdownSystem( UINT *args ) */ NTSTATUS WINAPI wow64_NtSystemDebugControl( UINT *args ) { - SYSDBG_COMMAND command = get_ulong( &args ); - void *in_buf = get_ptr( &args ); - ULONG in_len = get_ulong( &args ); - void *out_buf = get_ptr( &args ); - ULONG out_len = get_ulong( &args ); - ULONG *retlen = get_ptr( &args ); + FIXME( "stub.\n" );
- return NtSystemDebugControl( command, in_buf, in_len, out_buf, out_len, retlen ); + /* STATUS_NOT_IMPLEMENTED is returned on Windows for the most of the commands while that is different + * for native arch NtSystemDebugControl(). */ + return STATUS_NOT_IMPLEMENTED; }
diff --git a/include/winternl.h b/include/winternl.h index 40feadfb22f..6d4218effee 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -3601,7 +3601,19 @@ typedef enum _SYSDBG_COMMAND { SysDbgReadMsr, SysDbgWriteMsr, SysDbgReadBusData, - SysDbgWriteBusData + SysDbgWriteBusData, + SysDbgCheckLowMemory, + SysDbgEnableKernelDebugger, + SysDbgDisableKernelDebugger, + SysDbgGetAutoKdEnable, + SysDbgSetAutoKdEnable, + SysDbgGetPrintBufferSize, + SysDbgSetPrintBufferSize, + SysDbgGetKdUmExceptionEnable, + SysDbgSetKdUmExceptionEnable, + SysDbgGetTriageDump, + SysDbgGetKdBlockEnable, + SysDbgSetKdBlockEnable, } SYSDBG_COMMAND, *PSYSDBG_COMMAND;
typedef struct _CPTABLEINFO