home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / wownt16.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  4KB  |  129 lines

  1. /*++ BUILD Version: 0001    // Increment this if a change has global effects
  2.  
  3. Copyright 1995 - 1998 Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     wownt16.h
  8.  
  9. Abstract:
  10.  
  11.     Procedure declarations for functions in WOW32.DLL callable by
  12.     3rd-party 16-bit thunking code.
  13.  
  14. --*/
  15.  
  16. #ifndef _WOWNT16_
  17. #define _WOWNT16_
  18.  
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22.  
  23. //
  24. // 16:16 -> 0:32 Pointer translation.
  25. //
  26. // GetVDMPointer32W will convert the passed in 16-bit address
  27. // to the equivalent 32-bit flat pointer. The upper 16 bits
  28. // of the address are treated according to the value passed in
  29. // fMode: if fMode = 1, then the hiword of vp is used as a
  30. // protected mode selector. Otherwise it is used as a real mode
  31. // segment value.
  32. // The lower 16 bits are treated as the offset.
  33. //
  34. // The return value is 0 if the selector is invalid.
  35. //
  36. // NOTE:  Limit checking is not performed in the retail build
  37. // of Windows NT.  It is performed in the checked (debug) build
  38. // of WOW32.DLL, which will cause 0 to be returned when the
  39. // limit is exceeded by the supplied offset.
  40. //
  41.  
  42. DWORD FAR PASCAL GetVDMPointer32W(LPVOID vp, UINT fMode);
  43.  
  44.  
  45. //
  46. // Win32 module management.
  47. //
  48. // The following routines accept parameters that correspond directly
  49. // to the respective Win32 API function calls that they invoke. Refer
  50. // to the Win32 reference documentation for more detail.
  51.  
  52. DWORD FAR PASCAL LoadLibraryEx32W(LPCSTR lpszLibFile, DWORD hFile, DWORD dwFlags);
  53. DWORD FAR PASCAL GetProcAddress32W(DWORD hModule, LPCSTR lpszProc);
  54. DWORD FAR PASCAL FreeLibrary32W(DWORD hLibModule);
  55.  
  56. //
  57. // Generic Thunk Routine:
  58. //
  59. //   CallProc32W
  60. //
  61. // Transitions to 32 bits and calls specified routine
  62. //
  63. // This routine can pass a variable number of arguments, up to 32, to the
  64. // target 32-bit routine. These arguments are given to CallProc32W following
  65. // the 3 required parameters.
  66. //
  67. //   DWORD cParams          - Number of optional DWORD parameters (0-32)
  68. //
  69. //   LPVOID fAddressConvert - Bit Field, for 16:16 address Convertion. The
  70. //                            optional parameters can be automatically converted
  71. //                            from a 16:16 address format to flat by specifying
  72. //                            a 1 bit in the corresponding position in this mask.
  73. //                            eg (bit 1 means convert parameter 1 from 16:16
  74. //                              to flat address before calling routine)
  75. //
  76. //   DWORD lpProcAddress   -  32 bit native address to call (use LoadLibraryEx32W
  77. //                            and GetProcAddress32W to get this address).
  78. //
  79. // Returns:
  80. //   What ever the API returned on 32 bit side in AX:DX
  81. //
  82. // Error Returns:
  83. //   AX = 0, more than 32 parameters.
  84. //
  85. //
  86. // The function prototype must be declared by the application source code
  87. // in the following format:
  88. //
  89. // DWORD FAR PASCAL CallProc32W( DWORD p1, ... , DWORD lpProcAddress,
  90. //                                        DWORD fAddressConvert, DWORD cParams);
  91. //
  92. // where the value in cParams must match the actual number of optional
  93. // parameters (p1-pn) given AND the "DWORD p1, ..." must be replaced by
  94. // the correct number of parameters being passed.  For example, passing 3
  95. // parameter would simply require the removal of the ... and it insertion of
  96. // "DWORD p2, DWORD p3" instead.  The fAddressConvert parameter uses bit 1
  97. // for the last parameter (p3 in our example), with bit 2 for the next to last,
  98. // etc.
  99. //
  100. // Generic Thunk Routine:
  101. //
  102. //   CallProcEx32W
  103. //
  104. // Transitions to 32 bits and calls specified routine
  105. //
  106. // Similar to the CallProc32W function, the CallProcEx32W is an equivalent
  107. // function that is C calling convention and allows easier and more flexible
  108. // prototyping.  See the prototype below.  The fAddressConvert parameter uses
  109. // bit 1 for the 1st parameter, bit 2 for the 2nd parameter, etc.
  110. //
  111. // Both CallProc32W and CallProcEx32W accept a flag OR'd with the parameter
  112. // count to indicate the calling convention of the function in 32 bits.
  113. // For example, to call a cdecl function in 32-bits with 1 parameter, it would
  114. // look like this:
  115. //
  116. // dwResult = CallProcEx32W( CPEX_DEST_CDECL | 1, 0, dwfn32, p1 );
  117. //
  118.  
  119. DWORD FAR CDECL CallProcEx32W( DWORD, DWORD, DWORD, ... );
  120.  
  121. #define CPEX_DEST_STDCALL   0x00000000L
  122. #define CPEX_DEST_CDECL     0x80000000L
  123.  
  124. #ifdef __cplusplus
  125. }
  126. #endif
  127.  
  128. #endif /* !_WOWNT16_ */
  129.