diff --git a/src/windows-emulator/memory_utils.hpp b/src/windows-emulator/memory_utils.hpp index 03494553..f3172815 100644 --- a/src/windows-emulator/memory_utils.hpp +++ b/src/windows-emulator/memory_utils.hpp @@ -19,8 +19,10 @@ inline std::string get_permission_string(const memory_permission permission) return res; } -inline memory_permission map_nt_to_emulator_protection(const uint32_t nt_protection) +inline memory_permission map_nt_to_emulator_protection(uint32_t nt_protection) { + nt_protection &= ~PAGE_GUARD; // TODO: Implement that + switch (nt_protection) { case PAGE_NOACCESS: diff --git a/src/windows-emulator/process_context.hpp b/src/windows-emulator/process_context.hpp index c04ae56b..79e33247 100644 --- a/src/windows-emulator/process_context.hpp +++ b/src/windows-emulator/process_context.hpp @@ -219,6 +219,8 @@ public: uint32_t id{}; + std::wstring name{}; + std::optional exit_status{}; std::optional await_object{}; bool waiting_for_alert{false}; diff --git a/src/windows-emulator/syscalls.cpp b/src/windows-emulator/syscalls.cpp index 854cf44b..af326937 100644 --- a/src/windows-emulator/syscalls.cpp +++ b/src/windows-emulator/syscalls.cpp @@ -68,16 +68,41 @@ namespace return STATUS_NOT_SUPPORTED; } - NTSTATUS handle_NtSetInformationThread(const syscall_context& c, const uint64_t /*thread_handle*/, + NTSTATUS handle_NtSetInformationThread(const syscall_context& c, const uint64_t thread_handle, const THREADINFOCLASS info_class, - const uint64_t /*thread_information*/, - const uint32_t /*thread_information_length*/) + const uint64_t thread_information, + const uint32_t thread_information_length) { + auto* thread = thread_handle == ~1ULL + ? c.proc.active_thread + : c.proc.threads.get(thread_handle); + + if (!thread) + { + return STATUS_INVALID_HANDLE; + } + if (info_class == ThreadSchedulerSharedDataSlot) { return STATUS_SUCCESS; } + if (info_class == ThreadNameInformation) + { + if (thread_information_length != sizeof(THREAD_NAME_INFORMATION)) + { + return STATUS_BUFFER_OVERFLOW; + } + + const emulator_object info{c.emu, thread_information}; + const auto i = info.read(); + thread->name = read_unicode_string(c.emu, i.ThreadName); + + c.win_emu.logger.print(color::blue, "Setting thread (%d) name: %S\n", thread->id, thread->name.c_str()); + + return STATUS_SUCCESS; + } + printf("Unsupported thread info class: %X\n", info_class); c.emu.stop(); return STATUS_NOT_SUPPORTED; @@ -1485,6 +1510,11 @@ namespace return STATUS_NOT_SUPPORTED; } + NTSTATUS handle_NtUserRegisterWindowMessage() + { + return STATUS_NOT_SUPPORTED; + } + NTSTATUS handle_NtUserGetThreadState() { return STATUS_NOT_SUPPORTED; @@ -2203,6 +2233,7 @@ void syscall_dispatcher::add_handlers(std::unordered_map