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.

140 lines
2.8 KiB

  1. #include "msrating.h"
  2. /* the following defs will make msluglob.h actually define globals */
  3. #define EXTERN
  4. #define ASSIGN(value) = value
  5. #include "msluglob.h"
  6. #include "ratings.h"
  7. #define DECL_CRTFREE
  8. #include <crtfree.h>
  9. #include <npassert.h>
  10. HANDLE g_hmtxShell = 0; // for critical sections
  11. HANDLE g_hsemStateCounter = 0; //
  12. #ifdef DEBUG
  13. BOOL g_fCritical=FALSE;
  14. #endif
  15. HINSTANCE g_hInstance = NULL;
  16. long g_cRefThisDll = 0; // Reference count of this DLL.
  17. long g_cLocks = 0; // Number of locks on this server.
  18. BOOL g_bMirroredOS = FALSE;
  19. CComModule _Module;
  20. // #define CLSID_MSRating szRORSGUID
  21. // BEGIN_OBJECT_MAP(ObjectMap)
  22. // OBJECT_ENTRY(CLSID_MSRating, CMSRating)
  23. // END_OBJECT_MAP()
  24. void LockThisDLL(BOOL fLock)
  25. {
  26. if (fLock)
  27. {
  28. InterlockedIncrement(&g_cLocks);
  29. }
  30. else
  31. {
  32. ASSERT( 0 != g_cLocks );
  33. InterlockedDecrement(&g_cLocks);
  34. }
  35. }
  36. void RefThisDLL(BOOL fRef)
  37. {
  38. if (fRef)
  39. {
  40. InterlockedIncrement(&g_cRefThisDll);
  41. }
  42. else
  43. {
  44. ASSERT( 0 != g_cLocks );
  45. InterlockedDecrement(&g_cRefThisDll);
  46. }
  47. }
  48. void Netlib_EnterCriticalSection(void)
  49. {
  50. WaitForSingleObject(g_hmtxShell, INFINITE);
  51. #ifdef DEBUG
  52. g_fCritical=TRUE;
  53. #endif
  54. }
  55. void Netlib_LeaveCriticalSection(void)
  56. {
  57. #ifdef DEBUG
  58. g_fCritical=FALSE;
  59. #endif
  60. ReleaseMutex(g_hmtxShell);
  61. }
  62. #include <shlwapip.h>
  63. #include <mluisupp.h>
  64. void _ProcessAttach()
  65. {
  66. ::DisableThreadLibraryCalls(::g_hInstance);
  67. MLLoadResources(::g_hInstance, TEXT("msratelc.dll"));
  68. InitMUILanguage( MLGetUILanguage() );
  69. // Override the Module Resources Handle.
  70. _Module.m_hInstResource = MLGetHinst();
  71. g_hmtxShell = CreateMutex(NULL, FALSE, TEXT("MSRatingMutex")); // per-instance
  72. g_hsemStateCounter = CreateSemaphore(NULL, 0, 0x7FFFFFFF, "MSRatingCounter");
  73. g_bMirroredOS = IS_MIRRORING_ENABLED();
  74. ::InitStringLibrary();
  75. RatingInit();
  76. }
  77. void _ProcessDetach()
  78. {
  79. MLFreeResources(::g_hInstance);
  80. // Clear the Module Resources Handle.
  81. _Module.m_hInstResource = NULL;
  82. RatingTerm();
  83. CleanupWinINet();
  84. CleanupRatingHelpers(); /* important, must do this before CleanupOLE() */
  85. CleanupOLE();
  86. CloseHandle(g_hmtxShell);
  87. CloseHandle(g_hsemStateCounter);
  88. }
  89. STDAPI_(BOOL) DllMain(HINSTANCE hInstDll, DWORD fdwReason, LPVOID reserved)
  90. {
  91. if (fdwReason == DLL_PROCESS_ATTACH)
  92. {
  93. _Module.Init( NULL, hInstDll );
  94. SHFusionInitializeFromModule(hInstDll);
  95. g_hInstance = hInstDll;
  96. _ProcessAttach();
  97. }
  98. else if (fdwReason == DLL_PROCESS_DETACH)
  99. {
  100. _ProcessDetach();
  101. SHFusionUninitialize();
  102. _Module.Term();
  103. }
  104. return TRUE;
  105. }