mirror of
				https://github.com/mintty/wsltty.git
				synced 2025-10-31 07:04:00 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			41 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
| --- 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();
 |