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.

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