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.

156 lines
3.2 KiB

  1. /*++
  2. Copyright (c) 2001, Microsoft Corporation
  3. Module Name:
  4. globals.cpp
  5. Abstract:
  6. This file implements the global data.
  7. Author:
  8. Revision History:
  9. Notes:
  10. --*/
  11. #include "private.h"
  12. #include "globals.h"
  13. #include "list.h"
  14. #include "tls.h"
  15. CCicCriticalSectionStatic g_cs;
  16. // for combase
  17. CRITICAL_SECTION *GetServerCritSec(void)
  18. {
  19. return g_cs;
  20. }
  21. HINSTANCE g_hInst;
  22. // used by COM server
  23. HINSTANCE GetServerHINSTANCE(void)
  24. {
  25. return g_hInst;
  26. }
  27. #ifdef DEBUG
  28. DWORD g_dwThreadDllMain = 0;
  29. #endif
  30. DWORD TLS::dwTLSIndex = 0;
  31. #if !defined(OLD_AIMM_ENABLED)
  32. //+---------------------------------------------------------------------------
  33. //
  34. // RunningInExcludedModule
  35. //
  36. // Exclude some processes from using the old aimm IIDs/CLSIDs.
  37. //----------------------------------------------------------------------------
  38. BOOL RunningInExcludedModule()
  39. {
  40. DWORD dwHandle;
  41. void *pvData;
  42. VS_FIXEDFILEINFO *pffi;
  43. UINT cb;
  44. TCHAR ch;
  45. TCHAR *pch;
  46. TCHAR *pchFileName;
  47. BOOL fRet;
  48. TCHAR achModule[MAX_PATH + 1];
  49. if (GetModuleFileName(NULL, achModule, ARRAY_SIZE(achModule) - 1) == 0)
  50. return FALSE;
  51. achModule[ARRAYSIZE(achModule) - 1] = TEXT('\0');
  52. pch = pchFileName = achModule;
  53. while ((ch = *pch) != 0)
  54. {
  55. pch = CharNext(pch);
  56. if (ch == TEXT('\\'))
  57. {
  58. pchFileName = pch;
  59. }
  60. }
  61. fRet = FALSE;
  62. if (lstrcmpi(pchFileName, TEXT("outlook.exe")) == 0)
  63. {
  64. static BOOL s_fCached = FALSE;
  65. static BOOL s_fOldVersion = TRUE;
  66. // don't run aimm with versions of outlook before 10.0
  67. if (s_fCached)
  68. {
  69. return s_fOldVersion;
  70. }
  71. cb = GetFileVersionInfoSize(achModule, &dwHandle);
  72. if (cb == 0)
  73. {
  74. // can't get ver info...assume the worst
  75. return TRUE;
  76. }
  77. if ((pvData = cicMemAlloc(cb)) == NULL)
  78. return TRUE; // assume the worst
  79. if (GetFileVersionInfo(achModule, 0, cb, pvData) &&
  80. VerQueryValue(pvData, TEXT("\\"), (void **)&pffi, &cb))
  81. {
  82. fRet = s_fOldVersion = (HIWORD(pffi->dwProductVersionMS) < 10);
  83. s_fCached = TRUE; // set this last to be thread safe
  84. }
  85. else
  86. {
  87. fRet = TRUE; // something went wrong
  88. }
  89. cicMemFree(pvData);
  90. }
  91. return fRet;
  92. }
  93. #endif // OLD_AIMM_ENABLED
  94. //+---------------------------------------------------------------------------
  95. //
  96. // GetCompartment
  97. //
  98. //----------------------------------------------------------------------------
  99. HRESULT GetCompartment(IUnknown *punk, REFGUID rguidComp, ITfCompartment **ppComp)
  100. {
  101. HRESULT hr = E_FAIL;
  102. ITfCompartmentMgr *pCompMgr = NULL;
  103. if (FAILED(hr = punk->QueryInterface(IID_ITfCompartmentMgr,
  104. (void **)&pCompMgr)))
  105. goto Exit;
  106. if (SUCCEEDED(hr) && pCompMgr)
  107. {
  108. hr = pCompMgr->GetCompartment(rguidComp, ppComp);
  109. pCompMgr->Release();
  110. }
  111. else
  112. hr = E_FAIL;
  113. Exit:
  114. return hr;
  115. }