1999-08-18 18:31:26 +00:00
|
|
|
/*
|
|
|
|
* Win32 WOW Generic Thunk API
|
|
|
|
*
|
|
|
|
* Copyright 1999 Ulrich Weigand
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "wine/winbase16.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wownt32.h"
|
2000-08-14 14:42:41 +00:00
|
|
|
#include "file.h"
|
1999-08-18 18:31:26 +00:00
|
|
|
#include "heap.h"
|
|
|
|
#include "miscemu.h"
|
|
|
|
#include "stackframe.h"
|
|
|
|
#include "builtin16.h"
|
|
|
|
#include "debugtools.h"
|
|
|
|
|
2000-08-14 14:42:41 +00:00
|
|
|
DEFAULT_DEBUG_CHANNEL(thunk);
|
1999-08-18 18:31:26 +00:00
|
|
|
|
2000-09-26 22:20:14 +00:00
|
|
|
/*
|
|
|
|
* These are the 16-bit side WOW routines. They reside in wownt16.h
|
|
|
|
* in the SDK; since we don't support Win16 source code anyway, I've
|
|
|
|
* placed them here for compilation with Wine ...
|
|
|
|
*/
|
|
|
|
|
|
|
|
DWORD WINAPI GetVDMPointer32W16(SEGPTR,UINT16);
|
|
|
|
|
|
|
|
DWORD WINAPI LoadLibraryEx32W16(LPCSTR,DWORD,DWORD);
|
|
|
|
DWORD WINAPI GetProcAddress32W16(DWORD,LPCSTR);
|
|
|
|
DWORD WINAPI FreeLibrary32W16(DWORD);
|
|
|
|
|
|
|
|
#define CPEX_DEST_STDCALL 0x00000000L
|
|
|
|
#define CPEX_DEST_CDECL 0x80000000L
|
|
|
|
|
|
|
|
DWORD WINAPI CallProcExW16(VOID);
|
|
|
|
DWORD WINAPI CallProcEx32W16(VOID);
|
|
|
|
|
1999-08-18 18:31:26 +00:00
|
|
|
/*
|
|
|
|
* 32-bit WOW routines (in WOW32, but actually forwarded to KERNEL32)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-11-27 21:59:08 +00:00
|
|
|
* K32WOWGetDescriptor (WOW32.1) (KERNEL32.70)
|
1999-08-18 18:31:26 +00:00
|
|
|
*/
|
2000-11-27 21:59:08 +00:00
|
|
|
BOOL WINAPI K32WOWGetDescriptor( SEGPTR segptr, LPLDT_ENTRY ldtent )
|
1999-08-18 18:31:26 +00:00
|
|
|
{
|
2000-04-30 12:11:12 +00:00
|
|
|
return GetThreadSelectorEntry( GetCurrentThread(),
|
1999-08-18 18:31:26 +00:00
|
|
|
segptr >> 16, ldtent );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-11-27 21:59:08 +00:00
|
|
|
* K32WOWGetVDMPointer (WOW32.5) (KERNEL32.56)
|
1999-08-18 18:31:26 +00:00
|
|
|
*/
|
2000-11-27 21:59:08 +00:00
|
|
|
LPVOID WINAPI K32WOWGetVDMPointer( DWORD vp, DWORD dwBytes, BOOL fProtectedMode )
|
1999-08-18 18:31:26 +00:00
|
|
|
{
|
|
|
|
/* FIXME: add size check too */
|
|
|
|
|
|
|
|
if ( fProtectedMode )
|
|
|
|
return PTR_SEG_TO_LIN( vp );
|
|
|
|
else
|
|
|
|
return DOSMEM_MapRealToLinear( vp );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-11-27 21:59:08 +00:00
|
|
|
* K32WOWGetVDMPointerFix (WOW32.6) (KERNEL32.68)
|
1999-08-18 18:31:26 +00:00
|
|
|
*/
|
2000-11-27 21:59:08 +00:00
|
|
|
LPVOID WINAPI K32WOWGetVDMPointerFix( DWORD vp, DWORD dwBytes, BOOL fProtectedMode )
|
1999-08-18 18:31:26 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Hmmm. According to the docu, we should call:
|
|
|
|
*
|
|
|
|
* GlobalFix16( SELECTOROF(vp) );
|
|
|
|
*
|
|
|
|
* But this is unnecessary under Wine, as we never move global
|
|
|
|
* memory segments in linear memory anyway.
|
|
|
|
*
|
|
|
|
* (I'm not so sure what we are *supposed* to do if
|
|
|
|
* fProtectedMode is TRUE, anyway ...)
|
|
|
|
*/
|
|
|
|
|
2000-11-27 21:59:08 +00:00
|
|
|
return K32WOWGetVDMPointer( vp, dwBytes, fProtectedMode );
|
1999-08-18 18:31:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-11-27 21:59:08 +00:00
|
|
|
* K32WOWGetVDMPointerUnFix (WOW32.7) (KERNEL32.69)
|
1999-08-18 18:31:26 +00:00
|
|
|
*/
|
2000-11-27 21:59:08 +00:00
|
|
|
VOID WINAPI K32WOWGetVDMPointerUnfix( DWORD vp )
|
1999-08-18 18:31:26 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* See above why we don't call:
|
|
|
|
*
|
|
|
|
* GlobalUnfix16( SELECTOROF(vp) );
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-11-27 21:59:08 +00:00
|
|
|
* K32WOWGlobalAlloc16 (WOW32.8) (KERNEL32.59)
|
1999-08-18 18:31:26 +00:00
|
|
|
*/
|
2000-11-27 21:59:08 +00:00
|
|
|
WORD WINAPI K32WOWGlobalAlloc16( WORD wFlags, DWORD cb )
|
1999-08-18 18:31:26 +00:00
|
|
|
{
|
|
|
|
return (WORD)GlobalAlloc16( wFlags, cb );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-11-27 21:59:08 +00:00
|
|
|
* K32WOWGlobalFree16 (WOW32.10) (KERNEL32.62)
|
1999-08-18 18:31:26 +00:00
|
|
|
*/
|
2000-11-27 21:59:08 +00:00
|
|
|
WORD WINAPI K32WOWGlobalFree16( WORD hMem )
|
1999-08-18 18:31:26 +00:00
|
|
|
{
|
|
|
|
return (WORD)GlobalFree16( (HGLOBAL16)hMem );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-11-27 21:59:08 +00:00
|
|
|
* K32WOWGlobalLock16 (WOW32.11) (KERNEL32.60)
|
1999-08-18 18:31:26 +00:00
|
|
|
*/
|
2000-11-27 21:59:08 +00:00
|
|
|
DWORD WINAPI K32WOWGlobalLock16( WORD hMem )
|
1999-08-18 18:31:26 +00:00
|
|
|
{
|
|
|
|
return (DWORD)WIN16_GlobalLock16( (HGLOBAL16)hMem );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-11-27 21:59:08 +00:00
|
|
|
* K32WOWGlobalUnlock16 (WOW32.13) (KERNEL32.61)
|
1999-08-18 18:31:26 +00:00
|
|
|
*/
|
2000-11-27 21:59:08 +00:00
|
|
|
BOOL WINAPI K32WOWGlobalUnlock16( WORD hMem )
|
1999-08-18 18:31:26 +00:00
|
|
|
{
|
|
|
|
return (BOOL)GlobalUnlock16( (HGLOBAL16)hMem );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-11-27 21:59:08 +00:00
|
|
|
* K32WOWGlobalAllocLock16 (WOW32.9) (KERNEL32.63)
|
1999-08-18 18:31:26 +00:00
|
|
|
*/
|
2000-11-27 21:59:08 +00:00
|
|
|
DWORD WINAPI K32WOWGlobalAllocLock16( WORD wFlags, DWORD cb, WORD *phMem )
|
1999-08-18 18:31:26 +00:00
|
|
|
{
|
2000-11-27 21:59:08 +00:00
|
|
|
WORD hMem = K32WOWGlobalAlloc16( wFlags, cb );
|
1999-08-18 18:31:26 +00:00
|
|
|
if (phMem) *phMem = hMem;
|
|
|
|
|
2000-11-27 21:59:08 +00:00
|
|
|
return K32WOWGlobalLock16( hMem );
|
1999-08-18 18:31:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-11-27 21:59:08 +00:00
|
|
|
* K32WOWGlobalLockSize16 (WOW32.12) (KERNEL32.65)
|
1999-08-18 18:31:26 +00:00
|
|
|
*/
|
2000-11-27 21:59:08 +00:00
|
|
|
DWORD WINAPI K32WOWGlobalLockSize16( WORD hMem, PDWORD pcb )
|
1999-08-18 18:31:26 +00:00
|
|
|
{
|
|
|
|
if ( pcb )
|
|
|
|
*pcb = GlobalSize16( (HGLOBAL16)hMem );
|
|
|
|
|
2000-11-27 21:59:08 +00:00
|
|
|
return K32WOWGlobalLock16( hMem );
|
1999-08-18 18:31:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-11-27 21:59:08 +00:00
|
|
|
* K32WOWGlobalUnlockFree16 (WOW32.14) (KERNEL32.64)
|
1999-08-18 18:31:26 +00:00
|
|
|
*/
|
2000-11-27 21:59:08 +00:00
|
|
|
WORD WINAPI K32WOWGlobalUnlockFree16( DWORD vpMem )
|
1999-08-18 18:31:26 +00:00
|
|
|
{
|
2000-11-27 21:59:08 +00:00
|
|
|
if ( !K32WOWGlobalUnlock16( HIWORD(vpMem) ) )
|
1999-08-18 18:31:26 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2000-11-27 21:59:08 +00:00
|
|
|
return K32WOWGlobalFree16( HIWORD(vpMem) );
|
1999-08-18 18:31:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-11-27 21:59:08 +00:00
|
|
|
* K32WOWYield16 (WOW32.17) (KERNEL32.66)
|
1999-08-18 18:31:26 +00:00
|
|
|
*/
|
2000-11-27 21:59:08 +00:00
|
|
|
VOID WINAPI K32WOWYield16( void )
|
1999-08-18 18:31:26 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* This does the right thing for both Win16 and Win32 tasks.
|
|
|
|
* More or less, at least :-/
|
|
|
|
*/
|
|
|
|
Yield16();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-11-27 21:59:08 +00:00
|
|
|
* K32WOWDirectedYield16 (WOW32.4) (KERNEL32.67)
|
1999-08-18 18:31:26 +00:00
|
|
|
*/
|
2000-11-27 21:59:08 +00:00
|
|
|
VOID WINAPI K32WOWDirectedYield16( WORD htask16 )
|
1999-08-18 18:31:26 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Argh. Our scheduler doesn't like DirectedYield by Win32
|
|
|
|
* tasks at all. So we do hope that this routine is indeed
|
|
|
|
* only ever called by Win16 tasks that have thunked up ...
|
|
|
|
*/
|
|
|
|
DirectedYield16( (HTASK16)htask16 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2000-11-27 21:59:08 +00:00
|
|
|
* K32WOWHandle32 (WOW32.16) (KERNEL32.57)
|
1999-08-18 18:31:26 +00:00
|
|
|
*/
|
2000-11-27 21:59:08 +00:00
|
|
|
HANDLE WINAPI K32WOWHandle32( WORD handle, WOW_HANDLE_TYPE type )
|
1999-08-18 18:31:26 +00:00
|
|
|
{
|
|
|
|
switch ( type )
|
|
|
|
{
|
|
|
|
case WOW_TYPE_HWND:
|
|
|
|
case WOW_TYPE_HMENU:
|
|
|
|
case WOW_TYPE_HDWP:
|
|
|
|
case WOW_TYPE_HDROP:
|
|
|
|
case WOW_TYPE_HDC:
|
|
|
|
case WOW_TYPE_HFONT:
|
|
|
|
case WOW_TYPE_HMETAFILE:
|
|
|
|
case WOW_TYPE_HRGN:
|
|
|
|
case WOW_TYPE_HBITMAP:
|
|
|
|
case WOW_TYPE_HBRUSH:
|
|
|
|
case WOW_TYPE_HPALETTE:
|
|
|
|
case WOW_TYPE_HPEN:
|
|
|
|
case WOW_TYPE_HACCEL:
|
|
|
|
case WOW_TYPE_HTASK:
|
|
|
|
case WOW_TYPE_FULLHWND:
|
|
|
|
return (HANDLE)handle;
|
|
|
|
|
|
|
|
default:
|
|
|
|
ERR( "handle 0x%04x of unknown type %d\n", handle, type );
|
|
|
|
return (HANDLE)handle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2000-11-27 21:59:08 +00:00
|
|
|
* K32WOWHandle16 (WOW32.15) (KERNEL32.58)
|
1999-08-18 18:31:26 +00:00
|
|
|
*/
|
2000-11-27 21:59:08 +00:00
|
|
|
WORD WINAPI K32WOWHandle16( HANDLE handle, WOW_HANDLE_TYPE type )
|
1999-08-18 18:31:26 +00:00
|
|
|
{
|
|
|
|
if ( HIWORD(handle ) )
|
|
|
|
ERR( "handle 0x%08x of type %d has non-zero HIWORD\n", handle, type );
|
|
|
|
|
|
|
|
switch ( type )
|
|
|
|
{
|
|
|
|
case WOW_TYPE_HWND:
|
|
|
|
case WOW_TYPE_HMENU:
|
|
|
|
case WOW_TYPE_HDWP:
|
|
|
|
case WOW_TYPE_HDROP:
|
|
|
|
case WOW_TYPE_HDC:
|
|
|
|
case WOW_TYPE_HFONT:
|
|
|
|
case WOW_TYPE_HMETAFILE:
|
|
|
|
case WOW_TYPE_HRGN:
|
|
|
|
case WOW_TYPE_HBITMAP:
|
|
|
|
case WOW_TYPE_HBRUSH:
|
|
|
|
case WOW_TYPE_HPALETTE:
|
|
|
|
case WOW_TYPE_HPEN:
|
|
|
|
case WOW_TYPE_HACCEL:
|
|
|
|
case WOW_TYPE_HTASK:
|
|
|
|
case WOW_TYPE_FULLHWND:
|
|
|
|
return LOWORD(handle);
|
|
|
|
|
|
|
|
default:
|
|
|
|
ERR( "handle 0x%08x of unknown type %d\n", handle, type );
|
|
|
|
return LOWORD(handle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-11-27 21:59:08 +00:00
|
|
|
* K32WOWCallback16Ex (WOW32.3) (KERNEL32.55)
|
1999-08-18 18:31:26 +00:00
|
|
|
*/
|
2000-11-27 21:59:08 +00:00
|
|
|
BOOL WINAPI K32WOWCallback16Ex( DWORD vpfn16, DWORD dwFlags,
|
|
|
|
DWORD cbArgs, LPVOID pArgs, LPDWORD pdwRetCode )
|
1999-08-18 18:31:26 +00:00
|
|
|
{
|
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Arguments must be prepared in the correct order by the caller
|
|
|
|
* (both for PASCAL and CDECL calling convention), so we simply
|
|
|
|
* copy them to the 16-bit stack ...
|
|
|
|
*/
|
|
|
|
memcpy( (LPBYTE)CURRENT_STACK16 - cbArgs, (LPBYTE)pArgs, cbArgs );
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Actually, we should take care whether the called routine cleans up
|
2000-11-29 19:39:30 +00:00
|
|
|
* its stack or not. Fortunately, our wine_call_to_16 core doesn't rely on
|
1999-08-18 18:31:26 +00:00
|
|
|
* the callee to do so; after the routine has returned, the 16-bit
|
|
|
|
* stack pointer is always reset to the position it had before.
|
|
|
|
*/
|
|
|
|
|
2000-11-29 19:39:30 +00:00
|
|
|
ret = wine_call_to_16_long( (FARPROC16)vpfn16, cbArgs );
|
1999-08-18 18:31:26 +00:00
|
|
|
|
|
|
|
if ( pdwRetCode )
|
|
|
|
*pdwRetCode = ret;
|
|
|
|
|
|
|
|
return TRUE; /* success */
|
|
|
|
}
|
|
|
|
|
2000-11-27 21:59:08 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* K32WOWCallback16 (WOW32.2) (KERNEL32.54)
|
|
|
|
*/
|
|
|
|
DWORD WINAPI K32WOWCallback16( DWORD vpfn16, DWORD dwParam )
|
|
|
|
{
|
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
if ( !K32WOWCallback16Ex( vpfn16, WCB16_PASCAL,
|
|
|
|
sizeof(DWORD), &dwParam, &ret ) )
|
|
|
|
ret = 0L;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
1999-08-18 18:31:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 16-bit WOW routines (in KERNEL)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* GetVDMPointer32W16 (KERNEL.516)
|
|
|
|
*/
|
|
|
|
DWORD WINAPI GetVDMPointer32W16( SEGPTR vp, UINT16 fMode )
|
|
|
|
{
|
2000-11-27 21:59:08 +00:00
|
|
|
return (DWORD)K32WOWGetVDMPointer( vp, 0, (DWORD)fMode );
|
1999-08-18 18:31:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* LoadLibraryEx32W16 (KERNEL.513)
|
|
|
|
*/
|
|
|
|
DWORD WINAPI LoadLibraryEx32W16( LPCSTR lpszLibFile, DWORD hFile, DWORD dwFlags )
|
|
|
|
{
|
|
|
|
HMODULE hModule;
|
2000-08-07 04:18:00 +00:00
|
|
|
DOS_FULL_NAME full_name;
|
2000-11-15 23:41:46 +00:00
|
|
|
DWORD mutex_count;
|
2000-08-07 04:18:00 +00:00
|
|
|
|
2000-08-16 12:43:42 +00:00
|
|
|
/* if the file can not be found, call LoadLibraryExA anyway, since it might be
|
|
|
|
a buildin module. This case is handled in MODULE_LoadLibraryExA */
|
|
|
|
|
|
|
|
if ( ! DIR_SearchPath ( NULL, lpszLibFile, ".DLL", &full_name, FALSE ) ) {
|
|
|
|
strcpy ( full_name.short_name, lpszLibFile );
|
|
|
|
}
|
1999-08-18 18:31:26 +00:00
|
|
|
|
2000-11-15 23:41:46 +00:00
|
|
|
ReleaseThunkLock( &mutex_count );
|
2000-08-07 04:18:00 +00:00
|
|
|
hModule = LoadLibraryExA( full_name.short_name, (HANDLE)hFile, dwFlags );
|
2000-11-15 23:41:46 +00:00
|
|
|
RestoreThunkLock( mutex_count );
|
1999-08-18 18:31:26 +00:00
|
|
|
return (DWORD)hModule;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetProcAddress32W16 (KERNEL.515)
|
|
|
|
*/
|
|
|
|
DWORD WINAPI GetProcAddress32W16( DWORD hModule, LPCSTR lpszProc )
|
|
|
|
{
|
|
|
|
return (DWORD)GetProcAddress( (HMODULE)hModule, lpszProc );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FreeLibrary32W16 (KERNEL.514)
|
|
|
|
*/
|
|
|
|
DWORD WINAPI FreeLibrary32W16( DWORD hLibModule )
|
|
|
|
{
|
|
|
|
BOOL retv;
|
2000-11-15 23:41:46 +00:00
|
|
|
DWORD mutex_count;
|
1999-08-18 18:31:26 +00:00
|
|
|
|
2000-11-15 23:41:46 +00:00
|
|
|
ReleaseThunkLock( &mutex_count );
|
1999-08-18 18:31:26 +00:00
|
|
|
retv = FreeLibrary( (HMODULE)hLibModule );
|
2000-11-15 23:41:46 +00:00
|
|
|
RestoreThunkLock( mutex_count );
|
1999-08-18 18:31:26 +00:00
|
|
|
return (DWORD)retv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* WOW_CallProc32W
|
|
|
|
*/
|
|
|
|
static DWORD WOW_CallProc32W16( BOOL Ex )
|
|
|
|
{
|
|
|
|
DWORD nrofargs, argconvmask;
|
|
|
|
FARPROC proc32;
|
|
|
|
DWORD *args, ret;
|
2000-11-15 23:41:46 +00:00
|
|
|
DWORD mutex_count;
|
1999-08-18 18:31:26 +00:00
|
|
|
VA_LIST16 valist;
|
|
|
|
int i;
|
|
|
|
int aix;
|
|
|
|
|
2000-11-15 23:41:46 +00:00
|
|
|
ReleaseThunkLock( &mutex_count );
|
1999-08-18 18:31:26 +00:00
|
|
|
|
|
|
|
VA_START16( valist );
|
|
|
|
nrofargs = VA_ARG16( valist, DWORD );
|
|
|
|
argconvmask = VA_ARG16( valist, DWORD );
|
|
|
|
proc32 = VA_ARG16( valist, FARPROC );
|
|
|
|
TRACE("(%ld,%ld,%p, Ex%d args[",nrofargs,argconvmask,proc32,Ex);
|
2000-04-30 12:11:12 +00:00
|
|
|
args = (DWORD*)HeapAlloc( GetProcessHeap(), 0, sizeof(DWORD)*nrofargs );
|
|
|
|
if(args == NULL) proc32 = NULL; /* maybe we should WARN here? */
|
1999-08-18 18:31:26 +00:00
|
|
|
/* CallProcEx doesn't need its args reversed */
|
|
|
|
for (i=0;i<nrofargs;i++) {
|
|
|
|
if (Ex) {
|
|
|
|
aix = i;
|
|
|
|
} else {
|
|
|
|
aix = nrofargs - i - 1;
|
|
|
|
}
|
|
|
|
if (argconvmask & (1<<i))
|
|
|
|
{
|
|
|
|
SEGPTR ptr = VA_ARG16( valist, SEGPTR );
|
2000-04-30 12:11:12 +00:00
|
|
|
if (args) args[aix] = (DWORD)PTR_SEG_TO_LIN(ptr);
|
1999-08-18 18:31:26 +00:00
|
|
|
if (TRACE_ON(thunk)) DPRINTF("%08lx(%p),",ptr,PTR_SEG_TO_LIN(ptr));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-04-30 12:11:12 +00:00
|
|
|
DWORD arg = VA_ARG16( valist, DWORD );
|
|
|
|
if (args) args[aix] = arg;
|
|
|
|
if (TRACE_ON(thunk)) DPRINTF("%ld,", arg);
|
1999-08-18 18:31:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (TRACE_ON(thunk)) DPRINTF("])\n");
|
|
|
|
VA_END16( valist );
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FIXME: If ( nrofargs & CPEX_DEST_CDECL ) != 0, we should call a
|
|
|
|
* 32-bit CDECL routine ...
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!proc32) ret = 0;
|
|
|
|
else switch (nrofargs)
|
|
|
|
{
|
|
|
|
case 0: ret = proc32();
|
|
|
|
break;
|
|
|
|
case 1: ret = proc32(args[0]);
|
|
|
|
break;
|
|
|
|
case 2: ret = proc32(args[0],args[1]);
|
|
|
|
break;
|
|
|
|
case 3: ret = proc32(args[0],args[1],args[2]);
|
|
|
|
break;
|
|
|
|
case 4: ret = proc32(args[0],args[1],args[2],args[3]);
|
|
|
|
break;
|
|
|
|
case 5: ret = proc32(args[0],args[1],args[2],args[3],args[4]);
|
|
|
|
break;
|
|
|
|
case 6: ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5]);
|
|
|
|
break;
|
|
|
|
case 7: ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6]);
|
|
|
|
break;
|
|
|
|
case 8: ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7]);
|
|
|
|
break;
|
|
|
|
case 9: ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8]);
|
|
|
|
break;
|
|
|
|
case 10:ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9]);
|
|
|
|
break;
|
|
|
|
case 11:ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10]);
|
|
|
|
break;
|
2000-08-28 19:29:44 +00:00
|
|
|
case 12:ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10],args[11]);
|
|
|
|
break;
|
|
|
|
case 13:ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10],args[11],args[12]);
|
|
|
|
break;
|
1999-08-18 18:31:26 +00:00
|
|
|
default:
|
|
|
|
/* FIXME: should go up to 32 arguments */
|
|
|
|
ERR("Unsupported number of arguments %ld, please report.\n",nrofargs);
|
|
|
|
ret = 0;
|
|
|
|
break;
|
|
|
|
}
|
2000-04-30 12:11:12 +00:00
|
|
|
|
1999-08-18 18:31:26 +00:00
|
|
|
/* POP nrofargs DWORD arguments and 3 DWORD parameters */
|
|
|
|
if (!Ex) stack16_pop( (3 + nrofargs) * sizeof(DWORD) );
|
|
|
|
|
|
|
|
TRACE("returns %08lx\n",ret);
|
|
|
|
HeapFree( GetProcessHeap(), 0, args );
|
|
|
|
|
2000-11-15 23:41:46 +00:00
|
|
|
RestoreThunkLock( mutex_count );
|
1999-08-18 18:31:26 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* CallProc32W16 (KERNEL.517)
|
|
|
|
*
|
|
|
|
* DWORD PASCAL CallProc32W( DWORD p1, ... , DWORD lpProcAddress,
|
|
|
|
* DWORD fAddressConvert, DWORD cParams );
|
|
|
|
*/
|
|
|
|
DWORD WINAPI CallProc32W16( void )
|
|
|
|
{
|
|
|
|
return WOW_CallProc32W16( FALSE );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* CallProcEx32W16 (KERNEL.518)
|
|
|
|
*
|
|
|
|
* DWORD CallProcEx32W( DWORD cParams, DWORD fAddressConvert,
|
|
|
|
* DWORD lpProcAddress, DWORD p1, ... );
|
|
|
|
*/
|
|
|
|
DWORD WINAPI CallProcEx32W16( void )
|
|
|
|
{
|
|
|
|
return WOW_CallProc32W16( TRUE );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* WOW16Call (KERNEL.501)
|
|
|
|
*
|
|
|
|
* FIXME!!!
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
DWORD WINAPI WOW16Call(WORD x,WORD y,WORD z)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
DWORD calladdr;
|
|
|
|
VA_LIST16 args;
|
|
|
|
FIXME("(0x%04x,0x%04x,%d),calling (",x,y,z);
|
|
|
|
|
|
|
|
VA_START16(args);
|
|
|
|
for (i=0;i<x/2;i++) {
|
|
|
|
WORD a = VA_ARG16(args,WORD);
|
|
|
|
DPRINTF("%04x ",a);
|
|
|
|
}
|
|
|
|
calladdr = VA_ARG16(args,DWORD);
|
|
|
|
VA_END16(args);
|
|
|
|
stack16_pop( x + sizeof(DWORD) );
|
|
|
|
DPRINTF(") calling address was 0x%08lx\n",calladdr);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|