Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

273 lines
8.5 KiB

  1. /*******************************************************************/
  2. /* Copyright(c) 1993 Microsoft Corporation */
  3. /*******************************************************************/
  4. //***
  5. //
  6. // Filename: registry.c
  7. //
  8. // Description: routines for reading the registry configuration
  9. //
  10. // Author: Stefan Solomon (stefans) November 9, 1993.
  11. //
  12. // Revision History:
  13. // Updated to read parameters of new forwarder driver (11/95)
  14. //
  15. //***
  16. #include "precomp.h"
  17. NTSTATUS
  18. SetIpxDeviceName(
  19. IN PWSTR ValueName,
  20. IN ULONG ValueType,
  21. IN PVOID ValueData,
  22. IN ULONG ValueLength,
  23. IN PVOID Context,
  24. IN PVOID EntryContext
  25. );
  26. /*++
  27. *******************************************************************
  28. R e a d I p x D e v i c e N a m e
  29. Routine Description:
  30. Allocates buffer and reads device name exported by the IPX stack
  31. into it
  32. Arguments:
  33. FileName - pointer to buffer to hold the name
  34. Return Value:
  35. STATUS_SUCCESS - tables were created ok
  36. STATUS_INSUFFICIENT_RESOURCES - resource allocation failed
  37. STATUS_OBJECT_NAME_NOT_FOUND - if name value is not found
  38. *******************************************************************
  39. --*/
  40. NTSTATUS
  41. ReadIpxDeviceName (
  42. PWSTR *FileName
  43. ) {
  44. NTSTATUS Status;
  45. RTL_QUERY_REGISTRY_TABLE QueryTable[2];
  46. PWSTR Export = L"Export";
  47. PWSTR IpxRegistryPath = L"NwLnkIpx\\Linkage";
  48. //
  49. // Set up QueryTable to do the following:
  50. //
  51. //
  52. // 1) Call SetIpxDeviceName for the string in "Export"
  53. //
  54. QueryTable[0].QueryRoutine = SetIpxDeviceName;
  55. QueryTable[0].Flags = RTL_QUERY_REGISTRY_REQUIRED;
  56. QueryTable[0].Name = Export;
  57. QueryTable[0].EntryContext = FileName;
  58. QueryTable[0].DefaultType = 0;
  59. //
  60. // 2) Stop
  61. //
  62. QueryTable[1].QueryRoutine = NULL;
  63. QueryTable[1].Flags = 0;
  64. QueryTable[1].Name = NULL;
  65. Status = RtlQueryRegistryValues(
  66. RTL_REGISTRY_SERVICES,
  67. IpxRegistryPath,
  68. QueryTable,
  69. NULL,
  70. NULL);
  71. return Status;
  72. }
  73. /*++
  74. *******************************************************************
  75. S e t I p x D e v i c e N a m e
  76. Routine Description:
  77. This routine is a callback routine for RtlQueryRegistryValues
  78. It is called for each piece of the "Export" multi-string and
  79. saves the information in a ConfigurationInfo structure.
  80. Arguments:
  81. ValueName - The name of the value ("Export" -- ignored).
  82. ValueType - The type of the value (REG_SZ -- ignored).
  83. ValueData - The null-terminated data for the value.
  84. ValueLength - The length of ValueData.
  85. Context - NULL.
  86. EntryContext - file name pointer.
  87. Return Value:
  88. STATUS_SUCCESS - name was allocated and copied OK
  89. STATUS_INSUFFICIENT_RESOURCES - name allocation failed
  90. *******************************************************************
  91. --*/
  92. NTSTATUS
  93. SetIpxDeviceName(
  94. IN PWSTR ValueName,
  95. IN ULONG ValueType,
  96. IN PVOID ValueData,
  97. IN ULONG ValueLength,
  98. IN PVOID Context,
  99. IN PVOID EntryContext
  100. ) {
  101. PWSTR *FileName = (PWSTR *)EntryContext;
  102. ASSERT (ValueType==REG_SZ);
  103. *FileName = (PWSTR)ExAllocatePoolWithTag(NonPagedPool,
  104. ValueLength, FWD_POOL_TAG);
  105. if (*FileName != NULL) {
  106. RtlCopyMemory (*FileName, ValueData, ValueLength);
  107. return STATUS_SUCCESS;
  108. }
  109. else
  110. return STATUS_INSUFFICIENT_RESOURCES;
  111. }
  112. /*++
  113. *******************************************************************
  114. G e t R o u t e r P a r a m e t e r s
  115. Routine Description:
  116. Reads the parameters from the registry or sets the defaults
  117. Arguments:
  118. RegistryPath - where to read from.
  119. Return Value:
  120. STATUS_SUCCESS
  121. *******************************************************************
  122. --*/
  123. NTSTATUS
  124. GetForwarderParameters (
  125. IN PUNICODE_STRING RegistryPath
  126. ) {
  127. NTSTATUS Status;
  128. PWSTR RegistryPathBuffer;
  129. PWSTR Parameters = L"Parameters";
  130. RTL_QUERY_REGISTRY_TABLE paramTable[11]; // table size = nr of params + 1
  131. RegistryPathBuffer = (PWSTR)ExAllocatePoolWithTag(NonPagedPool, RegistryPath->Length + sizeof(WCHAR), 'gRwN');
  132. if (RegistryPathBuffer == NULL) {
  133. return STATUS_INSUFFICIENT_RESOURCES;
  134. }
  135. RtlCopyMemory (RegistryPathBuffer, RegistryPath->Buffer, RegistryPath->Length);
  136. *(PWCHAR)(((PUCHAR)RegistryPathBuffer)+RegistryPath->Length) = (WCHAR)'\0';
  137. RtlZeroMemory(&paramTable[0], sizeof(paramTable));
  138. paramTable[0].QueryRoutine = NULL;
  139. paramTable[0].Flags = RTL_QUERY_REGISTRY_SUBKEY;
  140. paramTable[0].Name = Parameters;
  141. paramTable[1].Flags = RTL_QUERY_REGISTRY_DIRECT;
  142. paramTable[1].Name = L"MaxRcvPktPoolSize";
  143. paramTable[1].EntryContext = &MaxRcvPktsPoolSize;
  144. paramTable[1].DefaultType = REG_DWORD;
  145. paramTable[1].DefaultData = &MaxRcvPktsPoolSize;
  146. paramTable[1].DefaultLength = sizeof(ULONG);
  147. paramTable[2].Flags = RTL_QUERY_REGISTRY_DIRECT;
  148. paramTable[2].Name = L"RcvPktsPerSegment";
  149. paramTable[2].EntryContext = &RcvPktsPerSegment;
  150. paramTable[2].DefaultType = REG_DWORD;
  151. paramTable[2].DefaultData = &RcvPktsPerSegment;
  152. paramTable[2].DefaultLength = sizeof(ULONG);
  153. paramTable[3].Flags = RTL_QUERY_REGISTRY_DIRECT;
  154. paramTable[3].Name = L"RouteTableSegmentSize";
  155. paramTable[3].EntryContext = &RouteSegmentSize;
  156. paramTable[3].DefaultType = REG_DWORD;
  157. paramTable[3].DefaultData = &RouteSegmentSize;
  158. paramTable[3].DefaultLength = sizeof(ULONG);
  159. paramTable[4].Flags = RTL_QUERY_REGISTRY_DIRECT;
  160. paramTable[4].Name = L"MaxSendPktsQueued";
  161. paramTable[4].EntryContext = &MaxSendPktsQueued;
  162. paramTable[4].DefaultType = REG_DWORD;
  163. paramTable[4].DefaultData = &MaxSendPktsQueued;
  164. paramTable[4].DefaultLength = sizeof(ULONG);
  165. paramTable[5].Flags = RTL_QUERY_REGISTRY_DIRECT;
  166. paramTable[5].Name = L"ClientHashSize";
  167. paramTable[5].EntryContext = &ClientHashSize;
  168. paramTable[5].DefaultType = REG_DWORD;
  169. paramTable[5].DefaultData = &ClientHashSize;
  170. paramTable[5].DefaultLength = sizeof(ULONG);
  171. paramTable[6].Flags = RTL_QUERY_REGISTRY_DIRECT;
  172. paramTable[6].Name = L"InterfaceHashSize";
  173. paramTable[6].EntryContext = &InterfaceHashSize;
  174. paramTable[6].DefaultType = REG_DWORD;
  175. paramTable[6].DefaultData = &InterfaceHashSize;
  176. paramTable[6].DefaultLength = sizeof(ULONG);
  177. paramTable[7].Flags = RTL_QUERY_REGISTRY_DIRECT;
  178. paramTable[7].Name = L"MaxNetbiosPacketsQueued";
  179. paramTable[7].EntryContext = &MaxNetbiosPacketsQueued;
  180. paramTable[7].DefaultType = REG_DWORD;
  181. paramTable[7].DefaultData = &MaxNetbiosPacketsQueued;
  182. paramTable[7].DefaultLength = sizeof(ULONG);
  183. paramTable[8].Flags = RTL_QUERY_REGISTRY_DIRECT;
  184. paramTable[8].Name = L"SpoofingTimeout";
  185. paramTable[8].EntryContext = &SpoofingTimeout;
  186. paramTable[8].DefaultType = REG_DWORD;
  187. paramTable[8].DefaultData = &SpoofingTimeout;
  188. paramTable[8].DefaultLength = sizeof(ULONG);
  189. paramTable[9].Flags = RTL_QUERY_REGISTRY_DIRECT;
  190. paramTable[9].Name = L"DontSuppressNonAgentSapAdvertisements";
  191. paramTable[9].EntryContext = &DontSuppressNonAgentSapAdvertisements;
  192. paramTable[9].DefaultType = REG_DWORD;
  193. paramTable[9].DefaultData = &DontSuppressNonAgentSapAdvertisements;
  194. paramTable[9].DefaultLength = sizeof(ULONG);
  195. Status = RtlQueryRegistryValues(
  196. RTL_REGISTRY_ABSOLUTE,
  197. RegistryPathBuffer,
  198. paramTable,
  199. NULL,
  200. NULL);
  201. if(!NT_SUCCESS(Status)) {
  202. IpxFwdDbgPrint (DBG_REGISTRY, DBG_WARNING,
  203. ("IpxFwd: Missing Parameters key in the registry\n"));
  204. }
  205. ExFreePool(RegistryPathBuffer);
  206. if ((RcvPktsPerSegment > MAX_RCV_PKTS_PER_SEGMENT) ||
  207. (RcvPktsPerSegment < MIN_RCV_PKTS_PER_SEGMENT)) {
  208. RcvPktsPerSegment = DEF_RCV_PKTS_PER_SEGMENT;
  209. }
  210. if ((RouteSegmentSize > MAX_ROUTE_SEGMENT_SIZE) ||
  211. (RouteSegmentSize < MIN_ROUTE_SEGMENT_SIZE)) {
  212. RouteSegmentSize = DEF_ROUTE_SEGMENT_SIZE;
  213. }
  214. else
  215. RouteSegmentSize = (ULONG) ROUND_TO_PAGES(RouteSegmentSize);
  216. if ((InterfaceHashSize > MAX_INTERFACE_HASH_SIZE) ||
  217. (InterfaceHashSize < MIN_INTERFACE_HASH_SIZE)) {
  218. InterfaceHashSize = DEF_INTERFACE_HASH_SIZE;
  219. }
  220. if ((ClientHashSize > MAX_CLIENT_HASH_SIZE) ||
  221. (ClientHashSize < MIN_CLIENT_HASH_SIZE)) {
  222. ClientHashSize = DEF_CLIENT_HASH_SIZE;
  223. }
  224. // even if the RtlQueryRegistryValues has failed, we return success and will
  225. // use the defaults.
  226. return STATUS_SUCCESS;
  227. }
  228.