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.

3940 lines
142 KiB

  1. /****************************** Module Header ******************************\
  2. * Module Name: user.h
  3. *
  4. * Copyright (c) 1985 - 1999, Microsoft Corporation
  5. *
  6. * This header file contains stuff shared by all the modules of the USER.DLL.
  7. *
  8. * History:
  9. * 09-18-90 DarrinM Created.
  10. * 04-27-91 DarrinM Merged in USERCALL.H, removed some dead wood.
  11. \***************************************************************************/
  12. #ifndef _USER_
  13. #define _USER_
  14. /******************************WOW64***NOTE********************************\
  15. * Note: Win32k Memory shared with User-Mode and Wow64
  16. *
  17. * For Wow64 (Win32 apps on Win64) we build a 32-bit version
  18. * of user32.dll & gdi32.dll which can run against the 64-bit kernel
  19. * with no changes to the 64-bit kernel code.
  20. *
  21. * For the 32 on 64 bit dlls all data structures which are shared with
  22. * win32k must be 64-bit. These data structures include the shared
  23. * sections, as well as members of the TEB.
  24. * These shared data structures are now declared so that they can be
  25. * built as 32 bit in a 32 bit dll, 64 bit in a 64 bit dll, and now
  26. * 64 bit in a 32 bit dll.
  27. *
  28. * The following rules should be followed when declaring
  29. * shared data structures:
  30. *
  31. * Pointers in shared data structures use the KPTR_MODIFIER in their
  32. * declaration.
  33. *
  34. * Handles in shared data structures are declared KHxxx.
  35. *
  36. * xxx_PTR changes to KERNEL_xxx_PTR.
  37. *
  38. * Pointers to basic types are declared as KPxxx;
  39. *
  40. * Also on Wow64 every thread has both a 32-bit TEB and a 64-bit TEB.
  41. * GetCurrentTeb() returns the current 32-bit TEB while the kernel
  42. * will allways reference the 64-bit TEB.
  43. *
  44. * All client side references to shared data in the TEB should use
  45. * the new GetCurrentTebShared() macro which returns the 64-bit TEB
  46. * for Wow64 builds and returns GetCurrentTeb() for regular builds.
  47. * The exception to this rule is LastErrorValue, which should allways
  48. * be referenced through GetCurrentTeb().
  49. *
  50. * Ex:
  51. *
  52. * DECLARE_HANDLE(HFOO);
  53. *
  54. * typedef struct _MY_STRUCT *PMPTR;
  55. *
  56. * struct _SHARED_STRUCT
  57. * {
  58. * struct _SHARED_STRUCT * pNext;
  59. * PMPTR pmptr;
  60. * HFOO hFoo;
  61. * UINT_PTR cb;
  62. * PBYTE pb;
  63. * PVOID pv;
  64. *
  65. * DWORD dw;
  66. * USHORT us;
  67. * } SHARED_STRUCT;
  68. *
  69. *
  70. * Changes to:
  71. *
  72. *
  73. * DECLARE_HANDLE(HFOO);
  74. * DECLARE_KHANDLE(HFOO);
  75. *
  76. * typedef struct _MY_STRUCT * KPTR_MODIFIER PMPTR;
  77. *
  78. * struct _SHARED_STRUCT
  79. * {
  80. * struct _SHARED_STRUCT * KPTR_MODIFIER pNext;
  81. * PMPTR pmptr;
  82. * KHFOO hFoo;
  83. * KERNEL_UINT_PTR cb;
  84. * KPBYTE pb;
  85. * KERNEL_PVOID pv;
  86. *
  87. * DWORD dw;
  88. * USHORT us;
  89. * } SHARED_STRUCT;
  90. *
  91. \***************************************************************************/
  92. #include "w32wow64.h"
  93. DECLARE_KHANDLE(HIMC);
  94. /*
  95. * Enable warnings that are turned off default for NT but we want on
  96. */
  97. #ifndef RC_INVOKED // RC can't handle #pragmas
  98. #pragma warning(error:4100) // Unreferenced formal parameter
  99. #pragma warning(error:4101) // Unreferenced local variable
  100. // #pragma warning(error:4702) // Unreachable code
  101. #pragma warning(error:4705) // Statement has no effect
  102. #endif // RC_INVOKED
  103. #if !defined(FASTCALL)
  104. #if defined(_X86_)
  105. #define FASTCALL _fastcall
  106. #else // defined(_X86_)
  107. #define FASTCALL
  108. #endif // defined(_X86_)
  109. #endif // !defined(FASTCALL)
  110. #ifdef UNICODE
  111. #define UTCHAR WCHAR
  112. #else // UINCODE
  113. #define UTCHAR UCHAR
  114. #endif // UINCODE
  115. /*
  116. * These types are needed before they are fully defined.
  117. */
  118. typedef struct tagWINDOWSTATION * KPTR_MODIFIER PWINDOWSTATION;
  119. typedef struct _LOCKRECORD * KPTR_MODIFIER PLR;
  120. typedef struct _TL * KPTR_MODIFIER PTL;
  121. typedef struct tagDESKTOP * KPTR_MODIFIER PDESKTOP;
  122. typedef struct tagTDB * KPTR_MODIFIER PTDB;
  123. typedef struct tagSVR_INSTANCE_INFO * PSVR_INSTANCE_INFO;
  124. typedef struct _MOVESIZEDATA * PMOVESIZEDATA;
  125. typedef struct tagCURSOR * KPTR_MODIFIER PCURSOR;
  126. typedef struct tagPOPUPMENU * KPTR_MODIFIER PPOPUPMENU;
  127. typedef struct tagQMSG * KPTR_MODIFIER PQMSG;
  128. typedef struct tagWND * KPTR_MODIFIER PWND;
  129. typedef struct _ETHREAD * PETHREAD;
  130. typedef struct tagDESKTOPINFO * KPTR_MODIFIER PDESKTOPINFO;
  131. typedef struct tagDISPLAYINFO * KPTR_MODIFIER PDISPLAYINFO;
  132. typedef struct tagCLIENTTHREADINFO * KPTR_MODIFIER PCLIENTTHREADINFO;
  133. typedef struct tagDCE * KPTR_MODIFIER PDCE;
  134. typedef struct tagSPB * KPTR_MODIFIER PSPB;
  135. typedef struct tagQ * KPTR_MODIFIER PQ;
  136. typedef struct tagTHREADINFO * KPTR_MODIFIER PTHREADINFO;
  137. typedef struct tagPROCESSINFO * KPTR_MODIFIER PPROCESSINFO;
  138. typedef struct tagWOWTHREADINFO * PWOWTHREADINFO;
  139. typedef struct tagPERUSERDATA * PPERUSERDATA;
  140. typedef struct tagTERMINAL * PTERMINAL;
  141. typedef struct tagCLIENTINFO * PCLIENTINFO;
  142. typedef struct tagMENU * KPTR_MODIFIER PMENU;
  143. typedef struct tagHOOK * KPTR_MODIFIER PHOOK;
  144. typedef struct _HANDLEENTRY * KPTR_MODIFIER PHE;
  145. typedef struct tagSERVERINFO * KPTR_MODIFIER PSERVERINFO;
  146. typedef struct _CALLPROCDATA * KPTR_MODIFIER PCALLPROCDATA;
  147. typedef struct tagCLS * KPTR_MODIFIER PCLS;
  148. typedef struct tagMONITOR * KPTR_MODIFIER PMONITOR;
  149. /*
  150. * MessageBox button strings.
  151. * They should be in the same order as IDOK... and SEB_OK... are
  152. */
  153. #define STR_OK 800
  154. #define STR_CANCEL 801
  155. #define STR_ABORT 802
  156. #define STR_RETRY 803
  157. #define STR_IGNORE 804
  158. #define STR_YES 805
  159. #define STR_NO 806
  160. #define STR_CLOSE 807
  161. #define STR_HELP 808
  162. #define STR_TRYAGAIN 809
  163. #define STR_CONTINUE 810
  164. /*
  165. * ToolTip strings.
  166. */
  167. #define STR_TT_MIN 900
  168. #define STR_TT_MAX 901
  169. #define STR_TT_RESUP 902
  170. #define STR_TT_RESDOWN 903
  171. #define STR_TT_HELP 904
  172. #define STR_TT_SCLOSE 905
  173. /*
  174. * This name is used both in kernel\server.c and ntuser\server\exitwin.c
  175. */
  176. #define ICON_PROP_NAME L"SysIC"
  177. /*
  178. * Define DbgPrint to be something bogus on free builds so we won't
  179. * include it accidentally.
  180. */
  181. #if !DBG
  182. #define DbgPrint UserDbgPrint
  183. #endif
  184. typedef struct tagMBSTRING
  185. {
  186. WCHAR szName[15];
  187. UINT uID;
  188. UINT uStr;
  189. } MBSTRING, * KPTR_MODIFIER PMBSTRING;
  190. /*
  191. * SIZERECT is a rectangle represented by a top-left coordinate, width,
  192. * and height.
  193. *
  194. * Hungarian is "src".
  195. */
  196. typedef struct tagSIZERECT {
  197. int x;
  198. int y;
  199. int cx;
  200. int cy;
  201. } SIZERECT, *PSIZERECT, *LPSIZERECT;
  202. typedef const SIZERECT * PCSIZERECT;
  203. typedef const SIZERECT * LPCSIZERECT;
  204. void RECTFromSIZERECT(PRECT prc, PCSIZERECT psrc);
  205. void SIZERECTFromRECT(PSIZERECT psrc, LPCRECT prc);
  206. /*
  207. * Use these macros to unpack things packed by MAKELPARAM.
  208. */
  209. #define LOSHORT(l) ((short)LOWORD(l))
  210. #define HISHORT(l) ((short)HIWORD(l))
  211. #ifndef GET_X_LPARAM
  212. #define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
  213. #endif
  214. #ifndef GET_Y_LPARAM
  215. #define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
  216. #endif
  217. #ifdef _USERK_
  218. #define GetClientInfo() (((PTHREADINFO)(W32GetCurrentThread()))->pClientInfo)
  219. #else
  220. // We don't grab it this way in the kernel in case it is a kernel only thread
  221. #define GetClientInfo() ((PCLIENTINFO)((NtCurrentTebShared())->Win32ClientInfo))
  222. #endif
  223. /* Used by xxxSleepTask */
  224. #define HEVENT_REMOVEME ((HANDLE)IntToPtr(0xFFFFFFFF))
  225. /*
  226. * Access to system metrics, colors, and brushes.
  227. */
  228. #define SYSMETBOOL(i) ((gpsi->aiSysMet[SM_BOOLEANS] & (1 << (SM_##i - SM_STARTBOOLRANGE))) != 0)
  229. #define SYSMETBOOL2(index) ((gpsi->aiSysMet[SM_BOOLEANS] & (1 << (index - SM_STARTBOOLRANGE))) != 0)
  230. #define SETSYSMETBOOL(i, val) SET_OR_CLEAR_FLAG(gpsi->aiSysMet[SM_BOOLEANS], 1 << (SM_##i - SM_STARTBOOLRANGE), val)
  231. #define SYSMET(i) (gpsi->aiSysMet[SM_##i])
  232. #define SYSMETRTL(i) (gpsi->aiSysMet[SM_##i])
  233. #define SYSRGB(i) (gpsi->argbSystem[COLOR_##i])
  234. #define SYSRGBRTL(i) (gpsi->argbSystem[COLOR_##i])
  235. #define SYSHBR(i) KHBRUSH_TO_HBRUSH(gpsi->ahbrSystem[COLOR_##i])
  236. #define SYSHBRUSH(i) KHBRUSH_TO_HBRUSH(gpsi->ahbrSystem[i])
  237. #ifdef _USERK_
  238. #define SYSMETFROMPROCESS(i) gpsi->aiSysMet[SM_##i]
  239. #endif
  240. /*
  241. * These cool constants can be used to specify rops.
  242. */
  243. #define DESTINATION (DWORD)0x00AA0000
  244. #define SOURCE (DWORD)0x00CC0000
  245. #define PATTERN (DWORD)0x00F00000
  246. /*
  247. * Chicago equates.
  248. */
  249. #define BI_CHECKBOX 0
  250. #define BI_RADIOBUTTON 1
  251. #define BI_3STATE 2
  252. #define NUM_BUTTON_TYPES 3
  253. #define NUM_BUTTON_STATES 4
  254. /*
  255. * Total number of strings used as button strings in MessageBoxes.
  256. */
  257. #define MAX_MB_STRINGS 11
  258. /*
  259. * Rectangle macros. Inlining these is both faster and smaller.
  260. */
  261. #define CopyRect CopyRectInl
  262. #define EqualRect EqualRectInl
  263. #define SetRectEmpty SetRectEmptyInl
  264. __inline void
  265. CopyRectInl(LPRECT prcDest, LPCRECT prcSrc)
  266. {
  267. *prcDest = *prcSrc;
  268. }
  269. __inline DWORD
  270. EqualRectInl(LPCRECT prc1, LPCRECT prc2)
  271. {
  272. return RtlEqualMemory(prc1, prc2, sizeof(*prc1));
  273. }
  274. __inline void
  275. SetRectEmptyInl(LPRECT prc)
  276. {
  277. RtlZeroMemory(prc, sizeof(*prc));
  278. }
  279. /***************************************************************************\
  280. * ANSI/Unicode function names
  281. *
  282. * For non-API Client/Server stubs, an "A" or "W" suffix must be added.
  283. * (API function names are generated by running wcshdr.exe over winuser.x)
  284. *
  285. \***************************************************************************/
  286. #ifdef UNICODE
  287. #define TEXT_FN(fn) fn##W
  288. #else // UNICODE
  289. #define TEXT_FN(fn) fn##A
  290. #endif // UNICODE
  291. #ifdef UNICODE
  292. #define BYTESTOCHARS(cb) ((cb) / sizeof(TCHAR))
  293. #define CHARSTOBYTES(cch) ((cch) * sizeof(TCHAR))
  294. #else // UNICODE
  295. #define BYTESTOCHARS(cb) (cb)
  296. #define CHARSTOBYTES(cch) (cch)
  297. #endif // UNICODE
  298. /*
  299. * Internal window class names
  300. */
  301. #define DESKTOPCLASS MAKEINTATOM(0x8001)
  302. #define DIALOGCLASS MAKEINTATOM(0x8002)
  303. #define SWITCHWNDCLASS MAKEINTATOM(0x8003)
  304. #define ICONTITLECLASS MAKEINTATOM(0x8004)
  305. #define INFOCLASS MAKEINTATOM(0x8005)
  306. #define TOOLTIPCLASS MAKEINTATOM(0x8006)
  307. #define GHOSTCLASS MAKEINTATOM(0x8007)
  308. #define MENUCLASS MAKEINTATOM(0x8000) /* Public Knowledge */
  309. //
  310. // System timer IDs
  311. //
  312. #define IDSYS_LAYER 0x0000FFF5L
  313. #define IDSYS_FADE 0x0000FFF6L
  314. #define IDSYS_WNDTRACKING 0x0000FFF7L
  315. #define IDSYS_FLASHWND 0x0000FFF8L
  316. #define IDSYS_MNAUTODISMISS 0x0000FFF9L
  317. #define IDSYS_MOUSEHOVER 0x0000FFFAL
  318. #define IDSYS_MNANIMATE 0x0000FFFBL
  319. #define IDSYS_MNDOWN MFMWFP_DOWNARROW /* 0xFFFFFFFC */
  320. #define IDSYS_LBSEARCH 0x0000FFFCL
  321. #define IDSYS_MNUP MFMWFP_UPARROW /* 0xFFFFFFFD */
  322. #define IDSYS_STANIMATE 0x0000FFFDL
  323. #define IDSYS_MNSHOW 0x0000FFFEL
  324. #define IDSYS_SCROLL 0x0000FFFEL
  325. #define IDSYS_MNHIDE 0x0000FFFFL
  326. #define IDSYS_CARET 0x0000FFFFL
  327. /*
  328. * Special case string token codes. These must be the same as in the resource
  329. * compiler's RC.H file.
  330. */
  331. /*
  332. * NOTE: Order is assumed and much be this way for applications to be
  333. * compatable with windows 2.0
  334. */
  335. #define CODEBIT 0x80
  336. #define BUTTONCODE 0x80
  337. #define EDITCODE 0x81
  338. #define STATICCODE 0x82
  339. #define LISTBOXCODE 0x83
  340. #define SCROLLBARCODE 0x84
  341. #define COMBOBOXCODE 0x85
  342. #define MDICLIENTCODE 0x86
  343. #define COMBOLISTBOXCODE 0x87
  344. /*
  345. * Internal window classes. These numbers serve as indices into the
  346. * atomSysClass table so that we can get the atoms for the various classes.
  347. * The order of the control classes (through COMBOLISTBOXCLASS) is assumed
  348. * to be the same as the class codes above.
  349. */
  350. #define ICLS_BUTTON 0
  351. #define ICLS_EDIT 1
  352. #define ICLS_STATIC 2
  353. #define ICLS_LISTBOX 3
  354. #define ICLS_SCROLLBAR 4
  355. #define ICLS_COMBOBOX 5 // End of special dlgmgr indices
  356. #define ICLS_MDICLIENT 6
  357. #define ICLS_COMBOLISTBOX 7
  358. #define ICLS_DDEMLEVENT 8
  359. #define ICLS_DDEMLMOTHER 9
  360. #define ICLS_DDEML16BIT 10
  361. #define ICLS_DDEMLCLIENTA 11
  362. #define ICLS_DDEMLCLIENTW 12
  363. #define ICLS_DDEMLSERVERA 13
  364. #define ICLS_DDEMLSERVERW 14
  365. #define ICLS_IME 15
  366. #define ICLS_CTL_MAX 16 // Number of public control classes
  367. #define ICLS_DESKTOP 16
  368. #define ICLS_DIALOG 17
  369. #define ICLS_MENU 18
  370. #define ICLS_SWITCH 19
  371. #define ICLS_ICONTITLE 20
  372. #define ICLS_TOOLTIP 21
  373. #define ICLS_GHOST 22
  374. #define ICLS_MAX 23 // Number of system classes
  375. /*
  376. * Directory name for windowstations and desktops
  377. */
  378. #define WINSTA_DIR L"\\Windows\\WindowStations"
  379. #define WINSTA_SESSION_DIR L"\\Sessions\\xxxxxxxxxxx\\Windows\\WindowStations"
  380. #define WINSTA_NAME L"Service-0x0000-0000$"
  381. #define MAX_SESSION_PATH 256
  382. #define SESSION_ROOT L"\\Sessions"
  383. /***************************************************************************\
  384. * Normal Stuff
  385. *
  386. * Nice normal typedefs, defines, prototypes, etc that everyone wants to share.
  387. *
  388. \***************************************************************************/
  389. /*
  390. * Define size limit of callback data. Below or equal to this limit, put data
  391. * on the client-side stack. Above this limit allocate virtual memory
  392. * for the data.
  393. */
  394. #define CALLBACKSTACKLIMIT (KERNEL_PAGE_SIZE / 2)
  395. /*
  396. * Capture buffer definition for callbacks.
  397. */
  398. typedef struct _CAPTUREBUF {
  399. DWORD cbCallback;
  400. DWORD cbCapture;
  401. DWORD cCapturedPointers;
  402. PBYTE pbFree;
  403. DWORD offPointers;
  404. PVOID pvVirtualAddress;
  405. } CAPTUREBUF, *PCAPTUREBUF;
  406. /*
  407. * Callback return status
  408. */
  409. typedef struct _CALLBACKSTATUS {
  410. KERNEL_ULONG_PTR retval;
  411. DWORD cbOutput;
  412. KERNEL_PVOID pOutput;
  413. } CALLBACKSTATUS, *PCALLBACKSTATUS;
  414. #define IS_PTR(p) ((((ULONG_PTR)(p)) & ~MAXUSHORT) != 0)
  415. #define PTR_TO_ID(p) ((USHORT)(((ULONG_PTR)(p)) & MAXUSHORT))
  416. //
  417. // Strings are counted 16-bit character strings. If they are
  418. // NULL terminated, Length does not include trailing NULL.
  419. //
  420. typedef struct _LARGE_STRING {
  421. ULONG Length;
  422. ULONG MaximumLength : 31;
  423. ULONG bAnsi : 1;
  424. KERNEL_PVOID Buffer;
  425. } LARGE_STRING, *PLARGE_STRING;
  426. typedef struct _LARGE_ANSI_STRING {
  427. ULONG Length;
  428. ULONG MaximumLength : 31;
  429. ULONG bAnsi : 1;
  430. KPSTR Buffer;
  431. } LARGE_ANSI_STRING, *PLARGE_ANSI_STRING;
  432. typedef struct _LARGE_UNICODE_STRING {
  433. ULONG Length;
  434. ULONG MaximumLength : 31;
  435. ULONG bAnsi : 1;
  436. KPWSTR Buffer;
  437. } LARGE_UNICODE_STRING, *PLARGE_UNICODE_STRING;
  438. /*
  439. * String macros
  440. */
  441. __inline BOOL IsEmptyString(PVOID p, ULONG bAnsi)
  442. {
  443. return (BOOL)!(bAnsi ? *(LPSTR)p : *(LPWSTR)p);
  444. }
  445. __inline void NullTerminateString(PVOID p, ULONG bAnsi)
  446. {
  447. if (bAnsi) *(LPSTR)p = (CHAR)0; else *(LPWSTR)p = (WCHAR)0;
  448. }
  449. __inline UINT StringLength(PVOID p, ULONG bAnsi)
  450. {
  451. return (bAnsi ? strlen((LPSTR)p) : wcslen((LPWSTR)p));
  452. }
  453. typedef struct _CTLCOLOR {
  454. COLORREF crText;
  455. COLORREF crBack;
  456. int iBkMode;
  457. } CTLCOLOR, *PCTLCOLOR;
  458. /*
  459. * This is used by the cool client side DrawIcon code
  460. */
  461. typedef struct _DRAWICONEXDATA {
  462. HBITMAP hbmMask;
  463. HBITMAP hbmColor;
  464. int cx;
  465. int cy;
  466. HBITMAP hbmUserAlpha;
  467. } DRAWICONEXDATA;
  468. /*
  469. * Static items stored in the TEB
  470. */
  471. typedef struct _CALLBACKWND {
  472. KHWND hwnd;
  473. PWND pwnd;
  474. PACTIVATION_CONTEXT pActCtx;
  475. } CALLBACKWND, *PCALLBACKWND;
  476. #define CVKKEYCACHE 32
  477. #define CBKEYCACHE (CVKKEYCACHE >> 2)
  478. #define CVKASYNCKEYCACHE 32
  479. #define CBASYNCKEYCACHE (CVKASYNCKEYCACHE >> 2)
  480. /*
  481. * The offset to cSpins must match WIN32_CLIENT_INFO_SPIN_COUNT defined
  482. * in ntpsapi.h. GDI uses this offset to reset the spin count. WARNING!
  483. * This struct must fit in the TEB::Win32ClientInfo field.
  484. */
  485. typedef struct tagCLIENTINFO {
  486. KERNEL_ULONG_PTR CI_flags; // Needs to be first because CSR sets this
  487. KERNEL_ULONG_PTR cSpins; // GDI resets this
  488. DWORD dwExpWinVer;
  489. DWORD dwCompatFlags;
  490. DWORD dwCompatFlags2;
  491. DWORD dwTIFlags;
  492. PDESKTOPINFO pDeskInfo;
  493. KERNEL_ULONG_PTR ulClientDelta;
  494. PHOOK phkCurrent;
  495. DWORD fsHooks;
  496. CALLBACKWND CallbackWnd;
  497. DWORD dwHookCurrent;
  498. int cInDDEMLCallback;
  499. PCLIENTTHREADINFO pClientThreadInfo;
  500. KERNEL_ULONG_PTR dwHookData;
  501. DWORD dwKeyCache;
  502. BYTE afKeyState[CBKEYCACHE];
  503. DWORD dwAsyncKeyCache;
  504. BYTE afAsyncKeyState[CBASYNCKEYCACHE];
  505. BYTE afAsyncKeyStateRecentDown[CBASYNCKEYCACHE];
  506. KHKL hKL;
  507. WORD CodePage;
  508. BYTE achDbcsCF[2]; // Save ANSI DBCS LeadByte character code
  509. // in this field for ANSI to Unicode.
  510. // Uses SendMessageA/PostMessageA from CLIENT
  511. // to SERVER (index 0)
  512. // And...
  513. // Uses SendMessageA/DispatchMessageA
  514. // for CLIENT to CLIENT (index 1)
  515. KERNEL_MSG msgDbcsCB; // Save ANSI DBCS character message in
  516. // this field for convert Unicode to ANSI.
  517. // Uses GetMessageA/PeekMessageA from
  518. // SERVER to CLIENT
  519. LPBOOL lpClassesRegistered;
  520. } CLIENTINFO, *PCLIENTINFO;
  521. #define CI_IN_SYNC_TRANSACTION 0x00000001
  522. #define CI_PROCESSING_QUEUE 0x00000002
  523. #define CI_16BIT 0x00000004
  524. #define CI_INITIALIZED 0x00000008
  525. #define CI_INTERTHREAD_HOOK 0x00000010
  526. #define CI_REGISTERCLASSES 0x00000020
  527. #define CI_INPUTCONTEXT_REINIT 0x00000040
  528. #ifdef CUAS_ENABLE
  529. #define CI_CUAS_COINIT_CALLED 0x00000080 /* CoInit is called for CUAS */
  530. #define CI_CUAS_TIM_ACTIVATED 0x00000100 /* Tim activate for CUAS */
  531. #define CI_CUAS_MSCTF_RUNNING 0x00000200 /* Msctf (hooks) is running in the thread */
  532. #define CI_CUAS_DISABLE 0x00000400 /* Disable CUAS on thread */
  533. #define CI_CUAS_AIMM12ACTIVATED 0x00000800
  534. #endif // CUAS_ENABLE
  535. /*
  536. * THREAD_CODEPAGE()
  537. *
  538. * Returns the CodePage based on the current keyboard layout.
  539. */
  540. #ifndef _USERK_
  541. #define THREAD_CODEPAGE() (GetClientInfo()->CodePage)
  542. #endif // _USERK_
  543. // WMCR_IR_DBCSCHAR and DBCS Macros
  544. /*
  545. * Flags used for the WM_CHAR HIWORD of wParam for DBCS messaging.
  546. * (LOWORD of wParam will have character codepoint)
  547. */
  548. #define WMCR_IR_DBCSCHAR 0x80000000
  549. /*
  550. * Macros to determine this is DBCS message or not.
  551. */
  552. #define IS_DBCS_MESSAGE(DbcsChar) (((DWORD)(DbcsChar)) & 0x0000FF00)
  553. /*
  554. * Macros for IR_DBCSCHAR format to/from regular format.
  555. */
  556. #define MAKE_IR_DBCSCHAR(DbcsChar) \
  557. (IS_DBCS_MESSAGE((DbcsChar)) ? \
  558. (MAKEWPARAM(MAKEWORD(HIBYTE((DbcsChar)),LOBYTE((DbcsChar))),0)) : \
  559. ((WPARAM)((DbcsChar) & 0x00FF)) \
  560. )
  561. #define MAKE_WPARAM_DBCSCHAR(DbcsChar) \
  562. (IS_DBCS_MESSAGE((DbcsChar)) ? \
  563. (MAKEWPARAM(MAKEWORD(HIBYTE((DbcsChar)),LOBYTE((DbcsChar))),0)) : \
  564. ((WPARAM)((DbcsChar) & 0x00FF)) \
  565. )
  566. #define DBCS_CHARSIZE (2)
  567. #define IS_DBCS_ENABLED() (TEST_SRVIF(SRVIF_DBCS))
  568. #define _IS_IME_ENABLED() (TEST_SRVIF(SRVIF_IME))
  569. #ifdef _IMMCLI_
  570. #define IS_IME_ENABLED() (gpsi && _IS_IME_ENABLED())
  571. #else // _IMMCLI_
  572. #define IS_IME_ENABLED() _IS_IME_ENABLED()
  573. #endif // _IMMCLI_
  574. #ifdef CUAS_ENABLE
  575. #define _IS_CICERO_ENABLED() (TEST_SRVIF(SRVIF_CTFIME_ENABLED))
  576. #ifdef _IMMCLI_
  577. #define IS_CICERO_ENABLED() (gpsi && _IS_CICERO_ENABLED())
  578. #define IS_CICERO_ENABLED_AND_NOT16BIT() \
  579. (IS_CICERO_ENABLED() && !(GetClientInfo()->dwTIFlags & TIF_16BIT))
  580. #else // _IMMCLI_
  581. #define IS_CICERO_ENABLED() _IS_CICERO_ENABLED()
  582. #define IS_CICERO_ENABLED_AND_NOT16BIT() \
  583. (IS_CICERO_ENABLED() && !(PtiCurrent()->TIF_flags & TIF_16BIT))
  584. #endif // _IMMCLI_
  585. #endif // CUAS_ENABLE
  586. #ifndef IS_IME_KBDLAYOUT
  587. #define IS_IME_KBDLAYOUT(hkl) ((HIWORD((ULONG_PTR)(hkl)) & 0xf000) == 0xe000)
  588. #endif
  589. #define CP_JAPANESE (932)
  590. #define CP_KOREAN (949)
  591. #define CP_CHINESE_SIMP (936)
  592. #define CP_CHINESE_TRAD (950)
  593. #define IS_DBCS_CODEPAGE(wCodePage) \
  594. ((wCodePage) == CP_JAPANESE || \
  595. (wCodePage) == CP_KOREAN || \
  596. (wCodePage) == CP_CHINESE_TRAD || \
  597. (wCodePage) == CP_CHINESE_SIMP)
  598. #define IS_DBCS_CHARSET(charset) \
  599. ((charset) == SHIFTJIS_CHARSET || \
  600. (charset) == HANGEUL_CHARSET || \
  601. (charset) == CHINESEBIG5_CHARSET || \
  602. (charset) == GB2312_CHARSET)
  603. #define IS_JPN_1BYTE_KATAKANA(c) ((c) >= 0xa1 && (c) <= 0xdf)
  604. /*
  605. * Dynamic layout switching
  606. */
  607. typedef struct tagKBDTABLE_MULT_INTERNAL {
  608. KBDTABLE_MULTI multi;
  609. WCHAR wszDllName[32]; // main dll name
  610. struct {
  611. KHANDLE hFile;
  612. WORD wTable;
  613. WORD wNls;
  614. } files[KBDTABLE_MULTI_MAX];
  615. } KBDTABLE_MULTI_INTERNAL, *PKBDTABLE_MULTI_INTERNAL;
  616. // IMM dynamic loading support
  617. #define IMM_MAGIC_CALLER_ID (0x19650412)
  618. BOOL User32InitializeImmEntryTable(DWORD dwMagic);
  619. #define IS_MIDEAST_ENABLED() (TEST_SRVIF(SRVIF_MIDEAST))
  620. /*
  621. * Flags used for the WM_CLIENTSHUTDOWN wParam.
  622. */
  623. #define WMCS_EXIT 0x0001
  624. #define WMCS_QUERYEND 0x0002
  625. #define WMCS_SHUTDOWN 0x0004
  626. #define WMCS_CONTEXTLOGOFF 0x0008
  627. #define WMCS_ENDTASK 0x0010
  628. #define WMCS_CONSOLE 0x0020
  629. #define WMCS_NODLGIFHUNG 0x0040
  630. #define WMCS_NORETRY 0x0080
  631. #define WMCS_LOGOFF ENDSESSION_LOGOFF /* from winuser.w */
  632. /*
  633. * WM_CLIENTSHUTDOWN return value
  634. */
  635. #define WMCSR_ALLOWSHUTDOWN 1
  636. #define WMCSR_DONE 2
  637. #define WMCSR_CANCEL 3
  638. /*
  639. * We don't need 64-bit intermediate precision so we use this macro
  640. * instead of calling MulDiv.
  641. */
  642. #define MultDiv(x, y, z) (((INT)(x) * (INT)(y) + (INT)(z) / 2) / (INT)(z))
  643. typedef DWORD ICH, *LPICH;
  644. typedef struct _PROPSET {
  645. KHANDLE hData;
  646. ATOM atom;
  647. } PROPSET, *PPROPSET;
  648. /*
  649. * Internal menu flags stored in pMenu->fFlags.
  650. * High order bits are used for public MNS_ flags defined in winuser.w
  651. */
  652. #define MFISPOPUP 0x00000001
  653. #define MFMULTIROW 0x00000002
  654. #define MFUNDERLINE 0x00000004
  655. #define MFWINDOWDC 0x00000008 /* Window DC vs Client area DC when drawing*/
  656. #define MFINACTIVE 0x00000010
  657. #define MFRTL 0x00000020
  658. #define MFDESKTOP 0x00000040 /* Set on the desktop menu AND its submenus */
  659. #define MFSYSMENU 0x00000080 /* Set on desktop menu but NOT on its submenus */
  660. #define MFAPPSYSMENU 0x00000100 /* Set on (sub)menu we return to the app via GetSystemMenu */
  661. #define MFREADONLY 0x00000200 /* Menu cannot be modified */
  662. #define MFLAST 0x00000200
  663. #if (MNS_LAST <= MFLAST)
  664. #error MNS_ AND MF defines conflict
  665. #endif // (MNS_LAST <= MFLAST)
  666. // Event stuff --------------------------------------------
  667. typedef struct tagEVENT_PACKET {
  668. DWORD EventType; // == apropriate afCmd filter flag
  669. WORD fSense; // TRUE means flag on is passed.
  670. WORD cbEventData; // size of data starting at Data field.
  671. DWORD Data; // event specific data - must be last
  672. } EVENT_PACKET, *PEVENT_PACKET;
  673. // Window long offsets in mother window (szDDEMLMOTHERCLASS)
  674. #define GWLP_INSTANCE_INFO 0 // PCL_INSTANCE_INFO
  675. // Window long offsets in client window (szDDEMLCLIENTCLASS)
  676. #define GWLP_PCI 0
  677. #define GWL_CONVCONTEXT GWLP_PCI + sizeof(PVOID)
  678. #define GWL_CONVSTATE GWL_CONVCONTEXT + sizeof(CONVCONTEXT) // See CLST_ flags
  679. #define GWLP_SHINST GWL_CONVSTATE + sizeof(LONG)
  680. #define GWLP_CHINST GWLP_SHINST + sizeof(HANDLE)
  681. #define CLST_CONNECTED 0
  682. #define CLST_SINGLE_INITIALIZING 1
  683. #define CLST_MULT_INITIALIZING 2
  684. // Window long offsets in server window (szDDEMLSERVERCLASS)
  685. #define GWLP_PSI 0
  686. // Window long offsets in event window (szDDEMLEVENTCLASS)
  687. #define GWLP_PSII 0
  688. /*
  689. * DrawFrame defines
  690. */
  691. #define DF_SHIFT0 0x0000
  692. #define DF_SHIFT1 0x0001
  693. #define DF_SHIFT2 0x0002
  694. #define DF_SHIFT3 0x0003
  695. #define DF_PATCOPY 0x0000
  696. #define DF_PATINVERT 0x0004
  697. #define DF_SHIFTMASK (DF_SHIFT0 | DF_SHIFT1 | DF_SHIFT2 | DF_SHIFT3)
  698. #define DF_ROPMASK (DF_PATCOPY | DF_PATINVERT)
  699. #define DF_HBRMASK ~(DF_SHIFTMASK | DF_ROPMASK)
  700. #define DF_SCROLLBAR (COLOR_SCROLLBAR << 3)
  701. #define DF_BACKGROUND (COLOR_BACKGROUND << 3)
  702. #define DF_ACTIVECAPTION (COLOR_ACTIVECAPTION << 3)
  703. #define DF_INACTIVECAPTION (COLOR_INACTIVECAPTION << 3)
  704. #define DF_MENU (COLOR_MENU << 3)
  705. #define DF_WINDOW (COLOR_WINDOW << 3)
  706. #define DF_WINDOWFRAME (COLOR_WINDOWFRAME << 3)
  707. #define DF_MENUTEXT (COLOR_MENUTEXT << 3)
  708. #define DF_WINDOWTEXT (COLOR_WINDOWTEXT << 3)
  709. #define DF_CAPTIONTEXT (COLOR_CAPTIONTEXT << 3)
  710. #define DF_ACTIVEBORDER (COLOR_ACTIVEBORDER << 3)
  711. #define DF_INACTIVEBORDER (COLOR_INACTIVEBORDER << 3)
  712. #define DF_APPWORKSPACE (COLOR_APPWORKSPACE << 3)
  713. #define DF_3DSHADOW (COLOR_3DSHADOW << 3)
  714. #define DF_3DFACE (COLOR_3DFACE << 3)
  715. #define DF_GRAY (COLOR_MAX << 3)
  716. /*
  717. * CreateWindowEx internal flags for dwExStyle
  718. */
  719. #define WS_EX_MDICHILD 0x00000040L // Internal
  720. #define WS_EX_ANSICREATOR 0x80000000L // Internal
  721. /*
  722. * These flags are used in the internal version of NtUserFindWindowEx
  723. */
  724. #define FW_BOTH 0
  725. #define FW_16BIT 1
  726. #define FW_32BIT 2
  727. /*
  728. * Calculate the size of a field in a structure of type type.
  729. */
  730. #define FIELD_SIZE(type, field) (sizeof(((type *)0)->field))
  731. #define FLASTKEY 0x80
  732. /*
  733. * Special types we've fabricated for special thunks.
  734. */
  735. typedef struct {
  736. POINT point1;
  737. POINT point2;
  738. POINT point3;
  739. POINT point4;
  740. POINT point5;
  741. } POINT5, *LPPOINT5;
  742. typedef struct {
  743. DWORD dwRecipients;
  744. DWORD dwFlags;
  745. BSMINFO;
  746. } BROADCASTSYSTEMMSGPARAMS, *LPBROADCASTSYSTEMMSGPARAMS;
  747. /*
  748. * Server side address constants. When we want to call a server side proc,
  749. * we pass an index indentifying the function, rather than the server side
  750. * address itself. More robust. The functions between WNDPROCSTART/END
  751. * have client side stubs which map to this routines.
  752. *
  753. * Adding a new FNID (This is just what I figured out...so fix it if wrong or incomplete)
  754. * -Decide what range it should be in:
  755. * FNID_WNDPROCSTART to FNID_WNDPROCEND: Server side proc with client
  756. * stub
  757. * FIND_CONTROLSTART to FNID_CONTROLEND: Client side controls with no
  758. * server side proc
  759. * After FNID_CONTROLEND: other, like server side only procs or client
  760. * side only....
  761. * -Make sure to adjust FNID_*START and FNID_*END appropriately here and in wowuserp.w.
  762. * -If the ID is to be associated with a window class, and it is for all
  763. * windows of that class, make sure that the InternalRegisterClassEx call
  764. * receives the id as a parameter.
  765. * -If in FNID_WNDPROCSTART-END range, make the proper STOCID call in InitFunctionTables.
  766. * -Add proper FNID call in InitFunctionTables.
  767. * -If the class has a client side worker function (pcls->lpfnWorker) or you expect
  768. * apps to send messages to it or call its window proc directly, define
  769. * a message table in kernel\server.c and initialize it in InitMessageTables.
  770. * -Add a new entry to the PFNCLIENT and matching entries in clinet\clinet.c pfnClientA and
  771. * pfnClientW arrays.
  772. * -Add the debug-only text description of this FNID to in gapszFNID in globals.c
  773. * -Modify aiClassWow in client\client.c
  774. * -Modify the gaFNIDtoICLS table in kernel\ntstubs.c
  775. */
  776. #define FNID_START 0x0000029A
  777. #define FNID_WNDPROCSTART 0x0000029A
  778. #define FNID_SCROLLBAR 0x0000029A // xxxSBWndProc;
  779. #define FNID_ICONTITLE 0x0000029B // xxxDefWindowProc;
  780. #define FNID_MENU 0x0000029C // xxxMenuWindowProc;
  781. #define FNID_DESKTOP 0x0000029D // xxxDesktopWndProc;
  782. #define FNID_DEFWINDOWPROC 0x0000029E // xxxDefWindowProc;
  783. #define FNID_MESSAGEWND 0x0000029F // xxxDefWindowProc;
  784. #define FNID_SWITCH 0x000002A0 // xxxSwitchWndProc
  785. #define FNID_WNDPROCEND 0x000002A0 // see PatchThreadWindows
  786. #define FNID_CONTROLSTART 0x000002A1
  787. #define FNID_BUTTON 0x000002A1 // No server side proc
  788. #define FNID_COMBOBOX 0x000002A2 // No server side proc
  789. #define FNID_COMBOLISTBOX 0x000002A3 // No server side proc
  790. #define FNID_DIALOG 0x000002A4 // No server side proc
  791. #define FNID_EDIT 0x000002A5 // No server side proc
  792. #define FNID_LISTBOX 0x000002A6 // No server side proc
  793. #define FNID_MDICLIENT 0x000002A7 // No server side proc
  794. #define FNID_STATIC 0x000002A8 // No server side proc
  795. #define FNID_IME 0x000002A9 // No server side proc
  796. #define FNID_CONTROLEND 0x000002A9
  797. #define FNID_HKINLPCWPEXSTRUCT 0x000002AA
  798. #define FNID_HKINLPCWPRETEXSTRUCT 0x000002AB
  799. #define FNID_DEFFRAMEPROC 0x000002AC // No server side proc
  800. #define FNID_DEFMDICHILDPROC 0x000002AD // No server side proc
  801. #define FNID_MB_DLGPROC 0x000002AE // No server side proc
  802. #define FNID_MDIACTIVATEDLGPROC 0x000002AF // No server side proc
  803. #define FNID_SENDMESSAGE 0x000002B0
  804. #define FNID_SENDMESSAGEFF 0x000002B1
  805. #define FNID_SENDMESSAGEEX 0x000002B2
  806. #define FNID_CALLWINDOWPROC 0x000002B3
  807. #define FNID_SENDMESSAGEBSM 0x000002B4
  808. #define FNID_TOOLTIP 0x000002B5
  809. #define FNID_GHOST 0x000002B6
  810. #define FNID_SENDNOTIFYMESSAGE 0x000002B7
  811. #define FNID_SENDMESSAGECALLBACK 0x000002B8
  812. #define FNID_END 0x000002B8
  813. /*
  814. * The size of the server side function table is defined as a power of two
  815. * so a simple "and" operation can be used to determine if a function index
  816. * is legal or not. Unused entries in the table are fill with a routine that
  817. * catches invalid functions that have indices within range, but are not
  818. * implemented.
  819. */
  820. #define FNID_ARRAY_SIZE 32
  821. #if (FNID_END - FNID_START + 1) > FNID_ARRAY_SIZE
  822. #error"The size of the function array is greater than the allocated storage"
  823. #endif // (FNID_END - FNID_START + 1) > FNID_ARRAY_SIZE
  824. #define FNID_DDE_BIT 0x00002000 // Used by RegisterClassExWOW
  825. #define FNID_CLEANEDUP_BIT 0x00004000
  826. #define FNID_DELETED_BIT 0x00008000
  827. #define FNID_STATUS_BITS (FNID_CLEANEDUP_BIT | FNID_DELETED_BIT)
  828. #define FNID(s) (gpsi->mpFnidPfn[((DWORD)(s) - FNID_START) & (FNID_ARRAY_SIZE - 1)])
  829. #define STOCID(s) (gpsi->aStoCidPfn[(DWORD)((s) & ~FNID_STATUS_BITS) - FNID_START])
  830. #define CBFNID(s) (gpsi->mpFnid_serverCBWndProc[(DWORD)((s) & ~FNID_STATUS_BITS) - FNID_START])
  831. #define GETFNID(pwnd) ((pwnd)->fnid & ~FNID_STATUS_BITS)
  832. #ifndef BUILD_WOW6432
  833. typedef LRESULT (APIENTRY * WNDPROC_PWND)(PWND, UINT, WPARAM, LPARAM);
  834. typedef LRESULT (APIENTRY * WNDPROC_PWNDEX)(PWND, UINT, WPARAM, LPARAM, ULONG_PTR);
  835. #else
  836. typedef KERNEL_PVOID WNDPROC_PWND;
  837. typedef KERNEL_PVOID WNDPROC_PWNDEX;
  838. #endif
  839. typedef BOOL (APIENTRY * WNDENUMPROC_PWND)(PWND, LPARAM);
  840. typedef VOID (APIENTRY * TIMERPROC_PWND)(PWND, UINT, UINT_PTR, LPARAM);
  841. /*
  842. * Structure passed by client during process initialization that holds some
  843. * client-side callback addresses.
  844. */
  845. typedef struct _PFNCLIENT {
  846. KPROC pfnScrollBarWndProc; // and must be paired Unicode then ANSI
  847. KPROC pfnTitleWndProc;
  848. KPROC pfnMenuWndProc;
  849. KPROC pfnDesktopWndProc;
  850. KPROC pfnDefWindowProc;
  851. KPROC pfnMessageWindowProc;
  852. KPROC pfnSwitchWindowProc;
  853. // Below not in FNID_WNDPROCSTART FNID_WNDPROCEND range
  854. KPROC pfnButtonWndProc;
  855. KPROC pfnComboBoxWndProc;
  856. KPROC pfnComboListBoxProc;
  857. KPROC pfnDialogWndProc;
  858. KPROC pfnEditWndProc;
  859. KPROC pfnListBoxWndProc;
  860. KPROC pfnMDIClientWndProc;
  861. KPROC pfnStaticWndProc;
  862. KPROC pfnImeWndProc;
  863. // Below not in FNID_CONTROLSTART FNID_CONTROLEND range
  864. KPROC pfnHkINLPCWPSTRUCT; // client-side callback for hook thunks
  865. KPROC pfnHkINLPCWPRETSTRUCT; // client-side callback for hook thunks
  866. KPROC pfnDispatchHook;
  867. KPROC pfnDispatchDefWindowProc;
  868. KPROC pfnDispatchMessage;
  869. KPROC pfnMDIActivateDlgProc;
  870. } PFNCLIENT, *PPFNCLIENT;
  871. typedef struct _PFNCLIENTWORKER {
  872. KPROC pfnButtonWndProc;
  873. KPROC pfnComboBoxWndProc;
  874. KPROC pfnComboListBoxProc;
  875. KPROC pfnDialogWndProc;
  876. KPROC pfnEditWndProc;
  877. KPROC pfnListBoxWndProc;
  878. KPROC pfnMDIClientWndProc;
  879. KPROC pfnStaticWndProc;
  880. KPROC pfnImeWndProc;
  881. } PFNCLIENTWORKER, *PPFNCLIENTWORKER;
  882. #ifdef BUILD_WOW6432
  883. extern const PFNCLIENT pfnClientA;
  884. extern const PFNCLIENT pfnClientW;
  885. extern const PFNCLIENTWORKER pfnClientWorker;
  886. #define FNID_TO_CLIENT_PFNA_CLIENT(s) ((ULONG_PTR)(*(((KERNEL_ULONG_PTR *)&pfnClientA) + (s - FNID_START))))
  887. #define FNID_TO_CLIENT_PFNW_CLIENT(s) ((ULONG_PTR)(*(((KERNEL_ULONG_PTR *)&pfnClientW) + (s - FNID_START))))
  888. #define FNID_TO_CLIENT_PFNWORKER(s) ((ULONG_PTR)(*(((KERNEL_ULONG_PTR *)&pfnClientWorker) + (s - FNID_CONTROLSTART))))
  889. WNDPROC_PWND MapKernelClientFnToClientFn(WNDPROC_PWND lpfnWndProc);
  890. #else
  891. #define FNID_TO_CLIENT_PFNA_CLIENT FNID_TO_CLIENT_PFNA_KERNEL
  892. #define FNID_TO_CLIENT_PFNW_CLIENT FNID_TO_CLIENT_PFNW_KERNEL
  893. #define FNID_TO_CLIENT_PFNWORKER(s) (*(((KERNEL_ULONG_PTR *)&gpsi->apfnClientWorker) + (s - FNID_CONTROLSTART)))
  894. #define MapKernelClientFnToClientFn(lpfnWndProc) (lpfnWndProc)
  895. #endif
  896. #define FNID_TO_CLIENT_PFNA_KERNEL(s) (*(((KERNEL_ULONG_PTR * KPTR_MODIFIER)&gpsi->apfnClientA) + (s - FNID_START)))
  897. #define FNID_TO_CLIENT_PFNW_KERNEL(s) (*(((KERNEL_ULONG_PTR * KPTR_MODIFIER)&gpsi->apfnClientW) + (s - FNID_START)))
  898. #define FNID_TO_CLIENT_PFNA FNID_TO_CLIENT_PFNA_KERNEL
  899. #define FNID_TO_CLIENT_PFNW FNID_TO_CLIENT_PFNW_KERNEL
  900. /*
  901. * Object types
  902. *
  903. * NOTE: Changing this table means changing hard-coded arrays that depend
  904. * on the index number (in security.c and in debug.c)
  905. */
  906. #define TYPE_FREE 0 // must be zero!
  907. #define TYPE_WINDOW 1 // in order of use for C code lookups
  908. #define TYPE_MENU 2
  909. #define TYPE_CURSOR 3
  910. #define TYPE_SETWINDOWPOS 4
  911. #define TYPE_HOOK 5
  912. #define TYPE_CLIPDATA 6 // clipboard data
  913. #define TYPE_CALLPROC 7
  914. #define TYPE_ACCELTABLE 8
  915. #define TYPE_DDEACCESS 9
  916. #define TYPE_DDECONV 10
  917. #define TYPE_DDEXACT 11 // DDE transaction tracking info.
  918. #define TYPE_MONITOR 12
  919. #define TYPE_KBDLAYOUT 13 // Keyboard Layout handle (HKL) object.
  920. #define TYPE_KBDFILE 14 // Keyboard Layout file object.
  921. #define TYPE_WINEVENTHOOK 15 // WinEvent hook (EVENTHOOK)
  922. #define TYPE_TIMER 16
  923. #define TYPE_INPUTCONTEXT 17 // Input Context info structure
  924. #define TYPE_HIDDATA 18
  925. #define TYPE_DEVICEINFO 19
  926. #define TYPE_CTYPES 20 // Count of TYPEs; Must be LAST + 1
  927. #define TYPE_GENERIC 255 // used for generic handle validation
  928. /* OEM Bitmap Information Structure */
  929. typedef struct tagOEMBITMAPINFO
  930. {
  931. int x;
  932. int y;
  933. int cx;
  934. int cy;
  935. } OEMBITMAPINFO, * KPTR_MODIFIER POEMBITMAPINFO;
  936. // For the following OBI_ defines :
  937. //
  938. // a pushed state bitmap should be at +1 from it's normal state bitmap
  939. // an inactive state bitmap should be at +2 from it's normal state bitmap
  940. // A small caption bitmap should be +2 from the normal bitmap
  941. #define DOBI_NORMAL 0
  942. #define DOBI_PUSHED 1
  943. #define DOBI_HOT 2
  944. #define DOBI_INACTIVE 3
  945. #define DOBI_CHECK 1 // checkbox/radio/3state button states
  946. #define DOBI_DOWN 2
  947. #define DOBI_CHECKDOWN 3
  948. #define DOBI_CAPON 0 // caption states
  949. #define DOBI_CAPOFF 1
  950. // shared bitmap mappings
  951. #define DOBI_3STATE 8 // offset from checkbox to 3state
  952. #define DOBI_MBAR OBI_CLOSE_MBAR // offset to menu bar equivalent
  953. #define OBI_CLOSE 0 // caption close button
  954. #define OBI_CLOSE_D 1
  955. #define OBI_CLOSE_H 2
  956. #define OBI_CLOSE_I 3
  957. #define OBI_REDUCE 4 // caption minimize button
  958. #define OBI_REDUCE_D 5
  959. #define OBI_REDUCE_H 6
  960. #define OBI_REDUCE_I 7
  961. #define OBI_RESTORE 8 // caption restore button
  962. #define OBI_RESTORE_D 9
  963. #define OBI_RESTORE_H 10
  964. #define OBI_HELP 11
  965. #define OBI_HELP_D 12
  966. #define OBI_HELP_H 13
  967. #define OBI_ZOOM 14 // caption maximize button
  968. #define OBI_ZOOM_D 15
  969. #define OBI_ZOOM_H 16
  970. #define OBI_ZOOM_I 17
  971. #define OBI_CLOSE_MBAR 18 // menu bar close button
  972. #define OBI_CLOSE_MBAR_D 19
  973. #define OBI_CLOSE_MBAR_H 20
  974. #define OBI_CLOSE_MBAR_I 21
  975. #define OBI_REDUCE_MBAR 22 // menu bar minimize button
  976. #define OBI_REDUCE_MBAR_D 23
  977. #define OBI_REDUCE_MBAR_H 24
  978. #define OBI_REDUCE_MBAR_I 25
  979. #define OBI_RESTORE_MBAR 26 // menu bar restore button
  980. #define OBI_RESTORE_MBAR_D 27
  981. #define OBI_RESTORE_MBAR_H 28
  982. #define OBI_CAPCACHE1 29 // caption icon cache entry #1
  983. #define OBI_CAPCACHE1_I 30
  984. #define OBI_CAPCACHE2 31 // caption icon cache entry #2
  985. #define OBI_CAPCACHE2_I 32
  986. #define OBI_CAPCACHE3 33 // caption icon cache entry #3
  987. #define OBI_CAPCACHE3_I 34
  988. #define OBI_CAPCACHE4 35 // caption icon cache entry #4
  989. #define OBI_CAPCACHE4_I 36
  990. #define OBI_CAPCACHE5 37 // caption icon cache entry #5
  991. #define OBI_CAPCACHE5_I 38
  992. #define OBI_CAPBTNS 39 // caption buttons cache
  993. #define OBI_CAPBTNS_I 40
  994. #define OBI_CLOSE_PAL 41 // small caption close button
  995. #define OBI_CLOSE_PAL_D 42
  996. #define OBI_CLOSE_PAL_H 43
  997. #define OBI_CLOSE_PAL_I 44
  998. #define OBI_NCGRIP 45 // bottom/right size grip
  999. #define OBI_UPARROW 46 // up scroll arrow
  1000. #define OBI_UPARROW_D 47
  1001. #define OBI_UPARROW_H 48
  1002. #define OBI_UPARROW_I 49
  1003. #define OBI_DNARROW 50 // down scroll arrow
  1004. #define OBI_DNARROW_D 51
  1005. #define OBI_DNARROW_H 52
  1006. #define OBI_DNARROW_I 53
  1007. #define OBI_RGARROW 54 // right scroll arrow
  1008. #define OBI_RGARROW_D 55
  1009. #define OBI_RGARROW_H 56
  1010. #define OBI_RGARROW_I 57
  1011. #define OBI_LFARROW 58 // left scroll arrow
  1012. #define OBI_LFARROW_D 59
  1013. #define OBI_LFARROW_H 60
  1014. #define OBI_LFARROW_I 61
  1015. #define OBI_MENUARROW 62 // menu hierarchy arrow
  1016. #define OBI_MENUCHECK 63 // menu check mark
  1017. #define OBI_MENUBULLET 64 // menu bullet mark
  1018. #define OBI_MENUARROWUP 65
  1019. #define OBI_MENUARROWUP_H 66
  1020. #define OBI_MENUARROWUP_I 67
  1021. #define OBI_MENUARROWDOWN 68
  1022. #define OBI_MENUARROWDOWN_H 69
  1023. #define OBI_MENUARROWDOWN_I 70
  1024. #define OBI_RADIOMASK 71 // radio button mask
  1025. #define OBI_CHECK 72 // check box
  1026. #define OBI_CHECK_C 73
  1027. #define OBI_CHECK_D 74
  1028. #define OBI_CHECK_CD 75
  1029. #define OBI_CHECK_CDI 76
  1030. #define OBI_RADIO 77 // radio button
  1031. #define OBI_RADIO_C 78
  1032. #define OBI_RADIO_D 79
  1033. #define OBI_RADIO_CD 80
  1034. #define OBI_RADIO_CDI 81
  1035. #define OBI_3STATE 82 // 3-state button
  1036. #define OBI_3STATE_C 83
  1037. #define OBI_3STATE_D 84
  1038. #define OBI_3STATE_CD 85
  1039. #define OBI_3STATE_CDI 86
  1040. #define OBI_POPUPFIRST 87 // System popupmenu bitmaps.
  1041. #define OBI_CLOSE_POPUP 87
  1042. #define OBI_RESTORE_POPUP 88
  1043. #define OBI_ZOOM_POPUP 89
  1044. #define OBI_REDUCE_POPUP 90
  1045. #define OBI_NCGRIP_L 91
  1046. #define OBI_MENUARROW_L 92
  1047. #define OBI_COUNT 93 // bitmap count
  1048. /*
  1049. * One global instance of this structure is allocated into memory that is
  1050. * mapped into all clients' address space. Client-side functions will
  1051. * read this data to avoid calling the server.
  1052. */
  1053. #define NCHARS 256
  1054. #define NCTRLS 0x20
  1055. #define PUSIF_PALETTEDISPLAY 0x00000001 /* Is the display palettized? */
  1056. #define PUSIF_SNAPTO 0x00000002 /* Is SnapTo enabled? */
  1057. #define PUSIF_COMBOBOXANIMATION 0x00000004 /* Must match UPBOOLMask(SPI_GETCOMBOBOXANIMATION) */
  1058. #define PUSIF_LISTBOXSMOOTHSCROLLING 0x00000008 /* Must match UPBOOLMask(SPI_GETLISTBOXSMOOTHSCROLLING) */
  1059. #define PUSIF_KEYBOARDCUES 0x00000020 /* Must match UPBOOLMask(SPI_GETKEYBOARDCUES) */
  1060. #define PUSIF_UIEFFECTS 0x80000000 /* Must match UPBOOLMask(SPI_GETUIEFFECTS) */
  1061. #define TEST_PUSIF(f) TEST_FLAG(gpsi->PUSIFlags, f)
  1062. #define TEST_BOOL_PUSIF(f) TEST_BOOL_FLAG(gpsi->PUSIFlags, f)
  1063. #define SET_PUSIF(f) SET_FLAG(gpsi->PUSIFlags, f)
  1064. #define CLEAR_PUSIF(f) CLEAR_FLAG(gpsi->PUSIFlags, f)
  1065. #define SET_OR_CLEAR_PUSIF(f, fSet) SET_OR_CLEAR_FLAG(gpsi->PUSIFlags, f, fSet)
  1066. #define TOGGLE_PUSIF(f) TOGGLE_FLAG(gpsi->PUSIFlags, f)
  1067. #define TEST_EffectPUSIF(f) \
  1068. ((gpsi->PUSIFlags & (f | PUSIF_UIEFFECTS)) == (f | PUSIF_UIEFFECTS))
  1069. /*
  1070. * Some UI effects have an "inverted" disabled value (ie, disabled is TRUE)
  1071. */
  1072. #define TEST_EffectInvertPUSIF(f) (TEST_PUSIF(f) || !TEST_PUSIF(PUSIF_UIEFFECTS))
  1073. /*
  1074. * System-wide last user input info on shared system page is updated
  1075. * by a session only if this many tick counts have elapsed since
  1076. * the last time the session updated it.
  1077. */
  1078. #define SYSTEM_RIT_EVENT_UPDATE_PERIOD (60 * 1000)
  1079. #define SRVIF_CHECKED 0x0001
  1080. #define SRVIF_DBCS 0x0002
  1081. #define SRVIF_IME 0x0004
  1082. #define SRVIF_MIDEAST 0x0008
  1083. #define SRVIF_HOOKED 0x0010
  1084. #ifdef CUAS_ENABLE
  1085. #define SRVIF_CTFIME_ENABLED 0x0020
  1086. #endif // CUAS_ENABLE
  1087. #define SRVIF_LASTRITWASKEYBOARD 0x0040
  1088. #define SRVIF_KEYBOARDPREF 0x0080
  1089. #define SRVIF_LOGDESKTOPHEAPFAILURE 0x0100
  1090. #define TEST_SRVIF(f) TEST_BOOL_FLAG(gpsi->dwSRVIFlags, f)
  1091. #define SET_SRVIF(f) SET_FLAG(gpsi->dwSRVIFlags, f)
  1092. #define CLEAR_SRVIF(f) CLEAR_FLAG(gpsi->dwSRVIFlags, f)
  1093. #define SET_OR_CLEAR_SRVIF(f, fSet) SET_OR_CLEAR_FLAG(gpsi->dwSRVIFlags, f, fSet)
  1094. #define TOGGLE_SRVIF(f) TOGGLE_FLAG(gpsi->dwSRVIFlags, f)
  1095. #define TEST_KbdCuesPUSIF (!TEST_SRVIF(SRVIF_KEYBOARDPREF) && \
  1096. !TEST_EffectInvertPUSIF(PUSIF_KEYBOARDCUES) && \
  1097. !(GetAppCompatFlags2(VER40) & GACF2_KCOFF))
  1098. typedef struct tagSERVERINFO {
  1099. DWORD dwSRVIFlags; // SRVIF_ flags
  1100. KERNEL_ULONG_PTR cHandleEntries; // count of handle entries in array
  1101. /*
  1102. * Array of server-side function pointers.
  1103. * Client passes servers function ID so they can be easily validated;
  1104. * this array maps function ID into server-side function address.
  1105. * The order of these are enforced by the FNID_ constants, and must match
  1106. * the client-side mpFnidClientPfn[] order as well.
  1107. */
  1108. WNDPROC_PWNDEX mpFnidPfn[FNID_ARRAY_SIZE]; // function mapping table
  1109. WNDPROC_PWND aStoCidPfn[(FNID_WNDPROCEND - FNID_START) + 1];
  1110. // mapping of fnid to min bytes need by public windproc user
  1111. WORD mpFnid_serverCBWndProc[(FNID_END - FNID_START) + 1];
  1112. /*
  1113. * Client side functions pointer structure.
  1114. */
  1115. struct _PFNCLIENT apfnClientA;
  1116. struct _PFNCLIENT apfnClientW;
  1117. struct _PFNCLIENTWORKER apfnClientWorker;
  1118. DWORD cbHandleTable;
  1119. /*
  1120. * Class atoms to allow fast checks on the client.
  1121. */
  1122. ATOM atomSysClass[ICLS_MAX]; // Atoms for control classes
  1123. DWORD dwDefaultHeapBase; // so WOW can do handle validation
  1124. DWORD dwDefaultHeapSize;
  1125. UINT uiShellMsg; // message for shell hooks
  1126. UINT wMaxBtnSize; /* Size of the longest button string in any MessageBox */
  1127. MBSTRING MBStrings[MAX_MB_STRINGS];
  1128. /*
  1129. * values to allow HasCaptionIcon to be in user32
  1130. */
  1131. ATOM atomIconSmProp;
  1132. ATOM atomIconProp;
  1133. ATOM atomContextHelpIdProp;
  1134. char acOemToAnsi[NCHARS];
  1135. char acAnsiToOem[NCHARS];
  1136. #ifdef LAME_BUTTON
  1137. /*
  1138. * button size
  1139. */
  1140. int ncxLame;
  1141. WCHAR gwszLame[50];
  1142. #endif // LAME_BUTTON
  1143. /*
  1144. * We track the WinEvent hooks that are installed for events by their
  1145. * event category. This is strictly an implementation detail, and is
  1146. * not exposed to the user. The user API is IsWinEventHookInstalled.
  1147. */
  1148. DWORD dwInstalledEventHooks;
  1149. int aiSysMet[SM_CMETRICS];
  1150. COLORREF argbSystemUnmatched[COLOR_MAX];
  1151. COLORREF argbSystem[COLOR_MAX];
  1152. KHBRUSH ahbrSystem[COLOR_MAX];
  1153. KHBRUSH hbrGray;
  1154. POINT ptCursor;
  1155. DWORD dwLastRITEventTickCount;
  1156. int nEvents;
  1157. int gclBorder; /* # of logical units in window frame */
  1158. UINT dtScroll;
  1159. UINT dtLBSearch;
  1160. UINT dtCaretBlink;
  1161. UINT ucWheelScrollLines;
  1162. int wMaxLeftOverlapChars;
  1163. int wMaxRightOverlapChars;
  1164. /*
  1165. * these are here to lose a thunk for GetDialogBaseUnits
  1166. */
  1167. int cxSysFontChar;
  1168. int cySysFontChar;
  1169. int cxMsgFontChar;
  1170. int cyMsgFontChar;
  1171. TEXTMETRICW tmSysFont;
  1172. /*
  1173. * values to allow HasCaptionIcon to be in user32
  1174. */
  1175. KHICON hIconSmWindows;
  1176. KHICON hIcoWindows;
  1177. KHFONT hCaptionFont;
  1178. KHFONT hMsgFont;
  1179. /*
  1180. * These are needed for various user-mode performance hacks.
  1181. */
  1182. DWORD dwKeyCache;
  1183. DWORD dwAsyncKeyCache;
  1184. DWORD cCaptures;
  1185. /*
  1186. * Information about the current state of the display which needs to
  1187. * be shared with the client side. The information here corresponds
  1188. * to the display in gpDispInfo. Note that much of this information
  1189. * is only for the primary monitor.
  1190. */
  1191. OEMBITMAPINFO oembmi[OBI_COUNT]; /* OEM bitmap information */
  1192. RECT rcScreen; /* rectangle of the virtual screen */
  1193. WORD BitCount; /* Planes * Depth */
  1194. WORD dmLogPixels; /* logical pixels per inch, both X and Y */
  1195. BYTE Planes; /* Planes */
  1196. BYTE BitsPixel; /* Depth */
  1197. DWORD PUSIFlags; // PUSIF_ flags
  1198. UINT uCaretWidth; /* caret width in edits */
  1199. LANGID UILangID; // Default UI language
  1200. /*
  1201. * TickCount when our session updated LastSystemRITEventTickCount on
  1202. * the shared system page that stands for the last RIT event time across
  1203. * all terminal sessions. For MP performance, it is not updated all
  1204. * the time.
  1205. */
  1206. DWORD dwLastSystemRITEventTickCountUpdate;
  1207. #if DBG
  1208. DWORD adwDBGTAGFlags[DBGTAG_Max + 1];
  1209. DWORD dwTagCount;
  1210. DWORD dwRIPFlags;
  1211. #endif
  1212. } SERVERINFO;
  1213. /*
  1214. * IS_BUTTON checks if the button is either our system button control or
  1215. * a fusionized one.
  1216. *
  1217. * To check for system button controls only, then use
  1218. * (GETFNID(pwnd) == FNID_BUTTON).
  1219. *
  1220. * IS_EDIT works similarly for edit controls and the system edit control
  1221. * can also be checked by (GETFNID(pwnd) == FNID_EDIT).
  1222. */
  1223. #ifdef _USERK_
  1224. #define REBASEALWAYS(p, elem) ((p)->elem)
  1225. #endif
  1226. #define IS_BUTTON(pwnd) (gpsi->atomSysClass[ICLS_BUTTON] == ((PCLS)REBASEALWAYS(pwnd, pcls))->atomNVClassName)
  1227. #define IS_EDIT(pwnd) (gpsi->atomSysClass[ICLS_EDIT] == ((PCLS)REBASEALWAYS(pwnd, pcls))->atomNVClassName)
  1228. /*
  1229. * Event Categories
  1230. * If you make any changes here, you must update the global variable geci,
  1231. * and the define EVENTCATEGORY_ALL!
  1232. */
  1233. #define EVENTCATEGORY_SYSTEM_MENU 0x0001
  1234. #define EVENTCATEGORY_CONSOLE 0x0002
  1235. #define EVENTCATEGORY_FOCUS 0x0004
  1236. #define EVENTCATEGORY_NAMECHANGE 0x0008
  1237. #define EVENTCATEGORY_VALUECHANGE 0x0010
  1238. #define EVENTCATEGORY_STATECHANGE 0x0020
  1239. #define EVENTCATEGORY_LOCATIONCHANGE 0x0040
  1240. #define EVENTCATEGORY_OTHER 0x8000
  1241. #define EVENTCATEGORY_ALL 0x807F
  1242. DWORD CategoryMaskFromEvent(DWORD event);
  1243. DWORD CategoryMaskFromEventRange(DWORD eventMin, DWORD eventMax);
  1244. /*
  1245. * Quick test for any Window Event Hooks.
  1246. */
  1247. #define FEVENTCATEGORYHOOKED(CategoryMask) (TEST_FLAG(gpsi->dwInstalledEventHooks, (CategoryMask)) ? TRUE : FALSE)
  1248. #define FEVENTHOOKED(Event) FEVENTCATEGORYHOOKED(CategoryMaskFromEvent(Event))
  1249. /* MessageBox String pointers from offset in the gpsi struct */
  1250. #define GETGPSIMBPSTR(u) KPWSTR_TO_PWSTR(gpsi->MBStrings[(u)].szName)
  1251. typedef struct _WNDMSG {
  1252. UINT maxMsgs;
  1253. KPBYTE abMsgs;
  1254. } WNDMSG, *PWNDMSG;
  1255. typedef struct tagSHAREDINFO {
  1256. PSERVERINFO psi;
  1257. PHE aheList; /* handle table pointer */
  1258. PDISPLAYINFO pDispInfo; /* global displayinfo */
  1259. KERNEL_UINT_PTR ulSharedDelta; /* delta between client and kernel mapping of ...*/
  1260. /* shared memory section. Only valid/used in client.*/
  1261. WNDMSG awmControl[FNID_END - FNID_START + 1];
  1262. WNDMSG DefWindowMsgs;
  1263. WNDMSG DefWindowSpecMsgs;
  1264. } SHAREDINFO, *PSHAREDINFO;
  1265. typedef struct _USERCONNECT {
  1266. IN ULONG ulVersion;
  1267. OUT ULONG ulCurrentVersion;
  1268. IN DWORD dwDispatchCount;
  1269. OUT SHAREDINFO siClient;
  1270. } USERCONNECT, *PUSERCONNECT;
  1271. #define USER_MAJOR_VERSION 0x0005
  1272. #define USER_MINOR_VERSION 0x0000
  1273. #define USERCURRENTVERSION MAKELONG(USER_MINOR_VERSION, USER_MAJOR_VERSION)
  1274. /*
  1275. * Options used for NtUserSetSysColors
  1276. */
  1277. #define SSCF_NOTIFY 0x00000001
  1278. #define SSCF_FORCESOLIDCOLOR 0x00000002
  1279. #define SSCF_SETMAGICCOLORS 0x00000004
  1280. #define SSCF_16COLORS 0x00000008
  1281. /*
  1282. * Structure used for GetClipboardData, where we can have
  1283. * extra information returned from the kernel.
  1284. */
  1285. typedef struct tagGETCLIPBDATA {
  1286. UINT uFmtRet; // Identifies returned format.
  1287. BOOL fGlobalHandle; // Indicates if handle is global.
  1288. union {
  1289. HANDLE hLocale; // Locale (text-type formats only).
  1290. HANDLE hPalette; // Palette (bitmap-type formats only).
  1291. };
  1292. } GETCLIPBDATA, *PGETCLIPBDATA;
  1293. /*
  1294. * Structure used for SetClipboardData, where we can have
  1295. * extra information passed to the kernel.
  1296. */
  1297. typedef struct tagSETCLIPBDATA {
  1298. BOOL fGlobalHandle; // Indicates if handle is global.
  1299. BOOL fIncSerialNumber; // Indicates if we should increment serial#
  1300. } SETCLIPBDATA, *PSETCLIPBDATA;
  1301. /*
  1302. * HM Object definition control flags
  1303. */
  1304. #define OCF_THREADOWNED 0x01
  1305. #define OCF_PROCESSOWNED 0x02
  1306. #define OCF_MARKPROCESS 0x04
  1307. #define OCF_USEPOOLQUOTA 0x08
  1308. #define OCF_DESKTOPHEAP 0x10
  1309. #define OCF_USEPOOLIFNODESKTOP 0x20
  1310. #define OCF_SHAREDHEAP 0x40
  1311. #if DBG
  1312. #define OCF_VARIABLESIZE 0x80
  1313. #else
  1314. #define OCF_VARIABLESIZE 0
  1315. #endif
  1316. /*
  1317. * From HANDTABL.C
  1318. */
  1319. /*
  1320. * Static information about each handle type.
  1321. */
  1322. typedef void (*FnDestroyUserObject)(void *);
  1323. typedef struct tagHANDLETYPEINFO {
  1324. #if DBG
  1325. LPCSTR szObjectType;
  1326. UINT uSize;
  1327. #endif
  1328. FnDestroyUserObject fnDestroy;
  1329. DWORD dwAllocTag;
  1330. BYTE bObjectCreateFlags;
  1331. } HANDLETYPEINFO, *PHANDLETYPEINFO;
  1332. /*
  1333. * The following is the header of all objects managed in the handle list.
  1334. * (allocated as part of the object for easy access). All object
  1335. * headers must start with the members of a HEAD structure.
  1336. */
  1337. typedef struct _HEAD {
  1338. KHANDLE h;
  1339. DWORD cLockObj;
  1340. } HEAD, * KPTR_MODIFIER PHEAD;
  1341. /*
  1342. * sizeof(THROBJHEAD) must be equal to sizeof(PROCOBJHEAD)
  1343. * This is to make sure that DESKHEAD fields are always at the same offset.
  1344. */
  1345. typedef struct _THROBJHEAD {
  1346. HEAD;
  1347. PTHREADINFO pti;
  1348. } THROBJHEAD, * KPTR_MODIFIER PTHROBJHEAD;
  1349. typedef struct _PROCOBJHEAD {
  1350. HEAD;
  1351. DWORD hTaskWow;
  1352. } PROCOBJHEAD, *PPROCOBJHEAD;
  1353. typedef struct _PROCMARKHEAD {
  1354. PROCOBJHEAD;
  1355. PPROCESSINFO ppi;
  1356. } PROCMARKHEAD, *PPROCMARKHEAD;
  1357. typedef struct _DESKHEAD {
  1358. PDESKTOP rpdesk;
  1359. KPBYTE pSelf;
  1360. } DESKHEAD, *PDESKHEAD;
  1361. /*
  1362. * This type is for HM casting only. Use THRDESKHEAD or PROCDESKHEAD instead.
  1363. */
  1364. typedef struct _DESKOBJHEAD {
  1365. HEAD;
  1366. KERNEL_PVOID pOwner;
  1367. DESKHEAD;
  1368. } DESKOBJHEAD, *PDESKOBJHEAD;
  1369. typedef struct _THRDESKHEAD {
  1370. THROBJHEAD;
  1371. DESKHEAD;
  1372. } THRDESKHEAD, *PTHRDESKHEAD;
  1373. typedef struct _PROCDESKHEAD {
  1374. PROCOBJHEAD;
  1375. DESKHEAD;
  1376. } PROCDESKHEAD, *PPROCDESKHEAD;
  1377. #define HANDLEF_DESTROY 0x01
  1378. #define HANDLEF_INDESTROY 0x02
  1379. #define HANDLEF_MARKED_OK 0x10
  1380. #define HANDLEF_GRANTED 0x20
  1381. #define HANDLEF_POOL 0x40 // for the mother desktop window
  1382. #define HANDLEF_VALID 0x7F
  1383. /*
  1384. * The following is a handle table entry.
  1385. *
  1386. * Note that by keeping a pointer to the owning entity (process or
  1387. * thread), cleanup will touch only those objects that belong to
  1388. * the entity being destroyed. This helps keep the working set
  1389. * size down. Look at DestroyProcessesObjects() for an example.
  1390. */
  1391. typedef struct _HANDLEENTRY {
  1392. PHEAD phead; /* pointer to the real object */
  1393. KERNEL_PVOID pOwner; /* pointer to owning entity (pti or ppi) */
  1394. BYTE bType; /* type of object */
  1395. BYTE bFlags; /* flags - like destroy flag */
  1396. WORD wUniq; /* uniqueness count */
  1397. #if DBG || FRE_LOCK_RECORD
  1398. PLR plr; /* lock record pointer */
  1399. #endif // DBG
  1400. } HANDLEENTRY;
  1401. /*
  1402. * Change HMINDEXBITS for bits that make up table index in handle
  1403. * Change HMUNIQSHIFT for count of bits to shift uniqueness left.
  1404. * Change HMUNIQBITS for bits that make up uniqueness.
  1405. *
  1406. * Currently 64K handles can be created, w/16 bits of uniqueness.
  1407. */
  1408. #define HMINDEXBITS 0x0000FFFF // bits where index is stored
  1409. #define HMUNIQSHIFT 16 // bits to shift uniqueness
  1410. #define HMUNIQBITS 0xFFFF // valid uniqueness bits
  1411. #ifdef _USERK_
  1412. #define HMHandleFromIndex(i) LongToHandle((LONG)(i) | ((LONG)gSharedInfo.aheList[i].wUniq << HMUNIQSHIFT))
  1413. #define HMObjectFlags(p) (gahti[HMObjectType(p)].bObjectCreateFlags)
  1414. #endif
  1415. #define HMIndexFromHandle(h) ((ULONG)(((ULONG_PTR)(h)) & HMINDEXBITS))
  1416. #define _HMPheFromObject(p) (&gSharedInfo.aheList[HMIndexFromHandle((((PHEAD)p)->h))])
  1417. #define _HMObjectFromHandle(h) ((KERNEL_PVOID)(gSharedInfo.aheList[HMIndexFromHandle(h)].phead))
  1418. #define HMUniqFromHandle(h) ((WORD)((((ULONG_PTR)h) >> HMUNIQSHIFT) & HMUNIQBITS))
  1419. #define HMObjectType(p) (HMPheFromObject(p)->bType)
  1420. #define HMIsMarkDestroy(p) (HMPheFromObject(p)->bFlags & HANDLEF_DESTROY)
  1421. /*
  1422. * Validation, handle mapping, etc.
  1423. */
  1424. #define HMRevalidateHandle(h) HMValidateHandleNoSecure(h, TYPE_GENERIC)
  1425. #define HMRevalidateCatHandle(h) HMValidateCatHandleNoSecure(h, TYPE_GENERIC)
  1426. #define HMRevalidateHandleNoRip(h) HMValidateHandleNoRip(h, TYPE_GENERIC)
  1427. #define RevalidateHmenu(hmenuX) HMValidateHandleNoRip(hmenuX, TYPE_MENU)
  1428. #define _PtoHq(p) (KHANDLE_TO_HANDLE(((PHEAD)p)->h))
  1429. #define _PtoH(p) ((HANDLE)((p) == NULL ? NULL : _PtoHq(p)))
  1430. #define _HW(pwnd) ((HWND)_PtoH(pwnd))
  1431. #define _HWCCX(ccxPwnd) ((HWND)_PtoH(ccxPwnd))
  1432. #define _HWq(pwnd) ((HWND)_PtoHq(pwnd))
  1433. #if DBG && defined(_USERK_)
  1434. PHE DBGHMPheFromObject (PVOID p);
  1435. PVOID DBGHMObjectFromHandle (HANDLE h);
  1436. PVOID DBGHMCatObjectFromHandle (HANDLE h);
  1437. HANDLE DBGPtoH (PVOID p);
  1438. HANDLE DBGPtoHq (PVOID p);
  1439. HWND DBGHW (PWND pwnd);
  1440. HWND DBGHWCCX (PWND pwnd);
  1441. HWND DBGHWq (PWND pwnd);
  1442. #define HMPheFromObject(p) DBGHMPheFromObject((p))
  1443. #define HMObjectFromHandle(h) DBGHMObjectFromHandle((HANDLE)(h))
  1444. #define HMCatObjectFromHandle(h) DBGHMCatObjectFromHandle((HANDLE)(h))
  1445. #define PtoH(p) DBGPtoH((PVOID)(p))
  1446. #define PtoHq(p) DBGPtoHq((PVOID)(p))
  1447. #define HW(pwnd) DBGHW((PWND)(pwnd))
  1448. #define HWCCX(ccxPwnd) DBGHWCCX((PWND)(ccxPwnd))
  1449. #define HWq(pwnd) DBGHWq((PWND)(pwnd))
  1450. #else
  1451. #define HMPheFromObject(p) _HMPheFromObject(p)
  1452. #define HMObjectFromHandle(h) _HMObjectFromHandle(h)
  1453. #define HMCatObjectFromHandle(h) _HMObjectFromHandle(h)
  1454. #define PtoH(p) _PtoH(p)
  1455. #define PtoHq(p) _PtoHq(p)
  1456. #define HW(pwnd) _HW(pwnd)
  1457. #define HWCCX(ccxPwnd) _HW(ccxPwnd)
  1458. #define HWq(pwnd) _HWq(pwnd)
  1459. #endif // DBG && defined(_USERK_)
  1460. /*
  1461. * Inline functions / macros to access HM object head fields
  1462. */
  1463. #define _GETPTI(p) (((PTHROBJHEAD)p)->pti)
  1464. #define _GETPDESK(p) (((PDESKOBJHEAD)p)->rpdesk)
  1465. #define _GETPPI(p) (((PPROCMARKHEAD)p)->ppi)
  1466. #if DBG && defined(_USERK_)
  1467. extern CONST HANDLETYPEINFO gahti[];
  1468. extern SHAREDINFO gSharedInfo;
  1469. __inline PTHREADINFO GETPTI (PVOID p)
  1470. {
  1471. UserAssert(HMObjectFlags(p) & OCF_THREADOWNED);
  1472. return _GETPTI(p);
  1473. }
  1474. __inline PDESKTOP GETPDESK (PVOID p)
  1475. {
  1476. UserAssert(HMObjectFlags(p) & OCF_DESKTOPHEAP);
  1477. return _GETPDESK(p);
  1478. }
  1479. __inline PPROCESSINFO GETPPI (PVOID p)
  1480. {
  1481. UserAssert(HMObjectFlags(p) & OCF_MARKPROCESS);
  1482. return _GETPPI(p);
  1483. }
  1484. #else
  1485. #define GETPTI(p) _GETPTI(p)
  1486. #define GETPDESK(p) _GETPDESK(p)
  1487. #define GETPPI(p) _GETPPI(p)
  1488. #endif /* #else #if DBG && defined(_USERK_) */
  1489. #define GETPWNDPPI(p) (GETPTI(p)->ppi)
  1490. #define GETPTIID(p) (PsGetThreadId((p)->pEThread))
  1491. /*
  1492. * NOTE!: there is code in exitwin.c that assumes HMIsMarkDestroy is defined as
  1493. * (HMPheFromObject(p)->bFlags & HANDLEF_DESTROY)
  1494. */
  1495. #define CPD_ANSI_TO_UNICODE 0x0001 /* CPD represents ansi to U transition */
  1496. #define CPD_UNICODE_TO_ANSI 0x0002
  1497. #define CPD_TRANSITION_TYPES (CPD_ANSI_TO_UNICODE|CPD_UNICODE_TO_ANSI)
  1498. #define CPD_CLASS 0x0010 /* Get CPD for a class */
  1499. #define CPD_WND 0x0020
  1500. #define CPD_DIALOG 0x0040
  1501. #define CPD_WNDTOCLS 0x0080
  1502. #define CPDHANDLE_HI ((ULONG_PTR)~HMINDEXBITS)
  1503. #define MAKE_CPDHANDLE(h) (HMIndexFromHandle(h) | CPDHANDLE_HI)
  1504. #define ISCPDTAG(x) (((ULONG_PTR)(x) & CPDHANDLE_HI) == CPDHANDLE_HI)
  1505. /*
  1506. * Call Proc Handle Info
  1507. */
  1508. typedef struct _CALLPROCDATA {
  1509. PROCDESKHEAD head;
  1510. PCALLPROCDATA spcpdNext;
  1511. KERNEL_ULONG_PTR pfnClientPrevious;
  1512. WORD wType;
  1513. } CALLPROCDATA;
  1514. /*
  1515. * Class styles
  1516. */
  1517. #define CFVREDRAW 0x0001
  1518. #define CFHREDRAW 0x0002
  1519. #define CFKANJIWINDOW 0x0004
  1520. #define CFDBLCLKS 0x0008
  1521. #define CFSERVERSIDEPROC 0x0010 // documented as reserved in winuser.h
  1522. #define CFOWNDC 0x0020
  1523. #define CFCLASSDC 0x0040
  1524. #define CFPARENTDC 0x0080
  1525. #define CFNOKEYCVT 0x0101
  1526. #define CFNOCLOSE 0x0102
  1527. #define CFLVB 0x0104
  1528. #define CFSAVEBITS 0x0108
  1529. #define CFOEMCHARS 0x0140
  1530. #define CFIME 0x0201
  1531. #define CFDROPSHADOW 0x0202
  1532. /*
  1533. * Offset from the beginning of the CLS structure to the WNDCLASS section.
  1534. */
  1535. #define CFOFFSET (FIELD_OFFSET(CLS, style))
  1536. #define TestCF(hwnd, flag) (*((KPBYTE)((PWND)(hwnd))->pcls + CFOFFSET + HIBYTE(flag)) & LOBYTE(flag))
  1537. #define SetCF(hwnd, flag) (*((KPBYTE)((PWND)(hwnd))->pcls + CFOFFSET + HIBYTE(flag)) |= LOBYTE(flag))
  1538. #define ClrCF(pcls, flag) (*((KPBYTE)((PWND)(hwnd))->pcls + CFOFFSET + HIBYTE(flag)) &= ~LOBYTE(flag))
  1539. #define TestCF2(pcls, flag) (*((KPBYTE)(pcls) + CFOFFSET + (int)HIBYTE(flag)) & LOBYTE(flag))
  1540. #define SetCF2(pcls, flag) (*((KPBYTE)(pcls) + CFOFFSET + (int)HIBYTE(flag)) |= LOBYTE(flag))
  1541. #define ClrCF2(pcls, flag) (*((KPBYTE)(pcls) + CFOFFSET + (int)HIBYTE(flag)) &= ~LOBYTE(flag))
  1542. #define PWCFromPCLS(pcls) ((PWC)KPBYTE_TO_PBYTE((KPBYTE)(pcls) + sizeof(CLS) + (pcls)->cbclsExtra))
  1543. /* Window class structure */
  1544. typedef struct tagCOMMON_WNDCLASS
  1545. {
  1546. /*
  1547. * We'll add cWndReferenceCount here so COMMON_WNDCLASS and WNDCLASSEX have
  1548. * the same layout. Otherwise padding will mess us up on 64-bit platforms.
  1549. */
  1550. int cWndReferenceCount; /* The number of windows registered
  1551. with this class */
  1552. UINT style;
  1553. WNDPROC_PWND lpfnWndProc; // HI BIT on means WOW PROC
  1554. int cbclsExtra;
  1555. int cbwndExtra;
  1556. KHANDLE hModule;
  1557. PCURSOR spicn;
  1558. PCURSOR spcur;
  1559. KHBRUSH hbrBackground;
  1560. KLPWSTR lpszMenuName;
  1561. KLPSTR lpszAnsiClassName;
  1562. PCURSOR spicnSm;
  1563. } COMMON_WNDCLASS;
  1564. /*
  1565. * Class Menu names structure. For performance reasons (GetClassInfo) we
  1566. * keep two client side copies of wndcls.lpszMenu and another kernel side
  1567. * copy. This structure is used to pass menu names info between client and
  1568. * kernel.
  1569. */
  1570. typedef struct tagCLSMENUNAME
  1571. {
  1572. KLPSTR pszClientAnsiMenuName;
  1573. KLPWSTR pwszClientUnicodeMenuName;
  1574. PUNICODE_STRING pusMenuName;
  1575. } CLSMENUNAME, *PCLSMENUNAME;
  1576. /*
  1577. * This is the window class structure. All window classes are linked
  1578. * together in a master list pointed to by gpclsList.
  1579. *
  1580. * RED ALERT! Do not add any fields after the COMMON_WNDCLASS structure;
  1581. * CFOFFSET depends on this.
  1582. */
  1583. typedef struct tagCLS {
  1584. /* NOTE: The order of the following fields is assumed. */
  1585. PCLS pclsNext;
  1586. ATOM atomClassName; //Version aware class name.
  1587. ATOM atomNVClassName; //None-version aware class name.
  1588. WORD fnid; // record window proc used by this hwnd
  1589. // access through GETFNID
  1590. PDESKTOP rpdeskParent;/* Parent desktop */
  1591. PDCE pdce; /* PDCE to DC associated with class */
  1592. WORD hTaskWow;
  1593. WORD CSF_flags; /* internal class flags */
  1594. KLPSTR lpszClientAnsiMenuName; /* string or resource ID */
  1595. KLPWSTR lpszClientUnicodeMenuName; /* string or resource ID */
  1596. PCALLPROCDATA spcpdFirst; /* Pointer to first CallProcData element (or 0) */
  1597. PCLS pclsBase; /* Pointer to base class */
  1598. PCLS pclsClone; /* Pointer to clone class list */
  1599. COMMON_WNDCLASS;
  1600. /*
  1601. * WARNING:
  1602. * CFOFFSET expects COMMON_WNDCLASS to be last fields in CLS
  1603. */
  1604. } CLS, **PPCLS;
  1605. /*
  1606. * This class flag is used to distinguish classes that were registered
  1607. * by the server (most system classes) from those registered by the client.
  1608. * Note -- flags are a WORD in the class structure now.
  1609. */
  1610. #define CSF_SERVERSIDEPROC 0x0001
  1611. #define CSF_ANSIPROC 0x0002
  1612. #define CSF_WOWDEFERDESTROY 0x0004
  1613. #define CSF_SYSTEMCLASS 0x0008
  1614. #define CSF_WOWCLASS 0x0010 // extra words at end for wow info
  1615. #define CSF_WOWEXTRA 0x0020
  1616. #define CSF_CACHEDSMICON 0x0040
  1617. #define CSF_WIN40COMPAT 0x0080
  1618. #define CSF_VERSIONCLASS 0x0100
  1619. #define CSF_VALID (CSF_ANSIPROC | CSF_WIN40COMPAT | CSF_VERSIONCLASS)
  1620. /*
  1621. * SBDATA are the values for one scrollbar
  1622. */
  1623. typedef struct tagSBDATA {
  1624. int posMin;
  1625. int posMax;
  1626. int page;
  1627. int pos;
  1628. } SBDATA, *PSBDATA;
  1629. /*
  1630. * SBINFO is the set of values that hang off of a window structure, if the
  1631. * window has scrollbars.
  1632. */
  1633. typedef struct tagSBINFO {
  1634. int WSBflags;
  1635. SBDATA Horz;
  1636. SBDATA Vert;
  1637. } SBINFO, * KPTR_MODIFIER PSBINFO;
  1638. /*
  1639. * Window Property structure
  1640. */
  1641. typedef struct tagPROP {
  1642. KHANDLE hData;
  1643. ATOM atomKey;
  1644. WORD fs;
  1645. } PROP, * KPTR_MODIFIER PPROP;
  1646. #define PROPF_INTERNAL 0x0001
  1647. #define PROPF_STRING 0x0002
  1648. #define PROPF_NOPOOL 0x0004
  1649. /*
  1650. * Window Property List structure
  1651. */
  1652. typedef struct tagPROPLIST {
  1653. UINT cEntries;
  1654. UINT iFirstFree;
  1655. PROP aprop[1];
  1656. } PROPLIST, * KPTR_MODIFIER PPROPLIST;
  1657. /*
  1658. * NOTE -- this structure has been sorted (roughly) in order of use
  1659. * of the fields. The x86 code set allows cheaper access to fields
  1660. * that are in the first 0x80 bytes of a structure. Please attempt
  1661. * to ensure that frequently-used fields are below this boundary.
  1662. */
  1663. typedef struct tagWND {
  1664. THRDESKHEAD head;
  1665. WW; // WOW-USER common fields. Defined in wowuserp.h
  1666. // The presence of "state" at the start of this structure is
  1667. // assumed by the STATEOFFSET macro.
  1668. PWND spwndNext; // Handle to the next window
  1669. PWND spwndPrev; // Handle to the previous window
  1670. PWND spwndParent; // Backpointer to the parent window.
  1671. PWND spwndChild; // Handle to child
  1672. PWND spwndOwner; // Popup window owner field
  1673. RECT rcWindow; // Window outer rectangle
  1674. RECT rcClient; // Client rectangle
  1675. WNDPROC_PWND lpfnWndProc; // Can be WOW address or standard address
  1676. PCLS pcls; // Pointer to window class
  1677. KHRGN hrgnUpdate; // Accumulated paint region
  1678. PPROPLIST ppropList; // Pointer to property list
  1679. PSBINFO pSBInfo; // Words used for scrolling
  1680. PMENU spmenuSys; // Handle to system menu
  1681. PMENU spmenu; // Menu handle or ID
  1682. KHRGN hrgnClip; // Clipping region for this window
  1683. LARGE_UNICODE_STRING strName;
  1684. int cbwndExtra; // Extra bytes in window
  1685. PWND spwndLastActive; // Last active in owner/ownee list
  1686. KHIMC hImc; // Associated input context handle
  1687. KERNEL_ULONG_PTR dwUserData; // Reserved for random application data
  1688. struct _ACTIVATION_CONTEXT * KPTR_MODIFIER pActCtx;
  1689. } WND;
  1690. #define NEEDSPAINT(pwnd) (pwnd->hrgnUpdate != NULL || TestWF(pwnd, WFINTERNALPAINT))
  1691. /*
  1692. * Combo Box stuff
  1693. */
  1694. typedef struct tagCBox {
  1695. PWND spwnd; /* Window for the combo box */
  1696. PWND spwndParent;/* Parent of the combo box */
  1697. RECT editrc; /* Rectangle for the edit control/static text
  1698. area */
  1699. RECT buttonrc; /* Rectangle where the dropdown button is */
  1700. int cxCombo; // Width of sunken area
  1701. int cyCombo; // Height of sunken area
  1702. int cxDrop; // 0x24 Width of dropdown
  1703. int cyDrop; // Height of dropdown or shebang if simple
  1704. PWND spwndEdit; /* Edit control window handle */
  1705. PWND spwndList; /* List box control window handle */
  1706. UINT CBoxStyle:2; /* Combo box style */
  1707. UINT fFocus:1; /* Combo box has focus? */
  1708. UINT fNoRedraw:1; /* Stop drawing? */
  1709. UINT fMouseDown:1; /* Was the popdown button just clicked and
  1710. mouse still down? */
  1711. UINT fButtonPressed:1; /* Is the dropdown button in an inverted state?
  1712. */
  1713. UINT fLBoxVisible:1; /* Is list box visible? (dropped down?) */
  1714. UINT OwnerDraw:2; /* Owner draw combo box if nonzero. value
  1715. * specifies either fixed or varheight
  1716. */
  1717. UINT fKeyboardSelInListBox:1; /* Is the user keyboarding through the
  1718. * listbox. So that we don't hide the
  1719. * listbox on selchanges caused by the
  1720. * user keyboard through it but we do
  1721. * hide it if the mouse causes the
  1722. * selchange.
  1723. */
  1724. UINT fExtendedUI:1; /* Are we doing TandyT's UI changes on this
  1725. * combo box?
  1726. */
  1727. UINT fCase:2;
  1728. UINT f3DCombo:1; // 3D or flat border?
  1729. UINT fNoEdit:1; /* True if editing is not allowed in the edit
  1730. * window.
  1731. */
  1732. #ifdef COLOR_HOTTRACKING
  1733. UINT fButtonHotTracked:1; /* Is the dropdown hot-tracked? */
  1734. #endif // COLOR_HOTTRACKING
  1735. UINT fRightAlign:1; /* used primarily for MidEast right align */
  1736. UINT fRtoLReading:1; /* used only for MidEast, text rtol reading order */
  1737. UINT fInDestroy:1; /* Is combobox destruction started already? */
  1738. HANDLE hFont; /* Font for the combo box */
  1739. LONG styleSave; /* Temp to save the style bits when creating
  1740. * window. Needed because we strip off some
  1741. * bits and pass them on to the listbox or
  1742. * edit box.
  1743. */
  1744. } CBOX, * KPTR_MODIFIER PCBOX;
  1745. typedef struct tagCOMBOWND {
  1746. WND wnd;
  1747. PCBOX pcbox;
  1748. } COMBOWND, * KPTR_MODIFIER PCOMBOWND;
  1749. /*
  1750. * List Box
  1751. */
  1752. typedef struct _SCROLLPOS {
  1753. INT cItems;
  1754. UINT iPage;
  1755. INT iPos;
  1756. UINT fMask;
  1757. INT iReturn;
  1758. } SCROLLPOS, *PSCROLLPOS;
  1759. typedef struct tagLBIV {
  1760. PWND spwndParent; /* parent window */
  1761. PWND spwnd; /* lbox ctl window */
  1762. INT iTop; /* index of top item displayed */
  1763. INT iSel; /* index of current item selected */
  1764. INT iSelBase; /* base sel for multiple selections */
  1765. INT cItemFullMax; /* cnt of Fully Visible items. Always contains
  1766. result of CItemInWindow(plb, FALSE) for fixed
  1767. height listboxes. Contains 1 for var height
  1768. listboxes. */
  1769. INT cMac; /* cnt of items in listbox */
  1770. INT cMax; /* cnt of total # items allocated for rgpch.
  1771. Not all are necessarly in use */
  1772. KPBYTE rgpch; /* pointer to array of string offsets */
  1773. KLPWSTR hStrings; /* string storage handle */
  1774. INT cchStrings; /* Size in bytes of hStrings */
  1775. INT ichAlloc; /* Pointer to end of hStrings (end of last valid
  1776. string) */
  1777. INT cxChar; /* Width of a character */
  1778. INT cyChar; /* height of line */
  1779. INT cxColumn; /* width of a column in multicolumn listboxes */
  1780. INT itemsPerColumn; /* for multicolumn listboxes */
  1781. INT numberOfColumns; /* for multicolumn listboxes */
  1782. POINT ptPrev; /* coord of last tracked mouse pt. used for auto
  1783. scrolling the listbox during timer's */
  1784. UINT OwnerDraw:2; /* Owner draw styles. Non-zero if ownerdraw. */
  1785. UINT fRedraw:1; /* if TRUE then do repaints */
  1786. UINT fDeferUpdate:1; /* */
  1787. UINT wMultiple:2; /* SINGLESEL allows a single item to be selected.
  1788. * MULTIPLESEL allows simple toggle multi-selection
  1789. * EXTENDEDSEL allows extended multi selection;
  1790. */
  1791. UINT fSort:1; /* if TRUE the sort list */
  1792. UINT fNotify:1; /* if TRUE then Notify parent */
  1793. UINT fMouseDown:1; /* if TRUE then process mouse moves/mouseup */
  1794. UINT fCaptured:1; /* if TRUE then process mouse messages */
  1795. UINT fCaret:1; /* flashing caret allowed */
  1796. UINT fDoubleClick:1; /* mouse down in double click */
  1797. UINT fCaretOn:1; /* if TRUE then caret is on */
  1798. UINT fAddSelMode:1; /* if TRUE, then it is in ADD selection mode */
  1799. UINT fHasStrings:1; /* True if the listbox has a string associated
  1800. * with each item else it has an app suppled LONG
  1801. * value and is ownerdraw
  1802. */
  1803. UINT fHasData:1; /* if FALSE, then lb doesn't keep any line data
  1804. * beyond selection state, but instead calls back
  1805. * to the client for each line's definition.
  1806. * Forces OwnerDraw==OWNERDRAWFIXED, !fSort,
  1807. * and !fHasStrings.
  1808. */
  1809. UINT fNewItemState:1; /* select/deselect mode? for multiselection lb
  1810. */
  1811. UINT fUseTabStops:1; /* True if the non-ownerdraw listbox should handle
  1812. * tabstops
  1813. */
  1814. UINT fMultiColumn:1; /* True if this is a multicolumn listbox */
  1815. UINT fNoIntegralHeight:1; /* True if we don't want to size the listbox
  1816. * an integral lineheight
  1817. */
  1818. UINT fWantKeyboardInput:1; /* True if we should pass on WM_KEY & CHAR
  1819. * so that the app can go to special items
  1820. * with them.
  1821. */
  1822. UINT fDisableNoScroll:1; /* True if the listbox should
  1823. * automatically Enable/disable
  1824. * it's scroll bars. If false, the scroll
  1825. * bars will be hidden/Shown automatically
  1826. * if they are present.
  1827. */
  1828. UINT fHorzBar:1; // TRUE if WS_HSCROLL specified at create time
  1829. UINT fVertBar:1; // TRUE if WS_VSCROLL specified at create time
  1830. UINT fFromInsert:1; // TRUE if client drawing should be deferred during delete/insert ops
  1831. UINT fNoSel:1;
  1832. UINT fHorzInitialized : 1; // Horz scroll cache initialized
  1833. UINT fVertInitialized : 1; // Vert scroll cache initialized
  1834. UINT fSized : 1; // Listbox was resized.
  1835. UINT fIgnoreSizeMsg : 1; // If TRUE, ignore WM_SIZE message
  1836. UINT fInitialized : 1;
  1837. UINT fRightAlign:1; // used primarily for MidEast right align
  1838. UINT fRtoLReading:1; // used only for MidEast, text rtol reading order
  1839. UINT fSmoothScroll:1; // allow just one smooth-scroll per scroll cycle
  1840. int xRightOrigin; // For horizontal scrolling. The current x origin
  1841. INT iLastSelection; /* Used for cancelable selection. Last selection
  1842. * in listbox for combo box support
  1843. */
  1844. INT iMouseDown; /* For multiselection mouse click & drag extended
  1845. * selection. It is the ANCHOR point for range
  1846. * selections
  1847. */
  1848. INT iLastMouseMove; /* selection of listbox items */
  1849. KPINT iTabPixelPositions; /* List of positions for tabs */
  1850. KHANDLE hFont; /* User settable font for listboxes */
  1851. int xOrigin; /* For horizontal scrolling. The current x origin */
  1852. int maxWidth; /* Maximum width of listbox in pixels for
  1853. horizontal scrolling purposes */
  1854. PCBOX pcbox; /* Combo box pointer */
  1855. HDC hdc; /* hdc currently in use */
  1856. DWORD dwLocaleId; /* Locale used for sorting strings in list box */
  1857. int iTypeSearch;
  1858. KLPWSTR pszTypeSearch;
  1859. SCROLLPOS HPos;
  1860. SCROLLPOS VPos;
  1861. } LBIV, *PLBIV;
  1862. typedef struct tagLBWND {
  1863. WND wnd;
  1864. PLBIV pLBIV;
  1865. } LBWND, * KPTR_MODIFIER PLBWND;
  1866. /*
  1867. * Kernel side input context structure.
  1868. */
  1869. typedef struct tagIMC { /* hImc */
  1870. THRDESKHEAD head;
  1871. struct tagIMC* KPTR_MODIFIER pImcNext;
  1872. KERNEL_ULONG_PTR dwClientImcData; // Client side data
  1873. KHWND hImeWnd; // in use Ime Window
  1874. } IMC, * KPTR_MODIFIER PIMC;
  1875. /*
  1876. * Hook structure.
  1877. */
  1878. #undef HOOKBATCH
  1879. typedef struct tagHOOK { /* hk */
  1880. THRDESKHEAD head;
  1881. PHOOK phkNext;
  1882. int iHook; // WH_xxx hook type
  1883. KERNEL_ULONG_PTR offPfn;
  1884. UINT flags; // HF_xxx flags
  1885. int ihmod;
  1886. PTHREADINFO ptiHooked; // Thread hooked.
  1887. PDESKTOP rpdesk; // Global hook pdesk. Only used when
  1888. // hook is locked and owner is destroyed
  1889. BOOL fLastHookHung : 1; // for LL hook only
  1890. #ifdef HOOKBATCH
  1891. DWORD cEventMessages; // Number of events in the cache
  1892. DWORD iCurrentEvent; // Current cache event
  1893. DWORD CacheTimeOut; // Timeout between keys
  1894. PEVENTMSG aEventCache; // The array of Events
  1895. #endif // HOOKBATCH
  1896. } HOOK;
  1897. /*
  1898. * Hook defines.
  1899. */
  1900. #define HF_GLOBAL 0x0001
  1901. #define HF_ANSI 0x0002
  1902. #define HF_NEEDHC_SKIP 0x0004
  1903. #define HF_HUNG 0x0008 // Hook Proc hung don't call if system
  1904. #define HF_HOOKFAULTED 0x0010 // Hook Proc faulted
  1905. #define HF_NOPLAYBACKDELAY 0x0020 // Ignore requested delay
  1906. #define HF_DESTROYED 0x0080 // Set by FreeHook
  1907. #if DBG
  1908. #define HF_INCHECKWHF 0x0100 // fsHooks is being updated
  1909. #define HF_FREED 0x0200 // Object has been freed.
  1910. #define HF_DBGUSED 0x03FF // Update if adding a flag
  1911. #endif
  1912. /*
  1913. * Macro to convert the WH_* index into a bit position for
  1914. * the fsHooks fields of SERVERINFO and THREADINFO.
  1915. */
  1916. #define WHF_FROM_WH(n) (1 << (n + 1))
  1917. /*
  1918. * Flags for IsHooked().
  1919. */
  1920. #define WHF_MSGFILTER WHF_FROM_WH(WH_MSGFILTER)
  1921. #define WHF_JOURNALRECORD WHF_FROM_WH(WH_JOURNALRECORD)
  1922. #define WHF_JOURNALPLAYBACK WHF_FROM_WH(WH_JOURNALPLAYBACK)
  1923. #define WHF_KEYBOARD WHF_FROM_WH(WH_KEYBOARD)
  1924. #define WHF_GETMESSAGE WHF_FROM_WH(WH_GETMESSAGE)
  1925. #define WHF_CALLWNDPROC WHF_FROM_WH(WH_CALLWNDPROC)
  1926. #define WHF_CALLWNDPROCRET WHF_FROM_WH(WH_CALLWNDPROCRET)
  1927. #define WHF_CBT WHF_FROM_WH(WH_CBT)
  1928. #define WHF_SYSMSGFILTER WHF_FROM_WH(WH_SYSMSGFILTER)
  1929. #define WHF_MOUSE WHF_FROM_WH(WH_MOUSE)
  1930. #define WHF_HARDWARE WHF_FROM_WH(WH_HARDWARE)
  1931. #define WHF_DEBUG WHF_FROM_WH(WH_DEBUG)
  1932. #define WHF_SHELL WHF_FROM_WH(WH_SHELL)
  1933. #define WHF_FOREGROUNDIDLE WHF_FROM_WH(WH_FOREGROUNDIDLE)
  1934. /*
  1935. * Windowstation and desktop enum list structure.
  1936. */
  1937. typedef struct tagNAMELIST {
  1938. DWORD cb;
  1939. DWORD cNames;
  1940. WCHAR awchNames[1];
  1941. } NAMELIST, *PNAMELIST;
  1942. #define MONF_VISIBLE 0x01 // monitor is visible on desktop
  1943. #define MONF_PALETTEDISPLAY 0x02 // monitor has palette
  1944. #ifndef _USERSRV_
  1945. #ifdef SUBPIXEL_MOUSE
  1946. typedef LONG64 FIXPOINT;
  1947. /*
  1948. * Number of points in the arrays describing the acceleration curves.
  1949. */
  1950. #define SM_POINT_CNT 5
  1951. #endif // SUBPIXEL_MOUSE
  1952. /*
  1953. * Monitor information structure.
  1954. *
  1955. * This structure defines the attributes of a single monitor
  1956. * in a virtual display.
  1957. */
  1958. typedef struct tagMONITOR {
  1959. HEAD head; // object handle stuff
  1960. PMONITOR pMonitorNext; // next monitor in free or used list
  1961. DWORD dwMONFlags; // flags
  1962. RECT rcMonitor; // location of monitor in virtual screen coordinates
  1963. RECT rcWork; // work area of monitor in virtual screen coordinates
  1964. KHRGN hrgnMonitor; // monitor region in virtual screen coordinates
  1965. short cFullScreen; // number of fullscreen apps on this monitor
  1966. short cWndStack; // number of tiled top-level windows
  1967. KHANDLE hDev; // hdev associated with this monitor
  1968. #ifdef SUBPIXEL_MOUSE
  1969. FIXPOINT xTxf[SM_POINT_CNT], yTxf[SM_POINT_CNT];
  1970. /*
  1971. * SM_POINT_CNT - 1 because you need two points for one slope/yint value.
  1972. */
  1973. FIXPOINT slope[SM_POINT_CNT - 1], yint[SM_POINT_CNT - 1];
  1974. #endif // SUBPIXEL_MOUSE
  1975. } MONITOR;
  1976. #endif
  1977. /*
  1978. * Display Information Structure.
  1979. *
  1980. * This structure defines the display attributes for the
  1981. * desktop. This is usually maintained in the DESKTOP
  1982. * structure. The current display in use is pointed to
  1983. * by gpDispInfo.
  1984. *
  1985. * CONSIDER: How many of these fields need to be actually kept
  1986. * in a DISPLAYINFO that is not in use, rather than just be put
  1987. * in gpsi or a kernel-side global?
  1988. */
  1989. #ifndef _USERSRV_
  1990. typedef struct tagDISPLAYINFO {
  1991. // device stuff
  1992. KHANDLE hDev;
  1993. KERNEL_PVOID pmdev;
  1994. KHANDLE hDevInfo;
  1995. // useful dcs
  1996. KHDC hdcScreen; // Device-Context for screen
  1997. KHDC hdcBits; // Holds system-bitmap resource
  1998. // Graystring resources
  1999. KHDC hdcGray; // GrayString DC.
  2000. KHBITMAP hbmGray; // GrayString Bitmap Surface.
  2001. int cxGray; // width of gray bitmap
  2002. int cyGray; // height of gray bitmap
  2003. // random stuff
  2004. PDCE pdceFirst; // list of dcs
  2005. PSPB pspbFirst; // list of spbs
  2006. // Monitors on this device
  2007. ULONG cMonitors; // number of MONF_VISIBLE monitors attached to desktop
  2008. PMONITOR pMonitorPrimary; // the primary monitor (display)
  2009. PMONITOR pMonitorFirst; // monitor in use list
  2010. // device characteristics
  2011. RECT rcScreen; // Rectangle of entire desktop surface
  2012. KHRGN hrgnScreen; // region describing virtual screen
  2013. WORD dmLogPixels; // pixels per inch
  2014. WORD BitCountMax; // Maximum bitcount across all monitors
  2015. BOOL fDesktopIsRect:1; // Is the desktop a simple rectangle?
  2016. BOOL fAnyPalette:1; // Are any of the monitors paletized?
  2017. // NOTE: if you need more flags, make fDesktopIsRect a flags field instead.
  2018. } DISPLAYINFO;
  2019. /*
  2020. * Multimonitor function in rtl\mmrtl.c
  2021. */
  2022. PMONITOR _MonitorFromPoint(POINT pt, DWORD dwFlags);
  2023. PMONITOR _MonitorFromRect(LPCRECT lprc, DWORD dwFlags);
  2024. PMONITOR _MonitorFromWindow(PWND pwnd, DWORD dwFlags);
  2025. #endif
  2026. #define HDCBITS() gpDispInfo->hdcBits
  2027. #define DTF_NEEDSPALETTECHANGED 0x00000001
  2028. #define DTF_NEEDSREDRAW 0x00000002
  2029. #define CWINHOOKS (WH_MAX - WH_MIN + 1)
  2030. /*
  2031. * VWPL - Volatile Window Pointer List (see rare.c)
  2032. * VPWLs are manipulate with the functions:
  2033. * VWPLAdd(), VWPLRemove() and VWPLNext()
  2034. */
  2035. typedef struct {
  2036. DWORD cPwnd; // number of pwnds in apwnd[]
  2037. DWORD cElem; // number of elements in apwnd[]
  2038. DWORD cThreshhold; // (re)allocation increment/decrement
  2039. PWND aPwnd[0]; // array of pwnds
  2040. } VWPL, * KPTR_MODIFIER PVWPL;
  2041. /*
  2042. * Desktop Information Structure.
  2043. *
  2044. * This structure contains information regading the
  2045. * desktop. This is viewable from both the client and
  2046. * kernel processes.
  2047. */
  2048. typedef struct tagDESKTOPINFO {
  2049. KERNEL_PVOID pvDesktopBase; // For handle validation
  2050. KERNEL_PVOID pvDesktopLimit; // ???
  2051. PWND spwnd; // Desktop window
  2052. DWORD fsHooks; // Deskop global hooks
  2053. PHOOK aphkStart[CWINHOOKS]; // List of hooks
  2054. PWND spwndShell; // Shell window
  2055. PPROCESSINFO ppiShellProcess; // Shell Process
  2056. PWND spwndBkGnd; // Shell background window
  2057. PWND spwndTaskman; // Task-Manager window
  2058. PWND spwndProgman; // Program-Manager window
  2059. PVWPL pvwplShellHook; // see (De)RegisterShellHookWindow
  2060. int cntMBox; // ???
  2061. } DESKTOPINFO;
  2062. #define CURSOR_ALWAYSDESTROY 0
  2063. #define CURSOR_CALLFROMCLIENT 1
  2064. #define CURSOR_THREADCLEANUP 2
  2065. typedef struct tagCURSOR_ACON {
  2066. PROCMARKHEAD head;
  2067. PCURSOR pcurNext;
  2068. UNICODE_STRING strName;
  2069. ATOM atomModName;
  2070. WORD rt;
  2071. } CURSOR_ACON;
  2072. typedef struct CURSOR_COMMON {
  2073. CURSINFO; // CURSINFO includes the flags
  2074. DWORD bpp;
  2075. DWORD cx;
  2076. DWORD cy;
  2077. } CURSOR_COMMON;
  2078. typedef struct ACON_COMMON {
  2079. int cpcur; // Count of image frames
  2080. int cicur; // Count of steps in animation sequence
  2081. PCURSOR * KPTR_MODIFIER aspcur; // Array of image frame pointers
  2082. DWORD * KPTR_MODIFIER aicur; // Array of frame indices (seq-table)
  2083. JIF * KPTR_MODIFIER ajifRate; // Array of time offsets
  2084. int iicur; // Current step in animation
  2085. } ACON_COMMON;
  2086. typedef struct tagCURSOR {
  2087. CURSOR_ACON; // common cursor/acon elements -
  2088. // See SetSystemImage()
  2089. CURSOR_COMMON;
  2090. } CURSOR;
  2091. typedef struct tagACON { // acon
  2092. CURSOR_ACON; // common cursor/acon elements -
  2093. // See SetSystemImage()
  2094. /*
  2095. * CURSORF_flags must be the first element to follow CURSOR_ACON. This
  2096. * way all members up to and including CURSORF_flags are the same in
  2097. * tagCURSOR and tagACON which is needed for SetSystemImage. See more
  2098. * comments for CI_FIRST in wingdi.w.
  2099. */
  2100. DWORD CURSORF_flags; // same as CI_FIRST in CURSINFO
  2101. ACON_COMMON;
  2102. } ACON, *PACON;
  2103. #define PICON PCURSOR
  2104. typedef struct tagCURSORDATA {
  2105. KLPWSTR lpName;
  2106. KLPWSTR lpModName;
  2107. WORD rt;
  2108. WORD dummy;
  2109. CURSOR_COMMON;
  2110. ACON_COMMON;
  2111. } CURSORDATA, *PCURSORDATA;
  2112. typedef struct tagCURSORFIND {
  2113. KHCURSOR hcur;
  2114. DWORD rt;
  2115. DWORD cx;
  2116. DWORD cy;
  2117. DWORD bpp;
  2118. } CURSORFIND, *PCURSORFIND;
  2119. #define MSGFLAG_MASK 0xFFFE0000
  2120. #define MSGFLAG_WOW_RESERVED 0x00010000 // Used by WOW
  2121. #define MSGFLAG_DDE_MID_THUNK 0x80000000 // DDE tracking thunk
  2122. #define MSGFLAG_DDE_SPECIAL_SEND 0x40000000 // WOW bad DDE app hack
  2123. #define MSGFLAG_SPECIAL_THUNK 0x10000000 // server->client thunk needs special handling
  2124. #define WIDTHBYTES(i) \
  2125. ((((i) + 31) & ~31) >> 3)
  2126. #define BITMAPWIDTHSIZE(cx, cy, planes, bpp) \
  2127. (WIDTHBYTES((cx * bpp)) * (cy) * (planes))
  2128. /*
  2129. * Window Style and State Masks -
  2130. *
  2131. * High byte of word is byte index from the start of the state field
  2132. * in the WND structure, low byte is the mask to use on the byte.
  2133. * These masks assume the order of the state and style fields of a
  2134. * window instance structure.
  2135. *
  2136. * This is how the Test/Set/Clr/MaskWF value ranges map to the corresponding
  2137. * fields in the window structure.
  2138. *
  2139. * offset WND field
  2140. * 0 - 3 state - private
  2141. * 4 - 7 state2 - private
  2142. * 8 - B ExStyle - public, exposed in SetWindowLong(GWL_EXSTYLE)
  2143. * C - F style - public, exposed in SetWindowLong(GWL_STYLE)
  2144. * C-D are reserved for window class designer.
  2145. * E-F are reserved for WS_ styles.
  2146. *
  2147. * NOTE: Be sure to add the flag to the wFlags array in kd\userexts.c!!!
  2148. */
  2149. /*
  2150. * State flags, from 0x0000 to 0x0780.
  2151. */
  2152. /*
  2153. * DON'T MOVE ANY ONE OF THE FOLLOWING WFXPRESENT FLAGS,
  2154. * BECAUSE WFFRAMEPRESENTMASK DEPENDS ON THEIR VALUES
  2155. */
  2156. #define WFMPRESENT 0x0001
  2157. #define WFVPRESENT 0x0002
  2158. #define WFHPRESENT 0x0004
  2159. #define WFCPRESENT 0x0008
  2160. #define WFFRAMEPRESENTMASK 0x000F
  2161. #define WFSENDSIZEMOVE 0x0010
  2162. #define WFMSGBOX 0x0020 // used to maintain count of msg boxes on screen
  2163. #define WFFRAMEON 0x0040
  2164. #define WFHASSPB 0x0080
  2165. #define WFNONCPAINT 0x0101
  2166. #define WFSENDERASEBKGND 0x0102
  2167. #define WFERASEBKGND 0x0104
  2168. #define WFSENDNCPAINT 0x0108
  2169. #define WFINTERNALPAINT 0x0110
  2170. #define WFUPDATEDIRTY 0x0120
  2171. #define WFHIDDENPOPUP 0x0140
  2172. #define WFMENUDRAW 0x0180
  2173. /*
  2174. * NOTE -- WFDIALOGWINDOW is used in WOW. DO NOT CHANGE without
  2175. * changing WD_DIALOG_WINDOW in winuser.w
  2176. */
  2177. #define WFDIALOGWINDOW 0x0201
  2178. #define WFTITLESET 0x0202
  2179. #define WFSERVERSIDEPROC 0x0204
  2180. #define WFANSIPROC 0x0208
  2181. #define WFBEINGACTIVATED 0x0210 // prevent recursion in xxxActivateThis Window
  2182. #define WFHASPALETTE 0x0220
  2183. #define WFPAINTNOTPROCESSED 0x0240 // WM_PAINT message not processed
  2184. #define WFSYNCPAINTPENDING 0x0280
  2185. #define WFGOTQUERYSUSPENDMSG 0x0301
  2186. #define WFGOTSUSPENDMSG 0x0302
  2187. #define WFTOGGLETOPMOST 0x0304 // Toggle the WS_EX_TOPMOST bit ChangeStates
  2188. /*
  2189. * DON'T MOVE REDRAWIFHUNGFLAGS WITHOUT ADJUSTING WFANYHUNGREDRAW
  2190. */
  2191. #define WFREDRAWIFHUNG 0x0308
  2192. #define WFREDRAWFRAMEIFHUNG 0x0310
  2193. #define WFANYHUNGREDRAW 0x0318
  2194. #define WFANSICREATOR 0x0320
  2195. #define WFREALLYMAXIMIZABLE 0x0340 // The window fills the work area or monitor when maximized
  2196. #define WFDESTROYED 0x0380
  2197. #define WFWMPAINTSENT 0x0401
  2198. #define WFDONTVALIDATE 0x0402
  2199. #define WFSTARTPAINT 0x0404
  2200. #define WFOLDUI 0x0408
  2201. #define WFCEPRESENT 0x0410 // Client edge present
  2202. #define WFBOTTOMMOST 0x0420 // Bottommost window
  2203. #define WFFULLSCREEN 0x0440
  2204. #define WFINDESTROY 0x0480
  2205. /*
  2206. * DON'T MOVE ANY ONE OF THE FOLLOWING WFWINXXCOMPAT FLAGS,
  2207. * BECAUSE WFWINCOMPATMASK DEPENDS ON THEIR VALUES
  2208. */
  2209. #define WFWIN31COMPAT 0x0501 // Win 3.1 compatible window
  2210. #define WFWIN40COMPAT 0x0502 // Win 4.0 compatible window
  2211. #define WFWIN50COMPAT 0x0504 // Win 5.0 compatibile window
  2212. #define WFWINCOMPATMASK 0x0507 // Compatibility flag mask
  2213. #define WFMAXFAKEREGIONAL 0x0508 // Window has a fake region for maxing on 1 monitor
  2214. // Active Accessibility (Window Event) state
  2215. #define WFCLOSEBUTTONDOWN 0x0510
  2216. #define WFZOOMBUTTONDOWN 0x0520
  2217. #define WFREDUCEBUTTONDOWN 0x0540
  2218. #define WFHELPBUTTONDOWN 0x0580
  2219. #define WFLINEUPBUTTONDOWN 0x0601 // Line up/left scroll button down
  2220. #define WFPAGEUPBUTTONDOWN 0x0602 // Page up/left scroll area down
  2221. #define WFPAGEDNBUTTONDOWN 0x0604 // Page down/right scroll area down
  2222. #define WFLINEDNBUTTONDOWN 0x0608 // Line down/right scroll area down
  2223. #define WFSCROLLBUTTONDOWN 0x0610 // Any scroll button down?
  2224. #define WFVERTSCROLLTRACK 0x0620 // Vertical or horizontal scroll track...
  2225. #define WFALWAYSSENDNCPAINT 0x0640 // Always send WM_NCPAINT to children
  2226. #define WFPIXIEHACK 0x0680 // Send (HRGN)1 to WM_NCPAINT (see PixieHack)
  2227. /*
  2228. * WFFULLSCREENBASE MUST HAVE LOWORD OF 0. See SetFullScreen macro.
  2229. */
  2230. #define WFFULLSCREENBASE 0x0700 // Fullscreen flags take up 0x0701
  2231. #define WFFULLSCREENMASK 0x0707 // and 0x0702 and 0x0704
  2232. #define WEFTRUNCATEDCAPTION 0x0708 // The caption text was truncated -> caption tootip
  2233. #define WFNOANIMATE 0x0710 // ???
  2234. #define WFSMQUERYDRAGICON 0x0720 // ??? Small icon comes from WM_QUERYDRAGICON
  2235. #define WFSHELLHOOKWND 0x0740 // ???
  2236. #define WFISINITIALIZED 0x0780 // Window is initialized -- checked by WoW32
  2237. /*
  2238. * Add more state flags here, up to 0x0780.
  2239. * Look for empty slots above before adding to the end.
  2240. * Be sure to add the flag to the wFlags array in kd\userexts.c
  2241. */
  2242. /*
  2243. * Window Extended Style, from 0x0800 to 0x0B80.
  2244. */
  2245. #define WEFDLGMODALFRAME 0x0801 // WS_EX_DLGMODALFRAME
  2246. #define WEFDRAGOBJECT 0x0802 // ???
  2247. #define WEFNOPARENTNOTIFY 0x0804 // WS_EX_NOPARENTNOTIFY
  2248. #define WEFTOPMOST 0x0808 // WS_EX_TOPMOST
  2249. #define WEFACCEPTFILES 0x0810 // WS_EX_ACCEPTFILES
  2250. #define WEFTRANSPARENT 0x0820 // WS_EX_TRANSPARENT
  2251. #define WEFMDICHILD 0x0840 // WS_EX_MDICHILD
  2252. #define WEFTOOLWINDOW 0x0880 // WS_EX_TOOLWINDOW
  2253. #define WEFWINDOWEDGE 0x0901 // WS_EX_WINDOWEDGE
  2254. #define WEFCLIENTEDGE 0x0902 // WS_EX_CLIENTEDGE
  2255. #define WEFEDGEMASK 0x0903 // WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE
  2256. #define WEFCONTEXTHELP 0x0904 // WS_EX_CONTEXTHELP
  2257. #define WEFGHOSTMAKEVISIBLE 0x0908 // WS_EXP_GHOSTMAKEVISIBLE
  2258. // intl styles
  2259. #define WEFRIGHT 0x0910 // WS_EX_RIGHT
  2260. #define WEFRTLREADING 0x0920 // WS_EX_RTLREADING
  2261. #define WEFLEFTSCROLL 0x0940 // WS_EX_LEFTSCROLLBAR
  2262. #define WEFCONTROLPARENT 0x0A01 // WS_EX_CONTROLPARENT
  2263. #define WEFSTATICEDGE 0x0A02 // WS_EX_STATICEDGE
  2264. #define WEFAPPWINDOW 0x0A04 // WS_EX_APPWINDOW
  2265. #define WEFLAYERED 0x0A08 // WS_EX_LAYERED
  2266. #define WEFNOINHERITLAYOUT 0x0A10 // WS_EX_NOINHERITLAYOUT
  2267. #define WEFLAYOUTVBHRESERVED 0x0A20 // WS_EX_LAYOUTVBHRESERVED
  2268. #define WEFLAYOUTRTL 0x0A40 // WS_EX_LAYOUTRTL
  2269. #define WEFLAYOUTBTTRESERVED 0x0A80 // WS_EX_LAYOUTBTTRESERVED
  2270. /*
  2271. * To delay adding a new state3 DWORD in the WW structure, we're using
  2272. * the extended style bits for now. If we'll need more of these, we'll
  2273. * add the new DWORD and move these ones around
  2274. */
  2275. #define WEFPUIFOCUSHIDDEN 0x0B80 // focus indicators hidden
  2276. #define WEFPUIACCELHIDDEN 0x0B40 // keyboard acceleraors hidden
  2277. #define WEFPREDIRECTED 0x0B20 // redirection bit
  2278. #define WEFPCOMPOSITING 0x0B10 // compositing
  2279. /*
  2280. * Add more Window Extended Style flags here, up to 0x0B80.
  2281. * Be sure to add the flag to the wFlags array in kd\userexts.c
  2282. */
  2283. #ifdef REDIRECTION
  2284. #define WEFEXTREDIRECTED 0x0B01 // WS_EX_EXTREDIRECTED
  2285. #endif // REDIRECTION
  2286. #define WEFCOMPOSITED 0x0B02 // WS_EX_COMPOSITED
  2287. #define WEFPUIACTIVE 0x0B04 // WS_EXP_UIACTIVE
  2288. #define WEFNOACTIVATE 0x0B08 // WS_EX_NOACTIVATE
  2289. #ifdef LAME_BUTTON
  2290. #define WEFLAMEBUTTON 0x0980 // the window should display a lame button
  2291. #endif // LAME_BUTTON
  2292. /*
  2293. * Window styles, from 0x0E00 to 0x0F80.
  2294. */
  2295. #define WFMAXBOX 0x0E01 // WS_MAXIMIZEBOX
  2296. #define WFTABSTOP 0x0E01 // WS_TABSTOP
  2297. #define WFMINBOX 0x0E02 // WS_MAXIMIZEBOX
  2298. #define WFGROUP 0x0E02 // WS_GROUP
  2299. #define WFSIZEBOX 0x0E04 // WS_THICKFRAME, WS_SIZEBOX
  2300. #define WFSYSMENU 0x0E08 // WS_SYSMENU
  2301. #define WFHSCROLL 0x0E10 // WS_HSCROLL
  2302. #define WFVSCROLL 0x0E20 // WS_VSCROLL
  2303. #define WFDLGFRAME 0x0E40 // WS_DLGFRAME
  2304. #define WFTOPLEVEL 0x0E40 // ???
  2305. #define WFBORDER 0x0E80 // WS_BORDER
  2306. #define WFBORDERMASK 0x0EC0 // WS_BORDER | WS_DLGFRAME
  2307. #define WFCAPTION 0x0EC0 // WS_CAPTION
  2308. #define WFTILED 0x0F00 // WS_OVERLAPPED, WS_TILED
  2309. #define WFMAXIMIZED 0x0F01 // WS_MAXIMIZE
  2310. #define WFCLIPCHILDREN 0x0F02 // WS_CLIPCHILDREN
  2311. #define WFCLIPSIBLINGS 0x0F04 // WS_CLIPSIBLINGS
  2312. #define WFDISABLED 0x0F08 // WS_DISABLED
  2313. #define WFVISIBLE 0x0F10 // WS_VISIBLE
  2314. #define WFMINIMIZED 0x0F20 // WS_MINIMIZE
  2315. #define WFCHILD 0x0F40 // WS_CHILD
  2316. #define WFPOPUP 0x0F80 // WS_POPUP
  2317. #define WFTYPEMASK 0x0FC0 // WS_CHILD | WS_POPUP
  2318. #define WFICONICPOPUP 0x0FC0 // WS_CHILD | WS_POPUP
  2319. #define WFICONIC WFMINIMIZED
  2320. /*
  2321. * No more Window style flags are available, use Extended window styles.
  2322. */
  2323. /*
  2324. * Window Styles for built-in classes, from 0x0C00 to 0x0D80.
  2325. */
  2326. // Buttons
  2327. #define BFTYPEMASK 0x0C0F
  2328. #define BFRIGHTBUTTON 0x0C20
  2329. #define BFICON 0x0C40
  2330. #define BFBITMAP 0x0C80
  2331. #define BFIMAGEMASK 0x0CC0
  2332. #define BFLEFT 0x0D01
  2333. #define BFRIGHT 0x0D02
  2334. #define BFCENTER 0x0D03
  2335. #define BFHORZMASK 0x0D03
  2336. #define BFTOP 0x0D04
  2337. #define BFBOTTOM 0x0D08
  2338. #define BFVCENTER 0x0D0C
  2339. #define BFVERTMASK 0x0D0C
  2340. #define BFALIGNMASK 0x0D0F
  2341. #define BFPUSHLIKE 0x0D10
  2342. #define BFMULTILINE 0x0D20
  2343. #define BFNOTIFY 0x0D40
  2344. #define BFFLAT 0x0D80
  2345. #define ISBSTEXTOROD(pwnd) (!TestWF(pwnd, BFBITMAP) && !TestWF(pwnd, BFICON))
  2346. // Combos
  2347. #define CBFSIMPLE 0x0C01
  2348. #define CBFDROPDOWN 0x0C02
  2349. #define CBFDROPDOWNLIST 0x0C03
  2350. #define CBFEDITABLE 0x0C01
  2351. #define CBFDROPPABLE 0x0C02
  2352. #define CBFDROPTYPE 0x0C03
  2353. #define CBFOWNERDRAWFIXED 0x0C10
  2354. #define CBFOWNERDRAWVAR 0x0C20
  2355. #define CBFOWNERDRAW 0x0C30
  2356. #define CBFAUTOHSCROLL 0x0C40
  2357. #define CBFOEMCONVERT 0x0C80
  2358. #define CBFSORT 0x0D01
  2359. #define CBFHASSTRINGS 0x0D02
  2360. #define CBFNOINTEGRALHEIGHT 0x0D04
  2361. #define CBFDISABLENOSCROLL 0x0D08
  2362. #define CBFBUTTONUPTRACK 0x0D10
  2363. #define CBFUPPERCASE 0x0D20
  2364. #define CBFLOWERCASE 0x0D40
  2365. // Dialogs
  2366. #define DFSYSMODAL 0x0C02
  2367. #define DF3DLOOK 0x0C04
  2368. #define DFNOFAILCREATE 0x0C10
  2369. #define DFLOCALEDIT 0x0C20
  2370. #define WFNOIDLEMSG 0x0D01
  2371. #define DFCONTROL 0x0D04
  2372. // Edits
  2373. #define EFMULTILINE 0x0C04
  2374. #define EFUPPERCASE 0x0C08
  2375. #define EFLOWERCASE 0x0C10
  2376. #define EFPASSWORD 0x0C20
  2377. #define EFAUTOVSCROLL 0x0C40
  2378. #define EFAUTOHSCROLL 0x0C80
  2379. #define EFNOHIDESEL 0x0D01
  2380. #define EFCOMBOBOX 0x0D02
  2381. #define EFOEMCONVERT 0x0D04
  2382. #define EFREADONLY 0x0D08
  2383. #define EFWANTRETURN 0x0D10
  2384. #define EFNUMBER 0x0D20
  2385. // Scrollbars
  2386. #define SBFSIZEBOXTOPLEFT 0x0C02
  2387. #define SBFSIZEBOXBOTTOMRIGHT 0x0C04
  2388. #define SBFSIZEBOX 0x0C08
  2389. #define SBFSIZEGRIP 0x0C10
  2390. // Statics
  2391. #define SFTYPEMASK 0x0C1F
  2392. #define SFREALSIZECONTROL 0x0C40
  2393. #define SFNOPREFIX 0x0C80
  2394. #define SFNOTIFY 0x0D01
  2395. #define SFCENTERIMAGE 0x0D02
  2396. #define SFRIGHTJUST 0x0D04
  2397. #define SFREALSIZEIMAGE 0x0D08
  2398. #define SFSUNKEN 0x0D10
  2399. #define SFEDITCONTROL 0x0D20
  2400. #define SFELLIPSISMASK 0x0DC0
  2401. #define SFWIDELINESPACING 0x0C20
  2402. /*
  2403. *
  2404. */
  2405. #define SYS_ALTERNATE 0x2000
  2406. #define SYS_PREVKEYSTATE 0x4000
  2407. /*** AWESOME HACK ALERT!!!
  2408. *
  2409. * The low byte of the WF?PRESENT state flags must NOT be the
  2410. * same as the low byte of the WFBORDER and WFCAPTION flags,
  2411. * since these are used as paint hint masks. The masks are calculated
  2412. * with the MaskWF macro below.
  2413. *
  2414. * The magnitude of this hack compares favorably with that of the national debt.
  2415. *
  2416. * STATEOFFSET is the offset into the WND structure of the state field.
  2417. * The state field is actually part of the WW structure defined in wowuserp.h
  2418. * which is embedded in the WND structure.
  2419. */
  2420. #define STATEOFFSET (FIELD_OFFSET(WND, state))
  2421. #define TestWF(hwnd, flag) (*(((KPBYTE)(hwnd)) + STATEOFFSET + (int)HIBYTE(flag)) & LOBYTE(flag))
  2422. #define SetWF(hwnd, flag) (*(((KPBYTE)(hwnd)) + STATEOFFSET + (int)HIBYTE(flag)) |= LOBYTE(flag))
  2423. #define ClrWF(hwnd, flag) (*(((KPBYTE)(hwnd)) + STATEOFFSET + (int)HIBYTE(flag)) &= ~LOBYTE(flag))
  2424. #define MaskWF(flag) ((WORD)( (HIBYTE(flag) & 1) ? LOBYTE(flag) << 8 : LOBYTE(flag)))
  2425. #define TestwndChild(hwnd) (TestWF(hwnd, WFTYPEMASK) == LOBYTE(WFCHILD))
  2426. #define TestwndIPopup(hwnd) (TestWF(hwnd, WFTYPEMASK) == LOBYTE(WFICONICPOPUP))
  2427. #define TestwndTiled(hwnd) (TestWF(hwnd, WFTYPEMASK) == LOBYTE(WFTILED))
  2428. #define TestwndNIPopup(hwnd) (TestWF(hwnd, WFTYPEMASK) == LOBYTE(WFPOPUP))
  2429. #define TestwndPopup(hwnd) (TestwndNIPopup(hwnd) || TestwndIPopup(hwnd))
  2430. #define TestwndHI(hwnd) (TestwndTiled(hwnd) || TestwndIPopup(hwnd))
  2431. #define GetChildParent(pwnd) (TestwndChild(pwnd) ? pwnd->spwndParent : (PWND)NULL)
  2432. #define GetWindowCreator(pwnd) (TestwndChild(pwnd) ? pwnd->spwndParent : pwnd->spwndOwner)
  2433. #define TestwndFrameOn(pwnd) (TestWF(pwnd, WFFRAMEON) && (GETPTI(pwnd)->pq == gpqForeground))
  2434. #define GetFullScreen(pwnd) (TestWF(pwnd, WFFULLSCREENMASK))
  2435. #define SetFullScreen(pwnd, state) (ClrWF(pwnd, WFFULLSCREENMASK), \
  2436. SetWF(pwnd, WFFULLSCREENBASE | (state & WFFULLSCREENMASK)))
  2437. #define FTrueVis(pwnd) (_IsWindowVisible(pwnd))
  2438. #define _IsWindowEnabled(pwnd) (TestWF(pwnd, WFDISABLED) == 0)
  2439. #define _IsIconic(pwnd) (TestWF(pwnd, WFMINIMIZED) != 0)
  2440. #define _IsZoomed(pwnd) (TestWF(pwnd, WFMAXIMIZED) != 0)
  2441. #define SV_UNSET 0x0000
  2442. #define SV_SET 0x0001
  2443. #define SV_CLRFTRUEVIS 0x0002
  2444. /*
  2445. * System menu IDs
  2446. */
  2447. #define ID_SYSMENU 0x10
  2448. #define ID_CLOSEMENU 0x20
  2449. #define CHILDSYSMENU ID_CLOSEMENU
  2450. #define ID_DIALOGSYSMENU 0x30
  2451. #define ID_HSCROLLMENU 0x40
  2452. #define ID_VSCROLLMENU 0x50
  2453. /*
  2454. * Menu Item Structure
  2455. */
  2456. typedef struct tagITEM {
  2457. UINT fType; // Item Type Flags
  2458. UINT fState; // Item State Flags
  2459. UINT wID;
  2460. PMENU spSubMenu; /* Handle to a popup */
  2461. KHANDLE hbmpChecked; /* Bitmap for an on check */
  2462. KHANDLE hbmpUnchecked; /* Bitmap for an off check */
  2463. KLPWSTR lpstr; //item's text
  2464. DWORD cch; /* String: WCHAR count */
  2465. KERNEL_ULONG_PTR dwItemData;
  2466. DWORD xItem;
  2467. DWORD yItem;
  2468. DWORD cxItem;
  2469. DWORD cyItem;
  2470. DWORD dxTab;
  2471. DWORD ulX; /* String: Underline start */
  2472. DWORD ulWidth; /* String: underline width */
  2473. KHBITMAP hbmp; // item's bitmap
  2474. int cxBmp; // bitmap width
  2475. int cyBmp; // bitmap height
  2476. } ITEM, * KPTR_MODIFIER PITEM, * KPTR_MODIFIER LPITEM;
  2477. /*
  2478. * MENULIST structure, holds the PMENUs that contain a submenu
  2479. * We store a list of menus in MENU.pParentMenus as a menu
  2480. * can be submenu in more items
  2481. */
  2482. typedef struct tagMENULIST {
  2483. struct tagMENULIST *pNext;
  2484. PMENU pMenu;
  2485. } MENULIST, * KPTR_MODIFIER PMENULIST;
  2486. /*
  2487. * Scroll menu arrow flags
  2488. */
  2489. #define MSA_OFF 0
  2490. #define MSA_ON 1
  2491. #define MSA_ATTOP 2
  2492. #define MSA_ATBOTTOM 3
  2493. /*
  2494. * Menu Structure
  2495. */
  2496. typedef struct tagMENU {
  2497. PROCDESKHEAD head;
  2498. DWORD fFlags; /* Menu Flags */
  2499. int iItem; /* Contains the position of the selected
  2500. item in the menu. -1 if no selection */
  2501. UINT cAlloced; // Number of items that can fit in rgItems
  2502. UINT cItems; /* Number of items in rgItems */
  2503. DWORD cxMenu;
  2504. DWORD cyMenu;
  2505. DWORD cxTextAlign; /* Text align offset for popups*/
  2506. PWND spwndNotify; /* The owner hwnd of this menu */
  2507. PITEM rgItems; /* The list of items in this menu */
  2508. PMENULIST pParentMenus; // The list of parents (menus that have this as submenu)
  2509. DWORD dwContextHelpId;// Context help Id for the whole menu
  2510. DWORD cyMax; /* max menu height after which menu scrolls */
  2511. KERNEL_ULONG_PTR dwMenuData; /* app-supplied menu data */
  2512. KHBRUSH hbrBack; // background brush for menu
  2513. int iTop; // Scroll top
  2514. int iMaxTop; // Scroll MaxTop
  2515. DWORD dwArrowsOn:2; // Scroll flags
  2516. } MENU, * KPTR_MODIFIER PMENU;
  2517. /*
  2518. * Items used for WinHelp and Context Sensitive help support
  2519. */
  2520. #define ID_HELPMENU 4
  2521. // WINHELP4 invoked type
  2522. enum {
  2523. TYPE_NORMAL,
  2524. TYPE_POPUP,
  2525. TYPE_TCARD
  2526. };
  2527. typedef struct tagDLGENUMDATA {
  2528. PWND pwndDialog;
  2529. PWND pwndControl;
  2530. POINT ptCurHelp;
  2531. } DLGENUMDATA, *PDLGENUMDATA;
  2532. BOOL CALLBACK EnumPwndDlgChildProc(PWND pwnd, LPARAM lParam);
  2533. BOOL FIsParentDude(PWND pwnd);
  2534. #define MNF_DONTSKIPSEPARATORS 0x0001
  2535. /*
  2536. * The following masks can be used along with the wDisableFlags field of SB
  2537. * to find if the Up/Left or Down/Right arrow or Both are disabled;
  2538. * Now it is possible to selectively Enable/Disable just one or both the
  2539. * arrows in a scroll bar control;
  2540. */
  2541. #define LTUPFLAG 0x0001 // Left/Up arrow disable flag.
  2542. #define RTDNFLAG 0x0002 // Right/Down arrow disable flag.
  2543. typedef struct tagSBCALC {
  2544. SBDATA; /* this must be first -- we cast structure pointers */
  2545. int pxTop;
  2546. int pxBottom;
  2547. int pxLeft;
  2548. int pxRight;
  2549. int cpxThumb;
  2550. int pxUpArrow;
  2551. int pxDownArrow;
  2552. int pxStart; /* Initial position of thumb */
  2553. int pxThumbBottom;
  2554. int pxThumbTop;
  2555. int cpx;
  2556. int pxMin;
  2557. } SBCALC, *PSBCALC;
  2558. typedef struct tagSBTRACK {
  2559. DWORD fHitOld : 1;
  2560. DWORD fTrackVert : 1;
  2561. DWORD fCtlSB : 1;
  2562. DWORD fTrackRecalc: 1;
  2563. PWND spwndTrack;
  2564. PWND spwndSB;
  2565. PWND spwndSBNotify;
  2566. RECT rcTrack;
  2567. VOID (*xxxpfnSB)(PWND, UINT, WPARAM, LPARAM, PSBCALC);
  2568. UINT cmdSB;
  2569. UINT_PTR hTimerSB;
  2570. int dpxThumb; /* Offset from mouse point to start of thumb box */
  2571. int pxOld; /* Previous position of thumb */
  2572. int posOld;
  2573. int posNew;
  2574. int nBar;
  2575. PSBCALC pSBCalc;
  2576. } SBTRACK, *PSBTRACK;
  2577. /*
  2578. * How many times a thread can spin through get/peek message without idling
  2579. * before the system puts the app in the background.
  2580. */
  2581. #define CSPINBACKGROUND 100
  2582. #define CCHTITLEMAX 256
  2583. #define SW_MDIRESTORE 0xCC /* special xxxMinMaximize() command for MDI */
  2584. /*
  2585. * This is used by CreateWindow() - the 16 bit version of CW_USEDEFAULT,
  2586. * that we still need to support.
  2587. */
  2588. #define CW2_USEDEFAULT 0x8000
  2589. #define CW_FLAGS_DIFFHMOD 0x80000000
  2590. #define CW_FLAGS_VERSIONCLASS 0x40000000
  2591. /*
  2592. * Menu commands
  2593. */
  2594. //#define MENUBIT (0x8000)
  2595. //#define MENUUP (0x8000 | VK_UP)
  2596. //#define MENUDOWN (0x8000 | VK_DOWN)
  2597. //#define MENULEFT (0x8000 | VK_LEFT)
  2598. //#define MENURIGHT (0x8000 | VK_RIGHT)
  2599. //#define MENUEXECUTE TEXT('\r') /* Return character */
  2600. #define MENUSYSMENU TEXT(' ') /* Space character */
  2601. #define MENUCHILDSYSMENU TEXT('-') /* Hyphen */
  2602. #define LAMEBUTTONHOTKEY TEXT('/') /* Forward slash */
  2603. #define MF_ALLSTATE 0x00FF
  2604. #define MF_MAINMENU 0xFFFF
  2605. #define MFMWFP_OFFMENU 0
  2606. #define MFMWFP_MAINMENU 0x0000FFFF
  2607. #define MFMWFP_NOITEM 0xFFFFFFFF
  2608. #define MFMWFP_UPARROW 0xFFFFFFFD /* Warning: Also used to define IDSYS_MNUP */
  2609. #define MFMWFP_DOWNARROW 0xFFFFFFFC /* Warning: Also used to define IDSYS_MNDOWN */
  2610. #define MFMWFP_MINVALID 0xFFFFFFFC
  2611. #define MFMWFP_ALTMENU 0xFFFFFFFB
  2612. #define MFMWFP_FIRSTITEM 0
  2613. /*
  2614. * NOTE: SetMF() can only be used on single bit flags.
  2615. */
  2616. #define SetMF(pmenu, flag) ((pmenu)->fFlags |= (flag))
  2617. #define ClearMF(pmenu, flag) ((pmenu)->fFlags &= ~(flag))
  2618. #define TestMF(pmenu, flag) ((pmenu)->fFlags & (flag))
  2619. #define SetMFS(pitem, flag) ((pitem)->fState |= (flag))
  2620. #define TestMFS(pitem, flag) ((pitem)->fState & (flag))
  2621. #define ClearMFS(pitem, flag) ((pitem)->fState &= ~(flag))
  2622. #define SetMFT(pitem, flag) ((pitem)->fType |= (flag))
  2623. #define TestMFT(pitem, flag) ((pitem)->fType & (flag))
  2624. #define ClearMFT(pitem, flag) ((pitem)->fType &= ~(flag))
  2625. /*
  2626. * Dialog structure (dlg). The window-words for the dialog structure must
  2627. * be EXACTLY 30 bytes long! This is because Windows 3.0 exported a constant
  2628. * called DLGWINDOWEXTRA that resolved to 30. Although we could redefine this
  2629. * for 32-bit windows apps, we cannot redefine it for 16 bit apps (it is
  2630. * a difficult problem). So instead we peg the window-words at 30 bytes
  2631. * exactly, and allocate storage for the other information.
  2632. */
  2633. typedef struct _DLG {
  2634. DLGPROC lpfnDlg;
  2635. DWORD flags; /* Various useful flags -- see definitions below */
  2636. int cxChar;
  2637. int cyChar;
  2638. KHWND hwndFocusSave;
  2639. UINT fEnd : 1;
  2640. UINT fDisabled : 1;
  2641. KERNEL_INT_PTR result; /* DialogBox result */
  2642. KHANDLE hData; /* Global handle for edit ctl storage. */
  2643. KHFONT hUserFont; /* Handle of the font mentioned by the user in template*/
  2644. #ifdef SYSMODALWINDOWS
  2645. KHWND hwndSysModalSave; /* Previous sysmodal window saved here */
  2646. #endif
  2647. } DLG, * KPTR_MODIFIER PDLG;
  2648. typedef struct _DIALOG {
  2649. WND wnd;
  2650. KERNEL_LRESULT resultWP; /* window proc result -- DWL_MSGRESULT (+0) */
  2651. PDLG pdlg;
  2652. KERNEL_LONG_PTR unused; /* DWL_USER (+8) */
  2653. BYTE reserved[DLGWINDOWEXTRA - sizeof(KERNEL_LRESULT) - sizeof(PDLG) - sizeof(KERNEL_LONG_PTR)];
  2654. } DIALOG, * KPTR_MODIFIER PDIALOG;
  2655. #define PDLG(pwnd) (((PDIALOG)pwnd)->pdlg)
  2656. /*
  2657. * Flags definitions for DLG.flags
  2658. */
  2659. #define DLGF_ANSI 0x01 /* lpfnDlg is an ANSI proc */
  2660. /*
  2661. * MDI typedefs
  2662. */
  2663. typedef struct tagMDI {
  2664. UINT cKids;
  2665. HWND hwndMaxedChild;
  2666. HWND hwndActiveChild;
  2667. HMENU hmenuWindow;
  2668. UINT idFirstChild;
  2669. UINT wScroll;
  2670. LPWSTR pTitle;
  2671. UINT iChildTileLevel;
  2672. } MDI, * PMDI;
  2673. typedef struct tagMDIWND {
  2674. WND wnd;
  2675. KERNEL_UINT_PTR dwReserved; // quattro pro 1.0 stores stuff here!!
  2676. PMDI pmdi;
  2677. } MDIWND, * KPTR_MODIFIER PMDIWND;
  2678. #define CST_DESKTOP (UINT)0x00000001
  2679. #define CST_RIT (UINT)0x00000002
  2680. #define CST_GHOST (UINT)0x00000003
  2681. #define CST_POWER (UINT)0x00000004
  2682. #define CST_LAST (UINT)0x00000004
  2683. #define GWLP_MDIDATA (FIELD_OFFSET(MDIWND, pmdi) - sizeof(WND))
  2684. #define TIF_INCLEANUP (UINT)0x00000001
  2685. #define TIF_16BIT (UINT)0x00000002
  2686. #define TIF_SYSTEMTHREAD (UINT)0x00000004
  2687. #define TIF_CSRSSTHREAD (UINT)0x00000008
  2688. #define TIF_TRACKRECTVISIBLE (UINT)0x00000010
  2689. #define TIF_ALLOWFOREGROUNDACTIVATE (UINT)0x00000020
  2690. #define TIF_DONTATTACHQUEUE (UINT)0x00000040
  2691. #define TIF_DONTJOURNALATTACH (UINT)0x00000080
  2692. #define TIF_WOW64 (UINT)0x00000100 /* Thread is in a emulated 32bit process */
  2693. #define TIF_INACTIVATEAPPMSG (UINT)0x00000200
  2694. #define TIF_SPINNING (UINT)0x00000400
  2695. #define TIF_PALETTEAWARE (UINT)0x00000800
  2696. #define TIF_SHAREDWOW (UINT)0x00001000
  2697. #define TIF_FIRSTIDLE (UINT)0x00002000
  2698. #define TIF_WAITFORINPUTIDLE (UINT)0x00004000
  2699. #define TIF_MOVESIZETRACKING (UINT)0x00008000
  2700. #define TIF_VDMAPP (UINT)0x00010000
  2701. #define TIF_DOSEMULATOR (UINT)0x00020000
  2702. #define TIF_GLOBALHOOKER (UINT)0x00040000
  2703. #define TIF_DELAYEDEVENT (UINT)0x00080000
  2704. #define TIF_MSGPOSCHANGED (UINT)0x00100000
  2705. #define TIF_IGNOREPLAYBACKDELAY (UINT)0x00200000
  2706. #define TIF_ALLOWOTHERACCOUNTHOOK (UINT)0x00400000
  2707. #define TIF_MEOW (UINT)0x00800000 /* Thread is associated with the MEOW VM */
  2708. #define TIF_GUITHREADINITIALIZED (UINT)0x01000000
  2709. #define TIF_DISABLEIME (UINT)0x02000000
  2710. #define TIF_INGETTEXTLENGTH (UINT)0x04000000
  2711. #define TIF_ANSILENGTH (UINT)0x08000000
  2712. #define TIF_DISABLEHOOKS (UINT)0x10000000
  2713. #define TIF_RESTRICTED (UINT)0x20000000
  2714. #define TIF_QUITPOSTED (UINT)0x40000000
  2715. /*
  2716. * Client Thread Information Structure.
  2717. *
  2718. * This structure contains information regarding the
  2719. * thread. This is viewable from both the client and
  2720. * kernel processes.
  2721. */
  2722. typedef struct tagCLIENTTHREADINFO {
  2723. UINT CTIF_flags;
  2724. WORD fsChangeBits; // Bits changes since last compared
  2725. WORD fsWakeBits; // Bits currently available
  2726. WORD fsWakeBitsJournal; // Bits saved while journalling
  2727. WORD fsWakeMask; // Bits looking for when asleep
  2728. LONG timeLastRead; // Time of last input read
  2729. #ifdef MESSAGE_PUMP_HOOK
  2730. LONG cMessagePumpHooks; // Count of installed MPH's on this thread
  2731. #endif
  2732. } CLIENTTHREADINFO;
  2733. #define CTIF_SYSQUEUELOCKED (UINT)0x00000001
  2734. #define CTIF_INSENDMESSAGE (UINT)0x00000002
  2735. #define CTIF_INCALLBACKMESSAGE (UINT)0x00000004
  2736. /*
  2737. * First check for a 0, 0 filter which means we want all input.
  2738. * If inverted message range, filter is exclusive.
  2739. */
  2740. #define CheckMsgFilter(wMsg, wMsgFilterMin, wMsgFilterMax) \
  2741. ( ((wMsgFilterMin) == 0 && (wMsgFilterMax) == 0xFFFFFFFF) \
  2742. || ( ((wMsgFilterMin) > (wMsgFilterMax)) \
  2743. ? (((wMsg) < (wMsgFilterMax)) || ((wMsg) > (wMsgFilterMin))) \
  2744. : (((wMsg) >= (wMsgFilterMin)) && ((wMsg) <= (wMsgFilterMax)))))
  2745. UINT CalcWakeMask(UINT wMsgFilterMin, UINT wMsgFilterMax, UINT fsWakeMaskFilter);
  2746. /*
  2747. * GetInputBits
  2748. *
  2749. * This function checks if the specified input (fsWakeMask) has arrived
  2750. * (fsChangeBits) or it's available (fsWakeBits).
  2751. */
  2752. __inline WORD GetInputBits(
  2753. CLIENTTHREADINFO *pcti,
  2754. WORD fsWakeMask,
  2755. BOOL fAvailable)
  2756. {
  2757. return (pcti->fsChangeBits | (fAvailable ? pcti->fsWakeBits : 0)) & fsWakeMask;
  2758. }
  2759. typedef struct tagCARET {
  2760. struct tagWND *spwnd;
  2761. UINT fVisible : 1;
  2762. UINT fOn : 1;
  2763. int iHideLevel;
  2764. int x;
  2765. int y;
  2766. int cy;
  2767. int cx;
  2768. HBITMAP hBitmap;
  2769. UINT_PTR hTimer;
  2770. DWORD tid;
  2771. /*
  2772. * The following values are used to track the equivelent client coordinates
  2773. * for caret positions in a window with a private DC.
  2774. * See Also: zzzSetCaretPos, _GetGUIThreadInfo
  2775. */
  2776. int xOwnDc;
  2777. int yOwnDc;
  2778. int cxOwnDc;
  2779. int cyOwnDc;
  2780. } CARET, *PCARET;
  2781. #define XPixFromXDU(x, cxChar) MultDiv(x, cxChar, 4)
  2782. #define YPixFromYDU(y, cyChar) MultDiv(y, cyChar, 8)
  2783. #define XDUFromXPix(x, cxChar) MultDiv(x, 4, cxChar)
  2784. #define YDUFromYPix(y, cyChar) MultDiv(y, 8, cyChar)
  2785. /*
  2786. * Flags for the Q structure.
  2787. */
  2788. #define QF_UPDATEKEYSTATE (UINT)0x00001 // Set as key events are received. See PostUpdateKeyStateEvent.
  2789. #define QF_FMENUSTATUSBREAK (UINT)0x00004 // Mouse button went up/down while ALT key was down == ignore ALT up.
  2790. #define QF_FMENUSTATUS (UINT)0x00008 // ALT key down - toggle menu status mode (enter or exit).
  2791. #define QF_FF10STATUS (UINT)0x00010 // Context menu key down. Treat us ALT if set on key up.
  2792. #define QF_MOUSEMOVED (UINT)0x00020 // Mouse has moved but no move posted yet. Coalescing & performance
  2793. #define QF_ACTIVATIONCHANGE (UINT)0x00040 // This flag is examined in the
  2794. // menu loop code so that we
  2795. // exit from menu mode if
  2796. // another window was activated
  2797. // while we were tracking
  2798. // menus. This flag is set
  2799. // whenever we activate a new
  2800. // window.
  2801. #define QF_TABSWITCHING (UINT)0x00080 // This bit is used as a
  2802. // safety check when alt-
  2803. // tabbing between apps. It
  2804. // tells us when to expect
  2805. // a tab-switch in dwp.c.
  2806. #define QF_KEYSTATERESET (UINT)0x00100 // Used by xxxSwitchDesktop to overwrite the key state upon desktop activation
  2807. #define QF_INDESTROY (UINT)0x00200 // Debug only. To make sure we don't use a queue to be destroyed.
  2808. #define QF_LOCKNOREMOVE (UINT)0x00400 // An input message has been peeked but not removed. Must be removed next.
  2809. #define QF_FOCUSNULLSINCEACTIVE (UINT)0x00800 // Application set focus to NULL. Don't send focus messages on activation
  2810. #define QF_DIALOGACTIVE (UINT)0x04000 // To pass this info in key/char messages lparam's. Undocumented.
  2811. #define QF_EVENTDEACTIVATEREMOVED (UINT)0x08000 //
  2812. #define QF_CAPTURELOCKED 0x00100000 // Set by menu mode. Prevent capture changes.
  2813. #define QF_ACTIVEWNDTRACKING 0x00200000 // Mouse has moved over a new window while in active wnd tracking mode
  2814. /*
  2815. * Constants for Round Frame balloons
  2816. */
  2817. #define RNDFRM_CORNER 10
  2818. #define RNDFRM_BORDER 3
  2819. /*
  2820. * Constants for GetRealClientRect
  2821. */
  2822. #define GRC_SCROLLS 0x0001
  2823. #define GRC_MINWNDS 0x0002
  2824. #define GRC_FULLSCREEN 0x0004
  2825. /*
  2826. * Scroll bar info structure
  2827. */
  2828. typedef struct tagSBWND {
  2829. WND wnd;
  2830. BOOL fVert;
  2831. #ifdef COLOR_HOTTRACKING
  2832. int ht;
  2833. #endif // COLOR_HOTTRACKING
  2834. UINT wDisableFlags; /* Indicates which arrow is disabled; */
  2835. SBCALC SBCalc;
  2836. } SBWND, * KPTR_MODIFIER PSBWND;
  2837. //
  2838. // Special regions
  2839. //
  2840. #define HRGN_NONE ((HRGN)-1)
  2841. #define HRGN_EMPTY ((HRGN)0)
  2842. #define HRGN_FULL ((HRGN)1)
  2843. #define HRGN_MONITOR ((HRGN)2)
  2844. #define HRGN_SPECIAL_LAST HRGN_MONITOR
  2845. /*
  2846. * SendMsgTimeout client/server transition struct
  2847. */
  2848. typedef struct tagSNDMSGTIMEOUT { /* smto */
  2849. UINT fuFlags; // how to send the message, SMTO_BLOCK, SMTO_ABORTIFHUNG
  2850. UINT uTimeout; // time-out duration
  2851. ULONG_PTR lSMTOReturn; // return value TRUE or FALSE
  2852. ULONG_PTR lSMTOResult; // result value for lpdwResult
  2853. } SNDMSGTIMEOUT, *PSNDMSGTIMEOUT;
  2854. typedef struct tagSNDMSGCALLBACK {
  2855. SENDASYNCPROC lpResultCallBack;
  2856. ULONG_PTR dwData;
  2857. } SNDMSGCALLBACK, *PSNDMSGCALLBACK;
  2858. #ifndef _USERK_
  2859. #if DBG
  2860. ULONG_PTR USERTHREADCONNECT();
  2861. __inline ULONG_PTR USERTHREADCONNECT()
  2862. {
  2863. ULONG_PTR ulReturn;
  2864. ulReturn = NtUserGetThreadState(UserThreadConnect);
  2865. UserAssert(ulReturn == 0 || ulReturn == 1);
  2866. return ulReturn;
  2867. }
  2868. #else
  2869. #define USERTHREADCONNECT() (NtUserGetThreadState(UserThreadConnect))
  2870. #endif // DBG
  2871. #define ConnectIfNecessary(retval) \
  2872. { \
  2873. if ((NtCurrentTebShared()->Win32ThreadInfo == NULL) \
  2874. && !USERTHREADCONNECT()) { \
  2875. return retval; \
  2876. } \
  2877. }
  2878. #endif // !_USERK_
  2879. /*
  2880. * Button data structures (use to be in usercli.h)
  2881. */
  2882. typedef struct tagBUTN {
  2883. PWND spwnd;
  2884. UINT buttonState;
  2885. KHANDLE hFont;
  2886. KHANDLE hImage;
  2887. UINT fPaintKbdCuesOnly : 1;
  2888. } BUTN, * KPTR_MODIFIER PBUTN;
  2889. typedef struct tagBUTNWND {
  2890. WND wnd;
  2891. PBUTN pbutn;
  2892. } BUTNWND, * KPTR_MODIFIER PBUTNWND;
  2893. /*
  2894. * IME control data structures
  2895. */
  2896. typedef struct tagIMEUI {
  2897. PWND spwnd;
  2898. KHIMC hIMC;
  2899. KHWND hwndIMC;
  2900. KHKL hKL;
  2901. KHWND hwndUI; // To keep handle for UI window.
  2902. int nCntInIMEProc; // Non-zero if hwnd has called into ImeWndProc.
  2903. BOOL fShowStatus:1; // TRUE if don't want to show IME's window.
  2904. BOOL fActivate:1; // TRUE if hwnd has called into ImeWndProc.
  2905. BOOL fDestroy:1; // TRUE if hwnd has called into ImeWndProc.
  2906. BOOL fDefault:1; // TRUE if this is the default IME.
  2907. BOOL fChildThreadDef:1; // TRUE if this is the default IME which
  2908. // thread has only child window.
  2909. BOOL fCtrlShowStatus:1; // Control status of show status bar.
  2910. BOOL fFreeActiveEvent:1; // Control status of show status bar.
  2911. #ifdef CUAS_ENABLE
  2912. // Cicero
  2913. DWORD dwPrevToolbarStatus; // Cicero for Hide or RestoreToolbar
  2914. #endif // CUAS_ENABLE
  2915. } IMEUI, *PIMEUI;
  2916. typedef struct tagIMEWND {
  2917. WND wnd;
  2918. PIMEUI pimeui;
  2919. } IMEWND, * KPTR_MODIFIER PIMEWND;
  2920. /*
  2921. * SysErrorBox is a 3.1 API that has no 32-bit equivalent. It's
  2922. * implemented for WOW in harderr.c.
  2923. */
  2924. #define MAX_SEB_STYLES 11 /* number of SEB_* values */
  2925. /*
  2926. * The next values should be in the same order
  2927. * with the ones in IDOK and STR_OK lists
  2928. */
  2929. #define SEB_OK 0 /* Button with "OK". */
  2930. #define SEB_CANCEL 1 /* Button with "Cancel" */
  2931. #define SEB_ABORT 2 /* Button with "&Abort" */
  2932. #define SEB_RETRY 3 /* Button with "&Retry" */
  2933. #define SEB_IGNORE 4 /* Button with "&Ignore" */
  2934. #define SEB_YES 5 /* Button with "&Yes" */
  2935. #define SEB_NO 6 /* Button with "&No" */
  2936. #define SEB_CLOSE 7 /* Button with "&Close" */
  2937. #define SEB_HELP 8 /* Button with "&Help" */
  2938. #define SEB_TRYAGAIN 9 /* Button with "&Try Again" */
  2939. #define SEB_CONTINUE 10 /* Button with "&Continue" */
  2940. #define SEB_DEFBUTTON 0x8000 /* Mask to make this button default */
  2941. typedef struct _MSGBOXDATA { // mbd
  2942. MSGBOXPARAMS; // Must be 1st item in structure
  2943. PWND pwndOwner; // Converted hwndOwner
  2944. WORD wLanguageId;
  2945. INT * pidButton; // Array of button IDs
  2946. LPWSTR * ppszButtonText; // Array of button text strings
  2947. UINT cButtons; // Number of buttons
  2948. UINT DefButton;
  2949. UINT CancelId;
  2950. DWORD dwTimeout;
  2951. HWND *phwndList;
  2952. } MSGBOXDATA, *PMSGBOXDATA, *LPMSGBOXDATA;
  2953. LPWSTR MB_GetString(UINT wBtn);
  2954. int SoftModalMessageBox(LPMSGBOXDATA lpmb);
  2955. DWORD GetContextHelpId(PWND pwnd);
  2956. PITEM MNLookUpItem(PMENU pMenu, UINT wCmd, BOOL fByPosition, PMENU *ppMenuItemIsOn);
  2957. BOOL xxxMNCanClose(PWND pwnd);
  2958. PMENU xxxGetSysMenuHandle(PWND pwnd);
  2959. PWND GetPrevPwnd(PWND pwndList, PWND pwndFind);
  2960. BOOL _RegisterServicesProcess(DWORD dwProcessId);
  2961. #ifdef _USERK_
  2962. #define RTLMENU PMENU
  2963. #define RtlGetSubMenu(rtlMenu, nPos) _GetSubMenu(rtlMenu, nPos)
  2964. #define xxxRtlSetMenuInfo xxxSetMenuInfo
  2965. #define xxxRtlInsertMenuItem(rtlMenu, wIndex, fByPos, lpmii, pstrItem) \
  2966. xxxInsertMenuItem(rtlMenu, wIndex, fByPos, lpmii, pstrItem)
  2967. #define xxxRtlSetMenuItemInfo(rtlMenu, uId, pmii) \
  2968. xxxSetMenuItemInfo(rtlMenu, uId, FALSE, pmii, NULL)
  2969. #else
  2970. #define RTLMENU HMENU
  2971. #define RtlGetSubMenu(rtlMenu, nPos) GetSubMenu(rtlMenu, nPos)
  2972. #define xxxRtlSetMenuInfo NtUserThunkedMenuInfo
  2973. #define xxxRtlInsertMenuItem(rtlMenu, wIndex, fByPos, lpmii, pstrItem) \
  2974. InternalInsertMenuItem(rtlMenu, wIndex, fByPos, lpmii)
  2975. #define xxxRtlSetMenuItemInfo(rtlMenu, uId, pmii) \
  2976. NtUserThunkedMenuItemInfo(rtlMenu, uId, FALSE, FALSE, pmii, NULL)
  2977. #endif
  2978. #ifdef LAME_BUTTON
  2979. RTLMENU xxxLoadSysMenu(UINT uMenuId, PWND pwnd);
  2980. #else
  2981. RTLMENU xxxLoadSysMenu(UINT uMenuId);
  2982. #endif // LAME_BUTTON
  2983. BOOL _FChildVisible(PWND pwnd);
  2984. #define CH_PREFIX TEXT('&')
  2985. //
  2986. // Japan support both Kanji and English mnemonic characters,
  2987. // toggled from control panel. Both mnemonics are embedded in menu
  2988. // resource templates. The following prefixes guide their parsing.
  2989. //
  2990. #define CH_ENGLISHPREFIX 0x1E
  2991. #define CH_KANJIPREFIX 0x1F
  2992. BOOL RtlWCSMessageWParamCharToMB(DWORD msg, WPARAM *pWParam);
  2993. BOOL RtlMBMessageWParamCharToWCS(DWORD msg, WPARAM *pWParam);
  2994. VOID RtlInitLargeAnsiString(PLARGE_ANSI_STRING plstr, LPCSTR psz,
  2995. UINT cchLimit);
  2996. VOID RtlInitLargeUnicodeString(PLARGE_UNICODE_STRING plstr, LPCWSTR psz,
  2997. UINT cchLimit);
  2998. DWORD RtlGetExpWinVer(HANDLE hmod);
  2999. /***************************************************************************\
  3000. *
  3001. * International multi-keyboard layout/font support
  3002. *
  3003. \***************************************************************************/
  3004. #define DT_CHARSETDRAW 1
  3005. #define DT_GETNEXTWORD 2
  3006. typedef void (FAR *LPFNTEXTDRAW)(HDC, int, int, LPWSTR, int, DWORD);
  3007. typedef struct {
  3008. RECT rcFormat; // Format rectangle.
  3009. int cxTabLength; // Tab length in pixels.
  3010. int iXSign;
  3011. int iYSign;
  3012. int cyLineHeight; // Height of a line based on DT_EXTERNALLEADING
  3013. int cxMaxWidth; // Width of the format rectangle.
  3014. int cxMaxExtent; // Width of the longest line drawn.
  3015. int cxRightMargin; // Right margin in pixels (with proper sign)
  3016. LPFNTEXTDRAW lpfnTextDraw; // pointer to PSTextOut or PSMTextOut based
  3017. // on DT_NOPREFIX flag.
  3018. int cxOverhang; // Character overhang.
  3019. BOOL bCharsetDll; // redirect to intl DLL, not textout
  3020. int iCharset; // ANSI charset value
  3021. } DRAWTEXTDATA, *LPDRAWTEXTDATA;
  3022. typedef LONG (*FPLPKTABBEDTEXTOUT)
  3023. (HDC, int, int, LPCWSTR, int, int, CONST INT *, int, BOOL, int, int, int);
  3024. typedef void (*FPLPKPSMTEXTOUT)
  3025. (HDC, int, int, LPWSTR, int, DWORD);
  3026. typedef int (*FPLPKDRAWTEXTEX)
  3027. (HDC, int, int, LPCWSTR, int, BOOL, UINT, LPDRAWTEXTDATA, UINT, int);
  3028. extern FPLPKTABBEDTEXTOUT fpLpkTabbedTextOut;
  3029. extern FPLPKPSMTEXTOUT fpLpkPSMTextOut;
  3030. extern FPLPKDRAWTEXTEX fpLpkDrawTextEx;
  3031. // The number of characters in the ellipsis string (string defined in rtl\drawtext.c).
  3032. #define CCHELLIPSIS 3
  3033. int DrawTextExWorker(HDC hdc, LPWSTR lpchText, int cchText, LPRECT lprc,
  3034. UINT dwDTformat, LPDRAWTEXTPARAMS lpDTparams, int iCharset);
  3035. /***************************************************************************\
  3036. *
  3037. * Language pack edit control callouts.
  3038. *
  3039. * Functions are accessed through the pLpkEditCallout pointer in the ED
  3040. * structure. pLpkEditCallout points to a structure containing a pointer
  3041. * to each callout routine. These are typedef'd here.
  3042. *
  3043. * (In Windows95 this was achieved through a single function pointer
  3044. * - lpfnCharset - which was written in assembler and called from over 30
  3045. * places with different parameters. Since for NT the Lpk is written in C,
  3046. * the ED structure now points to a list of function pointers, each properly
  3047. * typedef'd, improving performance, enabling typechecking and avoiding
  3048. * varargs discrepancies between architectures.)
  3049. *
  3050. \***************************************************************************/
  3051. typedef struct tagED *PED;
  3052. typedef BOOL LpkEditCreate (PED ped, HWND hWnd);
  3053. typedef int LpkEditIchToXY (PED ped, HDC hDC, PSTR pText, ICH cch, ICH ichPos);
  3054. typedef ICH LpkEditMouseToIch (PED ped, HDC hDC, PSTR pText, ICH cch, INT iX);
  3055. typedef ICH LpkEditCchInWidth (PED ped, HDC hdc, PSTR pText, ICH cch, int width);
  3056. typedef INT LpkEditGetLineWidth (PED ped, HDC hdc, PSTR pText, ICH cch);
  3057. typedef void LpkEditDrawText (PED ped, HDC hdc, PSTR pText, INT cch, INT iMinSel, INT iMaxSel, INT iY);
  3058. typedef BOOL LpkEditHScroll (PED ped, HDC hdc, PSTR pText);
  3059. typedef ICH LpkEditMoveSelection (PED ped, HDC hdc, PSTR pText, ICH ich, BOOL fLeft);
  3060. typedef int LpkEditVerifyText (PED ped, HDC hdc, PSTR pText, ICH ichInsert, PSTR pInsertText, ICH cchInsert);
  3061. typedef void LpkEditNextWord (PED ped, HDC hdc, PSTR pText, ICH ichStart, BOOL fLeft, ICH *pichMin, ICH *pichMax);
  3062. typedef void LpkEditSetMenu (PED ped, HMENU hMenu);
  3063. typedef int LpkEditProcessMenu (PED ped, UINT idMenuItem);
  3064. typedef int LpkEditCreateCaret (PED ped, HDC hdc, INT nWidth, INT nHeight, UINT hkl);
  3065. typedef ICH LpkEditAdjustCaret (PED ped, HDC hdc, PSTR pText, ICH ich);
  3066. typedef struct tagLPKEDITCALLOUT {
  3067. LpkEditCreate *EditCreate;
  3068. LpkEditIchToXY *EditIchToXY;
  3069. LpkEditMouseToIch *EditMouseToIch;
  3070. LpkEditCchInWidth *EditCchInWidth;
  3071. LpkEditGetLineWidth *EditGetLineWidth;
  3072. LpkEditDrawText *EditDrawText;
  3073. LpkEditHScroll *EditHScroll;
  3074. LpkEditMoveSelection *EditMoveSelection;
  3075. LpkEditVerifyText *EditVerifyText;
  3076. LpkEditNextWord *EditNextWord;
  3077. LpkEditSetMenu *EditSetMenu;
  3078. LpkEditProcessMenu *EditProcessMenu;
  3079. LpkEditCreateCaret *EditCreateCaret;
  3080. LpkEditAdjustCaret *EditAdjustCaret;
  3081. } LPKEDITCALLOUT, *PLPKEDITCALLOUT;
  3082. extern PLPKEDITCALLOUT fpLpkEditControl;
  3083. /***************************************************************************\
  3084. *
  3085. * Structure for client-side thread-info.
  3086. * dwHookCurrent HIWORD is current hook filter type (eg: WH_GETMESSAGE)
  3087. * LOWORD is TRUE if current hook is ANSI, FALSE if Unicode
  3088. *
  3089. \***************************************************************************/
  3090. /*
  3091. * Hook thunks.
  3092. */
  3093. #ifdef REDIRECTION
  3094. LRESULT CALLBACK fnHkINLPPOINT(DWORD nCode,
  3095. WPARAM wParam, LPPOINT lParam,
  3096. ULONG_PTR xParam, PROC xpfnProc);
  3097. #endif // REDIRECTION
  3098. LRESULT CALLBACK fnHkINLPRECT(DWORD nCode,
  3099. WPARAM wParam, LPRECT lParam,
  3100. ULONG_PTR xParam, PROC xpfnProc);
  3101. LRESULT CALLBACK fnHkINDWORD(DWORD nCode,
  3102. WPARAM wParam, LPARAM lParam,
  3103. ULONG_PTR xParam, PROC xpfnProc, LPDWORD lpFlags);
  3104. LRESULT CALLBACK fnHkINLPMSG(DWORD nCode,
  3105. WPARAM wParam, LPMSG lParam,
  3106. ULONG_PTR xParam, PROC xpfnProc, BOOL bAnsi, LPDWORD lpFlags);
  3107. LRESULT CALLBACK fnHkOPTINLPEVENTMSG(DWORD nCode,
  3108. WPARAM wParam, LPEVENTMSGMSG lParam,
  3109. ULONG_PTR xParam, PROC xpfnProc);
  3110. LRESULT CALLBACK fnHkINLPDEBUGHOOKSTRUCT(DWORD nCode,
  3111. WPARAM wParam, LPDEBUGHOOKINFO lParam,
  3112. ULONG_PTR xParam, PROC xpfnProc);
  3113. LRESULT CALLBACK fnHkINLPMOUSEHOOKSTRUCTEX(DWORD nCode,
  3114. WPARAM wParam, LPMOUSEHOOKSTRUCTEX lParam,
  3115. ULONG_PTR xParam, PROC xpfnProc, LPDWORD lpFlags);
  3116. LRESULT CALLBACK fnHkINLPKBDLLHOOKSTRUCT(DWORD nCode,
  3117. WPARAM wParam, LPKBDLLHOOKSTRUCT lParam,
  3118. ULONG_PTR xParam, PROC xpfnProc);
  3119. LRESULT CALLBACK fnHkINLPMSLLHOOKSTRUCT(DWORD nCode,
  3120. WPARAM wParam, LPMSLLHOOKSTRUCT lParam,
  3121. ULONG_PTR xParam, PROC xpfnProc);
  3122. LRESULT CALLBACK fnHkINLPCBTACTIVATESTRUCT(DWORD nCode,
  3123. WPARAM wParam, LPCBTACTIVATESTRUCT lParam,
  3124. ULONG_PTR xParam, PROC xpfnProc);
  3125. LRESULT CALLBACK fnHkINLPCBTCSTRUCT(UINT msg,
  3126. WPARAM wParam, LPCBT_CREATEWND pcbt,
  3127. PROC xpfnProc, BOOL bAnsi);
  3128. LRESULT CALLBACK fnHkINLPCBTMDICCSTRUCT(UINT msg,
  3129. WPARAM wParam, LPCBT_CREATEWND pcbt,
  3130. PROC xpfnProc, BOOL bAnsi);
  3131. #ifdef REDIRECTION
  3132. LRESULT CALLBACK fnHkINLPHTHOOKSTRUCT(DWORD nCode,
  3133. WPARAM wParam, LPHTHOOKSTRUCT lParam,
  3134. ULONG_PTR xParam, PROC xpfnProc);
  3135. #endif // REDIRECTION
  3136. /***************************************************************************\
  3137. *
  3138. * Definitions for client/server-specific data referenced by rtl routines.
  3139. *
  3140. \***************************************************************************/
  3141. extern HBRUSH ghbrWhite;
  3142. extern HBRUSH ghbrBlack;
  3143. ULONG_PTR GetCPD(KERNEL_PVOID pWndOrCls, DWORD options, ULONG_PTR dwData);
  3144. BOOL TestWindowProcess(PWND pwnd);
  3145. DWORD GetAppCompatFlags(PTHREADINFO pti);
  3146. DWORD GetAppCompatFlags2(WORD wVer);
  3147. DWORD GetAppImeCompatFlags(PTHREADINFO pti);
  3148. PWND _GetDesktopWindow(VOID);
  3149. PWND _GetMessageWindow(VOID);
  3150. /***************************************************************************\
  3151. *
  3152. * Shared function prototypes
  3153. *
  3154. \***************************************************************************/
  3155. PVOID FASTCALL HMValidateHandle(HANDLE h, BYTE btype);
  3156. PVOID FASTCALL HMValidateCatHandleNoRip(HANDLE h, BYTE btype);
  3157. PVOID FASTCALL HMValidateHandleNoRip(HANDLE h, BYTE btype);
  3158. KERNEL_PVOID FASTCALL HMValidateHandleNoDesktop(HANDLE h, BYTE btype);
  3159. PVOID FASTCALL HMValidateSharedHandle(HANDLE h, BYTE bType);
  3160. PVOID FASTCALL HMValidateCatHandleNoSecure(HANDLE h, BYTE bType);
  3161. PVOID FASTCALL HMValidateCatHandleNoSecureCCX(HANDLE h, BYTE bType, PTHREADINFO pti);
  3162. PVOID FASTCALL HMValidateHandleNoSecure(HANDLE h, BYTE bType);
  3163. ULONG_PTR MapClientNeuterToClientPfn(PCLS pcls, KERNEL_ULONG_PTR dw, BOOL bAnsi);
  3164. ULONG_PTR MapServerToClientPfn(KERNEL_ULONG_PTR dw, BOOL bAnsi);
  3165. BOOL IsSysFontAndDefaultMode(HDC hdc);
  3166. int GetCharDimensions(HDC hDC, TEXTMETRICW *lpTextMetrics, LPINT lpcy);
  3167. int GetWindowBorders(LONG lStyle, DWORD dwExStyle, BOOL fWindow, BOOL fClient);
  3168. PWND SizeBoxHwnd(PWND pwnd);
  3169. VOID _GetClientRect(PWND pwnd, LPRECT prc);
  3170. #ifndef _USERSRV_
  3171. void GetRealClientRect(PWND pwnd, LPRECT prc, UINT uFlags, PMONITOR pMonitor);
  3172. #endif
  3173. VOID _GetWindowRect(PWND pwnd, LPRECT prc);
  3174. PWND _GetLastActivePopup(PWND pwnd);
  3175. BOOL _IsChild(PWND pwndParent, PWND pwnd);
  3176. BOOL _AdjustWindowRectEx(LPRECT lprc, DWORD style, BOOL fMenu, DWORD dwExStyle);
  3177. BOOL NeedsWindowEdge(DWORD dwStyle, DWORD dwExStyle, BOOL fNewApp);
  3178. VOID _ClientToScreen(PWND pwnd, PPOINT ppt);
  3179. VOID _ScreenToClient(PWND pwnd, PPOINT ppt);
  3180. int _MapWindowPoints(PWND pwndFrom, PWND pwndTo, LPPOINT lppt, DWORD cpt);
  3181. BOOL _IsWindowVisible(PWND pwnd);
  3182. BOOL _IsDescendant(PWND pwndParent, PWND pwndChild);
  3183. BOOL IsVisible(PWND pwnd);
  3184. PWND _GetWindow(PWND pwnd, UINT cmd);
  3185. PWND _GetParent(PWND pwnd);
  3186. int FindNCHit(PWND pwnd, LONG lPt);
  3187. SHORT _GetKeyState(int vk);
  3188. PHOOK PhkNextValid(PHOOK phk);
  3189. #define GRECT_CLIENT 0x0001
  3190. #define GRECT_WINDOW 0x0002
  3191. #define GRECT_RECTMASK 0x0003
  3192. #define GRECT_CLIENTCOORDS 0x0010
  3193. #define GRECT_WINDOWCOORDS 0x0020
  3194. #define GRECT_PARENTCOORDS 0x0040
  3195. #define GRECT_COORDMASK 0x0070
  3196. void GetRect(PWND pwnd, LPRECT lprc, UINT uCoords);
  3197. PPROP _FindProp(PWND pwnd, PCWSTR pszKey, BOOL fInternal);
  3198. HANDLE _GetProp(PWND pwnd, PCWSTR pszKey, BOOL fInternal);
  3199. BOOL _HasCaptionIcon(PWND pwnd);
  3200. PWND GetTopLevelWindow(PWND pwnd);
  3201. BOOL _SBGetParms(PWND pwnd, int code, PSBDATA pw, LPSCROLLINFO lpsi);
  3202. BOOL PSMGetTextExtent(HDC hdc, LPCWSTR lpstr, int cch, PSIZE psize);
  3203. LONG GetPrefixCount(LPCWSTR lpstr, int cb, LPWSTR lpstrCopy, int cbCopy);
  3204. PMENU _GetSubMenu(PMENU pMenu, int nPos);
  3205. DWORD _GetMenuDefaultItem(PMENU pMenu, BOOL fByPosition, UINT uFlags);
  3206. UINT _GetMenuState(PMENU pMenu, UINT wID, UINT dwFlags);
  3207. BOOL APIENTRY CopyInflateRect(LPRECT prcDst, CONST RECT *prcSrc, int cx, int cy);
  3208. BOOL APIENTRY CopyOffsetRect(LPRECT prcDst, CONST RECT *prcSrc, int cx, int cy);
  3209. DWORD FindCharPosition(LPWSTR lpString, WCHAR ch);
  3210. LPWSTR TextAlloc(LPCWSTR lpsz);
  3211. UINT TextCopy(PLARGE_UNICODE_STRING pstr, LPWSTR lpstr, UINT size);
  3212. DWORD wcsncpycch(LPWSTR pwsDest, LPCWSTR pwszSrc, DWORD cch);
  3213. DWORD strncpycch(LPSTR pszDest, LPCSTR pszSrc, DWORD cch);
  3214. #define TextPointer(h) ((LPWSTR)h)
  3215. BOOL DrawFrame(HDC hdc, LPRECT prect, int clFrame, int cmd);
  3216. VOID DrawPushButton(HDC hdc, LPRECT lprc, UINT state, UINT flags);
  3217. BOOL ClientFrame(HDC hDC, CONST RECT *pRect, HBRUSH hBrush, DWORD patOp, int cxBorder, int cyBorder);
  3218. VOID MirrorClientRect(PWND pwnd, LPRECT lprc);
  3219. VOID MirrorWindowRect(PWND pwnd, LPRECT lprc);
  3220. #define ISTS() (!!(USER_SHARED_DATA->SuiteMask & (1 << TerminalServer)))
  3221. /*
  3222. * Structure for DoConnect system call.
  3223. */
  3224. typedef struct _DOCONNECTDATA {
  3225. BOOL fConsoleShadowFlag;
  3226. BOOL fMouse;
  3227. BOOL fINetClient;
  3228. BOOL fInitialProgram;
  3229. BOOL fHideTitleBar;
  3230. HANDLE IcaVideoChannel;
  3231. HANDLE IcaBeepChannel;
  3232. HANDLE IcaMouseChannel;
  3233. HANDLE IcaKeyboardChannel;
  3234. HANDLE IcaThinwireChannel;
  3235. HANDLE DisplayChangeEvent;
  3236. WCHAR WinStationName[32];
  3237. WCHAR ProtocolName[10];
  3238. WCHAR AudioDriverName[10];
  3239. BOOL fClientDoubleClickSupport;
  3240. BOOL fEnableWindowsKey;
  3241. DWORD drBitsPerPel;
  3242. DWORD drPelsWidth;
  3243. DWORD drPelsHeight;
  3244. DWORD drDisplayFrequency;
  3245. USHORT drProtocolType;
  3246. CLIENTKEYBOARDTYPE ClientKeyboardType;
  3247. } DOCONNECTDATA, *PDOCONNECTDATA;
  3248. /*
  3249. * Structure for DoReconnect system call.
  3250. */
  3251. #define DR_DISPLAY_DRIVER_NAME_LENGTH 9
  3252. #define DR_PROTOCOL_NAME_LENGTH 9
  3253. typedef struct _DORECONNECTDATA {
  3254. BOOL fMouse;
  3255. BOOL fINetClient;
  3256. WCHAR WinStationName[32];
  3257. WCHAR DisplayDriverName[DR_DISPLAY_DRIVER_NAME_LENGTH];
  3258. WCHAR ProtocolName[DR_PROTOCOL_NAME_LENGTH];
  3259. WCHAR AudioDriverName[9];
  3260. BOOL fClientDoubleClickSupport;
  3261. BOOL fEnableWindowsKey;
  3262. DWORD drBitsPerPel;
  3263. DWORD drPelsWidth;
  3264. DWORD drPelsHeight;
  3265. DWORD drDisplayFrequency;
  3266. USHORT drProtocolType;
  3267. BOOL fChangeDisplaySettings;
  3268. CLIENTKEYBOARDTYPE ClientKeyboardType;
  3269. } DORECONNECTDATA, *PDORECONNECTDATA;
  3270. typedef enum _NOTIFYEVENT {
  3271. Notify_Disconnect,
  3272. Notify_Reconnect,
  3273. Notify_PreReconnect,
  3274. Notify_SyncDisconnect,
  3275. Notify_DisableScrnSaver,
  3276. Notify_EnableScrnSaver,
  3277. Notify_StopReadInput,
  3278. Notify_PreReconnectDesktopSwitch,
  3279. Notify_HelpAssistantShadowStart,
  3280. Notify_HelpAssistantShadowFinish,
  3281. Notify_DisconnectPipe
  3282. } NOTIFYEVENT, *PNOTIFYEVENT;
  3283. typedef struct _DONOTIFYDATA {
  3284. NOTIFYEVENT NotifyEvent;
  3285. } DONOTIFYDATA, *PDONOTIFYDATA;
  3286. /*
  3287. * EndTask, ExitWindows, hung app, etc time outs
  3288. */
  3289. #define CMSSLEEP 250
  3290. #define CMSHUNGAPPTIMEOUT (5 * 1000)
  3291. #define CMSHUNGTOKILLCOUNT 4
  3292. #define CMSWAITTOKILLTIMEOUT (CMSHUNGTOKILLCOUNT * CMSHUNGAPPTIMEOUT)
  3293. #define CMSAPPSTARTINGTIMEOUT (6 * CMSHUNGAPPTIMEOUT) /* Some setup apps are pretty slow. bug 195832 */
  3294. #define CMS_QANIMATION 165
  3295. #define CMS_FLASHWND 500
  3296. #define CMS_MENUFADE 175
  3297. #define CMS_SELECTIONFADE 350
  3298. #define CMS_TOOLTIP 135
  3299. #ifdef MOUSE_IP
  3300. #define CMS_SONARTIMEOUT 1000 /* if it takes more than this, sonar will just bail out */
  3301. #endif
  3302. #define PROCESSTERMINATETIMEOUT (90 * 1000)
  3303. #define CB_DELAYRENDER_TIMEOUT (30 *1000)
  3304. /*
  3305. * Message table definitions
  3306. */
  3307. typedef struct tagMSG_TABLE_ENTRY {
  3308. BYTE iFunction:6;
  3309. BYTE bThunkMessage:1;
  3310. BYTE bSyncOnlyMessage:1;
  3311. } MSG_TABLE_ENTRY;
  3312. extern CONST MSG_TABLE_ENTRY MessageTable[];
  3313. #define TESTSYNCONLYMESSAGE(msg, wParam) (((msg) < WM_USER) ? \
  3314. ( (MessageTable[msg].bSyncOnlyMessage) || \
  3315. (((msg) == WM_DEVICECHANGE) && ((wParam) & 0x8000))) : \
  3316. 0)
  3317. #define BLOCKMESSAGECROSSLUID(msg, ppiSender, ppiReceiver) \
  3318. ((msg == EM_SETWORDBREAKPROC) ? \
  3319. !RtlEqualLuid(&(ppiSender->luidSession), &(ppiReceiver->luidSession)) : FALSE)
  3320. /*
  3321. * Drag and Drop menus.
  3322. * MNDragOver output info
  3323. */
  3324. typedef struct tagMNDRAGOVERINFO
  3325. {
  3326. DWORD dwFlags;
  3327. HMENU hmenu;
  3328. UINT uItemIndex;
  3329. HWND hwndNotify;
  3330. } MNDRAGOVERINFO, * PMNDRAGOVERINFO;
  3331. #ifdef _USERK_
  3332. typedef struct tagMOUSECURSOR {
  3333. BYTE bAccelTableLen;
  3334. BYTE bAccelTable[128];
  3335. BYTE bConstantTableLen;
  3336. BYTE bConstantTable[128];
  3337. } MOUSECURSOR;
  3338. #endif
  3339. typedef struct tagINTERNALSETHIGHCONTRAST {
  3340. UINT cbSize;
  3341. DWORD dwFlags;
  3342. UNICODE_STRING usDefaultScheme;
  3343. } INTERNALSETHIGHCONTRAST, *LPINTERNALSETHIGHCONTRAST;
  3344. #define InMsgRange(msg, start, end) (((msg) >= (start)) && ((msg) <= (end)))
  3345. /*
  3346. * Enforce 64bit/32bit natural alignment
  3347. * N.b. does not work for byte aligned objects.
  3348. */
  3349. #define NATURAL_ALIGNED_PTR(type, x) ((type*)(((ULONG_PTR)(x) + PROBE_ALIGNMENT(type) - 1) & ~(PROBE_ALIGNMENT(type) - 1)))
  3350. #define ARABIC_UI_LANGID() (gpsi->UILangID == MAKELANGID(LANG_ARABIC, SUBLANG_DEFAULT))
  3351. #define HEBREW_UI_LANGID() (gpsi->UILangID == MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT))
  3352. #define RTL_UI() (ARABIC_UI_LANGID() || HEBREW_UI_LANGID())
  3353. #endif // _USER_