diff --git a/cmake/compiler-env.cmake b/cmake/compiler-env.cmake index d9d09c5c..2840e536 100644 --- a/cmake/compiler-env.cmake +++ b/cmake/compiler-env.cmake @@ -100,6 +100,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "Emscripten") -sASSERTIONS -sWASM_BIGINT -sUSE_OFFSET_CONVERTER + -sMAXIMUM_MEMORY=4gb #-sEXCEPTION_CATCHING_ALLOWED=[..] -sEXIT_RUNTIME #-sASYNCIFY @@ -109,7 +110,6 @@ if(CMAKE_SYSTEM_NAME MATCHES "Emscripten") add_link_options( -lnodefs.js -sNODERAWFS=1 -sENVIRONMENT=node - -sMAXIMUM_MEMORY=4gb --pre-js ${CMAKE_CURRENT_LIST_DIR}/misc/node-pre-script.js ) else() diff --git a/deps/googletest b/deps/googletest index e90fe248..155b337c 160000 --- a/deps/googletest +++ b/deps/googletest @@ -1 +1 @@ -Subproject commit e90fe2485641bab0d6af4500192dc503384950d1 +Subproject commit 155b337c938a2953e5675f9dc18c99f05f4c85d0 diff --git a/deps/reflect b/deps/reflect index e85c958d..68d8fd09 160000 --- a/deps/reflect +++ b/deps/reflect @@ -1 +1 @@ -Subproject commit e85c958d22b3ca3cb79cc91f7e547f2e5eb0872f +Subproject commit 68d8fd0913711c1ac161af273f0bc1a4153601f8 diff --git a/src/analyzer/main.cpp b/src/analyzer/main.cpp index 1b9ce5a4..ec943fa0 100644 --- a/src/analyzer/main.cpp +++ b/src/analyzer/main.cpp @@ -60,7 +60,7 @@ namespace (void)modules; (void)cache_logging; -#ifdef OS_WINDOWS +#if !defined(__GNUC__) || defined(__clang__) watch_object(win_emu, modules, *win_emu.current_thread().teb, cache_logging); watch_object(win_emu, modules, win_emu.process.peb, cache_logging); watch_object(win_emu, modules, emulator_object{win_emu.emu(), kusd_mmio::address()}, @@ -252,7 +252,7 @@ namespace win_emu->log.log("Using emulator: %s\n", win_emu->emu().get_name().c_str()); (void)&watch_system_objects; - watch_system_objects(*win_emu, options.modules, options.concise_logging); + watch_system_objects(*win_emu, options.modules, !options.verbose_logging); win_emu->buffer_stdout = options.buffer_stdout; if (options.silent) diff --git a/src/analyzer/object_watching.hpp b/src/analyzer/object_watching.hpp index 4d700d4c..dd77c4b3 100644 --- a/src/analyzer/object_watching.hpp +++ b/src/analyzer/object_watching.hpp @@ -2,6 +2,7 @@ #include "reflect_type_info.hpp" #include +#include template emulator_hook* watch_object(windows_emulator& emu, const std::set>& modules, @@ -31,9 +32,12 @@ emulator_hook* watch_object(windows_emulator& emu, const std::setname.c_str() : ""; + const auto& type_name = i.get_type_name(); + const auto member_name = i.get_member_name(static_cast(offset)); + emu.log.print(is_main_access ? color::green : color::dark_gray, - "Object access: %s - 0x%llX (%s) at 0x%llX (%s)\n", i.get_type_name().c_str(), offset, - i.get_member_name(static_cast(offset)).c_str(), rip, - mod ? mod->name.c_str() : ""); + "Object access: %s - 0x%" PRIx64 " (%s) at 0x%" PRIx64 " (%s)\n", type_name.c_str(), offset, + member_name.c_str(), rip, mod_name); }); } diff --git a/src/tools/create-root.bat b/src/tools/create-root.bat index 6bd1bd34..975b7bea 100644 --- a/src/tools/create-root.bat +++ b/src/tools/create-root.bat @@ -111,6 +111,13 @@ CALL :collect shcore.dll CALL :collect diagnosticdatasettings.dll CALL :collect mswsock.dll CALL :collect umpdc.dll +CALL :collect pdh.dll +CALL :collect dxva2.dll +CALL :collect propsys.dll +CALL :collect wintypes.dll +CALL :collect slwga.dll +CALL :collect sppc.dll +CALL :collect kernel.appcore.dll CALL :collect locale.nls diff --git a/src/windows-emulator/syscalls.cpp b/src/windows-emulator/syscalls.cpp index bd3126fc..605f000e 100644 --- a/src/windows-emulator/syscalls.cpp +++ b/src/windows-emulator/syscalls.cpp @@ -109,6 +109,8 @@ namespace syscalls emulator_object>> io_status_block, ULONG fs_control_code, uint64_t input_buffer, ULONG input_buffer_length, uint64_t output_buffer, ULONG output_buffer_length); + NTSTATUS handle_NtFlushBuffersFile(const syscall_context& c, handle file_handle, + emulator_object>> /*io_status_block*/); // syscalls/locale.cpp: NTSTATUS handle_NtInitializeNlsFiles(const syscall_context& c, emulator_object base_address, @@ -269,6 +271,9 @@ namespace syscalls NTSTATUS handle_NtQueryInformationThread(const syscall_context& c, handle thread_handle, uint32_t info_class, uint64_t thread_information, uint32_t thread_information_length, emulator_object return_length); + NTSTATUS handle_NtOpenThread(const syscall_context&, handle thread_handle, ACCESS_MASK /*desired_access*/, + emulator_object>> /*object_attributes*/, + emulator_pointer /*client_id*/); NTSTATUS handle_NtOpenThreadToken(const syscall_context&, handle thread_handle, ACCESS_MASK /*desired_access*/, BOOLEAN /*open_as_self*/, emulator_object token_handle); NTSTATUS handle_NtOpenThreadTokenEx(const syscall_context& c, handle thread_handle, ACCESS_MASK desired_access, @@ -618,6 +623,11 @@ namespace syscalls return 0; } + NTSTATUS handle_NtUserGetProcessWindowStation() + { + return 0; + } + template struct CLSMENUNAME { @@ -664,6 +674,7 @@ void syscall_dispatcher::add_handlers(std::map& ha add_handler(NtSetInformationVirtualMemory); add_handler(NtFreeVirtualMemory); add_handler(NtQueryVirtualMemory); + add_handler(NtOpenThread); add_handler(NtOpenThreadToken); add_handler(NtOpenThreadTokenEx); add_handler(NtQueryPerformanceCounter); @@ -791,8 +802,10 @@ void syscall_dispatcher::add_handlers(std::map& ha add_handler(NtCreateNamedPipeFile); add_handler(NtFsControlFile); add_handler(NtQueryFullAttributesFile); + add_handler(NtFlushBuffersFile); + add_handler(NtUserGetProcessWindowStation); add_handler(NtUserRegisterClassExWOW); add_handler(NtUserUnregisterClass); #undef add_handler -} +} \ No newline at end of file diff --git a/src/windows-emulator/syscalls/file.cpp b/src/windows-emulator/syscalls/file.cpp index 006e3ba2..17e07e0c 100644 --- a/src/windows-emulator/syscalls/file.cpp +++ b/src/windows-emulator/syscalls/file.cpp @@ -846,4 +846,23 @@ namespace syscalls return STATUS_NOT_SUPPORTED; } -} + + NTSTATUS handle_NtFlushBuffersFile( + const syscall_context& c, const handle file_handle, + const emulator_object>> /*io_status_block*/) + { + if (file_handle == STDOUT_HANDLE) + { + return STATUS_SUCCESS; + } + + const auto* f = c.proc.files.get(file_handle); + if (!f) + { + return STATUS_INVALID_HANDLE; + } + + (void)fflush(f->handle); + return STATUS_SUCCESS; + } +} \ No newline at end of file diff --git a/src/windows-emulator/syscalls/section.cpp b/src/windows-emulator/syscalls/section.cpp index 3bcaaa90..bb0aa437 100644 --- a/src/windows-emulator/syscalls/section.cpp +++ b/src/windows-emulator/syscalls/section.cpp @@ -82,7 +82,8 @@ namespace syscalls return STATUS_NOT_SUPPORTED; } - if (attributes.RootDirectory != KNOWN_DLLS_DIRECTORY) + if (attributes.RootDirectory != KNOWN_DLLS_DIRECTORY && + attributes.RootDirectory != BASE_NAMED_OBJECTS_DIRECTORY) { c.win_emu.log.error("Unsupported section\n"); c.emu.stop(); diff --git a/src/windows-emulator/syscalls/thread.cpp b/src/windows-emulator/syscalls/thread.cpp index 827dc0e1..4952759e 100644 --- a/src/windows-emulator/syscalls/thread.cpp +++ b/src/windows-emulator/syscalls/thread.cpp @@ -239,6 +239,13 @@ namespace syscalls return STATUS_NOT_SUPPORTED; } + NTSTATUS handle_NtOpenThread(const syscall_context&, handle /*thread_handle*/, ACCESS_MASK /*desired_access*/, + emulator_object>> /*object_attributes*/, + emulator_pointer /*client_id*/) + { + return STATUS_NOT_SUPPORTED; + } + NTSTATUS handle_NtOpenThreadToken(const syscall_context&, const handle thread_handle, const ACCESS_MASK /*desired_access*/, const BOOLEAN /*open_as_self*/, const emulator_object token_handle)