Module: wine Branch: master Commit: 7bd070ae866f9c690343c82b05fcef4d0fc7de1d URL: https://gitlab.winehq.org/wine/wine/-/commit/7bd070ae866f9c690343c82b05fcef4...
Author: Paul Gofman pgofman@codeweavers.com Date: Mon Jan 8 17:54:30 2024 -0600
ntdll: Return STATUS_DEBUGGER_INACTIVE from NtSystemDebugControl() stub.
---
dlls/ntdll/tests/info.c | 24 ++++++++++++++++++++++++ dlls/ntdll/unix/system.c | 3 ++- dlls/wow64/system.c | 25 ++++++++++++++++++++++++- include/winternl.h | 22 +++++++++++++++++++++- 4 files changed, 71 insertions(+), 3 deletions(-)
diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c index 68a9f165bfd..70d566df3c6 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 < SysDbgMaxInfoClass; ++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..b2c8eec8769 100644 --- a/dlls/wow64/system.c +++ b/dlls/wow64/system.c @@ -755,7 +755,30 @@ NTSTATUS WINAPI wow64_NtSystemDebugControl( UINT *args ) ULONG out_len = get_ulong( &args ); ULONG *retlen = get_ptr( &args );
- return NtSystemDebugControl( command, in_buf, in_len, out_buf, out_len, retlen ); + switch (command) + { + case SysDbgBreakPoint: + case SysDbgEnableKernelDebugger: + case SysDbgDisableKernelDebugger: + case SysDbgGetAutoKdEnable: + case SysDbgSetAutoKdEnable: + case SysDbgGetPrintBufferSize: + case SysDbgSetPrintBufferSize: + case SysDbgGetKdUmExceptionEnable: + case SysDbgSetKdUmExceptionEnable: + case SysDbgGetTriageDump: + case SysDbgGetKdBlockEnable: + case SysDbgSetKdBlockEnable: + case SysDbgRegisterForUmBreakInfo: + case SysDbgGetUmBreakPid: + case SysDbgClearUmBreakPid: + case SysDbgGetUmAttachPid: + case SysDbgClearUmAttachPid: + return NtSystemDebugControl( command, in_buf, in_len, out_buf, out_len, retlen ); + + default: + return STATUS_NOT_IMPLEMENTED; /* not implemented on Windows either */ + } }
diff --git a/include/winternl.h b/include/winternl.h index b551e404fc9..48eac76c4d6 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -3603,7 +3603,27 @@ typedef enum _SYSDBG_COMMAND { SysDbgReadMsr, SysDbgWriteMsr, SysDbgReadBusData, - SysDbgWriteBusData + SysDbgWriteBusData, + SysDbgCheckLowMemory, + SysDbgEnableKernelDebugger, + SysDbgDisableKernelDebugger, + SysDbgGetAutoKdEnable, + SysDbgSetAutoKdEnable, + SysDbgGetPrintBufferSize, + SysDbgSetPrintBufferSize, + SysDbgGetKdUmExceptionEnable, + SysDbgSetKdUmExceptionEnable, + SysDbgGetTriageDump, + SysDbgGetKdBlockEnable, + SysDbgSetKdBlockEnable, + SysDbgRegisterForUmBreakInfo, + SysDbgGetUmBreakPid, + SysDbgClearUmBreakPid, + SysDbgGetUmAttachPid, + SysDbgClearUmAttachPid, + SysDbgGetLiveKernelDump, + SysDbgKdPullRemoteFile, + SysDbgMaxInfoClass } SYSDBG_COMMAND, *PSYSDBG_COMMAND;
typedef struct _CPTABLEINFO