From 09972471b9c14b6ae0b40824f2734d83a2b80085 Mon Sep 17 00:00:00 2001 From: mintty Date: Thu, 10 Oct 2024 00:00:00 +0200 Subject: [PATCH] add rluetzner's patch Get VmId from registry (#356) --- 0012-get-vmid-from-registry.patch | 40 +++++++++++++++++++++++++++++++ makefile | 2 ++ 2 files changed, 42 insertions(+) create mode 100644 0012-get-vmid-from-registry.patch diff --git a/0012-get-vmid-from-registry.patch b/0012-get-vmid-from-registry.patch new file mode 100644 index 0000000..fa52abe --- /dev/null +++ b/0012-get-vmid-from-registry.patch @@ -0,0 +1,40 @@ +--- wslbridge2/src/wslbridge2.cpp 2024-10-10 20:20:21.931891800 +0000 ++++ wslbridge2-0.12/src/wslbridge2.cpp 2024-10-08 09:31:35.954145800 +0000 +@@ -228,6 +228,26 @@ static void start_dummy(std::wstring wsl + CloseHandle(pi.hThread); + } + ++bool GetIdFromRegistry(GUID *guid) { ++ HKEY hKeyRoot = HKEY_LOCAL_MACHINE; ++ std::wstring subKey = L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\HostComputeService\\VolatileStore\\ComputeSystem"; ++ HKEY hKey; ++ if (RegOpenKeyEx(hKeyRoot, subKey.c_str(), 0, KEY_READ, &hKey) == ERROR_SUCCESS) { ++ DWORD index = 0; ++ WCHAR keyName[256]; ++ DWORD keyNameSize = sizeof(keyName) / sizeof(keyName[0]); ++ ++ while (RegEnumKeyEx(hKey, index, keyName, &keyNameSize, nullptr, nullptr, nullptr, nullptr) == ERROR_SUCCESS) { ++ RegCloseKey(hKey); ++ std::wstring id = L"{" + std::wstring(keyName) + L"}"; ++ return IIDFromString(id.c_str(), guid) == S_OK; ++ } ++ RegCloseKey(hKey); ++ } ++ return false; ++} ++ ++ + int main(int argc, char *argv[]) + { + /* Minimum requirement Windows 10 build 17763 aka. version 1809 */ +@@ -387,8 +407,8 @@ int main(int argc, char *argv[]) + if (LiftedWSLVersion) + start_dummy(wslPath, wslCmdLine, distroName, debugMode); + +- const HRESULT hRes = GetVmId(&DistroId, &VmId, LiftedWSLVersion); +- if (hRes != 0) ++ const bool hRes = GetIdFromRegistry(&VmId); ++ if (!hRes) + fatal("GetVmId: %s\n", GetErrorMessage(hRes).c_str()); + + inputSock = win_vsock_create(); diff --git a/makefile b/makefile index 5061378..42485d4 100644 --- a/makefile +++ b/makefile @@ -159,6 +159,8 @@ wslbridge-source: $(wslbridgedir).zip #cd $(wslbridgedir); patch -p1 < ../0001-notify-size-change-inband.patch # patch to https://github.com/Biswa96/wslbridge2/commit/41575379b416703c49e2687e957440239a4cdfb7 #cd $(wslbridgedir); patch -p0 < ../0002-add-com-for-lifted-wsl.patch + # patch to fix WSL 2 launching, again + cd $(wslbridgedir); patch -p1 < ../0012-get-vmid-from-registry.patch wslbridge-frontend: echo ------------- Compiling wslbridge2 frontend