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.

154 lines
4.9 KiB

  1. /****************************************************************************
  2. vidthunk.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. #ifdef WIN32
  20. #include <wownt32.h>
  21. //
  22. // Thunking support
  23. //
  24. #define GET_VDM_POINTER_NAME "WOWGetVDMPointer"
  25. #define GET_HANDLE_MAPPER16 "WOWHandle16"
  26. #define GET_HANDLE_MAPPER32 "WOWHandle32"
  27. #define GET_CALLBACK16 "WOWCallback16"
  28. #define GET_MAPPING_MODULE_NAME TEXT("wow32.dll")
  29. typedef LPVOID (APIENTRY *LPGETVDMPOINTER)( DWORD Address, DWORD dwBytes, BOOL fProtectMode );
  30. #define WOW32ResolveMemory( p ) (LPVOID)(GetVdmPointer( (DWORD)(p), 0, TRUE ))
  31. typedef HANDLE (APIENTRY *LPWOWHANDLE32)(WORD, WOW_HANDLE_TYPE);
  32. typedef WORD (APIENTRY *LPWOWHANDLE16)(HANDLE, WOW_HANDLE_TYPE);
  33. typedef DWORD (APIENTRY *LPWOWCALLBACK16)(DWORD vpfn16, DWORD dwParam);
  34. #ifdef DEBUG
  35. extern int thunkDebugLevel;
  36. extern int videoDebugLevel;
  37. extern void FAR CDECL dprintf(LPSTR szFormat, ...);
  38. #define thDPF( _x_ ) if (thunkDebugLevel || videoDebugLevel >= 1) dprintf _x_
  39. #define thDPF0( _x_ ) dprintf _x_
  40. #define thDPF1( _x_ ) if (thunkDebugLevel || videoDebugLevel >= 1) dprintf _x_
  41. #define thDPF2( _x_ ) if (thunkDebugLevel || videoDebugLevel >= 2) dprintf _x_
  42. #define thDPF3( _x_ ) if (thunkDebugLevel || videoDebugLevel >= 3) dprintf _x_
  43. #define thDPF4( _x_ ) if (videoDebugLevel >= 4) dprintf _x_
  44. #else
  45. /* debug printf macros */
  46. #define thDPF( x )
  47. #define thDPF0( x )
  48. #define thDPF1( x )
  49. #define thDPF2( x )
  50. #define thDPF3( x )
  51. #define thDPF4( x )
  52. #endif
  53. #define StartThunk(Function) \
  54. LONG ReturnCode = 0; \
  55. thDPF2(("Entering function %s", #Function));
  56. #define EndThunk() \
  57. thDPF2(("Returned %4X :%4X", \
  58. HIWORD(ReturnCode), \
  59. LOWORD(ReturnCode))); \
  60. return ReturnCode;
  61. #define ThunkHWND(h16) ((HWND)lpWOWHandle32(h16, WOW_TYPE_HWND))
  62. #define ThunkHDC(h16) ((HDC) lpWOWHandle32(h16, WOW_TYPE_HDC))
  63. #define ThunkHPAL(h16) ((HPALETTE)lpWOWHandle32(h16, WOW_TYPE_HPALETTE))
  64. #endif // WIN32
  65. /*
  66. * Useful structures and mapping
  67. */
  68. typedef struct {
  69. short left, top, right, bottom;
  70. } RECT_SHORT;
  71. #define SHORT_RECT_TO_RECT(OutRect, InRect) \
  72. OutRect.left = (LONG)InRect.left; \
  73. OutRect.top = (LONG)InRect.top; \
  74. OutRect.right = (LONG)InRect.right; \
  75. OutRect.bottom = (LONG)InRect.bottom;
  76. #define RECT_TO_SHORT_RECT(OutRect, InRect) \
  77. OutRect.left = (short)InRect.left; \
  78. OutRect.top = (short)InRect.top; \
  79. OutRect.right = (short)InRect.right; \
  80. OutRect.bottom = (short)InRect.bottom;
  81. //
  82. // Function ids across the thunking layer (used by 32 and 16 bit)
  83. //
  84. enum {
  85. vidThunkvideoMessage32=1,
  86. vidThunkvideoGetNumDevs32,
  87. vidThunkvideoOpen32,
  88. vidThunkvideoClose32,
  89. compThunkICInfo32,
  90. compThunkICSendMessage32,
  91. compThunkICOpen32,
  92. compThunkICClose32
  93. };
  94. #ifndef WIN32
  95. typedef struct _VIDTHUNK
  96. {
  97. //
  98. // Thunking stuff
  99. //
  100. DWORD (FAR PASCAL *lpfnCallproc32W)(DWORD, DWORD, DWORD,
  101. DWORD, DWORD,
  102. LPVOID, DWORD, DWORD);
  103. LPVOID lpvThunkEntry;
  104. DWORD dwVideo32Handle;
  105. } VIDTHUNK, *PVIDTHUNK, FAR *LPVIDTHUNK;
  106. #endif // !WIN32
  107. //
  108. // The following functions generate calls to the 32-bit side
  109. //
  110. #ifdef _INC_MSVIDEO
  111. DWORD FAR PASCAL videoMessage32(HVIDEO hVideo, UINT msg, DWORD dwP1, DWORD dwP2);
  112. DWORD FAR PASCAL videoGetNumDevs32(void);
  113. DWORD FAR PASCAL videoClose32(HVIDEO hVideo);
  114. DWORD FAR PASCAL videoOpen32(LPHVIDEO lphVideo, DWORD dwDeviceID, DWORD dwFlags);
  115. #endif // _INC_MSVIDEO
  116. #ifdef _INC_COMPMAN
  117. BOOL FAR PASCAL ICInfo32(DWORD fccType, DWORD fccHandler, ICINFO16 FAR * lpicInfo);
  118. LRESULT FAR PASCAL ICSendMessage32(DWORD hic, UINT msg, DWORD dwP1, DWORD dwP2);
  119. DWORD FAR PASCAL ICOpen32(DWORD fccType, DWORD fccHandler, UINT wMode);
  120. LRESULT FAR PASCAL ICClose32(DWORD hic);
  121. #endif // _INC_COMPMAN