diff --git a/src/windows/common/CMakeLists.txt b/src/windows/common/CMakeLists.txt index a254469..0226920 100644 --- a/src/windows/common/CMakeLists.txt +++ b/src/windows/common/CMakeLists.txt @@ -1,9 +1,16 @@ set(SOURCES ConsoleProgressBar.cpp ConsoleProgressIndicator.cpp + DeviceHostProxy.cpp disk.cpp Distribution.cpp + Dmesg.cpp + DnsResolver.cpp + DnsTunnelingChannel.cpp filesystem.cpp + GnsChannel.cpp + GnsPortTrackerChannel.cpp + GuestDeviceManager.cpp HandleConsoleProgressBar.cpp hcs.cpp helpers.cpp @@ -15,21 +22,28 @@ set(SOURCES lxssbusclient.cpp lxssclient.cpp LxssMessagePort.cpp + LxssSecurity.cpp LxssServerPort.cpp + NatNetworking.cpp Redirector.cpp registry.cpp relay.cpp + RingBuffer.cpp string.cpp SubProcess.cpp svccomm.cpp svccommio.cpp WslClient.cpp WslCoreConfig.cpp + WslCoreFilesystem.cpp WslCoreFirewallSupport.cpp + WslCoreHostDnsInfo.cpp + WslCoreNetworkEndpointSettings.cpp WslCoreNetworkingSupport.cpp WslInstall.cpp WslSecurity.cpp WslTelemetry.cpp + VirtioNetworking.cpp wslutil.cpp notifications.cpp) @@ -60,9 +74,16 @@ set(HEADERS ../inc/wslrelay.h ConsoleProgressBar.h ConsoleProgressIndicator.h + DeviceHostProxy.h disk.hpp Distribution.h + Dmesg.h + DnsResolver.h + DnsTunnelingChannel.h filesystem.hpp + GnsChannel.h + GnsPortTrackerChannel.h + GuestDeviceManager.h HandleConsoleProgressBar.h hcs.hpp hcs_schema.h @@ -71,13 +92,17 @@ set(HEADERS ExecutionContext.h socket.hpp hvsocket.hpp + INetworkingEngine.h LxssMessagePort.h LxssPort.h + LxssSecurity.h LxssServerPort.h + NatNetworking.h precomp.h Redirector.h registry.hpp relay.hpp + RingBuffer.h string.hpp Stringify.h SubProcess.h @@ -85,11 +110,16 @@ set(HEADERS svccommio.hpp WslClient.h WslCoreConfig.h + WslCoreFilesystem.h WslCoreFirewallSupport.h + WslCoreHostDnsInfo.h + WslCoreMessageQueue.h + WslCoreNetworkEndpointSettings.h WslCoreNetworkingSupport.h WslInstall.h WslSecurity.h WslTelemetry.h + VirtioNetworking.h wslutil.h notifications.h) diff --git a/src/windows/service/exe/DeviceHostProxy.cpp b/src/windows/common/DeviceHostProxy.cpp similarity index 100% rename from src/windows/service/exe/DeviceHostProxy.cpp rename to src/windows/common/DeviceHostProxy.cpp diff --git a/src/windows/service/exe/DeviceHostProxy.h b/src/windows/common/DeviceHostProxy.h similarity index 100% rename from src/windows/service/exe/DeviceHostProxy.h rename to src/windows/common/DeviceHostProxy.h diff --git a/src/windows/service/exe/Dmesg.cpp b/src/windows/common/Dmesg.cpp similarity index 100% rename from src/windows/service/exe/Dmesg.cpp rename to src/windows/common/Dmesg.cpp diff --git a/src/windows/service/exe/Dmesg.h b/src/windows/common/Dmesg.h similarity index 100% rename from src/windows/service/exe/Dmesg.h rename to src/windows/common/Dmesg.h diff --git a/src/windows/service/exe/DnsResolver.cpp b/src/windows/common/DnsResolver.cpp similarity index 100% rename from src/windows/service/exe/DnsResolver.cpp rename to src/windows/common/DnsResolver.cpp diff --git a/src/windows/service/exe/DnsResolver.h b/src/windows/common/DnsResolver.h similarity index 100% rename from src/windows/service/exe/DnsResolver.h rename to src/windows/common/DnsResolver.h diff --git a/src/windows/service/exe/DnsTunnelingChannel.cpp b/src/windows/common/DnsTunnelingChannel.cpp similarity index 100% rename from src/windows/service/exe/DnsTunnelingChannel.cpp rename to src/windows/common/DnsTunnelingChannel.cpp diff --git a/src/windows/service/exe/DnsTunnelingChannel.h b/src/windows/common/DnsTunnelingChannel.h similarity index 100% rename from src/windows/service/exe/DnsTunnelingChannel.h rename to src/windows/common/DnsTunnelingChannel.h diff --git a/src/windows/service/exe/GnsChannel.cpp b/src/windows/common/GnsChannel.cpp similarity index 100% rename from src/windows/service/exe/GnsChannel.cpp rename to src/windows/common/GnsChannel.cpp diff --git a/src/windows/service/exe/GnsChannel.h b/src/windows/common/GnsChannel.h similarity index 100% rename from src/windows/service/exe/GnsChannel.h rename to src/windows/common/GnsChannel.h diff --git a/src/windows/service/exe/GnsPortTrackerChannel.cpp b/src/windows/common/GnsPortTrackerChannel.cpp similarity index 100% rename from src/windows/service/exe/GnsPortTrackerChannel.cpp rename to src/windows/common/GnsPortTrackerChannel.cpp diff --git a/src/windows/service/exe/GnsPortTrackerChannel.h b/src/windows/common/GnsPortTrackerChannel.h similarity index 100% rename from src/windows/service/exe/GnsPortTrackerChannel.h rename to src/windows/common/GnsPortTrackerChannel.h diff --git a/src/windows/service/exe/GuestDeviceManager.cpp b/src/windows/common/GuestDeviceManager.cpp similarity index 100% rename from src/windows/service/exe/GuestDeviceManager.cpp rename to src/windows/common/GuestDeviceManager.cpp diff --git a/src/windows/service/exe/GuestDeviceManager.h b/src/windows/common/GuestDeviceManager.h similarity index 100% rename from src/windows/service/exe/GuestDeviceManager.h rename to src/windows/common/GuestDeviceManager.h diff --git a/src/windows/service/exe/INetworkingEngine.h b/src/windows/common/INetworkingEngine.h similarity index 100% rename from src/windows/service/exe/INetworkingEngine.h rename to src/windows/common/INetworkingEngine.h diff --git a/src/windows/service/exe/LxssSecurity.cpp b/src/windows/common/LxssSecurity.cpp similarity index 100% rename from src/windows/service/exe/LxssSecurity.cpp rename to src/windows/common/LxssSecurity.cpp diff --git a/src/windows/service/exe/LxssSecurity.h b/src/windows/common/LxssSecurity.h similarity index 100% rename from src/windows/service/exe/LxssSecurity.h rename to src/windows/common/LxssSecurity.h diff --git a/src/windows/service/exe/NatNetworking.cpp b/src/windows/common/NatNetworking.cpp similarity index 99% rename from src/windows/service/exe/NatNetworking.cpp rename to src/windows/common/NatNetworking.cpp index b7dd080..dbad2a2 100644 --- a/src/windows/service/exe/NatNetworking.cpp +++ b/src/windows/common/NatNetworking.cpp @@ -6,7 +6,6 @@ #include "WslCoreHostDnsInfo.h" #include "Stringify.h" #include "WslCoreFirewallSupport.h" -#include "WslCoreVm.h" #include "hcs.hpp" using namespace wsl::core::networking; @@ -672,7 +671,7 @@ wsl::windows::common::hcs::unique_hcn_network NatNetworking::CreateNetwork(wsl:: wil::ResultFromException(WI_DIAGNOSTICS_INFO, [&] { try { - wsl::core::networking::ConfigureHyperVFirewall(config.FirewallConfig, c_vmOwner); + wsl::core::networking::ConfigureHyperVFirewall(config.FirewallConfig, wsl::windows::common::wslutil::c_vmOwner); natNetwork = CreateNetworkInternal(config); } catch (...) diff --git a/src/windows/service/exe/NatNetworking.h b/src/windows/common/NatNetworking.h similarity index 100% rename from src/windows/service/exe/NatNetworking.h rename to src/windows/common/NatNetworking.h diff --git a/src/windows/service/exe/RingBuffer.cpp b/src/windows/common/RingBuffer.cpp similarity index 100% rename from src/windows/service/exe/RingBuffer.cpp rename to src/windows/common/RingBuffer.cpp diff --git a/src/windows/service/exe/RingBuffer.h b/src/windows/common/RingBuffer.h similarity index 100% rename from src/windows/service/exe/RingBuffer.h rename to src/windows/common/RingBuffer.h diff --git a/src/windows/service/exe/VirtioNetworking.cpp b/src/windows/common/VirtioNetworking.cpp similarity index 100% rename from src/windows/service/exe/VirtioNetworking.cpp rename to src/windows/common/VirtioNetworking.cpp diff --git a/src/windows/service/exe/VirtioNetworking.h b/src/windows/common/VirtioNetworking.h similarity index 100% rename from src/windows/service/exe/VirtioNetworking.h rename to src/windows/common/VirtioNetworking.h diff --git a/src/windows/service/exe/WslCoreFilesystem.cpp b/src/windows/common/WslCoreFilesystem.cpp similarity index 100% rename from src/windows/service/exe/WslCoreFilesystem.cpp rename to src/windows/common/WslCoreFilesystem.cpp diff --git a/src/windows/service/exe/WslCoreFilesystem.h b/src/windows/common/WslCoreFilesystem.h similarity index 100% rename from src/windows/service/exe/WslCoreFilesystem.h rename to src/windows/common/WslCoreFilesystem.h diff --git a/src/windows/service/exe/WslCoreHostDnsInfo.cpp b/src/windows/common/WslCoreHostDnsInfo.cpp similarity index 100% rename from src/windows/service/exe/WslCoreHostDnsInfo.cpp rename to src/windows/common/WslCoreHostDnsInfo.cpp diff --git a/src/windows/service/exe/WslCoreHostDnsInfo.h b/src/windows/common/WslCoreHostDnsInfo.h similarity index 100% rename from src/windows/service/exe/WslCoreHostDnsInfo.h rename to src/windows/common/WslCoreHostDnsInfo.h diff --git a/src/windows/service/exe/WslCoreMessageQueue.h b/src/windows/common/WslCoreMessageQueue.h similarity index 100% rename from src/windows/service/exe/WslCoreMessageQueue.h rename to src/windows/common/WslCoreMessageQueue.h diff --git a/src/windows/service/exe/WslCoreNetworkEndpointSettings.cpp b/src/windows/common/WslCoreNetworkEndpointSettings.cpp similarity index 100% rename from src/windows/service/exe/WslCoreNetworkEndpointSettings.cpp rename to src/windows/common/WslCoreNetworkEndpointSettings.cpp diff --git a/src/windows/service/exe/WslCoreNetworkEndpointSettings.h b/src/windows/common/WslCoreNetworkEndpointSettings.h similarity index 100% rename from src/windows/service/exe/WslCoreNetworkEndpointSettings.h rename to src/windows/common/WslCoreNetworkEndpointSettings.h diff --git a/src/windows/common/wslutil.h b/src/windows/common/wslutil.h index fab4c98..54febf8 100644 --- a/src/windows/common/wslutil.h +++ b/src/windows/common/wslutil.h @@ -44,6 +44,7 @@ inline auto c_msixPackageFamilyName = L"MicrosoftCorporationII.WindowsSubsystemF inline auto c_githubUrlOverrideRegistryValue = L"GitHubUrlOverride"; inline auto c_vhdFileExtension = L".vhd"; inline auto c_vhdxFileExtension = L".vhdx"; +inline constexpr auto c_vmOwner = L"WSL"; struct GitHubReleaseAsset { diff --git a/src/windows/service/exe/CMakeLists.txt b/src/windows/service/exe/CMakeLists.txt index c1e49a2..620e127 100644 --- a/src/windows/service/exe/CMakeLists.txt +++ b/src/windows/service/exe/CMakeLists.txt @@ -1,40 +1,25 @@ set(SOURCES DistributionRegistration.cpp - LxssSecurity.cpp LxssUserCallback.cpp LxssUserSession.cpp LxssUserSessionFactory.cpp LxssIptables.cpp - LxssUserCallback.cpp LxssHttpProxy.cpp LxssInstance.cpp PluginManager.cpp ServiceMain.cpp BridgedNetworking.cpp - DeviceHostProxy.cpp - Dmesg.cpp - DnsTunnelingChannel.cpp - GnsChannel.cpp - GnsPortTrackerChannel.cpp GnsRpcServer.cpp - GuestDeviceManager.cpp GuestTelemetryLogger.cpp Lifetime.cpp LxssConsoleManager.cpp LxssCreateProcess.cpp MirroredNetworking.cpp - NatNetworking.cpp - RingBuffer.cpp - WslCoreFilesystem.cpp WslCoreGuestNetworkService.cpp - WslCoreHostDnsInfo.cpp WslCoreInstance.cpp WslMirroredNetworking.cpp - WslCoreNetworkEndpointSettings.cpp - DnsResolver.cpp WslCoreTcpIpStateTracking.cpp WslCoreVm.cpp - VirtioNetworking.cpp main.rc ${CMAKE_CURRENT_BINARY_DIR}/../mc/${TARGET_PLATFORM}/${CMAKE_BUILD_TYPE}/wsleventschema.rc application.manifest) @@ -42,7 +27,6 @@ set(SOURCES set(HEADERS ../../inc/comservicehelper.h DistributionRegistration.h - LxssSecurity.h LxssUserCallback.h LxssUserSession.h LxssUserSessionFactory.h @@ -51,31 +35,17 @@ set(HEADERS PluginManager.h LxssInstance.h BridgedNetworking.h - DeviceHostProxy.h - Dmesg.h - DnsTunnelingChannel.h - GnsChannel.h - GnsPortTrackerChannel.h GnsRpcServer.h - GuestDeviceManager.h GuestTelemetryLogger.h - INetworkingEngine.h IMirroredNetworkManager.h Lifetime.h LxssConsoleManager.h LxssCreateProcess.h MirroredNetworking.h - NatNetworking.h - RingBuffer.h - WslCoreFilesystem.h WslCoreGuestNetworkService.h - WslCoreHostDnsInfo.h WslCoreInstance.h - WslCoreMessageQueue.h WslMirroredNetworking.h WslCoreNetworkEndpoint.h - WslCoreNetworkEndpointSettings.h - DnsResolver.h WslCoreTcpIpStateTracking.h WslCoreVm.h) diff --git a/src/windows/service/exe/MirroredNetworking.cpp b/src/windows/service/exe/MirroredNetworking.cpp index 79b15cb..417006e 100644 --- a/src/windows/service/exe/MirroredNetworking.cpp +++ b/src/windows/service/exe/MirroredNetworking.cpp @@ -256,7 +256,7 @@ void MirroredNetworking::Initialize() m_config.FirewallConfig.Enabled(), m_config.IgnoredPorts, m_runtimeId, m_gnsRpcServer->GetServerUuid(), s_GuestNetworkServiceCallback, this); m_ephemeralPortRange = m_guestNetworkService.AllocateEphemeralPortRange(); - networking::ConfigureHyperVFirewall(m_config.FirewallConfig, c_vmOwner); + networking::ConfigureHyperVFirewall(m_config.FirewallConfig, wsl::windows::common::wslutil::c_vmOwner); // must keep all m_networkManager interactions (including) creation queued // also must queue GNS callbacks to keep them serialized diff --git a/src/windows/service/exe/WslCoreVm.cpp b/src/windows/service/exe/WslCoreVm.cpp index 343b818..931e392 100644 --- a/src/windows/service/exe/WslCoreVm.cpp +++ b/src/windows/service/exe/WslCoreVm.cpp @@ -1411,7 +1411,7 @@ void WslCoreVm::FreeLun(_In_ ULONG lun) std::wstring WslCoreVm::GenerateConfigJson() { hcs::ComputeSystem systemSettings{}; - systemSettings.Owner = c_vmOwner; + systemSettings.Owner = wsl::windows::common::wslutil::c_vmOwner; systemSettings.ShouldTerminateOnLastHandleClosed = true; systemSettings.SchemaVersion.Major = 2; systemSettings.SchemaVersion.Minor = 3; @@ -1518,7 +1518,7 @@ std::wstring WslCoreVm::GenerateConfigJson() // Set the vmmem suffix which will change the process name in task manager. if (IsVmemmSuffixSupported()) { - vmSettings.ComputeTopology.Memory.HostingProcessNameSuffix = c_vmOwner; + vmSettings.ComputeTopology.Memory.HostingProcessNameSuffix = wsl::windows::common::wslutil::c_vmOwner; } // If nested virtualization was requested, ensure the platform supports it. diff --git a/src/windows/service/exe/WslCoreVm.h b/src/windows/service/exe/WslCoreVm.h index 496ae6e..4c21672 100644 --- a/src/windows/service/exe/WslCoreVm.h +++ b/src/windows/service/exe/WslCoreVm.h @@ -40,8 +40,6 @@ inline constexpr auto c_optionsValueName = L"Options"; inline constexpr auto c_typeValueName = L"Type"; inline constexpr auto c_mountNameValueName = L"Name"; -inline constexpr auto c_vmOwner = L"WSL"; - static constexpr GUID c_virtiofsAdminClassId = {0x7e6ad219, 0xd1b3, 0x42d5, {0xb8, 0xee, 0xd9, 0x63, 0x24, 0xe6, 0x4f, 0xf6}}; // {60285AE6-AAF3-4456-B444-A6C2D0DEDA38}