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.

172 lines
4.1 KiB

  1. /**********************************************************************/
  2. /** Microsoft Passport **/
  3. /** Copyright(c) Microsoft Corporation, 1999 - 2001 **/
  4. /**********************************************************************/
  5. /*
  6. nexus.cpp
  7. implement exported functions from this dll
  8. FILE HISTORY:
  9. */
  10. #include "precomp.h"
  11. PpNotificationThread g_NotificationThread;
  12. LONG g_bStarted;
  13. //===========================================================================
  14. //
  15. // DllMain
  16. // -- dll entry function
  17. // -- manage creation/deletion of alert object or event log object
  18. //
  19. BOOL WINAPI DllMain(
  20. HINSTANCE hinstDLL, // handle to DLL module
  21. DWORD fdwReason, // reason for calling function
  22. LPVOID lpvReserved // reserved
  23. )
  24. {
  25. switch(fdwReason)
  26. {
  27. case DLL_PROCESS_ATTACH:
  28. g_bStarted = FALSE;
  29. DisableThreadLibraryCalls(hinstDLL);
  30. if(!g_pAlert)
  31. {
  32. g_pAlert = CreatePassportAlertObject(PassportAlertInterface::EVENT_TYPE);
  33. if(g_pAlert)
  34. {
  35. g_pAlert->initLog(PM_ALERTS_REGISTRY_KEY, EVCAT_NEXUS, NULL, 1);
  36. }
  37. else
  38. _ASSERT(g_pAlert);
  39. }
  40. break;
  41. case DLL_PROCESS_DETACH:
  42. if (g_pAlert)
  43. {
  44. g_pAlert->closeLog();
  45. delete g_pAlert;
  46. }
  47. if(g_bStarted)
  48. {
  49. // DARRENAN 4092
  50. // Remove lines that wait for thread to stop, a
  51. // guaranteed deadlock.
  52. g_NotificationThread.stop();
  53. }
  54. break;
  55. default:
  56. break;
  57. }
  58. return TRUE;
  59. }
  60. //===========================================================================
  61. //
  62. // RegisterCCDUpdateNotification
  63. // -- set CCD e.g. partner.xml changing notification sink
  64. //
  65. HANDLE WINAPI
  66. RegisterCCDUpdateNotification(
  67. LPCTSTR pszCCDName,
  68. ICCDUpdate* piCCDUpdate
  69. )
  70. {
  71. HANDLE hClientHandle;
  72. HRESULT hr;
  73. hr = g_NotificationThread.AddCCDClient(tstring(pszCCDName), piCCDUpdate, &hClientHandle);
  74. if(hr != S_OK)
  75. {
  76. hClientHandle = NULL;
  77. }
  78. if(!InterlockedExchange(&g_bStarted, TRUE))
  79. g_NotificationThread.start();
  80. return hClientHandle;
  81. }
  82. //===========================================================================
  83. //
  84. // UnregisterCCDUpdateNotification
  85. // -- remove CCD e.g. partner.xml changing notification sink
  86. //
  87. //
  88. BOOL WINAPI
  89. UnregisterCCDUpdateNotification(
  90. HANDLE hNotificationHandle
  91. )
  92. {
  93. return (g_NotificationThread.RemoveClient(hNotificationHandle) == S_OK);
  94. }
  95. //===========================================================================
  96. //
  97. // RegisterConfigChangeNotification
  98. // -- set registry setting change sink
  99. //
  100. HANDLE WINAPI
  101. RegisterConfigChangeNotification(
  102. IConfigurationUpdate* piConfigUpdate
  103. )
  104. {
  105. HANDLE hClientHandle;
  106. HRESULT hr;
  107. hr = g_NotificationThread.AddLocalConfigClient(piConfigUpdate, &hClientHandle);
  108. if(hr != S_OK)
  109. {
  110. hClientHandle = NULL;
  111. }
  112. if(!InterlockedExchange(&g_bStarted, TRUE))
  113. g_NotificationThread.start();
  114. return hClientHandle;
  115. }
  116. //===========================================================================
  117. //
  118. // UnregisterConfigChangeNotification
  119. // -- remove registry setting change sink
  120. //
  121. BOOL WINAPI
  122. UnregisterConfigChangeNotification(
  123. HANDLE hNotificationHandle
  124. )
  125. {
  126. return (g_NotificationThread.RemoveClient(hNotificationHandle) == S_OK);
  127. }
  128. //===========================================================================
  129. //
  130. // GetCCD
  131. // -- get CCD, returns IXMLDocument object
  132. // -- bForchFetch : if to fetch from Nexus server or to use local
  133. //
  134. BOOL WINAPI
  135. GetCCD(
  136. LPCTSTR pszCCDName,
  137. IXMLDocument** ppiXMLDocument,
  138. BOOL bForceFetch
  139. )
  140. {
  141. return (g_NotificationThread.GetCCD(tstring(pszCCDName), ppiXMLDocument, bForceFetch) == S_OK);
  142. }