1
{******************************************************************************}
3
{ 16 bit Generic Thunks API interface Unit for Object Pascal }
5
{ Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
6
{ Corporation. All Rights Reserved. }
8
{ The original file is: wownt16.h, released June 2000. The original Pascal }
9
{ code is: WowNT16.pas, released December 2000. The initial developer of the }
10
{ Pascal code is Marcel van Brakel (brakelm att chello dott nl). }
12
{ Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
13
{ Marcel van Brakel. All Rights Reserved. }
15
{ Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
17
{ You may retrieve the latest version of this file at the Project JEDI }
18
{ APILIB home page, located at http://jedi-apilib.sourceforge.net }
20
{ The contents of this file are used with permission, subject to the Mozilla }
21
{ Public License Version 1.1 (the "License"); you may not use this file except }
22
{ in compliance with the License. You may obtain a copy of the License at }
23
{ http://www.mozilla.org/MPL/MPL-1.1.html }
25
{ Software distributed under the License is distributed on an "AS IS" basis, }
26
{ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
27
{ the specific language governing rights and limitations under the License. }
29
{ Alternatively, the contents of this file may be used under the terms of the }
30
{ GNU Lesser General Public License (the "LGPL License"), in which case the }
31
{ provisions of the LGPL License are applicable instead of those above. }
32
{ If you wish to allow use of your version of this file only under the terms }
33
{ of the LGPL License and not to allow others to use your version of this file }
34
{ under the MPL, indicate your decision by deleting the provisions above and }
35
{ replace them with the notice and other provisions required by the LGPL }
36
{ License. If you do not delete the provisions above, a recipient may use }
37
{ your version of this file under either the MPL or the LGPL License. }
39
{ For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
41
{******************************************************************************}
43
// $Id: jwawownt16.pas,v 1.1 2005/04/04 07:56:11 marco Exp $
50
{$HPPEMIT '#include "wownt16.h"'}
55
// (rom) get rid of warnings about "index" directive
56
{$WARN SYMBOL_PLATFORM OFF}
64
// 16:16 -> 0:32 Pointer translation.
66
// GetVDMPointer32W will convert the passed in 16-bit address
67
// to the equivalent 32-bit flat pointer. The upper 16 bits
68
// of the address are treated according to the value passed in
69
// fMode: if fMode = 1, then the hiword of vp is used as a
70
// protected mode selector. Otherwise it is used as a real mode
72
// The lower 16 bits are treated as the offset.
74
// The return value is 0 if the selector is invalid.
76
// NOTE: Limit checking is not performed in the retail build
77
// of Windows NT. It is performed in the checked (debug) build
78
// of WOW32.DLL, which will cause 0 to be returned when the
79
// limit is exceeded by the supplied offset.
82
function GetVDMPointer32W(vp: LPVOID; fMode: UINT): DWORD; stdcall;
83
{$EXTERNALSYM GetVDMPointer32W}
86
// Win32 module management.
88
// The following routines accept parameters that correspond directly
89
// to the respective Win32 API function calls that they invoke. Refer
90
// to the Win32 reference documentation for more detail.
92
function LoadLibraryEx32W(lpszLibFile: LPCSTR; hFile, dwFlags: DWORD): DWORD; stdcall;
93
{$EXTERNALSYM LoadLibraryEx32W}
94
function GetProcAddress32W(hModule: DWORD; lpszProc: LPCSTR): DWORD; stdcall;
95
{$EXTERNALSYM GetProcAddress32W}
96
function FreeLibrary32W(hLibModule: DWORD): DWORD; stdcall;
97
{$EXTERNALSYM FreeLibrary32W}
100
// Generic Thunk Routine:
104
// Transitions to 32 bits and calls specified routine
106
// This routine can pass a variable number of arguments, up to 32, to the
107
// target 32-bit routine. These arguments are given to CallProc32W following
108
// the 3 required parameters.
110
// DWORD cParams - Number of optional DWORD parameters (0-32)
112
// LPVOID fAddressConvert - Bit Field, for 16:16 address Convertion. The
113
// optional parameters can be automatically converted
114
// from a 16:16 address format to flat by specifying
115
// a 1 bit in the corresponding position in this mask.
116
// eg (bit 1 means convert parameter 1 from 16:16
117
// to flat address before calling routine)
119
// DWORD lpProcAddress - 32 bit native address to call (use LoadLibraryEx32W
120
// and GetProcAddress32W to get this address).
123
// What ever the API returned on 32 bit side in AX:DX
126
// AX = 0, more than 32 parameters.
129
// The function prototype must be declared by the application source code
130
// in the following format:
132
// DWORD FAR PASCAL CallProc32W( DWORD p1, ... , DWORD lpProcAddress,
133
// DWORD fAddressConvert, DWORD cParams);
135
// where the value in cParams must match the actual number of optional
136
// parameters (p1-pn) given AND the "DWORD p1, ..." must be replaced by
137
// the correct number of parameters being passed. For example, passing 3
138
// parameter would simply require the removal of the ... and it insertion of
139
// "DWORD p2, DWORD p3" instead. The fAddressConvert parameter uses bit 1
140
// for the last parameter (p3 in our example), with bit 2 for the next to last,
143
// Generic Thunk Routine:
147
// Transitions to 32 bits and calls specified routine
149
// Similar to the CallProc32W function, the CallProcEx32W is an equivalent
150
// function that is C calling convention and allows easier and more flexible
151
// prototyping. See the prototype below. The fAddressConvert parameter uses
152
// bit 1 for the 1st parameter, bit 2 for the 2nd parameter, etc.
154
// Both CallProc32W and CallProcEx32W accept a flag OR'd with the parameter
155
// count to indicate the calling convention of the function in 32 bits.
156
// For example, to call a cdecl function in 32-bits with 1 parameter, it would
159
// dwResult = CallProcEx32W( CPEX_DEST_CDECL | 1, 0, dwfn32, p1 );
162
// TODO Variable argument list wrapper!
165
function CallProcEx32W(nParams, fAddressConvert, lpProcAddress: DWORD): DWORD; cdecl;
166
{$EXTERNALSYM CallProcEx32W}
170
CPEX_DEST_STDCALL = DWORD($00000000);
171
{$EXTERNALSYM CPEX_DEST_STDCALL}
172
CPEX_DEST_CDECL = DWORD($80000000);
173
{$EXTERNALSYM CPEX_DEST_CDECL}
178
wow16lib = 'kernel32.dll';
180
//function CallProcEx32W; external wow16lib index 517;
182
{$IFDEF DYNAMIC_LINK}
185
_GetVDMPointer32W: Pointer;
187
function GetVDMPointer32W;
189
GetProcedureAddress(_GetVDMPointer32W, wow16lib, '516');
193
JMP [_GetVDMPointer32W]
198
_LoadLibraryEx32W: Pointer;
200
function LoadLibraryEx32W;
202
GetProcedureAddress(_LoadLibraryEx32W, wow16lib, '513');
206
JMP [_LoadLibraryEx32W]
211
_GetProcAddress32W: Pointer;
213
function GetProcAddress32W;
215
GetProcedureAddress(_GetProcAddress32W, wow16lib, '515');
219
JMP [_GetProcAddress32W]
224
_FreeLibrary32W: Pointer;
226
function FreeLibrary32W;
228
GetProcedureAddress(_FreeLibrary32W, wow16lib, '514');
232
JMP [_FreeLibrary32W]
238
function GetVDMPointer32W; external wow16lib index 516;
239
function LoadLibraryEx32W; external wow16lib index 513;
240
function GetProcAddress32W; external wow16lib index 515;
241
function FreeLibrary32W; external wow16lib index 514;
243
{$ENDIF DYNAMIC_LINK}
1
{******************************************************************************}
3
{ 16 bit Generic Thunks API interface Unit for Object Pascal }
5
{ Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
6
{ Corporation. All Rights Reserved. }
8
{ The original file is: wownt16.h, released June 2000. The original Pascal }
9
{ code is: WowNT16.pas, released December 2000. The initial developer of the }
10
{ Pascal code is Marcel van Brakel (brakelm att chello dott nl). }
12
{ Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
13
{ Marcel van Brakel. All Rights Reserved. }
15
{ Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
17
{ You may retrieve the latest version of this file at the Project JEDI }
18
{ APILIB home page, located at http://jedi-apilib.sourceforge.net }
20
{ The contents of this file are used with permission, subject to the Mozilla }
21
{ Public License Version 1.1 (the "License"); you may not use this file except }
22
{ in compliance with the License. You may obtain a copy of the License at }
23
{ http://www.mozilla.org/MPL/MPL-1.1.html }
25
{ Software distributed under the License is distributed on an "AS IS" basis, }
26
{ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
27
{ the specific language governing rights and limitations under the License. }
29
{ Alternatively, the contents of this file may be used under the terms of the }
30
{ GNU Lesser General Public License (the "LGPL License"), in which case the }
31
{ provisions of the LGPL License are applicable instead of those above. }
32
{ If you wish to allow use of your version of this file only under the terms }
33
{ of the LGPL License and not to allow others to use your version of this file }
34
{ under the MPL, indicate your decision by deleting the provisions above and }
35
{ replace them with the notice and other provisions required by the LGPL }
36
{ License. If you do not delete the provisions above, a recipient may use }
37
{ your version of this file under either the MPL or the LGPL License. }
39
{ For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
41
{******************************************************************************}
49
{$HPPEMIT '#include "wownt16.h"'}
54
// (rom) get rid of warnings about "index" directive
55
{ $WARN SYMBOL_PLATFORM OFF}
63
// 16:16 -> 0:32 Pointer translation.
65
// GetVDMPointer32W will convert the passed in 16-bit address
66
// to the equivalent 32-bit flat pointer. The upper 16 bits
67
// of the address are treated according to the value passed in
68
// fMode: if fMode = 1, then the hiword of vp is used as a
69
// protected mode selector. Otherwise it is used as a real mode
71
// The lower 16 bits are treated as the offset.
73
// The return value is 0 if the selector is invalid.
75
// NOTE: Limit checking is not performed in the retail build
76
// of Windows NT. It is performed in the checked (debug) build
77
// of WOW32.DLL, which will cause 0 to be returned when the
78
// limit is exceeded by the supplied offset.
81
function GetVDMPointer32W(vp: LPVOID; fMode: UINT): DWORD; stdcall;
82
{$EXTERNALSYM GetVDMPointer32W}
85
// Win32 module management.
87
// The following routines accept parameters that correspond directly
88
// to the respective Win32 API function calls that they invoke. Refer
89
// to the Win32 reference documentation for more detail.
91
function LoadLibraryEx32W(lpszLibFile: LPCSTR; hFile, dwFlags: DWORD): DWORD; stdcall;
92
{$EXTERNALSYM LoadLibraryEx32W}
93
function GetProcAddress32W(hModule: DWORD; lpszProc: LPCSTR): DWORD; stdcall;
94
{$EXTERNALSYM GetProcAddress32W}
95
function FreeLibrary32W(hLibModule: DWORD): DWORD; stdcall;
96
{$EXTERNALSYM FreeLibrary32W}
99
// Generic Thunk Routine:
103
// Transitions to 32 bits and calls specified routine
105
// This routine can pass a variable number of arguments, up to 32, to the
106
// target 32-bit routine. These arguments are given to CallProc32W following
107
// the 3 required parameters.
109
// DWORD cParams - Number of optional DWORD parameters (0-32)
111
// LPVOID fAddressConvert - Bit Field, for 16:16 address Convertion. The
112
// optional parameters can be automatically converted
113
// from a 16:16 address format to flat by specifying
114
// a 1 bit in the corresponding position in this mask.
115
// eg (bit 1 means convert parameter 1 from 16:16
116
// to flat address before calling routine)
118
// DWORD lpProcAddress - 32 bit native address to call (use LoadLibraryEx32W
119
// and GetProcAddress32W to get this address).
122
// What ever the API returned on 32 bit side in AX:DX
125
// AX = 0, more than 32 parameters.
128
// The function prototype must be declared by the application source code
129
// in the following format:
131
// DWORD FAR PASCAL CallProc32W( DWORD p1, ... , DWORD lpProcAddress,
132
// DWORD fAddressConvert, DWORD cParams);
134
// where the value in cParams must match the actual number of optional
135
// parameters (p1-pn) given AND the "DWORD p1, ..." must be replaced by
136
// the correct number of parameters being passed. For example, passing 3
137
// parameter would simply require the removal of the ... and it insertion of
138
// "DWORD p2, DWORD p3" instead. The fAddressConvert parameter uses bit 1
139
// for the last parameter (p3 in our example), with bit 2 for the next to last,
142
// Generic Thunk Routine:
146
// Transitions to 32 bits and calls specified routine
148
// Similar to the CallProc32W function, the CallProcEx32W is an equivalent
149
// function that is C calling convention and allows easier and more flexible
150
// prototyping. See the prototype below. The fAddressConvert parameter uses
151
// bit 1 for the 1st parameter, bit 2 for the 2nd parameter, etc.
153
// Both CallProc32W and CallProcEx32W accept a flag OR'd with the parameter
154
// count to indicate the calling convention of the function in 32 bits.
155
// For example, to call a cdecl function in 32-bits with 1 parameter, it would
158
// dwResult = CallProcEx32W( CPEX_DEST_CDECL | 1, 0, dwfn32, p1 );
161
// TODO Variable argument list wrapper!
164
function CallProcEx32W(nParams, fAddressConvert, lpProcAddress: DWORD): DWORD; cdecl;
165
{$EXTERNALSYM CallProcEx32W}
169
CPEX_DEST_STDCALL = DWORD($00000000);
170
{$EXTERNALSYM CPEX_DEST_STDCALL}
171
CPEX_DEST_CDECL = DWORD($80000000);
172
{$EXTERNALSYM CPEX_DEST_CDECL}
177
wow16lib = 'kernel32.dll';
179
//function CallProcEx32W; external wow16lib index 517;
181
{$IFDEF DYNAMIC_LINK}
184
_GetVDMPointer32W: Pointer;
186
function GetVDMPointer32W;
188
GetProcedureAddress(_GetVDMPointer32W, wow16lib, '516');
192
JMP [_GetVDMPointer32W]
197
_LoadLibraryEx32W: Pointer;
199
function LoadLibraryEx32W;
201
GetProcedureAddress(_LoadLibraryEx32W, wow16lib, '513');
205
JMP [_LoadLibraryEx32W]
210
_GetProcAddress32W: Pointer;
212
function GetProcAddress32W;
214
GetProcedureAddress(_GetProcAddress32W, wow16lib, '515');
218
JMP [_GetProcAddress32W]
223
_FreeLibrary32W: Pointer;
225
function FreeLibrary32W;
227
GetProcedureAddress(_FreeLibrary32W, wow16lib, '514');
231
JMP [_FreeLibrary32W]
237
function GetVDMPointer32W; external wow16lib index 516;
238
function LoadLibraryEx32W; external wow16lib index 513;
239
function GetProcAddress32W; external wow16lib index 515;
240
function FreeLibrary32W; external wow16lib index 514;
242
{$ENDIF DYNAMIC_LINK}