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.

179 lines
6.2 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // File: globals.cpp
  4. //
  5. // Contents: Global variables.
  6. //
  7. //----------------------------------------------------------------------------
  8. #include "private.h"
  9. #include "globals.h"
  10. HINSTANCE g_hInst = NULL;
  11. // used by COM server
  12. HINSTANCE GetServerHINSTANCE(void)
  13. {
  14. return g_hInst;
  15. }
  16. DWORD g_dwTLSIndex = TLS_OUT_OF_INDEXES;
  17. DECLARE_OSVER()
  18. CCiceroSharedMem g_SharedMemory;
  19. HKL g_hklDefault;
  20. // registered messages
  21. UINT g_msgPrivate;
  22. //
  23. // private message for SetFocusNotifySink
  24. //
  25. UINT g_msgSetFocus;
  26. UINT g_msgThreadTerminate;
  27. UINT g_msgThreadItemChange;
  28. //
  29. // private message for Modal LangBar
  30. //
  31. UINT g_msgLBarModal;
  32. UINT g_msgRpcSendReceive;
  33. UINT g_msgThreadMarshal;
  34. UINT g_msgCheckThreadInputIdel;
  35. #ifdef POINTER_MARSHAL
  36. UINT g_msgPointerMarshal;
  37. #endif
  38. UINT g_msgStubCleanUp;
  39. UINT g_msgShowFloating;
  40. UINT g_msgLBUpdate;
  41. UINT g_msgNuiMgrDirtyUpdate;
  42. //
  43. // g_csInDllMain.
  44. //
  45. // We should try not to use Thread Synchronizaion. However we got some
  46. // race condition in stress testing so we need it.
  47. // g_csInDllMain just protect the section that could be touched from
  48. // DllMain so that we need to be very careful for the critical section.
  49. // We can not call some Kernel API (LoadLibrary, CreateProcess and so on)
  50. // there.
  51. //
  52. CCicCriticalSectionStatic g_csInDllMain;
  53. CCicCriticalSectionStatic g_cs;
  54. // for combase
  55. CRITICAL_SECTION *GetServerCritSec(void)
  56. {
  57. return g_cs;
  58. }
  59. #ifdef DEBUG
  60. // for tracking last owner of g_cs
  61. const TCHAR *g_szMutexEnterFile = NULL;
  62. int g_iMutexEnterLine = -1;
  63. #endif // DEBUG
  64. TfGuidAtom g_gaApp;
  65. TfGuidAtom g_gaSystem;
  66. BOOL g_fCTFMONProcess = FALSE;
  67. BOOL g_fCUAS = FALSE;
  68. TCHAR g_szCUASImeFile[16];
  69. //
  70. // application compatibility flag
  71. //
  72. DWORD g_dwAppCompatibility = 0;
  73. /* 626761ad-78d2-44d2-be8b-752cf122acec */
  74. const GUID GUID_APPLICATION = { 0x626761ad, 0x78d2, 0x44d2, {0xbe, 0x8b, 0x75, 0x2c, 0xf1, 0x22, 0xac, 0xec} };
  75. /* 78cb5b0e-26ed-4fcc-854c-77e8f3d1aa80 */
  76. const GUID GUID_SYSTEM = { 0x78cb5b0e, 0x26ed, 0x4fcc, {0x85, 0x4c, 0x77, 0xe8, 0xf3, 0xd1, 0xaa, 0x80} };
  77. const TCHAR c_szCTFKey[] = TEXT("SOFTWARE\\Microsoft\\CTF\\");
  78. const TCHAR c_szTIPKey[] = TEXT("TIP");
  79. const TCHAR c_szCTFTIPKey[] = TEXT("SOFTWARE\\Microsoft\\CTF\\TIP\\");
  80. const TCHAR c_szLangBarKey[] = TEXT("SOFTWARE\\Microsoft\\CTF\\LangBar\\");
  81. const WCHAR c_szDescriptionW[] = L"Description";
  82. const WCHAR c_szMUIDescriptionW[] = L"Display Description";
  83. const WCHAR c_szEnableW[] = L"Enable";
  84. const TCHAR c_szEnable[] = TEXT("Enable");
  85. const TCHAR c_szDisabledOnTransitory[] = TEXT("DisabledOnTransitory");
  86. const TCHAR c_szAsmKey[] = TEXT("SOFTWARE\\Microsoft\\CTF\\Assemblies");
  87. const TCHAR c_szCompartKey[] = TEXT("SOFTWARE\\Microsoft\\CTF\\Compartment");
  88. const TCHAR c_szGlobalCompartment[] = TEXT("GlobalCompartment");
  89. const TCHAR c_szNonInit[] = TEXT("NonInit");
  90. const TCHAR c_szDefault[] = TEXT("Default");
  91. const TCHAR c_szProfile[] = TEXT("Profile");
  92. const WCHAR c_szProfileW[] = L"Profile";
  93. const TCHAR c_szDefaultAsmName[] = TEXT("Default Assembly");
  94. const TCHAR c_szUpdateProfile[] = TEXT("UpdateProfile");
  95. const TCHAR c_szAssembly[] = TEXT("Assemblies");
  96. const TCHAR c_szLanguageProfileKey[] = TEXT("LanguageProfile\\");
  97. const TCHAR c_szSubstitutehKL[] = TEXT("SubstituteLayout");
  98. const TCHAR c_szKeyboardLayout[] = TEXT("KeyboardLayout");
  99. const WCHAR c_szIconFileW[] = L"IconFile";
  100. const TCHAR c_szIconIndex[] = TEXT("IconIndex");
  101. const WCHAR c_szIconIndexW[] = L"IconIndex";
  102. const TCHAR c_szShowStatus[] = TEXT("ShowStatus");
  103. const TCHAR c_szLabel[] = TEXT("Label");
  104. const TCHAR c_szTransparency[] = TEXT("Transparency");
  105. const TCHAR c_szExtraIconsOnMinimized[] = TEXT("ExtraIconsOnMinimized");
  106. const TCHAR c_szLocaleInfo[] = TEXT("SYSTEM\\CurrentControlSet\\Control\\Nls\\Locale");
  107. const TCHAR c_szLocaleInfoNT4[] = TEXT("SYSTEM\\CurrentControlSet\\Control\\Nls\\Language");
  108. const TCHAR c_szKeyboardLayoutKey[] = TEXT("SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\");
  109. const TCHAR c_szKbdUSNameNT[] = TEXT("kbdus.dll");
  110. const TCHAR c_szKbdUSName[] = TEXT("kbdus.kbd");
  111. const TCHAR c_szLayoutFile[] = TEXT("layout file");
  112. const TCHAR c_szIMEFile[] = TEXT("IME file");
  113. const TCHAR c_szRunInputCPLCmdLine[] = TEXT("RunDll32.exe shell32.dll,Control_RunDLL %s");
  114. const TCHAR c_szRunInputCPL[] = TEXT("input.cpl");
  115. const TCHAR c_szRunInputCPLOnWin9x[] = TEXT("input98.cpl");
  116. const TCHAR c_szRunInputCPLOnNT51[] = TEXT("input.dll");
  117. const TCHAR c_szHHEXELANGBARCHM[] = TEXT("hh.exe langbar.chm");
  118. const TCHAR c_szHHEXE[] = TEXT("hh.exe");
  119. // marshal window class
  120. const TCHAR c_szCicMarshalClass[] = "CicMarshalWndClass";
  121. const TCHAR c_szCicMarshalWnd[] = "CicMarshalWnd";
  122. const TCHAR c_szAppCompat[] = TEXT("SOFTWARE\\Microsoft\\CTF\\Compatibility\\");
  123. const TCHAR c_szCompatibility[] = TEXT("Compatibility");
  124. const TCHAR c_szCtfShared[] = TEXT("SOFTWARE\\Microsoft\\CTF\\SystemShared\\");
  125. const TCHAR c_szCUAS[] = TEXT("CUAS");
  126. const TCHAR c_szIMMKey[] = TEXT("Software\\Microsoft\\Windows NT\\CurrentVersion\\IMM");
  127. const TCHAR c_szCUASIMEFile[] = TEXT("IME File");
  128. //+---------------------------------------------------------------------------
  129. //
  130. // CheckAnchorStores
  131. //
  132. //----------------------------------------------------------------------------
  133. // if set TRUE, we don't ask for ITextStoreAnchor during context creation
  134. BOOL g_fNoITextStoreAnchor = TRUE;
  135. void CheckAnchorStores()
  136. {
  137. HKEY hKeyCTF;
  138. DWORD cb;
  139. DWORD dwEnable;
  140. if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, c_szCTFKey, NULL, KEY_READ, &hKeyCTF) != ERROR_SUCCESS)
  141. return;
  142. cb = sizeof(DWORD);
  143. if (RegQueryValueEx(hKeyCTF, TEXT("EnableAnchorContext"), NULL, NULL, (BYTE *)&dwEnable, &cb) == ERROR_SUCCESS &&
  144. cb == sizeof(DWORD) &&
  145. dwEnable == 1)
  146. {
  147. g_fNoITextStoreAnchor = FALSE;
  148. }
  149. RegCloseKey(hKeyCTF);
  150. }