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.

696 lines
19 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // File: globals.h
  4. //
  5. // Contents: Global variable declarations.
  6. //
  7. //----------------------------------------------------------------------------
  8. #ifndef GLOBALS_H
  9. #define GLOBALS_H
  10. #include "private.h"
  11. #include "resource.h"
  12. #include "ptrary.h"
  13. #include "strary.h"
  14. #include "cicmutex.h"
  15. #include "tfpriv.h"
  16. #include "ctflbui.h"
  17. #include "csecattr.h"
  18. void CheckAnchorStores();
  19. extern BOOL g_fNoITextStoreAnchor;
  20. inline size_t Align(size_t a)
  21. {
  22. //
  23. // Alignment width should be 8 BYTES for IA64 wow64 platform
  24. // even x86 build enviroment.
  25. //
  26. return (size_t) ((a + 7) & ~7);
  27. }
  28. #ifndef StringCopyArray
  29. #define StringCopyArray(Dstr, Sstr) StringCchCopy((Dstr), ARRAYSIZE(Dstr), (Sstr))
  30. #endif
  31. #ifndef StringCopyArrayA
  32. #define StringCopyArrayA(Dstr, Sstr) StringCchCopyA((Dstr), ARRAYSIZE(Dstr), (Sstr))
  33. #endif
  34. #ifndef StringCopyArrayW
  35. #define StringCopyArrayW(Dstr, Sstr) StringCchCopyW((Dstr), ARRAYSIZE(Dstr), (Sstr))
  36. #endif
  37. #ifndef StringCatArray
  38. #define StringCatArray(Dstr, Sstr) StringCchCat((Dstr), ARRAYSIZE(Dstr), (Sstr))
  39. #endif
  40. #ifndef StringCatArrayA
  41. #define StringCatArrayA(Dstr, Sstr) StringCchCatA((Dstr), ARRAYSIZE(Dstr), (Sstr))
  42. #endif
  43. #ifndef StringCatArrayW
  44. #define StringCatArrayW(Dstr, Sstr) StringCchCatW((Dstr), ARRAYSIZE(Dstr), (Sstr))
  45. #endif
  46. #define LANGIDFROMHKL(x) LANGID(LOWORD(HandleToLong(x)))
  47. #define BACKDOOR_EDIT_COOKIE ((DWORD)1) // 0 is TF_INVALID_EDIT_COOKIE
  48. #define EC_MIN (BACKDOOR_EDIT_COOKIE + 1) // minimum value to avoid collisions with reserved values
  49. //
  50. // timer ids for marshaling window
  51. //
  52. #define MARSHALWND_TIMER_UPDATEKANACAPS 1
  53. #define MARSHALWND_TIMER_NUIMGRDIRTYUPDATE 2
  54. #define MARSHALWND_TIMER_WAITFORINPUTIDLEFORSETFOCUS 3
  55. //
  56. // alignment for platforms.
  57. //
  58. #define CIC_ALIGNMENT 7
  59. extern TfGuidAtom g_gaApp;
  60. extern TfGuidAtom g_gaSystem;
  61. extern BOOL g_fCTFMONProcess;
  62. extern BOOL g_fCUAS;
  63. extern TCHAR g_szCUASImeFile[];
  64. extern DWORD g_dwThreadDllMain;
  65. #define ISINDLLMAIN() ((g_dwThreadDllMain == GetCurrentThreadId()) ? TRUE : FALSE)
  66. extern CCicCriticalSectionStatic g_cs;
  67. extern CCicCriticalSectionStatic g_csInDllMain;
  68. #ifndef DEBUG
  69. #define CicEnterCriticalSection(lpCriticalSection) EnterCriticalSection(lpCriticalSection)
  70. #else // DEBUG
  71. extern const TCHAR *g_szMutexEnterFile;
  72. extern int g_iMutexEnterLine;
  73. //
  74. // In debug, you can see the file/line number where g_cs was last entered
  75. // by checking g_szMutexEnterFile and g_iMutexEnterLine.
  76. //
  77. #define CicEnterCriticalSection(lpCriticalSection) \
  78. { \
  79. Assert((g_dwThreadDllMain != GetCurrentThreadId()) || \
  80. (lpCriticalSection == (CRITICAL_SECTION *)g_csInDllMain)); \
  81. \
  82. EnterCriticalSection(lpCriticalSection); \
  83. \
  84. if (lpCriticalSection == (CRITICAL_SECTION *)g_cs) \
  85. { \
  86. g_szMutexEnterFile = __FILE__; \
  87. g_iMutexEnterLine = __LINE__; \
  88. /* need the InterlockedXXX to keep retail from optimizing away the assignment */ \
  89. InterlockedIncrement((long *)&g_szMutexEnterFile); \
  90. InterlockedDecrement((long *)&g_szMutexEnterFile); \
  91. InterlockedIncrement((long *)&g_iMutexEnterLine); \
  92. InterlockedDecrement((long *)&g_iMutexEnterLine); \
  93. } \
  94. }
  95. #endif // DEBUG
  96. inline void CicLeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
  97. {
  98. Assert((g_dwThreadDllMain != GetCurrentThreadId()) ||
  99. (lpCriticalSection == (CRITICAL_SECTION *)g_csInDllMain));
  100. LeaveCriticalSection(lpCriticalSection);
  101. }
  102. extern HKL g_hklDefault;
  103. extern const GUID GUID_APPLICATION;
  104. extern const GUID GUID_SYSTEM;
  105. //
  106. // application compatibility flag
  107. //
  108. //
  109. #define CIC_COMPAT_NOWAITFORINPUTIDLEONWIN9X 0x00000001
  110. #define CIC_COMPAT_DELAYFIRSTACTIVATEKBDLAYOUT 0x00000002
  111. extern DWORD g_dwAppCompatibility;
  112. #define CicTestAppCompat(x) ((g_dwAppCompatibility & (x)) ? TRUE : FALSE)
  113. extern BOOL InitAppCompatFlags();
  114. extern void InitCUASFlag();
  115. extern const TCHAR c_szCTFKey[];
  116. extern const TCHAR c_szTIPKey[];
  117. extern const TCHAR c_szCTFTIPKey[];
  118. extern const TCHAR c_szLangBarKey[];
  119. extern const WCHAR c_szDescriptionW[];
  120. extern const WCHAR c_szMUIDescriptionW[];
  121. extern const WCHAR c_szEnableW[];
  122. extern const TCHAR c_szEnable[];
  123. extern const TCHAR c_szDisabledOnTransitory[];
  124. extern const TCHAR c_szAsmKey[];
  125. extern const TCHAR c_szCompartKey[];
  126. extern const TCHAR c_szGlobalCompartment[];
  127. extern const TCHAR c_szNonInit[];
  128. extern const TCHAR c_szDefault[];
  129. extern const TCHAR c_szProfile[];
  130. extern const WCHAR c_szProfileW[];
  131. extern const TCHAR c_szDefaultAsmName[];
  132. extern const TCHAR c_szUpdateProfile[];
  133. extern const TCHAR c_szAssembly[];
  134. extern const TCHAR c_szLanguageProfileKey[];
  135. extern const TCHAR c_szSubstitutehKL[];
  136. extern const TCHAR c_szKeybaordLayout[];
  137. extern const WCHAR c_szIconFileW[];
  138. extern const TCHAR c_szIconIndex[];
  139. extern const WCHAR c_szIconIndexW[];
  140. extern const TCHAR c_szShowStatus[];
  141. extern const TCHAR c_szLabel[];
  142. extern const TCHAR c_szTransparency[];
  143. extern const TCHAR c_szExtraIconsOnMinimized[];
  144. extern const TCHAR c_szLocaleInfo[];
  145. extern const TCHAR c_szLocaleInfoNT4[];
  146. extern const TCHAR c_szKeyboardLayout[];
  147. extern const TCHAR c_szKeyboardLayoutKey[];
  148. extern const TCHAR c_szKbdUSNameNT[];
  149. extern const TCHAR c_szKbdUSName[];
  150. extern const TCHAR c_szLayoutFile[];
  151. extern const TCHAR c_szIMEFile[];
  152. extern const TCHAR c_szRunInputCPLCmdLine[];
  153. extern const TCHAR c_szRunInputCPL[];
  154. extern const TCHAR c_szRunInputCPLOnWin9x[];
  155. extern const TCHAR c_szRunInputCPLOnNT51[];
  156. extern const TCHAR c_szCicMarshalClass[];
  157. extern const TCHAR c_szCicMarshalWnd[];
  158. extern const TCHAR c_szHHEXELANGBARCHM[];
  159. extern const TCHAR c_szHHEXE[];
  160. extern const TCHAR c_szAppCompat[];
  161. extern const TCHAR c_szCompatibility[];
  162. extern const TCHAR c_szCtfShared[];
  163. extern const TCHAR c_szCUAS[];
  164. extern const TCHAR c_szIMMKey[];
  165. extern const TCHAR c_szCUASIMEFile[];
  166. extern HINSTANCE g_hInst;
  167. extern DWORD g_dwTLSIndex;
  168. class CThreadInputMgr;
  169. class CLangBarItemMgr;
  170. class CLangBarMgr;
  171. class CLBarItemCtrl;
  172. class CLBarItemHelp;
  173. class CLBarItemReconv;
  174. class CLBarItemWin32IME;
  175. class CLBarItemDeviceType;
  176. class CDisplayAttributeMgr;
  177. class CInputProcessorProfiles;
  178. class CAssemblyList;
  179. class CStub;
  180. class CSharedHeap;
  181. class CSharedBlock;
  182. class CInputContext;
  183. class CGlobalCompartmentMgr;
  184. typedef struct tag_LANGBARADDIN {
  185. GUID _guid;
  186. CLSID _clsid;
  187. ITfLangBarAddIn *_plbai;
  188. HINSTANCE _hInst;
  189. BOOL _fStarted : 1;
  190. BOOL _fEnabled : 1;
  191. WCHAR _wszFilePath[MAX_PATH];
  192. } LANGBARADDIN;
  193. typedef enum { COPY_ANCHORS, OWN_ANCHORS } AnchorOwnership;
  194. typedef struct tag_TL_THREADINFO {
  195. DWORD dwThreadId;
  196. DWORD dwProcessId;
  197. DWORD dwFlags;
  198. //
  199. // handle of marshal worker window.
  200. //
  201. CAlignWinHandle<HWND> hwndMarshal;
  202. //
  203. // now this thread is being called by Stub.
  204. //
  205. ULONG ulInMarshal;
  206. //
  207. // now this thread is waiting for marshaling reply from the thread.
  208. //
  209. DWORD dwMarshalWaitingThread;
  210. DWORD dwTickTime;
  211. //
  212. // Store the keyboard layout of console app here.
  213. //
  214. CAlignWinHKL hklConsole;
  215. } TL_THREADINFO;
  216. typedef struct
  217. {
  218. CThreadInputMgr *ptim;
  219. CLangBarItemMgr *plbim;
  220. CDisplayAttributeMgr *pdam;
  221. CInputProcessorProfiles *pipp;
  222. DWORD dwThreadId;
  223. DWORD dwProcessId;
  224. UINT uMsgRemoved;
  225. DWORD dwMsgTime;
  226. CAssemblyList *pAsmList;
  227. LANGID langidCurrent;
  228. LANGID langidPrev;
  229. BOOL bInImeNoImeToggle : 1;
  230. BOOL bLangToggleReady : 1; // Lang hotkey toggle flag.
  231. BOOL bKeyTipToggleReady : 1; // Lang hotkey toggle flag.
  232. int nModalLangBarId;
  233. int dwModalLangBarFlags;
  234. ULONG ulMshlCnt;
  235. HWND hwndMarshal;
  236. CPtrArray<CStub> *prgStub;
  237. CSharedHeap *psheap;
  238. CPtrArray<CSharedBlock> *prgThreadMem;
  239. HKL hklDelayActive;
  240. HKL hklBeingActivated;
  241. //
  242. // delay focus DIM change.
  243. // Cicero saves the last focused window here in CBT hook. And actual
  244. // _SetFocus() will be done in TFPRIV_ONSETWIDOWFOCUS.
  245. //
  246. HWND hwndBeingFocused;
  247. BOOL fSetWindowFocusPosted : 1;
  248. BOOL fCTFMON : 1;
  249. BOOL fInmsgSetFocus : 1;
  250. BOOL fInmsgThreadItemChange : 1;
  251. BOOL fInmsgThreadTerminate : 1;
  252. BOOL fInActivateAssembly : 1;
  253. BOOL fInitCapsKanaIndicator : 1;
  254. BOOL fRemovingInputLangChangeReq : 1;
  255. BOOL fInitGlobalCompartment : 1;
  256. BOOL fStopImm32HandlerInHook : 1;
  257. BOOL fStopLangHotkeyHandlerInHook : 1;
  258. //
  259. // CUAS
  260. //
  261. BOOL fCUASInCtfImmLastEnabledWndDestroy : 1;
  262. BOOL fCUASNoVisibleWindowChecked : 1;
  263. BOOL fCUASInCreateDummyWnd : 1;
  264. BOOL fCUASDllDetachInOtherOrMe : 1;
  265. BOOL fUninitThreadOnShuttingDown : 1;
  266. BOOL fDeactivatingTIP : 1;
  267. ULONG uDestroyingMarshalWnd;
  268. TL_THREADINFO *pti;
  269. //
  270. // Workaround for global keyboard hook
  271. //
  272. HHOOK hThreadKeyboardHook;
  273. HHOOK hThreadMouseHook;
  274. //
  275. // For CH IME-NonIME toggle hotkey
  276. //
  277. LANGID langidPrevForCHHotkey;
  278. GUID guidPrevProfileForCHHotkey;
  279. HKL hklPrevForCHHotkey;
  280. DWORD _dwLockRequestICRef;
  281. DWORD _fLockRequestPosted;
  282. CGlobalCompartmentMgr *_pGlobalCompMgr;
  283. CAlignWinHandle<HWND> hwndOleMainThread;
  284. CPtrArray<LANGBARADDIN> *prgLBAddIn;
  285. BOOL fLBAddInLoaded;
  286. ITfLangBarEventSink *_pLangBarEventSink;
  287. DWORD _dwLangBarEventCookie;
  288. } SYSTHREAD;
  289. extern SYSTHREAD *GetSYSTHREAD();
  290. extern SYSTHREAD *FindSYSTHREAD();
  291. extern void FreeSYSTHREAD();
  292. class CCatGUIDTbl;
  293. extern CCatGUIDTbl *g_pCatGUIDTbl;
  294. class CTimList;
  295. extern CTimList g_timlist;
  296. // registered messages
  297. extern UINT g_msgPrivate;
  298. extern UINT g_msgSetFocus;
  299. extern UINT g_msgThreadTerminate;
  300. extern UINT g_msgThreadItemChange;
  301. extern UINT g_msgLBarModal;
  302. extern UINT g_msgRpcSendReceive;
  303. extern UINT g_msgThreadMarshal;
  304. extern UINT g_msgCheckThreadInputIdel;
  305. #ifdef POINTER_MARSHAL
  306. extern UINT g_msgPointerMarshal;
  307. #endif
  308. extern UINT g_msgStubCleanUp;
  309. extern UINT g_msgShowFloating;
  310. extern UINT g_msgLBUpdate;
  311. extern UINT g_msgNuiMgrDirtyUpdate;
  312. extern HWND g_hwndLastForeground;
  313. extern DWORD g_dwThreadLastFocus;
  314. #define TF_S_GENERALPROPSTORE MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_ITF, 0x0401)
  315. #define TF_S_PROPSTOREPROXY MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_ITF, 0x0402)
  316. //
  317. // default.cpp
  318. //
  319. extern LONG WINAPI CicExceptionFilter(struct _EXCEPTION_POINTERS *pExceptionInfo);
  320. extern CAssemblyList *EnsureAssemblyList(SYSTHREAD *psfn, BOOL fUpdate = FALSE);
  321. extern LANGID GetCurrentAssemblyLangId(SYSTHREAD *psfn);
  322. extern void SetCurrentAssemblyLangId(SYSTHREAD *psfn, LANGID langid);
  323. extern BOOL TF_InitThreadSystem(void);
  324. extern BOOL TF_UninitThreadSystem(void);
  325. extern void UninitProcess();
  326. extern BOOL OnForegroundChanged(HWND hwndFocus);
  327. extern void OnIMENotify();
  328. extern void KanaCapsUpdate(SYSTHREAD *psfn);
  329. extern void StartKanaCapsUpdateTimer(SYSTHREAD *psfn);
  330. BOOL InitUniqueString();
  331. void GetDesktopUniqueName(const TCHAR *pszPrefix, TCHAR *pch, ULONG cchPch);
  332. BOOL IsMsctfEnabledUser();
  333. #define GetDesktopUniqueNameArray(prefix, buf) \
  334. GetDesktopUniqueName((prefix), buf, ARRAYSIZE(buf));
  335. //
  336. // ithdmshl.cpp and focusnfy.cpp
  337. //
  338. void SetFocusNotifyHandler(UINT uMsg, WPARAM wParam, LPARAM lParam);
  339. void MakeSetFocusNotify(UINT uMsg, WPARAM wParam, LPARAM lParam);
  340. void SetModalLBarSink(DWORD dwTargetThreadId, BOOL fSet, DWORD dwFlags);
  341. void SetModalLBarId(int nId, DWORD dwFlags);
  342. BOOL HandleModalLBar(UINT uMsg, WPARAM wParam, LPARAM lParam);
  343. BOOL DispatchModalLBar(WPARAM wParam, LPARAM lParam);
  344. HRESULT ThreadGetItemFloatingRect(DWORD dwThreadId, REFGUID rguid, RECT *prc);
  345. BOOL InitSharedHeap();
  346. BOOL DestroySharedHeap();
  347. BOOL IsCTFMONBusy();
  348. BOOL IsInPopupMenuMode();
  349. //
  350. // nuihkl.cpp
  351. //
  352. BOOL GetFontSig(HWND hwnd, HKL hKL);
  353. void PostInputLangRequest(SYSTHREAD *psfn, HKL hkl, BOOL fUsePost);
  354. void FlushIconIndex(SYSTHREAD *psfn);
  355. //
  356. // imelist.h
  357. //
  358. BOOL InitProfileRegKeyStr(char *psz, ULONG cchMax, REFCLSID rclsid, LANGID langid, REFGUID guidProfile);
  359. #include "catmgr.h"
  360. inline BOOL MyIsEqualTfGuidAtom(TfGuidAtom guidatom, REFGUID rguid)
  361. {
  362. BOOL fEqual;
  363. CCategoryMgr::s_IsEqualTfGuidAtom(guidatom, rguid, &fEqual);
  364. return fEqual;
  365. }
  366. inline HRESULT MyGetGUID(TfGuidAtom guidatom, GUID *pguid)
  367. {
  368. return CCategoryMgr::s_GetGUID(guidatom, pguid);
  369. }
  370. inline HRESULT MyRegisterCategory(REFGUID rcatid, REFGUID rguid)
  371. {
  372. return CCategoryMgr::s_RegisterCategory(GUID_SYSTEM, rcatid, rguid);
  373. }
  374. inline HRESULT MyUnregisterCategory(REFGUID rcatid, REFGUID rguid)
  375. {
  376. return CCategoryMgr::s_UnregisterCategory(GUID_SYSTEM, rcatid, rguid);
  377. }
  378. inline HRESULT MyRegisterGUID(REFGUID rguid, TfGuidAtom *pguidatom)
  379. {
  380. return CCategoryMgr::s_RegisterGUID(rguid, pguidatom);
  381. }
  382. inline HRESULT MyRegisterGUIDDescription(REFGUID rguid, WCHAR *psz)
  383. {
  384. return CCategoryMgr::s_RegisterGUIDDescription(GUID_SYSTEM, rguid, psz);
  385. }
  386. inline HRESULT MyUnregisterGUIDDescription(REFGUID rguid)
  387. {
  388. return CCategoryMgr::s_UnregisterGUIDDescription(GUID_SYSTEM, rguid);
  389. }
  390. inline HRESULT MyGetGUIDDescription(REFGUID rguid, BSTR *pbstr)
  391. {
  392. return CCategoryMgr::s_GetGUIDDescription(rguid, pbstr);
  393. }
  394. inline HRESULT MyGetGUIDValue(REFGUID rguid, const WCHAR *psz, BSTR *pbstr)
  395. {
  396. return CCategoryMgr::s_GetGUIDValue(rguid, psz, pbstr);
  397. }
  398. inline HRESULT MyRegisterGUIDDWORD(REFGUID rguid, DWORD dw)
  399. {
  400. return CCategoryMgr::s_RegisterGUIDDWORD(GUID_SYSTEM, rguid, dw);
  401. }
  402. inline HRESULT MyUnregisterGUIDDWORD(REFGUID rguid)
  403. {
  404. return CCategoryMgr::s_UnregisterGUIDDWORD(GUID_SYSTEM, rguid);
  405. }
  406. inline HRESULT MyGetGUIDDWORD(REFGUID rguid, DWORD *pdw)
  407. {
  408. return CCategoryMgr::s_GetGUIDDWORD(rguid, pdw);
  409. }
  410. inline BOOL MyIsValidGUIDATOM(TfGuidAtom guidatom)
  411. {
  412. return CCategoryMgr::s_IsValidGUIDATOM(guidatom);
  413. }
  414. inline HRESULT MyEnumItemsInCategory(REFGUID rcatid, IEnumGUID **ppEnum)
  415. {
  416. return CCategoryMgr::s_EnumItemsInCategory(rcatid, ppEnum);
  417. }
  418. typedef struct tag_LBESLASTMSG {
  419. UINT uMsg;
  420. CAlignPointer<WPARAM> wParam;
  421. CAlignPointer<LPARAM> lParam;
  422. } LBESLASTMSG;
  423. typedef struct tag_LBAREVENTSINK {
  424. DWORD m_dwProcessId;
  425. DWORD m_dwThreadId;
  426. DWORD m_dwCookie;
  427. DWORD m_dwLangBarFlags;
  428. DWORD m_dwFlags;
  429. CAlignWinHandle<HWND> m_hWnd; // window handle to avoid notification.
  430. LBESLASTMSG m_lastmsg;
  431. } LBAREVENTSINK;
  432. typedef struct tag_LBAREVENTSINKLOCAL {
  433. ITfLangBarEventSink* m_pSink;
  434. LBAREVENTSINK lb;
  435. } LBAREVENTSINKLOCAL;
  436. #define LBESF_INUSE 0x00000001
  437. #define LBESF_SETFOCUSINQUEUE 0x00000002
  438. extern CStructArray<LBAREVENTSINKLOCAL> *g_rglbes;
  439. extern BOOL g_fDllProcessDetached;
  440. extern BOOL g_bOnWow64;
  441. typedef struct {
  442. BOOL m_fInUse;
  443. DWORD m_dwThreadId;
  444. DWORD m_dwSrcThreadId;
  445. GUID m_iid;
  446. CAlignPointer<LRESULT> m_ref;
  447. union {
  448. DWORD m_dwType;
  449. struct {
  450. //
  451. // IUnknown pointer used only own process.
  452. // Other process distingush exists interface.
  453. //
  454. CNativeOrWow64_Pointer<IUnknown*> m_punk;
  455. ULONG m_ulStubId;
  456. DWORD m_dwStubTime;
  457. };
  458. };
  459. TCHAR m_szName[_MAX_PATH];
  460. TCHAR m_szNameConnection[_MAX_PATH];
  461. } THREADMARSHALINTERFACEDATA;
  462. #define CBBUFFERSIZE 0x80 // 0x80 is enough for NUI manager
  463. typedef struct {
  464. BOOL m_fInUse;
  465. DWORD m_dwSize;
  466. BYTE m_bBuffer[CBBUFFERSIZE];
  467. } BUFFER, *PBUFFER;
  468. //
  469. // All shared memory for msctf.dll must live in this struct, it will
  470. // be stored in a filemapping.
  471. //
  472. // Use GetSharedMemory()->myData to access shared memory.
  473. //
  474. typedef struct
  475. {
  476. //
  477. // Issue:
  478. //
  479. // max number of the threads that can initialize marshaled interface same time.
  480. // 5 is enough??
  481. //
  482. #define NUM_TMD 5
  483. THREADMARSHALINTERFACEDATA tmd[NUM_TMD];
  484. //
  485. // The current focus thread, proccess and foreground window.
  486. //
  487. DWORD dwFocusThread;
  488. DWORD dwFocusProcess;
  489. CAlignWinHandle<HWND> hwndForeground;
  490. //
  491. // The previous focus thread, proccess and foreground window.
  492. //
  493. DWORD dwFocusThreadPrev;
  494. CAlignWinHandle<HWND> hwndForegroundPrev;
  495. //
  496. // The last thread of ITfThreadFocusSink
  497. //
  498. DWORD dwLastFocusSinkThread;
  499. //
  500. // Native/WOW6432 system hook
  501. //
  502. CNativeOrWow64_WinHandle<HHOOK> hSysShellHook;
  503. CNativeOrWow64_WinHandle<HHOOK> hSysGetMsgHook;
  504. CNativeOrWow64_WinHandle<HHOOK> hSysCBTHook;
  505. //
  506. // track shell hook WINDOWACTIVATE
  507. //
  508. BOOL fInFullScreen;
  509. //
  510. // Issue:
  511. //
  512. // we must take care of more Sinks.
  513. //
  514. #define MAX_LPES_NUM 5
  515. LBAREVENTSINK lbes[MAX_LPES_NUM];
  516. DWORD dwlbesCookie;
  517. LONG cProcessesMinus1;
  518. CAlignWinHandle<HANDLE> hheapShared; // Only use on Windows95/98 platform
  519. // MSAA activation ref count
  520. LONG cMSAARef; // inited to -1 for win95 InterlockedIncrement compat
  521. DWORD dwPrevShowFloatingStatus;
  522. } SHAREMEM;
  523. class CCiceroSharedMem : public CCicFileMappingStatic
  524. {
  525. public:
  526. BOOL Start()
  527. {
  528. BOOL fAlreadyExists;
  529. TCHAR ach[MAX_PATH];
  530. GetDesktopUniqueName(TEXT("CiceroSharedMem"), ach, ARRAYSIZE(ach));
  531. Init(ach, NULL);
  532. // Init(TEXT("CiceroSharedMem"), NULL);
  533. CCicSecAttr sa;
  534. if (Create(sa, sizeof(SHAREMEM), &fAlreadyExists) == NULL)
  535. return FALSE;
  536. if (!fAlreadyExists)
  537. {
  538. // by default, every member initialize to 0
  539. // initialize other members here
  540. ((SHAREMEM *)_pv)->cProcessesMinus1 = -1;
  541. ((SHAREMEM *)_pv)->cMSAARef = -1;
  542. }
  543. return TRUE;
  544. }
  545. SHAREMEM *GetPtr() { return (SHAREMEM *)_pv; }
  546. private:
  547. };
  548. extern CCiceroSharedMem g_SharedMemory;
  549. inline SHAREMEM *GetSharedMemory() { return g_SharedMemory.GetPtr(); }
  550. inline BOOL IsSharedMemoryCreated() { return g_SharedMemory.IsCreated(); }
  551. inline BOOL IsChinesePlatform()
  552. {
  553. if (g_uACP == 936)
  554. return TRUE;
  555. if (g_uACP == 950)
  556. return TRUE;
  557. return FALSE;
  558. }
  559. #endif // GLOBALS_H