From b49f9f6d99d6f9dfe13d7a9508e6e6750021a805 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Tue, 5 Nov 2024 18:39:59 +0100 Subject: [PATCH] Prepare socket support --- src/windows-emulator/handles.hpp | 1 + src/windows-emulator/syscalls.cpp | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/windows-emulator/handles.hpp b/src/windows-emulator/handles.hpp index 766db2bd..977ea26c 100644 --- a/src/windows-emulator/handles.hpp +++ b/src/windows-emulator/handles.hpp @@ -314,6 +314,7 @@ constexpr auto SHARED_SECTION = make_pseudo_handle(0x1337, handle_types::section constexpr auto CONSOLE_SERVER = make_pseudo_handle(0x1338, handle_types::section); constexpr auto CM_API = make_pseudo_handle(0x1338, handle_types::file); constexpr auto KSEC_DD = make_pseudo_handle(0x1339, handle_types::file); +constexpr auto AFD_ENDPOINT = make_pseudo_handle(0x133A, handle_types::file); constexpr auto CONSOLE_HANDLE = make_pseudo_handle(0x1, handle_types::file); constexpr auto STDOUT_HANDLE = make_pseudo_handle(0x2, handle_types::file); diff --git a/src/windows-emulator/syscalls.cpp b/src/windows-emulator/syscalls.cpp index 1e2c88be..35c71a61 100644 --- a/src/windows-emulator/syscalls.cpp +++ b/src/windows-emulator/syscalls.cpp @@ -8,6 +8,8 @@ #include #include +#include "utils/finally.hpp" + namespace { NTSTATUS handle_NtQueryPerformanceCounter(const syscall_context& c, @@ -2033,7 +2035,10 @@ namespace const auto attributes = object_attributes.read(); auto filename = read_unicode_string(c.emu, attributes.ObjectName); - c.win_emu.logger.print(color::dark_gray, "--> Opening file: %S\n", filename.c_str()); + auto printer = utils::finally([&] + { + c.win_emu.logger.print(color::dark_gray, "--> Opening file: %S\n", filename.c_str()); + }); if (filename == L"\\Device\\ConDrv\\Server") { @@ -2053,6 +2058,12 @@ namespace return STATUS_SUCCESS; } + if (filename.starts_with(L"\\Device\\Afd\\Endpoint")) + { + file_handle.write(AFD_ENDPOINT.bits); + return STATUS_SUCCESS; + } + if (filename.starts_with(L"\\Device\\")) { return STATUS_NOT_SUPPORTED; @@ -2080,6 +2091,8 @@ namespace f.name = root->name + f.name; } + printer.cancel(); + if (f.name.ends_with(L"\\")) { c.win_emu.logger.print(color::dark_gray, "--> Opening folder: %S\n", f.name.c_str());