From af9df932748d3aaa2f334e0f430d35723fa46651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Sat, 17 Apr 2021 23:06:53 +0200 Subject: [PATCH] [WS2_32] Create registry keys Protocol_Catalog9/NameSpace_Catalog5 if needed This fixes networking in LiveCD and installation in 2nd stage. CORE-17514 --- dll/win32/ws2_32/src/dcatalog.c | 58 +++++++++++++++++++-------------- dll/win32/ws2_32/src/nscatalo.c | 58 +++++++++++++++++++-------------- 2 files changed, 68 insertions(+), 48 deletions(-) diff --git a/dll/win32/ws2_32/src/dcatalog.c b/dll/win32/ws2_32/src/dcatalog.c index c53e6c4faec..eb56765e40f 100644 --- a/dll/win32/ws2_32/src/dcatalog.c +++ b/dll/win32/ws2_32/src/dcatalog.c @@ -59,35 +59,45 @@ WsTcOpen(IN PTCATALOG Catalog, &RegType, NULL, &RegSize); - if (ErrorCode != ERROR_SUCCESS) + if (ErrorCode == ERROR_FILE_NOT_FOUND) { - DPRINT1("Failed to get protocol catalog name: %d.\n", ErrorCode); - return FALSE; + static const CHAR DefaultCatalogName[] = "Protocol_Catalog9"; + RegSize = sizeof(DefaultCatalogName); + CatalogKeyName = HeapAlloc(WsSockHeap, 0, RegSize); + memcpy(CatalogKeyName, DefaultCatalogName, RegSize); } - - if (RegType != REG_SZ) + else { - DPRINT1("Protocol catalog name is not a string (Type %d).\n", RegType); - return FALSE; + if (ErrorCode != ERROR_SUCCESS) + { + DPRINT1("Failed to get protocol catalog name: %d.\n", ErrorCode); + return FALSE; + } + + if (RegType != REG_SZ) + { + DPRINT1("Protocol catalog name is not a string (Type %d).\n", RegType); + return FALSE; + } + + CatalogKeyName = HeapAlloc(WsSockHeap, 0, RegSize); + + /* Read the catalog name */ + ErrorCode = RegQueryValueEx(ParentKey, + "Current_Protocol_Catalog", + 0, + &RegType, + (LPBYTE)CatalogKeyName, + &RegSize); + + /* Open the Catalog Key */ + ErrorCode = RegOpenKeyEx(ParentKey, + CatalogKeyName, + 0, + MAXIMUM_ALLOWED, + &CatalogKey); } - CatalogKeyName = HeapAlloc(WsSockHeap, 0, RegSize); - - /* Read the catalog name */ - ErrorCode = RegQueryValueEx(ParentKey, - "Current_Protocol_Catalog", - 0, - &RegType, - (LPBYTE)CatalogKeyName, - &RegSize); - - /* Open the Catalog Key */ - ErrorCode = RegOpenKeyEx(ParentKey, - CatalogKeyName, - 0, - MAXIMUM_ALLOWED, - &CatalogKey); - /* If we didn't find the key, create it */ if (ErrorCode == ERROR_SUCCESS) { diff --git a/dll/win32/ws2_32/src/nscatalo.c b/dll/win32/ws2_32/src/nscatalo.c index fe4d9cb28cf..32cee959c89 100644 --- a/dll/win32/ws2_32/src/nscatalo.c +++ b/dll/win32/ws2_32/src/nscatalo.c @@ -58,35 +58,45 @@ WsNcOpen(IN PNSCATALOG Catalog, &RegType, NULL, &RegSize); - if (ErrorCode != ERROR_SUCCESS) + if (ErrorCode == ERROR_FILE_NOT_FOUND) { - DPRINT1("Failed to get namespace catalog name: %d.\n", ErrorCode); - return FALSE; + static const CHAR DefaultCatalogName[] = "NameSpace_Catalog5"; + RegSize = sizeof(DefaultCatalogName); + CatalogKeyName = HeapAlloc(WsSockHeap, 0, RegSize); + memcpy(CatalogKeyName, DefaultCatalogName, RegSize); } - - if (RegType != REG_SZ) + else { - DPRINT1("Namespace catalog name is not a string (Type %d).\n", RegType); - return FALSE; + if (ErrorCode != ERROR_SUCCESS) + { + DPRINT1("Failed to get namespace catalog name: %d.\n", ErrorCode); + return FALSE; + } + + if (RegType != REG_SZ) + { + DPRINT1("Namespace catalog name is not a string (Type %d).\n", RegType); + return FALSE; + } + + CatalogKeyName = HeapAlloc(WsSockHeap, 0, RegSize); + + /* Read the catalog name */ + ErrorCode = RegQueryValueEx(ParentKey, + "Current_NameSpace_Catalog", + 0, + &RegType, + (LPBYTE)CatalogKeyName, + &RegSize); + + /* Open the Catalog Key */ + ErrorCode = RegOpenKeyEx(ParentKey, + CatalogKeyName, + 0, + MAXIMUM_ALLOWED, + &CatalogKey); } - CatalogKeyName = HeapAlloc(WsSockHeap, 0, RegSize); - - /* Read the catalog name */ - ErrorCode = RegQueryValueEx(ParentKey, - "Current_NameSpace_Catalog", - 0, - &RegType, - (LPBYTE)CatalogKeyName, - &RegSize); - - /* Open the Catalog Key */ - ErrorCode = RegOpenKeyEx(ParentKey, - CatalogKeyName, - 0, - MAXIMUM_ALLOWED, - &CatalogKey); - /* If we didn't find the key, create it */ if (ErrorCode == ERROR_SUCCESS) {