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.

3568 lines
72 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. #define dllexp __declspec( dllexport )
  11. //
  12. // System include files.
  13. //
  14. #include <nt.h>
  15. #include <ntrtl.h>
  16. #include <nturtl.h>
  17. #include <windows.h>
  18. #include <winsock2.h>
  19. #include <lm.h>
  20. #include <stdio.h>
  21. #include <stdarg.h>
  22. #include <stdlib.h>
  23. #include <string.h>
  24. #include <tchar.h>
  25. #include <iis64.h>
  26. #include <dbgutil.h>
  27. #include <buffer.hxx>
  28. #include <string.hxx>
  29. #include <refb.hxx>
  30. //
  31. // Project include files.
  32. //
  33. #define SECURITY_WIN32
  34. #include <sspi.h> // Security Support Provider APIs
  35. #include <schnlsp.h>
  36. #include <xbf.hxx>
  37. #include <iismap.hxx>
  38. #include <iiscmr.hxx>
  39. #include <ole2.h>
  40. #include <imd.h>
  41. #include <mb.hxx>
  42. #include <iiscnfgp.h>
  43. #include <nsepname.hxx>
  44. #include "map.hxx"
  45. //
  46. // Private prototypes
  47. //
  48. #define DWORDALIGNCOUNT(a) (((a)+3)&0xfffffffc)
  49. CNseInstance*
  50. LocateObject(
  51. LPSTR* ppszPath,
  52. BOOL fIncludeLastSegment,
  53. LPDWORD pdwIndex = NULL,
  54. CNseMountPoint**ppMP = NULL
  55. );
  56. VOID WINAPI FreeIisAcctMapper(
  57. LPVOID pvMap
  58. )
  59. {
  60. delete (CIisAcctMapper*)pvMap;
  61. }
  62. VOID WINAPI FreeIisRuleMapper(
  63. LPVOID pvMap
  64. )
  65. {
  66. delete (CIisRuleMapper*)pvMap;
  67. }
  68. //
  69. // Globals
  70. //
  71. CRITICAL_SECTION CNseMountPoint::m_csList;
  72. LIST_ENTRY CNseMountPoint::m_ListHead;
  73. BOOL g_fPathOpened = FALSE;
  74. DWORD g_dwCurrentThreadId = NULL;
  75. PFN_MAPPER_TOUCHED g_pfnCert11Touched = NULL;
  76. BOOL g_fCert11Touched;
  77. //
  78. // cert 1:1
  79. CNseFieldMapperId g_f1 = CNseFieldMapperId(NULL, MD_MAPCERT, FALSE, NULL, 0, IISMDB_INDEX_CERT11_CERT, BINARY_METADATA);
  80. CNseFieldMapperId g_f2 = CNseFieldMapperId(NULL, MD_MAPNTACCT, FALSE, NULL, 0, IISMDB_INDEX_CERT11_NT_ACCT, STRING_METADATA);
  81. CNseFieldMapperId g_f3 = CNseFieldMapperId(NULL, MD_MAPNAME, FALSE, NULL, 0, IISMDB_INDEX_CERT11_NAME, STRING_METADATA);
  82. CNseFieldMapperId g_f4 = CNseFieldMapperId(NULL, MD_MAPENABLED, FALSE, NULL, 0, IISMDB_INDEX_CERT11_ENABLED, STRING_METADATA);
  83. CNseFieldMapperId g_f4b = CNseFieldMapperId(NULL, MD_MAPNTPWD, FALSE, NULL, 0, IISMDB_INDEX_CERT11_NT_PWD, STRING_METADATA);
  84. CNseFieldMapperId* g_amiCert11[] =
  85. {
  86. &g_f1,
  87. &g_f2,
  88. &g_f3,
  89. &g_f4,
  90. &g_f4b,
  91. } ;
  92. CNseCert11Mapping g_c11Mappings = CNseCert11Mapping("%u", NULL, TRUE, (CNseObj**)g_amiCert11, sizeof(g_amiCert11)/sizeof(CNseFieldMapperId*), NULL);
  93. CNseCert11Mapping* g_ac11Mappings[] = {
  94. &g_c11Mappings,
  95. } ;
  96. CNseObj g_c11Params = CNseObj("Parameters", NULL, FALSE, NULL, 0 );
  97. CNseObj g_c11Maps = CNseObj("Mappings", NULL, FALSE, (CNseObj**)g_ac11Mappings, 1 );
  98. CNoCppObj g_c11CppObj = CNoCppObj(NULL, MD_CPP_CERT11, FALSE, NULL, 0 );
  99. CAccessByAccount g_c11AccessAccount = CAccessByAccount(NULL, MD_NSEPM_ACCESS_ACCOUNT, FALSE, NULL, 0 );
  100. CAccessByCert g_c11AccessCert = CAccessByCert(NULL, MD_NSEPM_ACCESS_CERT, FALSE, NULL, 0 );
  101. CAccessByName g_c11AccessName = CAccessByName(NULL, MD_NSEPM_ACCESS_NAME, FALSE, NULL, 0 );
  102. CSerialAllObj g_c11SerialAllObj = CSerialAllObj( NULL, MD_SERIAL_ALL_CERT11, FALSE, NULL, 0 );
  103. // container for iterated list of mappings
  104. CNseObj* g_c11Mapper_Children[]= {
  105. &g_c11Params,
  106. &g_c11Maps,
  107. &g_c11CppObj,
  108. &g_c11SerialAllObj,
  109. &g_c11AccessAccount,
  110. &g_c11AccessCert,
  111. &g_c11AccessName,
  112. } ;
  113. CNseCert11Mapper g_c11Mapper= CNseCert11Mapper(NSEPM_CERT11_OBJ, NULL, FALSE, g_c11Mapper_Children, sizeof(g_c11Mapper_Children)/sizeof(CNseObj*), MD_SERIAL_CERT11 );
  114. //
  115. // Digest
  116. CNseFieldMapperId g_f5 = CNseFieldMapperId(NULL, MD_MAPREALM, FALSE, NULL, 0, IISMMDB_INDEX_IT_REALM, STRING_METADATA);
  117. CNseFieldMapperId g_f6 = CNseFieldMapperId(NULL, MD_ITACCT, FALSE, NULL, 0, IISMMDB_INDEX_IT_ACCT, STRING_METADATA);
  118. CNseFieldMapperId g_f7 = CNseFieldMapperId(NULL, MD_MAPPWD, FALSE, NULL, 0, IISMMDB_INDEX_IT_MD5PWD, STRING_METADATA);
  119. CNseFieldMapperId g_f8 = CNseFieldMapperId(NULL, MD_MAPNTACCT, FALSE, NULL, 0, IISMMDB_INDEX_NT_ACCT, STRING_METADATA);
  120. CNseFieldMapperId g_f8b = CNseFieldMapperId(NULL, MD_MAPNTPWD, FALSE, NULL, 0, IISMMDB_INDEX_NT_PWD, STRING_METADATA);
  121. CNseFieldMapperId* g_amiDigest[] =
  122. {
  123. &g_f5,
  124. &g_f6,
  125. &g_f7,
  126. &g_f8,
  127. &g_f8b,
  128. } ;
  129. CNseDigestMapping g_digestMappings = CNseDigestMapping("%u", NULL, TRUE, (CNseObj**)g_amiDigest, sizeof(g_amiDigest)/sizeof(CNseFieldMapperId*), NULL);
  130. CNseDigestMapping* g_adigestMappings[] = {
  131. &g_digestMappings,
  132. } ;
  133. CNseObj g_digestParams = CNseObj("Parameters", NULL, FALSE, NULL, 0 );
  134. CNseObj g_digestMaps = CNseObj("Mappings", NULL, FALSE, (CNseObj**)g_adigestMappings, 1 );
  135. CNoCppObj g_digestCppObj = CNoCppObj(NULL, MD_CPP_DIGEST, FALSE, NULL, 0 );
  136. CSerialAllObj g_digestSerialAllObj = CSerialAllObj( NULL, MD_SERIAL_ALL_DIGEST, FALSE, NULL, 0 );
  137. // container for iterated list of mappings
  138. CNseObj* g_digestMapper_Children[]= {
  139. &g_digestParams,
  140. &g_digestMaps,
  141. &g_digestCppObj,
  142. &g_digestSerialAllObj,
  143. } ;
  144. CNseDigestMapper g_digestMapper= CNseDigestMapper(NSEPM_DIGEST_OBJ, NULL, FALSE, g_digestMapper_Children, sizeof(g_digestMapper_Children)/sizeof(CNseObj*), MD_SERIAL_DIGEST );
  145. //
  146. // Ita
  147. CNseFieldMapperId g_f9= CNseFieldMapperId(NULL, MD_ITACCT, FALSE, NULL, 0, IISIMDB_INDEX_IT_ACCT, STRING_METADATA);
  148. CNseFieldMapperId g_f10= CNseFieldMapperId(NULL, MD_MAPPWD, FALSE, NULL, 0, IISIMDB_INDEX_IT_PWD, STRING_METADATA);
  149. CNseFieldMapperId g_f11 = CNseFieldMapperId(NULL, MD_MAPNTACCT, FALSE, NULL, 0, IISIMDB_INDEX_NT_ACCT, STRING_METADATA);
  150. CNseFieldMapperId g_f11b = CNseFieldMapperId(NULL, MD_MAPNTPWD, FALSE, NULL, 0, IISIMDB_INDEX_NT_PWD, STRING_METADATA);
  151. CNseFieldMapperId* g_amiIta[] =
  152. {
  153. &g_f9,
  154. &g_f10,
  155. &g_f11,
  156. &g_f11b,
  157. } ;
  158. CNseItaMapping g_itaMappings = CNseItaMapping("%u", NULL, TRUE, (CNseObj**)g_amiIta, sizeof(g_amiIta)/sizeof(CNseFieldMapperId*), NULL);
  159. CNseItaMapping* g_aitaMappings[] = {
  160. &g_itaMappings,
  161. } ;
  162. CNseObj g_itaParams = CNseObj("Parameters", NULL, FALSE, NULL, 0 );
  163. CNseObj g_itaMaps = CNseObj("Mappings", NULL, FALSE, (CNseObj**)g_aitaMappings, 1 );
  164. CNoCppObj g_itaCppObj = CNoCppObj(NULL, MD_CPP_ITA, FALSE, NULL, 0 );
  165. // container for iterated list of mappings
  166. CNseObj* g_itaMapper_Children[]= {
  167. &g_itaParams,
  168. &g_itaMaps,
  169. &g_itaCppObj,
  170. } ;
  171. CNseItaMapper g_itaMapper= CNseItaMapper(NSEPM_BASIC_OBJ, NULL, FALSE, g_itaMapper_Children, sizeof(g_itaMapper_Children)/sizeof(CNseObj*), MD_SERIAL_ITA );
  172. //
  173. // Cert wildcard
  174. CNoCwSerObj g_cwSerObj = CNoCwSerObj(NULL, MD_SERIAL_CERTW, FALSE, NULL, 0 );
  175. CNoCppObj g_cwCppObj = CNoCppObj(NULL, MD_CPP_CERTW, FALSE, NULL, 0 );
  176. // container for iterated list of mappings
  177. CNseObj* g_cwMapper_Children[]= {
  178. &g_cwSerObj,
  179. &g_cwCppObj,
  180. } ;
  181. CNseCwMapper g_cwMapper= CNseCwMapper(NSEPM_CERTW_OBJ, NULL, FALSE, g_cwMapper_Children, sizeof(g_cwMapper_Children)/sizeof(CNseObj*), MD_SERIAL_CERTW );
  182. //
  183. // Issuers
  184. CNoIsSerObj g_isSerObj = CNoIsSerObj(NULL, MD_SERIAL_ISSUERS, FALSE, NULL, 0 );
  185. // container for iterated list of mappings
  186. CNseObj* g_isChildren[]= {
  187. &g_isSerObj,
  188. } ;
  189. CNseIssuers g_Issuers= CNseIssuers(NSEPM_ISSUER_OBJ, NULL, FALSE, g_isChildren, sizeof(g_isChildren)/sizeof(CNseObj*), MD_SERIAL_ISSUERS );
  190. //
  191. // list of mapper types
  192. CNseObj* g_cMappers[]= {
  193. &g_c11Mapper,
  194. &g_digestMapper,
  195. &g_itaMapper,
  196. &g_cwMapper,
  197. &g_Issuers,
  198. } ;
  199. //
  200. // top object, must load sub-objects from metabase
  201. CNoList g_NoList = CNoList("<>", NULL, FALSE, g_cMappers, sizeof(g_cMappers)/sizeof(CNseObj*)) ;
  202. //
  203. // Member Functions
  204. //
  205. BOOL
  206. CNoList::Load(
  207. CNseInstance* pI,
  208. LPSTR pszPath
  209. )
  210. /*++
  211. Routine Description:
  212. Load a subtree of the current instance
  213. Arguments:
  214. pI - current instance
  215. pszPath - path in metabase where current instance object is stored
  216. Returns:
  217. TRUE on success, FALSE on failure
  218. --*/
  219. {
  220. UINT i;
  221. CNseInstance* pNI;
  222. pI->m_pTemplateObject = this;
  223. for ( i = 0 ; i < m_cnoChildren ; ++i )
  224. {
  225. if ( pNI = new CNseInstance( m_pnoChildren[i], pI ) )
  226. {
  227. if ( pNI->m_pTemplateObject->Load( pNI, pszPath ) )
  228. {
  229. if ( !pI->AddChild( pNI ) )
  230. {
  231. return FALSE;
  232. }
  233. }
  234. else
  235. {
  236. delete pNI;
  237. }
  238. }
  239. else
  240. {
  241. SetLastError( ERROR_NOT_ENOUGH_MEMORY );
  242. return FALSE;
  243. }
  244. }
  245. return TRUE;
  246. }
  247. BOOL
  248. CNseObj::Release(
  249. CNseInstance* pI,
  250. DWORD
  251. )
  252. /*++
  253. Routine Description:
  254. Release a subtree of the current instance
  255. Arguments:
  256. pI - current instance
  257. DWORD - ignored
  258. Returns:
  259. TRUE on success, FALSE on failure
  260. --*/
  261. {
  262. UINT i;
  263. for ( i = 0 ;i < pI->GetNbChildren() ; ++i )
  264. {
  265. // continue processing even if error
  266. pI->GetChild(i)->m_pTemplateObject->Release( pI->GetChild(i), 0 );
  267. delete pI->GetChild(i);
  268. }
  269. return TRUE;
  270. }
  271. BOOL
  272. CNseFldMap::Release(
  273. CNseInstance* pI,
  274. DWORD dwIndex
  275. )
  276. /*++
  277. Routine Description:
  278. Release memory associated with current instance RefBlob object
  279. Arguments:
  280. pI - current instance
  281. DWORD - ignored
  282. Returns:
  283. TRUE on success, FALSE on failure
  284. --*/
  285. {
  286. CNseObj::Release( pI, dwIndex );
  287. if ( pI->m_pvParam )
  288. {
  289. ((RefBlob*)pI->m_pvParam)->Release();
  290. pI->m_pvParam = NULL;
  291. }
  292. return TRUE;
  293. }
  294. BOOL
  295. CNseFldMap::Delete(
  296. LPSTR pszPath,
  297. CNseInstance* pI,
  298. DWORD dwIndex
  299. )
  300. /*++
  301. Routine Description:
  302. Delete a mapper object
  303. Arguments:
  304. pszPath - path where mapper exists in tree
  305. pI - current instance
  306. dwIndex - mapper index, ignored : mapper object is not iterated
  307. Returns:
  308. TRUE on success, FALSE on failure
  309. --*/
  310. {
  311. BOOL fSt = FALSE;
  312. BOOL fStUpd = FALSE;
  313. if ( pI->m_pvParam )
  314. {
  315. CIisAcctMapper* pM = (CIisAcctMapper*)((RefBlob*)pI->m_pvParam)->QueryPtr();
  316. if ( pM )
  317. {
  318. pM->Delete();
  319. }
  320. }
  321. //
  322. // update metabase
  323. //
  324. MB mb( IMDCOM_PTR );
  325. if ( mb.Open( pszPath, METADATA_PERMISSION_WRITE ) )
  326. {
  327. mb.DeleteData( "", GetDwParam(), IIS_MD_UT_SERVER, BINARY_METADATA );
  328. mb.Save();
  329. mb.Close();
  330. fStUpd = TRUE;
  331. }
  332. //
  333. // delete object even if metabase update not successful
  334. //
  335. if ( pI->m_pniParent->m_pTemplateObject->RemoveFromChildren( pI->m_pniParent, pI ) )
  336. {
  337. if ( Release( pI, dwIndex ) )
  338. {
  339. fSt = fStUpd;
  340. }
  341. }
  342. return fSt;
  343. }
  344. DWORD
  345. CNseFldMap::GetCount(
  346. CNseInstance* pI,
  347. DWORD dwIndex
  348. )
  349. /*++
  350. Routine Description:
  351. Retrive count of mappings in mapper object
  352. Arguments:
  353. pI - current instance
  354. dwIndex - mapper index, ignored : mapper object is not iterated
  355. Returns:
  356. TRUE on success, FALSE on failure
  357. --*/
  358. {
  359. CIisAcctMapper *pM = (CIisAcctMapper*)((RefBlob*)pI->m_pvParam)->QueryPtr();
  360. return pM ? pM->GetNbMapping( TRUE ) : 0;
  361. }
  362. DWORD
  363. CNseAllMappings::GetCount(
  364. CNseInstance* pI,
  365. DWORD dwIndex
  366. )
  367. /*++
  368. Routine Description:
  369. Retrive count of mappings in mapper object from a mapping instance
  370. Arguments:
  371. pI - current instance
  372. dwIndex - mapper index, ignored : mapper object is not iterated
  373. Returns:
  374. TRUE on success, FALSE on failure
  375. --*/
  376. {
  377. CIisAcctMapper *pM = (CIisAcctMapper*)((RefBlob*)pI->m_pniParent->m_pniParent->m_pvParam)->QueryPtr();
  378. return pM ? pM->GetNbMapping( TRUE ) : 0;
  379. }
  380. BOOL
  381. CNseFldMap::AddMapper(
  382. CNseInstance* pFather,
  383. CIisAcctMapper* pM
  384. )
  385. /*++
  386. Routine Description:
  387. Add a mapper object in father instance.
  388. Will create mapper children hierarchy
  389. Arguments:
  390. pFather - instance where to insert new mapper instance as child
  391. pM - mapper object
  392. Returns:
  393. TRUE on success, FALSE on failure
  394. --*/
  395. {
  396. CNseInstance* pI = NULL;
  397. RefBlob* pB = NULL;
  398. // BugFix: 57660, 57661, 57662 Whistler
  399. // Prefix bug accessing NULL pointer
  400. // If the caller has passed a NULL pointer
  401. // do not do the call, just return an error.
  402. // EBK 5/5/2000
  403. if (pM)
  404. {
  405. if ( pM->Create() &&
  406. (pI = new CNseInstance) &&
  407. (pB = new RefBlob) )
  408. {
  409. pB->Init( pM, sizeof(CIisAcctMapper*), FreeIisAcctMapper );
  410. pI->m_pvParam = pB;
  411. pI->m_pniParent = pFather;
  412. pI->m_pTemplateObject = this;
  413. pI->m_fModified = TRUE;
  414. if ( pFather->AddChild( pI ) )
  415. {
  416. return pI->CreateChildrenInstances( TRUE );
  417. }
  418. }
  419. if ( pI )
  420. {
  421. delete pI;
  422. }
  423. if ( pB )
  424. {
  425. delete pB;
  426. }
  427. }
  428. return FALSE;
  429. }
  430. BOOL
  431. CNseFldMap::EndTransac(
  432. LPSTR pszPath,
  433. CNseInstance* pI,
  434. BOOL fApplyChanges
  435. )
  436. /*++
  437. Routine Description:
  438. Metabase close on mapper : ask mapper object to synchronize std and alternate list
  439. Arguments:
  440. pszPath - path where mapper exists in tree
  441. pI - current instance
  442. fApplyChanges - TRUE to commit changes
  443. Returns:
  444. TRUE on success, FALSE on failure
  445. --*/
  446. {
  447. BOOL fSt = TRUE;
  448. CIisAcctMapper * pM;
  449. if ( pI->m_pvParam )
  450. {
  451. pM = (CIisAcctMapper*) ((RefBlob*)pI->m_pvParam)->QueryPtr();
  452. if ( pI->m_fModified )
  453. {
  454. pM->Lock();
  455. if ( fApplyChanges )
  456. {
  457. fSt = pM->FlushAlternate( TRUE );
  458. }
  459. else
  460. {
  461. fSt = pM->FlushAlternate( FALSE );
  462. pI->m_fModified = FALSE;
  463. }
  464. pM->Unlock();
  465. }
  466. }
  467. return fSt;
  468. }
  469. BOOL
  470. CNseFldMap::SaveMapper(
  471. LPSTR pszPath,
  472. CNseInstance* pI,
  473. DWORD dwId,
  474. LPBOOL pfModified
  475. )
  476. /*++
  477. Routine Description:
  478. Save a mapper object on persistance storage
  479. First save mappings in file then store reference to file in metabase
  480. Arguments:
  481. pszPath - path where mapper exists in tree
  482. pI - current instance
  483. dwId - ignored, mapper objects are not iterated
  484. pfModified - updated with TRUE if metabase modified
  485. Returns:
  486. TRUE on success, FALSE on failure
  487. --*/
  488. {
  489. BOOL fSt = TRUE;
  490. CIisAcctMapper * pM;
  491. BOOL f;
  492. HANDLE hnd;
  493. if ( pI->m_pvParam )
  494. {
  495. pM = (CIisAcctMapper*) ((RefBlob*)pI->m_pvParam)->QueryPtr();
  496. pM->Lock();
  497. if ( pI->m_fModified )
  498. {
  499. CStoreXBF xbf;
  500. fSt = FALSE;
  501. MB mb( IMDCOM_PTR );
  502. if ( mb.Open( pszPath, METADATA_PERMISSION_WRITE ) )
  503. {
  504. if ( dwId == MD_SERIAL_CERT11 )
  505. {
  506. g_fCert11Touched = TRUE;
  507. }
  508. // must revert to process identity before saving mapping, as we are
  509. // using crypto storage
  510. if ( OpenThreadToken( GetCurrentThread(), TOKEN_ALL_ACCESS, TRUE, &hnd ) )
  511. {
  512. RevertToSelf();
  513. }
  514. else
  515. {
  516. hnd = NULL;
  517. }
  518. f = pM->FlushAlternate( TRUE ) && pM->Save() && pM->Serialize( &xbf );
  519. if ( hnd )
  520. {
  521. HANDLE hThread = GetCurrentThread();
  522. SetThreadToken( &hThread, hnd );
  523. CloseHandle( hnd );
  524. }
  525. if ( f )
  526. {
  527. // save to metabase
  528. if ( mb.SetData( "", dwId, IIS_MD_UT_SERVER, BINARY_METADATA, xbf.GetBuff(), xbf.GetUsed(), 0 ) )
  529. {
  530. fSt = TRUE;
  531. *pfModified = TRUE;
  532. }
  533. }
  534. mb.Close();
  535. pI->m_fModified = FALSE;
  536. }
  537. }
  538. else
  539. {
  540. pM->FlushAlternate( FALSE );
  541. }
  542. pM->Unlock();
  543. }
  544. return fSt;
  545. }
  546. BOOL
  547. CNseFldMap::LoadAndUnserialize(
  548. CNseInstance* pI,
  549. CIisAcctMapper* pM,
  550. LPSTR pszPath,
  551. DWORD dwId
  552. )
  553. /*++
  554. Routine Description:
  555. Instantiate a mapper object from persistent storage
  556. First load reference to file in metabase, then load mappings from file
  557. Arguments:
  558. pI - current instance
  559. pM - ptr to mapper object
  560. pszPath - path where mapper exists in tree
  561. dwId - ignored, mapper objects are not iterated
  562. Returns:
  563. TRUE on success, FALSE on failure
  564. --*/
  565. {
  566. MB mb( (IMDCOM*) IMDCOM_PTR );
  567. BYTE abUnser[1024];
  568. LPBYTE pUnser;
  569. DWORD cUnser;
  570. BOOL fSt = FALSE;
  571. RefBlob* pB = NULL;
  572. if ( !pM )
  573. {
  574. return FALSE;
  575. }
  576. // load from metabase
  577. if ( mb.Open( pszPath) )
  578. {
  579. cUnser = sizeof(abUnser);
  580. if ( mb.GetData( "", dwId, IIS_MD_UT_SERVER, BINARY_METADATA, abUnser, &cUnser, 0) )
  581. {
  582. pUnser = abUnser;
  583. if ( pM->Unserialize( &pUnser, &cUnser ) && pM->Load() )
  584. {
  585. if ( pB = new RefBlob() )
  586. {
  587. pB->Init( pM, sizeof(CIisAcctMapper*), FreeIisAcctMapper );
  588. pI->m_pvParam = (LPVOID)pB;
  589. // create sub-instances in pI : from template
  590. fSt = pI->CreateChildrenInstances( TRUE );
  591. }
  592. }
  593. }
  594. mb.Close();
  595. }
  596. return fSt;
  597. }
  598. BOOL
  599. CNseCwMapper::Release(
  600. CNseInstance* pI,
  601. DWORD dwIndex
  602. )
  603. /*++
  604. Routine Description:
  605. Release memory used by a certificate wildcard mapper
  606. not including ptr to current instance
  607. Arguments:
  608. pI - current instance
  609. dwIndex - ignored, mapper objects are not iterated
  610. Returns:
  611. TRUE on success, FALSE on failure
  612. --*/
  613. {
  614. CNseObj::Release( pI, dwIndex );
  615. if ( pI->m_pvParam )
  616. {
  617. ((RefBlob*)pI->m_pvParam)->Release();
  618. pI->m_pvParam = NULL;
  619. }
  620. return TRUE;
  621. }
  622. BOOL
  623. CNseCwMapper::Add(
  624. CNseInstance* pFather,
  625. DWORD dwId
  626. )
  627. /*++
  628. Routine Description:
  629. Add a certificate wildcard mapper object in father instance.
  630. Will create mapper children hierarchy
  631. Arguments:
  632. pFather - instance where to insert new mapper instance as child
  633. dwId - ignored, mapper objects are not iterated
  634. Returns:
  635. TRUE on success, FALSE on failure
  636. --*/
  637. {
  638. CNseInstance* pI = NULL;
  639. RefBlob* pB = NULL;
  640. CIisRuleMapper * pM = NULL;
  641. BOOL fSt = FALSE;
  642. if ( (pM = new CIisRuleMapper) &&
  643. (pI = new CNseInstance) &&
  644. (pB = new RefBlob) )
  645. {
  646. pB->Init( pM, sizeof(CIisRuleMapper*), FreeIisRuleMapper );
  647. pI->m_pvParam = pB;
  648. pI->m_pniParent = pFather;
  649. pI->m_pTemplateObject = this;
  650. pI->m_fModified = TRUE;
  651. if ( pI->CreateChildrenInstances( TRUE ) )
  652. {
  653. fSt = pFather->AddChild( pI );
  654. }
  655. }
  656. if ( !fSt )
  657. {
  658. if ( pI )
  659. {
  660. delete pI;
  661. }
  662. if ( pB )
  663. {
  664. delete pB;
  665. }
  666. if ( pM )
  667. {
  668. delete pM;
  669. }
  670. }
  671. return fSt;
  672. }
  673. BOOL
  674. CNseCwMapper::Save(
  675. LPSTR pszPath,
  676. CNseInstance* pI,
  677. LPBOOL pfModified
  678. )
  679. /*++
  680. Routine Description:
  681. Save a certificate wildcard mapper object on persistance storage
  682. Arguments:
  683. pszPath - path where mapper exists in tree
  684. pI - current instance
  685. pfModified - updated with TRUE if metabase modified
  686. Returns:
  687. TRUE on success, FALSE on failure
  688. --*/
  689. {
  690. BOOL fSt = TRUE;
  691. CIisRuleMapper * pM;
  692. if ( pI->m_pvParam )
  693. {
  694. pM = (CIisRuleMapper*) ((RefBlob*)pI->m_pvParam)->QueryPtr();
  695. pM->LockRules();
  696. if ( pI->m_fModified )
  697. {
  698. CStoreXBF xbf;
  699. fSt = FALSE;
  700. if ( pM->Serialize( &xbf ) )
  701. {
  702. MB mb( IMDCOM_PTR );
  703. // save to metabase
  704. if ( mb.Open( pszPath, METADATA_PERMISSION_WRITE ) )
  705. {
  706. if ( mb.SetData( "", GetDwParam(), IIS_MD_UT_SERVER, BINARY_METADATA, xbf.GetBuff(), xbf.GetUsed(), METADATA_SECURE ) )
  707. {
  708. fSt = TRUE;
  709. *pfModified = TRUE;
  710. }
  711. mb.Close();
  712. }
  713. }
  714. pI->m_fModified = FALSE;
  715. }
  716. pM->UnlockRules();
  717. }
  718. return fSt;
  719. }
  720. BOOL
  721. CNseCwMapper::Load(
  722. CNseInstance* pI,
  723. LPSTR pszPath
  724. )
  725. /*++
  726. Routine Description:
  727. Load a certificate wildcard mapper object from persistance storage
  728. Arguments:
  729. pI - current instance
  730. pszPath - path where mapper exists in tree
  731. Returns:
  732. TRUE on success, FALSE on failure
  733. --*/
  734. {
  735. MB mb( (IMDCOM*) IMDCOM_PTR );
  736. BYTE abUnser[4096];
  737. LPBYTE pUnser;
  738. LPBYTE pU;
  739. DWORD cUnser;
  740. BOOL fSt = FALSE;
  741. RefBlob* pB = NULL;
  742. CIisRuleMapper * pM = NULL;
  743. pM = new CIisRuleMapper;
  744. if ( !pM )
  745. {
  746. return FALSE;
  747. }
  748. pUnser = abUnser;
  749. cUnser = sizeof(abUnser);
  750. // load from metabase
  751. if ( mb.Open( pszPath) )
  752. {
  753. ag:
  754. if ( mb.GetData( "", GetDwParam(), IIS_MD_UT_SERVER, BINARY_METADATA, pUnser, &cUnser, METADATA_SECURE) )
  755. {
  756. pU = pUnser;
  757. if ( pM->Unserialize( &pU, &cUnser ) )
  758. {
  759. if ( pB = new RefBlob() )
  760. {
  761. pB->Init( pM, sizeof(CIisRuleMapper*), FreeIisRuleMapper );
  762. pI->m_pvParam = (LPVOID)pB;
  763. // create sub-instances in pI : from template
  764. fSt = pI->CreateChildrenInstances( TRUE );
  765. }
  766. }
  767. }
  768. else if ( GetLastError() == ERROR_INSUFFICIENT_BUFFER )
  769. {
  770. if ( pUnser = (LPBYTE)LocalAlloc( LMEM_FIXED, cUnser ) )
  771. {
  772. goto ag;
  773. }
  774. }
  775. mb.Close();
  776. }
  777. if ( !fSt )
  778. {
  779. delete pM;
  780. }
  781. if ( pUnser != abUnser )
  782. {
  783. LocalFree( pUnser );
  784. }
  785. return fSt;
  786. }
  787. BOOL
  788. CNseIssuers::Load(
  789. CNseInstance* pI,
  790. LPSTR pszPath
  791. )
  792. /*++
  793. Routine Description:
  794. Initialize instance for Issuer list
  795. Arguments:
  796. pI - current instance
  797. pszPath - path where issuer exists in tree
  798. Returns:
  799. TRUE on success, FALSE on failure
  800. --*/
  801. {
  802. return pI->CreateChildrenInstances( TRUE );
  803. }
  804. BOOL
  805. CNseObj::RemoveFromChildren(
  806. CNseInstance* pI,
  807. CNseInstance* pChild
  808. )
  809. /*++
  810. Routine Description:
  811. Remove instance from children list
  812. Arguments:
  813. pI - current instance
  814. pChild - instance to delete from pI
  815. Returns:
  816. TRUE on success, FALSE on failure
  817. --*/
  818. {
  819. UINT i;
  820. for ( i = 0 ; i < pI->GetNbChildren() ; ++i )
  821. {
  822. if ( pI->GetChild(i) == pChild )
  823. {
  824. return pI->DeleteChild( i );
  825. }
  826. }
  827. return FALSE;
  828. }
  829. BOOL
  830. CNseCwMapper::Delete(
  831. LPSTR pszPath,
  832. CNseInstance* pI,
  833. DWORD dwIndex
  834. )
  835. /*++
  836. Routine Description:
  837. Delete a cert wildcard mapper
  838. Arguments:
  839. pszPath - path where mapper exists in tree
  840. pI - current instance
  841. dwIndex - ignored, mapper object is not iterated
  842. Returns:
  843. TRUE on success, FALSE on failure
  844. --*/
  845. {
  846. BOOL fSt = FALSE;
  847. //
  848. // update metabase
  849. //
  850. MB mb( IMDCOM_PTR );
  851. if ( mb.Open( pszPath, METADATA_PERMISSION_WRITE ) )
  852. {
  853. fSt = mb.DeleteData( "", GetDwParam(), IIS_MD_UT_SERVER, BINARY_METADATA ) &&
  854. mb.Save();
  855. mb.Close();
  856. }
  857. //
  858. // Update instance hierarchy
  859. //
  860. if ( pI->m_pniParent->m_pTemplateObject->RemoveFromChildren( pI->m_pniParent, pI ) )
  861. {
  862. if ( !Release( pI, dwIndex ) )
  863. {
  864. fSt = FALSE;
  865. }
  866. }
  867. else
  868. {
  869. fSt = FALSE;
  870. }
  871. return fSt;
  872. }
  873. BOOL
  874. CNseAllMappings::GetAll(
  875. CNseInstance* pWalk,
  876. DWORD dwIndex,
  877. LPDWORD pdwMDNumDataEntries,
  878. DWORD dwMDBufferSize,
  879. LPBYTE pbBuffer,
  880. LPDWORD pdwMDRequiredBufferSize
  881. )
  882. /*++
  883. Routine Description:
  884. Handle GetAll request for cert11, digest & ita
  885. Arguments:
  886. pWalk - mapping entry instance
  887. dwIndex - mapping entry index ( 0 based )
  888. pdwMDNumDataEntries - updated with count of properties
  889. pbBuffer - updated with properties if size sufficient
  890. pdwMDRequiredBufferSize - pbBuffer size on input, updated with minimum size to handle
  891. all properties on output
  892. Returns:
  893. TRUE on success, FALSE on failure
  894. returns FALSE, error ERROR_INSUFFICIENT_BUFFER if pbBuffer not big enough
  895. --*/
  896. {
  897. UINT i;
  898. DWORD cId = 0;
  899. DWORD cReq = 0;
  900. DWORD cNeed;
  901. DWORD cRem;
  902. BOOL fSt = TRUE;
  903. METADATA_RECORD MD;
  904. PMETADATA_GETALL_RECORD pGA;
  905. LPBYTE pB;
  906. //
  907. // Count # properties, compute needed size
  908. //
  909. for ( i = 0 ; i < pWalk->GetNbChildren() ; ++i )
  910. {
  911. if ( pWalk->GetChild(i)->m_pTemplateObject->GetId() )
  912. {
  913. ++cId;
  914. cReq += sizeof(METADATA_GETALL_RECORD);
  915. cNeed = 0;
  916. MD.dwMDDataLen = 0;
  917. MD.pbMDData = NULL;
  918. MD.dwMDIdentifier = pWalk->GetChild(i)->m_pTemplateObject->GetId();
  919. if ( GetByIndex( pWalk, dwIndex, &MD, i, &cNeed ) ||
  920. GetLastError() == ERROR_INSUFFICIENT_BUFFER )
  921. {
  922. cReq += cNeed;
  923. }
  924. else
  925. {
  926. fSt = FALSE;
  927. break;
  928. }
  929. }
  930. }
  931. *pdwMDNumDataEntries = cId;
  932. *pdwMDRequiredBufferSize = cReq;
  933. if ( fSt && cId )
  934. {
  935. if ( dwMDBufferSize >= cReq )
  936. {
  937. pGA = (PMETADATA_GETALL_RECORD)pbBuffer;
  938. pB = pbBuffer + sizeof(METADATA_GETALL_RECORD) * cId;
  939. cRem = cReq - sizeof(METADATA_GETALL_RECORD) * cId;
  940. for ( i = 0 ; i < pWalk->GetNbChildren() ; ++i, ++pGA )
  941. {
  942. if ( pWalk->GetChild(i)->m_pTemplateObject->GetId() )
  943. {
  944. memset( &MD, '\0', sizeof(METADATA_RECORD) );
  945. MD.dwMDDataLen = cRem;
  946. MD.pbMDData = pbBuffer ? pB : NULL;
  947. MD.dwMDIdentifier = pWalk->GetChild(i)->m_pTemplateObject->GetId();
  948. if ( MD.dwMDIdentifier == MD_MAPNTPWD )
  949. {
  950. MD.dwMDAttributes |= METADATA_SECURE;
  951. }
  952. if (!GetByIndex( pWalk, dwIndex, &MD, i, &cNeed ) )
  953. {
  954. fSt = FALSE;
  955. break;
  956. }
  957. pGA->dwMDIdentifier = MD.dwMDIdentifier;
  958. pGA->dwMDAttributes = MD.dwMDAttributes;
  959. pGA->dwMDUserType = MD.dwMDUserType;
  960. pGA->dwMDDataType = MD.dwMDDataType;
  961. pGA->dwMDDataLen = MD.dwMDDataLen;
  962. pGA->dwMDDataOffset = DIFF(pB - pbBuffer);
  963. pGA->dwMDDataTag = 0;
  964. pB += pGA->dwMDDataLen;
  965. cRem -= pGA->dwMDDataLen;
  966. }
  967. }
  968. }
  969. else
  970. {
  971. SetLastError( ERROR_INSUFFICIENT_BUFFER );
  972. fSt = FALSE;
  973. }
  974. }
  975. return fSt;
  976. }
  977. BOOL
  978. CNseCert11Mapper::Add(
  979. CNseInstance* pFather,
  980. DWORD
  981. )
  982. /*++
  983. Routine Description:
  984. Add a cert 1:1 mapper to instance hierarchy
  985. Arguments:
  986. pFather - instance where to add new cert 1:1 instance
  987. Returns:
  988. TRUE on success, FALSE on failure
  989. --*/
  990. {
  991. return AddMapper( pFather, (CIisAcctMapper*)new CIisCert11Mapper() );
  992. }
  993. BOOL
  994. CNseCert11Mapper::Load(
  995. CNseInstance* pI,
  996. LPSTR pszPath
  997. )
  998. /*++
  999. Routine Description:
  1000. Load a certificate 1:1 mapper object from persistance storage
  1001. Arguments:
  1002. pI - current instance
  1003. pszPath - path where mapper exists in tree
  1004. Returns:
  1005. TRUE on success, FALSE on failure
  1006. --*/
  1007. {
  1008. CIisAcctMapper* pM = new CIisCert11Mapper;
  1009. if ( pM )
  1010. {
  1011. if ( LoadAndUnserialize( pI, pM, pszPath, MD_SERIAL_CERT11 ) )
  1012. {
  1013. return TRUE;
  1014. }
  1015. delete pM;
  1016. }
  1017. return FALSE;
  1018. }
  1019. BOOL
  1020. CNseDigestMapper::Add(
  1021. CNseInstance* pFather,
  1022. DWORD
  1023. )
  1024. /*++
  1025. Routine Description:
  1026. Add a digest auth mapper to instance hierarchy
  1027. Arguments:
  1028. pFather - instance where to add new digest auth mapper instance
  1029. Returns:
  1030. TRUE on success, FALSE on failure
  1031. --*/
  1032. {
  1033. return AddMapper( pFather, (CIisAcctMapper*)new CIisMd5Mapper() );
  1034. }
  1035. BOOL
  1036. CNseDigestMapper::Load(
  1037. CNseInstance* pI,
  1038. LPSTR pszPath
  1039. )
  1040. /*++
  1041. Routine Description:
  1042. Load a digest auth mapper object from persistance storage
  1043. Arguments:
  1044. pI - current instance
  1045. pszPath - path where mapper exists in tree
  1046. Returns:
  1047. TRUE on success, FALSE on failure
  1048. --*/
  1049. {
  1050. CIisAcctMapper* pM = new CIisMd5Mapper;
  1051. if ( pM )
  1052. {
  1053. if ( LoadAndUnserialize( pI, pM, pszPath, MD_SERIAL_DIGEST ) )
  1054. {
  1055. return TRUE;
  1056. }
  1057. delete pM;
  1058. }
  1059. return FALSE;
  1060. }
  1061. BOOL
  1062. CNseItaMapper::Add(
  1063. CNseInstance* pFather,
  1064. DWORD
  1065. )
  1066. /*++
  1067. Routine Description:
  1068. Add an internet acct mapper to instance hierarchy
  1069. Arguments:
  1070. pFather - instance where to add new internet acct mapper instance
  1071. Returns:
  1072. TRUE on success, FALSE on failure
  1073. --*/
  1074. {
  1075. return AddMapper( pFather, (CIisAcctMapper*)new CIisItaMapper() );
  1076. }
  1077. BOOL
  1078. CNseItaMapper::Load(
  1079. CNseInstance* pI,
  1080. LPSTR pszPath
  1081. )
  1082. /*++
  1083. Routine Description:
  1084. Load an internet acct mapper object from persistance storage
  1085. Arguments:
  1086. pI - current instance
  1087. pszPath - path where mapper exists in tree
  1088. Returns:
  1089. TRUE on success, FALSE on failure
  1090. --*/
  1091. {
  1092. CIisAcctMapper* pM = new CIisItaMapper;
  1093. if ( pM )
  1094. {
  1095. if ( LoadAndUnserialize( pI, pM, pszPath, MD_SERIAL_ITA ) )
  1096. {
  1097. return TRUE;
  1098. }
  1099. delete pM;
  1100. }
  1101. return FALSE;
  1102. }
  1103. BOOL
  1104. CNseFldMap::Save(
  1105. LPSTR pszPath,
  1106. CNseInstance* pI,
  1107. LPBOOL pfModified
  1108. )
  1109. /*++
  1110. Routine Description:
  1111. Save a mapper ( cert11, digest, ita ) instance
  1112. Arguments:
  1113. pszPath - path where mapper exists in tree
  1114. pI - current instance
  1115. pfModified - updated with TRUE if metabase storage modified
  1116. Returns:
  1117. TRUE on success, FALSE on failure
  1118. --*/
  1119. {
  1120. return SaveMapper( pszPath, pI, GetDwParam(), pfModified );
  1121. }
  1122. CNseInstance*
  1123. CNseObj::Locate(
  1124. CNseInstance* pI,
  1125. PMETADATA_RECORD pMD
  1126. )
  1127. /*++
  1128. Routine Description:
  1129. Locate a metadata record based on its ID in current instance
  1130. Arguments:
  1131. pI - current instance
  1132. pMD - metadata record, only ID is used
  1133. Returns:
  1134. ptr to child instance if success, otherwise NULL
  1135. --*/
  1136. {
  1137. UINT i;
  1138. for ( i = 0 ; i < pI->GetNbChildren() ; ++i )
  1139. {
  1140. if ( pI->GetChild(i)->m_pTemplateObject->GetId() == pMD->dwMDIdentifier )
  1141. {
  1142. return pI->GetChild(i);
  1143. }
  1144. }
  1145. return NULL;
  1146. }
  1147. BOOL
  1148. CNseObj::Set(
  1149. CNseInstance* pI,
  1150. DWORD dwIndex,
  1151. PMETADATA_RECORD pMD
  1152. )
  1153. /*++
  1154. Routine Description:
  1155. set property in the child matching the specified property
  1156. Arguments:
  1157. pI - current instance
  1158. dwIndex - instance index
  1159. pMD - metadata record, only ID is used
  1160. Returns:
  1161. TRUE if success, otherwise FALSE
  1162. --*/
  1163. {
  1164. CNseInstance* pL;
  1165. BOOL fSt = FALSE;
  1166. if ( pL = Locate( pI, pMD ) )
  1167. {
  1168. return pL->m_pTemplateObject->Set( pL, dwIndex, pMD );
  1169. }
  1170. return fSt;
  1171. }
  1172. BOOL
  1173. CNseObj::Get(
  1174. CNseInstance* pI,
  1175. DWORD dwIndex,
  1176. PMETADATA_RECORD pMD,
  1177. LPDWORD pdwRequiredLen
  1178. )
  1179. /*++
  1180. Routine Description:
  1181. get property from the child matching the specified property
  1182. Arguments:
  1183. pI - current instance
  1184. dwIndex - instance index
  1185. pMD - metadata record, only ID is used
  1186. pdwRequiredLen - updated with required length if length specified in pMD is not
  1187. sufficient
  1188. Returns:
  1189. TRUE if success, otherwise FALSE
  1190. --*/
  1191. {
  1192. CNseInstance* pL;
  1193. BOOL fSt = FALSE;
  1194. if ( pL = Locate( pI, pMD ) )
  1195. {
  1196. return pL->m_pTemplateObject->Get( pL, dwIndex, pMD, pdwRequiredLen );
  1197. }
  1198. return fSt;
  1199. }
  1200. BOOL
  1201. CNseAllMappings::Set(
  1202. CNseInstance* pI,
  1203. DWORD dwIndex,
  1204. PMETADATA_RECORD pMD
  1205. )
  1206. /*++
  1207. Routine Description:
  1208. set property in the child matching the specified property
  1209. Arguments:
  1210. pI - current instance
  1211. dwIndex - instance index
  1212. pMD - metadata record, only ID is used
  1213. Returns:
  1214. TRUE if success, otherwise FALSE
  1215. --*/
  1216. {
  1217. CNseInstance* pL;
  1218. BOOL fSt = FALSE;
  1219. if ( pL = Locate( pI, pMD ) )
  1220. {
  1221. CIisAcctMapper *pM = (CIisAcctMapper*)((RefBlob*)pI->m_pniParent->m_pniParent->m_pvParam)->QueryPtr();
  1222. CIisMapping* pG;
  1223. if ( pM )
  1224. {
  1225. pM->Lock();
  1226. if ( pM->GetMapping( dwIndex, &pG, TRUE, TRUE ) )
  1227. {
  1228. if ( pMD->dwMDDataType == STRING_METADATA )
  1229. {
  1230. fSt = pG->MappingSetField( pL->m_pTemplateObject->GetDwParam(),
  1231. (LPSTR)pMD->pbMDData );
  1232. }
  1233. else
  1234. {
  1235. fSt = pG->MappingSetField( pL->m_pTemplateObject->GetDwParam(),
  1236. (LPSTR)pMD->pbMDData,
  1237. pMD->dwMDDataLen,
  1238. FALSE );
  1239. }
  1240. }
  1241. else
  1242. {
  1243. SetLastError( ERROR_INVALID_NAME );
  1244. }
  1245. pM->Unlock();
  1246. pI->m_pniParent->m_pniParent->m_fModified = TRUE;
  1247. }
  1248. }
  1249. return fSt;
  1250. }
  1251. BOOL
  1252. CNseAllMappings::Get(
  1253. CNseInstance* pI,
  1254. DWORD dwIndex,
  1255. PMETADATA_RECORD pMD,
  1256. LPDWORD pdwReq
  1257. )
  1258. /*++
  1259. Routine Description:
  1260. get property from the child matching the specified property
  1261. Arguments:
  1262. pI - current instance
  1263. dwIndex - instance index
  1264. pMD - metadata record, only ID is used
  1265. pdwRequiredLen - updated with required length if length specified in pMD is not
  1266. sufficient
  1267. Returns:
  1268. TRUE if success, otherwise FALSE
  1269. --*/
  1270. {
  1271. CNseInstance* pL;
  1272. BOOL fSt = FALSE;
  1273. if ( pL = Locate( pI, pMD ) )
  1274. {
  1275. fSt = Get( pI, dwIndex, pMD, pL, pdwReq );
  1276. }
  1277. return fSt;
  1278. }
  1279. BOOL
  1280. CNseAllMappings::GetByIndex(
  1281. CNseInstance* pI,
  1282. DWORD dwIndex,
  1283. PMETADATA_RECORD pMD,
  1284. DWORD dwI,
  1285. LPDWORD pdwReq
  1286. )
  1287. /*++
  1288. Routine Description:
  1289. get property from child based on child index
  1290. Arguments:
  1291. pI - current instance
  1292. dwIndex - instance index
  1293. pMD - metadata record, only ID is used
  1294. dwI - child index in child list
  1295. pdwReq - updated with required length if length specified in pMD is not
  1296. sufficient
  1297. Returns:
  1298. TRUE if success, otherwise FALSE
  1299. --*/
  1300. {
  1301. CNseInstance* pL;
  1302. BOOL fSt = FALSE;
  1303. if ( dwI < pI->GetNbChildren() )
  1304. {
  1305. fSt = Get( pI, dwIndex, pMD, pI->GetChild(dwI), pdwReq );
  1306. }
  1307. return fSt;
  1308. }
  1309. BOOL
  1310. CNseAllMappings::Get(
  1311. CNseInstance* pI,
  1312. DWORD dwIndex,
  1313. PMETADATA_RECORD pMD,
  1314. CNseInstance* pL,
  1315. LPDWORD pdwReq
  1316. )
  1317. /*++
  1318. Routine Description:
  1319. get property from specified child instance
  1320. Arguments:
  1321. pI - current instance
  1322. dwIndex - instance index
  1323. pMD - metadata record, only ID is used
  1324. pL - instance where property is defined
  1325. pdwReq - updated with required length if length specified in pMD is not
  1326. sufficient
  1327. Returns:
  1328. TRUE if success, otherwise FALSE
  1329. --*/
  1330. {
  1331. CIisAcctMapper* pM = (CIisAcctMapper*)((RefBlob*)pI->m_pniParent->m_pniParent->m_pvParam)->QueryPtr();
  1332. CIisMapping* pG;
  1333. LPSTR pData;
  1334. DWORD cData;
  1335. BOOL fSt = FALSE;
  1336. if ( pM )
  1337. {
  1338. pM->Lock();
  1339. if ( pM->GetMapping( dwIndex, &pG, TRUE, FALSE ) &&
  1340. pG->MappingGetField( pL->m_pTemplateObject->GetDwParam(), &pData, &cData, FALSE ) )
  1341. {
  1342. if ( pMD->dwMDDataLen >= cData )
  1343. {
  1344. if ( pMD->pbMDData )
  1345. {
  1346. memcpy( pMD->pbMDData, pData, cData );
  1347. }
  1348. pMD->dwMDDataLen = cData;
  1349. fSt = TRUE;
  1350. }
  1351. else
  1352. {
  1353. SetLastError( ERROR_INSUFFICIENT_BUFFER );
  1354. }
  1355. pMD->dwMDDataType = pL->m_pTemplateObject->GetDwParam2();
  1356. pMD->dwMDDataTag = NULL;
  1357. if ( pMD->dwMDIdentifier == MD_MAPNTPWD )
  1358. {
  1359. pMD->dwMDAttributes |= METADATA_SECURE;
  1360. }
  1361. *pdwReq = cData;
  1362. }
  1363. pM->Unlock();
  1364. }
  1365. return fSt;
  1366. }
  1367. BOOL
  1368. CNseAllMappings::Add(
  1369. CNseInstance* pI,
  1370. DWORD dwIndex
  1371. )
  1372. /*++
  1373. Routine Description:
  1374. add a mapping entry
  1375. Arguments:
  1376. pI - current instance
  1377. dwIndex - ignored
  1378. Returns:
  1379. TRUE if success, otherwise FALSE
  1380. --*/
  1381. {
  1382. CIisAcctMapper* pM = (CIisAcctMapper*)((RefBlob*)pI->m_pniParent->m_pvParam)->QueryPtr();
  1383. CIisMapping* pG;
  1384. BOOL fSt = FALSE;
  1385. if ( pM )
  1386. {
  1387. pM->Lock();
  1388. if ( dwIndex == pM->GetNbMapping( TRUE ) ||
  1389. dwIndex == (DWORD)-1 )
  1390. {
  1391. if ( pG = pM->CreateNewMapping() )
  1392. {
  1393. if ( !pM->Add( pG, TRUE ) )
  1394. {
  1395. delete pG;
  1396. }
  1397. else
  1398. {
  1399. pI->m_pniParent->m_dwParam = pM->GetNbMapping( TRUE );
  1400. fSt = TRUE;
  1401. }
  1402. }
  1403. }
  1404. else
  1405. {
  1406. SetLastError( ERROR_INVALID_NAME );
  1407. }
  1408. pM->Unlock();
  1409. pI->m_pniParent->m_fModified = TRUE;
  1410. }
  1411. return fSt;
  1412. }
  1413. BOOL
  1414. CNseAllMappings::Delete(
  1415. LPSTR pszPath,
  1416. CNseInstance* pI,
  1417. DWORD dwIndex
  1418. )
  1419. /*++
  1420. Routine Description:
  1421. delete a mapping entry
  1422. Arguments:
  1423. pszPath - path where mapper exists in tree
  1424. pI - current instance
  1425. dwIndex - mapping entry index ( 0 based )
  1426. Returns:
  1427. TRUE if success, otherwise FALSE
  1428. --*/
  1429. {
  1430. CIisAcctMapper *pM = (CIisAcctMapper*)((RefBlob*)pI->m_pniParent->m_pniParent->m_pvParam)->QueryPtr();
  1431. BOOL fSt = FALSE;
  1432. if ( pM )
  1433. {
  1434. pM->Lock();
  1435. fSt = pM->Delete( dwIndex, TRUE );
  1436. pM->Unlock();
  1437. pI->m_pniParent->m_pniParent->m_fModified = TRUE;
  1438. }
  1439. return fSt;
  1440. }
  1441. BOOL
  1442. CNoCppObj::Get(
  1443. CNseInstance* pI,
  1444. DWORD,
  1445. PMETADATA_RECORD pM,
  1446. LPDWORD pdwRequiredLen
  1447. )
  1448. /*++
  1449. Routine Description:
  1450. get ptr to c++ mapper object ( as a RefBlob )
  1451. returned data is ptr to RefBlob pointing to c++ mapper object
  1452. RefBlob refcount is incremented
  1453. Arguments:
  1454. pI - current instance
  1455. pM - metadata record, ID ignored, updated with ID, data type & length
  1456. pdwRequiredLen - ignored, length is assumed to be sufficient
  1457. Returns:
  1458. TRUE if success, otherwise FALSE
  1459. --*/
  1460. {
  1461. if ( pI->m_pniParent->m_pvParam )
  1462. {
  1463. *(LPVOID*)pM->pbMDData = pI->m_pniParent->m_pvParam; // ptr to RefBlob
  1464. pM->dwMDDataLen = sizeof(pI->m_pniParent->m_pvParam);
  1465. pM->dwMDDataType = BINARY_METADATA;
  1466. pM->dwMDIdentifier = m_dwId;
  1467. ((RefBlob*)pI->m_pniParent->m_pvParam)->AddRef();
  1468. return TRUE;
  1469. }
  1470. return FALSE;
  1471. }
  1472. BOOL
  1473. CSerialAllObj::Get(
  1474. CNseInstance* pI,
  1475. DWORD,
  1476. PMETADATA_RECORD pMD,
  1477. LPDWORD pdwRequiredLen
  1478. )
  1479. /*++
  1480. Routine Description:
  1481. serialize all mappings
  1482. Arguments:
  1483. pI - current instance
  1484. pM - metadata record, ID ignored, updated with ID, data type & length
  1485. pdwRequiredLen - ignored, length is assumed to be sufficient
  1486. Returns:
  1487. TRUE if success, otherwise FALSE
  1488. --*/
  1489. {
  1490. CIisAcctMapper *pM = (CIisAcctMapper*)((RefBlob*)pI->m_pniParent->m_pvParam)->QueryPtr();
  1491. BOOL fSt = TRUE;
  1492. if ( pM )
  1493. {
  1494. // serial format : list [(DWORD)elem, elem]
  1495. CIisMapping* pG;
  1496. LPSTR pData;
  1497. DWORD cData;
  1498. UINT cM;
  1499. UINT iM;
  1500. DWORD cF;
  1501. UINT iF;
  1502. LPSTR * pFields;
  1503. LPDWORD pcFields;
  1504. DWORD cLen = 0;
  1505. LPBYTE pD;
  1506. IISMDB_Fields* pFld;
  1507. pM->Lock();
  1508. pM->MappingGetFieldList( &pFld, &cF );
  1509. cM = pM->GetNbMapping();
  1510. pD = pMD->pbMDData;
  1511. for ( iM = 0 ; iM < cM ; ++iM )
  1512. {
  1513. if ( pM->GetMapping( iM, &pG, FALSE, FALSE ) )
  1514. {
  1515. for ( iF = 0 ; iF < cF ; ++iF )
  1516. {
  1517. if ( !pG->MappingGetField( iF, &pData, &cData, FALSE ) )
  1518. {
  1519. fSt = FALSE;
  1520. SetLastError( ERROR_INVALID_NAME );
  1521. goto ExitIterMappings;
  1522. }
  1523. cLen += sizeof(DWORD) + DWORDALIGNCOUNT(cData);
  1524. if ( cLen <= pMD->dwMDDataLen )
  1525. {
  1526. *(LPDWORD)pD = cData;
  1527. memcpy( pD + sizeof(DWORD), pData, cData );
  1528. pD += sizeof(DWORD) + DWORDALIGNCOUNT(cData);
  1529. }
  1530. }
  1531. }
  1532. else
  1533. {
  1534. SetLastError( ERROR_INVALID_NAME );
  1535. fSt = FALSE;
  1536. break;
  1537. }
  1538. }
  1539. ExitIterMappings:
  1540. pM->Unlock();
  1541. if ( fSt )
  1542. {
  1543. if ( cLen > pMD->dwMDDataLen )
  1544. {
  1545. SetLastError( ERROR_INSUFFICIENT_BUFFER );
  1546. *pdwRequiredLen = cLen;
  1547. fSt = FALSE;
  1548. }
  1549. else
  1550. {
  1551. pMD->dwMDDataLen = cLen;
  1552. pMD->dwMDAttributes |= METADATA_SECURE;
  1553. }
  1554. }
  1555. }
  1556. else
  1557. {
  1558. SetLastError( ERROR_INVALID_PARAMETER );
  1559. fSt = FALSE;
  1560. }
  1561. return fSt;
  1562. }
  1563. BOOL
  1564. CSerialAllObj::Set(
  1565. CNseInstance* pI,
  1566. DWORD,
  1567. PMETADATA_RECORD pMD
  1568. )
  1569. /*++
  1570. Routine Description:
  1571. deserialize all mappings
  1572. Arguments:
  1573. pI - current instance
  1574. pM - metadata record, ID ignored
  1575. Returns:
  1576. TRUE if success, otherwise FALSE
  1577. --*/
  1578. {
  1579. CIisAcctMapper *pM = (CIisAcctMapper*)((RefBlob*)pI->m_pniParent->m_pvParam)->QueryPtr();
  1580. BOOL fSt = TRUE;
  1581. if ( pM )
  1582. {
  1583. // serial format : list [(DWORD)elem, elem]
  1584. CIisMapping* pG;
  1585. DWORD cData;
  1586. UINT cM;
  1587. UINT iM;
  1588. DWORD cF;
  1589. UINT iF;
  1590. LPSTR * pFields;
  1591. LPDWORD pcFields;
  1592. DWORD cLen = pMD->dwMDDataLen;
  1593. LPBYTE pD;
  1594. IISMDB_Fields* pFld;
  1595. pM->Lock();
  1596. pM->MappingGetFieldList( &pFld, &cF );
  1597. cM = pM->GetNbMapping();
  1598. //
  1599. // delete all existing mappings
  1600. //
  1601. for ( iM = 0 ; iM < cM ; ++iM )
  1602. {
  1603. pM->Delete( 0 );
  1604. }
  1605. pD = pMD->pbMDData;
  1606. //
  1607. // Iterate on buffer
  1608. //
  1609. while ( cLen )
  1610. {
  1611. if ( pG = pM->CreateNewMapping() )
  1612. {
  1613. //
  1614. // get all fields for this entry from buffer
  1615. //
  1616. for ( iF = 0 ; iF < cF ; ++iF )
  1617. {
  1618. cData = *(LPDWORD)pD;
  1619. if ( cLen >= sizeof(DWORD) + cData )
  1620. {
  1621. if ( !pG->MappingSetField( iF, (LPSTR)pD+sizeof(DWORD), cData, FALSE ) )
  1622. {
  1623. fSt = FALSE;
  1624. SetLastError( ERROR_NOT_ENOUGH_MEMORY );
  1625. goto ExitIterMappings;
  1626. }
  1627. }
  1628. else
  1629. {
  1630. fSt = FALSE;
  1631. SetLastError( ERROR_INVALID_PARAMETER );
  1632. goto ExitIterMappings;
  1633. }
  1634. cLen -= sizeof(DWORD) + DWORDALIGNCOUNT(cData);
  1635. pD += sizeof(DWORD) + DWORDALIGNCOUNT(cData);
  1636. }
  1637. if ( !pM->Add( pG, FALSE ) )
  1638. {
  1639. delete pG;
  1640. fSt = FALSE;
  1641. SetLastError( ERROR_NOT_ENOUGH_MEMORY );
  1642. break;
  1643. }
  1644. else
  1645. {
  1646. pI->m_pniParent->m_fModified = TRUE;
  1647. }
  1648. }
  1649. else
  1650. {
  1651. fSt = FALSE;
  1652. SetLastError( ERROR_NOT_ENOUGH_MEMORY );
  1653. break;
  1654. }
  1655. }
  1656. ExitIterMappings:
  1657. pM->Unlock();
  1658. }
  1659. else
  1660. {
  1661. SetLastError( ERROR_INVALID_PARAMETER );
  1662. fSt = FALSE;
  1663. }
  1664. return fSt;
  1665. }
  1666. BOOL
  1667. CKeyedAccess::Get(
  1668. CNseInstance* pI,
  1669. DWORD,
  1670. PMETADATA_RECORD pMD,
  1671. LPDWORD pdwRequiredLen
  1672. )
  1673. /*++
  1674. Routine Description:
  1675. get index set by previous successfull CKeyedAccess::Set
  1676. Arguments:
  1677. pI - current instance
  1678. pM - metadata record, ID ignored, updated with ID, data type & length
  1679. pdwRequiredLen - ignored, length is assumed to be sufficient
  1680. Returns:
  1681. TRUE if success, otherwise FALSE
  1682. --*/
  1683. {
  1684. BOOL fSt;
  1685. if ( sizeof(DWORD) > pMD->dwMDDataLen )
  1686. {
  1687. SetLastError( ERROR_INSUFFICIENT_BUFFER );
  1688. *pdwRequiredLen = sizeof(DWORD);
  1689. fSt = FALSE;
  1690. }
  1691. else if ( pMD->dwMDDataType != DWORD_METADATA )
  1692. {
  1693. SetLastError( ERROR_INVALID_PARAMETER );
  1694. fSt = FALSE;
  1695. }
  1696. else
  1697. {
  1698. pMD->dwMDDataLen = sizeof(DWORD);
  1699. *pdwRequiredLen = sizeof(DWORD);
  1700. *(LPDWORD)pMD->pbMDData = pI->m_pniParent->m_dwParam;
  1701. fSt = TRUE;
  1702. }
  1703. return fSt;
  1704. }
  1705. BOOL
  1706. CKeyedAccess::Set(
  1707. CNseInstance* pI,
  1708. DWORD,
  1709. PMETADATA_RECORD pMD,
  1710. DWORD dwType
  1711. )
  1712. /*++
  1713. Routine Description:
  1714. Find a mapping based on key
  1715. Arguments:
  1716. pI - current instance
  1717. pM - metadata record, ID ignored
  1718. dwType - type of access : by cert, account, name
  1719. Returns:
  1720. TRUE if success, otherwise FALSE
  1721. error set to ERROR_PATH_NOT_FOUND if key not found in mappings
  1722. --*/
  1723. {
  1724. CIisAcctMapper *pM = (CIisAcctMapper*)((RefBlob*)pI->m_pniParent->m_pvParam)->QueryPtr();
  1725. BOOL fSt = FALSE;
  1726. if ( pM )
  1727. {
  1728. // serial format : list [(DWORD)elem, elem]
  1729. CIisMapping* pG;
  1730. DWORD cData;
  1731. LPSTR pData;
  1732. UINT cM;
  1733. UINT iM;
  1734. UINT iF;
  1735. switch ( dwType )
  1736. {
  1737. case NSEPM_ACCESS_CERT:
  1738. iF = IISMDB_INDEX_CERT11_CERT;
  1739. break;
  1740. case NSEPM_ACCESS_ACCOUNT:
  1741. iF = IISMDB_INDEX_CERT11_NT_ACCT;
  1742. break;
  1743. case NSEPM_ACCESS_NAME:
  1744. iF = IISMDB_INDEX_CERT11_NAME;
  1745. break;
  1746. default:
  1747. SetLastError( ERROR_INVALID_PARAMETER );
  1748. return FALSE;
  1749. }
  1750. pM->Lock();
  1751. cM = pM->GetNbMapping();
  1752. for ( iM = 0 ; iM < cM ; ++iM )
  1753. {
  1754. if ( pM->GetMapping( iM, &pG, TRUE, FALSE ) )
  1755. {
  1756. if ( !pG->MappingGetField( iF, &pData, &cData, FALSE ) )
  1757. {
  1758. SetLastError( ERROR_INVALID_NAME );
  1759. break;
  1760. }
  1761. if ( cData == pMD->dwMDDataLen &&
  1762. !memcmp( pData, pMD->pbMDData, cData ) )
  1763. {
  1764. fSt = TRUE;
  1765. pI->m_pniParent->m_dwParam = iM + 1;
  1766. break;
  1767. }
  1768. }
  1769. else
  1770. {
  1771. SetLastError( ERROR_INVALID_NAME );
  1772. break;
  1773. }
  1774. }
  1775. if ( iM == cM )
  1776. {
  1777. SetLastError( ERROR_PATH_NOT_FOUND );
  1778. }
  1779. pM->Unlock();
  1780. }
  1781. else
  1782. {
  1783. SetLastError( ERROR_INVALID_PARAMETER );
  1784. fSt = FALSE;
  1785. }
  1786. return fSt;
  1787. }
  1788. BOOL
  1789. CNoCwSerObj::Get(
  1790. CNseInstance* pI,
  1791. DWORD,
  1792. PMETADATA_RECORD pMD,
  1793. LPDWORD pdwRequiredLen
  1794. )
  1795. /*++
  1796. Routine Description:
  1797. get serialized representation of cert wildcard mapper
  1798. to be deserialized in CIisRuleMapper
  1799. Arguments:
  1800. pI - current instance
  1801. pMD - metadata record, ID ignored & type , updated with length
  1802. pdwRequiredLen - updated with required length if pMD length is not sufficient
  1803. Returns:
  1804. TRUE if success, otherwise FALSE
  1805. --*/
  1806. {
  1807. BOOL fSt = FALSE;
  1808. CIisRuleMapper * pM;
  1809. if ( pI->m_pniParent->m_pvParam )
  1810. {
  1811. pM = (CIisRuleMapper*) ((RefBlob*)pI->m_pniParent->m_pvParam)->QueryPtr();
  1812. pM->LockRules();
  1813. CStoreXBF xbf;
  1814. if ( pM->Serialize( &xbf ) )
  1815. {
  1816. *pdwRequiredLen = xbf.GetUsed();
  1817. if ( pMD->dwMDDataLen >= xbf.GetUsed() )
  1818. {
  1819. memcpy( pMD->pbMDData, xbf.GetBuff(), xbf.GetUsed() );
  1820. pMD->dwMDDataLen = xbf.GetUsed();
  1821. fSt = TRUE;
  1822. }
  1823. else
  1824. {
  1825. SetLastError( ERROR_INSUFFICIENT_BUFFER );
  1826. }
  1827. }
  1828. pM->UnlockRules();
  1829. }
  1830. return fSt;
  1831. }
  1832. BOOL
  1833. CNoCwSerObj::Set(
  1834. CNseInstance* pI,
  1835. DWORD,
  1836. PMETADATA_RECORD pMD
  1837. )
  1838. /*++
  1839. Routine Description:
  1840. set cert wildcard mapper from serialized representation
  1841. Arguments:
  1842. pI - current instance
  1843. pMD - metadata record, ID ignored & type , updated with length
  1844. Returns:
  1845. TRUE if success, otherwise FALSE
  1846. --*/
  1847. {
  1848. BOOL fSt = TRUE;
  1849. CIisRuleMapper * pM;
  1850. if ( pI->m_pniParent->m_pvParam )
  1851. {
  1852. pM = (CIisRuleMapper*) ((RefBlob*)pI->m_pniParent->m_pvParam)->QueryPtr();
  1853. pM->LockRules();
  1854. LPBYTE pB = pMD->pbMDData;
  1855. DWORD dwB = pMD->dwMDDataLen;
  1856. if ( pM->Unserialize( &pB, &dwB ) )
  1857. {
  1858. pI->m_pniParent->m_fModified = TRUE;
  1859. }
  1860. pM->UnlockRules();
  1861. }
  1862. return fSt;
  1863. }
  1864. BOOL
  1865. CNoIsSerObj::Get(
  1866. CNseInstance* pI,
  1867. DWORD,
  1868. PMETADATA_RECORD pMD,
  1869. LPDWORD pdwRequiredLen
  1870. )
  1871. /*++
  1872. Routine Description:
  1873. get serialized representation of issuer list
  1874. to be deserialized in CIssuerStore
  1875. Arguments:
  1876. pI - current instance
  1877. pMD - metadata record, ID ignored & type , updated with length
  1878. pdwRequiredLen - updated with required length if pMD length is not sufficient
  1879. Returns:
  1880. TRUE if success, otherwise FALSE
  1881. --*/
  1882. {
  1883. BOOL fSt = FALSE;
  1884. CIssuerStore is;
  1885. CStoreXBF xbf;
  1886. if ( is.LoadServerAcceptedIssuers() && is.Serialize( &xbf ) )
  1887. {
  1888. *pdwRequiredLen = xbf.GetUsed();
  1889. if ( pMD->dwMDDataLen >= xbf.GetUsed() )
  1890. {
  1891. memcpy( pMD->pbMDData, xbf.GetBuff(), xbf.GetUsed() );
  1892. pMD->dwMDDataLen = xbf.GetUsed();
  1893. fSt = TRUE;
  1894. }
  1895. else
  1896. {
  1897. SetLastError( ERROR_INSUFFICIENT_BUFFER );
  1898. }
  1899. }
  1900. return fSt;
  1901. }
  1902. CNseInstance::CNseInstance(
  1903. CNseObj* pTemp,
  1904. CNseInstance* pFather
  1905. )
  1906. /*++
  1907. Routine Description:
  1908. CNseInstance constructor
  1909. Arguments:
  1910. pTemp - ptr to template object
  1911. pFather - ptr to father instance
  1912. Returns:
  1913. Nothing
  1914. --*/
  1915. {
  1916. m_fModified = FALSE;
  1917. m_pvParam = NULL;
  1918. m_pniParent = pFather;
  1919. m_pTemplateObject = pTemp;
  1920. }
  1921. BOOL
  1922. CNseInstance::CreateChildrenInstances(
  1923. BOOL fRecursive
  1924. )
  1925. /*++
  1926. Routine Description:
  1927. Create children instance objects
  1928. Arguments:
  1929. fRecursive - TRUE for recursive creation
  1930. Returns:
  1931. TRUE if success, otherwise FALSE
  1932. --*/
  1933. {
  1934. CNseInstance* pI;
  1935. UINT i;
  1936. // create all object ( not property ) children
  1937. for ( i = 0 ; i < m_pTemplateObject->m_cnoChildren ; ++i )
  1938. {
  1939. if ( !(pI = new CNseInstance) )
  1940. {
  1941. return FALSE;
  1942. }
  1943. pI->m_pTemplateObject = m_pTemplateObject->m_pnoChildren[i];
  1944. pI->m_pniParent = this;
  1945. if ( !AddChild( pI ) )
  1946. {
  1947. // BugFix: 57659 Whistler
  1948. // Prefix bug leaking memory in error condition.
  1949. // If we were not able to add the child to the list
  1950. // than we should delete the memory it takes instead
  1951. // of just orphaning it.
  1952. // EBK 5/5/2000
  1953. delete pI;
  1954. pI = NULL;
  1955. return FALSE;
  1956. }
  1957. if ( fRecursive && !pI->CreateChildrenInstances( fRecursive ) )
  1958. {
  1959. return FALSE;
  1960. }
  1961. }
  1962. return TRUE;
  1963. }
  1964. CNseMountPoint::CNseMountPoint(
  1965. )
  1966. /*++
  1967. Routine Description:
  1968. CNseMountPoint constructor
  1969. Arguments:
  1970. None
  1971. Returns:
  1972. Nothing
  1973. --*/
  1974. {
  1975. m_pTopTemp = NULL;
  1976. }
  1977. BOOL
  1978. CNseMountPoint::Release(
  1979. )
  1980. /*++
  1981. Routine Description:
  1982. Free children instances of this mount point
  1983. Arguments:
  1984. None
  1985. Returns:
  1986. TRUE if success, otherwise FALSE
  1987. --*/
  1988. {
  1989. UINT i;
  1990. for ( i = 0 ;i < m_pTopInst.GetNbChildren() ; ++i )
  1991. {
  1992. m_pTopInst.GetChild(i)->m_pTemplateObject->Release( m_pTopInst.GetChild(i), 0 );
  1993. }
  1994. return TRUE;
  1995. }
  1996. BOOL
  1997. CNseMountPoint::Save(
  1998. LPBOOL pfModified
  1999. )
  2000. /*++
  2001. Routine Description:
  2002. Save changes made children instances of this mount point on persistent storage
  2003. Arguments:
  2004. pfModified - updated with TRUE if metadata modified
  2005. Returns:
  2006. TRUE if success, otherwise FALSE
  2007. --*/
  2008. {
  2009. UINT i;
  2010. BOOL fRet = TRUE;
  2011. for ( i = 0 ;i < m_pTopInst.GetNbChildren() ; ++i )
  2012. {
  2013. if ( !m_pTopInst.GetChild(i)->m_pTemplateObject->Save( m_pszPath.Get(), m_pTopInst.GetChild(i), pfModified ) )
  2014. {
  2015. fRet = FALSE;
  2016. }
  2017. }
  2018. return fRet;
  2019. }
  2020. BOOL
  2021. CNseMountPoint::EndTransac(
  2022. BOOL fApplyChanges
  2023. )
  2024. /*++
  2025. Routine Description:
  2026. Signal a close operation to mount poinr
  2027. Arguments:
  2028. fApplyChanges - TRUE to commit changes
  2029. Returns:
  2030. TRUE if success, otherwise FALSE
  2031. --*/
  2032. {
  2033. UINT i;
  2034. BOOL fRet = TRUE;
  2035. for ( i = 0 ;i < m_pTopInst.GetNbChildren() ; ++i )
  2036. {
  2037. if ( !m_pTopInst.GetChild(i)->m_pTemplateObject->EndTransac( m_pszPath.Get(), m_pTopInst.GetChild(i), fApplyChanges ) )
  2038. {
  2039. fRet = FALSE;
  2040. }
  2041. }
  2042. return fRet;
  2043. }
  2044. //
  2045. // Global functions
  2046. //
  2047. CNseInstance*
  2048. LocateObject(
  2049. LPSTR* ppszPath,
  2050. BOOL fIncludeLastSegment,
  2051. LPDWORD pdwIndex,
  2052. CNseMountPoint**ppMP
  2053. )
  2054. /*++
  2055. Routine Description:
  2056. Return instance matching path
  2057. Arguments:
  2058. ppszPath - ptr to path, updated with name of last path element
  2059. if fIncludeLastSegment is FALSE
  2060. fIncludeLastSegment - TRUE to use full path, FALSE to stop before last
  2061. path element
  2062. pdwIndex - updated with index for iterated instance
  2063. ppMP - updated with ptr to mount point
  2064. Returns:
  2065. ptr to instance if success, otherwise NULL
  2066. --*/
  2067. {
  2068. LPSTR p;
  2069. LPSTR pN;
  2070. LPSTR p2;
  2071. LPSTR pNx;
  2072. LPSTR pS;
  2073. LPSTR pszPath = *ppszPath;
  2074. LIST_ENTRY* pEntry;
  2075. CNseMountPoint* pMount = NULL;
  2076. CNseObj* pTemp;
  2077. CNseInstance* pWalk;
  2078. UINT i;
  2079. UINT iM;
  2080. //
  2081. // leading path delimiter is not mandatory, so skip it if present to consider
  2082. // both formats as equivalent.
  2083. //
  2084. if ( *pszPath == '/' || *pszPath == '\\' )
  2085. {
  2086. ++pszPath;
  2087. }
  2088. // delimit to NSEP, find MountPoint ( create one if not exist )
  2089. if ( (pS = strchr( pszPath, '<' )) &&
  2090. (p = strchr( pszPath, '>' )) &&
  2091. (pS < p) &&
  2092. (pS > pszPath) &&
  2093. (p[1]=='\0' || p[1]=='/' || p[1]=='\\') )
  2094. {
  2095. if ( p[1] )
  2096. {
  2097. p[1] = '\0';
  2098. p += 2;
  2099. }
  2100. else
  2101. {
  2102. ++p;
  2103. }
  2104. pS[-1] = '\0';
  2105. EnterCriticalSection( &CNseMountPoint::m_csList );
  2106. for ( pEntry = CNseMountPoint::m_ListHead.Flink;
  2107. pEntry != &CNseMountPoint::m_ListHead ;
  2108. pEntry = pEntry->Flink )
  2109. {
  2110. pMount = CONTAINING_RECORD( pEntry,
  2111. CNseMountPoint,
  2112. CNseMountPoint::m_ListEntry );
  2113. if ( !_stricmp( pMount->m_pszPath.Get(), pszPath ) )
  2114. {
  2115. break;
  2116. }
  2117. else
  2118. {
  2119. pMount = NULL;
  2120. }
  2121. }
  2122. if( pMount == NULL )
  2123. {
  2124. if ( (pMount = new CNseMountPoint()) &&
  2125. pMount->Init( pszPath ) )
  2126. {
  2127. InsertHeadList( &CNseMountPoint::m_ListHead,
  2128. &pMount->m_ListEntry );
  2129. pMount->m_pTopTemp = &g_NoList;
  2130. pMount->m_pTopTemp->Load( &pMount->m_pTopInst, pszPath );
  2131. }
  2132. else
  2133. {
  2134. if ( pMount )
  2135. {
  2136. delete pMount;
  2137. pMount = NULL;
  2138. }
  2139. }
  2140. }
  2141. LeaveCriticalSection( &CNseMountPoint::m_csList );
  2142. if( pMount == NULL )
  2143. {
  2144. SetLastError( ERROR_NOT_ENOUGH_MEMORY );
  2145. return NULL;
  2146. }
  2147. // delimit before last elem in path, find partial path
  2148. pWalk = &pMount->m_pTopInst;
  2149. for ( ; *p ; p = pNx )
  2150. {
  2151. pN = strchr( p, '/' );
  2152. p2 = strchr( p, '\\' );
  2153. if ( !pN || (p2 && p2 < pN ) )
  2154. {
  2155. pN = p2;
  2156. }
  2157. if ( !pN )
  2158. {
  2159. if ( fIncludeLastSegment )
  2160. {
  2161. pN = p + strlen( p );
  2162. pNx = pN;
  2163. }
  2164. else
  2165. {
  2166. break;
  2167. }
  2168. }
  2169. else
  2170. {
  2171. pNx = pN + 1;
  2172. }
  2173. *pN = '\0';
  2174. // find in pWalk
  2175. for ( i = 0, iM = pWalk->GetNbChildren(); i < iM ; ++i )
  2176. {
  2177. if ( pWalk->GetChild( i )->m_pTemplateObject->GetIterated() )
  2178. {
  2179. pWalk = pWalk->GetChild( i );
  2180. if ( (UINT)atoi(p)-1 < pWalk->m_pTemplateObject->GetCount( pWalk, 0 ) )
  2181. {
  2182. if ( pdwIndex )
  2183. {
  2184. *pdwIndex = atoi( p )-1;
  2185. }
  2186. break;
  2187. }
  2188. }
  2189. if ( pdwIndex )
  2190. {
  2191. *pdwIndex = 0;
  2192. }
  2193. if ( pWalk->GetChild( i )->m_pTemplateObject->m_pszName &&
  2194. !_stricmp( pWalk->GetChild( i )->m_pTemplateObject->m_pszName,
  2195. p ) )
  2196. {
  2197. pWalk = pWalk->GetChild( i );
  2198. break;
  2199. }
  2200. }
  2201. if ( i == iM )
  2202. {
  2203. SetLastError( ERROR_PATH_NOT_FOUND );
  2204. return NULL;
  2205. }
  2206. }
  2207. *ppszPath = p;
  2208. if ( ppMP )
  2209. {
  2210. *ppMP = pMount;
  2211. }
  2212. return pWalk;
  2213. }
  2214. SetLastError( ERROR_PATH_NOT_FOUND );
  2215. return NULL;
  2216. }
  2217. BOOL
  2218. NseAddObj(
  2219. LPSTR pszPath
  2220. )
  2221. /*++
  2222. Routine Description:
  2223. Handle Add Object operation
  2224. Arguments:
  2225. pszPath - absolute path of object to create
  2226. Returns:
  2227. TRUE if success, otherwise FALSE
  2228. --*/
  2229. {
  2230. CNseObj* pTemp;
  2231. CNseInstance* pWalk;
  2232. UINT i;
  2233. DWORD dwIndex;
  2234. BOOL fSt = FALSE;
  2235. EnterCriticalSection( &CNseMountPoint::m_csList );
  2236. if ( pWalk = LocateObject( &pszPath, FALSE, &dwIndex ) )
  2237. {
  2238. // add object instance ( check not already exist first )
  2239. for ( i = 0 ; i < pWalk->GetNbChildren() ; ++i )
  2240. {
  2241. if ( pWalk->GetChild(i)->m_pTemplateObject->m_pszName &&
  2242. !_stricmp( pWalk->GetChild(i)->m_pTemplateObject->m_pszName, pszPath ) )
  2243. {
  2244. SetLastError( ERROR_ALREADY_EXISTS );
  2245. LeaveCriticalSection( &CNseMountPoint::m_csList );
  2246. return FALSE;
  2247. }
  2248. }
  2249. // find in template
  2250. pTemp = pWalk->m_pTemplateObject;
  2251. for ( i = 0 ; i < pTemp->m_cnoChildren; ++i )
  2252. {
  2253. if ( pTemp->m_pnoChildren[i]->GetIterated() ||
  2254. !_stricmp( pszPath, pTemp->m_pnoChildren[i]->m_pszName ) )
  2255. {
  2256. break;
  2257. }
  2258. }
  2259. if ( i < pTemp->m_cnoChildren )
  2260. {
  2261. fSt = pTemp->m_pnoChildren[i]->Add( pWalk,
  2262. pTemp->m_pnoChildren[i]->GetIterated()
  2263. ? strtoul(pszPath,NULL,10)-1 : 0
  2264. );
  2265. }
  2266. }
  2267. LeaveCriticalSection( &CNseMountPoint::m_csList );
  2268. return fSt;
  2269. }
  2270. BOOL
  2271. NseDeleteObj(
  2272. LPSTR pszPath
  2273. )
  2274. /*++
  2275. Routine Description:
  2276. Handle Delete Object operation
  2277. Arguments:
  2278. pszPath - absolute path of object to delete
  2279. Returns:
  2280. TRUE if success, otherwise FALSE
  2281. --*/
  2282. {
  2283. CNseInstance* pWalk;
  2284. DWORD dwIndex;
  2285. BOOL fSt = FALSE;
  2286. CNseMountPoint* pMP;
  2287. EnterCriticalSection( &CNseMountPoint::m_csList );
  2288. if ( pWalk = LocateObject( &pszPath, TRUE, &dwIndex, &pMP ) )
  2289. {
  2290. fSt = pWalk->m_pTemplateObject->Delete( pMP->GetPath(), pWalk, dwIndex );
  2291. }
  2292. LeaveCriticalSection( &CNseMountPoint::m_csList );
  2293. return fSt;
  2294. }
  2295. BOOL
  2296. NseGetProp(
  2297. LPSTR pszPath,
  2298. PMETADATA_RECORD pMD,
  2299. LPDWORD pdwReq
  2300. )
  2301. /*++
  2302. Routine Description:
  2303. Handle Get Property operation
  2304. Arguments:
  2305. pszPath - absolute path of object where property is to be queried
  2306. pMD - metadata descriptor
  2307. pdwReq - updated with required length of buffer
  2308. Returns:
  2309. TRUE if success, otherwise FALSE
  2310. error is ERROR_INSUFFICIENT_BUFFER if supplied buffer too small
  2311. --*/
  2312. {
  2313. CNseObj* pTemp;
  2314. CNseInstance* pWalk;
  2315. UINT i;
  2316. DWORD dwIndex;
  2317. BOOL fSt = FALSE;
  2318. EnterCriticalSection( &CNseMountPoint::m_csList );
  2319. if ( pWalk = LocateObject( &pszPath, TRUE, &dwIndex ) )
  2320. {
  2321. fSt = pWalk->m_pTemplateObject->Get( pWalk, dwIndex, pMD, pdwReq );
  2322. }
  2323. LeaveCriticalSection( &CNseMountPoint::m_csList );
  2324. return fSt;
  2325. }
  2326. BOOL
  2327. NseGetPropByIndex(
  2328. LPSTR pszPath,
  2329. PMETADATA_RECORD pMD,
  2330. DWORD dwI,
  2331. LPDWORD pdwReq
  2332. )
  2333. /*++
  2334. Routine Description:
  2335. Handle Get Property operation, based on property index ( 0 based )
  2336. Arguments:
  2337. pszPath - absolute path of object where property is to be queried
  2338. pMD - metadata descriptor
  2339. dwI - index of property in property list for this object
  2340. pdwReq - updated with required length of buffer
  2341. Returns:
  2342. TRUE if success, otherwise FALSE
  2343. error is ERROR_INSUFFICIENT_BUFFER if supplied buffer too small
  2344. --*/
  2345. {
  2346. CNseObj* pTemp;
  2347. CNseInstance* pWalk;
  2348. UINT i;
  2349. DWORD dwIndex;
  2350. BOOL fSt = FALSE;
  2351. EnterCriticalSection( &CNseMountPoint::m_csList );
  2352. if ( pWalk = LocateObject( &pszPath, TRUE, &dwIndex ) )
  2353. {
  2354. fSt = pWalk->m_pTemplateObject->GetByIndex( pWalk, dwIndex, pMD, dwI, pdwReq );
  2355. }
  2356. LeaveCriticalSection( &CNseMountPoint::m_csList );
  2357. return fSt;
  2358. }
  2359. BOOL
  2360. NseGetAllProp(
  2361. LPSTR pszPath,
  2362. DWORD dwMDAttributes,
  2363. DWORD dwMDUserType,
  2364. DWORD dwMDDataType,
  2365. DWORD * pdwMDNumDataEntries,
  2366. DWORD * pdwMDDataSetNumber,
  2367. DWORD dwMDBufferSize,
  2368. unsigned char * pbBuffer,
  2369. DWORD * pdwMDRequiredBufferSize
  2370. )
  2371. /*++
  2372. Routine Description:
  2373. Handle Get All Properties operation
  2374. Arguments:
  2375. pszPath - absolute path of object where properties are to be queried
  2376. dwMDAttributes - metadata attribute, ignored
  2377. dwMDUserType - metadata user type, ignored
  2378. dwMDDataType - metadata data type, ignored
  2379. pdwMDNumDataEntries - updated with count of properties
  2380. pdwMDDataSetNumber - ignored
  2381. dwMDBufferSize - size of pbBuffer
  2382. pbBuffer - buffer where to store properties descriptor and values
  2383. pdwMDRequiredBufferSize - updated with required length of buffer
  2384. Returns:
  2385. TRUE if success, otherwise FALSE
  2386. error is ERROR_INSUFFICIENT_BUFFER if supplied buffer too small
  2387. --*/
  2388. {
  2389. CNseInstance* pWalk;
  2390. UINT i;
  2391. DWORD dwReq;
  2392. DWORD dwIndex;
  2393. BOOL fSt = FALSE;
  2394. EnterCriticalSection( &CNseMountPoint::m_csList );
  2395. if ( pWalk = LocateObject( &pszPath, TRUE, &dwIndex ) )
  2396. {
  2397. fSt = pWalk->m_pTemplateObject->GetAll( pWalk, dwIndex, pdwMDNumDataEntries, dwMDBufferSize, pbBuffer, pdwMDRequiredBufferSize);
  2398. }
  2399. LeaveCriticalSection( &CNseMountPoint::m_csList );
  2400. return fSt;
  2401. }
  2402. BOOL
  2403. NseEnumObj(
  2404. LPSTR pszPath,
  2405. LPBYTE pszMDName,
  2406. DWORD dwMDEnumObjectIndex
  2407. )
  2408. /*++
  2409. Routine Description:
  2410. Handle Enumerate object operation
  2411. Arguments:
  2412. pszPath - absolute path where to enumerate objects
  2413. pszMDName - updated with object name
  2414. dwMDEnumObjectIndex - index of object ( 0 based ) in path
  2415. Returns:
  2416. TRUE if success, otherwise FALSE
  2417. ERROR_NO_MORE_ITEMS if index out of range
  2418. --*/
  2419. {
  2420. CNseInstance* pWalk;
  2421. UINT i;
  2422. DWORD dwReq;
  2423. DWORD dwIndex;
  2424. DWORD dwN;
  2425. BOOL fSt = FALSE;
  2426. EnterCriticalSection( &CNseMountPoint::m_csList );
  2427. if ( pWalk = LocateObject( &pszPath, TRUE, &dwIndex ) )
  2428. {
  2429. for ( i = 0 ; i < pWalk->GetNbChildren() ; )
  2430. {
  2431. if ( pWalk->GetChild(i)->m_pTemplateObject->m_pszName )
  2432. {
  2433. if ( pWalk->GetChild(i)->m_pTemplateObject->GetIterated() )
  2434. {
  2435. dwN = pWalk->GetChild(i)->m_pTemplateObject->GetCount( pWalk->GetChild(i), 0 );
  2436. if ( dwMDEnumObjectIndex < dwN )
  2437. {
  2438. if ( pszMDName )
  2439. {
  2440. wsprintf( (LPSTR)pszMDName,
  2441. pWalk->GetChild(i)->m_pTemplateObject->m_pszName,
  2442. dwMDEnumObjectIndex + 1);
  2443. }
  2444. fSt = TRUE;
  2445. }
  2446. break;
  2447. }
  2448. if ( !dwMDEnumObjectIndex-- )
  2449. {
  2450. if ( pszMDName )
  2451. {
  2452. strcpy( (LPSTR)pszMDName, pWalk->GetChild(i)->m_pTemplateObject->m_pszName );
  2453. }
  2454. fSt = TRUE;
  2455. break;
  2456. }
  2457. }
  2458. }
  2459. }
  2460. if ( !fSt )
  2461. {
  2462. SetLastError( ERROR_NO_MORE_ITEMS );
  2463. }
  2464. LeaveCriticalSection( &CNseMountPoint::m_csList );
  2465. return fSt;
  2466. }
  2467. BOOL
  2468. NseSetProp(
  2469. LPSTR pszPath,
  2470. PMETADATA_RECORD pMD
  2471. )
  2472. /*++
  2473. Routine Description:
  2474. Handle Set Property operation
  2475. Arguments:
  2476. pszPath - absolute path of object where property is to be set
  2477. pMD - metadata descriptor
  2478. Returns:
  2479. TRUE if success, otherwise FALSE
  2480. --*/
  2481. {
  2482. CNseObj* pTemp;
  2483. CNseInstance* pWalk;
  2484. UINT i;
  2485. DWORD dwReq;
  2486. DWORD dwIndex;
  2487. BOOL fSt = FALSE;
  2488. EnterCriticalSection( &CNseMountPoint::m_csList );
  2489. if ( *pszPath == '\0' &&
  2490. pMD->dwMDIdentifier == MD_NOTIFY_CERT11_TOUCHED &&
  2491. pMD->dwMDDataType == BINARY_METADATA ) // Funky fix for Sundown
  2492. {
  2493. PVOID p = *(PVOID *)pMD->pbMDData;
  2494. g_pfnCert11Touched = (PFN_MAPPER_TOUCHED)p;
  2495. fSt = TRUE;
  2496. }
  2497. else if ( pWalk = LocateObject( &pszPath, TRUE, &dwIndex ) )
  2498. {
  2499. if ( pMD->dwMDDataType == STRING_METADATA )
  2500. {
  2501. pMD->dwMDDataLen = strlen( (LPSTR)pMD->pbMDData ) + 1;
  2502. }
  2503. fSt = pWalk->m_pTemplateObject->Set( pWalk, dwIndex, pMD );
  2504. }
  2505. LeaveCriticalSection( &CNseMountPoint::m_csList );
  2506. return fSt;
  2507. }
  2508. BOOL
  2509. NseReleaseObjs(
  2510. )
  2511. /*++
  2512. Routine Description:
  2513. Free memory allocated by all instances
  2514. Arguments:
  2515. None
  2516. Returns:
  2517. TRUE if success, otherwise FALSE
  2518. --*/
  2519. {
  2520. LIST_ENTRY* pEntry;
  2521. LIST_ENTRY* pNext;
  2522. CNseMountPoint* pMount;
  2523. EnterCriticalSection( &CNseMountPoint::m_csList );
  2524. for ( pEntry = CNseMountPoint::m_ListHead.Flink;
  2525. pEntry != &CNseMountPoint::m_ListHead ;
  2526. pEntry = pNext )
  2527. {
  2528. pMount = CONTAINING_RECORD( pEntry,
  2529. CNseMountPoint,
  2530. CNseMountPoint::m_ListEntry );
  2531. pNext = pEntry->Flink;
  2532. RemoveEntryList( pEntry );
  2533. pMount->Release();
  2534. delete pMount;
  2535. }
  2536. LeaveCriticalSection( &CNseMountPoint::m_csList );
  2537. return TRUE;
  2538. }
  2539. BOOL
  2540. NseOpenObjs(
  2541. LPSTR pszPath
  2542. )
  2543. /*++
  2544. Routine Description:
  2545. Initialize access to objects
  2546. Arguments:
  2547. pszPath - ignored
  2548. Returns:
  2549. TRUE if success, otherwise FALSE
  2550. --*/
  2551. {
  2552. BOOL fSt = FALSE;
  2553. DWORD dwIndex;
  2554. EnterCriticalSection( &CNseMountPoint::m_csList );
  2555. if ( g_fPathOpened && GetCurrentThreadId() != g_dwCurrentThreadId )
  2556. {
  2557. SetLastError( ERROR_PATH_BUSY );
  2558. fSt = FALSE;
  2559. }
  2560. else if ( strchr( pszPath, '<' ) == NULL
  2561. || LocateObject( &pszPath, TRUE, &dwIndex ) )
  2562. {
  2563. fSt = TRUE;
  2564. g_fPathOpened = TRUE;
  2565. g_dwCurrentThreadId = GetCurrentThreadId();
  2566. }
  2567. LeaveCriticalSection( &CNseMountPoint::m_csList );
  2568. return fSt;
  2569. }
  2570. BOOL
  2571. NseCloseObjs(
  2572. BOOL fApplyChanges
  2573. )
  2574. /*++
  2575. Routine Description:
  2576. Signal close called to objects
  2577. Arguments:
  2578. fApplyChanges - TRUE to commit changes
  2579. Returns:
  2580. TRUE if success, otherwise FALSE
  2581. --*/
  2582. {
  2583. LIST_ENTRY* pEntry;
  2584. CNseMountPoint* pMount;
  2585. EnterCriticalSection( &CNseMountPoint::m_csList );
  2586. g_fPathOpened = FALSE;
  2587. g_dwCurrentThreadId = NULL;
  2588. for ( pEntry = CNseMountPoint::m_ListHead.Flink;
  2589. pEntry != &CNseMountPoint::m_ListHead ;
  2590. pEntry = pEntry->Flink )
  2591. {
  2592. pMount = CONTAINING_RECORD( pEntry,
  2593. CNseMountPoint,
  2594. CNseMountPoint::m_ListEntry );
  2595. pMount->EndTransac( fApplyChanges );
  2596. }
  2597. LeaveCriticalSection( &CNseMountPoint::m_csList );
  2598. return TRUE;
  2599. }
  2600. BOOL
  2601. NseSaveObjs(
  2602. )
  2603. /*++
  2604. Routine Description:
  2605. Save all objects
  2606. Arguments:
  2607. None
  2608. Returns:
  2609. TRUE if success, otherwise FALSE
  2610. --*/
  2611. {
  2612. LIST_ENTRY* pEntry;
  2613. CNseMountPoint* pMount;
  2614. BOOL fModified = FALSE;
  2615. BOOL fCert11Touched;
  2616. EnterCriticalSection( &CNseMountPoint::m_csList );
  2617. g_fCert11Touched = FALSE;
  2618. for ( pEntry = CNseMountPoint::m_ListHead.Flink;
  2619. pEntry != &CNseMountPoint::m_ListHead ;
  2620. pEntry = pEntry->Flink )
  2621. {
  2622. pMount = CONTAINING_RECORD( pEntry,
  2623. CNseMountPoint,
  2624. CNseMountPoint::m_ListEntry );
  2625. pMount->Save( &fModified );
  2626. }
  2627. #if 0
  2628. if ( fModified )
  2629. {
  2630. IMDCOM_PTR->ComMDSaveData();
  2631. }
  2632. #endif
  2633. fCert11Touched = g_fCert11Touched;
  2634. LeaveCriticalSection( &CNseMountPoint::m_csList );
  2635. if ( fCert11Touched && g_pfnCert11Touched )
  2636. {
  2637. __try
  2638. {
  2639. (g_pfnCert11Touched)();
  2640. }
  2641. __except( EXCEPTION_EXECUTE_HANDLER )
  2642. {
  2643. }
  2644. }
  2645. return TRUE;
  2646. }
  2647. BOOL
  2648. NseMappingInitialize(
  2649. )
  2650. /*++
  2651. Routine Description:
  2652. Initialize access to NSE for mapping
  2653. Arguments:
  2654. None
  2655. Returns:
  2656. TRUE if success, otherwise FALSE
  2657. --*/
  2658. {
  2659. INITIALIZE_CRITICAL_SECTION( &CNseMountPoint::m_csList );
  2660. InitializeListHead( &CNseMountPoint::m_ListHead );
  2661. g_fPathOpened = FALSE;
  2662. return TRUE;
  2663. }
  2664. BOOL
  2665. NseMappingTerminate(
  2666. )
  2667. /*++
  2668. Routine Description:
  2669. Terminate access to NSE for mapping
  2670. Arguments:
  2671. None
  2672. Returns:
  2673. TRUE if success, otherwise FALSE
  2674. --*/
  2675. {
  2676. NseReleaseObjs();
  2677. DeleteCriticalSection( &CNseMountPoint::m_csList );
  2678. return TRUE;
  2679. }