Merge branch 'main' into pr/1

This commit is contained in:
Igor Pissolati
2025-04-20 01:34:06 -03:00
committed by GitHub
10 changed files with 62 additions and 11 deletions

View File

@@ -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()

2
deps/reflect vendored

View File

@@ -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<KUSER_SHARED_DATA64>{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)

View File

@@ -2,6 +2,7 @@
#include "reflect_type_info.hpp"
#include <set>
#include <cinttypes>
template <typename T>
emulator_hook* watch_object(windows_emulator& emu, const std::set<std::string, std::less<>>& modules,
@@ -31,9 +32,12 @@ emulator_hook* watch_object(windows_emulator& emu, const std::set<std::string, s
}
const auto offset = address - object.value();
const auto* mod_name = mod ? mod->name.c_str() : "<N/A>";
const auto& type_name = i.get_type_name();
const auto member_name = i.get_member_name(static_cast<size_t>(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<size_t>(offset)).c_str(), rip,
mod ? mod->name.c_str() : "<N/A>");
"Object access: %s - 0x%" PRIx64 " (%s) at 0x%" PRIx64 " (%s)\n", type_name.c_str(), offset,
member_name.c_str(), rip, mod_name);
});
}

View File

@@ -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

View File

@@ -109,6 +109,8 @@ namespace syscalls
emulator_object<IO_STATUS_BLOCK<EmulatorTraits<Emu64>>> 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<EmulatorTraits<Emu64>>> /*io_status_block*/);
// syscalls/locale.cpp:
NTSTATUS handle_NtInitializeNlsFiles(const syscall_context& c, emulator_object<uint64_t> 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<uint32_t> return_length);
NTSTATUS handle_NtOpenThread(const syscall_context&, handle thread_handle, ACCESS_MASK /*desired_access*/,
emulator_object<OBJECT_ATTRIBUTES<EmulatorTraits<Emu64>>> /*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<handle> 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 <typename Traits>
struct CLSMENUNAME
{
@@ -664,6 +674,7 @@ void syscall_dispatcher::add_handlers(std::map<std::string, syscall_handler>& 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<std::string, syscall_handler>& 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
}
}

View File

@@ -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<EmulatorTraits<Emu64>>> /*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;
}
}

View File

@@ -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();

View File

@@ -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<EmulatorTraits<Emu64>>> /*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<handle> token_handle)