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.

295 lines
13 KiB

  1. /*++ BUILD Version: 0001
  2. *
  3. * WOW v1.0
  4. *
  5. * Copyright (c) 1991, Microsoft Corporation
  6. *
  7. * WSTRUC.H
  8. * WOW32 16-bit structure conversion support
  9. *
  10. * History:
  11. * Created 27-Jan-1991 by Jeff Parsons (jeffpar)
  12. * Added GDI macro definitions 6/13/91, ChandanC
  13. * Added MDI structures 1/20/91, BobDay
  14. --*/
  15. #ifndef _DEF_WSTRUC_ // if this hasn't already been included
  16. #define _DEF_WSTRUC_
  17. /* Structure conversion macros
  18. */
  19. #define PUTINT16(vp,i) WOW32ASSERT(!(LOW(vp)&1));\
  20. *(PSHORT16)GetPModeVDMPointer(vp, sizeof(SHORT)) = (SHORT)i;
  21. #define PUTBOOL16(vp,b) WOW32ASSERT(!(LOW(vp)&1));\
  22. if (FETCHDWORD(vp))\
  23. *(PWORD16)GetPModeVDMPointer(vp, sizeof(WORD)) = (WORD)b;
  24. #define STACKORHEAPALLOC(cBytesNeeded, cBytesAvail, lpStackBuffer) \
  25. ((INT)(cBytesNeeded) > (INT)(cBytesAvail)) ? (PVOID)malloc_w(cBytesNeeded) : \
  26. (PVOID)(lpStackBuffer)
  27. #define STACKORHEAPFREE(lpToFree, lpStackBuffer) \
  28. if ((lpToFree) && (PVOID)(lpToFree) != (PVOID)(lpStackBuffer)) free_w(lpToFree)
  29. #define PUTINTARRAY16(vp,c,p) putintarray16(FETCHDWORD(vp), c, p)
  30. #define PUTINTARRAY16V(vp,c,p) putintarray16(vp, c, p)
  31. // GETDWORDARRAY16 is not analogous to any of the above.
  32. #define GETDWORDARRAY16(vp,c,p) {GETVDMPTR(vp, c*sizeof(DWORD), p);}
  33. #define FREEDWORDARRAY16(p) {if (p) FREEVDMPTR(p);}
  34. #define GETRECT16(vp,p) getrect16(FETCHDWORD(vp), p)
  35. #define PUTRECT16(vp,p) putrect16(FETCHDWORD(vp), p)
  36. // COPYPOINT16 is used by ClientToScreen because the point is passed
  37. // directly as an argument, instead of a pointer to the point.
  38. #define COPYPOINT16(Pt16,Pt) {Pt.x = Pt16.x; Pt.y = Pt16.y;}
  39. #define GETPOINT16(vp,p) getpoint16(FETCHDWORD(vp), 1, p)
  40. #define PUTPOINT16(vp,p) putpoint16(FETCHDWORD(vp), 1, p)
  41. //
  42. // Get/Put point array macros.
  43. //
  44. // These routines will use a static buffer if the number of points to
  45. // be thunked is small enough. This will break badly if a thunk uses
  46. // GETPOINTARRAY16 and then calls a function which calls back, since
  47. // during the callback we could call another function which uses the
  48. // same static buffer.
  49. //
  50. // As of 7-Jan-92 the only callers are in GDI, which doesn't call back,
  51. // so we're OK.
  52. //
  53. // GETPOINTARRAY16 sometimes allocates memory, so you must call
  54. // FREEPOINTARRAY16 once for every GETPOINTARRAY16.
  55. //
  56. #define PUTPOINTARRAY16(vp,c,p) putpoint16(FETCHDWORD(vp), c, p)
  57. #define FREEMSG16(vp,lp)
  58. #define GETWNDCLASS16(vp,lp) {\
  59. WORD w;\
  60. PWNDCLASS16 pwc16;\
  61. GETVDMPTR(vp, sizeof(WNDCLASS16), pwc16);\
  62. (lp)->style = FETCHWORD(pwc16->style);\
  63. (lp)->lpfnWndProc = (WNDPROC)FETCHDWORD(pwc16->vpfnWndProc);\
  64. (lp)->cbClsExtra = FETCHWORD(pwc16->cbClsExtra);\
  65. (lp)->cbWndExtra = FETCHWORD(pwc16->cbWndExtra);\
  66. w = FETCHWORD(pwc16->hInstance);\
  67. if((w == gUser16hInstance) || (w == BOGUSGDT))\
  68. (lp)->hInstance = ghInstanceUser32;\
  69. else\
  70. (lp)->hInstance = HMODINST32(FETCHWORD(pwc16->hInstance));\
  71. (lp)->hIcon = HICON32_REGCLASS(FETCHWORD(pwc16->hIcon));\
  72. (lp)->hCursor = HCURSOR32(FETCHWORD(pwc16->hCursor));\
  73. w = FETCHWORD(pwc16->hbrBackground);\
  74. if (w > COLOR_ENDCOLORS)\
  75. (lp)->hbrBackground = HBRUSH32(w);\
  76. else\
  77. (lp)->hbrBackground = (HBRUSH)w;\
  78. (lp)->lpszMenuName = (LPSTR)FETCHDWORD(pwc16->vpszMenuName);\
  79. (lp)->lpszClassName = (LPSTR)FETCHDWORD(pwc16->vpszClassName);\
  80. FREEVDMPTR(pwc16);\
  81. }
  82. #define GETBITMAP16(vp, lp) {\
  83. PBITMAP16 pbm16;\
  84. GETVDMPTR(vp, sizeof(BITMAP16), pbm16);\
  85. (lp)->bmType = FETCHSHORT(pbm16->bmType);\
  86. (lp)->bmWidth = FETCHSHORT(pbm16->bmWidth);\
  87. (lp)->bmHeight = FETCHSHORT(pbm16->bmHeight);\
  88. (lp)->bmWidthBytes = FETCHSHORT(pbm16->bmWidthBytes);\
  89. (lp)->bmPlanes = pbm16->bmPlanes;\
  90. (lp)->bmBitsPixel = pbm16->bmBitsPixel;\
  91. GETMISCPTR(pbm16->bmBits, (lp)->bmBits);\
  92. FREEVDMPTR(pbm16);\
  93. }
  94. #define PUTBITMAP16(vp,cb,lp) {\
  95. PBITMAP16 pbm16;\
  96. GETVDMPTR(vp, ((int)cb), pbm16);\
  97. if (cb >= (FIELD_OFFSET(BITMAP16, bmType) + sizeof(pbm16->bmType)))\
  98. STORESHORT(pbm16->bmType, (lp)->bmType);\
  99. if (cb >= (FIELD_OFFSET(BITMAP16, bmWidth) + sizeof(pbm16->bmWidth)))\
  100. STORESHORT(pbm16->bmWidth, (lp)->bmWidth);\
  101. if (cb >= (FIELD_OFFSET(BITMAP16, bmHeight) + sizeof(pbm16->bmHeight)))\
  102. STORESHORT(pbm16->bmHeight, (lp)->bmHeight);\
  103. if (cb >= (FIELD_OFFSET(BITMAP16, bmWidthBytes) + sizeof(pbm16->bmWidthBytes)))\
  104. STORESHORT(pbm16->bmWidthBytes, \
  105. ((int)((((lp)->bmWidth * (lp)->bmBitsPixel + 15) / 16) * 2)));\
  106. if (cb >= (FIELD_OFFSET(BITMAP16, bmPlanes) + sizeof(pbm16->bmPlanes)))\
  107. pbm16->bmPlanes = (BYTE)(lp)->bmPlanes;\
  108. if (cb >= (FIELD_OFFSET(BITMAP16, bmBitsPixel) + sizeof(pbm16->bmBitsPixel)))\
  109. pbm16->bmBitsPixel = (BYTE)(lp)->bmBitsPixel;\
  110. if (cb >= (FIELD_OFFSET(BITMAP16, bmBits) + sizeof(pbm16->bmBits)))\
  111. pbm16->bmBits = (VPBYTE)NULL;\
  112. FLUSHVDMPTR(vp, cb, pbm16);\
  113. FREEVDMPTR(pbm16);\
  114. }
  115. #define GETDCB16(vp,lp) // not implemented yet
  116. #define PUTDCB16(vp,lp) // not implemented yet
  117. #define PUTCOMSTAT16(vp,lp) // not implemented yet
  118. #define PUTSEGINFO16(vp,lp) // not implemented yet
  119. #define GETLOADPARMS16(vp,lp) // not implemented yet
  120. #define PUTOFSTRUCT16(vp,lp) // not implemented yet
  121. #define GETCATCHBUF16(vp,lp) // not implemented yet
  122. #define PUTCATCHBUF16(vp,lp) // not implemented yet
  123. #define GETLOGPEN16(vp, lp) {\
  124. PLOGPEN16 plp16;\
  125. GETVDMPTR(vp, sizeof(LOGPEN16), plp16);\
  126. (lp)->lopnStyle = FETCHWORD(plp16->lopnStyle);\
  127. (lp)->lopnWidth.x = FETCHSHORT(plp16->lopnWidth.x);\
  128. (lp)->lopnColor = FETCHDWORD(plp16->lopnColor);\
  129. FREEVDMPTR(plp16);\
  130. }
  131. #define PUTLOGPEN16(vp,cb,lp) {\
  132. PLOGPEN16 plp16;\
  133. GETVDMPTR(vp, cb, plp16);\
  134. if (cb >= 2)\
  135. STOREWORD(plp16->lopnStyle, (lp)->lopnStyle);\
  136. if (cb >= 4)\
  137. STOREWORD(plp16->lopnWidth.x, (lp)->lopnWidth.x);\
  138. if (cb >= 6)\
  139. STOREWORD(plp16->lopnWidth.y, (lp)->lopnWidth.y);\
  140. if (cb >= 10)\
  141. STOREDWORD(plp16->lopnColor, (lp)->lopnColor);\
  142. FLUSHVDMPTR(vp, cb, plp16);\
  143. FREEVDMPTR(plp16);\
  144. }
  145. #define GETLOGBRUSH16(vp,lp) {\
  146. PLOGBRUSH16 plb16;\
  147. WORD wStyle;\
  148. GETVDMPTR(vp, sizeof(LOGBRUSH16), plb16);\
  149. wStyle = FETCHWORD(plb16->lbStyle);\
  150. (lp)->lbStyle = wStyle;\
  151. (lp)->lbColor = FETCHDWORD(plb16->lbColor);\
  152. if (wStyle == BS_PATTERN) { \
  153. (lp)->lbHatch = (DWORD)HBITMAP32(FETCHWORD(plb16->lbHatch));\
  154. } else { \
  155. (lp)->lbHatch = FETCHWORD(plb16->lbHatch);\
  156. } \
  157. FREEVDMPTR(plb16);\
  158. }
  159. #define PUTLOGBRUSH16(vp,cb,lp) {\
  160. PLOGBRUSH16 plb16;\
  161. GETVDMPTR(vp, cb, plb16);\
  162. if (cb >= 2)\
  163. STOREWORD(plb16->lbStyle, (lp)->lbStyle);\
  164. if (cb >= 6)\
  165. STOREDWORD(plb16->lbColor, (lp)->lbColor);\
  166. if (cb >= 8){\
  167. if( ((lp)->lbStyle == BS_PATTERN) || ((lp)->lbStyle == BS_DIBPATTERN)){\
  168. STORESHORT(plb16->lbHatch, GETHBITMAP16((HAND32)(lp)->lbHatch));\
  169. }\
  170. else {\
  171. STORESHORT(plb16->lbHatch, (lp)->lbHatch);\
  172. }\
  173. }\
  174. FLUSHVDMPTR(vp, cb, plb16);\
  175. FREEVDMPTR(plb16);\
  176. }
  177. #define GETLOGFONT16(vp,p) getlogfont16(FETCHDWORD(vp), p)
  178. #define PUTLOGFONT16(vp,cb,p) putlogfont16(FETCHDWORD(vp), cb, p)
  179. #define PUTENUMLOGFONT16(vp,p) putenumlogfont16(FETCHDWORD(vp), p)
  180. #define PUTTEXTMETRIC16(vp,p) puttextmetric16(FETCHDWORD(vp), p)
  181. #define PUTNEWTEXTMETRIC16(vp,p) putnewtextmetric16(FETCHDWORD(vp), p)
  182. #define PUTOUTLINETEXTMETRIC16(vp,c,p) putoutlinetextmetric16(vp,c,p)
  183. #define ALLOCHANDLETABLE16(c,p) p=malloc_w(c*sizeof(HANDLE))
  184. #define GETHANDLETABLE16(vp,c, p) gethandletable16(FETCHDWORD(vp), c, p)
  185. #define PUTHANDLETABLE16(vp,c, p) puthandletable16(FETCHDWORD(vp), c, p)
  186. #define FREEHANDLETABLE16(p) {if (p) free_w(p);}
  187. #define FREEDEVMODE32(p) {if (p) free_w(p);}
  188. #define GETCLIENTCREATESTRUCT16(vp,lp) { \
  189. PCLIENTCREATESTRUCT16 pccs16;\
  190. GETVDMPTR(vp, sizeof(CLIENTCREATESTRUCT16), pccs16);\
  191. (lp)->hWindowMenu = HMENU32(FETCHWORD(pccs16->hWindowMenu));\
  192. (lp)->idFirstChild = FETCHWORD(pccs16->idFirstChild);\
  193. FREEVDMPTR(pccs16);\
  194. }
  195. #define PUTCLIENTCREATESTRUCT16(vp,lp) { \
  196. PCLIENTCREATESTRUCT16 pccs16;\
  197. GETVDMPTR(vp, sizeof(CLIENTCREATESTRUCT16), pccs16);\
  198. STOREWORD(pccs16->hWindowMenu, GETHMENU16((lp)->hWindowMenu));\
  199. STOREWORD(pccs16->idFirstChild, (lp)->idFirstChild);\
  200. }
  201. // following 2 for allocating a maximum sized BITMAPINFO structure from stack
  202. #define MAXDIBCOLORS 256 // for biBitCount == 8
  203. typedef struct _tagSTACKBMI32 {
  204. BITMAPINFOHEADER bmiHeader;
  205. RGBQUAD bmiColors[MAXDIBCOLORS];
  206. } STACKBMI32, *LPSTACKBMI32;
  207. /* Function prototypes
  208. */
  209. VOID getstr16(VPSZ vpszSrc, LPSZ lpszDst, INT cb);
  210. VOID putstr16(VPSZ vpszDst, LPCSTR lpszSrc, INT cb);
  211. LPRECT getrect16(VPRECT16 vpRect, LPRECT lpRect);
  212. VOID putrect16(VPRECT16 vpRect, LPRECT lpRect);
  213. VOID getpoint16(VPPOINT16 vpPoint, INT c, LPPOINT lpPoint);
  214. VOID putpoint16(VPPOINT16 vpPoint, INT c, LPPOINT lpPoint);
  215. VOID getintarray16(VPINT16 vpInt, INT c, LPINT lpInt);
  216. VOID putintarray16(VPINT16 vpInt, INT c, LPINT lpInt);
  217. VOID getuintarray16(VPWORD vp, INT c, PUINT puint);
  218. VOID getdrawitem16(VPDRAWITEMSTRUCT16 vpDI16, LPDRAWITEMSTRUCT lpDI);
  219. HAND16 putdrawitem16(VPDRAWITEMSTRUCT16 vpDI16, LPDRAWITEMSTRUCT lpDI);
  220. VOID getmeasureitem16(VPMEASUREITEMSTRUCT16 vpMI16, LPMEASUREITEMSTRUCT lpMI, HWND16 hwnd16);
  221. VOID putmeasureitem16(VPMEASUREITEMSTRUCT16 vpMI16, LPMEASUREITEMSTRUCT lpMI);
  222. VOID getdeleteitem16(VPDELETEITEMSTRUCT16 vpDI16, LPDELETEITEMSTRUCT lpDI);
  223. VOID putdeleteitem16(VPDELETEITEMSTRUCT16 vpDI16, LPDELETEITEMSTRUCT lpDI);
  224. VOID getcompareitem16(VPCOMPAREITEMSTRUCT16 vpCI16, LPCOMPAREITEMSTRUCT lpCI);
  225. VOID putcompareitem16(VPCOMPAREITEMSTRUCT16 vpCI16, LPCOMPAREITEMSTRUCT lpCI);
  226. VOID getmsg16(VPMSG16 vpmsg16, LPMSG lpmsg, LPMSGPARAMEX lpmpex);
  227. ULONG putmsg16(VPMSG16 vpmsg16, LPMSG lpmsg);
  228. VOID getlogfont16(VPLOGFONT16 vplf, LPLOGFONT lplf);
  229. VOID putlogfont16(VPLOGFONT16 vplf, INT cb, LPLOGFONT lplf);
  230. VOID putenumlogfont16(VPENUMLOGFONT16 vpelf, LPENUMLOGFONT lpelf);
  231. VOID puttextmetric16(VPTEXTMETRIC16 vptm, LPTEXTMETRIC lptm);
  232. VOID putnewtextmetric16(VPNEWTEXTMETRIC16 vpntm, LPNEWTEXTMETRIC lpntm);
  233. VOID putoutlinetextmetric16(VPOUTLINETEXTMETRIC16 vpotm, INT cb, LPOUTLINETEXTMETRIC lpotm);
  234. VOID gethandletable16(VPWORD vpht, UINT c, LPHANDLETABLE lpht);
  235. VOID puthandletable16(VPWORD vpht, UINT c, LPHANDLETABLE lpht);
  236. VOID putkerningpairs16(VPWORD vp, UINT cb, LPKERNINGPAIR lp);
  237. #ifdef NOTUSED
  238. BOOL getdropfilestruct16(HAND16 hand16, PHANDLE phand32);
  239. #endif
  240. INT GetBMI16Size(PVPVOID vpbmi16, WORD fuColorUse, LPDWORD lpdwClrUsed);
  241. INT GetBMI32Size(LPBITMAPINFO lpbmi32, WORD fuColorUse);
  242. LPBITMAPINFO CopyBMI16ToBMI32(PVPVOID vpbmi16, LPBITMAPINFO lpbmi32, WORD fuColorUse);
  243. LPBITMAPINFOHEADER CopyBMIH16ToBMIH32(PVPVOID vpbmih16, LPBITMAPINFOHEADER lpbmih);
  244. VOID getwindowpos16( VPWINDOWPOS16 vpwp, LPWINDOWPOS lpwp );
  245. VOID putwindowpos16( VPWINDOWPOS16 vpwp, LPWINDOWPOS lpwp );
  246. VOID W32CopyMsgStruct(VPMSG16 vpmsg16, LPMSG lpmsg, BOOL fThunk16To32);
  247. HAND16 getpaintstruct16(VPVOID vp, LPPAINTSTRUCT lp);
  248. HAND16 putpaintstruct16(VPVOID vp, LPPAINTSTRUCT lp);
  249. VOID FASTCALL getmenuiteminfo16(VPVOID vp, LPMENUITEMINFO pmii32);
  250. VOID FASTCALL putmenuiteminfo16(VPVOID vp, LPMENUITEMINFO pmii32);
  251. LPDEVMODE ThunkDevMode16to32(VPDEVMODE31 vpdm16);
  252. BOOL ThunkDevMode32to16(VPDEVMODE31 vpdm16, LPDEVMODE lpdm32, UINT nBytes);
  253. #endif // ifndef _DEF_WSTRUC_ THIS SHOULD BE THE LAST LINE IN THIS FILE