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.

257 lines
7.2 KiB

  1. /****************************** Module Header ******************************\
  2. * Module Name: clglobal.c
  3. *
  4. * Copyright (c) 1985 - 1999, Microsoft Corporation
  5. *
  6. * This module contains all of USER.DLL's global variables. These are all
  7. * instance-specific, i.e. each client has his own copy of these. In general,
  8. * there shouldn't be much reason to create instance globals.
  9. *
  10. * NOTE: In this case what we mean by global is that this data is shared by
  11. * all threads of a given process, but not shared between processes
  12. * or between the client and the server. None of this data is useful
  13. * (or even accessable) to the server.
  14. *
  15. * History:
  16. * 10-18-90 DarrinM Created.
  17. \***************************************************************************/
  18. #include "precomp.h"
  19. #pragma hdrstop
  20. #ifdef LAZY_CLASS_INIT
  21. BOOL gbClassesRegistered;
  22. #endif
  23. /*
  24. * We get this warning if we don't explicitly initalize gZero:
  25. *
  26. * C4132: 'gZero' : const object should be initialized
  27. *
  28. * But we can't explicitly initialize it since it is a union. So
  29. * we turn the warning off.
  30. */
  31. #pragma warning(disable:4132)
  32. CONST ALWAYSZERO gZero;
  33. #pragma warning(default:4132)
  34. /*
  35. * Amount wheel has been scrolled in a control less than WHEEL_DELTA. Each
  36. * control resets this variable to 0 in WM_KILLFOCUS, and verifies it is
  37. * 0 in WM_SETFOCUS.
  38. * CONSIDER: Should be per-queue rather than per client?
  39. */
  40. int gcWheelDelta;
  41. WCHAR awchSlashStar[] = L"\\*";
  42. CHAR achSlashStar[] = "\\*";
  43. PSERVERINFO gpsi;
  44. SHAREDINFO gSharedInfo;
  45. HMODULE hmodUser; // USER.DLL's hmodule
  46. ULONG_PTR gHighestUserAddress;
  47. BOOL gfServerProcess; // USER is linked on the CSR server side
  48. BOOL gfSystemInitialized; // System has been initialized
  49. ACCESS_MASK gamWinSta; // ACCESS_MASK for the current WindowStation
  50. PVOID pUserHeap;
  51. WCHAR szUSER32[] = TEXT("USER32");
  52. CONST WCHAR szNull[2] = { TEXT('\0'), TEXT('\015') };
  53. CONST WCHAR szOneChar[] = TEXT("0");
  54. WCHAR szSLASHSTARDOTSTAR[] = TEXT("\\*"); /* This is a single "\" */
  55. LPWSTR pwcHighContrastScheme;
  56. LPSTR pcHighContrastScheme;
  57. /* Maps MessageBox type to number of buttons in the MessageBox */
  58. CONST BYTE mpTypeCcmd[] = { 1, 2, 3, 3, 2, 2, 3 };
  59. /* Maps MessageBox type to index into SEBbuttons array */
  60. CONST BYTE mpTypeIich[] = { 0, 2, 5, 12, 9, 16, 19 };
  61. CONST UINT SEBbuttons[] = {
  62. SEB_OK, SEB_HELP,
  63. SEB_OK, SEB_CANCEL, SEB_HELP,
  64. SEB_ABORT, SEB_RETRY, SEB_IGNORE, SEB_HELP,
  65. SEB_YES, SEB_NO, SEB_HELP,
  66. SEB_YES, SEB_NO, SEB_CANCEL, SEB_HELP,
  67. SEB_RETRY, SEB_CANCEL, SEB_HELP,
  68. SEB_CANCEL, SEB_TRYAGAIN, SEB_CONTINUE, SEB_HELP,
  69. };
  70. ATOM atomMDIActivateProp;
  71. #ifdef LAME_BUTTON
  72. ATOM gatomLameButton;
  73. #endif
  74. CRITICAL_SECTION gcsLookaside;
  75. CRITICAL_SECTION gcsHdc;
  76. CRITICAL_SECTION gcsClipboard;
  77. CRITICAL_SECTION gcsAccelCache;
  78. #ifdef _JANUS_
  79. BOOL gfEMIEnable;
  80. DWORD gdwEMIControl;
  81. BOOL gfDMREnable;
  82. HANDLE gEventSource;
  83. #endif
  84. HDC ghdcBits2;
  85. HDC ghdcGray;
  86. HFONT ghFontSys;
  87. HBRUSH ghbrWindowText;
  88. int gcxGray;
  89. int gcyGray;
  90. FPLPKTABBEDTEXTOUT fpLpkTabbedTextOut = UserLpkTabbedTextOut;
  91. FPLPKPSMTEXTOUT fpLpkPSMTextOut = UserLpkPSMTextOut;
  92. FPLPKDRAWTEXTEX fpLpkDrawTextEx = (FPLPKDRAWTEXTEX)NULL;
  93. PLPKEDITCALLOUT fpLpkEditControl = (PLPKEDITCALLOUT)NULL;
  94. /*
  95. * These are the resource call procedure addresses. If WOW is running,
  96. * it makes a call to set all these up to point to it. If it isn't
  97. * running, it defaults to the values you see below.
  98. */
  99. PFNFINDA pfnFindResourceExA; // Assigned dynamically - _declspec (PFNFINDA)FindResourceExA,
  100. PFNFINDW pfnFindResourceExW; // Assigned dynamically - _declspec (PFNFINDW)FindResourceExW,
  101. PFNLOAD pfnLoadResource; // Assigned dynamically - _declspec (PFNLOAD)LoadResource,
  102. PFNLOCK pfnLockResource = (PFNLOCK)_LockResource;
  103. PFNUNLOCK pfnUnlockResource = (PFNUNLOCK)_UnlockResource;
  104. PFNFREE pfnFreeResource = (PFNFREE)_FreeResource;
  105. PFNSIZEOF pfnSizeofResource; // Assigned dynamically - _declspec (PFNSIZEOF)SizeofResource
  106. PFNLALLOC pfnLocalAlloc = (PFNLALLOC)DispatchLocalAlloc;
  107. PFNLREALLOC pfnLocalReAlloc = (PFNLREALLOC)DispatchLocalReAlloc;
  108. PFNLLOCK pfnLocalLock = (PFNLLOCK)DispatchLocalLock;
  109. PFNLUNLOCK pfnLocalUnlock = (PFNUNLOCK)DispatchLocalUnlock;
  110. PFNLSIZE pfnLocalSize = (PFNLSIZE)DispatchLocalSize;
  111. PFNLFREE pfnLocalFree = (PFNLFREE)DispatchLocalFree;
  112. PFNGETEXPWINVER pfnGetExpWinVer = RtlGetExpWinVer;
  113. PFN16GALLOC pfn16GlobalAlloc;
  114. PFN16GFREE pfn16GlobalFree;
  115. PFNEMPTYCB pfnWowEmptyClipBoard;
  116. PFNWOWWNDPROCEX pfnWowWndProcEx;
  117. PFNWOWDLGPROCEX pfnWowDlgProcEx;
  118. PFNWOWEDITNEXTWORD pfnWowEditNextWord;
  119. PFNWOWCBSTOREHANDLE pfnWowCBStoreHandle;
  120. PFNGETPROCMODULE16 pfnWowGetProcModule;
  121. PFNWOWTELLWOWTHEHDLG pfnWOWTellWOWThehDlg;
  122. PFNWOWMSGBOXINDIRECTCALLBACK pfnWowMsgBoxIndirectCallback;
  123. PFNWOWILSTRCMP pfnWowIlstrcmp;
  124. PFNWOWTASK16SCHEDNOTIFY pfnWowTask16SchedNotify;
  125. /*
  126. * UserApiHook
  127. *
  128. * It is important to keep guah initialization in sync with ResetUserApiHook()
  129. * and the definition of USERAPIHOOK. This initialization must be done here
  130. * so that the function pointers are valid immediately on startup.
  131. */
  132. BYTE grgbDwpLiteHookMsg[(WM_USER + 7) / 8];
  133. BYTE grgbWndLiteHookMsg[(WM_USER + 7) / 8];
  134. BYTE grgbDlgLiteHookMsg[(WM_USER + 7) / 8];
  135. HMODULE ghmodUserApiHook;
  136. USERAPIHOOK guah =
  137. {
  138. sizeof(USERAPIHOOK),
  139. RealDefWindowProcA,
  140. RealDefWindowProcW,
  141. {
  142. NULL,
  143. 0
  144. },
  145. RealGetScrollInfo,
  146. RealSetScrollInfo,
  147. RealEnableScrollBar,
  148. RealAdjustWindowRectEx,
  149. RealSetWindowRgn,
  150. {
  151. DefaultOWP,
  152. DefaultOWP,
  153. NULL,
  154. 0
  155. },
  156. {
  157. DefaultOWP,
  158. DefaultOWP,
  159. NULL,
  160. 0
  161. },
  162. RealGetSystemMetrics,
  163. RealSystemParametersInfoA,
  164. RealSystemParametersInfoW,
  165. ForceResetUserApiHook,
  166. RealDrawFrameControl,
  167. RealDrawCaption,
  168. RealMDIRedrawFrame
  169. };
  170. BOOL gfUserApiHook;
  171. LONG gcCallUserApiHook;
  172. LONG gcLoadUserApiHook;
  173. RTL_CRITICAL_SECTION gcsUserApiHook;
  174. INITUSERAPIHOOK gpfnInitUserApi;
  175. #ifdef MESSAGE_PUMP_HOOK
  176. /*
  177. * MessagePumpHook
  178. */
  179. BOOL gfMessagePumpHook;
  180. LONG gcLoadMPH;
  181. MESSAGEPUMPHOOK gmph =
  182. {
  183. sizeof(gmph),
  184. NtUserRealInternalGetMessage,
  185. NtUserRealWaitMessageEx,
  186. RealGetQueueStatus,
  187. RealMsgWaitForMultipleObjectsEx,
  188. };
  189. RTL_CRITICAL_SECTION gcsMPH;
  190. INITMESSAGEPUMPHOOK gpfnInitMPH;
  191. #if TEST_DUSER_WMH
  192. HDCONTEXT g_hctx = NULL; // DirectUser Context
  193. #endif // TEST_DUSER_WMH
  194. #endif // MESSAGE_PUMP_HOOK
  195. /*
  196. * Menu Drag and Drop
  197. */
  198. HINSTANCE ghinstOLE;
  199. FARPROC gpfnOLEOleUninitialize;
  200. FARPROC gpfnOLERegisterDD;
  201. FARPROC gpfnOLERevokeDD;
  202. FARPROC gpfnOLEDoDD;
  203. /*
  204. * Accelerator table resources list.
  205. */
  206. PACCELCACHE gpac;
  207. /*
  208. * IME Window Handling.
  209. */
  210. DWORD gfConIme = UNKNOWN_CONIME;
  211. /*
  212. * Used for TS Services Message Box handling
  213. */
  214. FARPROC gfnWinStationSendMessageW;
  215. HINSTANCE ghinstWinStaDll;
  216. /*
  217. * Are we winlogon?
  218. */
  219. BOOL gfLogonProcess;
  220. #if DBG
  221. USERDBGGLOBALS gDbgGlobals;
  222. #endif