From 8e67dfcb66439c39a57965aad7db8eac68bbadd4 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Wed, 6 Nov 2024 20:37:23 +0100 Subject: [PATCH] Add afd endpoint device First step towards networking support #15 --- src/windows-emulator/devices/afd_endpoint.cpp | 20 +++++++++++++++++++ src/windows-emulator/devices/afd_endpoint.hpp | 4 ++++ src/windows-emulator/io_device.cpp | 9 +++++++-- 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 src/windows-emulator/devices/afd_endpoint.cpp create mode 100644 src/windows-emulator/devices/afd_endpoint.hpp diff --git a/src/windows-emulator/devices/afd_endpoint.cpp b/src/windows-emulator/devices/afd_endpoint.cpp new file mode 100644 index 00000000..3657cbe7 --- /dev/null +++ b/src/windows-emulator/devices/afd_endpoint.cpp @@ -0,0 +1,20 @@ +#include "afd_endpoint.hpp" + +#include "windows-emulator/windows_emulator.hpp" + +namespace +{ + struct afd_endpoint : stateless_device + { + NTSTATUS io_control(const io_device_context& c) override + { + c.win_emu.logger.print(color::cyan, "AFD IOCTL: %X\n", c.io_control_code); + return STATUS_SUCCESS; + } + }; +} + +std::unique_ptr create_afd_endpoint() +{ + return std::make_unique(); +} diff --git a/src/windows-emulator/devices/afd_endpoint.hpp b/src/windows-emulator/devices/afd_endpoint.hpp new file mode 100644 index 00000000..caf72689 --- /dev/null +++ b/src/windows-emulator/devices/afd_endpoint.hpp @@ -0,0 +1,4 @@ +#pragma once +#include "../io_device.hpp" + +std::unique_ptr create_afd_endpoint(); diff --git a/src/windows-emulator/io_device.cpp b/src/windows-emulator/io_device.cpp index 9b299792..f28cbaea 100644 --- a/src/windows-emulator/io_device.cpp +++ b/src/windows-emulator/io_device.cpp @@ -1,4 +1,5 @@ #include "io_device.hpp" +#include "devices/afd_endpoint.hpp" namespace { @@ -16,11 +17,15 @@ std::unique_ptr create_device(const std::wstring_view device) if (device == L"CNG" || device == L"KsecDD" || device == L"DeviceApi\\CMApi" - || device == L"ConDrv\\Server" - || device == L"Afd\\Endpoint") + || device == L"ConDrv\\Server") { return std::make_unique(); } + if (device == L"Afd\\Endpoint") + { + return create_afd_endpoint(); + } + throw std::runtime_error("Unsupported device: " + std::string(device.begin(), device.end())); }