ReactOS 0.4.15-dev-8348-gc1b9bb5
dcatitem.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS WinSock 2 API
4 * FILE: dll/win32/ws2_32/src/dcatitem.c
5 * PURPOSE: Transport Catalog Entry Object
6 * PROGRAMMER: Alex Ionescu (alex@relsoft.net)
7 */
8
9/* INCLUDES ******************************************************************/
10
11#include <ws2_32.h>
12
13/* FUNCTIONS *****************************************************************/
14
18{
19 PTCATALOG_ENTRY CatalogEntry;
20
21 /* Allocate the catalog entry */
22 CatalogEntry = HeapAlloc(WsSockHeap, HEAP_ZERO_MEMORY, sizeof(*CatalogEntry));
23 if (CatalogEntry)
24 {
25 /* Set the default non-null members */
26 CatalogEntry->RefCount = 1;
27 }
28
29 /* Return it */
30 return CatalogEntry;
31}
32
33VOID
36{
37 /* Check if a provider is loaded */
38 if (CatalogEntry->Provider)
39 {
40 /* Dereference it too */
41 WsTpDereference(CatalogEntry->Provider);
42 CatalogEntry->Provider = NULL;
43 }
44
45 /* Delete us */
46 HeapFree(WsSockHeap, 0, CatalogEntry);
47}
48
49VOID
52{
53 /* Dereference and check if it's now 0 */
54 if (!(InterlockedDecrement(&CatalogEntry->RefCount)))
55 {
56 /* We can delete the Provider now */
57 WsTcEntryDelete(CatalogEntry);
58 }
59}
60
65 IN DWORD UniqueId)
66{
67 CHAR CatalogEntryName[13];
68 DWORD RegSize;
69 DWORD RegType = REG_BINARY;
70 HKEY EntryKey;
71 DWORD Return;
72 LPBYTE Buf;
74
75 /* Convert to a 00000xxx string */
76 sprintf(CatalogEntryName, "%0""12""lu", UniqueId);
77
78 /* Open the Entry */
79 Return = RegOpenKeyEx(ParentKey,
80 CatalogEntryName,
81 0,
83 &EntryKey);
84
85 /* Get Size of Catalog Entry Structure */
86 Return = RegQueryValueEx(EntryKey,
87 "PackedCatalogItem",
88 0,
89 NULL,
90 NULL,
91 &RegSize);
92
93 if (!(Buf = HeapAlloc(WsSockHeap, HEAP_ZERO_MEMORY, RegSize)))
95
96 /* Read the Whole Catalog Entry Structure */
97 Return = RegQueryValueEx(EntryKey,
98 "PackedCatalogItem",
99 0,
100 &RegType,
101 Buf,
102 &RegSize);
103
104
105 memcpy(CatalogEntry->DllPath, Buf, sizeof(CatalogEntry->DllPath));
106 index = sizeof(CatalogEntry->DllPath);
107 if (index < RegSize)
108 {
109 memcpy(&CatalogEntry->ProtocolInfo, &Buf[index], sizeof(WSAPROTOCOL_INFOW));
110 index += sizeof(WSAPROTOCOL_INFOW);
111 }
112 HeapFree(WsSockHeap, 0, Buf);
113
114 /* Done */
115 RegCloseKey(EntryKey);
116 return Return;
117}
118
119VOID
120WSAAPI
123{
124 /* Reference the provider */
125 InterlockedIncrement(&Provider->RefCount);
126
127 /* Set it */
128 Entry->Provider = Provider;
129}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define index(s, c)
Definition: various.h:29
#define RegCloseKey(hKey)
Definition: registry.h:49
VOID WSAAPI WsTcEntrySetProvider(IN PTCATALOG_ENTRY Entry, IN PTPROVIDER Provider)
Definition: dcatitem.c:121
PTCATALOG_ENTRY WSAAPI WsTcEntryAllocate(VOID)
Definition: dcatitem.c:17
VOID WSAAPI WsTcEntryDereference(IN PTCATALOG_ENTRY CatalogEntry)
Definition: dcatitem.c:51
VOID WSAAPI WsTcEntryDelete(IN PTCATALOG_ENTRY CatalogEntry)
Definition: dcatitem.c:35
DWORD WSAAPI WsTcEntryInitializeFromRegistry(IN PTCATALOG_ENTRY CatalogEntry, IN HKEY ParentKey, IN DWORD UniqueId)
Definition: dcatitem.c:63
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define NULL
Definition: types.h:112
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint index
Definition: glext.h:6031
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define REG_BINARY
Definition: nt_native.h:1496
#define KEY_READ
Definition: nt_native.h:1023
base of all file and directory entries
Definition: entries.h:83
Definition: ws2_32p.h:86
LONG RefCount
Definition: ws2_32p.h:88
unsigned char * LPBYTE
Definition: typedefs.h:53
#define IN
Definition: typedefs.h:39
_Must_inspect_result_ _In_opt_ WDFKEY ParentKey
Definition: wdfregistry.h:69
#define RegOpenKeyEx
Definition: winreg.h:520
#define RegQueryValueEx
Definition: winreg.h:524
struct _WSAPROTOCOL_INFOW WSAPROTOCOL_INFOW
#define WSAAPI
Definition: winsock2.h:605
VOID WSAAPI WsTpDereference(IN PTPROVIDER Provider)
Definition: dprovide.c:143
HANDLE WsSockHeap
Definition: dllmain.c:21
char CHAR
Definition: xmlstorage.h:175