home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / wownt16.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  4.5 KB  |  137 lines

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