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.

2962 lines
123 KiB

  1. /****************************** Module Header ******************************\
  2. * Module Name: usercli.h
  3. *
  4. * Copyright (c) 1985 - 1999, Microsoft Corporation
  5. *
  6. * Typedefs, defines, and prototypes that are used exclusively by the User
  7. * client-side DLL.
  8. *
  9. * History:
  10. * 04-27-91 DarrinM Created from PROTO.H, MACRO.H and STRTABLE.H
  11. \***************************************************************************/
  12. #ifndef _USERCLI_
  13. #define _USERCLI_
  14. #define OEMRESOURCE 1
  15. #include <windows.h>
  16. #include <winnls32.h>
  17. #include <w32gdip.h>
  18. #include <w32err.h>
  19. #include <ddeml.h>
  20. #include "ddemlp.h"
  21. #include "winuserp.h"
  22. #include "w32wow64.h"
  23. #include "winuserk.h"
  24. #include <dde.h>
  25. #include <ddetrack.h>
  26. #include "kbd.h"
  27. #include <wowuserp.h>
  28. #include "immstruc.h"
  29. #include "immuser.h"
  30. #include <winbasep.h>
  31. #include "user.h"
  32. #include "callproc.h"
  33. #if DBG
  34. /*
  35. * This structure allows apps to set RIP flags locally to their process.
  36. * This is mostly intended for naughty/penetration apps.
  37. *
  38. * dwTouchedMask is used to determine which fields have been locally set.
  39. * For those that have not been, we'll return the global/kernel values.
  40. */
  41. #define USERDBG_TAGSTOUCHED 0x1
  42. #define USERDBG_PIDTOUCHED 0x2
  43. #define USERDBG_FLAGSTOUCHED 0x4
  44. typedef struct _USERDBGGLOBALS {
  45. DWORD adwDBGTAGFlags[DBGTAG_Max + 1];
  46. DWORD dwRIPPID;
  47. DWORD dwRIPFlags;
  48. DWORD dwTouchedMask;
  49. } USERDBGGLOBALS, *PUSERDBGGLOBALS;
  50. #endif
  51. /*
  52. * This prototype is needed in client\globals.h which is included unintentionally
  53. * from usersrv.h
  54. */
  55. typedef LRESULT (APIENTRY *CFNSCSENDMESSAGE)(HWND, UINT, WPARAM, LPARAM,
  56. ULONG_PTR, DWORD, BOOL);
  57. /***************************************************************************\
  58. * Typedefs and Macros
  59. *
  60. * Here are defined all types and macros that are shared across the User's
  61. * client-side code modules. Types and macros that are unique to a single
  62. * module should be defined at the head of that module, not in this file.
  63. *
  64. \***************************************************************************/
  65. #define MIRRORED_HDC(hdc) (GetLayout(hdc) & LAYOUT_RTL)
  66. #define MIRRORED_HWND(hwnd) (GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_LAYOUTRTL)
  67. #ifdef LAZY_CLASS_INIT
  68. BOOL UserRegisterControls(
  69. VOID);
  70. BOOL UserRegisterDDEML(
  71. VOID);
  72. extern BOOL gbClassesRegistered;
  73. __inline VOID LazyInitClasses(
  74. VOID)
  75. {
  76. if (!gbClassesRegistered) {
  77. gbClassesRegistered = TRUE;
  78. UserRegisterControls();
  79. UserRegisterDDEML();
  80. }
  81. }
  82. #endif
  83. #if DBG
  84. __inline void DebugUserGlobalUnlock(HANDLE h)
  85. {
  86. UserAssert(
  87. "GlobalUnlock on bad handle" &&
  88. !(GlobalFlags(h) == GMEM_INVALID_HANDLE));
  89. GlobalUnlock((HANDLE) h);
  90. }
  91. /*
  92. * Bug 262144 - joejo
  93. *
  94. * Changed function to accept a pointer to the handle so we
  95. * can trash the handle and return it as trashed.
  96. *
  97. * Added a local handle variable to accept the return from GlobalFree
  98. * so we can return it as expected.
  99. *
  100. * Trash incoming handle freed so we can track any invalid access on
  101. * it after it's been free'd.
  102. */
  103. __inline HANDLE DebugUserGlobalFree(HANDLE* ph)
  104. {
  105. HANDLE th;
  106. UserAssert(
  107. "GlobalFree on bad handle" &&
  108. !(GlobalFlags(*ph) == GMEM_INVALID_HANDLE));
  109. th = GlobalFree(*ph);
  110. #if defined(_WIN64)
  111. *ph = (HANDLE)(PVOID)0xBAADF00DBAADF00D;
  112. #else
  113. *ph = (HANDLE)(PVOID)0xBAADF00D;
  114. #endif
  115. return th;
  116. }
  117. __inline HANDLE DebugUserGlobalAlloc(UINT uFlags, SIZE_T dwBytes)
  118. {
  119. HANDLE h = GlobalAlloc(uFlags, dwBytes);
  120. /*
  121. * Assert that FreeDDElParam and _ClientFreeDDEHandle assumption is correct.
  122. */
  123. if (h != NULL) {
  124. UserAssert(h > (HANDLE)0xFFFF);
  125. }
  126. return h;
  127. }
  128. #define USERGLOBALUNLOCK(h) DebugUserGlobalUnlock((HANDLE)(h))
  129. #define UserGlobalFree(h) DebugUserGlobalFree((HANDLE*)(&h))
  130. #define UserGlobalAlloc(flags, size) DebugUserGlobalAlloc(flags, size)
  131. #else
  132. #define USERGLOBALUNLOCK(h) GlobalUnlock((HANDLE)(h))
  133. #define UserGlobalFree(h) GlobalFree((HANDLE)(h))
  134. #define UserGlobalAlloc(flags, size) GlobalAlloc(flags, size)
  135. #endif
  136. #define USERGLOBALLOCK(h, p) p = GlobalLock((HANDLE)(h))
  137. #define UserGlobalReAlloc(pmem, cnt, flags) GlobalReAlloc(pmem,cnt,flags)
  138. #define UserGlobalSize(pmem) GlobalSize(pmem)
  139. #define WOWGLOBALFREE(pmem) GlobalFree(pmem)
  140. #define RESERVED_MSG_BITS (0xFFFE0000)
  141. /*
  142. * A macro for testing bits in the message bit-arrays. Messages in the
  143. * the bit arrays must be processed
  144. */
  145. #define FDEFWINDOWMSG(msg, procname) \
  146. ((msg <= (gSharedInfo.procname.maxMsgs)) && \
  147. ((gSharedInfo.procname.abMsgs)[msg / 8] & (1 << (msg & 7))))
  148. #define FWINDOWMSG(msg, fnid) \
  149. ((msg <= (gSharedInfo.awmControl[fnid - FNID_START].maxMsgs)) && \
  150. ((gSharedInfo.awmControl[fnid - FNID_START].abMsgs)[msg / 8] & (1 << (msg & 7))))
  151. #define CsSendMessage(hwnd, msg, wParam, lParam, xParam, pfn, bAnsi) \
  152. (((msg) >= WM_USER) ? \
  153. NtUserMessageCall(hwnd, msg, wParam, lParam, xParam, pfn, bAnsi) : \
  154. gapfnScSendMessage[MessageTable[msg].iFunction](hwnd, msg, wParam, lParam, xParam, pfn, bAnsi))
  155. #define GetWindowProcess(hwnd) NtUserQueryWindow(hwnd, WindowProcess)
  156. #define GETPROCESSID() (NtCurrentTeb()->ClientId.UniqueProcess)
  157. #define GETTHREADID() (NtCurrentTeb()->ClientId.UniqueThread)
  158. /*
  159. * Macro to mask off uniqueness bits for WOW handles
  160. */
  161. #define SAMEWOWHANDLE(h1, h2) ((BOOL)!(((ULONG_PTR)(h1) ^ (ULONG_PTR)(h2)) & 0xffff))
  162. #define DIFFWOWHANDLE(h1, h2) (!SAMEWOWHANDLE(h1, h2))
  163. /*
  164. * For callbacks to the client - for msg and hook thunks, callback addresses
  165. * are passed as addresses, not function indexes as they are from client to
  166. * server.
  167. */
  168. typedef INT_PTR (WINAPI *GENERICPROC)();
  169. #define CALLPROC(p) ((GENERICPROC)p)
  170. #define PACTCTXT(pwnd) (pwnd ? pwnd->pActCtx : NULL)
  171. extern PFNWOWDLGPROCEX pfnWowDlgProcEx;
  172. extern PFNWOWWNDPROCEX pfnWowWndProcEx;
  173. BOOL UserCallDlgProcCheckWow(PACTIVATION_CONTEXT pActCtx, DLGPROC pfn,
  174. HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, PVOID pww, INT_PTR * pret);
  175. LRESULT UserCallWinProcCheckWow(PACTIVATION_CONTEXT pActCtx, WNDPROC pfn,
  176. HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, PVOID pww, BOOL fEnableLiteHooks);
  177. /***************************************************************************\
  178. * IsMsgOverride
  179. *
  180. * Returns if a message should be sent to USERAPIHOOK OverrideWndProc()
  181. * hooks. The message should only be sent if its "index" is within the range
  182. * specified by the hook and its "bit" is on. It is very important to
  183. * actually check guah.cbMsgMask instead of sizeof(gbLiteHookMsg) because the
  184. * hook may have a smaller MsgMask in which case anything past the end fails.
  185. *
  186. * History:
  187. * 27-Apr-2000 jstall Created
  188. \***************************************************************************/
  189. __inline BOOL IsMsgOverride(UINT msg, MSGMASK * pmm)
  190. {
  191. UINT idxMajor = msg / 8;
  192. if ((pmm->rgb != NULL) && (idxMajor < pmm->cb)) {
  193. return (pmm->rgb[idxMajor] & (1 << (msg & 7)));
  194. }
  195. return FALSE;
  196. }
  197. #define RevalidateHwnd(hwnd) ((PWND)HMValidateHandleNoSecure(hwnd, TYPE_WINDOW))
  198. #define VALIDATEHMENU(hmenu) ((PMENU)HMValidateHandle(hmenu, TYPE_MENU))
  199. #define VALIDATEHMONITOR(hmonitor) ((PMONITOR)HMValidateSharedHandle(hmonitor, TYPE_MONITOR))
  200. /*
  201. * REBASE macros take kernel desktop addresses and convert them into
  202. * user addresses.
  203. *
  204. * REBASEALWAYS converts a kernel address contained in an object
  205. * REBASEPWND casts REBASEALWAYS to a PWND
  206. * REBASE only converts if the address is in kernel space. Also works for NULL
  207. * REBASEPTR converts a random kernel address
  208. */
  209. #define REBASEALWAYS(p, elem) ((PVOID)((KERNEL_ULONG_PTR)(p) + ((KERNEL_ULONG_PTR)(p)->elem - (KERNEL_ULONG_PTR)(p)->head.pSelf)))
  210. #define REBASEPTR(obj, p) ((PVOID)((KERNEL_ULONG_PTR)(p) - ((KERNEL_ULONG_PTR)(obj)->head.pSelf - (KERNEL_ULONG_PTR)(obj))))
  211. #define REBASE(p, elem) ((KERNEL_ULONG_PTR)((p)->elem) <= (KERNEL_ULONG_PTR)gHighestUserAddress ? \
  212. ((PVOID)(KERNEL_ULONG_PTR)(p)->elem) : REBASEALWAYS(p, elem))
  213. #define REBASEPWND(p, elem) ((PWND)REBASE(p, elem))
  214. #ifndef USEREXTS
  215. PTHREADINFO PtiCurrent(VOID);
  216. /*
  217. * Window Proc Window Validation macro. This macro assumes
  218. * that pwnd and hwnd are existing variables pointing to the window.
  219. * Checking the BUTTON is for Mavis Beacon.
  220. */
  221. #define VALIDATECLASSANDSIZE(pwnd, inFNID) \
  222. switch ((pwnd)->fnid) { \
  223. case inFNID: \
  224. break; \
  225. \
  226. case 0: \
  227. if ((pwnd->cbwndExtra + sizeof(WND)) < (DWORD)(CBFNID(inFNID))) { \
  228. RIPMSG3(RIP_ERROR, \
  229. "(%#p %lX) needs at least (%ld) window words for this proc", \
  230. pwnd, pwnd->cbwndExtra, \
  231. (DWORD)(CBFNID(inFNID)) - sizeof(WND)); \
  232. return 0; \
  233. } \
  234. \
  235. if (inFNID == FNID_BUTTON && *((KPULONG_PTR)(pwnd + 1))) { \
  236. \
  237. RIPMSG3(RIP_WARNING, "Window (%#p) fnid = %lX overrides " \
  238. "the extra pointer with %#p\n", \
  239. pwnd, inFNID, *((KPULONG_PTR)(pwnd + 1))); \
  240. \
  241. NtUserSetWindowLongPtr(hwnd, 0, 0, FALSE); \
  242. } \
  243. \
  244. NtUserSetWindowFNID(hwnd, inFNID); \
  245. break; \
  246. \
  247. case (inFNID | FNID_CLEANEDUP_BIT): \
  248. case (inFNID | FNID_DELETED_BIT): \
  249. case (inFNID | FNID_STATUS_BITS): \
  250. return 0; \
  251. \
  252. default: \
  253. RIPMSG3(RIP_WARNING, \
  254. "Window (%#p) not of correct class; fnid = %lX not %lX", \
  255. (pwnd), (DWORD)((pwnd)->fnid), (DWORD)(inFNID)); \
  256. return 0; \
  257. }
  258. /*
  259. * This macro initializes the lookaside entry for a control. It assumes
  260. * that pwnd and hwnd are existing variables pointing to the control's
  261. * windows and that fInit exists as a BOOL initialization flag.
  262. */
  263. #define INITCONTROLLOOKASIDE(plaType, type, pwnditem, count) \
  264. if (!*((KPULONG_PTR)(pwnd + 1))) { \
  265. P ## type pType; \
  266. if (fInit) { \
  267. if (!NT_SUCCESS(InitLookaside(plaType, sizeof(type), count))) { \
  268. NtUserSetWindowFNID(hwnd, FNID_CLEANEDUP_BIT); \
  269. NtUserDestroyWindow(hwnd); \
  270. return FALSE; \
  271. } \
  272. fInit = FALSE; \
  273. } \
  274. if ((pType = (P ## type)AllocLookasideEntry(plaType))) { \
  275. NtUserSetWindowLongPtr(hwnd, 0, (LONG_PTR)pType, FALSE); \
  276. Lock(&(pType->pwnditem), pwnd); \
  277. } else { \
  278. NtUserSetWindowFNID(hwnd, FNID_CLEANEDUP_BIT); \
  279. NtUserDestroyWindow(hwnd); \
  280. return FALSE; \
  281. } \
  282. }
  283. #endif
  284. #define ISREMOTESESSION() (NtCurrentPeb()->SessionId != USER_SHARED_DATA->ActiveConsoleId)
  285. /*
  286. * Bitmap related macroes.
  287. */
  288. #define SetBestStretchMode(hdc, planes, bpp) \
  289. SetStretchBltMode(hdc, (((planes) * (bpp)) == 1 ? BLACKONWHITE : COLORONCOLOR))
  290. #define BitmapSize(cx, cy, planes, bits) \
  291. (BitmapWidth(cx, bits) * (cy) * (planes))
  292. #define BitmapWidth(cx, bpp) (((((cx)*(bpp)) + 31) & ~31) >> 3)
  293. #define RGBX(rgb) RGB(GetBValue(rgb), GetGValue(rgb), GetRValue(rgb))
  294. /*
  295. * Typedefs used for capturing string arguments to be passed
  296. * to the kernel.
  297. */
  298. typedef struct _IN_STRING {
  299. UNICODE_STRING strCapture;
  300. PUNICODE_STRING pstr;
  301. BOOL fAllocated;
  302. } IN_STRING, *PIN_STRING;
  303. typedef struct _LARGE_IN_STRING {
  304. LARGE_UNICODE_STRING strCapture;
  305. PLARGE_UNICODE_STRING pstr;
  306. BOOL fAllocated;
  307. } LARGE_IN_STRING, *PLARGE_IN_STRING;
  308. /*
  309. * Lookaside definitions
  310. */
  311. typedef struct _LOOKASIDE {
  312. PVOID LookasideBase;
  313. PVOID LookasideBounds;
  314. ZONE_HEADER LookasideZone;
  315. DWORD EntrySize;
  316. #if DBG
  317. ULONG AllocHiWater;
  318. ULONG AllocCalls;
  319. ULONG AllocSlowCalls;
  320. ULONG DelCalls;
  321. ULONG DelSlowCalls;
  322. #endif
  323. } LOOKASIDE, *PLOOKASIDE;
  324. NTSTATUS InitLookaside(PLOOKASIDE pla, DWORD cbEntry, DWORD cEntries);
  325. PVOID AllocLookasideEntry(PLOOKASIDE pla);
  326. VOID FreeLookasideEntry(PLOOKASIDE pla, PVOID pEntry);
  327. /***************************************************************************\
  328. *
  329. * Thread and structure locking routines - we'll just define these to do
  330. * nothing for now until we figure out what needs to be done
  331. *
  332. \***************************************************************************/
  333. #undef ThreadLock
  334. #undef ThreadLockAlways
  335. #undef ThreadLockWithPti
  336. #undef ThreadLockAlwaysWithPti
  337. #undef ThreadUnlock
  338. #undef Lock
  339. #undef Unlock
  340. #define CheckLock(pobj)
  341. #define ThreadLock(pobj, ptl) DBG_UNREFERENCED_LOCAL_VARIABLE(*ptl)
  342. #define ThreadLockAlways(pobj, ptl) DBG_UNREFERENCED_LOCAL_VARIABLE(*ptl)
  343. #define ThreadLockWithPti(pti, pobj, ptl) DBG_UNREFERENCED_LOCAL_VARIABLE(*ptl)
  344. #define ThreadLockAlwaysWithPti(pti, pobj, ptl) DBG_UNREFERENCED_LOCAL_VARIABLE(*ptl)
  345. #define ThreadUnlock(ptl) (ptl)
  346. #define Lock(ppobj, pobj) (*ppobj = pobj)
  347. #define Unlock(ppobj) (*ppobj = NULL)
  348. #if !defined(_USERRTL_) && !defined(USEREXTS)
  349. typedef struct _TL {
  350. int iBogus;
  351. } TL;
  352. #endif
  353. /***************************************************************************\
  354. *
  355. * Button Controls
  356. *
  357. \***************************************************************************/
  358. /*
  359. * Note: The button data structures are now found in user.h because the
  360. * kernel needs to handle a special case of SetWindowWord on index
  361. * 0L to change the state of the button.
  362. */
  363. #define BUTTONSTATE(pbutn) (pbutn->buttonState)
  364. #define BST_CHECKMASK 0x0003
  365. #define BST_INCLICK 0x0010
  366. #define BST_CAPTURED 0x0020
  367. #define BST_MOUSE 0x0040
  368. #define BST_DONTCLICK 0x0080
  369. #define BST_INBMCLICK 0x0100
  370. #define PBF_PUSHABLE 0x0001
  371. #define PBF_DEFAULT 0x0002
  372. /*
  373. * BNDrawText codes
  374. */
  375. #define DBT_TEXT 0x0001
  376. #define DBT_FOCUS 0x0002
  377. /***************************************************************************\
  378. *
  379. * ComboBox
  380. *
  381. \***************************************************************************/
  382. /*
  383. * ID numbers (hMenu) for the child controls in the combo box
  384. */
  385. #define CBLISTBOXID 1000
  386. #define CBEDITID 1001
  387. #define CBBUTTONID 1002
  388. /*
  389. * For CBOX.c. BoxType field, we define the following combo box styles. These
  390. * numbers are the same as the CBS_ style codes as defined in windows.h.
  391. */
  392. #define SDROPPABLE CBS_DROPDOWN
  393. #define SEDITABLE CBS_SIMPLE
  394. #define SSIMPLE SEDITABLE
  395. #define SDROPDOWNLIST SDROPPABLE
  396. #define SDROPDOWN (SDROPPABLE | SEDITABLE)
  397. /*
  398. * CBOX.OwnerDraw & LBIV.OwnerDraw types
  399. */
  400. #define OWNERDRAWFIXED 1
  401. #define OWNERDRAWVAR 2
  402. #define UPPERCASE 1
  403. #define LOWERCASE 2
  404. #define CaretCreate(plb) ((plb)->fCaret = TRUE)
  405. /*
  406. * This macro is used to isolate the combo box style bits. Ie if it the combo
  407. * box is simple, atomic, dropdown, or a dropdown listbox.
  408. */
  409. #define COMBOBOXSTYLE(style) ((LOBYTE(style)) & 3)
  410. #define IsComboVisible(pcbox) (!pcbox->fNoRedraw && IsVisible(pcbox->spwnd))
  411. /*
  412. * Note that I depend on the fact that these CBN_ defines are the same as
  413. * their listbox counterparts. These defines are found in windows.h.
  414. * #define CBN_ERRSPACE (-1)
  415. * #define CBN_SELCHANGE 1
  416. * #define CBN_DBLCLK 2
  417. */
  418. /***************************************************************************\
  419. *
  420. * Edit Control Types/Macros
  421. *
  422. \***************************************************************************/
  423. /* Window extra bytes - we need at least this much space for compatibility */
  424. #define CBEDITEXTRA 6
  425. /*
  426. * NOTE: Text handle is sized as multiple of this constant
  427. * (should be power of 2).
  428. */
  429. #define CCHALLOCEXTRA 0x20
  430. /* Maximum width in pixels for a line/rectangle */
  431. #define MAXPIXELWIDTH 30000
  432. #define MAXCLIPENDPOS 32764
  433. /* Limit multiline edit controls to at most 1024 characters on a single line.
  434. * We will force a wrap if the user exceeds this limit.
  435. */
  436. #define MAXLINELENGTH 1024
  437. /*
  438. * Allow an initial maximum of 30000 characters in all edit controls since
  439. * some apps will run into unsigned problems otherwise. If apps know about
  440. * the 64K limit, they can set the limit themselves.
  441. */
  442. #define MAXTEXT 30000
  443. /*
  444. * Key modifiers which have been pressed. Code in KeyDownHandler and
  445. * CharHandler depend on these exact values.
  446. */
  447. #define NONEDOWN 0 /* Neither shift nor control down */
  448. #define CTRLDOWN 1 /* Control key only down */
  449. #define SHFTDOWN 2 /* Shift key only down */
  450. #define SHCTDOWN 3 /* Shift and control keys down = CTRLDOWN + SHFTDOWN */
  451. #define NOMODIFY 4 /* Neither shift nor control down */
  452. #define CALLWORDBREAKPROC(proc, pText, iStart, cch, iAction) \
  453. (IsWOWProc(proc) ? \
  454. (* pfnWowEditNextWord)(pText, iStart, cch, iAction, PtrToUlong(proc)) : \
  455. (* proc)(pText, iStart, cch, iAction))
  456. /*
  457. * Types of undo supported in this ped
  458. */
  459. #define UNDO_NONE 0 /* We can't undo the last operation. */
  460. #define UNDO_INSERT 1 /* We can undo the user's insertion of characters */
  461. #define UNDO_DELETE 2 /* We can undo the user's deletion of characters */
  462. typedef struct tagUNDO {
  463. UINT undoType; /* Current type of undo we support */
  464. PBYTE hDeletedText; /* Pointer to text which has been deleted (for
  465. undo) -- note, the memory is allocated as fixed
  466. */
  467. ICH ichDeleted; /* Starting index from which text was deleted */
  468. ICH cchDeleted; /* Count of deleted characters in buffer */
  469. ICH ichInsStart; /* Starting index from which text was
  470. inserted */
  471. ICH ichInsEnd; /* Ending index of inserted text */
  472. } UNDO, *PUNDO;
  473. #define Pundo(ped) ((PUNDO)&(ped)->undoType)
  474. /*
  475. * Length of the buffer for ASCII character width caching: for characters
  476. * 0x00 to 0xff (field charWidthBuffer in PED structure below).
  477. * As the upper half of the cache was not used by almost anyone and fixing
  478. * it's usage required a lot of conversion, we decided to get rid of it
  479. * MCostea #174031
  480. */
  481. #define CHAR_WIDTH_BUFFER_LENGTH 128
  482. typedef struct tagED {
  483. HANDLE hText; /* Block of text we are editing */
  484. ICH cchAlloc; /* Number of chars we have allocated for hText*/
  485. ICH cchTextMax; /* Max number bytes allowed in edit control*/
  486. ICH cch; /* Current number of bytes of actual text*/
  487. ICH cLines; /* Number of lines of text */
  488. ICH ichMinSel; /* Selection extent. MinSel is first selected
  489. * char
  490. */
  491. ICH ichMaxSel; /* MaxSel is first unselected character */
  492. ICH ichCaret; /* Caret location. Caret is on left side of
  493. * char
  494. */
  495. ICH iCaretLine; /* The line the caret is on. So that if word
  496. * wrapping, we can tell if the caret is at end
  497. * of a line of at beginning of next line...
  498. */
  499. ICH ichScreenStart; /* Index of left most character displayed on
  500. * screen for sl ec and index of top most line
  501. * for multiline edit controls
  502. */
  503. ICH ichLinesOnScreen; /* Number of lines we can display on screen */
  504. UINT xOffset; /* x (horizontal) scroll position in pixels
  505. * (for multiline text horizontal scroll bar)
  506. */
  507. UINT charPasswordChar; /* If non null, display this character instead
  508. * of the real text. So that we can implement
  509. * hidden text fields.
  510. */
  511. int cPasswordCharWidth; /* Width of password char */
  512. HWND hwnd; /* Window for this edit control */
  513. PWND pwnd; /* Pointer to window */
  514. RECT rcFmt; /* Client rectangle */
  515. HWND hwndParent; /* Parent of this edit control window */
  516. /* These vars allow us to automatically scroll
  517. * when the user holds the mouse at the bottom
  518. * of the multiline edit control window.
  519. */
  520. POINT ptPrevMouse; /* Previous point for the mouse for system
  521. * timer.
  522. */
  523. UINT prevKeys; /* Previous key state for the mouse */
  524. UINT fSingle : 1; /* Single line edit control? (or multiline) */
  525. UINT fNoRedraw : 1; /* Redraw in response to a change? */
  526. UINT fMouseDown : 1; /* Is mouse button down? when moving mouse */
  527. UINT fFocus : 1; /* Does ec have the focus ? */
  528. UINT fDirty : 1; /* Modify flag for the edit control */
  529. UINT fDisabled : 1; /* Window disabled? */
  530. UINT fNonPropFont : 1; /* Fixed width font? */
  531. UINT fNonPropDBCS : 1; /* Non-Propotional DBCS font */
  532. UINT fBorder : 1; /* Draw a border? */
  533. UINT fAutoVScroll : 1; /* Automatically scroll vertically */
  534. UINT fAutoHScroll : 1; /* Automatically scroll horizontally */
  535. UINT fNoHideSel : 1; /* Hide sel when we lose focus? */
  536. UINT fDBCS : 1; /* Are we using DBCS font set for editing? */
  537. UINT fFmtLines : 1; /* For multiline only. Do we insert CR CR LF at
  538. * word wrap breaks?
  539. */
  540. UINT fWrap : 1; /* Do int wrapping? */
  541. UINT fCalcLines : 1; /* Recalc ped->chLines array? (recalc line
  542. * breaks?)
  543. */
  544. UINT fEatNextChar : 1; /* Hack for ALT-NUMPAD stuff with combo boxes.
  545. * If numlock is up, we want to eat the next
  546. * character generated by the keyboard driver
  547. * if user enter num pad ascii value...
  548. */
  549. UINT fStripCRCRLF : 1; /* CRCRLFs have been added to text. Strip them
  550. * before doing any internal edit control
  551. * stuff
  552. */
  553. UINT fInDialogBox : 1; /* True if the ml edit control is in a dialog
  554. * box and we have to specially treat TABS and
  555. * ENTER
  556. */
  557. UINT fReadOnly : 1; /* Is this a read only edit control? Only
  558. * allow scrolling, selecting and copying.
  559. */
  560. UINT fCaretHidden : 1; /* This indicates whether the caret is
  561. * currently hidden because the width or height
  562. * of the edit control is too small to show it.
  563. */
  564. UINT fTrueType : 1; /* Is the current font TrueType? */
  565. UINT fAnsi : 1; /* is the edit control Ansi or unicode */
  566. UINT fWin31Compat : 1; /* TRUE if created by Windows 3.1 app */
  567. UINT f40Compat : 1; /* TRUE if created by Windows 4.0 app */
  568. UINT fFlatBorder : 1; /* Do we have to draw this baby ourself? */
  569. UINT fSawRButtonDown : 1;
  570. UINT fInitialized : 1; /* If any more bits are needed, then */
  571. UINT fSwapRoOnUp : 1; /* Swap reading order on next keyup */
  572. UINT fAllowRTL : 1; /* Allow RTL processing */
  573. UINT fDisplayCtrl : 1; /* Display unicode control characters */
  574. UINT fRtoLReading : 1; /* Right to left reading order */
  575. BOOL fInsertCompChr :1; /* means WM_IME_COMPOSITION:CS_INSERTCHAR will come */
  576. BOOL fReplaceCompChr :1; /* means need to replace current composition str. */
  577. BOOL fNoMoveCaret :1; /* means stick to current caret pos. */
  578. BOOL fResultProcess :1; /* means now processing result. */
  579. BOOL fKorea :1; /* for Korea */
  580. BOOL fInReconversion :1; /* In reconversion mode */
  581. BOOL fLShift :1; /* L-Shift pressed with Ctrl */
  582. WORD wImeStatus; /* current IME status */
  583. WORD cbChar; /* count of bytes in the char size (1 or 2 if unicode) */
  584. LPICH chLines; /* index of the start of each line */
  585. UINT format; /* Left, center, or right justify multiline
  586. * text.
  587. */
  588. EDITWORDBREAKPROCA lpfnNextWord; /* use CALLWORDBREAKPROC macro to call */
  589. /* Next word function */
  590. int maxPixelWidth; /* WASICH Width (in pixels) of longest line */
  591. UNDO; /* Undo buffer */
  592. HANDLE hFont; /* Handle to the font for this edit control.
  593. * Null if system font.
  594. */
  595. int aveCharWidth; /* Ave width of a character in the hFont */
  596. int lineHeight; /* Height of a line in the hFont */
  597. int charOverhang; /* Overhang associated with the hFont */
  598. int cxSysCharWidth; /* System font ave width */
  599. int cySysCharHeight; /* System font height */
  600. HWND listboxHwnd; /* ListBox hwnd. Non null if we are a combo box */
  601. LPINT pTabStops; /* Points to an array of tab stops; First
  602. * element contains the number of elements in
  603. * the array
  604. */
  605. LPINT charWidthBuffer;
  606. BYTE charSet; /* Character set for currently selected font
  607. * needed for all versions
  608. */
  609. UINT wMaxNegA; /* The biggest negative A width, */
  610. UINT wMaxNegAcharPos; /* and how many characters it can span accross */
  611. UINT wMaxNegC; /* The biggest negative C width, */
  612. UINT wMaxNegCcharPos; /* and how many characters it can span accross */
  613. UINT wLeftMargin; /* Left margin width in pixels. */
  614. UINT wRightMargin; /* Right margin width in pixels. */
  615. ICH ichStartMinSel;
  616. ICH ichStartMaxSel;
  617. PLPKEDITCALLOUT pLpkEditCallout;
  618. HBITMAP hCaretBitmap; /* Current caret bitmap handle */
  619. INT iCaretOffset; /* Offset in pixels (for LPK use) */
  620. HANDLE hInstance; /* for WOW */
  621. UCHAR seed; /* used to encode and decode password text */
  622. BOOLEAN fEncoded; /* is the text currently encoded */
  623. int iLockLevel; /* number of times the text has been locked */
  624. BYTE DBCSVector[MAX_LEADBYTES]; /* DBCS vector table */
  625. HIMC hImcPrev; /* place to save hImc if we disable IME */
  626. POINT ptScreenBounding; /* top left corner of edit window in screen */
  627. } ED, *PED, **PPED;
  628. typedef struct tagEDITWND {
  629. WND wnd;
  630. PED ped;
  631. } EDITWND, * KPTR_MODIFIER PEDITWND;
  632. #ifdef FAREAST_CHARSET_BITS
  633. #error FAREAST_CHARSET_BITS should not be defined
  634. #endif
  635. #define FAREAST_CHARSET_BITS (FS_JISJAPAN | FS_CHINESESIMP | FS_WANSUNG | FS_CHINESETRAD)
  636. // Language pack specific context menu IDs
  637. #define ID_CNTX_RTL 0x00008000L
  638. #define ID_CNTX_DISPLAYCTRL 0x00008001L
  639. #define ID_CNTX_INSERTCTRL 0x00008013L
  640. #define ID_CNTX_ZWJ 0x00008002L
  641. #define ID_CNTX_ZWNJ 0x00008003L
  642. #define ID_CNTX_LRM 0x00008004L
  643. #define ID_CNTX_RLM 0x00008005L
  644. #define ID_CNTX_LRE 0x00008006L
  645. #define ID_CNTX_RLE 0x00008007L
  646. #define ID_CNTX_LRO 0x00008008L
  647. #define ID_CNTX_RLO 0x00008009L
  648. #define ID_CNTX_PDF 0x0000800AL
  649. #define ID_CNTX_NADS 0x0000800BL
  650. #define ID_CNTX_NODS 0x0000800CL
  651. #define ID_CNTX_ASS 0x0000800DL
  652. #define ID_CNTX_ISS 0x0000800EL
  653. #define ID_CNTX_AAFS 0x0000800FL
  654. #define ID_CNTX_IAFS 0x00008010L
  655. #define ID_CNTX_RS 0x00008011L
  656. #define ID_CNTX_US 0x00008012L
  657. /*
  658. * The following structure is used to store a selection block; In Multiline
  659. * edit controls, "StPos" and "EndPos" fields contain the Starting and Ending
  660. * lines of the block. In Single line edit controls, "StPos" and "EndPos"
  661. * contain the Starting and Ending character positions of the block;
  662. */
  663. typedef struct tagBLOCK {
  664. ICH StPos;
  665. ICH EndPos;
  666. } BLOCK, *LPBLOCK;
  667. /* The following structure is used to store complete information about a
  668. * a strip of text.
  669. */
  670. typedef struct {
  671. LPSTR lpString;
  672. ICH ichString;
  673. ICH nCount;
  674. int XStartPos;
  675. } STRIPINFO;
  676. typedef STRIPINFO FAR *LPSTRIPINFO;
  677. /***************************************************************************\
  678. *
  679. * ListBox
  680. *
  681. \***************************************************************************/
  682. #define IsLBoxVisible(plb) (plb->fRedraw && IsVisible(plb->spwnd))
  683. /*
  684. * Number of list box items we allocated whenever we grow the list box
  685. * structures.
  686. */
  687. #define CITEMSALLOC 32
  688. /* Return Values */
  689. #define EQ 0
  690. #define PREFIX 1
  691. #define LT 2
  692. #define GT 3
  693. #define SINGLESEL 0
  694. #define MULTIPLESEL 1
  695. #define EXTENDEDSEL 2
  696. #define LBI_ADD 0x0004
  697. /*
  698. * The various bits of wFileDetails field are used as mentioned below:
  699. * 0x0001 Should the file name be in upper case.
  700. * 0x0002 Should the file size be shown.
  701. * 0x0004 Date stamp of the file to be shown ?
  702. * 0x0008 Time stamp of the file to be shown ?
  703. * 0x0010 The dos attributes of the file ?
  704. * 0x0020 In DlgDirSelectEx(), along with file name
  705. * all other details also will be returned
  706. *
  707. */
  708. #define LBUP_RELEASECAPTURE 0x0001
  709. #define LBUP_RESETSELECTION 0x0002
  710. #define LBUP_NOTIFY 0x0004
  711. #define LBUP_SUCCESS 0x0008
  712. #define LBUP_SELCHANGE 0x0010
  713. /*
  714. * rgpch is set up as follows: First there are cMac 2 byte pointers to the
  715. * start of the strings in hStrings or if ownerdraw, it is 4 bytes of data
  716. * supplied by the app and hStrings is not used. Then if multiselection
  717. * listboxes, there are cMac 1 byte selection state bytes (one for each item
  718. * in the list box). If variable height owner draw, there will be cMac 1 byte
  719. * height bytes (once again, one for each item in the list box.).
  720. *
  721. * CHANGES DONE BY SANKAR:
  722. * The selection byte in rgpch is divided into two nibbles. The lower
  723. * nibble is the selection state (1 => Selected; 0 => de-selected)
  724. * and higher nibble is the display state(1 => Hilited and 0 => de-hilited).
  725. * You must be wondering why on earth we should store this selection state and
  726. * the display state seperately.Well! The reason is as follows:
  727. * While Ctrl+Dragging or Shift+Ctrl+Dragging, the user can adjust the
  728. * selection before the mouse button is up. If the user enlarges a range and
  729. * and before the button is up if he shrinks the range, then the old selection
  730. * state has to be preserved for the individual items that do not fall in the
  731. * range finally.
  732. * Please note that the display state and the selection state for an item
  733. * will be the same except when the user is dragging his mouse. When the mouse
  734. * is dragged, only the display state is updated so that the range is hilited
  735. * or de-hilited) but the selection state is preserved. Only when the button
  736. * goes up, for all the individual items in the range, the selection state is
  737. * made the same as the display state.
  738. */
  739. typedef struct tagLBItem {
  740. LONG offsz;
  741. ULONG_PTR itemData;
  742. } LBItem, *lpLBItem;
  743. typedef struct tagLBODItem {
  744. ULONG_PTR itemData;
  745. } LBODItem, *lpLBODItem;
  746. void LBEvent(PLBIV, UINT, int);
  747. /***************************************************************************\
  748. *
  749. * Static Controls
  750. *
  751. \***************************************************************************/
  752. typedef struct tagSTAT {
  753. PWND spwnd;
  754. union {
  755. HANDLE hFont;
  756. BOOL fDeleteIt;
  757. };
  758. HANDLE hImage;
  759. UINT cicur;
  760. UINT iicur;
  761. UINT fPaintKbdCuesOnly : 1;
  762. } STAT, *PSTAT;
  763. typedef struct tagSTATWND {
  764. WND wnd;
  765. PSTAT pstat;
  766. } STATWND, * KPTR_MODIFIER PSTATWND;
  767. typedef struct tagCURSORRESOURCE {
  768. WORD xHotspot;
  769. WORD yHotspot;
  770. BITMAPINFOHEADER bih;
  771. } CURSORRESOURCE, *PCURSORRESOURCE;
  772. #define NextWordBoundary(p) ((PBYTE)(p) + ((ULONG_PTR)(p) & 1))
  773. #define NextDWordBoundary(p) ((PBYTE)(p) + ((ULONG_PTR)(-(LONG_PTR)(p)) & 3))
  774. // DDEML stub prototypes
  775. DWORD Event(PEVENT_PACKET pep);
  776. PVOID CsValidateInstance(HANDLE hInst);
  777. /***************************************************************************\
  778. * WOW Prototypes, Typedefs and Defines
  779. *
  780. * WOW registers resource callback functions so it can load 16 bit resources
  781. * transparently for Win32. At resource load time, these WOW functions are
  782. * called.
  783. *
  784. \***************************************************************************/
  785. BOOL APIENTRY _FreeResource(HANDLE hResData, HINSTANCE hModule);
  786. LPSTR APIENTRY _LockResource(HANDLE hResData, HINSTANCE hModule);
  787. BOOL APIENTRY _UnlockResource(HANDLE hResData, HINSTANCE hModule);
  788. #define FINDRESOURCEA(hModule,lpName,lpType) ((*(pfnFindResourceExA))(hModule, lpType, lpName, 0))
  789. #define FINDRESOURCEW(hModule,lpName,lpType) ((*(pfnFindResourceExW))(hModule, lpType, lpName, 0))
  790. #define FINDRESOURCEEXA(hModule,lpName,lpType,wLang) ((*(pfnFindResourceExA))(hModule, lpType, lpName, wLang))
  791. #define FINDRESOURCEEXW(hModule,lpName,lpType,wLang) ((*(pfnFindResourceExW))(hModule, lpType, lpName, wLang))
  792. #define LOADRESOURCE(hModule,hResInfo) ((*(pfnLoadResource))(hModule, hResInfo))
  793. #define LOCKRESOURCE(hResData, hModule) ((*(pfnLockResource))(hResData, hModule))
  794. #define UNLOCKRESOURCE(hResData, hModule) ((*(pfnUnlockResource))(hResData, hModule))
  795. #define FREERESOURCE(hResData, hModule) ((*(pfnFreeResource))(hResData, hModule))
  796. #define SIZEOFRESOURCE(hModule,hResInfo) ((*(pfnSizeofResource))(hModule, hResInfo))
  797. #define GETEXPWINVER(hModule) ((*(pfnGetExpWinVer))((hModule)?(hModule):GetModuleHandle(NULL)))
  798. /*
  799. * Pointers to unaligned-bits. These are necessary for handling
  800. * bitmap-info's loaded from file.
  801. */
  802. typedef BITMAPINFO UNALIGNED *UPBITMAPINFO;
  803. typedef BITMAPINFOHEADER UNALIGNED *UPBITMAPINFOHEADER;
  804. typedef BITMAPCOREHEADER UNALIGNED *UPBITMAPCOREHEADER;
  805. #define CCHFILEMAX MAX_PATH
  806. HLOCAL WINAPI DispatchLocalAlloc(
  807. UINT uFlags,
  808. UINT uBytes,
  809. HANDLE hInstance);
  810. HLOCAL WINAPI DispatchLocalReAlloc(
  811. HLOCAL hMem,
  812. UINT uBytes,
  813. UINT uFlags,
  814. HANDLE hInstance,
  815. PVOID* ppv);
  816. LPVOID WINAPI DispatchLocalLock(
  817. HLOCAL hMem,
  818. HANDLE hInstance);
  819. BOOL WINAPI DispatchLocalUnlock(
  820. HLOCAL hMem,
  821. HANDLE hInstance);
  822. UINT WINAPI DispatchLocalSize(
  823. HLOCAL hMem,
  824. HANDLE hInstance);
  825. HLOCAL WINAPI DispatchLocalFree(
  826. HLOCAL hMem,
  827. HANDLE hInstance);
  828. #define UserLocalAlloc(uFlag,uBytes) RtlAllocateHeap(pUserHeap, uFlag, uBytes)
  829. #define UserLocalReAlloc(p, uBytes, uFlags) RtlReAllocateHeap(pUserHeap, uFlags, p, uBytes)
  830. #define UserLocalFree(p) RtlFreeHeap(pUserHeap, 0, (LPSTR)(p))
  831. #define UserLocalSize(p) RtlSizeHeap(pUserHeap, 0, (LPSTR)(p))
  832. LONG TabTextOut(HDC hdc, int x, int y, LPCWSTR lpstring, int nCount,
  833. int nTabPositions, CONST INT *lpTabPositions, int iTabOrigin,
  834. BOOL fDrawTheText, int iCharset);
  835. LONG UserLpkTabbedTextOut(HDC hdc, int x, int y, LPCWSTR lpstring,
  836. int nCount, int nTabPositions, CONST INT *lpTabPositions,
  837. int iTabOrigin, BOOL fDrawTheText, int cxCharWidth,
  838. int cyCharHeight, int iCharset);
  839. void UserLpkPSMTextOut(HDC hdc, int xLeft, int yTop,
  840. LPWSTR lpsz, int cch, DWORD dwFlags);
  841. void PSMTextOut(HDC hdc, int xLeft, int yTop, LPWSTR lpsz, int cch, DWORD dwFlags);
  842. void ECUpdateFormat(PED ped, DWORD dwStyle, DWORD dwExStyle);
  843. int LoadStringOrError(HANDLE, UINT, LPTSTR, int, WORD);
  844. int RtlGetIdFromDirectory(PBYTE, BOOL, int, int, DWORD, PDWORD);
  845. BOOL RtlCaptureAnsiString(PIN_STRING, LPCSTR, BOOL);
  846. BOOL RtlCaptureLargeAnsiString(PLARGE_IN_STRING, LPCSTR, BOOL);
  847. LONG BroadcastSystemMessageWorker(
  848. DWORD dwFlags,
  849. LPDWORD lpdwRecipients,
  850. UINT uiMessage,
  851. WPARAM wParam,
  852. LPARAM lParam,
  853. PBSMINFO pBSMInfo,
  854. BOOL fAnsi);
  855. PWND FASTCALL ValidateHwnd(HWND hwnd);
  856. PWND FASTCALL ValidateHwndNoRip(HWND hwnd);
  857. PSTR ECLock(PED ped);
  858. void ECUnlock(PED ped);
  859. BOOL ECNcCreate(PED, PWND, LPCREATESTRUCT);
  860. void ECInvalidateClient(PED ped, BOOL fErase);
  861. BOOL ECCreate(PED ped, LONG windowStyle);
  862. void ECWord(PED, ICH, BOOL, ICH*, ICH*);
  863. ICH ECFindTab(LPSTR, ICH);
  864. void ECNcDestroyHandler(PWND, PED);
  865. BOOL ECSetText(PED, LPSTR);
  866. void ECSetPasswordChar(PED, UINT);
  867. ICH ECCchInWidth(PED, HDC, LPSTR, ICH, int, BOOL);
  868. void ECEmptyUndo(PUNDO);
  869. void ECSaveUndo(PUNDO pundoFrom, PUNDO pundoTo, BOOL fClear);
  870. BOOL ECInsertText(PED, LPSTR, ICH*);
  871. ICH ECDeleteText(PED);
  872. void ECResetTextInfo(PED ped);
  873. void ECNotifyParent(PED, int);
  874. void ECSetEditClip(PED, HDC, BOOL);
  875. HDC ECGetEditDC(PED, BOOL);
  876. void ECReleaseEditDC(PED, HDC, BOOL);
  877. ICH ECGetText(PED, ICH, LPSTR, BOOL);
  878. void ECSetFont(PED, HFONT, BOOL);
  879. void ECSetMargin(PED, UINT, long, BOOL);
  880. ICH ECCopy(PED);
  881. BOOL ECCalcChangeSelection(PED, ICH, ICH, LPBLOCK, LPBLOCK);
  882. void ECFindXORblks(LPBLOCK, LPBLOCK, LPBLOCK, LPBLOCK);
  883. BOOL ECIsCharNumeric(PED ped, DWORD keyPress);
  884. /*
  885. * Combine two DBCS WM_CHAR messages to
  886. * a single WORD value.
  887. */
  888. WORD DbcsCombine(HWND, WORD);
  889. #define CrackCombinedDbcsLB(c) ((BYTE)(c))
  890. #define CrackCombinedDbcsTB(c) ((c) >> 8)
  891. ICH ECAdjustIch(PED, LPSTR, ICH);
  892. ICH ECAdjustIchNext(PED, LPSTR, ICH);
  893. int ECGetDBCSVector(PED, HDC, BYTE);
  894. BOOL ECIsDBCSLeadByte(PED, BYTE);
  895. LPSTR ECAnsiNext(PED, LPSTR);
  896. LPSTR ECAnsiPrev(PED, LPSTR, LPSTR);
  897. ICH ECPrevIch(PED, LPSTR, ICH);
  898. ICH ECNextIch(PED, LPSTR, ICH);
  899. void ECEnableDisableIME( PED ped );
  900. void ECImmSetCompositionFont( PED ped );
  901. void ECImmSetCompositionWindow( PED ped, LONG, LONG );
  902. void ECSetCaretHandler(PED ped);
  903. void ECInitInsert(PED ped, HKL hkl);
  904. LRESULT ECImeComposition(PED ped, WPARAM wParam, LPARAM lParam);
  905. LRESULT EcImeRequestHandler(PED, WPARAM, LPARAM); // NT 5.0
  906. BOOL HanjaKeyHandler(PED ped); // Korean Support
  907. void ECInOutReconversionMode(PED ped, BOOL fIn);
  908. // ECTabTheTextOut draw codes
  909. #define ECT_CALC 0
  910. #define ECT_NORMAL 1
  911. #define ECT_SELECTED 2
  912. #define ECGetCaretWidth() (gpsi->uCaretWidth)
  913. UINT ECTabTheTextOut(HDC, int, int, int, int,
  914. LPSTR, int, ICH, PED, int, BOOL, LPSTRIPINFO);
  915. HBRUSH ECGetControlBrush(PED, HDC, LONG);
  916. HBRUSH ECGetBrush(PED ped, HDC hdc);
  917. int ECGetModKeys(int);
  918. VOID ECSize(PED, LPRECT, BOOL);
  919. ICH MLInsertText(PED, LPSTR, ICH, BOOL);
  920. ICH MLDeleteText(PED);
  921. BOOL MLEnsureCaretVisible(PED);
  922. VOID MLDrawText(PED, HDC, ICH, ICH, BOOL);
  923. VOID MLBuildchLines(PED, ICH, int, BOOL, PLONG, PLONG);
  924. VOID MLShiftchLines(PED, ICH, int);
  925. VOID MLSetCaretPosition(PED,HDC);
  926. VOID MLIchToXYPos(PED, HDC, ICH, BOOL, LPPOINT);
  927. int MLIchToLine(PED, ICH);
  928. VOID MLMouseMotion(PED, UINT, UINT, LPPOINT);
  929. ICH MLLine(PED, ICH);
  930. VOID MLStripCrCrLf(PED);
  931. BOOL MLUndo(PED);
  932. LRESULT MLEditWndProc(HWND, PED, UINT, WPARAM, LPARAM);
  933. VOID MLChar(PED, DWORD, int);
  934. VOID MLSetSelection(PED, BOOL, ICH, ICH);
  935. LONG MLCreate(PED, LPCREATESTRUCT);
  936. BOOL MLInsertCrCrLf(PED);
  937. VOID MLSetHandle(PED, HANDLE);
  938. LONG MLGetLine(PED, ICH, ICH, LPSTR);
  939. ICH MLLineIndex(PED, ICH);
  940. VOID MLSize(PED, BOOL);
  941. VOID MLChangeSelection(PED, HDC, ICH, ICH);
  942. BOOL MLSetTabStops(PED, int, LPINT);
  943. LONG MLScroll(PED, BOOL, int, int, BOOL);
  944. VOID MLUpdateiCaretLine(PED ped);
  945. ICH MLLineLength(PED, ICH);
  946. VOID MLReplaceSel(PED, LPSTR);
  947. VOID SLReplaceSel(PED, LPSTR);
  948. BOOL SLUndo(PED);
  949. VOID SLSetCaretPosition(PED, HDC);
  950. int SLIchToLeftXPos(PED, HDC, ICH);
  951. VOID SLChangeSelection(PED, HDC, ICH, ICH);
  952. VOID SLDrawLine(PED, HDC, int, int, ICH, int, BOOL);
  953. VOID SLDrawText(PED, HDC, ICH);
  954. BOOL SLScrollText(PED, HDC);
  955. VOID SLSetSelection(PED,ICH, ICH);
  956. ICH SLInsertText(PED, LPSTR, ICH);
  957. VOID SLChar(PED, DWORD);
  958. LONG SLCreate(PED, LPCREATESTRUCT);
  959. LRESULT SLEditWndProc(HWND, PED, UINT, WPARAM, LPARAM);
  960. LRESULT EditWndProc(PWND, UINT, WPARAM, LPARAM);
  961. #define GETAPPVER() GetClientInfo()->dwExpWinVer
  962. #define THREAD_HKL() (KHKL_TO_HKL(GetClientInfo()->hKL))
  963. #define GETCLIENTTHREADINFO() (CLIENTTHREADINFO *)KPVOID_TO_PVOID(GetClientInfo()->pClientThreadInfo)
  964. #define CLIENTTHREADINFO(pci) (CLIENTTHREADINFO *)KPVOID_TO_PVOID((pci)->pClientThreadInfo)
  965. #define ISDELIMETERA(ch) ((ch == ' ') || (ch == '\t'))
  966. #define ISDELIMETERW(ch) ((ch == L' ') || (ch == L'\t'))
  967. #define AWCOMPARECHAR(ped,pbyte,awchar) (ped->fAnsi ? (*(PUCHAR)(pbyte) == (UCHAR)(awchar)) : (*(LPWSTR)(pbyte) == (WCHAR)(awchar)))
  968. /* Menu that comes up when you press the right mouse button on an edit
  969. * control
  970. */
  971. #define ID_EC_PROPERTY_MENU 1
  972. #define IDD_MDI_ACTIVATE 9
  973. #ifndef _USERK_
  974. /*
  975. * String IDs
  976. */
  977. #define STR_ERROR 0x00000002L
  978. #define STR_MOREWINDOWS 0x0000000DL
  979. #define STR_NOMEMBITMAP 0x0000000EL
  980. /*
  981. * IME specific context menu string
  982. */
  983. #define STR_IMEOPEN 700
  984. #define STR_IMECLOSE 701
  985. #define STR_SOFTKBDOPEN 702
  986. #define STR_SOFTKBDCLOSE 703
  987. #define STR_RECONVERTSTRING 705
  988. /*
  989. * Shutdown logging strings.
  990. */
  991. #define STR_SHUTDOWN_SHUTDOWN 706
  992. #define STR_SHUTDOWN_POWEROFF 707
  993. #define STR_SHUTDOWN_REBOOT 708
  994. /*
  995. * Misc. strings.
  996. */
  997. #define STR_UNKNOWN 709
  998. /*
  999. * ExitWindowsEx warning dlg strings
  1000. */
  1001. #define IDS_EXITWINDOWS_TITLE 710
  1002. #define IDS_SHUTDOWN_REMOTE 711
  1003. #define IDS_SHUTDOWN_REMOTE_OTHERUSERS 712
  1004. #define IDS_SHUTDOWN_OTHERUSERS 713
  1005. #define IDS_RESTART_OTHERUSERS 714
  1006. #endif // !_USERK_
  1007. BOOL InitClientDrawing();
  1008. /***************************************************************************\
  1009. * Function Prototypes
  1010. *
  1011. * NOTE: Only prototypes for GLOBAL (across module) functions should be put
  1012. * here. Prototypes for functions that are global to a single module should
  1013. * be put at the head of that module.
  1014. *
  1015. \***************************************************************************/
  1016. int InternalScrollWindowEx(HWND hwnd, int dx, int dy, CONST RECT *prcScroll,
  1017. CONST RECT *prcClip, HRGN hrgnUpdate, LPRECT prcUpdate,
  1018. UINT dwFlags, DWORD dwTime);
  1019. BOOL IsMetaFile(HDC hdc);
  1020. BOOL DrawDiagonal(HDC hdc, LPRECT lprc, HBRUSH hbrTL, HBRUSH hbrBR, UINT flags);
  1021. BOOL FillTriangle(HDC hdc, LPRECT lprc, HBRUSH hbr, UINT flags);
  1022. BOOL _ClientFreeLibrary(HANDLE hmod);
  1023. DWORD _ClientGetListboxString(PWND pwnd, UINT msg, WPARAM wParam, LPSTR lParam,
  1024. ULONG_PTR xParam, PROC xpfn);
  1025. LPHLP HFill(LPCSTR lpszHelp, DWORD ulCommand, ULONG_PTR ulData);
  1026. BOOL SetVideoTimeout(DWORD dwVideoTimeout);
  1027. DWORD _GetWindowLong(PWND pwnd, int index, BOOL bAnsi);
  1028. #ifdef _WIN64
  1029. ULONG_PTR _GetWindowLongPtr(PWND pwnd, int index, BOOL bAnsi);
  1030. #else
  1031. #define _GetWindowLongPtr _GetWindowLong
  1032. #endif
  1033. WORD _GetWindowWord(PWND pwnd, int index);
  1034. HWND InternalFindWindowExA(HWND hwndParent, HWND hwndChild, LPCSTR pClassName,
  1035. LPCSTR pWindowName, DWORD dwFlag);
  1036. HWND InternalFindWindowExW(HWND hwndParent, HWND hwndChild, LPCTSTR pClassName,
  1037. LPCTSTR pWindowName, DWORD dwFlag);
  1038. /*
  1039. * Message thunks.
  1040. */
  1041. #define fnCOPYDATA NtUserMessageCall
  1042. #define fnDDEINIT NtUserMessageCall
  1043. #define fnDWORD NtUserMessageCall
  1044. #define fnNCDESTROY NtUserMessageCall
  1045. #define fnDWORDOPTINLPMSG NtUserMessageCall
  1046. #define fnGETTEXTLENGTHS NtUserMessageCall
  1047. #define fnGETDBCSTEXTLENGTHS NtUserMessageCall
  1048. #define fnINLPCREATESTRUCT NtUserMessageCall
  1049. #define fnINLPCOMPAREITEMSTRUCT NtUserMessageCall
  1050. #define fnINLPDELETEITEMSTRUCT NtUserMessageCall
  1051. #define fnINLPDRAWITEMSTRUCT NtUserMessageCall
  1052. #define fnINLPHELPINFOSTRUCT NtUserMessageCall
  1053. #define fnINLPHLPSTRUCT NtUserMessageCall
  1054. #define fnINLPWINDOWPOS NtUserMessageCall
  1055. #define fnINOUTDRAG NtUserMessageCall
  1056. #define fnINOUTLPMEASUREITEMSTRUCT NtUserMessageCall
  1057. #define fnINOUTLPPOINT5 NtUserMessageCall
  1058. #define fnINOUTLPRECT NtUserMessageCall
  1059. #define fnINOUTLPSCROLLINFO NtUserMessageCall
  1060. #define fnINOUTLPWINDOWPOS NtUserMessageCall
  1061. #define fnINOUTNCCALCSIZE NtUserMessageCall
  1062. #define fnINOUTNEXTMENU NtUserMessageCall
  1063. #define fnINOUTSTYLECHANGE NtUserMessageCall
  1064. #define fnOPTOUTLPDWORDOPTOUTLPDWORD NtUserMessageCall
  1065. #define fnOUTLPRECT NtUserMessageCall
  1066. #define fnPOPTINLPUINT NtUserMessageCall
  1067. #define fnPOUTLPINT NtUserMessageCall
  1068. #define fnSENTDDEMSG NtUserMessageCall
  1069. #define fnOUTDWORDINDWORD NtUserMessageCall
  1070. #define fnINOUTMENUGETOBJECT NtUserMessageCall
  1071. #define fnINCBOXSTRING NtUserMessageCall
  1072. #define fnINCNTOUTSTRING NtUserMessageCall
  1073. #define fnINCNTOUTSTRINGNULL NtUserMessageCall
  1074. #define fnINLBOXSTRING NtUserMessageCall
  1075. #define fnINLPMDICREATESTRUCT NtUserMessageCall
  1076. #define fnINSTRING NtUserMessageCall
  1077. #define fnINSTRINGNULL NtUserMessageCall
  1078. #define fnINWPARAMCHAR NtUserMessageCall
  1079. #define fnOUTCBOXSTRING NtUserMessageCall
  1080. #define fnOUTLBOXSTRING NtUserMessageCall
  1081. #define fnOUTSTRING NtUserMessageCall
  1082. #define fnKERNELONLY NtUserMessageCall
  1083. #define fnOUTLPCOMBOBOXINFO NtUserMessageCall
  1084. #define fnOUTLPSCROLLBARINFO NtUserMessageCall
  1085. #define MESSAGEPROTO(func) \
  1086. LRESULT CALLBACK fn ## func( \
  1087. HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, \
  1088. ULONG_PTR xParam, DWORD xpfnWndProc, BOOL bAnsi)
  1089. MESSAGEPROTO(COPYGLOBALDATA);
  1090. MESSAGEPROTO(INDEVICECHANGE);
  1091. MESSAGEPROTO(INPAINTCLIPBRD);
  1092. MESSAGEPROTO(INSIZECLIPBRD);
  1093. MESSAGEPROTO(IMECONTROL);
  1094. MESSAGEPROTO(IMEREQUEST);
  1095. MESSAGEPROTO(INWPARAMDBCSCHAR);
  1096. MESSAGEPROTO(EMGETSEL);
  1097. MESSAGEPROTO(EMSETSEL);
  1098. MESSAGEPROTO(CBGETEDITSEL);
  1099. /*
  1100. * clhook.c
  1101. */
  1102. #define IsHooked(pci, fsHook) \
  1103. ((fsHook & (pci->fsHooks | pci->pDeskInfo->fsHooks)) != 0)
  1104. LRESULT fnHkINLPCWPSTRUCTW(PWND pwnd, UINT message, WPARAM wParam,
  1105. LPARAM lParam, ULONG_PTR xParam);
  1106. LRESULT fnHkINLPCWPSTRUCTA(PWND pwnd, UINT message, WPARAM wParam,
  1107. LPARAM lParam, ULONG_PTR xParam);
  1108. LRESULT fnHkINLPCWPRETSTRUCTW(PWND pwnd, UINT message, WPARAM wParam,
  1109. LPARAM lParam, ULONG_PTR xParam);
  1110. LRESULT fnHkINLPCWPRETSTRUCTA(PWND pwnd, UINT message, WPARAM wParam,
  1111. LPARAM lParam, ULONG_PTR xParam);
  1112. LRESULT DispatchHookW(int dw, WPARAM wParam, LPARAM lParam, HOOKPROC pfn);
  1113. LRESULT DispatchHookA(int dw, WPARAM wParam, LPARAM lParam, HOOKPROC pfn);
  1114. /*
  1115. * client.c
  1116. */
  1117. LRESULT APIENTRY ButtonWndProcA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  1118. LRESULT APIENTRY ButtonWndProcW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  1119. LRESULT APIENTRY MenuWndProcA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  1120. LRESULT APIENTRY MenuWndProcW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  1121. LRESULT APIENTRY DesktopWndProcA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  1122. LRESULT APIENTRY DesktopWndProcW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  1123. LRESULT APIENTRY ScrollBarWndProcA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  1124. LRESULT APIENTRY ScrollBarWndProcW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  1125. LRESULT APIENTRY ListBoxWndProcA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  1126. LRESULT APIENTRY ListBoxWndProcW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  1127. LRESULT APIENTRY StaticWndProcA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  1128. LRESULT APIENTRY StaticWndProcW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  1129. LRESULT APIENTRY ComboBoxWndProcA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  1130. LRESULT APIENTRY ComboBoxWndProcW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  1131. LRESULT APIENTRY ComboListBoxWndProcA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  1132. LRESULT APIENTRY ComboListBoxWndProcW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  1133. LRESULT APIENTRY MDIClientWndProcA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  1134. LRESULT APIENTRY MDIClientWndProcW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  1135. INT_PTR APIENTRY MB_DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  1136. INT_PTR APIENTRY MDIActivateDlgProcA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  1137. INT_PTR APIENTRY MDIActivateDlgProcW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  1138. LRESULT APIENTRY EditWndProcA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  1139. LRESULT APIENTRY EditWndProcW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  1140. LRESULT APIENTRY ImeWndProcA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  1141. LRESULT APIENTRY ImeWndProcW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  1142. #ifdef MESSAGE_PUMP_HOOK
  1143. DWORD APIENTRY RealGetQueueStatus(UINT flags);
  1144. DWORD WINAPI RealMsgWaitForMultipleObjectsEx(DWORD nCount, CONST HANDLE *pHandles,
  1145. DWORD dwMilliseconds, DWORD dwWakeMask, DWORD dwFlags);
  1146. #endif
  1147. LRESULT APIENTRY RealDefWindowProcA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  1148. LRESULT APIENTRY RealDefWindowProcW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  1149. LRESULT APIENTRY DispatchDefWindowProcA(PWND pwnd, UINT msg, WPARAM wParam, LPARAM lParam, ULONG_PTR pfn);
  1150. LRESULT APIENTRY DispatchDefWindowProcW(PWND pwnd, UINT msg, WPARAM wParam, LPARAM lParam, ULONG_PTR pfn);
  1151. BOOL InitUserApiHook(HMODULE hmod, ULONG_PTR offPfnInitUserApiHook);
  1152. BOOL ClearUserApiHook(HMODULE hmod);
  1153. BOOL CALLBACK DefaultOWP(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT * pr, void ** pvCookie);
  1154. void ResetUserApiHook(USERAPIHOOK * puah);
  1155. LRESULT SendMessageWorker(PWND pwnd, UINT message, WPARAM wParam, LPARAM lParam, BOOL fAnsi);
  1156. LRESULT SendMessageTimeoutWorker(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam,
  1157. UINT fuFlags, UINT uTimeout, PULONG_PTR lpdwResult, BOOL fAnsi);
  1158. void ClientEmptyClipboard(void);
  1159. VOID GetActiveKeyboardName(LPWSTR lpszName);
  1160. HANDLE OpenKeyboardLayoutFile(LPWSTR lpszKLName, LANGID langid,
  1161. PUINT puFlags, PUINT poffTable, PUINT pKbdInputLocale,
  1162. OUT OPTIONAL PKBDTABLE_MULTI_INTERNAL pKbdTableMulti);
  1163. VOID LoadPreloadKeyboardLayouts(void);
  1164. void SetWindowState(PWND pwnd, UINT flags);
  1165. void ClearWindowState(PWND pwnd, UINT flags);
  1166. HKL LoadKeyboardLayoutWorker(HKL hkl, LPCWSTR lpszKLName, LANGID langid, UINT uFlags, BOOL fFailSafe);
  1167. BOOL GetRemoteKeyboardLayout(PWCHAR pwszKLName, LANGID* pLangId);
  1168. /*
  1169. * Worker routines called from both the window procs and
  1170. * the callback thunks.
  1171. */
  1172. LRESULT DispatchClientMessage(PWND pwnd, UINT message, WPARAM wParam,
  1173. LPARAM lParam, ULONG_PTR pfn);
  1174. LRESULT DefWindowProcWorker(PWND pwnd, UINT message, WPARAM wParam,
  1175. LPARAM lParam, DWORD fAnsi);
  1176. LRESULT RealDefWindowProcWorker(PWND pwnd, UINT message, WPARAM wParam,
  1177. LPARAM lParam, DWORD fAnsi);
  1178. LRESULT ButtonWndProcWorker(PWND pwnd, UINT msg, WPARAM wParam,
  1179. LPARAM lParam, DWORD fAnsi);
  1180. LRESULT ListBoxWndProcWorker(PWND pwnd, UINT msg, WPARAM wParam,
  1181. LPARAM lParam, DWORD fAnsi);
  1182. LRESULT StaticWndProcWorker(PWND pwnd, UINT msg, WPARAM wParam,
  1183. LPARAM lParam, DWORD fAnsi);
  1184. LRESULT ComboBoxWndProcWorker(PWND pwnd, UINT msg, WPARAM wParam,
  1185. LPARAM lParam, DWORD fAnsi);
  1186. LRESULT ComboListBoxWndProcWorker(PWND pwnd, UINT msg, WPARAM wParam,
  1187. LPARAM lParam, DWORD fAnsi);
  1188. LRESULT MDIClientWndProcWorker(PWND pwnd, UINT msg, WPARAM wParam,
  1189. LPARAM lParam, DWORD fAnsi);
  1190. LRESULT EditWndProcWorker(PWND pwnd, UINT msg, WPARAM wParam,
  1191. LPARAM lParam, DWORD fAnsi);
  1192. LRESULT DefDlgProcWorker(PWND pwnd, UINT msg, WPARAM wParam,
  1193. LPARAM lParam, DWORD fAnsi);
  1194. LRESULT ImeWndProcWorker(PWND pwnd, UINT msg, WPARAM wParam,
  1195. LPARAM lParam, DWORD fAnsi);
  1196. /*
  1197. * Server Stubs - ntstubs.c
  1198. */
  1199. LONG _SetWindowLong(
  1200. HWND hWnd,
  1201. int nIndex,
  1202. LONG dwNewLong,
  1203. BOOL bAnsi);
  1204. #ifdef _WIN64
  1205. LONG_PTR _SetWindowLongPtr(
  1206. HWND hWnd,
  1207. int nIndex,
  1208. LONG_PTR dwNewLong,
  1209. BOOL bAnsi);
  1210. #else
  1211. #define _SetWindowLongPtr _SetWindowLong
  1212. #endif
  1213. BOOL _PeekMessage(
  1214. LPMSG pmsg,
  1215. HWND hwnd,
  1216. UINT wMsgFilterMin,
  1217. UINT wMsgFilterMax,
  1218. UINT wRemoveMsg,
  1219. BOOL bAnsi);
  1220. BOOL _DefSetText(
  1221. HWND hwnd,
  1222. LPCWSTR pstr,
  1223. BOOL bAnsi);
  1224. HCURSOR _GetCursorFrameInfo(
  1225. HCURSOR hcur,
  1226. LPWSTR id,
  1227. int iFrame,
  1228. LPDWORD pjifRate,
  1229. LPINT pccur);
  1230. HWND _CreateWindowEx(
  1231. DWORD dwExStyle,
  1232. LPCTSTR pClassName,
  1233. LPCTSTR pWindowName,
  1234. DWORD dwStyle,
  1235. int x,
  1236. int y,
  1237. int nWidth,
  1238. int nHeight,
  1239. HWND hwndParent,
  1240. HMENU hmenu,
  1241. HANDLE hModule,
  1242. LPVOID pParam,
  1243. DWORD dwFlags);
  1244. HWND VerNtUserCreateWindowEx(
  1245. IN DWORD dwExStyle,
  1246. IN PLARGE_STRING pstrClassName,
  1247. IN PLARGE_STRING pstrWindowName OPTIONAL,
  1248. IN DWORD dwStyle,
  1249. IN int x,
  1250. IN int y,
  1251. IN int nWidth,
  1252. IN int nHeight,
  1253. IN HWND hwndParent,
  1254. IN HMENU hmenu,
  1255. IN HANDLE hModule,
  1256. IN LPVOID pParam,
  1257. IN DWORD dwFlags);
  1258. HKL _LoadKeyboardLayoutEx(
  1259. HANDLE hFile,
  1260. UINT offTable,
  1261. PKBDTABLE_MULTI_INTERNAL pKbdTableMulti,
  1262. HKL hkl,
  1263. LPCWSTR pwszKL,
  1264. UINT KbdInputLocale,
  1265. UINT Flags);
  1266. BOOL _SetCursorIconData(
  1267. HCURSOR hCursor,
  1268. PCURSORDATA pcur);
  1269. HCURSOR FindExistingCursorIcon(
  1270. LPWSTR pszModName,
  1271. LPCWSTR pszResName,
  1272. PCURSORFIND pcfSearch);
  1273. HANDLE CreateLocalMemHandle(
  1274. HANDLE hMem);
  1275. HANDLE ConvertMemHandle(
  1276. HANDLE hMem,
  1277. UINT cbNULL);
  1278. HHOOK _SetWindowsHookEx(
  1279. HANDLE hmod,
  1280. LPTSTR pszLib,
  1281. DWORD idThread,
  1282. int nFilterType,
  1283. PROC pfnFilterProc,
  1284. DWORD dwFlags);
  1285. #if 0
  1286. DWORD WINAPI ImmGetReconvertTotalSize(
  1287. DWORD dwSize,
  1288. REQ_CALLER eCaller,
  1289. BOOL bAnsiTarget);
  1290. DWORD WINAPI ImmReconversionWorker(
  1291. LPRECONVERTSTRING lpRecTo,
  1292. LPRECONVERTSTRING lpRecFrom,
  1293. BOOL bToAnsi,
  1294. DWORD dwCodePage);
  1295. #endif
  1296. /*
  1297. * classc.c
  1298. */
  1299. ULONG_PTR _GetClassData(
  1300. PCLS pcls,
  1301. PWND pwnd,
  1302. int index,
  1303. BOOL bAnsi);
  1304. DWORD _GetClassLong(
  1305. PWND pwnd,
  1306. int index,
  1307. BOOL bAnsi);
  1308. #ifdef _WIN64
  1309. ULONG_PTR _GetClassLongPtr(
  1310. PWND pwnd,
  1311. int index,
  1312. BOOL bAnsi);
  1313. #else
  1314. #define _GetClassLongPtr _GetClassLong
  1315. #endif
  1316. /*
  1317. * mngrayc.c
  1318. */
  1319. BOOL BitBltSysBmp(
  1320. HDC hdc,
  1321. int x,
  1322. int y,
  1323. UINT i);
  1324. /*
  1325. * clenum.c
  1326. */
  1327. DWORD BuildHwndList(
  1328. HDESK hdesk,
  1329. HWND hwndNext,
  1330. BOOL fEnumChildren,
  1331. DWORD idThread,
  1332. HWND **phwndFirst);
  1333. /*
  1334. * cltxt.h
  1335. */
  1336. ATOM RegisterClassExWOWA(
  1337. PWNDCLASSEXA lpWndClass,
  1338. LPDWORD pdwWOWstuff,
  1339. WORD fnid,
  1340. DWORD dwFlags);
  1341. ATOM RegisterClassExWOWW(
  1342. PWNDCLASSEXW lpWndClass,
  1343. LPDWORD pdwWOWstuff,
  1344. WORD fnid,
  1345. DWORD dwFlags);
  1346. void CopyLogFontAtoW(
  1347. PLOGFONTW pdest,
  1348. PLOGFONTA psrc);
  1349. void CopyLogFontWtoA(
  1350. PLOGFONTA pdest,
  1351. PLOGFONTW psrc);
  1352. /*
  1353. * dlgmgrc.c
  1354. */
  1355. PWND _NextControl(
  1356. PWND pwndDlg,
  1357. PWND pwnd,
  1358. UINT uFlags);
  1359. PWND _PrevControl(
  1360. PWND pwndDlg,
  1361. PWND pwnd,
  1362. UINT uFlags);
  1363. PWND _GetNextDlgGroupItem(
  1364. PWND pwndDlg,
  1365. PWND pwnd,
  1366. BOOL fPrev);
  1367. PWND _GetNextDlgTabItem(
  1368. PWND pwndDlg,
  1369. PWND pwnd,
  1370. BOOL fPrev);
  1371. PWND _GetChildControl(
  1372. PWND pwndDlg,
  1373. PWND pwndLevel);
  1374. /*
  1375. * winmgrc.c
  1376. */
  1377. BOOL FChildVisible(
  1378. HWND hwnd);
  1379. /*
  1380. * draw.c
  1381. */
  1382. BOOL PaintRect(
  1383. HWND hwndBrush,
  1384. HWND hwndPaint,
  1385. HDC hdc,
  1386. HBRUSH hbr,
  1387. LPRECT lprc);
  1388. #define NtUserReleaseDC(hwnd,hdc) NtUserCallOneParam((ULONG_PTR)(hdc), SFI__RELEASEDC)
  1389. #define NtUserArrangeIconicWindows(hwnd) (UINT)NtUserCallHwndLock((hwnd), SFI_XXXARRANGEICONICWINDOWS)
  1390. #define NtUserBeginDeferWindowPos(nNumWindows) (HANDLE)NtUserCallOneParam((nNumWindows),SFI__BEGINDEFERWINDOWPOS)
  1391. #define NtUserCreateMenu() (HMENU)NtUserCallNoParam(SFI__CREATEMENU)
  1392. #define NtUserDestroyCaret() (BOOL)NtUserCallNoParam(SFI_ZZZDESTROYCARET)
  1393. #define NtUserEnableWindow(hwnd, bEnable) (BOOL)NtUserCallHwndParamLock((hwnd), (bEnable),SFI_XXXENABLEWINDOW)
  1394. #define NtUserGetMessagePos() (DWORD)NtUserCallNoParam(SFI__GETMESSAGEPOS)
  1395. #define NtUserKillSystemTimer(hwnd,nIDEvent) (BOOL)NtUserCallHwndParam((hwnd), (nIDEvent), SFI__KILLSYSTEMTIMER)
  1396. #define NtUserMessageBeep(wType) (BOOL)NtUserCallOneParam((wType), SFI_XXXMESSAGEBEEP)
  1397. #define NtUserSetWindowContextHelpId(hwnd,id) (BOOL)NtUserCallHwndParam((hwnd), (id), SFI__SETWINDOWCONTEXTHELPID)
  1398. #define NtUserGetWindowContextHelpId(hwnd) (BOOL)NtUserCallHwnd((hwnd), SFI__GETWINDOWCONTEXTHELPID)
  1399. #define NtUserRedrawFrame(hwnd) NtUserCallHwndLock((hwnd), SFI_XXXREDRAWFRAME)
  1400. #define NtUserRedrawFrameAndHook(hwnd) NtUserCallHwndLock((hwnd), SFI_XXXREDRAWFRAMEANDHOOK)
  1401. #define NtUserRedrawTitle(hwnd, wFlags) NtUserCallHwndParamLock((hwnd), (wFlags), SFI_XXXREDRAWTITLE)
  1402. #define NtUserReleaseCapture() (BOOL)NtUserCallNoParam(SFI_XXXRELEASECAPTURE)
  1403. #define NtUserSetCaretPos(X,Y) (BOOL)NtUserCallTwoParam((DWORD)(X), (DWORD)(Y), SFI_ZZZSETCARETPOS)
  1404. #define NtUserSetCursorPos(X, Y) (BOOL)NtUserCallTwoParam((X), (Y), SFI_ZZZSETCURSORPOS)
  1405. #define NtUserSetForegroundWindow(hwnd) (BOOL)NtUserCallHwndLock((hwnd), SFI_XXXSTUBSETFOREGROUNDWINDOW)
  1406. #define NtUserSetSysMenu(hwnd) NtUserCallHwndLock((hwnd), SFI_XXXSETSYSMENU)
  1407. #define NtUserSetVisible(hwnd,fSet) NtUserCallHwndParam((hwnd), (fSet), SFI_SETVISIBLE)
  1408. #define NtUserShowCursor(bShow) (int)NtUserCallOneParam((bShow), SFI_ZZZSHOWCURSOR)
  1409. #define NtUserUpdateClientRect(hwnd) NtUserCallHwndLock((hwnd), SFI_XXXUPDATECLIENTRECT)
  1410. #define CreateCaret NtUserCreateCaret
  1411. #define FillWindow NtUserFillWindow
  1412. #define GetControlBrush NtUserGetControlBrush
  1413. #define GetControlColor NtUserGetControlColor
  1414. #define GetDCEx NtUserGetDCEx
  1415. #define GetWindowPlacement NtUserGetWindowPlacement
  1416. #define RedrawWindow NtUserRedrawWindow
  1417. /*
  1418. * dmmnem.c
  1419. */
  1420. int FindMnemChar(
  1421. LPWSTR lpstr,
  1422. WCHAR ch,
  1423. BOOL fFirst,
  1424. BOOL fPrefix);
  1425. /*
  1426. * clres.c
  1427. */
  1428. BOOL WowGetModuleFileName(
  1429. HMODULE hModule,
  1430. LPWSTR pwsz,
  1431. DWORD cchMax);
  1432. HICON WowServerLoadCreateCursorIcon(
  1433. HANDLE hmod,
  1434. LPTSTR lpModName,
  1435. DWORD dwExpWinVer,
  1436. LPCTSTR lpName,
  1437. DWORD cb,
  1438. PVOID pcr,
  1439. LPTSTR lpType,
  1440. BOOL fClient);
  1441. HANDLE InternalCopyImage(
  1442. HANDLE hImage,
  1443. UINT IMAGE_flag,
  1444. int cxNew,
  1445. int cyNew,
  1446. UINT LR_flags);
  1447. HMENU CreateMenuFromResource(
  1448. LPBYTE);
  1449. /*
  1450. * acons.c
  1451. */
  1452. #define BFT_ICON 0x4349 // 'IC'
  1453. #define BFT_BITMAP 0x4D42 // 'BM'
  1454. #define BFT_CURSOR 0x5450 // 'PT'
  1455. typedef struct _FILEINFO {
  1456. LPBYTE pFileMap;
  1457. LPBYTE pFilePtr;
  1458. LPBYTE pFileEnd;
  1459. LPCWSTR pszName;
  1460. } FILEINFO, *PFILEINFO;
  1461. HANDLE LoadCursorIconFromFileMap(
  1462. IN PFILEINFO pfi,
  1463. IN OUT LPWSTR *prt,
  1464. IN DWORD cxDesired,
  1465. IN DWORD cyDesired,
  1466. IN DWORD LR_flags,
  1467. OUT LPBOOL pfAni);
  1468. DWORD GetIcoCurWidth(
  1469. DWORD cxOrg,
  1470. BOOL fIcon,
  1471. UINT LR_flags,
  1472. DWORD cxDesired);
  1473. DWORD GetIcoCurHeight(
  1474. DWORD cyOrg,
  1475. BOOL fIcon,
  1476. UINT LR_flags,
  1477. DWORD cyDesired);
  1478. DWORD GetIcoCurBpp(
  1479. UINT LR_flags);
  1480. HICON LoadIcoCur(
  1481. HINSTANCE hmod,
  1482. LPCWSTR lpName,
  1483. LPWSTR type,
  1484. DWORD cxDesired,
  1485. DWORD cyDesired,
  1486. UINT LR_flags);
  1487. HANDLE ObjectFromDIBResource(
  1488. HINSTANCE hmod,
  1489. LPCWSTR lpName,
  1490. LPWSTR type,
  1491. DWORD cxDesired,
  1492. DWORD cyDesired,
  1493. UINT LR_flags);
  1494. HANDLE RtlLoadObjectFromDIBFile(
  1495. LPCWSTR lpszName,
  1496. LPWSTR type,
  1497. DWORD cxDesired,
  1498. DWORD cyDesired,
  1499. UINT LR_flags);
  1500. HCURSOR LoadCursorOrIconFromFile(
  1501. LPCWSTR pszFilename,
  1502. BOOL fIcon);
  1503. HBITMAP ConvertDIBBitmap(
  1504. UPBITMAPINFOHEADER lpbih,
  1505. DWORD cxDesired,
  1506. DWORD cyDesired,
  1507. UINT flags,
  1508. LPBITMAPINFOHEADER *lplpbih,
  1509. LPSTR *lplpBits);
  1510. HICON ConvertDIBIcon(
  1511. LPBITMAPINFOHEADER lpbih,
  1512. HINSTANCE hmod,
  1513. LPCWSTR lpName,
  1514. BOOL fIcon,
  1515. DWORD cxNew,
  1516. DWORD cyNew,
  1517. UINT LR_flags);
  1518. int SmartStretchDIBits(
  1519. HDC hdc,
  1520. int xD,
  1521. int yD,
  1522. int dxD,
  1523. int dyD,
  1524. int xS,
  1525. int yS,
  1526. int dxS,
  1527. int dyS,
  1528. LPVOID lpBits,
  1529. LPBITMAPINFO lpbi,
  1530. UINT wUsage,
  1531. DWORD rop);
  1532. /*
  1533. * OFFSET for different DPI resources.
  1534. * This allows us to take a resource number and "map" to an actual resource
  1535. * based on what DPI the user selected
  1536. */
  1537. #define OFFSET_SCALE_DPI 000
  1538. #define OFFSET_96_DPI 100
  1539. #define OFFSET_120_DPI 200
  1540. #define OFFSET_160_DPI 300
  1541. /*
  1542. * defines the highest resource number so we can do math on the resource
  1543. * number.
  1544. */
  1545. #define MAX_RESOURCE_INDEX 32768
  1546. /*
  1547. * Parameter for xxxAlterHilite()
  1548. */
  1549. #define HILITEONLY 0x0001
  1550. #define SELONLY 0x0002
  1551. #define HILITEANDSEL (HILITEONLY + SELONLY)
  1552. #define HILITE 1
  1553. // LATER IanJa: these vary by country! For US they are VK_OEM_2 VK_OEM_5.
  1554. // Change lboxctl2.c MapVirtualKey to character - and fix the spelling?
  1555. #define VERKEY_SLASH 0xBF /* Virtual key for '/' character */
  1556. #define VERKEY_BACKSLASH 0xDC /* Virtual key for '\' character */
  1557. /*
  1558. * Procedures for combo boxes.
  1559. */
  1560. LONG xxxCBCommandHandler(PCBOX, DWORD, HWND);
  1561. LRESULT xxxCBMessageItemHandler(PCBOX, UINT, LPVOID);
  1562. int xxxCBDir(PCBOX, UINT, LPWSTR);
  1563. VOID xxxCBPaint(PCBOX, HDC);
  1564. VOID xxxCBCompleteEditWindow(PCBOX pcbox);
  1565. BOOL xxxCBHideListBoxWindow(PCBOX pcbox, BOOL fNotifyParent, BOOL fSelEndOK);
  1566. VOID xxxCBShowListBoxWindow(PCBOX pcbox, BOOL fTrack);
  1567. void xxxCBPosition(PCBOX pcbox);
  1568. /*
  1569. * combo.h
  1570. */
  1571. /* Initialization code */
  1572. long CBNcCreateHandler(PCBOX, PWND);
  1573. LRESULT xxxCBCreateHandler(PCBOX, PWND);
  1574. void xxxCBCalcControlRects(PCBOX pcbox, LPRECT lprcList);
  1575. /* Destruction code */
  1576. VOID xxxCBNcDestroyHandler(PWND, PCBOX);
  1577. /* Generic often used routines */
  1578. VOID xxxCBNotifyParent(PCBOX, SHORT);
  1579. VOID xxxCBUpdateListBoxWindow(PCBOX, BOOL);
  1580. /* Helpers' */
  1581. VOID xxxCBInternalUpdateEditWindow(PCBOX, HDC);
  1582. VOID xxxCBGetFocusHelper(PCBOX);
  1583. VOID xxxCBKillFocusHelper(PCBOX);
  1584. VOID xxxCBInvertStaticWindow(PCBOX,BOOL,HDC);
  1585. VOID xxxCBSetFontHandler(PCBOX, HANDLE, BOOL);
  1586. VOID xxxCBSizeHandler(PCBOX);
  1587. LONG xxxCBSetEditItemHeight(PCBOX pcbox, int editHeight);
  1588. /*
  1589. * String
  1590. */
  1591. INT xxxFindString(PLBIV, LPWSTR, INT, INT, BOOL);
  1592. VOID InitHStrings(PLBIV);
  1593. int xxxLBInsertItem(PLBIV, LPWSTR, int, UINT);
  1594. /*
  1595. * Selection
  1596. */
  1597. BOOL ISelFromPt(PLBIV, POINT, LPDWORD);
  1598. BOOL IsSelected(PLBIV, INT, UINT);
  1599. VOID LBSetCItemFullMax(PLBIV plb);
  1600. VOID xxxLBSelRange(PLBIV, INT, INT, BOOL);
  1601. INT xxxLBSetCurSel(PLBIV, INT);
  1602. INT LBoxGetSelItems(PLBIV, BOOL, INT, LPINT);
  1603. LONG xxxLBSetSel(PLBIV, BOOL, INT);
  1604. VOID xxxSetISelBase(PLBIV, INT);
  1605. VOID SetSelected(PLBIV, INT, BOOL, UINT);
  1606. /*
  1607. * Caret
  1608. */
  1609. void xxxLBSetCaret(PLBIV plb, BOOL fSetCaret);
  1610. VOID xxxCaretDestroy(PLBIV);
  1611. /*
  1612. * LBox
  1613. */
  1614. LONG xxxLBCreate(PLBIV, PWND, LPCREATESTRUCT);
  1615. VOID xxxDestroyLBox(PLBIV, PWND);
  1616. VOID xxxLBoxDeleteItem(PLBIV, INT);
  1617. VOID xxxLBoxDoDeleteItems(PLBIV);
  1618. VOID xxxLBoxDrawItem(PLBIV, INT, UINT, UINT, LPRECT);
  1619. /*
  1620. * Scroll
  1621. */
  1622. INT LBCalcVarITopScrollAmt(PLBIV, INT, INT);
  1623. VOID xxxLBoxCtlHScroll(PLBIV, INT, INT);
  1624. VOID xxxLBoxCtlHScrollMultiColumn(PLBIV, INT, INT);
  1625. VOID xxxLBoxCtlScroll(PLBIV, INT, INT);
  1626. VOID xxxLBShowHideScrollBars(PLBIV);
  1627. /*
  1628. * LBoxCtl
  1629. */
  1630. INT xxxLBoxCtlDelete(PLBIV, INT);
  1631. VOID xxxLBoxCtlCharInput(PLBIV, UINT, BOOL);
  1632. VOID xxxLBoxCtlKeyInput(PLBIV, UINT, UINT);
  1633. VOID xxxLBPaint(PLBIV, HDC, LPRECT);
  1634. BOOL xxxLBInvalidateRect(PLBIV plb, LPRECT lprc, BOOL fErase);
  1635. /*
  1636. * Miscellaneous
  1637. */
  1638. VOID xxxAlterHilite(PLBIV, INT, INT, BOOL, INT, BOOL);
  1639. INT CItemInWindow(PLBIV, BOOL);
  1640. VOID xxxCheckRedraw(PLBIV, BOOL, INT);
  1641. LPWSTR GetLpszItem(PLBIV, INT);
  1642. VOID xxxInsureVisible(PLBIV, INT, BOOL);
  1643. VOID xxxInvertLBItem(PLBIV, INT, BOOL);
  1644. VOID xxxLBBlockHilite(PLBIV, INT, BOOL);
  1645. int LBGetSetItemHeightHandler(PLBIV plb, UINT message, int item, UINT height);
  1646. VOID LBDropObjectHandler(PLBIV, PDROPSTRUCT);
  1647. LONG_PTR LBGetItemData(PLBIV, INT);
  1648. INT LBGetText(PLBIV, BOOL, BOOL, INT, LPWSTR);
  1649. VOID xxxLBSetFont(PLBIV, HANDLE, BOOL);
  1650. int LBSetItemData(PLBIV, INT, LONG_PTR);
  1651. BOOL LBSetTabStops(PLBIV, INT, LPINT);
  1652. VOID xxxLBSize(PLBIV, INT, INT);
  1653. INT LastFullVisible(PLBIV);
  1654. INT xxxLbDir(PLBIV, UINT, LPWSTR);
  1655. INT xxxLbInsertFile(PLBIV, LPWSTR);
  1656. VOID xxxNewITop(PLBIV, INT);
  1657. VOID xxxNewITopEx(PLBIV, INT, DWORD);
  1658. VOID xxxNotifyOwner(PLBIV, INT);
  1659. VOID xxxResetWorld(PLBIV, INT, INT, BOOL);
  1660. VOID xxxTrackMouse(PLBIV, UINT, POINT);
  1661. BOOL xxxDlgDirListHelper(PWND, LPWSTR, LPBYTE, int, int, UINT, BOOL);
  1662. BOOL DlgDirSelectHelper(LPWSTR pFileName, int cbFileName, HWND hwndListBox);
  1663. BOOL xxxLBResetContent(PLBIV plb);
  1664. VOID xxxLBSetRedraw(PLBIV plb, BOOL fRedraw);
  1665. int xxxSetLBScrollParms(PLBIV plb, int nCtl);
  1666. void xxxLBButtonUp(PLBIV plb, UINT uFlags);
  1667. /*
  1668. * Variable Height OwnerDraw Support Routines
  1669. */
  1670. INT CItemInWindowVarOwnerDraw(PLBIV, BOOL);
  1671. INT LBPage(PLBIV, INT, BOOL);
  1672. /*
  1673. * Multicolumn listbox
  1674. */
  1675. VOID LBCalcItemRowsAndColumns(PLBIV);
  1676. /*
  1677. * Both multicol and var height
  1678. */
  1679. BOOL LBGetItemRect(PLBIV, INT, LPRECT);
  1680. VOID LBSetVariableHeightItemHeight(PLBIV, INT, INT);
  1681. INT LBGetVariableHeightItemHeight(PLBIV, INT);
  1682. /*
  1683. * No-data (lazy evaluation) listbox
  1684. */
  1685. INT xxxLBSetCount(PLBIV, INT);
  1686. UINT LBCalcAllocNeeded(PLBIV, INT);
  1687. /*
  1688. * Storage pre-allocation support for LB_INITSTORAGE
  1689. */
  1690. LONG xxxLBInitStorage(PLBIV plb, BOOL fAnsi, INT cItems, INT cb);
  1691. /***************************************************************************\
  1692. *
  1693. * Dialog Boxes
  1694. *
  1695. \***************************************************************************/
  1696. HWND InternalCreateDialog(HANDLE hmod,
  1697. LPDLGTEMPLATE lpDlgTemplate, DWORD cb,
  1698. HWND hwndOwner , DLGPROC pfnWndProc, LPARAM dwInitParam,
  1699. UINT fFlags);
  1700. INT_PTR InternalDialogBox(HANDLE hmod,
  1701. LPDLGTEMPLATE lpDlgTemplate,
  1702. HWND hwndOwner , DLGPROC pfnWndProc, LPARAM dwInitParam,
  1703. UINT fFlags);
  1704. PWND _FindDlgItem(PWND pwndParent, DWORD id);
  1705. PWND _GetDlgItem(PWND, int);
  1706. long _GetDialogBaseUnits(VOID);
  1707. PWND GetParentDialog(PWND pwndDialog);
  1708. VOID xxxRemoveDefaultButton(PWND pwndDlg, PWND pwndStart);
  1709. VOID xxxCheckDefPushButton(PWND pwndDlg, HWND hwndOldFocus, HWND hwndNewFocus);
  1710. PWND xxxGotoNextMnem(PWND pwndDlg, PWND pwndStart, WCHAR ch);
  1711. VOID DlgSetFocus(HWND hwnd);
  1712. void RepositionRect(PMONITOR pMonitor, LPRECT lprc, DWORD dwStyle, DWORD dwExStyle);
  1713. BOOL ValidateDialogPwnd(PWND pwnd);
  1714. PMONITOR GetDialogMonitor(HWND hwndOwner, DWORD dwFlags);
  1715. HANDLE GetEditDS(VOID);
  1716. VOID ReleaseEditDS(HANDLE h);
  1717. VOID TellWOWThehDlg(HWND hDlg);
  1718. UINT GetACPCharSet();
  1719. /***************************************************************************\
  1720. *
  1721. * Menus
  1722. *
  1723. \***************************************************************************/
  1724. // cltxt.h
  1725. BOOL GetMenuItemInfoInternalW(HMENU hMenu, UINT uID, BOOL fByPosition, LPMENUITEMINFOW lpmii);
  1726. #define MENUAPI_INSERT 0
  1727. #define MENUAPI_GET 1
  1728. #define MENUAPI_SET 2
  1729. // clmenu.c
  1730. BOOL InternalInsertMenuItem(HMENU hMenu, UINT uID, BOOL fByPosition, LPCMENUITEMINFO lpmii);
  1731. BOOL ValidateMENUITEMINFO(LPMENUITEMINFOW lpmiiIn, LPMENUITEMINFOW lpmii, DWORD dwAPICode);
  1732. BOOL ValidateMENUINFO(LPCMENUINFO lpmi, DWORD dwAPICode);
  1733. // ntstubs.c
  1734. BOOL ThunkedMenuItemInfo(HMENU hMenu, UINT nPosition, BOOL fByPosition,
  1735. BOOL fInsert, LPMENUITEMINFOW lpmii, BOOL fAnsi);
  1736. // menuc.c
  1737. void SetMenuItemInfoStruct(HMENU hMenu, UINT wFlags, UINT_PTR wIDNew, LPWSTR pwszNew,
  1738. LPMENUITEMINFOW pmii);
  1739. /***************************************************************************\
  1740. *
  1741. * Message Boxes
  1742. *
  1743. \***************************************************************************/
  1744. /* Unicode Right-To-Left mark unicode code point. Look in msgbox.c for more info */
  1745. #define UNICODE_RLM 0x200f
  1746. /***************************************************************************\
  1747. *
  1748. * MDI Windows
  1749. *
  1750. \***************************************************************************/
  1751. /* maximum number of MDI children windows listed in "Window" menu */
  1752. #define MAXITEMS 10
  1753. /*
  1754. * MDI typedefs
  1755. */
  1756. typedef struct tagSHORTCREATE {
  1757. int cy;
  1758. int cx;
  1759. int y;
  1760. int x;
  1761. LONG style;
  1762. HMENU hMenu;
  1763. } SHORTCREATE, *PSHORTCREATE;
  1764. typedef struct tagMDIACTIVATEPOS {
  1765. int cx;
  1766. int cy;
  1767. int cxMin;
  1768. int cyMin;
  1769. } MDIACTIVATEPOS, *PMDIACTIVATEPOS;
  1770. BOOL CreateMDIChild(PSHORTCREATE pcs, LPMDICREATESTRUCT pmcs, DWORD dwExpWinVerAndFlags, HMENU *phSysMenu, PWND pwndParent);
  1771. BOOL MDICompleteChildCreation(HWND hwndChild, HMENU hSysMenu, BOOL fVisible, BOOL fDisabled);
  1772. /*
  1773. * MDI defines
  1774. */
  1775. #define WS_MDISTYLE (WS_CHILD | WS_CLIPSIBLINGS | WS_SYSMENU|WS_CAPTION|WS_THICKFRAME|WS_MAXIMIZEBOX|WS_MINIMIZEBOX)
  1776. #define WS_MDICOMMANDS (WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX)
  1777. #define WS_MDIALLOWED (WS_MINIMIZE | WS_MAXIMIZE | WS_CLIPCHILDREN | WS_DISABLED | WS_HSCROLL | WS_VSCROLL | 0x0000FFFFL)
  1778. #define HAS_SBVERT 0x0100
  1779. #define HAS_SBHORZ 0x0200
  1780. #define OTHERMAXING 0x0400
  1781. #define CALCSCROLL 0x0800
  1782. #define SCROLLSUPPRESS 0x0003
  1783. #define SCROLLCOUNT 0x00FF
  1784. #define CKIDS(pmdi) (pmdi->cKids)
  1785. #define MAXED(pmdi) (pmdi->hwndMaxedChild)
  1786. #define ACTIVE(pmdi) (pmdi->hwndActiveChild)
  1787. #define WINDOW(pmdi) (pmdi->hmenuWindow)
  1788. #define FIRST(pmdi) (pmdi->idFirstChild)
  1789. #define SCROLL(pmdi) (pmdi->wScroll)
  1790. #define ITILELEVEL(pmdi) (pmdi->iChildTileLevel)
  1791. #define HTITLE(pmdi) (pmdi->pTitle)
  1792. #define PROP_MDICLIENT MAKEINTRESOURCE(0x8CAC)
  1793. #define MDIACTIVATE_PROP_NAME L"MDIA"
  1794. PWND FindPwndChild(PWND pwndMDI, UINT wChildID);
  1795. int MakeMenuItem(LPWSTR lpOut, PWND pwnd);
  1796. VOID ModifyMenuItem(PWND pwnd);
  1797. BOOL MDIAddSysMenu(HMENU hmenuFrame, HWND hwndChild);
  1798. BOOL MDIRemoveSysMenu(HMENU hMenuFrame, HWND hwndChild);
  1799. VOID ShiftMenuIDs(PWND pwnd, PWND pwndVictim);
  1800. HMENU MDISetMenu(PWND,BOOL,HMENU,HMENU);
  1801. void MDIRedrawFrame(HWND hwndChild, BOOL fAdd);
  1802. /*
  1803. * Drag and Drop menus.
  1804. */
  1805. #define COM_NO_WINDOWS_H
  1806. #define RPC_NO_WINDOWS_H
  1807. #include <ole2.h>
  1808. /*
  1809. * Prototypes to cast function pointers
  1810. */
  1811. typedef HRESULT (* OLEINITIALIZEPROC)(LPVOID);
  1812. typedef HRESULT (* OLEUNINITIALIZEPROC)(VOID);
  1813. typedef HRESULT (* REGISTERDDPROC)(HWND, LPDROPTARGET);
  1814. typedef HRESULT (* REVOKEDDPROC)(HWND);
  1815. typedef HRESULT (* DODDPROC)(LPDATAOBJECT, LPDROPSOURCE, DWORD, LPDWORD);
  1816. /*
  1817. * Internal IDropTarget interface info
  1818. */
  1819. typedef struct tagMNIDROPTARGET
  1820. {
  1821. IDropTarget idt; /* Interal IDropTarget */
  1822. DWORD dwRefCount; /* Ref count */
  1823. IDataObject * pido; /* IDataObject received at DragEnter */
  1824. IDropTarget * pidt; /* Application IDropTarget, if any */
  1825. } MNIDROPTARGET, * PMNIDROPTARGET;
  1826. /*
  1827. * OLE procs info (used by LoadOLEOnce GetProcAddress calls)
  1828. */
  1829. typedef struct tagGETPROCINFO
  1830. {
  1831. FARPROC * ppfn;
  1832. LPCSTR lpsz;
  1833. } GETPROCINFO;
  1834. /*
  1835. * Special value used by __ClientLoadOLE.
  1836. */
  1837. #define OLEWONTLOAD (HINSTANCE)IntToPtr(0xFFFFFFFF)
  1838. /*
  1839. * Accelerator table resources list.
  1840. */
  1841. typedef struct tagACCELCACHE
  1842. {
  1843. struct tagACCELCACHE *pacNext;
  1844. UINT dwLockCount;
  1845. HACCEL hAccel;
  1846. PVOID pRes;
  1847. } ACCELCACHE, *PACCELCACHE;
  1848. /*
  1849. * x86 callback return function prototype
  1850. */
  1851. #if defined(_X86_) && !defined(BUILD_WOW6432)
  1852. NTSTATUS
  1853. FASTCALL
  1854. XyCallbackReturn(
  1855. IN PVOID Buffer,
  1856. IN ULONG Length,
  1857. IN NTSTATUS Status
  1858. );
  1859. #define UserCallbackReturn XyCallbackReturn
  1860. #else
  1861. #define UserCallbackReturn NtCallbackReturn
  1862. #endif
  1863. /*
  1864. * Reader mode support
  1865. */
  1866. typedef LONG (CALLBACK* READERMODEPROC)(LPARAM lParam, int nCode, int dx, int dy);
  1867. typedef struct tagREADERMODE { // rdrm
  1868. UINT cbSize;
  1869. DWORD dwFlags;
  1870. READERMODEPROC pfnReaderModeProc;
  1871. LPARAM lParam;
  1872. } READERMODE, *PREADERMODE, *LPREADERMODE;
  1873. #define RDRMODE_VERT 0x00000001
  1874. #define RDRMODE_HORZ 0x00000002
  1875. #define RDRMODE_DIAG 0x00000004
  1876. #define RDRCODE_START 1
  1877. #define RDRCODE_SCROLL 2
  1878. #define RDRCODE_END 3
  1879. typedef struct tagREADERINFO {
  1880. READERMODE;
  1881. int dx;
  1882. int dy;
  1883. UINT uCursor;
  1884. HBITMAP hbm;
  1885. UINT dxBmp;
  1886. UINT dyBmp;
  1887. } READERINFO, *PREADERINFO;
  1888. typedef struct tagREADERWND {
  1889. WND wnd;
  1890. PREADERINFO prdr;
  1891. } READERWND, * KPTR_MODIFIER PREADERWND;
  1892. BOOL EnterReaderModeHelper(HWND hwnd);
  1893. #include "ddemlcli.h"
  1894. #include "globals.h"
  1895. #include "cscall.h"
  1896. #include "ntuser.h"
  1897. /***************************************************************************\
  1898. *
  1899. * DBCS MESSAGING
  1900. *
  1901. \***************************************************************************/
  1902. /*
  1903. * Message keeper for ...
  1904. *
  1905. * Client to Client.
  1906. */
  1907. #define GetDispatchDbcsInfo() (&(GetClientInfo()->achDbcsCF[0]))
  1908. /*
  1909. * Client to Server.
  1910. */
  1911. #define GetForwardDbcsInfo() (&(GetClientInfo()->achDbcsCF[1]))
  1912. /*
  1913. * Server to Client.
  1914. */
  1915. #define GetCallBackDbcsInfo() (&(GetClientInfo()->msgDbcsCB))
  1916. /*
  1917. * Macros for DBCS Messaging for Recieve side.
  1918. */
  1919. #define GET_DBCS_MESSAGE_IF_EXIST(_apiName,_pmsg,_wMsgFilterMin,_wMsgFilterMax,bRemoveMsg) \
  1920. \
  1921. if (GetCallBackDbcsInfo()->wParam) { \
  1922. /* \
  1923. * Check message filter... only WM_CHAR message will be pushed \
  1924. * into CLIENTINFO. Then if WM_CHAR is filtered out, we should \
  1925. * get message from queue... \
  1926. */ \
  1927. if ((!(_wMsgFilterMin) && !(_wMsgFilterMax)) || \
  1928. ((_wMsgFilterMin) <= WM_CHAR && (_wMsgFilterMax) >= WM_CHAR)) { \
  1929. PKERNEL_MSG pmsgDbcs = GetCallBackDbcsInfo(); \
  1930. /* \
  1931. * Get pushed message. \
  1932. * \
  1933. * Backup current message. this backupped message will be used \
  1934. * when Apps peek (or get) message from thier WndProc. \
  1935. * (see GetMessageA(), PeekMessageA()...) \
  1936. * \
  1937. * pmsg->hwnd = pmsgDbcs->hwnd; \
  1938. * pmsg->message = pmsgDbcs->message; \
  1939. * pmsg->wParam = pmsgDbcs->wParam; \
  1940. * pmsg->lParam = pmsgDbcs->lParam; \
  1941. * pmsg->time = pmsgDbcs->time; \
  1942. * pmsg->pt = pmsgDbcs->pt; \
  1943. */ \
  1944. COPY_KERNELMSG_TO_MSG((_pmsg),pmsgDbcs); \
  1945. /* \
  1946. * if we don't want to clear the cached data, just leave it there. \
  1947. */ \
  1948. if (bRemoveMsg) { \
  1949. /* \
  1950. * Invalidate pushed message in CLIENTINFO. \
  1951. */ \
  1952. pmsgDbcs->wParam = 0; \
  1953. } \
  1954. /* \
  1955. * Set return value to TRUE. \
  1956. */ \
  1957. retval = TRUE; \
  1958. /* \
  1959. * Exit function.. \
  1960. */ \
  1961. goto Exit ## _apiName; \
  1962. } \
  1963. }
  1964. /*
  1965. * Macros for DBCS Messaging for Send side.
  1966. */
  1967. #define BUILD_DBCS_MESSAGE_TO_SERVER_FROM_CLIENTA(_msg,_wParam,_RetVal) \
  1968. \
  1969. if (IS_DBCS_ENABLED() && (((_msg) == WM_CHAR) || ((_msg) == EM_SETPASSWORDCHAR))) { \
  1970. /* \
  1971. * Chech wParam is DBCS character or not. \
  1972. */ \
  1973. if (IS_DBCS_MESSAGE((_wParam))) { \
  1974. if ((_wParam) & WMCR_IR_DBCSCHAR) { \
  1975. /* \
  1976. * This message sent with IR_DBCSCHAR, already aligned for conversion \
  1977. */ \
  1978. } else { \
  1979. /* \
  1980. * Make IR_DBCSCHAR compatible DBCS packed message \
  1981. */ \
  1982. (_wParam) = MAKEWPARAM(MAKE_IR_DBCSCHAR(LOWORD((_wParam))),0); \
  1983. } \
  1984. } else { \
  1985. PBYTE pchDbcsCF = GetForwardDbcsInfo(); \
  1986. /* \
  1987. * If we have cached Dbcs LeadingByte character, build A Dbcs character \
  1988. * with the TrailingByte in wParam... \
  1989. */ \
  1990. if (*pchDbcsCF) { \
  1991. WORD DbcsLeadChar = (WORD)(*pchDbcsCF); \
  1992. /* \
  1993. * HIBYTE(LOWORD(wParam)) = Dbcs LeadingByte. \
  1994. * LOBYTE(LOWORD(wParam)) = Dbcs TrailingByte. \
  1995. */ \
  1996. (_wParam) |= (DbcsLeadChar << 8); \
  1997. /* \
  1998. * Invalidate cached data.. \
  1999. */ \
  2000. *pchDbcsCF = 0; \
  2001. } else if (IsDBCSLeadByteEx(THREAD_CODEPAGE(),LOBYTE(LOWORD(_wParam)))) { \
  2002. /* \
  2003. * if this is Dbcs LeadByte character, we should wait Dbcs TrailingByte \
  2004. * to convert this to Unicode. then we cached it here... \
  2005. */ \
  2006. *pchDbcsCF = LOBYTE(LOWORD((_wParam))); \
  2007. /* \
  2008. * Right now, we have nothing to do for this, just return with TRUE. \
  2009. */ \
  2010. return((_RetVal)); \
  2011. } \
  2012. } \
  2013. }
  2014. #define BUILD_DBCS_MESSAGE_TO_CLIENTW_FROM_CLIENTA(_msg,_wParam,_RetVal) \
  2015. \
  2016. if (IS_DBCS_ENABLED() && (((_msg) == WM_CHAR) || ((_msg) == EM_SETPASSWORDCHAR))) { \
  2017. /* \
  2018. * Check wParam is DBCS character or not. \
  2019. */ \
  2020. if (IS_DBCS_MESSAGE((_wParam))) { \
  2021. if ((_wParam) & WMCR_IR_DBCSCHAR) { \
  2022. /* \
  2023. * This message sent with IR_DBCSCHAR, already aligned for conversion \
  2024. */ \
  2025. } else { \
  2026. /* \
  2027. * Make IR_DBCSCHAR compatible DBCS packed message \
  2028. */ \
  2029. (_wParam) = MAKEWPARAM(MAKE_IR_DBCSCHAR(LOWORD((_wParam))),0); \
  2030. } \
  2031. } else { \
  2032. PBYTE pchDbcsCF = GetDispatchDbcsInfo(); \
  2033. /* \
  2034. * If we have cached Dbcs LeadingByte character, build A Dbcs character \
  2035. * with the TrailingByte in wParam... \
  2036. */ \
  2037. if (*pchDbcsCF) { \
  2038. WORD DbcsLeadChar = (WORD)(*pchDbcsCF); \
  2039. /* \
  2040. * HIBYTE(LOWORD(wParam)) = Dbcs LeadingByte. \
  2041. * LOBYTE(LOWORD(wParam)) = Dbcs TrailingByte. \
  2042. */ \
  2043. (_wParam) |= (DbcsLeadChar << 8); \
  2044. /* \
  2045. * Invalidate cached data.. \
  2046. */ \
  2047. *pchDbcsCF = 0; \
  2048. } else if (IsDBCSLeadByteEx(THREAD_CODEPAGE(),LOBYTE(LOWORD(_wParam)))) { \
  2049. /* \
  2050. * if this is Dbcs LeadByte character, we should wait Dbcs TrailingByte \
  2051. * to convert this to Unicode. then we cached it here... \
  2052. */ \
  2053. *pchDbcsCF = LOBYTE(LOWORD((_wParam))); \
  2054. /* \
  2055. * Right now, we have nothing to do for this, just return with TRUE. \
  2056. */ \
  2057. return((_RetVal)); \
  2058. } \
  2059. } \
  2060. }
  2061. #define BUILD_DBCS_MESSAGE_TO_CLIENTA_FROM_SERVER(_pmsg,_dwAnsi,_bIrDbcsFormat,bSaveMsg) \
  2062. /* \
  2063. * _bIrDbcsFormat parameter is only effective WM_CHAR/EM_SETPASSWORDCHAR message \
  2064. * \
  2065. * (_bIrDbcsFormat == FALSE) dwAnsi has .... \
  2066. * \
  2067. * HIBYTE(LOWORD(_dwAnsi)) = DBCS TrailingByte character. \
  2068. * LOBYTE(LOWORD(_dwAnsi)) = DBCS LeadingByte character \
  2069. * or SBCS character. \
  2070. * \
  2071. * (_bIrDbcsFormat == TRUE) dwAnsi has .... \
  2072. * \
  2073. * HIBYTE(LOWORD(_dwAnsi)) = DBCS LeadingByte character. \
  2074. * LOBYTE(LOWORD(_dwAnsi)) = DBCS TrailingByte character \
  2075. * or SBCS character. \
  2076. */ \
  2077. if (IS_DBCS_ENABLED()) \
  2078. switch ((_pmsg)->message) { \
  2079. case WM_CHAR: \
  2080. case EM_SETPASSWORDCHAR: \
  2081. if (IS_DBCS_MESSAGE((_dwAnsi))) { \
  2082. /* \
  2083. * This is DBCS character.. \
  2084. */ \
  2085. if ((_pmsg)->wParam & WMCR_IR_DBCSCHAR) { \
  2086. /* \
  2087. * Build IR_DBCSCHAR format message. \
  2088. */ \
  2089. if ((_bIrDbcsFormat)) { \
  2090. (_pmsg)->wParam = (WPARAM)(LOWORD((_dwAnsi))); \
  2091. } else { \
  2092. (_pmsg)->wParam = MAKE_IR_DBCSCHAR(LOWORD((_dwAnsi))); \
  2093. } \
  2094. } else { \
  2095. PKERNEL_MSG pDbcsMsg = GetCallBackDbcsInfo(); \
  2096. if ((_bIrDbcsFormat)) { \
  2097. /* \
  2098. * if the format is IR_DBCSCHAR format, adjust it to regular \
  2099. * WPARAM format... \
  2100. */ \
  2101. (_dwAnsi) = MAKE_WPARAM_DBCSCHAR((_dwAnsi)); \
  2102. } \
  2103. if ((bSaveMsg)) { \
  2104. /* \
  2105. * Copy this message to CLIENTINFO for next GetMessage \
  2106. * or PeekMesssage() call. \
  2107. */ \
  2108. COPY_MSG_TO_KERNELMSG(pDbcsMsg,(_pmsg)); \
  2109. /* \
  2110. * Only Dbcs Trailingbyte is nessesary for pushed message. we'll \
  2111. * pass this message when GetMessage/PeekMessage is called at next. \
  2112. */ \
  2113. pDbcsMsg->wParam = (WPARAM)(((_dwAnsi) & 0x0000FF00) >> 8); \
  2114. } \
  2115. /* \
  2116. * Return DbcsLeading byte to Apps. \
  2117. */ \
  2118. (_pmsg)->wParam = (WPARAM)((_dwAnsi) & 0x000000FF); \
  2119. } \
  2120. } else { \
  2121. /* \
  2122. * This is single byte character... set it to wParam. \
  2123. */ \
  2124. (_pmsg)->wParam = (WPARAM)((_dwAnsi) & 0x000000FF); \
  2125. } \
  2126. break; \
  2127. case WM_IME_CHAR: \
  2128. case WM_IME_COMPOSITION: \
  2129. /* \
  2130. * if the message is not adjusted to IR_DBCSCHAR format yet, \
  2131. * Build WM_IME_xxx format message. \
  2132. */ \
  2133. if (!(_bIrDbcsFormat)) { \
  2134. (_pmsg)->wParam = MAKE_IR_DBCSCHAR(LOWORD((_dwAnsi))); \
  2135. } \
  2136. break; \
  2137. default: \
  2138. (_pmsg)->wParam = (WPARAM)(_dwAnsi); \
  2139. break; \
  2140. } /* switch */ \
  2141. else \
  2142. #define BUILD_DBCS_MESSAGE_TO_CLIENTW_FROM_SERVER(_msg,_wParam) \
  2143. \
  2144. if (((_msg) == WM_CHAR) || ((_msg) == EM_SETPASSWORDCHAR)) { \
  2145. /* \
  2146. * Only LOWORD of WPARAM is valid for WM_CHAR.... \
  2147. * (Mask off DBCS messaging information.) \
  2148. */ \
  2149. (_wParam) &= 0x0000FFFF; \
  2150. }
  2151. #define BUILD_DBCS_MESSAGE_TO_CLIENTA_FROM_CLIENTW(_hwnd,_msg,_wParam,_lParam,_time,_pt,_bDbcs) \
  2152. \
  2153. if (IS_DBCS_ENABLED() && (((_msg) == WM_CHAR) || ((_msg) == EM_SETPASSWORDCHAR))) { \
  2154. /* \
  2155. * Check this message is DBCS Message or not.. \
  2156. */ \
  2157. if (IS_DBCS_MESSAGE((_wParam))) { \
  2158. PKERNEL_MSG pmsgDbcsCB = GetCallBackDbcsInfo(); \
  2159. /* \
  2160. * Mark this is DBCS character. \
  2161. */ \
  2162. (_bDbcs) = TRUE; \
  2163. /* \
  2164. * Backup current message. this backupped message will be used \
  2165. * when Apps peek (or get) message from thier WndProc. \
  2166. * (see GetMessageA(), PeekMessageA()...) \
  2167. */ \
  2168. pmsgDbcsCB->hwnd = (_hwnd); \
  2169. pmsgDbcsCB->message = (_msg); \
  2170. pmsgDbcsCB->lParam = (_lParam); \
  2171. pmsgDbcsCB->time = (_time); \
  2172. pmsgDbcsCB->pt = (_pt); \
  2173. /* \
  2174. * DbcsLeadByte will be sent below soon, we just need DbcsTrailByte \
  2175. * for further usage.. \
  2176. */ \
  2177. pmsgDbcsCB->wParam = ((_wParam) & 0x000000FF); \
  2178. /* \
  2179. * Pass the LeadingByte of the DBCS character to an ANSI WndProc. \
  2180. */ \
  2181. (_wParam) = ((_wParam) & 0x0000FF00) >> 8; \
  2182. } else { \
  2183. /* \
  2184. * Validate only BYTE for WM_CHAR. \
  2185. */ \
  2186. (_wParam) &= 0x000000FF; \
  2187. } \
  2188. }
  2189. #define DISPATCH_DBCS_MESSAGE_IF_EXIST(_msg,_wParam,_bDbcs,_apiName) \
  2190. /* \
  2191. * Check we need to send trailing byte or not, if the wParam has Dbcs character \
  2192. */ \
  2193. if (IS_DBCS_ENABLED() && (_bDbcs) && (GetCallBackDbcsInfo()->wParam)) { \
  2194. PKERNEL_MSG pmsgDbcsCB = GetCallBackDbcsInfo(); \
  2195. /* \
  2196. * If an app didn't peek (or get) the trailing byte from within \
  2197. * WndProc, and then pass the DBCS TrailingByte to the ANSI WndProc here \
  2198. * pmsgDbcsCB->wParam has DBCS TrailingByte here.. see above.. \
  2199. */ \
  2200. (_wParam) = KERNEL_WPARAM_TO_WPARAM(pmsgDbcsCB->wParam); \
  2201. /* \
  2202. * Invalidate cached message. \
  2203. */ \
  2204. pmsgDbcsCB->wParam = 0; \
  2205. /* \
  2206. * Send it.... \
  2207. */ \
  2208. goto _apiName ## Again; \
  2209. }
  2210. #define CalcAnsiStringLengthW(_unicodestring,_unicodeLength,_ansiLength) \
  2211. /* \
  2212. * Get AnsiStringLength from UnicodeString,UnicodeLength \
  2213. */ \
  2214. { \
  2215. RtlUnicodeToMultiByteSize((ULONG *)(_ansiLength), \
  2216. (LPWSTR)(_unicodestring), \
  2217. (ULONG)((_unicodeLength)*sizeof(WCHAR))); \
  2218. }
  2219. #define CalcAnsiStringLengthA(_ansistring,_unicodeLength,_ansiLength) \
  2220. /* \
  2221. * Get AnsiStringLength from AnsiString,UnicodeLength \
  2222. */ \
  2223. { \
  2224. LPSTR _string = (_ansistring); \
  2225. LONG _length = (LONG)(_unicodeLength); \
  2226. (*(_ansiLength)) = 0; \
  2227. while(*_string && _length) { \
  2228. if (IsDBCSLeadByte(*_string)) { \
  2229. (*(_ansiLength)) += 2; _string++; \
  2230. } else { \
  2231. (*(_ansiLength))++; \
  2232. } \
  2233. _string++; _length--; \
  2234. } \
  2235. }
  2236. #define CalcUnicodeStringLengthA(_ansistring,_ansiLength,_unicodeLength) \
  2237. /* \
  2238. * Get UnicodeLength from AnsiString,AnsiLength \
  2239. */ \
  2240. { \
  2241. RtlMultiByteToUnicodeSize((ULONG *)(_unicodeLength), \
  2242. (LPSTR)(_ansistring), \
  2243. (ULONG)(_ansiLength)); \
  2244. (*(_unicodeLength)) /= sizeof(WCHAR); \
  2245. }
  2246. #define CalcUnicodeStringLengthW(_unicodestring,_ansiLength,_unicodeLength) \
  2247. /* \
  2248. * Get UnicodeLength from UnicodeString,AnsiLength \
  2249. */ \
  2250. { \
  2251. LPWSTR _string = (_unicodestring); \
  2252. LONG _length = (LONG)(_ansiLength); \
  2253. LONG _charlength; \
  2254. (*(_unicodeLength)) = 0; \
  2255. while(*_string && (_length > 0)) { \
  2256. CalcAnsiStringLengthW(_string,1,&_charlength); \
  2257. _length -= _charlength; \
  2258. if (_length >= 0) { \
  2259. (*(_unicodeLength))++; \
  2260. } \
  2261. _string++; \
  2262. } \
  2263. }
  2264. /*
  2265. * DBCS function defined in userrtl.lib (see ..\rtl\userrtl.h)
  2266. */
  2267. DWORD UserGetCodePage(HDC hdc);
  2268. BOOL UserIsFullWidth(DWORD dwCodePage,WCHAR wChar);
  2269. BOOL UserIsFELineBreak(DWORD dwCodePage,WCHAR wChar);
  2270. // FE_IME // fareast.c
  2271. typedef struct {
  2272. BOOL (WINAPI* ImmWINNLSEnableIME)(HWND, BOOL);
  2273. BOOL (WINAPI* ImmWINNLSGetEnableStatus)(HWND);
  2274. LRESULT (WINAPI* ImmSendIMEMessageExW)(HWND, LPARAM);
  2275. LRESULT (WINAPI* ImmSendIMEMessageExA)(HWND, LPARAM);
  2276. BOOL (WINAPI* ImmIMPGetIMEW)(HWND, LPIMEPROW);
  2277. BOOL (WINAPI* ImmIMPGetIMEA)(HWND, LPIMEPROA);
  2278. BOOL (WINAPI* ImmIMPQueryIMEW)(LPIMEPROW);
  2279. BOOL (WINAPI* ImmIMPQueryIMEA)(LPIMEPROA);
  2280. BOOL (WINAPI* ImmIMPSetIMEW)(HWND, LPIMEPROW);
  2281. BOOL (WINAPI* ImmIMPSetIMEA)(HWND, LPIMEPROA);
  2282. HIMC (WINAPI* ImmAssociateContext)(HWND, HIMC);
  2283. LRESULT (WINAPI* ImmEscapeA)(HKL, HIMC, UINT, LPVOID);
  2284. LRESULT (WINAPI* ImmEscapeW)(HKL, HIMC, UINT, LPVOID);
  2285. LONG (WINAPI* ImmGetCompositionStringA)(HIMC, DWORD, LPVOID, DWORD);
  2286. LONG (WINAPI* ImmGetCompositionStringW)(HIMC, DWORD, LPVOID, DWORD);
  2287. BOOL (WINAPI* ImmGetCompositionWindow)(HIMC, LPCOMPOSITIONFORM);
  2288. HIMC (WINAPI* ImmGetContext)(HWND);
  2289. HWND (WINAPI* ImmGetDefaultIMEWnd)(HWND);
  2290. BOOL (WINAPI* ImmIsIME)(HKL);
  2291. BOOL (WINAPI* ImmReleaseContext)(HWND, HIMC);
  2292. BOOL (*ImmRegisterClient)(PSHAREDINFO, HINSTANCE);
  2293. BOOL (WINAPI* ImmGetCompositionFontW)(HIMC, LPLOGFONTW);
  2294. BOOL (WINAPI* ImmGetCompositionFontA)(HIMC, LPLOGFONTA);
  2295. BOOL (WINAPI* ImmSetCompositionFontW)(HIMC, LPLOGFONTW);
  2296. BOOL (WINAPI* ImmSetCompositionFontA)(HIMC, LPLOGFONTA);
  2297. BOOL (WINAPI* ImmSetCompositionWindow)(HIMC, LPCOMPOSITIONFORM);
  2298. BOOL (WINAPI* ImmNotifyIME)(HIMC, DWORD, DWORD, DWORD);
  2299. PINPUTCONTEXT (WINAPI* ImmLockIMC)(HIMC);
  2300. BOOL (WINAPI* ImmUnlockIMC)(HIMC);
  2301. BOOL (WINAPI* ImmLoadIME)(HKL);
  2302. BOOL (WINAPI* ImmSetOpenStatus)(HIMC, BOOL);
  2303. BOOL (WINAPI* ImmFreeLayout)(DWORD);
  2304. BOOL (WINAPI* ImmActivateLayout)(HKL);
  2305. BOOL (WINAPI* ImmGetCandidateWindow)(HIMC, DWORD, LPCANDIDATEFORM);
  2306. BOOL (WINAPI* ImmSetCandidateWindow)(HIMC, LPCANDIDATEFORM);
  2307. BOOL (WINAPI* ImmConfigureIMEW)(HKL, HWND, DWORD, LPVOID);
  2308. BOOL (WINAPI* ImmGetConversionStatus)(HIMC, LPDWORD, LPDWORD);
  2309. BOOL (WINAPI* ImmSetConversionStatus)(HIMC, DWORD, DWORD);
  2310. BOOL (WINAPI* ImmSetStatusWindowPos)(HIMC, LPPOINT);
  2311. BOOL (WINAPI* ImmGetImeInfoEx)(PIMEINFOEX, IMEINFOEXCLASS, PVOID);
  2312. PIMEDPI (WINAPI* ImmLockImeDpi)(HKL);
  2313. VOID (WINAPI* ImmUnlockImeDpi)(PIMEDPI);
  2314. BOOL (WINAPI* ImmGetOpenStatus)(HIMC);
  2315. BOOL (*ImmSetActiveContext)(HWND, HIMC, BOOL);
  2316. BOOL (*ImmTranslateMessage)(HWND, UINT, WPARAM, LPARAM);
  2317. BOOL (*ImmLoadLayout)(HKL, PIMEINFOEX);
  2318. DWORD (WINAPI* ImmProcessKey)(HWND, HKL, UINT, LPARAM, DWORD);
  2319. LRESULT (*ImmPutImeMenuItemsIntoMappedFile)(HIMC);
  2320. DWORD (WINAPI* ImmGetProperty)(HKL hKL, DWORD dwIndex);
  2321. BOOL (WINAPI* ImmSetCompositionStringA)(
  2322. HIMC hImc, DWORD dwIndex, LPCVOID lpComp, DWORD dwCompLen, LPCVOID lpRead, DWORD dwReadLen);
  2323. BOOL (WINAPI* ImmSetCompositionStringW)(
  2324. HIMC hImc, DWORD dwIndex, LPCVOID lpComp, DWORD dwCompLen, LPCVOID lpRead, DWORD dwReadLen);
  2325. BOOL (WINAPI* ImmEnumInputContext)(
  2326. DWORD idThread, IMCENUMPROC lpfn, LPARAM lParam);
  2327. LRESULT (WINAPI* ImmSystemHandler)(HIMC, WPARAM, LPARAM);
  2328. #ifdef CUAS_ENABLE
  2329. // Cicero
  2330. HRESULT (WINAPI* CtfImmTIMActivate)(HKL hKL);
  2331. void (WINAPI* CtfImmRestoreToolbarWnd)(DWORD dwPrevSts);
  2332. DWORD (WINAPI* CtfImmHideToolbarWnd)(void);
  2333. LRESULT (WINAPI* CtfImmDispatchDefImeMessage)(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
  2334. #endif // CUAS_ENABLE
  2335. } ImmApiEntries;
  2336. extern ImmApiEntries gImmApiEntries;
  2337. extern HMODULE ghImm32;
  2338. VOID InitializeImmEntryTable(VOID);
  2339. VOID GetImmFileName(PWSTR);
  2340. VOID CliImmInitializeHotKeys(DWORD dwAction, HKL hkl);
  2341. #define fpImmAssociateContext gImmApiEntries.ImmAssociateContext
  2342. #define fpImmEscapeA gImmApiEntries.ImmEscapeA
  2343. #define fpImmEscapeW gImmApiEntries.ImmEscapeW
  2344. #define fpImmGetContext gImmApiEntries.ImmGetContext
  2345. #define fpImmGetCompositionStringA gImmApiEntries.ImmGetCompositionStringA
  2346. #define fpImmGetCompositionStringW gImmApiEntries.ImmGetCompositionStringW
  2347. #define fpImmGetCompositionWindow gImmApiEntries.ImmGetCompositionWindow
  2348. #define fpImmGetDefaultIMEWnd gImmApiEntries.ImmGetDefaultIMEWnd
  2349. #define fpImmIsIME gImmApiEntries.ImmIsIME
  2350. #define fpImmLockIMC gImmApiEntries.ImmLockIMC
  2351. #define fpImmReleaseContext gImmApiEntries.ImmReleaseContext
  2352. #define fpImmRegisterClient gImmApiEntries.ImmRegisterClient
  2353. #define fpImmGetCompositionFontW gImmApiEntries.ImmGetCompositionFontW
  2354. #define fpImmGetCompositionFontA gImmApiEntries.ImmGetCompositionFontA
  2355. #define fpImmSetCompositionFontW gImmApiEntries.ImmSetCompositionFontW
  2356. #define fpImmSetCompositionFontA gImmApiEntries.ImmSetCompositionFontA
  2357. #define fpImmSetCompositionFont gImmApiEntries.ImmSetCompositionFont
  2358. #define fpImmSetCompositionWindow gImmApiEntries.ImmSetCompositionWindow
  2359. #define fpImmNotifyIME gImmApiEntries.ImmNotifyIME
  2360. #define fpImmUnlockIMC gImmApiEntries.ImmUnlockIMC
  2361. #define fpImmLoadIME gImmApiEntries.ImmLoadIME
  2362. #define fpImmSetOpenStatus gImmApiEntries.ImmSetOpenStatus
  2363. #define fpImmFreeLayout gImmApiEntries.ImmFreeLayout
  2364. #define fpImmActivateLayout gImmApiEntries.ImmActivateLayout
  2365. #define fpImmGetCandidateWindow gImmApiEntries.ImmGetCandidateWindow
  2366. #define fpImmSetCandidateWindow gImmApiEntries.ImmSetCandidateWindow
  2367. #define fpImmConfigureIMEW gImmApiEntries.ImmConfigureIMEW
  2368. #define fpImmGetConversionStatus gImmApiEntries.ImmGetConversionStatus
  2369. #define fpImmSetConversionStatus gImmApiEntries.ImmSetConversionStatus
  2370. #define fpImmSetStatusWindowPos gImmApiEntries.ImmSetStatusWindowPos
  2371. #define fpImmGetImeInfoEx gImmApiEntries.ImmGetImeInfoEx
  2372. #define fpImmLockImeDpi gImmApiEntries.ImmLockImeDpi
  2373. #define fpImmUnlockImeDpi gImmApiEntries.ImmUnlockImeDpi
  2374. #define fpImmGetOpenStatus gImmApiEntries.ImmGetOpenStatus
  2375. #define fpImmSetActiveContext gImmApiEntries.ImmSetActiveContext
  2376. #define fpImmTranslateMessage gImmApiEntries.ImmTranslateMessage
  2377. #define fpImmLoadLayout gImmApiEntries.ImmLoadLayout
  2378. #define fpImmProcessKey gImmApiEntries.ImmProcessKey
  2379. #define fpImmPutImeMenuItemsIntoMappedFile gImmApiEntries.ImmPutImeMenuItemsIntoMappedFile
  2380. #define fpImmGetProperty gImmApiEntries.ImmGetProperty
  2381. #define fpImmSetCompositionStringA gImmApiEntries.ImmSetCompositionStringA
  2382. #define fpImmSetCompositionStringW gImmApiEntries.ImmSetCompositionStringW
  2383. #define fpImmEnumInputContext gImmApiEntries.ImmEnumInputContext
  2384. #define fpImmSystemHandler gImmApiEntries.ImmSystemHandler
  2385. BOOL SyncSoftKbdState(HIMC hImc, LPARAM lParam); // imectl.c
  2386. #ifdef CUAS_ENABLE
  2387. // Cicero
  2388. #define fpCtfImmTIMActivate gImmApiEntries.CtfImmTIMActivate
  2389. #define fpCtfImmRestoreToolbarWnd gImmApiEntries.CtfImmRestoreToolbarWnd
  2390. #define fpCtfImmHideToolbarWnd gImmApiEntries.CtfImmHideToolbarWnd
  2391. #define fpCtfImmDispatchDefImeMessage gImmApiEntries.CtfImmDispatchDefImeMessage
  2392. #endif
  2393. // end FE_IME
  2394. /*
  2395. * Rebasing functions for shared memory. Need to located after
  2396. * inclusion of globals.h.
  2397. */
  2398. __inline PVOID
  2399. REBASESHAREDPTRALWAYS(KERNEL_PVOID p)
  2400. {
  2401. return (PVOID)(((KERNEL_UINT_PTR)p) - gSharedInfo.ulSharedDelta);
  2402. }
  2403. __inline PVOID
  2404. REBASESHAREDPTR(KERNEL_PVOID p)
  2405. {
  2406. return (p) ? REBASESHAREDPTRALWAYS(p) : NULL;
  2407. }
  2408. /*
  2409. * Multimonitor macros used in RTL. There are similar definitions
  2410. * in kernel\userk.h
  2411. */
  2412. __inline PDISPLAYINFO
  2413. GetDispInfo(VOID)
  2414. {
  2415. return gSharedInfo.pDispInfo;
  2416. }
  2417. __inline PMONITOR
  2418. GetPrimaryMonitor(VOID)
  2419. {
  2420. return REBASESHAREDPTR(GetDispInfo()->pMonitorPrimary);
  2421. }
  2422. /*
  2423. * UserApiHook functions
  2424. */
  2425. __inline BOOL IsInsideUserApiHook(
  2426. VOID)
  2427. {
  2428. return (ghmodUserApiHook != NULL) && gfUserApiHook;
  2429. }
  2430. __inline BOOL _BeginIfHookedUserApiHook()
  2431. {
  2432. UserAssert(gcCallUserApiHook < MAXLONG);
  2433. InterlockedIncrement(&gcCallUserApiHook);
  2434. if (!IsInsideUserApiHook()) {
  2435. InterlockedDecrement(&gcCallUserApiHook);
  2436. return FALSE;
  2437. } else {
  2438. UserAssertMsg0(ghmodUserApiHook != NULL, "Should not reach 0 while outstanding call");
  2439. return TRUE;
  2440. }
  2441. }
  2442. VOID _EndUserApiHook(VOID);
  2443. #define BEGIN_USERAPIHOOK() \
  2444. { \
  2445. BOOL fInsideHook = IsInsideUserApiHook(); \
  2446. \
  2447. if (!gfServerProcess && !fInsideHook && TEST_SRVIF(SRVIF_HOOKED)) { \
  2448. if (!RtlIsThreadWithinLoaderCallout()) { \
  2449. NtUserCallNoParam(SFI_XXXLOADUSERAPIHOOK); \
  2450. } \
  2451. } \
  2452. \
  2453. fInsideHook = _BeginIfHookedUserApiHook(); \
  2454. try { \
  2455. #define END_USERAPIHOOK() \
  2456. } finally { \
  2457. if (fInsideHook) { \
  2458. _EndUserApiHook(); \
  2459. } \
  2460. } \
  2461. } \
  2462. #ifdef MESSAGE_PUMP_HOOK
  2463. __inline BOOL IsInsideMessagePumpHook()
  2464. {
  2465. PCLIENTTHREADINFO pcti = GetClientInfo()->pClientThreadInfo;
  2466. return gfMessagePumpHook && (pcti != NULL) && (pcti->cMessagePumpHooks > 0);
  2467. }
  2468. #define BEGIN_MESSAGEPUMPHOOK() \
  2469. { \
  2470. BOOL fInsideHook = IsInsideMessagePumpHook(); \
  2471. #define END_MESSAGEPUMPHOOK() \
  2472. } \
  2473. #endif
  2474. int RealSetScrollInfo(HWND hwnd, int fnBar, LPCSCROLLINFO lpsi, BOOL fRedraw);
  2475. BOOL RealGetScrollInfo(HWND hwnd, int code, LPSCROLLINFO lpsi);
  2476. BOOL RealEnableScrollBar(HWND hWnd, UINT wSBflags, UINT wArrows);
  2477. BOOL RealAdjustWindowRectEx(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle);
  2478. BOOL RealSetWindowRgn(HWND hwnd, HRGN hrgn, BOOL bRedraw);
  2479. int RealGetSystemMetrics(int index);
  2480. BOOL RealSystemParametersInfoA(UINT wFlag, UINT wParam, PVOID lParam, UINT flags);
  2481. BOOL RealSystemParametersInfoW(UINT wFlag, UINT wParam, PVOID lParam, UINT flags);
  2482. BOOL ForceResetUserApiHook(HMODULE hmod);
  2483. BOOL RealDrawFrameControl(HDC hdc, LPRECT lprc, UINT wType, UINT wState);
  2484. BOOL RealDrawCaption(HWND hwnd, HDC hdc, CONST RECT *lprc, UINT flags);
  2485. void RealMDIRedrawFrame(HWND hwndChild, BOOL fAdd);
  2486. /*
  2487. * Event logging stuff
  2488. */
  2489. BOOL GetCurrentProcessName(WCHAR *pszProcessName, int cch);
  2490. BOOL GetUserSid(PTOKEN_USER *ppTokenUser);
  2491. #ifdef _JANUS_
  2492. BOOL InitInstrument(LPDWORD lpEMIControl);
  2493. #endif
  2494. #define MAX_ATOM_LEN 256
  2495. #define FREE_LIBRARY_SAVE_ERROR(hModule) \
  2496. { \
  2497. DWORD SaveLastError = NtCurrentTeb()->LastErrorValue; \
  2498. FreeLibrary(hModule); \
  2499. NtCurrentTeb()->LastErrorValue = SaveLastError; \
  2500. }
  2501. BOOL VersionRegisterClass(LPWSTR lpzClassName, LPWSTR lpzDllName, PACTIVATION_CONTEXT lpActivationContext, HMODULE *phModule);
  2502. LPWSTR ClassNameToVersion (LPCWSTR lpClassName, LPWSTR pClassVerName, LPWSTR* lpDllName, PACTIVATION_CONTEXT* lppActivationContext, BOOL bIsANSI);
  2503. #define ARRAYSIZE(a) (sizeof(a) / sizeof(a[0]))
  2504. #define TEST_DUSER_WMH 0
  2505. #if TEST_DUSER_WMH
  2506. DECLARE_HANDLE(HDCONTEXT);
  2507. typedef struct tagINITGADGET
  2508. {
  2509. DWORD cbSize; // Size of structure
  2510. UINT nThreadMode; // Threading model
  2511. UINT nMsgMode; // DirectUser/Core messaging subsystem mode
  2512. HDCONTEXT hctxShare; // Existing context to share with
  2513. } INITGADGET;
  2514. typedef HDCONTEXT (WINAPI * InitGadgetsProc)(INITGADGET * pInit);
  2515. extern HDCONTEXT g_hctx; // DirectUser Context
  2516. #define IGTM_SEPARATE (2) // | MT with single thread per context
  2517. #define IGMM_STANDARD (3) // | Standard mode on Whistler
  2518. #endif
  2519. #ifdef LAME_BUTTON
  2520. #define LAMEBUTTON_PROP_NAME L"LAME"
  2521. #endif
  2522. #endif