Source code of Windows XP (NT5)
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.

257 lines
8.4 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. regmuck.c
  5. Abstract:
  6. This module contains the routines for mucking with the registry for smbrdr.exe
  7. Author:
  8. Revision History:
  9. --*/
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <string.h>
  13. #include <nt.h>
  14. #include <ntrtl.h>
  15. #include <nturtl.h>
  16. #include <windows.h>
  17. #include "smbrdr.h"
  18. // Global Registry key definitions for the new Redirector
  19. // the key definition is relative to HKEY_LOCAL_MACHINE
  20. #define RDBSS_REGISTRY_KEY L"System\\CurrentControlSet\\Services\\Rdbss"
  21. #define MRXSMB_REGISTRY_KEY L"System\\CurrentControlSet\\Services\\MRxSmb"
  22. #define MRXPROXY_REGISTRY_KEY L"System\\CurrentControlSet\\Services\\Reflctor"
  23. //most of the keynames are not #defined even if they were it wouldn't be here
  24. //#define MINI_REDIRECTORS L"MiniRedirectors"
  25. #define LAST_LOAD_STATUS L"LastLoadStatus"
  26. #define SwRxSetRegX(KEYHANDLE,NAME,REGTYPE,VALUEASPTR,VALUESIZE) { \
  27. TempStatus = RegSetValueEx( \
  28. KEYHANDLE, \
  29. NAME, \
  30. 0, \
  31. REGTYPE, \
  32. VALUEASPTR, \
  33. VALUESIZE); \
  34. if (TempStatus != ERROR_SUCCESS) { \
  35. printf("ERROR (%d) in adjusting the registry: cant store %ws\n", \
  36. TempStatus,NAME); \
  37. RegCloseKey(KEYHANDLE); \
  38. return(TempStatus); \
  39. } \
  40. }
  41. #define SwRxSetRegDword(KEYHANDLE,NAME,VALUE) { \
  42. DWORD DwordValue = VALUE; \
  43. SwRxSetRegX(KEYHANDLE,NAME,REG_DWORD,((PCHAR)&DwordValue),sizeof(DWORD)); \
  44. }
  45. #define SwRxSetRegSz(KEYHANDLE,NAME,VALUE) { \
  46. SwRxSetRegX(KEYHANDLE,NAME,REG_SZ,((PCHAR)VALUE),sizeof(VALUE)); \
  47. }
  48. #define SwRxSetRegExpandSz(KEYHANDLE,NAME,VALUE) { \
  49. SwRxSetRegX(KEYHANDLE,NAME,REG_EXPAND_SZ,((PCHAR)VALUE),sizeof(VALUE)); \
  50. }
  51. #define SwRxSetRegMultiSz(KEYHANDLE,NAME,VALUE) { \
  52. SwRxSetRegX(KEYHANDLE,NAME,REG_MULTI_SZ,((PCHAR)VALUE),sizeof(VALUE)); \
  53. }
  54. #define SwRxCreateKey(KEYHANDLE,KEYNAME) { \
  55. DWORD Disposition; \
  56. TempStatus = RegCreateKeyEx ( \
  57. HKEY_LOCAL_MACHINE, \
  58. KEYNAME, \
  59. 0, \
  60. NULL, \
  61. 0, \
  62. KEY_ALL_ACCESS, \
  63. NULL, \
  64. &KEYHANDLE, \
  65. &Disposition \
  66. ); \
  67. \
  68. if (TempStatus != ERROR_SUCCESS) { \
  69. printf("ERROR (%d) in adjusting the registry: cant create key %ws\n", \
  70. TempStatus,KEYNAME); \
  71. return(TempStatus); \
  72. } \
  73. }
  74. extern BOOLEAN SwRxProxyEnabled;
  75. NET_API_STATUS
  76. SwRxRdr2Muck(
  77. void
  78. )
  79. {
  80. NET_API_STATUS TempStatus;
  81. HKEY hRedirectorKey;
  82. printf("Adjusting the registry for Rdr2\n");
  83. //altho the code for the three different drivers is essentially similar, it is
  84. // not combined so that it can be changed more readily
  85. if (SwRxProxyEnabled) {
  86. //\registry\machine\system\currentcontrolset\services\reflctor
  87. // Type = REG_DWORD 0x00000002
  88. // Start = REG_DWORD 0x00000003
  89. // ErrorControl = REG_DWORD 0x00000001
  90. // ImagePath = REG_EXPAND_SZ \SystemRoot\System32\drivers\reflctor.sys
  91. // DisplayName = mrxproxy
  92. // Group = Network
  93. // Linkage
  94. // Disabled
  95. // Parameters
  96. // Security
  97. SwRxCreateKey(hRedirectorKey,MRXPROXY_REGISTRY_KEY L"\\Linkage\\Disabled");
  98. RegCloseKey(hRedirectorKey);
  99. SwRxCreateKey(hRedirectorKey,MRXPROXY_REGISTRY_KEY L"\\Parameters");
  100. RegCloseKey(hRedirectorKey);
  101. SwRxCreateKey(hRedirectorKey,MRXPROXY_REGISTRY_KEY L"\\Security");
  102. RegCloseKey(hRedirectorKey);
  103. SwRxCreateKey(hRedirectorKey,MRXPROXY_REGISTRY_KEY);
  104. SwRxSetRegDword(hRedirectorKey,L"Type",0x00000002);
  105. SwRxSetRegDword(hRedirectorKey,L"Start",0x00000003);
  106. SwRxSetRegDword(hRedirectorKey,L"ErrorControl",0x00000001);
  107. SwRxSetRegSz(hRedirectorKey,L"DisplayName",L"Reflctor");
  108. SwRxSetRegSz(hRedirectorKey,L"Group",L"Network");
  109. SwRxSetRegExpandSz(hRedirectorKey,L"ImagePath",L"System32\\drivers\\reflctor.sys");
  110. RegCloseKey(hRedirectorKey);
  111. }
  112. printf("no longer muck with mrxsmb or rdbss\n");
  113. #if 0
  114. //\registry\machine\system\currentcontrolset\services\mrxsmb
  115. // Type = REG_DWORD 0x00000002
  116. // Start = REG_DWORD 0x00000003
  117. // ErrorControl = REG_DWORD 0x00000001
  118. // ImagePath = REG_EXPAND_SZ \SystemRoot\System32\drivers\mrxsmb.sys
  119. // DisplayName = mrxsmb
  120. // Group = Network
  121. // Linkage
  122. // Disabled
  123. // Parameters
  124. // Security
  125. SwRxCreateKey(hRedirectorKey,MRXSMB_REGISTRY_KEY L"\\Linkage\\Disabled");
  126. RegCloseKey(hRedirectorKey);
  127. SwRxCreateKey(hRedirectorKey,MRXSMB_REGISTRY_KEY L"\\Parameters");
  128. RegCloseKey(hRedirectorKey);
  129. SwRxCreateKey(hRedirectorKey,MRXSMB_REGISTRY_KEY L"\\Security");
  130. RegCloseKey(hRedirectorKey);
  131. SwRxCreateKey(hRedirectorKey,MRXSMB_REGISTRY_KEY);
  132. SwRxSetRegDword(hRedirectorKey,L"Type",0x00000002);
  133. SwRxSetRegDword(hRedirectorKey,L"Start",0x00000003);
  134. SwRxSetRegDword(hRedirectorKey,L"ErrorControl",0x00000001);
  135. SwRxSetRegSz(hRedirectorKey,L"DisplayName",L"MRxSmb");
  136. SwRxSetRegSz(hRedirectorKey,L"Group",L"Network");
  137. SwRxSetRegExpandSz(hRedirectorKey,L"ImagePath",L"\\SystemRoot\\System32\\drivers\\mrxsmb.sys");
  138. SwRxSetRegDword(hRedirectorKey,LAST_LOAD_STATUS,0);
  139. RegCloseKey(hRedirectorKey);
  140. //\registry\machine\system\currentcontrolset\services\rdbss
  141. // Type = REG_DWORD 0x00000002
  142. // Start = REG_DWORD 0x00000003
  143. // ErrorControl = REG_DWORD 0x00000001
  144. // ImagePath = REG_EXPAND_SZ \SystemRoot\System32\drivers\rdbss.sys
  145. // DisplayName = Rdbss
  146. // Group = Network
  147. // LastLoadStatus = REG_DWORD 0x0
  148. // Linkage
  149. // Disabled
  150. // Parameters
  151. // Security
  152. SwRxCreateKey(hRedirectorKey,RDBSS_REGISTRY_KEY L"\\Linkage\\Disabled");
  153. RegCloseKey(hRedirectorKey);
  154. SwRxCreateKey(hRedirectorKey,RDBSS_REGISTRY_KEY L"\\Parameters");
  155. RegCloseKey(hRedirectorKey);
  156. SwRxCreateKey(hRedirectorKey,RDBSS_REGISTRY_KEY L"\\Security");
  157. RegCloseKey(hRedirectorKey);
  158. SwRxCreateKey(hRedirectorKey,RDBSS_REGISTRY_KEY);
  159. SwRxSetRegDword(hRedirectorKey,L"Type",0x00000002);
  160. SwRxSetRegDword(hRedirectorKey,L"Start",0x00000003);
  161. SwRxSetRegDword(hRedirectorKey,L"ErrorControl",0x00000001);
  162. SwRxSetRegSz(hRedirectorKey,L"DisplayName",L"Rdbss");
  163. SwRxSetRegSz(hRedirectorKey,L"Group",L"Network");
  164. SwRxSetRegExpandSz(hRedirectorKey,L"ImagePath",L"\\SystemRoot\\System32\\drivers\\rdbss.sys");
  165. RegCloseKey(hRedirectorKey);
  166. ////now put in the new minirdr enumeration
  167. ///SwRxCreateKey(hRedirectorKey,RDBSS_REGISTRY_KEY L"\\MiniRdrs");
  168. //SwRxSetRegDword(hRedirectorKey,L"MRxSmb",0xbaadf00d);
  169. //SwRxSetRegDword(hRedirectorKey,L"MRxFtp00",0xbaadf10d);
  170. //SwRxSetRegDword(hRedirectorKey,L"MRxNfs",0xbaadf20d);
  171. //SwRxSetRegDword(hRedirectorKey,L"MRxNcp6",0xbaadf30d);
  172. //RegCloseKey(hRedirectorKey);
  173. #endif
  174. return ERROR_SUCCESS;
  175. }
  176. NET_API_STATUS
  177. SwRxRdr1Muck(
  178. void
  179. )
  180. {
  181. NET_API_STATUS TempStatus;
  182. HKEY hRedirectorKey;
  183. DWORD FinalStatus;
  184. printf("Adjusting the registry for Rdr1...........\n");
  185. TempStatus = RegOpenKeyEx(
  186. HKEY_LOCAL_MACHINE,
  187. MRXSMB_REGISTRY_KEY,
  188. 0,
  189. KEY_ALL_ACCESS,
  190. &hRedirectorKey);
  191. if (TempStatus == ERROR_SUCCESS) {
  192. //the value 0 would mean load rdr2; the value 0x15 (ERROR_NOT_READY)
  193. //would mean load rdr1 BUT ONLY IS THE RDR IS NOT RUNNING. 0x1 means
  194. //start rdr1 on the next load
  195. SwRxSetRegDword(hRedirectorKey,LAST_LOAD_STATUS,0x1);
  196. RegCloseKey(hRedirectorKey);
  197. }
  198. return ERROR_SUCCESS;
  199. }
  200.