From dbf39fce0ab54ac0b566bbbe2d8f85f839573b44 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Wed, 5 Feb 2025 19:24:36 +0100 Subject: [PATCH] Support more features --- src/common/platform/process.hpp | 6 +++ src/windows-emulator/handles.hpp | 1 + src/windows-emulator/syscalls.cpp | 61 ++++++++++++++++++++++++++++++- 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/src/common/platform/process.hpp b/src/common/platform/process.hpp index 8467c2f9..1c057788 100644 --- a/src/common/platform/process.hpp +++ b/src/common/platform/process.hpp @@ -731,6 +731,12 @@ typedef struct _SYSTEM_RANGE_START_INFORMATION64 EmulatorTraits::SIZE_T SystemRangeStart; } SYSTEM_RANGE_START_INFORMATION64, *PSYSTEM_RANGE_START_INFORMATION64; +typedef struct _SYSTEM_KERNEL_DEBUGGER_INFORMATION +{ + BOOLEAN KernelDebuggerEnabled; + BOOLEAN KernelDebuggerNotPresent; +} SYSTEM_KERNEL_DEBUGGER_INFORMATION, *PSYSTEM_KERNEL_DEBUGGER_INFORMATION; + struct SID_AND_ATTRIBUTES64 { EMULATOR_CAST(EmulatorTraits::PVOID, PSID) Sid; diff --git a/src/windows-emulator/handles.hpp b/src/windows-emulator/handles.hpp index 962b1a9f..4646bd3e 100644 --- a/src/windows-emulator/handles.hpp +++ b/src/windows-emulator/handles.hpp @@ -397,6 +397,7 @@ constexpr auto BASE_NAMED_OBJECTS_DIRECTORY = make_pseudo_handle(0x2, handle_typ constexpr auto KNOWN_DLLS_SYMLINK = make_pseudo_handle(0x1, handle_types::symlink); constexpr auto SHARED_SECTION = make_pseudo_handle(0x1, handle_types::section); +constexpr auto DBWIN_BUFFER = make_pseudo_handle(0x2, handle_types::section); constexpr auto WER_PORT_READY = make_pseudo_handle(0x1, handle_types::event); diff --git a/src/windows-emulator/syscalls.cpp b/src/windows-emulator/syscalls.cpp index e17d1962..fdd30461 100644 --- a/src/windows-emulator/syscalls.cpp +++ b/src/windows-emulator/syscalls.cpp @@ -651,6 +651,12 @@ namespace return STATUS_SUCCESS; } + if (filename == u"DBWIN_BUFFER") + { + section_handle.write(DBWIN_BUFFER); + return STATUS_SUCCESS; + } + if (filename == u"windows_shell_global_counters" // || filename == u"{00020000-0000-1005-8005-0000C06B5161}" // || filename == u"Global\\{00020000-0000-1005-8005-0000C06B5161}") @@ -1052,6 +1058,28 @@ namespace return STATUS_SUCCESS; } + if (info_class == SystemKernelDebuggerInformation) + { + if (return_length) + { + return_length.write(sizeof(SYSTEM_KERNEL_DEBUGGER_INFORMATION)); + } + + if (system_information_length != sizeof(SYSTEM_KERNEL_DEBUGGER_INFORMATION)) + { + return STATUS_BUFFER_TOO_SMALL; + } + + const emulator_object info_obj{c.emu, system_information}; + + info_obj.access([&](SYSTEM_KERNEL_DEBUGGER_INFORMATION& info) { + info.KernelDebuggerEnabled = FALSE; + info.KernelDebuggerNotPresent = TRUE; + }); + + return STATUS_SUCCESS; + } + if (info_class == SystemProcessInformation || info_class == SystemModuleInformation) { return STATUS_NOT_SUPPORTED; @@ -1341,7 +1369,8 @@ namespace return STATUS_SUCCESS; } - if (info_class == ProcessDefaultHardErrorMode || info_class == ProcessWx86Information) + if (info_class == ProcessDefaultHardErrorMode || info_class == ProcessWx86Information || + info_class == ProcessDebugFlags) { if (return_length) { @@ -1359,6 +1388,24 @@ namespace return STATUS_SUCCESS; } + if (info_class == ProcessDebugObjectHandle) + { + if (return_length) + { + return_length.write(sizeof(handle)); + } + + if (process_information_length != sizeof(handle)) + { + return STATUS_BUFFER_OVERFLOW; + } + + const emulator_object info{c.emu, process_information}; + info.write(NULL_HANDLE); + + return STATUS_SUCCESS; + } + if (info_class == ProcessEnclaveInformation || info_class == ProcessMitigationPolicy) { return STATUS_NOT_SUPPORTED; @@ -3524,11 +3571,21 @@ namespace return STATUS_NOT_SUPPORTED; } + NTSTATUS handle_NtSystemDebugControl() + { + return STATUS_NOT_SUPPORTED; + } + NTSTATUS handle_NtUserFindWindowEx() { return 0; } + NTSTATUS handle_NtUserMoveWindow() + { + return 0; + } + NTSTATUS handle_NtGetNextThread(const syscall_context& c, const handle process_handle, const handle thread_handle, const ACCESS_MASK /*desired_access*/, const ULONG /*handle_attributes*/, const ULONG flags, const emulator_object new_thread_handle) @@ -3763,6 +3820,8 @@ void syscall_dispatcher::add_handlers(std::map& ha add_handler(NtUserFindExistingCursorIcon); add_handler(NtSetContextThread); add_handler(NtUserFindWindowEx); + add_handler(NtUserMoveWindow); + add_handler(NtSystemDebugControl); #undef add_handler }