Source code of Windows XP (NT5)
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.

245 lines
8.4 KiB

  1. /*++
  2. *
  3. * WOW v1.0
  4. *
  5. * Copyright (c) 1991, Microsoft Corporation
  6. *
  7. * WMSGLB.C
  8. * WOW32 16-bit message thunks
  9. *
  10. * History:
  11. * Created 11-Mar-1991 by Jeff Parsons (jeffpar)
  12. --*/
  13. #include "precomp.h"
  14. #pragma hdrstop
  15. MODNAME(wmsglb.c);
  16. #ifdef DEBUG
  17. MSGINFO amiLB[] = {
  18. {OLDLB_ADDSTRING, "LB_ADDSTRING"}, // 0x0401
  19. {OLDLB_INSERTSTRING, "LB_INSERTSTRING"}, // 0x0402
  20. {OLDLB_DELETESTRING, "LB_DELETESTRING"}, // 0x0403
  21. {OLDLB_RESETCONTENT, "LB_RESETCONTENT"}, // 0x0405
  22. {OLDLB_SETSEL, "LB_SETSEL"}, // 0x0406
  23. {OLDLB_SETCURSEL, "LB_SETCURSEL"}, // 0x0407
  24. {OLDLB_GETSEL, "LB_GETSEL"}, // 0x0408
  25. {OLDLB_GETCURSEL, "LB_GETCURSEL"}, // 0x0409
  26. {OLDLB_GETTEXT, "LB_GETTEXT"}, // 0x040A
  27. {OLDLB_GETTEXTLEN, "LB_GETTEXTLEN"}, // 0x040B
  28. {OLDLB_GETCOUNT, "LB_GETCOUNT"}, // 0x040C
  29. {OLDLB_SELECTSTRING, "LB_SELECTSTRING"}, // 0x040D
  30. {OLDLB_DIR, "LB_DIR"}, // 0x040E
  31. {OLDLB_GETTOPINDEX, "LB_GETTOPINDEX"}, // 0x040F
  32. {OLDLB_FINDSTRING, "LB_FINDSTRING"}, // 0x0410
  33. {OLDLB_GETSELCOUNT, "LB_GETSELCOUNT"}, // 0x0411
  34. {OLDLB_GETSELITEMS, "LB_GETSELITEMS"}, // 0x0412
  35. {OLDLB_SETTABSTOPS, "LB_SETTABSTOPS"}, // 0x0413
  36. {OLDLB_GETHORIZONTALEXTENT, "LB_GETHORIZONTALEXTENT"}, // 0x0414
  37. {OLDLB_SETHORIZONTALEXTENT, "LB_SETHORIZONTALEXTENT"}, // 0x0415
  38. {OLDLB_SETCOLUMNWIDTH, "LB_SETCOLUMNWIDTH"}, // 0x0416
  39. {OLDLB_ADDFILE, "LB_ADDFILE"}, // 0x0417
  40. {OLDLB_SETTOPINDEX, "LB_SETTOPINDEX"}, // 0x0418
  41. {OLDLB_GETITEMRECT, "LB_GETITEMRECT"}, // 0x0419
  42. {OLDLB_GETITEMDATA, "LB_GETITEMDATA"}, // 0x041A
  43. {OLDLB_SETITEMDATA, "LB_SETITEMDATA"}, // 0x041B
  44. {OLDLB_SELITEMRANGE, "LB_SELITEMRANGE"}, // 0x041C
  45. {OLDLB_SETANCHORINDEX, "LB_SETANCHORINDEX"}, // 0x041D
  46. {OLDLB_GETANCHORINDEX, "LB_GETANCHORINDEX"}, // 0x041E
  47. {OLDLB_SETCARETINDEX, "LB_SETCARETINDEX"}, // 0x041F
  48. {OLDLB_GETCARETINDEX, "LB_GETCARETINDEX"}, // 0x0420
  49. {OLDLB_SETITEMHEIGHT, "LB_SETITEMHEIGHT"}, // 0x0421
  50. {OLDLB_GETITEMHEIGHT, "LB_GETITEMHEIGHT"}, // 0x0422
  51. {OLDLB_FINDSTRINGEXACT, "LB_FINDSTRINGEXACT"}, // 0x0423
  52. {OLDLBCB_CARETON, "LBCB_CARETON"}, // 0x0424
  53. {OLDLBCB_CARETOFF, "LBCB_CARETOFF"}, // 0x0425
  54. };
  55. PSZ GetLBMsgName(WORD wMsg)
  56. {
  57. INT i;
  58. register PMSGINFO pmi;
  59. for (pmi=amiLB,i=NUMEL(amiLB); i>0; i--,pmi++)
  60. if ((WORD)pmi->uMsg == wMsg)
  61. return pmi->pszMsgName;
  62. return GetWMMsgName(wMsg);
  63. }
  64. #endif
  65. BOOL FASTCALL ThunkLBMsg16(LPMSGPARAMEX lpmpex)
  66. {
  67. register PWW pww;
  68. WORD wMsg = lpmpex->Parm16.WndProc.wMsg;
  69. LOGDEBUG(7,(" Thunking 16-bit list box message %s(%04x)\n", (LPSZ)GetLBMsgName(wMsg), wMsg));
  70. wMsg -= WM_USER + 1;
  71. //
  72. // For app defined (control) messages that are out of range
  73. // return TRUE.
  74. //
  75. // ChandanC Sept-15-1992
  76. //
  77. if (wMsg < (LBCB_CARETOFF - LB_ADDSTRING + 1)) {
  78. switch(lpmpex->uMsg = wMsg + LB_ADDSTRING) {
  79. case LB_SELECTSTRING:
  80. case LB_FINDSTRING:
  81. case LB_FINDSTRINGEXACT:
  82. case LB_INSERTSTRING:
  83. case LB_ADDSTRING:
  84. if (!(pww = lpmpex->pww))
  85. return FALSE;
  86. if (!(pww->style & (LBS_OWNERDRAWFIXED|LBS_OWNERDRAWVARIABLE)) ||
  87. (pww->style & (LBS_HASSTRINGS))) {
  88. GETPSZPTR(lpmpex->Parm16.WndProc.lParam, (LPSZ)lpmpex->lParam);
  89. }
  90. break;
  91. case LB_DIR:
  92. GETPSZPTR(lpmpex->Parm16.WndProc.lParam, (LPSZ)lpmpex->lParam);
  93. break;
  94. case LB_GETTEXT:
  95. if (NULL != (pww = lpmpex->pww)) {
  96. register PTHUNKTEXTDWORD pthkdword = (PTHUNKTEXTDWORD)lpmpex->MsgBuffer;
  97. // we set this as a flag to indicate that we retrieve a dword
  98. // instead of a string there. In case when hooks are installed
  99. // this code prevents RISC platforms from malfunctioning in
  100. // kernel (they have code like this:
  101. // try {
  102. // <assign to original ptr here>
  103. // }
  104. // except(1) {
  105. // <put error message in debug>
  106. // }
  107. // which causes this message not to return the proper value)
  108. // See walias.h for definition of THUNKTEXTDWORD structure as
  109. // well as MSGPARAMEX structure
  110. // this code is complemented in UnThunkLBMsg16
  111. //
  112. // Application: PeachTree Accounting v3.5
  113. pthkdword->fDWORD = (pww->style & (LBS_OWNERDRAWFIXED|LBS_OWNERDRAWVARIABLE)) &&
  114. !(pww->style & (LBS_HASSTRINGS));
  115. if (pthkdword->fDWORD) {
  116. lpmpex->lParam = (LPARAM)(LPVOID)&pthkdword->dwDataItem;
  117. break;
  118. }
  119. }
  120. else {
  121. register PTHUNKTEXTDWORD pthkdword = (PTHUNKTEXTDWORD)lpmpex->MsgBuffer;
  122. pthkdword->fDWORD = FALSE;
  123. }
  124. GETPSZPTR(lpmpex->Parm16.WndProc.lParam, (LPSZ)lpmpex->lParam);
  125. break;
  126. case LB_GETITEMRECT:
  127. lpmpex->lParam = (LONG)lpmpex->MsgBuffer;
  128. break;
  129. case LB_GETSELITEMS:
  130. (PVOID)lpmpex->lParam = STACKORHEAPALLOC(lpmpex->Parm16.WndProc.wParam * sizeof(INT),
  131. sizeof(lpmpex->MsgBuffer), lpmpex->MsgBuffer);
  132. break;
  133. case LB_SETSEL:
  134. // sign extend
  135. {
  136. LPARAM lParam = lpmpex->Parm16.WndProc.lParam;
  137. lpmpex->lParam = (LOWORD(lParam) == 0xffff) ?
  138. INT32(LOWORD(lParam)) : (LONG)lParam;
  139. }
  140. break;
  141. case LB_SETTABSTOPS:
  142. // apparently lParam is a pointer even if wParam == 1. Recorder passes
  143. // the data so. - nandurir
  144. {
  145. INT cItems = INT32(lpmpex->Parm16.WndProc.wParam);
  146. if (cItems > 0) {
  147. (PVOID)lpmpex->lParam = STACKORHEAPALLOC(cItems * sizeof(INT),
  148. sizeof(lpmpex->MsgBuffer), lpmpex->MsgBuffer);
  149. getintarray16((VPINT16)lpmpex->Parm16.WndProc.lParam, cItems, (LPINT)lpmpex->lParam);
  150. }
  151. }
  152. break;
  153. case LB_ADDSTRING + 3:
  154. if (!(CURRENTPTD()->dwWOWCompatFlagsEx & WOWCFEX_THUNKLBSELITEMRANGEEX)) {
  155. lpmpex->uMsg = 0;
  156. }
  157. break;
  158. }
  159. }
  160. return TRUE;
  161. }
  162. VOID FASTCALL UnThunkLBMsg16(LPMSGPARAMEX lpmpex)
  163. {
  164. switch(lpmpex->uMsg) {
  165. case LB_GETTEXT:
  166. {
  167. register PTHUNKTEXTDWORD pthkdword = (PTHUNKTEXTDWORD)lpmpex->MsgBuffer;
  168. if ((pthkdword->fDWORD) && (lpmpex->lReturn != LB_ERR)) {
  169. // this is a dword, not a string
  170. // assign the dword as unaligned
  171. UNALIGNED DWORD *lpdwDataItem;
  172. GETVDMPTR((lpmpex->Parm16.WndProc.lParam), sizeof(DWORD), lpdwDataItem);
  173. *lpdwDataItem = pthkdword->dwDataItem;
  174. FREEVDMPTR(lpdwDataItem);
  175. break;
  176. }
  177. }
  178. // fall through to the common code
  179. case LB_ADDSTRING: // BUGBUG 3-Jul-1991 JeffPar: for owner-draw list boxes, this can just be a 32-bit number
  180. case LB_DIR:
  181. case LB_FINDSTRING: // BUGBUG 3-Jul-1991 JeffPar: for owner-draw list boxes, this can just be a 32-bit number
  182. case LB_FINDSTRINGEXACT:
  183. case LB_INSERTSTRING:
  184. case LB_SELECTSTRING:
  185. FREEPSZPTR((LPSZ)lpmpex->lParam);
  186. break;
  187. case LB_GETITEMRECT:
  188. if ((lpmpex->lParam) && (lpmpex->lReturn != -1L)) {
  189. putrect16((VPRECT16)lpmpex->Parm16.WndProc.lParam, (LPRECT)lpmpex->lParam);
  190. }
  191. break;
  192. case LB_GETSELITEMS:
  193. PUTINTARRAY16V((VPINT16)lpmpex->Parm16.WndProc.lParam, (INT)(lpmpex->lReturn), (LPINT)lpmpex->lParam);
  194. STACKORHEAPFREE((LPINT)lpmpex->lParam, lpmpex->MsgBuffer);
  195. break;
  196. case LB_SETTABSTOPS:
  197. if (lpmpex->Parm16.WndProc.wParam > 0) {
  198. STACKORHEAPFREE((LPINT)lpmpex->lParam, lpmpex->MsgBuffer);
  199. }
  200. break;
  201. }
  202. }