Skip to content

Commit

Permalink
Prepare socket support
Browse files Browse the repository at this point in the history
  • Loading branch information
momo5502 committed Nov 5, 2024
1 parent ba86d9f commit b49f9f6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/windows-emulator/handles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 14 additions & 1 deletion src/windows-emulator/syscalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <cwctype>
#include <utils/io.hpp>

#include "utils/finally.hpp"

namespace
{
NTSTATUS handle_NtQueryPerformanceCounter(const syscall_context& c,
Expand Down Expand Up @@ -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")
{
Expand All @@ -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;
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit b49f9f6

Please sign in to comment.