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.

1118 lines
33 KiB

  1. /*++
  2. *
  3. * WOW v1.0
  4. *
  5. * Copyright (c) 1991, Microsoft Corporation
  6. *
  7. * WMSG32.C
  8. * WOW32 32-bit message thunks
  9. *
  10. * History:
  11. * Created 19-Feb-1992 by Chandan Chauhan (ChandanC)
  12. --*/
  13. #include "precomp.h"
  14. #pragma hdrstop
  15. MODNAME(wcntl32.c);
  16. // This function thunks the button control messages,
  17. //
  18. // BM_GETCHECK
  19. // BM_SETCHECK
  20. // BM_GETSTATE
  21. // BM_SETSTATE
  22. // BM_SETSTYLE
  23. //
  24. BOOL FASTCALL WM32BMControl(LPWM32MSGPARAMEX lpwm32mpex)
  25. {
  26. if (lpwm32mpex->fThunk) {
  27. lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - BM_GETCHECK));
  28. }
  29. return (TRUE);
  30. }
  31. BOOL FASTCALL WM32BMClick (LPWM32MSGPARAMEX lpwm32mpex)
  32. {
  33. if (lpwm32mpex->fThunk) {
  34. lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WIN31_BM_CLICK);
  35. }
  36. return (TRUE);
  37. }
  38. // This function thunks the following edit control messages,
  39. //
  40. // EM_GETSEL
  41. // EM_GETMODIFY
  42. // EM_SETMODIFY
  43. // EM_GETLINECOUNT
  44. // EM_GETLINEINDEX
  45. // EM_LINELENGTH
  46. // EM_LIMITTEX
  47. // EM_CANUNDO
  48. // EM_UNDO
  49. // EM_FMTLINES
  50. // EM_LINEFROMCHAR
  51. // EM_SETPASSWORDCHAR
  52. // EM_EMPTYUNDOBUFFER
  53. BOOL FASTCALL WM32EMControl(LPWM32MSGPARAMEX lpwm32mpex)
  54. {
  55. if (lpwm32mpex->fThunk) {
  56. lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - EM_GETSEL));
  57. }
  58. return (TRUE);
  59. }
  60. // This function thunks the button control messages,
  61. //
  62. // EM_SETSEL
  63. //
  64. BOOL FASTCALL WM32EMSetSel (LPWM32MSGPARAMEX lpwm32mpex)
  65. {
  66. if (lpwm32mpex->fThunk) {
  67. lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - EM_GETSEL));
  68. LOW(lpwm32mpex->Parm16.WndProc.lParam) = (WORD) lpwm32mpex->uParam;
  69. HIW(lpwm32mpex->Parm16.WndProc.lParam) = (WORD)
  70. ((lpwm32mpex->lParam != -1) ? lpwm32mpex->lParam : 32767);
  71. }
  72. return (TRUE);
  73. }
  74. // This function thunks the edit control messages,
  75. //
  76. // EM_GETRECT
  77. //
  78. BOOL FASTCALL WM32EMGetRect (LPWM32MSGPARAMEX lpwm32mpex)
  79. {
  80. if ( lpwm32mpex->fThunk ) {
  81. lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - EM_GETSEL));
  82. lpwm32mpex->Parm16.WndProc.lParam = malloc16(sizeof(RECT16));
  83. if (!(lpwm32mpex->Parm16.WndProc.lParam))
  84. return FALSE;
  85. } else {
  86. GETRECT16( lpwm32mpex->Parm16.WndProc.lParam, (LPRECT)lpwm32mpex->lParam );
  87. if (lpwm32mpex->Parm16.WndProc.lParam)
  88. free16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam);
  89. }
  90. return (TRUE);
  91. }
  92. // This function thunks the edit control messages,
  93. //
  94. // EM_SETRECT
  95. // EM_SETRECTNP
  96. //
  97. BOOL FASTCALL WM32EMSetRect (LPWM32MSGPARAMEX lpwm32mpex)
  98. {
  99. if ( lpwm32mpex->fThunk ) {
  100. lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - EM_GETSEL));
  101. lpwm32mpex->Parm16.WndProc.lParam = malloc16(sizeof(RECT16));
  102. if (!(lpwm32mpex->Parm16.WndProc.lParam))
  103. return FALSE;
  104. PUTRECT16( lpwm32mpex->Parm16.WndProc.lParam, (LPRECT)lpwm32mpex->lParam );
  105. } else {
  106. if (lpwm32mpex->Parm16.WndProc.lParam)
  107. free16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam);
  108. }
  109. return (TRUE);
  110. }
  111. // This function thunks the edit control messages,
  112. //
  113. // EM_LINESCROLL
  114. //
  115. BOOL FASTCALL WM32EMLineScroll (LPWM32MSGPARAMEX lpwm32mpex)
  116. {
  117. if (lpwm32mpex->fThunk) {
  118. lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - EM_GETSEL));
  119. LOW(lpwm32mpex->Parm16.WndProc.lParam) = (WORD) lpwm32mpex->lParam;
  120. HIW(lpwm32mpex->Parm16.WndProc.lParam) = (WORD) lpwm32mpex->uParam;
  121. }
  122. return (TRUE);
  123. }
  124. // This function thunks the edit control messages,
  125. //
  126. // EM_REPLACESEL
  127. //
  128. BOOL FASTCALL WM32EMReplaceSel (LPWM32MSGPARAMEX lpwm32mpex)
  129. {
  130. if ( lpwm32mpex->fThunk ) {
  131. lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - EM_GETSEL));
  132. if (lpwm32mpex->lParam) {
  133. INT cb;
  134. cb = strlen((LPSZ)lpwm32mpex->lParam)+1;
  135. lpwm32mpex->dwTmp[0] = (DWORD)cb; // save allocation size
  136. // winworks2.0a requires DS based string pointers for this message
  137. if (CURRENTPTD()->dwWOWCompatFlags & WOWCF_DSBASEDSTRINGPOINTERS) {
  138. // be sure allocation size matches stackfree16() size below
  139. lpwm32mpex->Parm16.WndProc.lParam = stackalloc16(cb);
  140. } else {
  141. lpwm32mpex->Parm16.WndProc.lParam = malloc16(cb);
  142. }
  143. if (!(lpwm32mpex->Parm16.WndProc.lParam))
  144. return FALSE;
  145. putstr16((VPSZ)lpwm32mpex->Parm16.WndProc.lParam, (LPSZ)lpwm32mpex->lParam, cb);
  146. }
  147. } else {
  148. if (lpwm32mpex->Parm16.WndProc.lParam) {
  149. if (CURRENTPTD()->dwWOWCompatFlags & WOWCF_DSBASEDSTRINGPOINTERS) {
  150. stackfree16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam,
  151. ((UINT)lpwm32mpex->dwTmp[0]));
  152. } else {
  153. free16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam);
  154. }
  155. }
  156. }
  157. return (TRUE);
  158. }
  159. BOOL FASTCALL WM32EMSetFont (LPWM32MSGPARAMEX lpwm32mpex)
  160. {
  161. if (lpwm32mpex->fThunk) {
  162. lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - EM_GETSEL));
  163. }
  164. LOGDEBUG(0,(" Window %08lX is receiving Control Message %s(%08x)\n", lpwm32mpex->hwnd, (LPSZ)GetWMMsgName(lpwm32mpex->uMsg), lpwm32mpex->uMsg));
  165. return (TRUE);
  166. }
  167. // This function thunks the edit control messages,
  168. //
  169. // EM_GETLINE
  170. //
  171. BOOL FASTCALL WM32EMGetLine (LPWM32MSGPARAMEX lpwm32mpex)
  172. {
  173. if ( lpwm32mpex->fThunk ) {
  174. lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - EM_GETSEL));
  175. if (lpwm32mpex->lParam) {
  176. INT cb;
  177. PBYTE lp;
  178. // the first WORD is what USER uses.
  179. cb = *(UNALIGNED WORD *)(lpwm32mpex->lParam);
  180. lpwm32mpex->Parm16.WndProc.lParam = malloc16(cb);
  181. if (!(lpwm32mpex->Parm16.WndProc.lParam))
  182. return FALSE;
  183. ALLOCVDMPTR(lpwm32mpex->Parm16.WndProc.lParam,2,lp);
  184. *((UNALIGNED WORD *)lp) = (WORD)cb;
  185. FLUSHVDMPTR(lpwm32mpex->Parm16.WndProc.lParam,2,lp); /* first 2 bytes modified */
  186. }
  187. } else {
  188. if (lpwm32mpex->Parm16.WndProc.lParam) {
  189. PBYTE lp;
  190. GETMISCPTR(lpwm32mpex->Parm16.WndProc.lParam,lp);
  191. RtlCopyMemory((PBYTE)lpwm32mpex->lParam,lp,lpwm32mpex->lReturn);
  192. FREEVDMPTR(lp);
  193. free16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam);
  194. }
  195. }
  196. LOGDEBUG(3,(" Window %08lX is receiving Control Message %s(%08x)\n", lpwm32mpex->hwnd, (LPSZ)GetWMMsgName(lpwm32mpex->uMsg), lpwm32mpex->uMsg));
  197. return (TRUE);
  198. }
  199. BOOL FASTCALL WM32EMSetWordBreakProc (LPWM32MSGPARAMEX lpwm32mpex)
  200. {
  201. if (lpwm32mpex->fThunk) {
  202. lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - EM_GETSEL));
  203. // take out the marker bits and fix the RPL bits
  204. UnMarkWOWProc (lpwm32mpex->lParam,lpwm32mpex->Parm16.WndProc.lParam);
  205. LOGDEBUG(3,(" Window %08lX is receiving Control Message %s(%08x)\n", lpwm32mpex->hwnd, (LPSZ)GetWMMsgName(lpwm32mpex->uMsg), lpwm32mpex->uMsg));
  206. }
  207. return (TRUE);
  208. }
  209. BOOL FASTCALL WM32EMGetWordBreakProc (LPWM32MSGPARAMEX lpwm32mpex)
  210. {
  211. if (lpwm32mpex->fThunk) {
  212. lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - EM_GETSEL));
  213. LOGDEBUG(3,(" Window %08lX is receiving Control Message %s(%08x)\n", lpwm32mpex->hwnd, (LPSZ)GetWMMsgName(lpwm32mpex->uMsg), lpwm32mpex->uMsg));
  214. }
  215. else {
  216. // Mark the address as WOW Proc and store the high bits in the RPL field
  217. MarkWOWProc (lpwm32mpex->lReturn,lpwm32mpex->lReturn);
  218. }
  219. return (TRUE);
  220. }
  221. // This function thunks the edit control messages,
  222. //
  223. // EM_SETTABSTOPS
  224. //
  225. BOOL FASTCALL WM32EMSetTabStops (LPWM32MSGPARAMEX lpwm32mpex)
  226. {
  227. if ( lpwm32mpex->fThunk ) {
  228. lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - EM_GETSEL));
  229. if (lpwm32mpex->uParam != 0) {
  230. lpwm32mpex->Parm16.WndProc.lParam = malloc16(lpwm32mpex->uParam * sizeof(WORD));
  231. if (!(lpwm32mpex->Parm16.WndProc.lParam))
  232. return FALSE;
  233. putintarray16((VPINT16)lpwm32mpex->Parm16.WndProc.lParam, (INT)lpwm32mpex->uParam, (LPINT)lpwm32mpex->lParam);
  234. }
  235. } else {
  236. if (lpwm32mpex->Parm16.WndProc.lParam)
  237. free16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam);
  238. }
  239. return (TRUE);
  240. }
  241. // This function thunks the following combo box control messages,
  242. //
  243. // CB_GETEDITSEL
  244. // CB_LIMITTEXT
  245. // CB_SETEDITSEL
  246. // CB_DELETESTRING
  247. // CB_GETCOUNT
  248. // CB_GETCURSEL
  249. // CB_GETLBTEXTLEN
  250. // CB_SETCURSEL
  251. // CB_SHOWDROPDOWN
  252. // CB_GETITEMDATA
  253. // CB_SETITEMDATA
  254. BOOL FASTCALL WM32CBControl (LPWM32MSGPARAMEX lpwm32mpex)
  255. {
  256. if (lpwm32mpex->fThunk) {
  257. lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - CB_GETEDITSEL));
  258. }
  259. return (TRUE);
  260. }
  261. // This function thunks the following combo box control messages,
  262. //
  263. // CB_ADDSTRING
  264. // CB_INSERTSTRING
  265. // CB_FINDSTRING
  266. // CB_SELECTSTRING
  267. BOOL FASTCALL WM32CBAddString (LPWM32MSGPARAMEX lpwm32mpex)
  268. {
  269. PWW pww;
  270. if ( lpwm32mpex->fThunk ) {
  271. if (!(pww = lpwm32mpex->pww)) {
  272. if (pww = FindPWW (lpwm32mpex->hwnd))
  273. lpwm32mpex->pww = pww;
  274. else
  275. return FALSE;
  276. }
  277. lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - CB_GETEDITSEL));
  278. //
  279. // Determine if this combobox has string pointers or handles passed
  280. // in with CB_ADDSTRING messages. Normal comboboxes have string
  281. // pointers passed. Owner-draw comboboxes that don't have the
  282. // CBS_HASSTRINGS style bit set have handles passed in. These handles
  283. // are simply passed back to the owner at paint time. If the
  284. // CBS_HASSTRINGS style bit is set, strings are used instead of
  285. // handles as the "cookie" which is passed back to the application
  286. // at paint time.
  287. //
  288. // We treat lpwm32mpex->dwParam as a BOOL indicating this combobox
  289. // takes handles instead of strings.
  290. //
  291. lpwm32mpex->dwParam =
  292. (pww->style & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) &&
  293. !(pww->style & CBS_HASSTRINGS);
  294. if ( !lpwm32mpex->dwParam ) { // if strings are used
  295. if (lpwm32mpex->lParam) {
  296. INT cb;
  297. cb = strlen((LPSZ)lpwm32mpex->lParam)+1;
  298. lpwm32mpex->Parm16.WndProc.lParam = malloc16(cb);
  299. if (!(lpwm32mpex->Parm16.WndProc.lParam))
  300. return FALSE;
  301. putstr16((VPSZ)lpwm32mpex->Parm16.WndProc.lParam, (LPSZ)lpwm32mpex->lParam, cb);
  302. }
  303. }
  304. } else {
  305. if ( !lpwm32mpex->dwParam ) { // if strings are used
  306. if (lpwm32mpex->Parm16.WndProc.lParam) {
  307. getstr16((VPSZ)lpwm32mpex->Parm16.WndProc.lParam, (LPSZ)lpwm32mpex->lParam, -1);
  308. free16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam);
  309. }
  310. }
  311. }
  312. LOGDEBUG(3,(" Window %08lX is receiving Control Message %s(%08x)\n", lpwm32mpex->hwnd, (LPSZ)GetWMMsgName(lpwm32mpex->uMsg), lpwm32mpex->uMsg));
  313. return(TRUE);
  314. }
  315. // This function thunks the following combo box control messages,
  316. //
  317. // CB_DIR
  318. //
  319. // Code in this routine references code in wparam.c in order to circumvent
  320. // copying memory to 16-bit memory space.
  321. // GetParam16 verifies that the parameter we get (lparam) had not originated
  322. // in 16-bit code. If it did come from 16-bit code, then we send an original
  323. // 16:16 pointer to the application.
  324. // This fixes PagePlus 3.0 application and (if implemented on a broader scale)
  325. // will positively affect performance of applications which send a lot of
  326. // standard messages and use subclassing a lot.
  327. // -- VadimB
  328. BOOL FASTCALL WM32CBDir (LPWM32MSGPARAMEX lpwm32mpex)
  329. {
  330. if (lpwm32mpex->fThunk) {
  331. lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - CB_GETEDITSEL));
  332. if (lpwm32mpex->lParam) {
  333. INT cb;
  334. if (W32CheckThunkParamFlag()) {
  335. LONG lParam = (LONG)GetParam16(lpwm32mpex->lParam);
  336. if (lParam) {
  337. lpwm32mpex->Parm16.WndProc.lParam = lParam;
  338. return (TRUE);
  339. }
  340. }
  341. cb = strlen((LPSZ)lpwm32mpex->lParam)+1;
  342. lpwm32mpex->Parm16.WndProc.lParam = malloc16(cb);
  343. if (!(lpwm32mpex->Parm16.WndProc.lParam))
  344. return FALSE;
  345. putstr16((VPSZ)lpwm32mpex->Parm16.WndProc.lParam, (LPSZ)lpwm32mpex->lParam, cb);
  346. }
  347. } else {
  348. if (W32CheckThunkParamFlag()) {
  349. if (DeleteParamMap(lpwm32mpex->Parm16.WndProc.lParam, PARAM_16, NULL)) {
  350. return TRUE;
  351. }
  352. }
  353. if (lpwm32mpex->Parm16.WndProc.lParam)
  354. free16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam);
  355. }
  356. return(TRUE);
  357. }
  358. // This function thunks the following combo box control messages,
  359. //
  360. // CB_GETLBTEXT
  361. BOOL FASTCALL WM32CBGetLBText (LPWM32MSGPARAMEX lpwm32mpex)
  362. {
  363. PWW pww;
  364. if ( lpwm32mpex->fThunk ) {
  365. INT cb;
  366. if (!(pww = lpwm32mpex->pww)) {
  367. if (pww = FindPWW (lpwm32mpex->hwnd))
  368. lpwm32mpex->pww = pww;
  369. else
  370. return FALSE;
  371. }
  372. lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - CB_GETEDITSEL));
  373. //
  374. // Determine if this combobox has string pointers or handles passed
  375. // in with CB_ADDSTRING messages. Normal comboboxes have string
  376. // pointers passed. Owner-draw comboboxes that don't have the
  377. // CBS_HASSTRINGS style bit set have handles passed in. These handles
  378. // are simply passed back to the owner at paint time. If the
  379. // CBS_HASSTRINGS style bit is set, strings are used instead of
  380. // handles as the "cookie" which is passed back to the application
  381. // at paint time.
  382. //
  383. // We treat lpwm32mpex->dwParam as a BOOL indicating this combobox
  384. // takes handles instead of strings.
  385. //
  386. lpwm32mpex->dwParam =
  387. (pww->style & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) &&
  388. !(pww->style & CBS_HASSTRINGS);
  389. //
  390. // Determine the size of the buffer to allocate on the 16-bit side
  391. // to receive the text.
  392. //
  393. if (lpwm32mpex->dwParam) { // if handles are used
  394. cb = 4;
  395. } else {
  396. cb = SendMessage(lpwm32mpex->hwnd, CB_GETLBTEXTLEN, lpwm32mpex->uParam, 0);
  397. if (cb == CB_ERR) {
  398. //
  399. // lpwm32mpex->dwTmp[0] is initialized to 0 so that nothing
  400. // gets copied to the buffer by getstr16() while unthunking
  401. // this message.
  402. //
  403. // bug # 24415, ChandanC
  404. //
  405. cb = SIZE_BOGUS;
  406. lpwm32mpex->dwTmp[0] = 0;
  407. }
  408. else {
  409. //
  410. // Add one for NULL character.
  411. //
  412. cb = cb + 1;
  413. (INT) lpwm32mpex->dwTmp[0] = (INT) -1;
  414. }
  415. }
  416. if (lpwm32mpex->lParam) {
  417. BYTE *lpT;
  418. // See comment on similar code below
  419. lpwm32mpex->Parm16.WndProc.lParam = malloc16(cb);
  420. if (!(lpwm32mpex->Parm16.WndProc.lParam))
  421. return FALSE;
  422. GETVDMPTR((lpwm32mpex->Parm16.WndProc.lParam), sizeof(BYTE), lpT);
  423. *lpT = 0;
  424. FREEVDMPTR(lpT);
  425. }
  426. }
  427. else {
  428. if (lpwm32mpex->lParam && lpwm32mpex->Parm16.WndProc.lParam) {
  429. if (lpwm32mpex->dwParam) { // if handles are used
  430. UNALIGNED DWORD *lpT;
  431. GETVDMPTR((lpwm32mpex->Parm16.WndProc.lParam), sizeof(DWORD), lpT);
  432. *(UNALIGNED DWORD *)lpwm32mpex->lParam = *lpT;
  433. FREEVDMPTR(lpT);
  434. }
  435. else {
  436. getstr16((VPSZ)lpwm32mpex->Parm16.WndProc.lParam, (LPSZ)lpwm32mpex->lParam,
  437. (INT) lpwm32mpex->dwTmp[0]);
  438. }
  439. free16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam);
  440. }
  441. }
  442. return(TRUE);
  443. }
  444. // This function thunks the following combo box control messages,
  445. //
  446. // CB_GETDROPPEDCONTROLRECT
  447. BOOL FASTCALL WM32CBGetDropDownControlRect (LPWM32MSGPARAMEX lpwm32mpex)
  448. {
  449. if ( lpwm32mpex->fThunk ) {
  450. lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - CB_GETEDITSEL));
  451. lpwm32mpex->Parm16.WndProc.lParam = malloc16(sizeof(RECT16));
  452. if (!(lpwm32mpex->Parm16.WndProc.lParam))
  453. return FALSE;
  454. } else {
  455. GETRECT16( lpwm32mpex->Parm16.WndProc.lParam, (LPRECT)lpwm32mpex->lParam );
  456. if (lpwm32mpex->Parm16.WndProc.lParam)
  457. free16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam);
  458. }
  459. return(TRUE);
  460. }
  461. // This function thunks the following combo box control messages,
  462. //
  463. // CBEC_SETCOMBOFOCUS (WM_USER+CB_MSGMAX+1)
  464. // CBEC_KILLCOMBOFOCUS (WM_USER+CB_MSGMAX+2)
  465. // These undocumented messages are used by Excel 5.0
  466. //
  467. BOOL FASTCALL WM32CBComboFocus (LPWM32MSGPARAMEX lpwm32mpex)
  468. {
  469. #if (CBEC_SETCOMBOFOCUS != 0x166)
  470. #error The USER Guys changed CBEC_SETCOMBOFOCUS again
  471. #endif
  472. #if (CBEC_KILLCOMBOFOCUS != 0x167)
  473. #error The USER Guys changed CBEC_KILLCOMBOFOCUS again
  474. #endif
  475. if (lpwm32mpex->fThunk) {
  476. lpwm32mpex->Parm16.WndProc.wMsg =
  477. (WORD)((lpwm32mpex->uMsg-CBEC_SETCOMBOFOCUS) + OLDCBEC_SETCOMBOFOCUS);
  478. }
  479. return (TRUE);
  480. }
  481. // This function thunks the list box control messages
  482. //
  483. // LB_RESETCONTENT
  484. // LB_SETCURSEL
  485. // LB_GETSEL
  486. // LB_GETCURSEL
  487. // LB_GETTEXTLEN
  488. // LB_GETCOUNT
  489. // LB_GETCARETINDEX
  490. // LB_GETTOPINDEX
  491. // LB_GETSELCOUNT
  492. // LB_GETHORIZONTALEXTENT
  493. // LB_SETHORIZONTALEXTENT
  494. // LB_SETCOLUMNWIDTH
  495. // LB_SETTOPINDEX
  496. // LB_SETCARETINDEX
  497. // LB_SETITEMDATA
  498. // LB_SELITEMRANGE
  499. // LB_SETITEMHEIGHT
  500. // LB_GETITEMHEIGHT
  501. // LB_DELETESTRING
  502. //
  503. BOOL FASTCALL WM32LBControl (LPWM32MSGPARAMEX lpwm32mpex)
  504. {
  505. if (lpwm32mpex->fThunk) {
  506. lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - LB_ADDSTRING + 1));
  507. }
  508. return (TRUE);
  509. }
  510. // This function thunks the list box control messages
  511. //
  512. // LB_GETTEXT
  513. BOOL FASTCALL WM32LBGetText (LPWM32MSGPARAMEX lpwm32mpex)
  514. {
  515. PWW pww;
  516. if ( lpwm32mpex->fThunk ) {
  517. INT cb;
  518. if (!(pww = lpwm32mpex->pww)) {
  519. if (pww = FindPWW (lpwm32mpex->hwnd))
  520. lpwm32mpex->pww = pww;
  521. else
  522. return FALSE;
  523. }
  524. lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - LB_ADDSTRING + 1));
  525. //
  526. // Determine if this listbox has string pointers or handles passed
  527. // in with LB_ADDSTRING messages. Owner-draw listboxes that don't
  528. // have the LBS_HASSTRINGS style bit set have handles passed in.
  529. // These handles are simply passed back to the owner at paint time.
  530. // If the LBS_HASSTRINGS style bit is set, strings are used instead of
  531. // handles as the "cookie" which is passed back to the application
  532. // at paint time.
  533. //
  534. // We treat lpwm32mpex->dwParam as a BOOL indicating this listbox
  535. // takes handles instead of strings.
  536. //
  537. lpwm32mpex->dwParam =
  538. (pww->style & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) &&
  539. !(pww->style & LBS_HASSTRINGS);
  540. if (lpwm32mpex->dwParam) { // if this listbox takes handles
  541. cb = 4;
  542. }
  543. else {
  544. cb = SendMessage(lpwm32mpex->hwnd, LB_GETTEXTLEN, lpwm32mpex->uParam, 0);
  545. // Check for LB_ERR (which is -1) on the above SendMessage().
  546. // When cb is equal to LB_ERR make the size as SIZE_BOGUS (256 bytes),
  547. // and allocate a buffer just in case if the app diddles the lParam.
  548. // We will free the buffer while unthunking the message (LB_GETTEXT).
  549. // This fix makes the app MCAD happy.
  550. // ChandanC 4-21-93.
  551. if (cb == LB_ERR) {
  552. cb = SIZE_BOGUS;
  553. }
  554. else {
  555. //
  556. // Add one for NULL character.
  557. //
  558. cb = cb + 1;
  559. }
  560. }
  561. if (lpwm32mpex->lParam) {
  562. BYTE *lpT;
  563. lpwm32mpex->Parm16.WndProc.lParam = malloc16(cb);
  564. if (!(lpwm32mpex->Parm16.WndProc.lParam))
  565. return FALSE;
  566. // The reason for this code to be here is that sometimes thunks
  567. // are executed on a buffer that has not been initialized, e.g.
  568. // if the hooks are installed by a wow app. That means we will
  569. // alloc 16-bit buffer while thunking (boils down to uninitialized
  570. // data buffer and will try to copy the buffer back while unthunking
  571. // overwriting the stack sometimes (as user allocates temp bufs from
  572. // the stack). This code initializes data so problem is avoided
  573. // App: Grammatik/Windows v6.0 -- VadimB
  574. GETVDMPTR((lpwm32mpex->Parm16.WndProc.lParam), sizeof(BYTE), lpT);
  575. *lpT = 0;
  576. FREEVDMPTR(lpT);
  577. }
  578. }
  579. else {
  580. if ((lpwm32mpex->lReturn != LB_ERR) && lpwm32mpex->lParam && lpwm32mpex->Parm16.WndProc.lParam) {
  581. if (lpwm32mpex->dwParam) { // if this listbox takes handles
  582. UNALIGNED DWORD *lpT;
  583. GETVDMPTR((lpwm32mpex->Parm16.WndProc.lParam), sizeof(DWORD), lpT);
  584. *(UNALIGNED DWORD *)lpwm32mpex->lParam = *lpT;
  585. FREEVDMPTR(lpT);
  586. }
  587. else {
  588. getstr16((VPSZ)lpwm32mpex->Parm16.WndProc.lParam, (LPSZ)lpwm32mpex->lParam, -1);
  589. }
  590. }
  591. if (lpwm32mpex->Parm16.WndProc.lParam) {
  592. free16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam);
  593. }
  594. }
  595. return(TRUE);
  596. }
  597. // This function thunks the list box control messages
  598. //
  599. // LB_GETTEXTLEN
  600. BOOL FASTCALL WM32LBGetTextLen (LPWM32MSGPARAMEX lpwm32mpex)
  601. {
  602. if (lpwm32mpex->fThunk) {
  603. lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - LB_ADDSTRING + 1));
  604. // USER32 and so do we send the LB_GETTEXTLEN message whenever an
  605. // LB_GETTEXT message is sent. This LB_GETTEXTLEN message is an
  606. // additional message that an app normally wouldn't see in WIN31.
  607. // lParam by definition is NULL.
  608. //
  609. // Super Project dies (at times) when it receives the LB_GETTEXTLEN
  610. // message. It doesn't expect to see this message and as a result does
  611. // strlen(lParam) and dies.
  612. // - nanduri
  613. if (CURRENTPTD()->dwWOWCompatFlags & WOWCF_LB_NONNULLLPARAM) {
  614. // be sure allocation size matches stackfree16() size below
  615. LPBYTE lpT = (LPBYTE)stackalloc16(0x2); // just an even number
  616. lpwm32mpex->Parm16.WndProc.lParam = (LONG)lpT;
  617. GETVDMPTR(lpT, 0x2, lpT);
  618. *lpT = '\0';
  619. }
  620. } else {
  621. if (CURRENTPTD()->dwWOWCompatFlags & WOWCF_LB_NONNULLLPARAM) {
  622. if(lpwm32mpex->Parm16.WndProc.lParam) {
  623. stackfree16((VPVOID)lpwm32mpex->Parm16.WndProc.lParam, 0x2);
  624. }
  625. }
  626. }
  627. return (TRUE);
  628. }
  629. // This function thunks the list box control messages
  630. //
  631. // LB_DIR
  632. BOOL FASTCALL WM32LBDir (LPWM32MSGPARAMEX lpwm32mpex)
  633. {
  634. INT cb;
  635. VPVOID vp;
  636. if (lpwm32mpex->fThunk) {
  637. lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - LB_ADDSTRING + 1));
  638. if (lpwm32mpex->lParam) {
  639. cb = strlen((LPSTR)lpwm32mpex->lParam)+1;
  640. if (!(vp = malloc16(cb))) {
  641. LOGDEBUG(0,(" WOW32.DLL : WM32LBDir() :: Could not allocate memory for string, ChandanC\n"));
  642. WOW32ASSERT(vp);
  643. return FALSE;
  644. }
  645. putstr16(vp, (LPSTR) lpwm32mpex->lParam, cb);
  646. lpwm32mpex->Parm16.WndProc.lParam = vp;
  647. }
  648. }
  649. else {
  650. if (lpwm32mpex->Parm16.WndProc.lParam) {
  651. free16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam);
  652. }
  653. }
  654. return(TRUE);
  655. }
  656. // This function thunks the list box control messages
  657. //
  658. // LB_GETSELITEMS
  659. BOOL FASTCALL WM32LBGetSelItems (LPWM32MSGPARAMEX lpwm32mpex)
  660. {
  661. if ( lpwm32mpex->fThunk ) {
  662. lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - LB_ADDSTRING + 1));
  663. if (lpwm32mpex->lParam) {
  664. INT cb;
  665. cb = lpwm32mpex->uParam * sizeof(WORD);
  666. lpwm32mpex->Parm16.WndProc.lParam = malloc16(cb);
  667. if (!(lpwm32mpex->Parm16.WndProc.lParam))
  668. return FALSE;
  669. }
  670. } else {
  671. getintarray16((VPRECT16)lpwm32mpex->Parm16.WndProc.lParam, (INT)lpwm32mpex->uParam, (LPINT)lpwm32mpex->lParam);
  672. if (lpwm32mpex->Parm16.WndProc.lParam)
  673. free16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam);
  674. }
  675. return(TRUE);
  676. }
  677. // This function thunks the list box control messages
  678. //
  679. // LB_SETTABSTOPS
  680. BOOL FASTCALL WM32LBSetTabStops (LPWM32MSGPARAMEX lpwm32mpex)
  681. {
  682. if ( lpwm32mpex->fThunk ) {
  683. lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - LB_ADDSTRING + 1));
  684. if (lpwm32mpex->uParam != 0) {
  685. lpwm32mpex->Parm16.WndProc.lParam = malloc16(lpwm32mpex->uParam * sizeof(WORD));
  686. if (!(lpwm32mpex->Parm16.WndProc.lParam))
  687. return FALSE;
  688. putintarray16((VPRECT16)lpwm32mpex->Parm16.WndProc.lParam, (INT)lpwm32mpex->uParam, (LPINT)lpwm32mpex->lParam);
  689. }
  690. } else {
  691. if (lpwm32mpex->Parm16.WndProc.lParam)
  692. free16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam);
  693. }
  694. return(TRUE);
  695. }
  696. // This function thunks the list box control messages
  697. //
  698. // LB_GETITEMRECT
  699. BOOL FASTCALL WM32LBGetItemRect (LPWM32MSGPARAMEX lpwm32mpex)
  700. {
  701. if ( lpwm32mpex->fThunk ) {
  702. lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - LB_ADDSTRING + 1));
  703. lpwm32mpex->Parm16.WndProc.lParam = malloc16(sizeof(RECT16));
  704. if (!(lpwm32mpex->Parm16.WndProc.lParam))
  705. return FALSE;
  706. } else {
  707. GETRECT16( lpwm32mpex->Parm16.WndProc.lParam, (LPRECT)lpwm32mpex->lParam );
  708. if (lpwm32mpex->Parm16.WndProc.lParam)
  709. free16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam);
  710. }
  711. LOGDEBUG(3,(" Window %08lX is receiving Control Message %s(%08x)\n", lpwm32mpex->hwnd, (LPSZ)GetWMMsgName(lpwm32mpex->uMsg), lpwm32mpex->uMsg));
  712. return(TRUE);
  713. }
  714. // This function thunks the list box control messages
  715. //
  716. // LB_ADDSTRING
  717. // LB_INSERTSTRING
  718. // LB_FINDSTRING
  719. // LB_SELECTSTRING
  720. BOOL FASTCALL WM32LBAddString (LPWM32MSGPARAMEX lpwm32mpex)
  721. {
  722. PWW pww;
  723. if ( lpwm32mpex->fThunk ) {
  724. if (!(pww = lpwm32mpex->pww)) {
  725. if (pww = FindPWW (lpwm32mpex->hwnd))
  726. lpwm32mpex->pww = pww;
  727. else
  728. return FALSE;
  729. }
  730. lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - LB_ADDSTRING + 1));
  731. //
  732. // Determine if this listbox has string pointers or handles passed
  733. // in with LB_ADDSTRING messages. Owner-draw listboxes that don't
  734. // have the LBS_HASSTRINGS style bit set have handles passed in.
  735. // These handles are simply passed back to the owner at paint time.
  736. // If the LBS_HASSTRINGS style bit is set, strings are used instead of
  737. // handles as the "cookie" which is passed back to the application
  738. // at paint time.
  739. //
  740. // We treat lpwm32mpex->dwParam as a BOOL indicating this listbox
  741. // takes handles instead of strings.
  742. //
  743. lpwm32mpex->dwParam =
  744. (pww->style & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) &&
  745. !(pww->style & LBS_HASSTRINGS);
  746. if ( !lpwm32mpex->dwParam ) { // if this listbox takes strings
  747. if (lpwm32mpex->lParam) {
  748. INT cb;
  749. cb = strlen((LPSZ)lpwm32mpex->lParam)+1;
  750. lpwm32mpex->Parm16.WndProc.lParam = malloc16(cb);
  751. if (!(lpwm32mpex->Parm16.WndProc.lParam))
  752. return FALSE;
  753. putstr16((VPSZ)lpwm32mpex->Parm16.WndProc.lParam, (LPSZ)lpwm32mpex->lParam, cb);
  754. }
  755. }
  756. } else {
  757. if ( !lpwm32mpex->dwParam ) { // if this listbox takes strings
  758. if (lpwm32mpex->Parm16.WndProc.lParam) {
  759. getstr16((VPSZ)lpwm32mpex->Parm16.WndProc.lParam, (LPSZ)lpwm32mpex->lParam, -1);
  760. free16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam);
  761. }
  762. }
  763. }
  764. return(TRUE);
  765. }
  766. // This function thunks the scrollbar control messages,
  767. //
  768. // SBM_SETPOS
  769. // SBM_GETPOS
  770. // SBM_ENABLE_ARROWS
  771. //
  772. BOOL FASTCALL WM32SBMControl (LPWM32MSGPARAMEX lpwm32mpex)
  773. {
  774. if (lpwm32mpex->fThunk) {
  775. lpwm32mpex->Parm16.WndProc.wMsg = WM_USER + (lpwm32mpex->uMsg - SBM_SETPOS);
  776. }
  777. return (TRUE);
  778. }
  779. // SBM_GETRANGE
  780. BOOL FASTCALL WM32SBMGetRange (LPWM32MSGPARAMEX lpwm32mpex)
  781. {
  782. //
  783. // Changed semantics for this message to support 32-bit
  784. // scroll bar ranges (vs. 16-bit).
  785. //
  786. // Win16:
  787. // posMin = LOWORD(SendMessage(hwnd, SBM_GETRANGE, 0, 0));
  788. // posMax = HIWORD(SendMessage(hwnd, SBM_GETRANGE, 0, 0));
  789. //
  790. // Win32:
  791. // SendMessage(hwnd, SBM_GETRANGE,
  792. // (WPARAM) &posMin, (LPARAM) &posMax);
  793. //
  794. if (lpwm32mpex->fThunk) {
  795. lpwm32mpex->Parm16.WndProc.wMsg = OLDSBM_GETRANGE;
  796. } else {
  797. *(DWORD *)lpwm32mpex->uParam = INT32(LOWORD(lpwm32mpex->lReturn));
  798. *(DWORD *)lpwm32mpex->lParam = INT32(HIWORD(lpwm32mpex->lReturn));
  799. lpwm32mpex->lReturn = 0;
  800. }
  801. return (TRUE);
  802. }
  803. // SBM_SETRANGE
  804. // SBM_SETRANGEREDRAW (new for Win32)
  805. BOOL FASTCALL WM32SBMSetRange (LPWM32MSGPARAMEX lpwm32mpex)
  806. {
  807. //
  808. // Changed semantics to support 32-bit scroll bar range:
  809. //
  810. // Win16:
  811. // SendMessage(hwnd, SBM_SETRANGE, fRedraw, MAKELONG(posMin, posMax);
  812. //
  813. // Win32:
  814. // SendMessage(hwnd, fRedraw ? SBM_SETRANGE : SBM_SETRANGEREDRAW,
  815. // posMin, posMax);
  816. //
  817. if (lpwm32mpex->fThunk) {
  818. lpwm32mpex->Parm16.WndProc.wMsg = OLDSBM_SETRANGE;
  819. lpwm32mpex->Parm16.WndProc.wParam = (SBM_SETRANGEREDRAW == lpwm32mpex->uMsg);
  820. lpwm32mpex->Parm16.WndProc.lParam = MAKELONG( (WORD)lpwm32mpex->uParam, (WORD)lpwm32mpex->lParam);
  821. }
  822. return (TRUE);
  823. }
  824. // LB_SETSEL
  825. BOOL FASTCALL WM32LBSetSel (LPWM32MSGPARAMEX lpwm32mpex)
  826. {
  827. if (lpwm32mpex->fThunk) {
  828. lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - LB_ADDSTRING + 1));
  829. lpwm32mpex->Parm16.WndProc.wParam = (WORD) lpwm32mpex->uParam;
  830. lpwm32mpex->Parm16.WndProc.lParam = (WORD)lpwm32mpex->lParam; // loword = index, hiword = 0
  831. }
  832. return (TRUE);
  833. }
  834. // This function thunks the static control messages,
  835. //
  836. // STM_SETICON
  837. // STM_GETICON
  838. //
  839. BOOL FASTCALL WM32STMControl (LPWM32MSGPARAMEX lpwm32mpex)
  840. {
  841. if (lpwm32mpex->fThunk) {
  842. switch (lpwm32mpex->uMsg) {
  843. case STM_SETICON:
  844. lpwm32mpex->Parm16.WndProc.wParam = (WORD)GETHICON16(lpwm32mpex->uParam);
  845. break;
  846. case STM_GETICON:
  847. break;
  848. }
  849. lpwm32mpex->Parm16.WndProc.wMsg = WM_USER + (lpwm32mpex->uMsg - STM_SETICON);
  850. }
  851. else {
  852. lpwm32mpex->lReturn = (LONG)HICON32(lpwm32mpex->lReturn);
  853. }
  854. return (TRUE);
  855. }
  856. // This function thunks the messages,
  857. //
  858. // MN_FINDMENUWINDOWFROMPOINT
  859. //
  860. // NT - wparam = (PUINT)pitem lParam = MAKELONG(pt.x, pt.y)
  861. // returns flags or hwnd *pitem = index or -1
  862. //
  863. // win31 wParam = 0 lParam = same
  864. // returns 0 or MAKELONG(-1, item) or MAKELONG(-2, item) or MAKELONG(hwnd, item)
  865. BOOL FASTCALL WM32MNFindMenuWindow (LPWM32MSGPARAMEX lpwm32mpex)
  866. {
  867. if (lpwm32mpex->fThunk) {
  868. lpwm32mpex->Parm16.WndProc.wMsg = WIN30_MN_FINDMENUWINDOWFROMPOINT;
  869. lpwm32mpex->Parm16.WndProc.wParam = 0;
  870. } else {
  871. USHORT n = LOWORD(lpwm32mpex->lReturn);
  872. *(PLONG)lpwm32mpex->uParam = (SHORT)HIWORD(lpwm32mpex->lReturn);
  873. lpwm32mpex->lReturn = (LONG)HWND32(n); // this sign-extends -1, -2 and leaves 0 as 0
  874. }
  875. return TRUE;
  876. }