From 2ff60aaf4c7afba0f780a0376099d2a31122564a Mon Sep 17 00:00:00 2001 From: hater <7element@mail.bg> Date: Wed, 4 Nov 2015 11:36:07 +0200 Subject: [PATCH] Use registry to find catalog registry path. Reverse while/do for better reading. --- reactos/dll/win32/ws2_32_new/src/nscatalo.c | 38 +++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/reactos/dll/win32/ws2_32_new/src/nscatalo.c b/reactos/dll/win32/ws2_32_new/src/nscatalo.c index 3c1f873..7fe8ee1 100644 --- a/reactos/dll/win32/ws2_32_new/src/nscatalo.c +++ b/reactos/dll/win32/ws2_32_new/src/nscatalo.c @@ -10,9 +10,11 @@ #include +#define NDEBUG +#include + /* DATA **********************************************************************/ -#define NSCATALOG_NAME "NameSpace_Catalog5" #define WsNcLock() EnterCriticalSection((LPCRITICAL_SECTION)&Catalog->Lock); #define WsNcUnlock() LeaveCriticalSection((LPCRITICAL_SECTION)&Catalog->Lock); @@ -39,19 +41,37 @@ WsNcOpen(IN PNSCATALOG Catalog, LONG ErrorCode; DWORD CreateDisposition; HKEY CatalogKey, NewKey; - //DWORD CatalogEntries = 0; DWORD RegType = REG_DWORD; DWORD RegSize = sizeof(DWORD); DWORD UniqueId = 0; DWORD NewData = 0; + CHAR* CatalogKeyName; /* Initialize the catalog lock and namespace list */ InitializeCriticalSection((LPCRITICAL_SECTION)&Catalog->Lock); InitializeListHead(&Catalog->CatalogList); + /* Read the catalog name */ + ErrorCode = RegQueryValueEx(ParentKey, + "Current_NameSpace_Catalog", + 0, + &RegType, + NULL, + &RegSize); + + 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, - NSCATALOG_NAME, + CatalogKeyName, 0, MAXIMUM_ALLOWED, &CatalogKey); @@ -66,7 +86,7 @@ WsNcOpen(IN PNSCATALOG Catalog, { /* Create the Catalog Name */ ErrorCode = RegCreateKeyEx(ParentKey, - NSCATALOG_NAME, + CatalogKeyName, 0, NULL, REG_OPTION_NON_VOLATILE, @@ -76,6 +96,10 @@ WsNcOpen(IN PNSCATALOG Catalog, &CreateDisposition); } + HeapFree(WsSockHeap, 0, CatalogKeyName); + RegType = REG_DWORD; + RegSize = sizeof(DWORD); + /* Fail if that didn't work */ if (ErrorCode != ERROR_SUCCESS) return FALSE; @@ -328,14 +352,14 @@ WsNcEnumerateCatalogItems(IN PNSCATALOG Catalog, { PLIST_ENTRY Entry; PNSCATALOG_ENTRY CatalogEntry; - BOOL GoOn = TRUE; + BOOL GoOn; /* Lock the catalog */ WsNcLock(); /* Loop the entries */ Entry = Catalog->CatalogList.Flink; - while (GoOn && (Entry != &Catalog->CatalogList)) + do { /* Get the entry */ CatalogEntry = CONTAINING_RECORD(Entry, NSCATALOG_ENTRY, CatalogLink); @@ -343,7 +367,7 @@ WsNcEnumerateCatalogItems(IN PNSCATALOG Catalog, /* Move to the next one and call the callback */ Entry = Entry->Flink; GoOn = Callback(Context, CatalogEntry); - } + } while (GoOn && (Entry != &Catalog->CatalogList)); /* Release lock */ WsNcUnlock(); -- 1.9.5.msysgit.0