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.

392 lines
11 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1991 - 1998.
  5. //
  6. // File: catreg.hxx
  7. //
  8. // Contents: Catalog registry helper classes
  9. //
  10. // Classes: CGibCallBack, CRegistryScopesCallBackFixups,
  11. // CRegistryScopesCallBackAdd, CRegistryScopesCallBackFind
  12. //
  13. // History: 13-Dec-1996 dlee split from cicat.cxx
  14. // 24-Jul-1997 KrishnaN enabled for null catalogs
  15. //
  16. //----------------------------------------------------------------------------
  17. #pragma once
  18. #include <dynload.hxx>
  19. #include <tstrhash.hxx>
  20. #include <notifary.hxx>
  21. //+---------------------------------------------------------------------------
  22. //
  23. // Class: CIISVirtualDirectory
  24. //
  25. // Purpose: All the info CI needs for an IIS virtual directory
  26. //
  27. // History: 2-Sep-97 dlee Created
  28. //
  29. //----------------------------------------------------------------------------
  30. class CIISVirtualDirectory
  31. {
  32. public:
  33. CIISVirtualDirectory( WCHAR const * pwcVPath,
  34. WCHAR const * pwcPPath,
  35. BOOL fIsIndexed,
  36. DWORD dwAccess,
  37. WCHAR const * pwcUser,
  38. WCHAR const * pwcPassword,
  39. BOOL fIsAVRoot );
  40. WCHAR const * VPath() { return _xVPath.GetPointer(); }
  41. unsigned VPathLen() { return _cwcVPath; }
  42. WCHAR const * PPath() { return _xPPath.GetPointer(); }
  43. unsigned PPathLen() { return _cwcPPath; }
  44. BOOL IsIndexed() { return _fIsIndexed; }
  45. BOOL IsAVRoot() { return _fIsAVRoot; }
  46. DWORD Access() { return _dwAccess; }
  47. WCHAR const * User() { return _xUser.GetPointer(); }
  48. WCHAR const * Password() { return _xPassword.GetPointer(); }
  49. ULONG Hash()
  50. {
  51. return Hash( VPath() );
  52. }
  53. static ULONG Hash( WCHAR const * pwc )
  54. {
  55. ULONG ulG;
  56. for ( ULONG ulH=0; *pwc; pwc++)
  57. {
  58. ulH = (ulH << 4) + (*pwc);
  59. if (ulG = (ulH & 0xf0000000))
  60. ulH ^= ulG >> 24;
  61. ulH &= ~ulG;
  62. }
  63. return ulH;
  64. }
  65. int Compare( WCHAR const * pwcVDir )
  66. {
  67. return wcscmp( VPath(), pwcVDir );
  68. }
  69. CIISVirtualDirectory * & Next() { return _pNext; }
  70. private:
  71. XPtrST<WCHAR> _xVPath;
  72. unsigned _cwcVPath;
  73. XPtrST<WCHAR> _xPPath;
  74. unsigned _cwcPPath;
  75. BOOL _fIsIndexed;
  76. BOOL _fIsAVRoot;
  77. DWORD _dwAccess;
  78. XPtrST<WCHAR> _xUser;
  79. XPtrST<WCHAR> _xPassword;
  80. CIISVirtualDirectory * _pNext;
  81. };
  82. //+---------------------------------------------------------------------------
  83. //
  84. // Class: CIISVirtualDirectories
  85. //
  86. // Purpose: Maintains a list of IIS virtual directories
  87. //
  88. // History: 2-Sep-97 dlee Created
  89. //
  90. //----------------------------------------------------------------------------
  91. class CiCat;
  92. class CIISVirtualDirectories : public CMetaDataCallBack
  93. {
  94. public:
  95. CIISVirtualDirectories( CiVRootTypeEnum eType ) : _eType( eType ) {}
  96. ~CIISVirtualDirectories() {}
  97. SCODE CallBack( WCHAR const * pwcVRoot,
  98. WCHAR const * pwcPRoot,
  99. BOOL fIsIndexed,
  100. DWORD dwAccess,
  101. WCHAR const * pwcUser,
  102. WCHAR const * pwcPassword,
  103. BOOL fIsAVRoot );
  104. BOOL Lookup( WCHAR const * pwcVPath,
  105. unsigned cwcVPath,
  106. WCHAR const * pwcPPath,
  107. unsigned cwcPPath );
  108. void Enum( CiCat & cicat );
  109. void Enum( CMetaDataCallBack & callback );
  110. private:
  111. CCountedDynArray<CIISVirtualDirectory> _aDirectories;
  112. CHashtable<CIISVirtualDirectory> _htDirectories;
  113. CiVRootTypeEnum _eType;
  114. };
  115. //+-------------------------------------------------------------------------
  116. //
  117. // Class: CRegistryScopesCallBackFixups
  118. //
  119. // Synopsis: Callback class for adding scope fixups
  120. //
  121. // History: 16-Oct-96 dlee Created
  122. //
  123. //--------------------------------------------------------------------------
  124. class CRegistryScopesCallBackFixups : public CRegCallBack
  125. {
  126. public:
  127. CRegistryScopesCallBackFixups( PCatalog * pCat ) :
  128. _pcat( pCat )
  129. {
  130. }
  131. NTSTATUS CallBack( WCHAR *pValueName, ULONG uValueType,
  132. VOID *pValueData, ULONG uValueLength)
  133. {
  134. CParseRegistryScope parse( pValueName,
  135. uValueType,
  136. pValueData,
  137. uValueLength );
  138. if ( ( parse.IsPhysical() ||
  139. parse.IsShadowAlias() ||
  140. parse.IsVirtualPlaceholder() ) &&
  141. ( 0 != parse.GetFixup() ) )
  142. {
  143. ciDebugOut(( DEB_ITRACE, "callbackFixups '%ws', fixup as '%ws'\n",
  144. pValueName, parse.GetFixup() ));
  145. _pcat->GetScopeFixup()->Add( parse.GetScope(), parse.GetFixup() );
  146. }
  147. return S_OK;
  148. }
  149. private:
  150. PCatalog * _pcat;
  151. }; //CRegistryScopesCallBackFixups
  152. //+-------------------------------------------------------------------------
  153. //
  154. // Class: CRegistryScopesCallBackRemoveAlias
  155. //
  156. // Synopsis: Callback class for removing automatic alias scopes
  157. //
  158. // History: 16-Oct-96 dlee Created
  159. //
  160. //--------------------------------------------------------------------------
  161. DeclDynLoad2( NetApi32,
  162. NetApiBufferFree,
  163. NET_API_STATUS,
  164. NET_API_FUNCTION,
  165. ( LPVOID Buffer ),
  166. ( Buffer ),
  167. NetShareGetInfo,
  168. NET_API_STATUS,
  169. NET_API_FUNCTION,
  170. ( LPWSTR servername, LPWSTR netname, DWORD level, LPBYTE * bufptr ),
  171. ( servername, netname, level, bufptr ) );
  172. class CRegistryScopesCallBackRemoveAlias : public CRegCallBack
  173. {
  174. public:
  175. CRegistryScopesCallBackRemoveAlias( CiCat & Cat,
  176. CDynLoadNetApi32 & dlNetApi32,
  177. BOOL fRemoveAll );
  178. NTSTATUS CallBack( WCHAR *pValueName, ULONG uValueType,
  179. VOID *pValueData, ULONG uValueLength);
  180. BOOL WasScopeRemoved() { return _fScopeRemoved; }
  181. private:
  182. CiCat & _cicat;
  183. CDynLoadNetApi32 & _dlNetApi32;
  184. BOOL _fScopeRemoved;
  185. BOOL _fRemoveAll;
  186. DWORD _ccCompName;
  187. WCHAR _wcsCompName[MAX_COMPUTERNAME_LENGTH+1];
  188. }; //CRegistryScopesCallBackRemoveAlias
  189. //+-------------------------------------------------------------------------
  190. //
  191. // Class: CRegistryScopesCallBackFind
  192. //
  193. // Synopsis: Callback class for finding a scope in the registry
  194. //
  195. // History: 16-Oct-96 dlee Created
  196. //
  197. //--------------------------------------------------------------------------
  198. class CRegistryScopesCallBackFind : public CRegCallBack
  199. {
  200. public:
  201. CRegistryScopesCallBackFind( WCHAR const *pwcRoot ) :
  202. _root( pwcRoot ),
  203. _fWasFound( FALSE )
  204. {
  205. _root.AppendBackSlash();
  206. ciDebugOut(( DEB_ITRACE, "callbackfind setup for '%ws'\n",
  207. _root.Get() ));
  208. }
  209. NTSTATUS CallBack( WCHAR *pValueName, ULONG uValueType,
  210. VOID *pValueData, ULONG uValueLength)
  211. {
  212. // if the value isn't a string, ignore it.
  213. if ( REG_SZ == uValueType )
  214. {
  215. CParseRegistryScope parse( pValueName,
  216. uValueType,
  217. pValueData,
  218. uValueLength );
  219. if ( parse.IsPhysical() )
  220. {
  221. CLowcaseBuf value( parse.GetScope() );
  222. value.AppendBackSlash();
  223. ciDebugOut(( DEB_ITRACE, "callbackfind '%ws', '%ws'\n",
  224. value.Get(), pValueData ));
  225. if ( _root.AreEqual( value ) )
  226. _fWasFound = TRUE;
  227. ciDebugOut(( DEB_ITRACE, "callbackfind wasfound: %d\n",
  228. _fWasFound ));
  229. }
  230. }
  231. return S_OK;
  232. }
  233. BOOL WasFound() { return _fWasFound; }
  234. private:
  235. BOOL _fWasFound;
  236. CLowcaseBuf _root;
  237. }; //CRegistryScopesCallBackFind
  238. //+-------------------------------------------------------------------------
  239. //
  240. // Class: CRegistryScopesCallBackAdd
  241. //
  242. // Synopsis: Callback class for adding scopes from the registry
  243. //
  244. // History: 16-Oct-96 dlee Created
  245. //
  246. //--------------------------------------------------------------------------
  247. class CRegistryScopesCallBackAdd : public CRegCallBack
  248. {
  249. public:
  250. CRegistryScopesCallBackAdd( CiCat &cicat ) : _cicat( cicat )
  251. {
  252. }
  253. NTSTATUS CallBack( WCHAR *pValueName, ULONG uValueType,
  254. VOID *pValueData, ULONG uValueLength );
  255. private:
  256. CiCat & _cicat;
  257. }; //CRegistryScopesCallBackAdd
  258. //+-------------------------------------------------------------------------
  259. //
  260. // Class: CRegistryScopesCallBackFillUsnArray
  261. //
  262. // Synopsis: Callback class for populating the Usn Volume Array with
  263. // scopes from the registry
  264. //
  265. // History: 23-Jun-98 kitmanh Created
  266. //
  267. //--------------------------------------------------------------------------
  268. class CRegistryScopesCallBackFillUsnArray : public CRegCallBack
  269. {
  270. public:
  271. CRegistryScopesCallBackFillUsnArray( CiCat &cicat ) : _cicat( cicat )
  272. {
  273. }
  274. NTSTATUS CallBack( WCHAR *pValueName, ULONG uValueType,
  275. VOID *pValueData, ULONG uValueLength );
  276. private:
  277. CiCat & _cicat;
  278. }; //CRegistryScopesCallBackAdd
  279. //+-------------------------------------------------------------------------
  280. //
  281. // Class: CRegistryScopesCallBackToDismount
  282. //
  283. // Synopsis: Callback class to check if the catalog contains a scope on
  284. // the volume to be dismounted
  285. //
  286. // History: 21-Jul-98 kitmanh Created
  287. //
  288. //--------------------------------------------------------------------------
  289. class CRegistryScopesCallBackToDismount : public CRegCallBack
  290. {
  291. public:
  292. CRegistryScopesCallBackToDismount( WCHAR wcVol ) :
  293. _wcVol( wcVol ),
  294. _fWasFound( FALSE )
  295. {
  296. }
  297. NTSTATUS CallBack( WCHAR *pValueName, ULONG uValueType,
  298. VOID *pValueData, ULONG uValueLength );
  299. BOOL WasFound() { return _fWasFound; }
  300. private:
  301. WCHAR _wcVol;
  302. BOOL _fWasFound;
  303. }; //CRegistryScopesCallBackToDismount
  304. //+-------------------------------------------------------------------------
  305. //
  306. // Class: CRegistryScopesCallBackAddDrvNotif
  307. //
  308. // Synopsis: Callback class to register the scopes for drive
  309. // notifications
  310. //
  311. // History: 19-Aug-98 kitmanh Created
  312. //
  313. //--------------------------------------------------------------------------
  314. class CRegistryScopesCallBackAddDrvNotif : public CRegCallBack
  315. {
  316. public:
  317. CRegistryScopesCallBackAddDrvNotif( CDrvNotifArray * pNotifArray ) :
  318. _pNotifArray( pNotifArray )
  319. {
  320. }
  321. NTSTATUS CallBack( WCHAR *pValueName, ULONG uValueType,
  322. VOID *pValueData, ULONG uValueLength );
  323. private:
  324. CDrvNotifArray * _pNotifArray;
  325. }; //CRegistryScopesCallBackAddDrvNotif