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.

252 lines
6.8 KiB

  1. /****************************************************************************
  2. thunk.h
  3. Contains definitions for msvideo thunks (16/32 bit)
  4. Copyright (c) Microsoft Corporation 1994. All rights reserved
  5. ****************************************************************************/
  6. //
  7. // NOTE - 32bit handles have 0x8000 'or'ed in - this makes a BIG ASSUMPTION
  8. // about how handles are generated on the 32-bit side. We ASSUME here
  9. // that :
  10. //
  11. // 32bit msvideo.dll always uses OpenDriver to create handles
  12. //
  13. // The OpenDriver returns indices into its table (ie small positive
  14. // numbers).
  15. //
  16. #define Is32bitHandle(h) (((h) & 0x8000) != 0)
  17. #define Make32bitHandle(h) ((h) | 0x8000)
  18. #define Map32bitHandle(h) ((h) & 0x7FFF)
  19. //
  20. //
  21. //
  22. #ifdef _WIN32
  23. #ifdef CHICAGO
  24. //
  25. // Following pasted from wownt32.h
  26. //
  27. //
  28. // 16 <--> 32 Handle mapping functions.
  29. //
  30. // NOTE: While some of these functions perform trivial
  31. // conversions, these functions must be used to maintain
  32. // compatibility with future versions of Windows NT which
  33. // may require different handle mapping.
  34. //
  35. typedef enum _WOW_HANDLE_TYPE { /* WOW */
  36. WOW_TYPE_HWND,
  37. WOW_TYPE_HMENU,
  38. WOW_TYPE_HDWP,
  39. WOW_TYPE_HDROP,
  40. WOW_TYPE_HDC,
  41. WOW_TYPE_HFONT,
  42. WOW_TYPE_HMETAFILE,
  43. WOW_TYPE_HRGN,
  44. WOW_TYPE_HBITMAP,
  45. WOW_TYPE_HBRUSH,
  46. WOW_TYPE_HPALETTE,
  47. WOW_TYPE_HPEN,
  48. WOW_TYPE_HACCEL,
  49. WOW_TYPE_HTASK,
  50. WOW_TYPE_FULLHWND
  51. } WOW_HANDLE_TYPE;
  52. #define ThunkHWND(h16) ((HWND)h16)
  53. #define ThunkHDC(h16) ((HDC)h16)
  54. #define ThunkHPAL(h16) ((HPALETTE)h16)
  55. #else
  56. #include <wownt32.h>
  57. #define ThunkHWND(h16) ((HWND)lpWOWHandle32((WORD)h16, WOW_TYPE_HWND))
  58. #define ThunkHDC(h16) ((HDC) lpWOWHandle32((WORD)h16, WOW_TYPE_HDC))
  59. #define ThunkHPAL(h16) ((HPALETTE)lpWOWHandle32((WORD)h16, WOW_TYPE_HPALETTE))
  60. #endif // !CHICAGO
  61. //
  62. // Thunking support
  63. //
  64. #define GET_VDM_POINTER_NAME "WOWGetVDMPointer"
  65. #define GET_HANDLE_MAPPER16 "WOWHandle16"
  66. #define GET_HANDLE_MAPPER32 "WOWHandle32"
  67. #define GET_CALLBACK16 "WOWCallback16"
  68. #define GET_MAPPING_MODULE_NAME TEXT("wow32.dll")
  69. typedef LPVOID (APIENTRY *LPGETVDMPOINTER)( DWORD Address, DWORD dwBytes, BOOL fProtectMode );
  70. typedef HANDLE (APIENTRY *LPWOWHANDLE32)(WORD, WOW_HANDLE_TYPE);
  71. typedef WORD (APIENTRY *LPWOWHANDLE16)(HANDLE, WOW_HANDLE_TYPE);
  72. typedef DWORD (APIENTRY *LPWOWCALLBACK16)(DWORD vpfn16, DWORD dwParam);
  73. #define StartThunk(Function) \
  74. LRESULT ReturnCode = 0; \
  75. DPFS(dbgThunks, 2, "Entering function %s", #Function);
  76. #define EndThunk() \
  77. DPFS(dbgThunks, 2, "Returned %4X :%4X", \
  78. HIWORD(ReturnCode), \
  79. LOWORD(ReturnCode)); \
  80. return ReturnCode;
  81. #endif // _WIN32
  82. /*
  83. * Useful structures and mapping
  84. */
  85. typedef struct {
  86. short left, top, right, bottom;
  87. } RECT_SHORT;
  88. #define SHORT_RECT_TO_RECT(OutRect, InRect) \
  89. OutRect.left = (LONG)InRect.left; \
  90. OutRect.top = (LONG)InRect.top; \
  91. OutRect.right = (LONG)InRect.right; \
  92. OutRect.bottom = (LONG)InRect.bottom;
  93. #define RECT_TO_SHORT_RECT(OutRect, InRect) \
  94. OutRect.left = (short)InRect.left; \
  95. OutRect.top = (short)InRect.top; \
  96. OutRect.right = (short)InRect.right; \
  97. OutRect.bottom = (short)InRect.bottom;
  98. //
  99. // Function ids across the thunking layer (used by 32 and 16 bit)
  100. //
  101. enum {
  102. vidThunkvideoMessage32=1,
  103. vidThunkvideoGetNumDevs32,
  104. vidThunkvideoOpen32,
  105. vidThunkvideoClose32,
  106. compThunkICInfoInternal32,
  107. compThunkICSendMessage32,
  108. compThunkICOpen32,
  109. compThunkICClose32,
  110. compThunkICOpenFunction32,
  111. compThunkICSetStatusProc32
  112. };
  113. #ifndef _WIN32
  114. typedef struct _VIDTHUNK
  115. {
  116. //
  117. // Thunking stuff
  118. //
  119. DWORD (FAR PASCAL *lpfnCallproc32W)(DWORD, DWORD, DWORD,
  120. DWORD, DWORD,
  121. LPVOID, DWORD, DWORD);
  122. LPVOID lpvThunkEntry;
  123. DWORD dwVideo32Handle;
  124. } VIDTHUNK, *PVIDTHUNK, FAR *LPVIDTHUNK;
  125. #endif // !_WIN32
  126. //
  127. // Some typedefs to assist with the ICM_SET_STATUS_PROC
  128. // thunk and callback thunk.
  129. //
  130. // Convention:
  131. // "S" suffix indicates a 16:16 ptr (Segmented)
  132. // "L" suffix indicates a 0:32 ptr (Linear)
  133. // no suffix indicates a native bitness pointer
  134. //
  135. typedef LONG (CALLBACK *ICSTATUSPROC)(LPARAM lParam, UINT uMsg, LONG l);
  136. typedef struct tICSTATUSTHUNKDESC FAR * LPICSTATUSTHUNKDESC;
  137. #ifdef _WIN32
  138. typedef DWORD LPVOIDS;
  139. typedef LPICSTATUSTHUNKDESC LPICSTATUSTHUNKDESCL;
  140. typedef DWORD LPICSTATUSTHUNKDESCS;
  141. typedef ICSTATUSPROC ICSTATUSPROCL;
  142. typedef DWORD ICSTATUSPROCS;
  143. #else
  144. typedef LPVOID LPVOIDS;
  145. typedef DWORD LPICSTATUSTHUNKDESCL;
  146. typedef LPICSTATUSTHUNKDESC LPICSTATUSTHUNKDESCS;
  147. typedef DWORD ICSTATUSPROCL;
  148. typedef ICSTATUSPROC ICSTATUSPROCS;
  149. #endif
  150. typedef struct tICSTATUSTHUNKDESC {
  151. //
  152. // segmented ptr to this struct
  153. //
  154. LPICSTATUSTHUNKDESCS lpstdS;
  155. //
  156. // segmented ptr to 16 bit callback stub
  157. //
  158. LPVOIDS pfnthkStatusProc16S;
  159. //
  160. // from client's ICSETSTATUSPROC
  161. //
  162. DWORD dwFlags;
  163. LPARAM lParam;
  164. ICSTATUSPROCS fnStatusProcS;
  165. //
  166. // to be sent to client's callback
  167. //
  168. DWORD uMsg;
  169. LONG l;
  170. } ICSTATUSTHUNKDESC;
  171. //--------------------------------------------------------------------------;
  172. //
  173. //
  174. //
  175. //--------------------------------------------------------------------------;
  176. //
  177. // The following functions generate calls to the 32-bit side
  178. //
  179. #ifdef _INC_MSVIDEO
  180. DWORD FAR PASCAL videoMessage32(HVIDEO hVideo, UINT msg, DWORD dwP1, DWORD dwP2);
  181. DWORD FAR PASCAL videoGetNumDevs32(void);
  182. DWORD FAR PASCAL videoClose32(HVIDEO hVideo);
  183. DWORD FAR PASCAL videoOpen32(LPHVIDEO lphVideo, DWORD dwDeviceID, DWORD dwFlags);
  184. #endif // _INC_MSVIDEO
  185. #ifdef _INC_COMPMAN
  186. #ifdef _WIN32
  187. LRESULT FAR PASCAL ICInfoInternal32(DWORD fccType, DWORD fccHandler, ICINFO16 FAR * lpicinfo, ICINFOI FAR * lpicinfoi);
  188. #else
  189. BOOL FAR PASCAL ICInfoInternal32(DWORD fccType, DWORD fccHandler, ICINFO FAR * lpicinfo, ICINFOI FAR * lpicinfoi);
  190. #endif
  191. LRESULT FAR PASCAL ICSendMessage32(DWORD hic, UINT msg, DWORD_PTR dwP1, DWORD_PTR dwP2);
  192. LRESULT FAR PASCAL ICOpen32(DWORD fccType, DWORD fccHandler, UINT wMode);
  193. LRESULT FAR PASCAL ICOpenFunction32(DWORD fccType, DWORD fccHandler, UINT wMode, FARPROC lpfnHandler);
  194. LRESULT FAR PASCAL ICClose32(DWORD hic);
  195. LRESULT FAR PASCAL ICSendSetStatusProc32(HIC hic, ICSETSTATUSPROC FAR* lpissp, DWORD cbStruct);
  196. #endif // _INC_COMPMAN
  197. //--------------------------------------------------------------------------;
  198. //
  199. //
  200. //
  201. //--------------------------------------------------------------------------;