2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS WinSock 2 API
4 * FILE: dll/win32/ws2_32_new/src/dcatitem.c
5 * PURPOSE: Transport Catalog Entry Object
6 * PROGRAMMER: Alex Ionescu (alex@relsoft.net)
9 /* INCLUDES ******************************************************************/
13 /* FUNCTIONS *****************************************************************/
17 WsTcEntryAllocate(VOID
)
19 PTCATALOG_ENTRY CatalogEntry
;
21 /* Allocate the catalog entry */
22 CatalogEntry
= HeapAlloc(WsSockHeap
, HEAP_ZERO_MEMORY
, sizeof(*CatalogEntry
));
25 /* Set the default non-null members */
26 CatalogEntry
->RefCount
= 1;
35 WsTcEntryDelete(IN PTCATALOG_ENTRY CatalogEntry
)
37 /* Check if a provider is loaded */
38 if (CatalogEntry
->Provider
)
40 /* Dereference it too */
41 WsTpDereference(CatalogEntry
->Provider
);
42 CatalogEntry
->Provider
= NULL
;
46 HeapFree(WsSockHeap
, 0, CatalogEntry
);
51 WsTcEntryDereference(IN PTCATALOG_ENTRY CatalogEntry
)
53 /* Dereference and check if it's now 0 */
54 if (!(InterlockedDecrement(&CatalogEntry
->RefCount
)))
56 /* We can delete the Provider now */
57 WsTcEntryDelete(CatalogEntry
);
63 WsTcEntryInitializeFromRegistry(IN PTCATALOG_ENTRY CatalogEntry
,
67 CHAR CatalogEntryName
[13];
69 DWORD RegType
= REG_BINARY
;
75 /* Convert to a 00000xxx string */
76 sprintf(CatalogEntryName
, "%0""12""lu", UniqueId
);
79 Return
= RegOpenKeyEx(ParentKey
,
85 /* Get Size of Catalog Entry Structure */
86 Return
= RegQueryValueEx(EntryKey
,
93 if (!(Buf
= HeapAlloc(WsSockHeap
, HEAP_ZERO_MEMORY
, RegSize
)))
94 return ERROR_NOT_ENOUGH_MEMORY
;
96 /* Read the Whole Catalog Entry Structure */
97 Return
= RegQueryValueEx(EntryKey
,
105 memcpy(CatalogEntry
->DllPath
, Buf
, sizeof(CatalogEntry
->DllPath
));
106 index
= sizeof(CatalogEntry
->DllPath
);
109 memcpy(&CatalogEntry
->ProtocolInfo
, &Buf
[index
], sizeof(WSAPROTOCOL_INFOW
));
110 index
+= sizeof(WSAPROTOCOL_INFOW
);
112 HeapFree(WsSockHeap
, 0, Buf
);
115 RegCloseKey(EntryKey
);
121 WsTcEntrySetProvider(IN PTCATALOG_ENTRY Entry
,
122 IN PTPROVIDER Provider
)
124 /* Reference the provider */
125 InterlockedIncrement(&Provider
->RefCount
);
128 Entry
->Provider
= Provider
;