ReactOS
0.4.16-dev-725-g22577ae
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
15
PTCATALOG_ENTRY
16
WSAAPI
17
WsTcEntryAllocate
(
VOID
)
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
33
VOID
34
WSAAPI
35
WsTcEntryDelete
(
IN
PTCATALOG_ENTRY
CatalogEntry)
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
49
VOID
50
WSAAPI
51
WsTcEntryDereference
(
IN
PTCATALOG_ENTRY
CatalogEntry)
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
61
DWORD
62
WSAAPI
63
WsTcEntryInitializeFromRegistry
(
IN
PTCATALOG_ENTRY
CatalogEntry,
64
IN
HKEY
ParentKey
,
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;
73
DWORD
index
;
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,
82
KEY_READ
,
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)))
94
return
ERROR_NOT_ENOUGH_MEMORY
;
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
119
VOID
120
WSAAPI
121
WsTcEntrySetProvider
(
IN
PTCATALOG_ENTRY
Entry
,
122
IN
PTPROVIDER
Provider
)
123
{
124
/* Reference the provider */
125
InterlockedIncrement
(&
Provider
->RefCount);
126
127
/* Set it */
128
Entry
->Provider =
Provider
;
129
}
InterlockedIncrement
#define InterlockedIncrement
Definition:
armddk.h:53
InterlockedDecrement
#define InterlockedDecrement
Definition:
armddk.h:52
index
#define index(s, c)
Definition:
various.h:29
RegCloseKey
#define RegCloseKey(hKey)
Definition:
registry.h:49
Provider
Definition:
provider.h:10
WsTcEntrySetProvider
VOID WSAAPI WsTcEntrySetProvider(IN PTCATALOG_ENTRY Entry, IN PTPROVIDER Provider)
Definition:
dcatitem.c:121
WsTcEntryAllocate
PTCATALOG_ENTRY WSAAPI WsTcEntryAllocate(VOID)
Definition:
dcatitem.c:17
WsTcEntryDereference
VOID WSAAPI WsTcEntryDereference(IN PTCATALOG_ENTRY CatalogEntry)
Definition:
dcatitem.c:51
WsTcEntryDelete
VOID WSAAPI WsTcEntryDelete(IN PTCATALOG_ENTRY CatalogEntry)
Definition:
dcatitem.c:35
WsTcEntryInitializeFromRegistry
DWORD WSAAPI WsTcEntryInitializeFromRegistry(IN PTCATALOG_ENTRY CatalogEntry, IN HKEY ParentKey, IN DWORD UniqueId)
Definition:
dcatitem.c:63
ERROR_NOT_ENOUGH_MEMORY
#define ERROR_NOT_ENOUGH_MEMORY
Definition:
dderror.h:7
NULL
#define NULL
Definition:
types.h:112
HeapAlloc
#define HeapAlloc
Definition:
compat.h:733
HeapFree
#define HeapFree(x, y, z)
Definition:
compat.h:735
HEAP_ZERO_MEMORY
#define HEAP_ZERO_MEMORY
Definition:
compat.h:134
DWORD
unsigned long DWORD
Definition:
ntddk_ex.h:95
index
GLuint index
Definition:
glext.h:6031
void
Definition:
nsiface.idl:2307
memcpy
#define memcpy(s1, s2, n)
Definition:
mkisofs.h:878
sprintf
#define sprintf(buf, format,...)
Definition:
sprintf.c:55
REG_BINARY
#define REG_BINARY
Definition:
nt_native.h:1496
KEY_READ
#define KEY_READ
Definition:
nt_native.h:1023
Entry
base of all file and directory entries
Definition:
entries.h:83
_TCATALOG_ENTRY
Definition:
ws2_32p.h:86
_TCATALOG_ENTRY::RefCount
LONG RefCount
Definition:
ws2_32p.h:88
_TPROVIDER
Definition:
ws2_32p.h:78
_WSAPROTOCOL_INFOW
Definition:
winsock2.h:679
LPBYTE
unsigned char * LPBYTE
Definition:
typedefs.h:53
IN
#define IN
Definition:
typedefs.h:39
ParentKey
_Must_inspect_result_ _In_opt_ WDFKEY ParentKey
Definition:
wdfregistry.h:69
RegOpenKeyEx
#define RegOpenKeyEx
Definition:
winreg.h:520
RegQueryValueEx
#define RegQueryValueEx
Definition:
winreg.h:524
WSAPROTOCOL_INFOW
struct _WSAPROTOCOL_INFOW WSAPROTOCOL_INFOW
WSAAPI
#define WSAAPI
Definition:
winsock2.h:605
WsTpDereference
VOID WSAAPI WsTpDereference(IN PTPROVIDER Provider)
Definition:
dprovide.c:143
WsSockHeap
HANDLE WsSockHeap
Definition:
dllmain.c:21
CHAR
char CHAR
Definition:
xmlstorage.h:175
dll
win32
ws2_32
src
dcatitem.c
Generated on Fri Feb 7 2025 06:05:27 for ReactOS by
1.9.6