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.

234 lines
9.0 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) October 30, 1995.
  11. //
  12. // Revision History:
  13. //
  14. // Nov 5th 1996 Ram Cherala (ramc) Changed default value of
  15. // EnableUnnumberedWanLinks to 0
  16. // because there is no UI to disable it.
  17. //
  18. //***
  19. #include "precomp.h"
  20. #pragma hdrstop
  21. BOOL bAssignSpecificNode = FALSE;
  22. DWORD LastNodeAssigned; // Don't initialize so it will be random
  23. //
  24. //*** IPXCP Registry Parameters ***
  25. IPXCP_GLOBAL_CONFIG_PARAMS GlobalConfig =
  26. {
  27. {0,0,0, {0,0,0,0}}, // RParams
  28. 1, // SingleClientDialout
  29. 0, // FirstWanNet
  30. 0, // WanNetPoolSize
  31. {0,0,0}, // WanNetPoolStr;
  32. 1, // EnableUnnumberedWanLinks;
  33. 1, // EnableAutoWanNetAllocation;
  34. 0, // EnableCompressionProtocol;
  35. 0, // EnableIpxwanForWorkstationDialout;
  36. 0, // AcceptRemoteNodeNumber;
  37. 0, // DebugLog;
  38. {0,0,0,0,0,0} // The specific wan node
  39. };
  40. // Returns a 1 byte value representing 2 hex digits
  41. UCHAR GetHexValue (PWCHAR pszDigits) {
  42. DWORD dw1, dw2;
  43. if ((pszDigits[0] >= L'0') && (pszDigits[0] <= L'9'))
  44. dw1 = (pszDigits[0] - L'0');
  45. else if ((pszDigits[0] >= L'A') && (pszDigits[0] <= L'D'))
  46. dw1 = (pszDigits[0] - L'A') + 10;
  47. else
  48. dw1 = 0;
  49. if ((pszDigits[1] >= L'0') && (pszDigits[1] <= L'9'))
  50. dw2 = (pszDigits[1] - L'0');
  51. else if ((pszDigits[1] >= L'A') && (pszDigits[1] <= L'D'))
  52. dw2 = (pszDigits[1] - L'A') + 10;
  53. else
  54. dw2 = 0;
  55. return (UCHAR) (16 * dw1 + dw2);
  56. }
  57. // Assigns the first wan node as stored in pUniStrSrc and returns TRUE if this
  58. // node is non zero.
  59. BOOL CopyWanNode (PUCHAR puDst, UNICODE_STRING * pUniStrSrc) {
  60. PWCHAR pBuf = pUniStrSrc->Buffer;
  61. DWORD i;
  62. if ((!pBuf) || (pUniStrSrc->Length == 0)) {
  63. memset (puDst, 0, 6);
  64. return FALSE;
  65. }
  66. // Convert the unicode string to uppercase
  67. _wcsupr(pBuf);
  68. puDst[0] = GetHexValue(&pBuf[0]);
  69. puDst[1] = GetHexValue(&pBuf[2]);
  70. puDst[2] = GetHexValue(&pBuf[4]);
  71. puDst[3] = GetHexValue(&pBuf[6]);
  72. puDst[4] = GetHexValue(&pBuf[8]);
  73. puDst[5] = GetHexValue(&pBuf[10]);
  74. return TRUE;
  75. }
  76. //***
  77. //
  78. // Function: GetIpxCpParameters
  79. //
  80. // Descr: Reads the parameters from the registry and sets them
  81. //
  82. //***
  83. VOID
  84. GetIpxCpParameters(PIPXCP_GLOBAL_CONFIG_PARAMS pConfig)
  85. {
  86. NTSTATUS Status;
  87. PWSTR IpxRouterParametersPath = L"RemoteAccess\\Parameters\\Ipx";
  88. RTL_QUERY_REGISTRY_TABLE paramTable[14]; // table size = nr of params + 1
  89. DWORD InvalidNetworkAccessValue = 987654,
  90. AllowNetworkAccess = InvalidNetworkAccessValue;
  91. WCHAR pszFirstWanNode[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
  92. UNICODE_STRING UniStrFirstWanNode = {0, 0, NULL};
  93. RtlZeroMemory(&paramTable[0], sizeof(paramTable));
  94. RtlInitUnicodeString (&(pConfig->WanNetPoolStr), NULL);
  95. paramTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
  96. paramTable[0].Name = L"FirstWanNet";
  97. paramTable[0].EntryContext = &(pConfig->FirstWanNet);
  98. paramTable[0].DefaultType = REG_DWORD;
  99. paramTable[0].DefaultData = &(pConfig->FirstWanNet);
  100. paramTable[0].DefaultLength = sizeof(ULONG);
  101. paramTable[1].Flags = RTL_QUERY_REGISTRY_DIRECT;
  102. paramTable[1].Name = L"WanNetPoolSize";
  103. paramTable[1].EntryContext = &(pConfig->WanNetPoolSize);
  104. paramTable[1].DefaultType = REG_DWORD;
  105. paramTable[1].DefaultData = &(pConfig->WanNetPoolSize);
  106. paramTable[1].DefaultLength = sizeof(ULONG);
  107. paramTable[2].Flags = RTL_QUERY_REGISTRY_DIRECT;
  108. paramTable[2].Name = L"EnableUnnumberedWanLinks";
  109. paramTable[2].EntryContext = &(pConfig->EnableUnnumberedWanLinks);
  110. paramTable[2].DefaultType = REG_DWORD;
  111. paramTable[2].DefaultData = &(pConfig->EnableUnnumberedWanLinks);
  112. paramTable[2].DefaultLength = sizeof(ULONG);
  113. paramTable[3].Flags = RTL_QUERY_REGISTRY_DIRECT;
  114. paramTable[3].Name = L"GlobalWanNet";
  115. paramTable[3].EntryContext = &(pConfig->RParams.EnableGlobalWanNet);
  116. paramTable[3].DefaultType = REG_DWORD;
  117. paramTable[3].DefaultData = &(pConfig->RParams.EnableGlobalWanNet);
  118. paramTable[3].DefaultLength = sizeof(ULONG);
  119. paramTable[4].Flags = RTL_QUERY_REGISTRY_DIRECT;
  120. paramTable[4].Name = L"AutoWanNetAllocation";
  121. paramTable[4].EntryContext = &(pConfig->EnableAutoWanNetAllocation);
  122. paramTable[4].DefaultType = REG_DWORD;
  123. paramTable[4].DefaultData = &(pConfig->EnableAutoWanNetAllocation);
  124. paramTable[4].DefaultLength = sizeof(ULONG);
  125. paramTable[5].Flags = RTL_QUERY_REGISTRY_DIRECT;
  126. paramTable[5].Name = L"DebugLog";
  127. paramTable[5].EntryContext = &(pConfig->DebugLog);
  128. paramTable[5].DefaultType = REG_DWORD;
  129. paramTable[5].DefaultData = &(pConfig->DebugLog);
  130. paramTable[5].DefaultLength = sizeof(ULONG);
  131. paramTable[6].Flags = RTL_QUERY_REGISTRY_DIRECT;
  132. paramTable[6].Name = L"EnableCompressionProtocol";
  133. paramTable[6].EntryContext = &(pConfig->EnableCompressionProtocol);
  134. paramTable[6].DefaultType = REG_DWORD;
  135. paramTable[6].DefaultData = &(pConfig->EnableCompressionProtocol);
  136. paramTable[6].DefaultLength = sizeof(ULONG);
  137. paramTable[7].Flags = RTL_QUERY_REGISTRY_DIRECT;
  138. paramTable[7].Name = L"SingleClientDialout";
  139. paramTable[7].EntryContext = &(pConfig->SingleClientDialout);
  140. paramTable[7].DefaultType = REG_DWORD;
  141. paramTable[7].DefaultData = &(pConfig->SingleClientDialout);
  142. paramTable[7].DefaultLength = sizeof(ULONG);
  143. paramTable[8].Flags = RTL_QUERY_REGISTRY_DIRECT;
  144. paramTable[8].Name = L"AllowNetworkAccess";
  145. paramTable[8].EntryContext = &AllowNetworkAccess;
  146. paramTable[8].DefaultType = REG_DWORD;
  147. paramTable[8].DefaultData = &AllowNetworkAccess;
  148. paramTable[8].DefaultLength = sizeof(ULONG);
  149. paramTable[9].Flags = RTL_QUERY_REGISTRY_DIRECT;
  150. paramTable[9].Name = L"EnableIpxwanForWorkstationDialout";
  151. paramTable[9].EntryContext = &(pConfig->EnableIpxwanForWorkstationDialout);
  152. paramTable[9].DefaultType = REG_DWORD;
  153. paramTable[9].DefaultData = &(pConfig->EnableIpxwanForWorkstationDialout);
  154. paramTable[9].DefaultLength = sizeof(ULONG);
  155. paramTable[10].Flags = RTL_QUERY_REGISTRY_DIRECT;
  156. paramTable[10].Name = L"AcceptRemoteNodeNumber";
  157. paramTable[10].EntryContext = &(pConfig->AcceptRemoteNodeNumber);
  158. paramTable[10].DefaultType = REG_DWORD;
  159. paramTable[10].DefaultData = &(pConfig->AcceptRemoteNodeNumber);
  160. paramTable[10].DefaultLength = sizeof(ULONG);
  161. paramTable[11].Flags = RTL_QUERY_REGISTRY_DIRECT|RTL_QUERY_REGISTRY_NOEXPAND;
  162. paramTable[11].Name = L"WanNetPool";
  163. paramTable[11].EntryContext = &(pConfig->WanNetPoolStr);
  164. paramTable[11].DefaultType = REG_MULTI_SZ;
  165. paramTable[11].DefaultData = &(pConfig->WanNetPoolStr);
  166. paramTable[11].DefaultLength = 0;
  167. paramTable[12].Flags = RTL_QUERY_REGISTRY_DIRECT|RTL_QUERY_REGISTRY_NOEXPAND;
  168. paramTable[12].Name = L"FirstWanNode";
  169. paramTable[12].EntryContext = &UniStrFirstWanNode;
  170. paramTable[12].DefaultType = REG_SZ;
  171. paramTable[12].DefaultData = &UniStrFirstWanNode;
  172. paramTable[12].DefaultLength = 0;
  173. Status = RtlQueryRegistryValues(
  174. RTL_REGISTRY_SERVICES,
  175. IpxRouterParametersPath,
  176. paramTable,
  177. NULL,
  178. NULL);
  179. // The registry parameter "ThisMachineOnly" was replaced
  180. // with the parameter "AllowNetworkAddress" whose semantics
  181. // are the inverse. If a new value was assigned to
  182. // AllowNetworkAccess, assign its inverse to pConfig->RParams.ThisMachineOnly
  183. // here.
  184. if (AllowNetworkAccess != InvalidNetworkAccessValue)
  185. pConfig->RParams.ThisMachineOnly = !AllowNetworkAccess;
  186. // Find out if a specific node number has been provided
  187. // in the registry.
  188. bAssignSpecificNode = CopyWanNode (pConfig->puSpecificNode, &UniStrFirstWanNode);
  189. if (bAssignSpecificNode) {
  190. GETLONG2ULONG(&LastNodeAssigned,&(pConfig->puSpecificNode[2]));
  191. //TraceIpx(OPTIONS_TRACE, "GetIpxCpParameters: FirstWanNode: %.2x%.2x%.2x%.2x%.2x%.2x LastNodeAssigned= %x",
  192. //pConfig->puSpecificNode[0],
  193. //pConfig->puSpecificNode[1],
  194. //pConfig->puSpecificNode[2],
  195. //pConfig->puSpecificNode[3],
  196. //pConfig->puSpecificNode[4],
  197. //pConfig->puSpecificNode[5],
  198. //LastNodeAssigned);
  199. }
  200. }