Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

785 lines
24 KiB

  1. #ifndef _ADM_COIMP_
  2. #define _ADM_COIMP_
  3. #include "connect.h"
  4. #include "sink.hxx"
  5. #include "admacl.hxx"
  6. //
  7. // Handle mapping table structure
  8. //
  9. #define HASHSIZE 5
  10. #define INVALID_ADMINHANDLE_VALUE 0xFFFFFFFF
  11. //
  12. // How long to wait getting a handle before saving
  13. // Wait a long time, as we want a safe save
  14. //
  15. #define DEFAULT_SAVE_TIMEOUT 5000
  16. //
  17. // Period to sleep while waiting for service to attain desired state
  18. //
  19. #define SLEEP_INTERVAL (500L)
  20. //
  21. // Maximum time to wait for service to attain desired state
  22. //
  23. #define MAX_SLEEP (180000) // For a service
  24. #define IS_MD_PATH_DELIM(a) ((a)==L'/' || (a)==L'\\')
  25. #define SERVICE_START_MAX_POLL 30
  26. #define SERVICE_START_POLL_DELAY 1000
  27. typedef struct _HANDLE_TABLE
  28. {
  29. struct _HANDLE_TABLE *next; // next entry
  30. METADATA_HANDLE hAdminHandle; // admin handle value
  31. METADATA_HANDLE hActualHandle; // actual handle value
  32. COpenHandle *pohHandle;
  33. } HANDLE_TABLE, *LPHANDLE_TABLE, *PHANDLE_TABLE;
  34. class CADMCOMSrvFactoryW : public IClassFactory
  35. {
  36. public:
  37. CADMCOMSrvFactoryW();
  38. ~CADMCOMSrvFactoryW();
  39. STDMETHODIMP
  40. QueryInterface(
  41. REFIID riid,
  42. void **ppObject);
  43. STDMETHODIMP_(ULONG)
  44. AddRef( VOID );
  45. STDMETHODIMP_(ULONG)
  46. Release( VOID );
  47. STDMETHODIMP
  48. CreateInstance(
  49. IUnknown *pUnkOuter,
  50. REFIID riid,
  51. void **pObject);
  52. STDMETHODIMP
  53. LockServer(
  54. BOOL fLock);
  55. private:
  56. ULONG m_dwRefCount;
  57. };
  58. class CADMCOMW : public IMSAdminBase3W
  59. {
  60. public:
  61. CADMCOMW();
  62. ~CADMCOMW();
  63. STDMETHODIMP
  64. AddKey(
  65. /* [in] */ METADATA_HANDLE hMDHandle,
  66. /* [string][in][unique] */ LPCWSTR pszMDPath);
  67. STDMETHODIMP
  68. DeleteKey(
  69. /* [in] */ METADATA_HANDLE hMDHandle,
  70. /* [string][in][unique] */ LPCWSTR pszMDPath);
  71. STDMETHODIMP
  72. DeleteChildKeys(
  73. /* [in] */ METADATA_HANDLE hMDHandle,
  74. /* [string][in][unique] */ LPCWSTR pszMDPath);
  75. STDMETHODIMP
  76. EnumKeys(
  77. /* [in] */ METADATA_HANDLE hMDHandle,
  78. /* [string][in][unique] */ LPCWSTR pszMDPath,
  79. /* [size_is][out] */ LPWSTR pszMDName,
  80. /* [in] */ DWORD dwMDEnumObjectIndex);
  81. STDMETHODIMP
  82. CopyKey(
  83. /* [in] */ METADATA_HANDLE hMDSourceHandle,
  84. /* [string][in][unique] */ LPCWSTR pszMDSourcePath,
  85. /* [in] */ METADATA_HANDLE hMDDestHandle,
  86. /* [string][in][unique] */ LPCWSTR pszMDDestPath,
  87. /* [in] */ BOOL bMDOverwriteFlag,
  88. /* [in] */ BOOL bMDCopyFlag);
  89. STDMETHODIMP
  90. RenameKey(
  91. /* [in] */ METADATA_HANDLE hMDHandle,
  92. /* [string][in][unique] */ LPCWSTR pszMDPath,
  93. /* [string][in][unique] */ LPCWSTR pszMDNewName);
  94. STDMETHODIMP
  95. SetData(
  96. /* [in] */ METADATA_HANDLE hMDHandle,
  97. /* [string][in][unique] */ LPCWSTR pszMDPath,
  98. /* [in] */ PMETADATA_RECORD pmdrMDData);
  99. STDMETHODIMP
  100. GetData(
  101. /* [in] */ METADATA_HANDLE hMDHandle,
  102. /* [string][in][unique] */ LPCWSTR pszMDPath,
  103. /* [out][in] */ PMETADATA_RECORD pmdrMDData,
  104. /* [out] */ DWORD *pdwMDRequiredDataLen);
  105. STDMETHODIMP
  106. DeleteData(
  107. /* [in] */ METADATA_HANDLE hMDHandle,
  108. /* [string][in][unique] */ LPCWSTR pszMDPath,
  109. /* [in] */ DWORD dwMDIdentifier,
  110. /* [in] */ DWORD dwMDDataType);
  111. STDMETHODIMP
  112. EnumData(
  113. /* [in] */ METADATA_HANDLE hMDHandle,
  114. /* [string][in][unique] */ LPCWSTR pszMDPath,
  115. /* [out][in] */ PMETADATA_RECORD pmdrMDData,
  116. /* [in] */ DWORD dwMDEnumDataIndex,
  117. /* [out] */ DWORD *pdwMDRequiredDataLen);
  118. STDMETHODIMP
  119. GetAllData(
  120. /* [in] */ METADATA_HANDLE hMDHandle,
  121. /* [string][in][unique] */ LPCWSTR pszMDPath,
  122. /* [in] */ DWORD dwMDAttributes,
  123. /* [in] */ DWORD dwMDUserType,
  124. /* [in] */ DWORD dwMDDataType,
  125. /* [out] */ DWORD *pdwMDNumDataEntries,
  126. /* [out] */ DWORD *pdwMDDataSetNumber,
  127. /* [in] */ DWORD dwMDBufferSize,
  128. /* [size_is][out] */ unsigned char *pbMDBuffer,
  129. /* [out] */ DWORD *pdwMDRequiredBufferSize);
  130. STDMETHODIMP
  131. DeleteAllData(
  132. /* [in] */ METADATA_HANDLE hMDHandle,
  133. /* [string][in][unique] */ LPCWSTR pszMDPath,
  134. /* [in] */ DWORD dwMDUserType,
  135. /* [in] */ DWORD dwMDDataType);
  136. STDMETHODIMP
  137. CopyData(
  138. /* [in] */ METADATA_HANDLE hMDSourceHandle,
  139. /* [string][in][unique] */ LPCWSTR pszMDSourcePath,
  140. /* [in] */ METADATA_HANDLE hMDDestHandle,
  141. /* [string][in][unique] */ LPCWSTR pszMDDestPath,
  142. /* [in] */ DWORD dwMDAttributes,
  143. /* [in] */ DWORD dwMDUserType,
  144. /* [in] */ DWORD dwMDDataType,
  145. /* [in] */ BOOL bMDCopyFlag);
  146. STDMETHODIMP
  147. GetDataPaths(
  148. /* [in] */ METADATA_HANDLE hMDHandle,
  149. /* [string][in][unique] */ LPCWSTR pszMDPath,
  150. /* [in] */ DWORD dwMDIdentifier,
  151. /* [in] */ DWORD dwMDDataType,
  152. /* [in] */ DWORD dwMDBufferSize,
  153. /* [size_is][out] */ LPWSTR pszBuffer,
  154. /* [out] */ DWORD *pdwMDRequiredBufferSize);
  155. STDMETHODIMP
  156. OpenKey(
  157. /* [in] */ METADATA_HANDLE hMDHandle,
  158. /* [string][in][unique] */ LPCWSTR pszMDPath,
  159. /* [in] */ DWORD dwMDAccessRequested,
  160. /* [in] */ DWORD dwMDTimeOut,
  161. /* [out] */ PMETADATA_HANDLE phMDNewHandle);
  162. STDMETHODIMP
  163. CloseKey(
  164. /* [in] */ METADATA_HANDLE hMDHandle);
  165. STDMETHODIMP
  166. ChangePermissions(
  167. /* [in] */ METADATA_HANDLE hMDHandle,
  168. /* [in] */ DWORD dwMDTimeOut,
  169. /* [in] */ DWORD dwMDAccessRequested);
  170. STDMETHODIMP
  171. SaveData( VOID );
  172. STDMETHODIMP
  173. GetHandleInfo(
  174. /* [in] */ METADATA_HANDLE hMDHandle,
  175. /* [out] */ PMETADATA_HANDLE_INFO pmdhiInfo);
  176. STDMETHODIMP
  177. GetSystemChangeNumber(
  178. /* [out] */ DWORD *pdwSystemChangeNumber);
  179. STDMETHODIMP
  180. GetDataSetNumber(
  181. /* [in] */ METADATA_HANDLE hMDHandle,
  182. /* [string][in][unique] */ LPCWSTR pszMDPath,
  183. /* [out] */ DWORD *pdwMDDataSetNumber);
  184. STDMETHODIMP
  185. SetLastChangeTime(
  186. /* [in] */ METADATA_HANDLE hMDHandle,
  187. /* [string][in][unique] */ LPCWSTR pszMDPath,
  188. /* [in] */ PFILETIME pftMDLastChangeTime,
  189. /* [in] */ BOOL bLocalTime);
  190. STDMETHODIMP
  191. GetLastChangeTime(
  192. /* [in] */ METADATA_HANDLE hMDHandle,
  193. /* [string][in][unique] */ LPCWSTR pszMDPath,
  194. /* [out] */ PFILETIME pftMDLastChangeTime,
  195. /* [in] */ BOOL bLocalTime);
  196. STDMETHODIMP
  197. NotifySinks(
  198. /* [in] */ METADATA_HANDLE hMDHandle,
  199. /* [in] */ DWORD dwMDNumElements,
  200. /* [size_is][in] */ MD_CHANGE_OBJECT_W pcoChangeList[],
  201. /* [in] */ BOOL bIsMainNotification);
  202. STDMETHODIMP
  203. KeyExchangePhase1( VOID );
  204. STDMETHODIMP
  205. KeyExchangePhase2( VOID );
  206. STDMETHODIMP
  207. Backup(
  208. /* [string][in][unique] */ LPCWSTR pszMDBackupLocation,
  209. /* [in] */ DWORD dwMDVersion,
  210. /* [in] */ DWORD dwMDFlags);
  211. STDMETHODIMP
  212. Restore(
  213. /* [string][in][unique] */ LPCWSTR pszMDBackupLocation,
  214. /* [in] */ DWORD dwMDVersion,
  215. /* [in] */ DWORD dwMDFlags);
  216. STDMETHODIMP
  217. BackupWithPasswd(
  218. /* [string][in][unique] */ LPCWSTR pszMDBackupLocation,
  219. /* [in] */ DWORD dwMDVersion,
  220. /* [in] */ DWORD dwMDFlags,
  221. /* [string][in][unique] */ LPCWSTR pszPasswd);
  222. STDMETHODIMP
  223. RestoreWithPasswd(
  224. /* [string][in][unique] */ LPCWSTR pszMDBackupLocation,
  225. /* [in] */ DWORD dwMDVersion,
  226. /* [in] */ DWORD dwMDFlags,
  227. /* [string][in][unique] */ LPCWSTR pszPasswd);
  228. STDMETHODIMP
  229. EnumBackups(
  230. /* [size_is][out][in] */ LPWSTR pszMDBackupLocation,
  231. /* [out] */ DWORD *pdwMDVersion,
  232. /* [out] */ PFILETIME pftMDBackupTime,
  233. /* [in] */ DWORD dwMDEnumIndex);
  234. STDMETHODIMP
  235. DeleteBackup(
  236. /* [string][in][unique] */ LPCWSTR pszMDBackupLocation,
  237. /* [in] */ DWORD dwMDVersion);
  238. STDMETHODIMP
  239. Export(
  240. /* [string][in][unique] */ LPCWSTR pszPasswd,
  241. /* [string][in][unique] */ LPCWSTR pszFileName,
  242. /* [string][in][unique] */ LPCWSTR pszSourcePath,
  243. /* [in] */ DWORD dwMDFlags);
  244. STDMETHODIMP
  245. Import(
  246. /* [string][in][unique] */ LPCWSTR pszPasswd,
  247. /* [string][in][unique] */ LPCWSTR pszFileName,
  248. /* [string][in][unique] */ LPCWSTR pszSourcePath,
  249. /* [string][in][unique] */ LPCWSTR pszDestPath,
  250. /* [in] */ DWORD dwMDFlags);
  251. STDMETHODIMP
  252. RestoreHistory(
  253. /* [unique][in][string] */ LPCWSTR pszMDHistoryLocation,
  254. /* [in] */ DWORD dwMDMajorVersion,
  255. /* [in] */ DWORD dwMDMinorVersion,
  256. /* [in] */ DWORD dwMDFlags);
  257. STDMETHODIMP
  258. EnumHistory(
  259. /* [size_is][out][in] */ LPWSTR pszMDHistoryLocation,
  260. /* [out] */ DWORD *pdwMDMajorVersion,
  261. /* [out] */ DWORD *pdwMDMinorVersion,
  262. /* [out] */ PFILETIME pftMDHistoryTime,
  263. /* [in] */ DWORD dwMDEnumIndex);
  264. /* IMSAdminBase3W methods */
  265. STDMETHODIMP
  266. GetChildPaths(
  267. /* [in] */ METADATA_HANDLE hMDHandle,
  268. /* [unique, in, string] */ LPCWSTR pszMDPath,
  269. /* [in] */ DWORD dwMDBufferSize,
  270. /* [out, size_is(dwMDBufferSize)] */ WCHAR *pszBuffer,
  271. /* [out] */ DWORD *pdwMDRequiredBufferSize);
  272. STDMETHODIMP
  273. UnmarshalInterface(
  274. /* [out] */ IMSAdminBaseW **piadmbwInterface);
  275. STDMETHODIMP
  276. GetServerGuid( VOID );
  277. STDMETHODIMP
  278. QueryInterface(
  279. REFIID riid,
  280. void **ppObject);
  281. STDMETHODIMP_(ULONG)
  282. AddRef( VOID );
  283. STDMETHODIMP_(ULONG)
  284. Release( VOID );
  285. //
  286. // Internal Use members
  287. //
  288. HRESULT
  289. AddNode(
  290. METADATA_HANDLE hActualHandle,
  291. COpenHandle *pohParentHandle,
  292. PMETADATA_HANDLE phAdminHandle,
  293. LPCWSTR pszPath);
  294. HRESULT
  295. AddKeyHelper(
  296. /* [in] */ METADATA_HANDLE hMDHandle,
  297. /* [string][in][unique] */ LPCWSTR pszMDPath);
  298. HRESULT
  299. OpenKeyHelper(
  300. /* [in] */ METADATA_HANDLE hMDHandle,
  301. /* [string][in][unique] */ LPCWSTR pszMDPath,
  302. /* [in] */ DWORD dwMDAccessRequested,
  303. /* [in] */ DWORD dwMDTimeOut,
  304. /* [out] */ PMETADATA_HANDLE phMDNewHandle);
  305. DWORD
  306. Lookup(
  307. IN METADATA_HANDLE hHandle,
  308. OUT METADATA_HANDLE *phActHandle,
  309. OUT COpenHandle **pphoHandle = NULL);
  310. HRESULT
  311. LookupAndAccessCheck(
  312. IN METADATA_HANDLE hHandle,
  313. OUT METADATA_HANDLE *phActualHandle,
  314. IN LPCWSTR pszPath,
  315. IN DWORD dwId, // check for MD_ADMIN_ACL, must have special right to write them
  316. IN DWORD dwAccess, // METADATA_PERMISSION_*
  317. OUT LPBOOL pfEnableSecureAccess = NULL);
  318. VOID
  319. DisableAllHandles( VOID );
  320. DWORD
  321. IsReadAccessGranted(
  322. METADATA_HANDLE hHandle,
  323. LPWSTR pszPath,
  324. METADATA_RECORD* pmdRecord);
  325. DWORD
  326. FindClosestProp(
  327. METADATA_HANDLE hHandle,
  328. LPWSTR pszRelPathIndex,
  329. LPWSTR* ppszAclPath,
  330. DWORD dwPropId,
  331. DWORD dwDataType,
  332. DWORD dwUserType,
  333. DWORD dwAttr,
  334. BOOL fSkipCurrentNode);
  335. DWORD
  336. LookupActualHandle(
  337. IN METADATA_HANDLE hHandle);
  338. DWORD
  339. DeleteNode(
  340. IN METADATA_HANDLE hHandle);
  341. VOID
  342. SetStatus(
  343. HRESULT hRes)
  344. {
  345. m_hRes = hRes;
  346. }
  347. HRESULT
  348. GetStatus( VOID )
  349. {
  350. return m_hRes;
  351. }
  352. static
  353. VOID
  354. ShutDownObjects( VOID );
  355. static
  356. VOID
  357. InitObjectList( VOID );
  358. static
  359. VOID
  360. TerminateObjectList( VOID );
  361. private:
  362. IUnknown *m_piuFTM;
  363. IMDCOM2* m_pMdObject;
  364. IMDCOM3* m_pMdObject3;
  365. volatile ULONG m_dwRefCount;
  366. DWORD m_dwHandleValue; // last handle value used
  367. HANDLE_TABLE *m_hashtab[HASHSIZE]; // handle table
  368. CImpIMDCOMSINKW *m_pEventSink;
  369. IConnectionPoint *m_pConnPoint;
  370. DWORD m_dwCookie;
  371. BOOL m_bTerminated;
  372. BOOL m_bIsTerminateRoutineComplete;
  373. HRESULT m_hRes;
  374. //
  375. // Keep a global list of these objects around to allow us to
  376. // cleanup during shutdown.
  377. //
  378. VOID
  379. AddObjectToList( VOID );
  380. BOOL
  381. RemoveObjectFromList(
  382. BOOL bIgnoreShutdown = FALSE);
  383. static
  384. VOID
  385. GetObjectListLock( VOID )
  386. {
  387. EnterCriticalSection( &sm_csObjectListLock );
  388. }
  389. static
  390. VOID
  391. ReleaseObjectListLock( VOID )
  392. {
  393. LeaveCriticalSection( &sm_csObjectListLock );
  394. }
  395. LIST_ENTRY m_ObjectListEntry;
  396. static LIST_ENTRY sm_ObjectList;
  397. static CRITICAL_SECTION sm_csObjectListLock;
  398. static BOOL sm_fShutdownInProgress;
  399. static DWORD sm_dwProcessIdThis;
  400. static DWORD sm_dwProcessIdRpcSs;
  401. DWORD m_dwProcessIdCaller;
  402. HANDLE m_hProcessCaller;
  403. HANDLE m_hWaitCaller;
  404. DWORD m_dwThreadIdDisconnect;
  405. static PTRACE_LOG sm_pDbgRefTraceLog;
  406. public:
  407. HRESULT
  408. RemoveAllPendingNotifications(
  409. BOOL fWaitForCurrent);
  410. private:
  411. HRESULT
  412. StopNotifications(
  413. BOOL fRemoveAllPending);
  414. VOID
  415. Terminate( VOID );
  416. VOID
  417. ForceTerminate( VOID );
  418. HRESULT
  419. InitializeCallerWatch(VOID);
  420. HRESULT
  421. ShutdownCallerWatch(VOID);
  422. BOOL
  423. IsCallerWatchInitialized( VOID )
  424. {
  425. return ( m_dwProcessIdCaller != 0 );
  426. }
  427. HRESULT
  428. DisconnectOrphaned(VOID);
  429. static
  430. VOID
  431. CALLBACK
  432. CallerWatchWaitOrTimerCallback(
  433. PVOID lpParameter, // thread data
  434. BOOLEAN TimerOrWaitFired); // reason
  435. public:
  436. static
  437. HRESULT
  438. GetPids(VOID);
  439. private:
  440. // ImpExp
  441. class CImpExpHelp : public IMSImpExpHelpW
  442. {
  443. public:
  444. CImpExpHelp();
  445. virtual ~CImpExpHelp();
  446. VOID Init(CADMCOMW *);
  447. // IUnknown methods.
  448. STDMETHODIMP
  449. QueryInterface(
  450. REFIID ,
  451. PPVOID );
  452. STDMETHODIMP_(ULONG)
  453. AddRef( VOID );
  454. STDMETHODIMP_(ULONG)
  455. Release( VOID );
  456. STDMETHODIMP
  457. EnumeratePathsInFile(
  458. /* [unique, in, string] */ LPCWSTR pszFileName,
  459. /* [unique, in, string] */ LPCWSTR pszKeyType,
  460. /* [in] */ DWORD dwMDBufferSize,
  461. /* [out, size_is(dwMDBufferSize)] */ WCHAR *pszBuffer,
  462. /* [out] */ DWORD *pdwMDRequiredBufferSize);
  463. private:
  464. IUnknown *m_pUnkOuter; // Outer unknown for Delegation.
  465. };
  466. friend CImpExpHelp;
  467. CImpExpHelp m_ImpExpHelp;
  468. //
  469. // synchronization to manipulate the handle table
  470. //
  471. CReaderWriterLock3 m_LockHandleResource;
  472. class CImpIConnectionPointContainer : public IConnectionPointContainer
  473. {
  474. public:
  475. // Interface Implementation Constructor & Destructor.
  476. CImpIConnectionPointContainer();
  477. virtual ~CImpIConnectionPointContainer();
  478. VOID
  479. Init(
  480. CADMCOMW *);
  481. // IUnknown methods.
  482. STDMETHODIMP
  483. QueryInterface(
  484. REFIID ,
  485. PPVOID );
  486. STDMETHODIMP_(ULONG)
  487. AddRef( VOID );
  488. STDMETHODIMP_(ULONG)
  489. Release( VOID );
  490. // IConnectionPointContainer methods.
  491. STDMETHODIMP
  492. FindConnectionPoint(
  493. REFIID ,
  494. IConnectionPoint** );
  495. STDMETHODIMP
  496. EnumConnectionPoints(
  497. IEnumConnectionPoints **);
  498. private:
  499. // Data private to this interface implementation.
  500. CADMCOMW *m_pBackObj; // Parent Object back pointer.
  501. IUnknown *m_pUnkOuter; // Outer unknown for Delegation.
  502. };
  503. friend CImpIConnectionPointContainer;
  504. // Nested IConnectionPointContainer implementation instantiation.
  505. CImpIConnectionPointContainer m_ImpIConnectionPointContainer;
  506. // The array of connection points for this connectable COM object.
  507. COConnectionPoint m_ConnectionPoint;
  508. BOOL
  509. CheckGetAttributes(
  510. DWORD dwAttributes);
  511. HRESULT
  512. BackupHelper(
  513. LPCWSTR pszMDBackupLocation,
  514. DWORD dwMDVersion,
  515. DWORD dwMDFlags,
  516. LPCWSTR pszPasswd = NULL);
  517. HRESULT
  518. RestoreHelper(
  519. LPCWSTR pszMDBackupLocation,
  520. DWORD dwMDVersion,
  521. DWORD dwMDMinorVersion,
  522. LPCWSTR pszPasswd,
  523. DWORD dwMDFlags,
  524. DWORD dwRestoreType);
  525. HRESULT
  526. EnumAndStopDependentServices(
  527. DWORD *pcServices,
  528. BUFFER *pbufDependentServices);
  529. HRESULT
  530. StartDependentServices(
  531. DWORD cServices,
  532. ENUM_SERVICE_STATUS *pessDependentServices);
  533. HRESULT
  534. SetHistoryAndEWR(
  535. DWORD dwEnableHistory,
  536. DWORD dwEnableEWR);
  537. HRESULT
  538. DisableHistory(
  539. DWORD *pdwEnableHistoryOld,
  540. DWORD *pdwEnableEWROld);
  541. HRESULT
  542. NotifySinkHelper(
  543. IUnknown *pUnk,
  544. DWORD dwMDNumElements,
  545. MD_CHANGE_OBJECT_W pcoChangeList[],
  546. BOOL bIsMainNotification);
  547. public:
  548. HRESULT
  549. NotifySinksAsync(
  550. /* [in] */ DWORD dwMDNumElements,
  551. /* [size_is][in] */ MD_CHANGE_OBJECT_W pcoChangeList[],
  552. /* [in] */ BOOL bIsMainNotification);
  553. };
  554. VOID
  555. WaitForServiceStatus(
  556. SC_HANDLE schDependent,
  557. DWORD dwDesiredServiceState);
  558. const DWORD NOTIFY_CONTEXT_SIGNATURE = ((DWORD) 'XTCN');
  559. const DWORD NOTIFY_CONTEXT_SIGNATURE_FREE = ((DWORD) 'xTCN');
  560. class NOTIFY_CONTEXT
  561. {
  562. private:
  563. DWORD _dwSignature;
  564. CADMCOMW *_pCADMCOMW;
  565. DWORD _dwMDNumElements;
  566. MD_CHANGE_OBJECT_W *_pcoChangeList;
  567. BOOL _bIsMainNotification;
  568. LIST_ENTRY _listEntry;
  569. public:
  570. static
  571. HRESULT
  572. CreateNewContext(
  573. CADMCOMW *pCADMCOMW,
  574. METADATA_HANDLE hMDHandle,
  575. DWORD dwMDNumElements,
  576. MD_CHANGE_OBJECT_W *pcoChangeList,
  577. BOOL bIsMainNotification);
  578. static
  579. VOID
  580. RemoveWorkFor(
  581. CADMCOMW *pCADMCOMW,
  582. BOOL fWaitForCurrent);
  583. static
  584. VOID
  585. RemoveAllWork( VOID );
  586. static
  587. HRESULT
  588. Initialize( VOID );
  589. static
  590. VOID
  591. Terminate( VOID );
  592. private:
  593. NOTIFY_CONTEXT();
  594. ~NOTIFY_CONTEXT();
  595. BOOL
  596. CheckSignature( VOID )
  597. {
  598. return NOTIFY_CONTEXT_SIGNATURE == _dwSignature;
  599. }
  600. static
  601. NOTIFY_CONTEXT *
  602. NOTIFY_CONTEXTFromListEntry(
  603. PLIST_ENTRY ple)
  604. {
  605. NOTIFY_CONTEXT *pContext = CONTAINING_RECORD(ple, NOTIFY_CONTEXT, _listEntry);
  606. DBG_ASSERT(pContext->CheckSignature());
  607. return pContext;
  608. }
  609. static NOTIFY_CONTEXT * s_pCurrentlyWorkingOn;
  610. static CReaderWriterLock3 s_LockCurrentlyWorkingOn;
  611. static LIST_ENTRY s_listEntry;
  612. static CRITICAL_SECTION s_critSec;
  613. static BOOL s_fInitializedCritSec;
  614. static HANDLE s_hShutdown;
  615. static HANDLE s_hDataAvailable;
  616. static HANDLE s_hThread;
  617. static DWORD s_dwThreadId;
  618. static DWORD WINAPI NotifyThreadProc( LPVOID lpParameter );
  619. static HRESULT GetNextContext(NOTIFY_CONTEXT ** ppContext);
  620. };
  621. HRESULT
  622. MakePathCanonicalizationProof(
  623. IN LPCWSTR pwszName,
  624. IN BOOL fResolve,
  625. OUT STRAU *pstrPath);
  626. #endif