From c66148cda0c08aad24545dad1db3f039a1759467 Mon Sep 17 00:00:00 2001 From: hater <7element@mail.bg> Date: Wed, 4 Nov 2015 11:44:06 +0200 Subject: [PATCH] Read catalog entry from registry. Add check for invalid params in wsTcEntryFromTriplet. Add and disable debug messages --- reactos/dll/win32/ws2_32_new/src/dcatalog.c | 41 +++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/reactos/dll/win32/ws2_32_new/src/dcatalog.c b/reactos/dll/win32/ws2_32_new/src/dcatalog.c index 8e0e2e2..24a69bb 100644 --- a/reactos/dll/win32/ws2_32_new/src/dcatalog.c +++ b/reactos/dll/win32/ws2_32_new/src/dcatalog.c @@ -10,9 +10,10 @@ #include -/* DATA **********************************************************************/ +#define NDEBUG +#include -#define TCCATALOG_NAME "Protocol_Catalog9" +/* DATA **********************************************************************/ #define WsTcLock() EnterCriticalSection((LPCRITICAL_SECTION)&Catalog->Lock); #define WsTcUnlock() LeaveCriticalSection((LPCRITICAL_SECTION)&Catalog->Lock); @@ -45,14 +46,33 @@ WsTcOpen(IN PTCATALOG Catalog, 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->ProtocolList); + /* Read the catalog name */ + ErrorCode = RegQueryValueEx(ParentKey, + "Current_Protocol_Catalog", + 0, + &RegType, + NULL, + &RegSize); + + 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, - TCCATALOG_NAME, + CatalogKeyName, 0, MAXIMUM_ALLOWED, &CatalogKey); @@ -67,7 +87,7 @@ WsTcOpen(IN PTCATALOG Catalog, { /* Create the Catalog Name */ ErrorCode = RegCreateKeyEx(ParentKey, - TCCATALOG_NAME, + CatalogKeyName, 0, NULL, REG_OPTION_NON_VOLATILE, @@ -77,6 +97,10 @@ WsTcOpen(IN PTCATALOG Catalog, &CreateDisposition); } + HeapFree(WsSockHeap, 0, CatalogKeyName); + RegType = REG_DWORD; + RegSize = sizeof(DWORD); + /* Fail if that didn't work */ if (ErrorCode != ERROR_SUCCESS) return FALSE; @@ -409,6 +433,7 @@ WsTcGetEntryFromCatalogEntryId(IN PTCATALOG Catalog, IN DWORD CatalogEntryId, IN PTCATALOG_ENTRY *CatalogEntry) { + INT ErrorCode = WSAEINVAL; PLIST_ENTRY NextEntry = Catalog->ProtocolList.Flink; PTCATALOG_ENTRY Entry; @@ -435,6 +460,7 @@ WsTcGetEntryFromCatalogEntryId(IN PTCATALOG Catalog, /* Reference the entry and return it */ InterlockedIncrement(&Entry->RefCount); *CatalogEntry = Entry; + ErrorCode = ERROR_SUCCESS; break; } } @@ -443,7 +469,7 @@ WsTcGetEntryFromCatalogEntryId(IN PTCATALOG Catalog, WsTcUnlock(); /* Return */ - return ERROR_SUCCESS; + return ErrorCode; } DWORD @@ -458,6 +484,10 @@ WsTcGetEntryFromTriplet(IN PTCATALOG Catalog, INT ErrorCode = WSAEINVAL; PLIST_ENTRY NextEntry = Catalog->ProtocolList.Flink; PTCATALOG_ENTRY Entry; + DPRINT1("WsTcGetEntryFromTriplet: %lx, %lx, %lx, %lx\n", af, type, protocol, StartId); + + if (af == 0 && protocol == 0) + return WSAEINVAL; /* Assume failure */ *CatalogEntry = NULL; @@ -580,6 +610,7 @@ WsTcLoadProvider(IN PTCATALOG Catalog, { INT ErrorCode = ERROR_SUCCESS; PTPROVIDER Provider; + DPRINT("WsTcLoadProvider: %p, %p\n", Catalog, CatalogEntry); /* Lock the catalog */ WsTcLock(); -- 1.9.5.msysgit.0