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.

345 lines
13 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. map.hxx
  5. Abstract:
  6. Name Space Extension Provider ( NSEP ) for mapping
  7. Author:
  8. Philippe Choquier (phillich) 25-Nov-1996
  9. --*/
  10. #if !defined(_MAP_NSEP_INCLUDE )
  11. #define _MAP_NSEP_INCLUDE
  12. class CNseInstance;
  13. #define NSEPM_ACCESS_ACCOUNT 0
  14. #define NSEPM_ACCESS_CERT 1
  15. #define NSEPM_ACCESS_NAME 2
  16. class CNseObj {
  17. public:
  18. CNseObj( LPSTR pName, DWORD dwId, BOOL fIter, CNseObj** pC, UINT cC, DWORD dwP = 0, DWORD dwP2 = 0)
  19. {
  20. m_pszName = pName;
  21. m_dwId = dwId;
  22. m_fIterated = fIter;
  23. m_pnoChildren = pC;
  24. m_cnoChildren = cC;
  25. m_dwParam = dwP;
  26. m_dwParam2 = dwP2;
  27. }
  28. virtual BOOL Add( CNseInstance*, DWORD dwIndex ) { return TRUE; }
  29. virtual BOOL Delete( LPSTR, CNseInstance* pI, DWORD dwIndex ) { return Release( pI, dwIndex ); }
  30. virtual BOOL Load( CNseInstance*, LPSTR pszPath ) { return FALSE; }
  31. virtual BOOL Save( CNseInstance* ) { return FALSE; }
  32. // called with index in object array
  33. virtual BOOL Set( CNseInstance*, DWORD dwIndex, PMETADATA_RECORD );
  34. virtual BOOL Get( CNseInstance*, DWORD dwIndex, PMETADATA_RECORD, LPDWORD pdwRequiredLen );
  35. virtual BOOL GetByIndex( CNseInstance*,
  36. DWORD dwIndex,
  37. PMETADATA_RECORD,
  38. DWORD dwI,
  39. LPDWORD pdwRequiredLen )
  40. { return FALSE; }
  41. virtual BOOL GetAll( CNseInstance* pWalk,
  42. DWORD dwIndex,
  43. LPDWORD pdwMDNumDataEntries,
  44. DWORD dwMDBufferSize,
  45. LPBYTE pbBuffer,
  46. LPDWORD pdwMDRequiredBufferSize)
  47. { return FALSE; }
  48. virtual BOOL BeginTransac( CNseInstance* ) { return TRUE; }
  49. virtual BOOL EndTransac( LPSTR pszPath, CNseInstance*, BOOL ) { return TRUE; }
  50. virtual BOOL Save( LPSTR pszPath, CNseInstance*, LPBOOL ) { return TRUE; }
  51. virtual DWORD GetCount( CNseInstance*, DWORD ) { return 0; }
  52. virtual BOOL Release( CNseInstance*, DWORD );
  53. public:
  54. DWORD GetId() { return m_dwId; }
  55. DWORD GetDwParam() { return m_dwParam; }
  56. DWORD GetDwParam2() { return m_dwParam2; }
  57. BOOL GetIterated() { return m_fIterated; }
  58. CNseInstance* Locate( CNseInstance* pI, PMETADATA_RECORD pMD );
  59. BOOL RemoveFromChildren( CNseInstance* pI, CNseInstance* pChild );
  60. public:
  61. CNseObj** m_pnoChildren;
  62. UINT m_cnoChildren;
  63. LPSTR m_pszName; // either Name or Id defined
  64. protected:
  65. DWORD m_dwId;
  66. BOOL m_fIterated;
  67. DWORD m_dwParam;
  68. DWORD m_dwParam2;
  69. } ;
  70. class CNseFieldMapperId : public CNseObj {
  71. public:
  72. CNseFieldMapperId( LPSTR pName, DWORD dwId, BOOL fIter, CNseObj** pC, UINT cC, DWORD dwP = 0, DWORD dwP2 = 0)
  73. : CNseObj( pName, dwId, fIter, pC, cC, dwP, dwP2 ) {}
  74. } ;
  75. class CNseFldMap : public CNseObj {
  76. public:
  77. CNseFldMap( LPSTR pName, DWORD dwId, BOOL fIter, CNseObj** pC, UINT cC, DWORD dwP = 0)
  78. : CNseObj( pName, dwId, fIter, pC, cC, dwP ) {}
  79. BOOL Release( CNseInstance* pI, DWORD dwIndex );
  80. BOOL Delete( LPSTR, CNseInstance* pI, DWORD dwIndex );
  81. DWORD GetCount( CNseInstance* pI, DWORD dwIndex );
  82. BOOL AddMapper( CNseInstance* pFather, CIisAcctMapper* pM );
  83. BOOL Save( LPSTR pszPath, CNseInstance* pI, LPBOOL );
  84. BOOL SaveMapper( LPSTR pszPath, CNseInstance* pI, DWORD dwId, LPBOOL );
  85. BOOL LoadAndUnserialize( CNseInstance* pI, CIisAcctMapper* pM, LPSTR pszPath, DWORD dwId );
  86. BOOL EndTransac( LPSTR pszPath, CNseInstance*, BOOL );
  87. } ;
  88. class CNseCert11Mapper : public CNseFldMap {
  89. public:
  90. CNseCert11Mapper( LPSTR pName, DWORD dwId, BOOL fIter, CNseObj** pC, UINT cC, DWORD dwP = 0)
  91. : CNseFldMap( pName, dwId, fIter, pC, cC, dwP ) {}
  92. BOOL Add( CNseInstance* pFather, DWORD );
  93. BOOL Load( CNseInstance* pI, LPSTR pszPath );
  94. } ;
  95. class CNseDigestMapper : public CNseFldMap {
  96. public:
  97. CNseDigestMapper( LPSTR pName, DWORD dwId, BOOL fIter, CNseObj** pC, UINT cC, DWORD dwP = 0)
  98. : CNseFldMap( pName, dwId, fIter, pC, cC, dwP ) {}
  99. BOOL Add( CNseInstance* pFather, DWORD );
  100. BOOL Load( CNseInstance* pI, LPSTR pszPath );
  101. } ;
  102. class CNseItaMapper : public CNseFldMap {
  103. public:
  104. CNseItaMapper( LPSTR pName, DWORD dwId, BOOL fIter, CNseObj** pC, UINT cC, DWORD dwP = 0)
  105. : CNseFldMap( pName, dwId, fIter, pC, cC, dwP ) {}
  106. BOOL Add( CNseInstance* pFather, DWORD );
  107. BOOL Load( CNseInstance* pI, LPSTR pszPath );
  108. } ;
  109. class CNseIssuers : public CNseObj {
  110. public:
  111. CNseIssuers( LPSTR pName, DWORD dwId, BOOL fIter, CNseObj** pC, UINT cC, DWORD dwP = 0)
  112. : CNseObj( pName, dwId, fIter, pC, cC, dwP ) {}
  113. BOOL Add( CNseInstance*, DWORD dwIndex ) { return FALSE; }
  114. BOOL Delete( LPSTR, CNseInstance* pI, DWORD dwIndex ) { return FALSE; }
  115. BOOL Load( CNseInstance* pI, LPSTR pszPath );
  116. BOOL Save( LPSTR pszPath, CNseInstance* pI, LPBOOL ) { return TRUE; }
  117. BOOL Release( CNseInstance* pI, DWORD dwIndex ) { return CNseObj::Release( pI, dwIndex ); }
  118. } ;
  119. class CNseCwMapper : public CNseObj {
  120. public:
  121. CNseCwMapper( LPSTR pName, DWORD dwId, BOOL fIter, CNseObj** pC, UINT cC, DWORD dwP = 0)
  122. : CNseObj( pName, dwId, fIter, pC, cC, dwP ) {}
  123. BOOL Add( CNseInstance*, DWORD dwIndex );
  124. BOOL Delete( LPSTR, CNseInstance* pI, DWORD dwIndex );
  125. BOOL Load( CNseInstance*, LPSTR pszPath );
  126. BOOL Save( LPSTR pszPath, CNseInstance* pI, LPBOOL );
  127. BOOL Release( CNseInstance* pI, DWORD dwIndex );
  128. } ;
  129. class CNseAllMappings : public CNseObj {
  130. public:
  131. CNseAllMappings( LPSTR pName, DWORD dwId, BOOL fIter, CNseObj** pC, UINT cC, DWORD dwP = 0)
  132. : CNseObj( pName, dwId, fIter, pC, cC, dwP ) {}
  133. BOOL Set( CNseInstance* pI, DWORD dwIndex, PMETADATA_RECORD pMD );
  134. BOOL Get( CNseInstance*, DWORD dwIndex, PMETADATA_RECORD pMD, LPDWORD pdwReq );
  135. BOOL GetByIndex( CNseInstance*,
  136. DWORD dwIndex,
  137. PMETADATA_RECORD pMD,
  138. DWORD dwI,
  139. LPDWORD pdwReq );
  140. DWORD GetCount( CNseInstance* pI, DWORD dwIndex );
  141. // Get property of iterated entry
  142. BOOL Get( CNseInstance*, DWORD dwIndex, PMETADATA_RECORD pMD, CNseInstance* pL, LPDWORD pdwReq );
  143. BOOL Add( CNseInstance* pI, DWORD dwIndex );
  144. BOOL Delete( LPSTR, CNseInstance* pI, DWORD dwIndex );
  145. BOOL GetAll( CNseInstance* pWalk,
  146. DWORD dwIndex,
  147. LPDWORD pdwMDNumDataEntries,
  148. DWORD dwMDBufferSize,
  149. LPBYTE pbBuffer,
  150. LPDWORD pdwMDRequiredBufferSize);
  151. } ;
  152. class CNseCert11Mapping : public CNseAllMappings {
  153. public:
  154. CNseCert11Mapping( LPSTR pName, DWORD dwId, BOOL fIter, CNseObj** pC, UINT cC, DWORD dwP = 0)
  155. : CNseAllMappings( pName, dwId, fIter, pC, cC, dwP ) {}
  156. } ;
  157. class CNseDigestMapping : public CNseAllMappings {
  158. public:
  159. CNseDigestMapping( LPSTR pName, DWORD dwId, BOOL fIter, CNseObj** pC, UINT cC, DWORD dwP = 0)
  160. : CNseAllMappings( pName, dwId, fIter, pC, cC, dwP ) {}
  161. } ;
  162. class CNseItaMapping : public CNseAllMappings {
  163. public:
  164. CNseItaMapping( LPSTR pName, DWORD dwId, BOOL fIter, CNseObj** pC, UINT cC, DWORD dwP = 0)
  165. : CNseAllMappings( pName, dwId, fIter, pC, cC, dwP ) {}
  166. } ;
  167. class CNoCppObj : public CNseObj {
  168. public:
  169. CNoCppObj( LPSTR pName, DWORD dwId, BOOL fIter, CNseObj** pC, UINT cC, DWORD dwP = NULL )
  170. : CNseObj( pName, dwId, fIter, pC, cC, dwP ) {}
  171. BOOL Get( CNseInstance*pI, DWORD, PMETADATA_RECORD pM, LPDWORD pdwRequiredLen );
  172. BOOL Set( CNseInstance*, DWORD dwIndex, PMETADATA_RECORD ) { return FALSE; }
  173. BOOL Add( CNseInstance*, DWORD ) { return FALSE; }
  174. BOOL Delete( LPSTR, CNseInstance*, DWORD ) { return FALSE; }
  175. } ;
  176. class CKeyedAccess : public CNseObj {
  177. public:
  178. CKeyedAccess( LPSTR pName, DWORD dwId, BOOL fIter, CNseObj** pC, UINT cC, DWORD dwP = NULL )
  179. : CNseObj( pName, dwId, fIter, pC, cC, dwP ) {}
  180. BOOL Get( CNseInstance*pI, DWORD, PMETADATA_RECORD pM, LPDWORD pdwRequiredLen );
  181. BOOL Set( CNseInstance*, DWORD dwIndex, PMETADATA_RECORD, DWORD dwType );
  182. BOOL Add( CNseInstance*, DWORD ) { return FALSE; }
  183. BOOL Delete( LPSTR, CNseInstance*, DWORD ) { return FALSE; }
  184. } ;
  185. class CAccessByAccount : public CKeyedAccess {
  186. public:
  187. CAccessByAccount( LPSTR pName, DWORD dwId, BOOL fIter, CNseObj** pC, UINT cC, DWORD dwP = NULL )
  188. : CKeyedAccess( pName, dwId, fIter, pC, cC, dwP ) {}
  189. BOOL Set( CNseInstance* pI, DWORD dwIndex, PMETADATA_RECORD pMD )
  190. { return CKeyedAccess::Set( pI, dwIndex, pMD, NSEPM_ACCESS_ACCOUNT ); }
  191. BOOL Add( CNseInstance*, DWORD ) { return FALSE; }
  192. BOOL Delete( LPSTR, CNseInstance*, DWORD ) { return FALSE; }
  193. } ;
  194. class CAccessByCert : public CKeyedAccess {
  195. public:
  196. CAccessByCert( LPSTR pName, DWORD dwId, BOOL fIter, CNseObj** pC, UINT cC, DWORD dwP = NULL )
  197. : CKeyedAccess( pName, dwId, fIter, pC, cC, dwP ) {}
  198. BOOL Set( CNseInstance* pI, DWORD dwIndex, PMETADATA_RECORD pMD )
  199. { return CKeyedAccess::Set( pI, dwIndex, pMD, NSEPM_ACCESS_CERT ); }
  200. BOOL Add( CNseInstance*, DWORD ) { return FALSE; }
  201. BOOL Delete( LPSTR, CNseInstance*, DWORD ) { return FALSE; }
  202. } ;
  203. class CAccessByName : public CKeyedAccess {
  204. public:
  205. CAccessByName( LPSTR pName, DWORD dwId, BOOL fIter, CNseObj** pC, UINT cC, DWORD dwP = NULL )
  206. : CKeyedAccess( pName, dwId, fIter, pC, cC, dwP ) {}
  207. BOOL Set( CNseInstance* pI, DWORD dwIndex, PMETADATA_RECORD pMD )
  208. { return CKeyedAccess::Set( pI, dwIndex, pMD, NSEPM_ACCESS_NAME ); }
  209. BOOL Add( CNseInstance*, DWORD ) { return FALSE; }
  210. BOOL Delete( LPSTR, CNseInstance*, DWORD ) { return FALSE; }
  211. } ;
  212. class CSerialAllObj : public CNseObj {
  213. public:
  214. CSerialAllObj( LPSTR pName, DWORD dwId, BOOL fIter, CNseObj** pC, UINT cC, DWORD dwP = NULL )
  215. : CNseObj( pName, dwId, fIter, pC, cC, dwP ) {}
  216. BOOL Get( CNseInstance*pI, DWORD, PMETADATA_RECORD pM, LPDWORD pdwRequiredLen );
  217. BOOL Set( CNseInstance*, DWORD dwIndex, PMETADATA_RECORD );
  218. BOOL Add( CNseInstance*, DWORD ) { return FALSE; }
  219. BOOL Delete( LPSTR, CNseInstance*, DWORD ) { return FALSE; }
  220. } ;
  221. class CNoCwSerObj : public CNseObj {
  222. public:
  223. CNoCwSerObj( LPSTR pName, DWORD dwId, BOOL fIter, CNseObj** pC, UINT cC, DWORD dwP = NULL )
  224. : CNseObj( pName, dwId, fIter, pC, cC, dwP ) {}
  225. BOOL Get( CNseInstance*pI, DWORD, PMETADATA_RECORD pM, LPDWORD pdwRequiredLen );
  226. BOOL Set( CNseInstance*, DWORD dwIndex, PMETADATA_RECORD );
  227. BOOL Add( CNseInstance*, DWORD ) { return FALSE; }
  228. BOOL Delete( LPSTR, CNseInstance*, DWORD ) { return FALSE; }
  229. } ;
  230. class CNoIsSerObj : public CNseObj {
  231. public:
  232. CNoIsSerObj( LPSTR pName, DWORD dwId, BOOL fIter, CNseObj** pC, UINT cC, DWORD dwP = NULL )
  233. : CNseObj( pName, dwId, fIter, pC, cC, dwP ) {}
  234. BOOL Get( CNseInstance*pI, DWORD, PMETADATA_RECORD pM, LPDWORD pdwRequiredLen );
  235. BOOL Set( CNseInstance*, DWORD dwIndex, PMETADATA_RECORD ) { return FALSE; }
  236. BOOL Add( CNseInstance*, DWORD ) { return FALSE; }
  237. BOOL Delete( LPSTR, CNseInstance*, DWORD ) { return FALSE; }
  238. } ;
  239. class CNoList : public CNseObj {
  240. public:
  241. CNoList( LPSTR pName, DWORD dwId, BOOL fIter, CNseObj** pC, UINT cC, DWORD dwP = NULL)
  242. : CNseObj( pName, dwId, fIter, pC, cC, dwP ) {}
  243. // load children of template in instance
  244. BOOL Load( CNseInstance* pI, LPSTR pszPath );
  245. } ;
  246. class CNseInstance {
  247. public:
  248. CNseInstance( CNseObj* pTemp = NULL, CNseInstance* pFather = NULL );
  249. DWORD GetNbChildren() { return m_pniChildren.GetNbPtr(); }
  250. CNseInstance* GetChild( DWORD i) { return (CNseInstance*)m_pniChildren.GetPtr( i); }
  251. BOOL AddChild( CNseInstance* pI ) { return m_pniChildren.AddPtr( (LPVOID)pI ) != 0xffffffff; }
  252. BOOL DeleteChild( DWORD i ) { return m_pniChildren.DeletePtr( i ); }
  253. BOOL CreateChildrenInstances( BOOL fRecursive );
  254. public:
  255. CNseObj* m_pTemplateObject;
  256. CNseInstance* m_pniParent;
  257. CPtrXBF m_pniChildren; //array of CNseInstance*, decode w/ their template
  258. LPVOID m_pvParam;
  259. DWORD m_dwParam;
  260. BOOL m_fModified;
  261. } ;
  262. class CNseMountPoint {
  263. public:
  264. CNseMountPoint();
  265. BOOL Release();
  266. BOOL Save( LPBOOL );
  267. BOOL EndTransac( BOOL );
  268. BOOL Init( LPSTR pszPath ) { return m_pszPath.Set( pszPath ); }
  269. LPSTR GetPath() { return m_pszPath.Get(); }
  270. public:
  271. LIST_ENTRY m_ListEntry;
  272. static LIST_ENTRY m_ListHead;
  273. static CRITICAL_SECTION m_csList;
  274. public:
  275. CNseInstance m_pTopInst; // only there to hold array of children
  276. CNseObj* m_pTopTemp; // only there to hold array of children
  277. CAllocString m_pszPath; // path to NSEP mounting point in metabase tree
  278. } ;
  279. extern IMDCOM* g_pMdIf;
  280. #define IMDCOM_PTR g_pMdIf
  281. #endif