xref: /reactos/sdk/include/ddk/prefix.h (revision 75548295)
1 #ifndef _RXPREFIX_
2 #define _RXPREFIX_
3 
4 typedef struct _RX_CONNECTION_ID
5 {
6     union
7     {
8         ULONG SessionID;
9         LUID Luid;
10     };
11 } RX_CONNECTION_ID, *PRX_CONNECTION_ID;
12 
13 ULONG
14 RxTableComputeHashValue(
15     _In_ PUNICODE_STRING Name);
16 
17 PVOID
18 RxPrefixTableLookupName(
19     _In_ PRX_PREFIX_TABLE ThisTable,
20     _In_ PUNICODE_STRING CanonicalName,
21     _Out_ PUNICODE_STRING RemainingName,
22     _In_ PRX_CONNECTION_ID ConnectionId);
23 
24 PRX_PREFIX_ENTRY
25 RxPrefixTableInsertName(
26     _Inout_ PRX_PREFIX_TABLE ThisTable,
27     _Inout_ PRX_PREFIX_ENTRY ThisEntry,
28     _In_ PVOID Container,
29     _In_ PULONG ContainerRefCount,
30     _In_ USHORT CaseInsensitiveLength,
31     _In_ PRX_CONNECTION_ID ConnectionId);
32 
33 VOID
34 RxRemovePrefixTableEntry(
35     _Inout_ PRX_PREFIX_TABLE ThisTable,
36     _Inout_ PRX_PREFIX_ENTRY Entry);
37 
38 VOID
39 RxInitializePrefixTable(
40     _Inout_ PRX_PREFIX_TABLE ThisTable,
41     _In_opt_ ULONG TableSize,
42     _In_ BOOLEAN CaseInsensitiveMatch);
43 
44 typedef struct _RX_PREFIX_ENTRY
45 {
46     NODE_TYPE_CODE NodeTypeCode;
47     NODE_BYTE_SIZE NodeByteSize;
48     USHORT CaseInsensitiveLength;
49     USHORT Spare1;
50     ULONG SavedHashValue;
51     LIST_ENTRY HashLinks;
52     LIST_ENTRY MemberQLinks;
53     UNICODE_STRING Prefix;
54     PULONG ContainerRefCount;
55     PVOID ContainingRecord;
56     PVOID Context;
57     RX_CONNECTION_ID ConnectionId;
58 } RX_PREFIX_ENTRY, *PRX_PREFIX_ENTRY;
59 
60 #define RX_PREFIX_TABLE_DEFAULT_LENGTH 32
61 
62 typedef struct _RX_PREFIX_TABLE {
63     NODE_TYPE_CODE NodeTypeCode;
64     NODE_BYTE_SIZE NodeByteSize;
65     ULONG Version;
66     LIST_ENTRY MemberQueue;
67     ERESOURCE TableLock;
68     PRX_PREFIX_ENTRY TableEntryForNull;
69     BOOLEAN CaseInsensitiveMatch;
70     BOOLEAN IsNetNameTable;
71     ULONG TableSize;
72 #if DBG
73     ULONG Lookups;
74     ULONG FailedLookups;
75     ULONG Considers;
76     ULONG Compares;
77 #endif
78     LIST_ENTRY HashBuckets[RX_PREFIX_TABLE_DEFAULT_LENGTH];
79 } RX_PREFIX_TABLE, *PRX_PREFIX_TABLE;
80 
81 #if (_WIN32_WINNT < 0x0600)
82 #define RxAcquirePrefixTableLockShared(T, W) RxpAcquirePrefixTableLockShared((T),(W),TRUE)
83 #define RxAcquirePrefixTableLockExclusive(T, W) RxpAcquirePrefixTableLockExclusive((T), (W), TRUE)
84 #define RxReleasePrefixTableLock(T) RxpReleasePrefixTableLock((T), TRUE)
85 
86 BOOLEAN
87 RxpAcquirePrefixTableLockShared(
88    _In_ PRX_PREFIX_TABLE pTable,
89    _In_ BOOLEAN Wait,
90    _In_ BOOLEAN ProcessBufferingStateChangeRequests);
91 
92 BOOLEAN
93 RxpAcquirePrefixTableLockExclusive(
94    _In_ PRX_PREFIX_TABLE pTable,
95    _In_ BOOLEAN Wait,
96    _In_ BOOLEAN ProcessBufferingStateChangeRequests);
97 
98 VOID
99 RxpReleasePrefixTableLock(
100    _In_ PRX_PREFIX_TABLE pTable,
101    _In_ BOOLEAN ProcessBufferingStateChangeRequests);
102 #else
103 #define RxAcquirePrefixTableLockShared(T, W) ExAcquireResourceSharedLite(&(T)->TableLock, (W))
104 #define RxAcquirePrefixTableLockExclusive(T, W) ExAcquireResourceExclusiveLite(&(T)->TableLock, (W))
105 #define RxReleasePrefixTableLock(T) ExReleaseResourceLite(&(T)->TableLock)
106 #endif
107 
108 VOID
109 RxExclusivePrefixTableLockToShared(
110     _In_ PRX_PREFIX_TABLE Table);
111 
112 #define RxIsPrefixTableLockExclusive(T) ExIsResourceAcquiredExclusiveLite(&(T)->TableLock)
113 #define RxIsPrefixTableLockAcquired(T) (ExIsResourceAcquiredSharedLite(&(T)->TableLock) || \
114                                         ExIsResourceAcquiredExclusiveLite(&(T)->TableLock))
115 
116 #ifdef __REACTOS__
117 #define HASH_BUCKET(T, H) &(T)->HashBuckets[H % (T)->TableSize]
118 #endif
119 
120 #endif
121