From c07fb2ca8640777ebdc318beaccbf4407bf2dfdb Mon Sep 17 00:00:00 2001 From: robert-yates Date: Tue, 24 Dec 2024 01:31:51 +0100 Subject: [PATCH] enable refactored api_set for windows platform --- src/common/platform/kernel_mapped.hpp | 7 +++++++ src/windows-emulator/windows_emulator.cpp | 8 +++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/common/platform/kernel_mapped.hpp b/src/common/platform/kernel_mapped.hpp index 85ea2207..ac3c040f 100644 --- a/src/common/platform/kernel_mapped.hpp +++ b/src/common/platform/kernel_mapped.hpp @@ -550,6 +550,13 @@ typedef struct _TEB64 ARRAY_CONTAINER Rcu; } TEB64, *PTEB64; +#ifdef OS_WINDOWS + inline TEB64* NtCurrentTeb64(VOID) + { + return (TEB64*)__readgsqword(FIELD_OFFSET(EMU_NT_TIB64, Self)); + } +#endif + #pragma pack(push, 4) typedef struct _KSYSTEM_TIME { diff --git a/src/windows-emulator/windows_emulator.cpp b/src/windows-emulator/windows_emulator.cpp index a366cbe0..1853df2e 100644 --- a/src/windows-emulator/windows_emulator.cpp +++ b/src/windows-emulator/windows_emulator.cpp @@ -144,10 +144,12 @@ namespace emulator_object build_api_set_map(x64_emulator& emu, emulator_allocator& allocator) { // TODO: fix - // const auto& orig_api_set_map = *NtCurrentTeb()->ProcessEnvironmentBlock->ApiSetMap; - // return clone_api_set_map(emu, allocator, orig_api_set_map); - +#ifdef OS_WINDOWS + const auto& orig_api_set_map = *NtCurrentTeb64()->ProcessEnvironmentBlock->ApiSetMap; + return clone_api_set_map(emu, allocator, orig_api_set_map); +#else return clone_api_set_map(emu, allocator, {}); +#endif } emulator_allocator create_allocator(emulator& emu, const size_t size)