Adapted for new register functions support (ESP_reg in register

functions now points after the arguments).
This commit is contained in:
Alexandre Julliard 1999-05-13 16:21:37 +00:00
parent 06b978991b
commit 0a277b638c
8 changed files with 96 additions and 159 deletions

View file

@ -96,12 +96,10 @@ static void EXC_DefaultHandling( EXCEPTION_RECORD *rec, CONTEXT *context )
} }
/******************************************************************* /***********************************************************************
* EXC_RaiseException * RtlRaiseException (NTDLL.464)
*
* Implementation of NtRaiseException.
*/ */
static void EXC_RaiseException( EXCEPTION_RECORD *rec, CONTEXT *context ) void WINAPI REGS_FUNC(RtlRaiseException)( EXCEPTION_RECORD *rec, CONTEXT *context )
{ {
PEXCEPTION_FRAME frame, dispatch, nested_frame; PEXCEPTION_FRAME frame, dispatch, nested_frame;
EXCEPTION_RECORD newrec; EXCEPTION_RECORD newrec;
@ -160,16 +158,17 @@ static void EXC_RaiseException( EXCEPTION_RECORD *rec, CONTEXT *context )
/******************************************************************* /*******************************************************************
* EXC_RtlUnwind * RtlUnwind (KERNEL32.590) (NTDLL.518)
*
* Implementation of RtlUnwind.
*/ */
static void EXC_RtlUnwind( EXCEPTION_FRAME *pEndFrame, EXCEPTION_RECORD *pRecord, void WINAPI REGS_FUNC(RtlUnwind)( PEXCEPTION_FRAME pEndFrame, LPVOID unusedEip,
CONTEXT *context ) PEXCEPTION_RECORD pRecord, DWORD returnEax,
CONTEXT *context )
{ {
EXCEPTION_RECORD record, newrec; EXCEPTION_RECORD record, newrec;
PEXCEPTION_FRAME frame, dispatch; PEXCEPTION_FRAME frame, dispatch;
EAX_reg(context) = returnEax;
/* build an exception record, if we do not have one */ /* build an exception record, if we do not have one */
if (!pRecord) if (!pRecord)
{ {
@ -235,68 +234,14 @@ static void EXC_RtlUnwind( EXCEPTION_FRAME *pEndFrame, EXCEPTION_RECORD *pRecord
* Real prototype: * Real prototype:
* DWORD WINAPI NtRaiseException( EXCEPTION_RECORD *rec, CONTEXT *ctx, BOOL first ); * DWORD WINAPI NtRaiseException( EXCEPTION_RECORD *rec, CONTEXT *ctx, BOOL first );
*/ */
REGS_ENTRYPOINT(NtRaiseException) void WINAPI REGS_FUNC(NtRaiseException)( EXCEPTION_RECORD *rec, CONTEXT *ctx,
BOOL first, CONTEXT *context )
{ {
DWORD ret; REGS_FUNC(RtlRaiseException)( rec, ctx );
EXCEPTION_RECORD *rec;
CONTEXT *ctx;
BOOL first;
ret = STACK32_POP(context); /* return addr */
rec = (PEXCEPTION_RECORD)STACK32_POP(context);
ctx = (PCONTEXT)STACK32_POP(context);
first = (BOOL)STACK32_POP(context);
STACK32_PUSH(context,ret); /* restore return addr */
EXC_RaiseException( rec, ctx );
*context = *ctx; *context = *ctx;
} }
/***********************************************************************
* RtlRaiseException (NTDLL.464)
*
* Real prototype:
* void WINAPI RtlRaiseException(PEXCEPTION_RECORD pRecord)
*/
REGS_ENTRYPOINT(RtlRaiseException)
{
EXCEPTION_RECORD *rec;
DWORD ret;
ret = STACK32_POP(context); /* return addr */
rec = (PEXCEPTION_RECORD)STACK32_POP(context);
STACK32_PUSH(context,ret); /* restore return addr */
rec->ExceptionAddress = (LPVOID)EIP_reg(context);
EXC_RaiseException( rec, context );
}
/*******************************************************************
* RtlUnwind (KERNEL32.590) (NTDLL.518)
*
* The real prototype is:
* void WINAPI RtlUnwind( PEXCEPTION_FRAME pEndFrame, LPVOID unusedEip,
* PEXCEPTION_RECORD pRecord, DWORD returnEax );
*/
REGS_ENTRYPOINT(RtlUnwind)
{
PEXCEPTION_FRAME pEndFrame;
PEXCEPTION_RECORD pRecord;
/* get the arguments from the stack */
DWORD ret = STACK32_POP(context); /* return addr */
pEndFrame = (PEXCEPTION_FRAME)STACK32_POP(context);
(void)STACK32_POP(context); /* unused arg */
pRecord = (PEXCEPTION_RECORD)STACK32_POP(context);
EAX_reg(context) = STACK32_POP(context);
STACK32_PUSH(context,ret); /* restore return addr */
EXC_RtlUnwind( pEndFrame, pRecord, context );
}
/*********************************************************************** /***********************************************************************
* RtlRaiseStatus (NTDLL.465) * RtlRaiseStatus (NTDLL.465)
* *

View file

@ -374,11 +374,11 @@ BOOLEAN WINAPI RtlGetNtProductType(LPDWORD type)
* NTDLL_alloca_probe [NTDLL.861] * NTDLL_alloca_probe [NTDLL.861]
* Glorified "enter xxxx". * Glorified "enter xxxx".
*/ */
REGS_ENTRYPOINT(NTDLL_chkstk) void WINAPI REGS_FUNC(NTDLL_chkstk)( CONTEXT *context )
{ {
ESP_reg(context) -= EAX_reg(context); ESP_reg(context) -= EAX_reg(context);
} }
REGS_ENTRYPOINT(NTDLL_alloca_probe) void WINAPI REGS_FUNC(NTDLL_alloca_probe)( CONTEXT *context )
{ {
ESP_reg(context) -= EAX_reg(context); ESP_reg(context) -= EAX_reg(context);
} }

View file

@ -85,6 +85,6 @@ typedef void *VA_LIST16;
#define STACK32_POP(context) (*(*(DWORD **)&ESP_reg(context))++) #define STACK32_POP(context) (*(*(DWORD **)&ESP_reg(context))++)
/* Win32 register functions */ /* Win32 register functions */
#define REGS_ENTRYPOINT(name) void WINAPI __regs_##name( CONTEXT *context ) #define REGS_FUNC(name) __regs_##name
#endif /* __WINE_STACKFRAME_H */ #endif /* __WINE_STACKFRAME_H */

View file

@ -1560,21 +1560,24 @@ HMODULE WINAPI MapHModuleSL(HMODULE16 hmod) {
/*************************************************************************** /***************************************************************************
* MapHInstLS (KERNEL32.516) * MapHInstLS (KERNEL32.516)
*/ */
REGS_ENTRYPOINT(MapHInstLS) { void WINAPI REGS_FUNC(MapHInstLS)( CONTEXT *context )
{
EAX_reg(context) = MapHModuleLS(EAX_reg(context)); EAX_reg(context) = MapHModuleLS(EAX_reg(context));
} }
/*************************************************************************** /***************************************************************************
* MapHInstSL (KERNEL32.518) * MapHInstSL (KERNEL32.518)
*/ */
REGS_ENTRYPOINT(MapHInstSL) { void WINAPI REGS_FUNC(MapHInstSL)( CONTEXT *context )
{
EAX_reg(context) = MapHModuleSL(EAX_reg(context)); EAX_reg(context) = MapHModuleSL(EAX_reg(context));
} }
/*************************************************************************** /***************************************************************************
* MapHInstLS_PN (KERNEL32.517) * MapHInstLS_PN (KERNEL32.517)
*/ */
REGS_ENTRYPOINT(MapHInstLS_PN) { void WINAPI REGS_FUNC(MapHInstLS_PN)( CONTEXT *context )
{
if (EAX_reg(context)) if (EAX_reg(context))
EAX_reg(context) = MapHModuleLS(EAX_reg(context)); EAX_reg(context) = MapHModuleLS(EAX_reg(context));
} }
@ -1582,7 +1585,8 @@ REGS_ENTRYPOINT(MapHInstLS_PN) {
/*************************************************************************** /***************************************************************************
* MapHInstSL_PN (KERNEL32.519) * MapHInstSL_PN (KERNEL32.519)
*/ */
REGS_ENTRYPOINT(MapHInstSL_PN) { void WINAPI REGS_FUNC(MapHInstSL_PN)( CONTEXT *context )
{
if (EAX_reg(context)) if (EAX_reg(context))
EAX_reg(context) = MapHModuleSL(EAX_reg(context)); EAX_reg(context) = MapHModuleSL(EAX_reg(context));
} }

View file

@ -558,11 +558,9 @@ LPVOID WINAPI MapSLFix( SEGPTR sptr )
* UnMapSLFixArray (KERNEL32.701) * UnMapSLFixArray (KERNEL32.701)
*/ */
REGS_ENTRYPOINT(UnMapSLFixArray) /* SEGPTR sptr[], INT32 length */ void WINAPI REGS_FUNC(UnMapSLFixArray)( SEGPTR sptr[], INT length, CONTEXT *context )
{ {
/* Must not change EAX, hence defined as 'register' function */ /* Must not change EAX, hence defined as 'register' function */
/* We need to remove the arguments ourselves */
ESP_reg( context ) += 8;
} }
/*********************************************************************** /***********************************************************************
@ -642,17 +640,17 @@ x_SMapLS_IP_EBP_x(CONTEXT *context,int argoff) {
EAX_reg(context) = ptr; EAX_reg(context) = ptr;
} }
REGS_ENTRYPOINT(SMapLS_IP_EBP_8) {x_SMapLS_IP_EBP_x(context,8);} void WINAPI REGS_FUNC(SMapLS_IP_EBP_8)(CONTEXT *context) {x_SMapLS_IP_EBP_x(context,8);}
REGS_ENTRYPOINT(SMapLS_IP_EBP_12) {x_SMapLS_IP_EBP_x(context,12);} void WINAPI REGS_FUNC(SMapLS_IP_EBP_12)(CONTEXT *context) {x_SMapLS_IP_EBP_x(context,12);}
REGS_ENTRYPOINT(SMapLS_IP_EBP_16) {x_SMapLS_IP_EBP_x(context,16);} void WINAPI REGS_FUNC(SMapLS_IP_EBP_16)(CONTEXT *context) {x_SMapLS_IP_EBP_x(context,16);}
REGS_ENTRYPOINT(SMapLS_IP_EBP_20) {x_SMapLS_IP_EBP_x(context,20);} void WINAPI REGS_FUNC(SMapLS_IP_EBP_20)(CONTEXT *context) {x_SMapLS_IP_EBP_x(context,20);}
REGS_ENTRYPOINT(SMapLS_IP_EBP_24) {x_SMapLS_IP_EBP_x(context,24);} void WINAPI REGS_FUNC(SMapLS_IP_EBP_24)(CONTEXT *context) {x_SMapLS_IP_EBP_x(context,24);}
REGS_ENTRYPOINT(SMapLS_IP_EBP_28) {x_SMapLS_IP_EBP_x(context,28);} void WINAPI REGS_FUNC(SMapLS_IP_EBP_28)(CONTEXT *context) {x_SMapLS_IP_EBP_x(context,28);}
REGS_ENTRYPOINT(SMapLS_IP_EBP_32) {x_SMapLS_IP_EBP_x(context,32);} void WINAPI REGS_FUNC(SMapLS_IP_EBP_32)(CONTEXT *context) {x_SMapLS_IP_EBP_x(context,32);}
REGS_ENTRYPOINT(SMapLS_IP_EBP_36) {x_SMapLS_IP_EBP_x(context,36);} void WINAPI REGS_FUNC(SMapLS_IP_EBP_36)(CONTEXT *context) {x_SMapLS_IP_EBP_x(context,36);}
REGS_ENTRYPOINT(SMapLS_IP_EBP_40) {x_SMapLS_IP_EBP_x(context,40);} void WINAPI REGS_FUNC(SMapLS_IP_EBP_40)(CONTEXT *context) {x_SMapLS_IP_EBP_x(context,40);}
REGS_ENTRYPOINT(SMapLS) void WINAPI REGS_FUNC(SMapLS)( CONTEXT *context )
{ {
if (EAX_reg(context)>=0x10000) { if (EAX_reg(context)>=0x10000) {
EAX_reg(context) = MapLS((LPVOID)EAX_reg(context)); EAX_reg(context) = MapLS((LPVOID)EAX_reg(context));
@ -662,7 +660,7 @@ REGS_ENTRYPOINT(SMapLS)
} }
} }
REGS_ENTRYPOINT(SUnMapLS) void WINAPI REGS_FUNC(SUnMapLS)( CONTEXT *context )
{ {
if (EAX_reg(context)>=0x10000) if (EAX_reg(context)>=0x10000)
UnMapLS((SEGPTR)EAX_reg(context)); UnMapLS((SEGPTR)EAX_reg(context));
@ -674,15 +672,15 @@ x_SUnMapLS_IP_EBP_x(CONTEXT *context,int argoff) {
UnMapLS(*(DWORD*)(EBP_reg(context)+argoff)); UnMapLS(*(DWORD*)(EBP_reg(context)+argoff));
*(DWORD*)(EBP_reg(context)+argoff)=0; *(DWORD*)(EBP_reg(context)+argoff)=0;
} }
REGS_ENTRYPOINT(SUnMapLS_IP_EBP_8) { x_SUnMapLS_IP_EBP_x(context,8); } void WINAPI REGS_FUNC(SUnMapLS_IP_EBP_8)(CONTEXT *context) { x_SUnMapLS_IP_EBP_x(context,8); }
REGS_ENTRYPOINT(SUnMapLS_IP_EBP_12) { x_SUnMapLS_IP_EBP_x(context,12); } void WINAPI REGS_FUNC(SUnMapLS_IP_EBP_12)(CONTEXT *context) { x_SUnMapLS_IP_EBP_x(context,12); }
REGS_ENTRYPOINT(SUnMapLS_IP_EBP_16) { x_SUnMapLS_IP_EBP_x(context,16); } void WINAPI REGS_FUNC(SUnMapLS_IP_EBP_16)(CONTEXT *context) { x_SUnMapLS_IP_EBP_x(context,16); }
REGS_ENTRYPOINT(SUnMapLS_IP_EBP_20) { x_SUnMapLS_IP_EBP_x(context,20); } void WINAPI REGS_FUNC(SUnMapLS_IP_EBP_20)(CONTEXT *context) { x_SUnMapLS_IP_EBP_x(context,20); }
REGS_ENTRYPOINT(SUnMapLS_IP_EBP_24) { x_SUnMapLS_IP_EBP_x(context,24); } void WINAPI REGS_FUNC(SUnMapLS_IP_EBP_24)(CONTEXT *context) { x_SUnMapLS_IP_EBP_x(context,24); }
REGS_ENTRYPOINT(SUnMapLS_IP_EBP_28) { x_SUnMapLS_IP_EBP_x(context,28); } void WINAPI REGS_FUNC(SUnMapLS_IP_EBP_28)(CONTEXT *context) { x_SUnMapLS_IP_EBP_x(context,28); }
REGS_ENTRYPOINT(SUnMapLS_IP_EBP_32) { x_SUnMapLS_IP_EBP_x(context,32); } void WINAPI REGS_FUNC(SUnMapLS_IP_EBP_32)(CONTEXT *context) { x_SUnMapLS_IP_EBP_x(context,32); }
REGS_ENTRYPOINT(SUnMapLS_IP_EBP_36) { x_SUnMapLS_IP_EBP_x(context,36); } void WINAPI REGS_FUNC(SUnMapLS_IP_EBP_36)(CONTEXT *context) { x_SUnMapLS_IP_EBP_x(context,36); }
REGS_ENTRYPOINT(SUnMapLS_IP_EBP_40) { x_SUnMapLS_IP_EBP_x(context,40); } void WINAPI REGS_FUNC(SUnMapLS_IP_EBP_40)(CONTEXT *context) { x_SUnMapLS_IP_EBP_x(context,40); }
/********************************************************************** /**********************************************************************
* AllocMappedBuffer (KERNEL32.38) * AllocMappedBuffer (KERNEL32.38)
@ -703,7 +701,7 @@ REGS_ENTRYPOINT(SUnMapLS_IP_EBP_40) { x_SUnMapLS_IP_EBP_x(context,40); }
* The SEGPTR is used by the caller! * The SEGPTR is used by the caller!
*/ */
REGS_ENTRYPOINT(AllocMappedBuffer) void WINAPI REGS_FUNC(AllocMappedBuffer)( CONTEXT *context )
{ {
HGLOBAL handle = GlobalAlloc(0, EDI_reg(context) + 8); HGLOBAL handle = GlobalAlloc(0, EDI_reg(context) + 8);
DWORD *buffer = (DWORD *)GlobalLock(handle); DWORD *buffer = (DWORD *)GlobalLock(handle);
@ -736,7 +734,7 @@ REGS_ENTRYPOINT(AllocMappedBuffer)
* Input: EDI register: pointer to buffer * Input: EDI register: pointer to buffer
*/ */
REGS_ENTRYPOINT(FreeMappedBuffer) void WINAPI REGS_FUNC(FreeMappedBuffer)( CONTEXT *context )
{ {
if (EDI_reg(context)) if (EDI_reg(context))
{ {

View file

@ -180,7 +180,7 @@ type win32
172 stdcall NtQueryValueKey(long long long long long long) NtQueryValueKey 172 stdcall NtQueryValueKey(long long long long long long) NtQueryValueKey
173 stub NtQueryVirtualMemory 173 stub NtQueryVirtualMemory
174 stub NtQueryVolumeInformationFile 174 stub NtQueryVolumeInformationFile
175 register NtRaiseException() NtRaiseException 175 register NtRaiseException(ptr ptr long) NtRaiseException
176 stub NtRaiseHardError 176 stub NtRaiseHardError
177 stdcall NtReadFile(long long long long long long long long long) NtReadFile 177 stdcall NtReadFile(long long long long long long long long long) NtReadFile
178 stub NtReadRequestData 178 stub NtReadRequestData
@ -469,7 +469,7 @@ type win32
461 stub RtlQuerySecurityObject 461 stub RtlQuerySecurityObject
462 stub RtlQueryTagHeap 462 stub RtlQueryTagHeap
463 stub RtlQueryTimeZoneInformation 463 stub RtlQueryTimeZoneInformation
464 register RtlRaiseException() RtlRaiseException 464 register RtlRaiseException(ptr) RtlRaiseException
465 stdcall RtlRaiseStatus(long) RtlRaiseStatus 465 stdcall RtlRaiseStatus(long) RtlRaiseStatus
466 stub RtlRandom 466 stub RtlRandom
467 stub RtlReAllocateHeap 467 stub RtlReAllocateHeap
@ -523,7 +523,7 @@ type win32
515 stdcall RtlUnicodeToOemN(ptr long ptr ptr long) RtlUnicodeToOemN 515 stdcall RtlUnicodeToOemN(ptr long ptr ptr long) RtlUnicodeToOemN
516 stub RtlUniform 516 stub RtlUniform
517 stub RtlUnlockHeap 517 stub RtlUnlockHeap
518 register RtlUnwind() RtlUnwind 518 register RtlUnwind(ptr ptr ptr long) RtlUnwind
519 stub RtlUpcaseUnicodeChar 519 stub RtlUpcaseUnicodeChar
520 stdcall RtlUpcaseUnicodeString(ptr ptr long) RtlUpcaseUnicodeString 520 stdcall RtlUpcaseUnicodeString(ptr ptr long) RtlUpcaseUnicodeString
521 stub RtlUpcaseUnicodeStringToAnsiString 521 stub RtlUpcaseUnicodeStringToAnsiString

View file

@ -248,11 +248,11 @@ UINT WINAPI ThunkConnect32(
* QT_Thunk (KERNEL32) * QT_Thunk (KERNEL32)
* *
* The target address is in EDX. * The target address is in EDX.
* The 16 bit arguments start at ESP+4. * The 16 bit arguments start at ESP.
* The number of 16bit argumentbytes is EBP-ESP-0x44 (68 Byte thunksetup). * The number of 16bit argument bytes is EBP-ESP-0x40 (64 Byte thunksetup).
* [ok] * [ok]
*/ */
REGS_ENTRYPOINT(QT_Thunk) void WINAPI REGS_FUNC(QT_Thunk)( CONTEXT *context )
{ {
CONTEXT context16; CONTEXT context16;
DWORD argsize; DWORD argsize;
@ -265,10 +265,10 @@ REGS_ENTRYPOINT(QT_Thunk)
EBP_reg(&context16) = OFFSETOF( thdb->cur_stack ) EBP_reg(&context16) = OFFSETOF( thdb->cur_stack )
+ (WORD)&((STACK16FRAME*)0)->bp; + (WORD)&((STACK16FRAME*)0)->bp;
argsize = EBP_reg(context)-ESP_reg(context)-0x44; argsize = EBP_reg(context)-ESP_reg(context)-0x40;
memcpy( ((LPBYTE)THREAD_STACK16(thdb))-argsize, memcpy( ((LPBYTE)THREAD_STACK16(thdb))-argsize,
(LPBYTE)ESP_reg(context)+4, argsize ); (LPBYTE)ESP_reg(context), argsize );
EAX_reg(context) = Callbacks->CallRegisterShortProc( &context16, argsize ); EAX_reg(context) = Callbacks->CallRegisterShortProc( &context16, argsize );
EDX_reg(context) = HIWORD(EAX_reg(context)); EDX_reg(context) = HIWORD(EAX_reg(context));
@ -316,15 +316,12 @@ REGS_ENTRYPOINT(QT_Thunk)
* ... (unclear) * ... (unclear)
* (ebp-64) * (ebp-64)
* *
* ESP is EBP-68 on return. * ESP is EBP-64 after return.
* *
*/ */
REGS_ENTRYPOINT(FT_Prolog) void WINAPI REGS_FUNC(FT_Prolog)( CONTEXT *context )
{ {
/* Pop return address to thunk code */
EIP_reg(context) = STACK32_POP(context);
/* Build stack frame */ /* Build stack frame */
STACK32_PUSH(context, EBP_reg(context)); STACK32_PUSH(context, EBP_reg(context));
EBP_reg(context) = ESP_reg(context); EBP_reg(context) = ESP_reg(context);
@ -342,9 +339,6 @@ REGS_ENTRYPOINT(FT_Prolog)
*(DWORD *)(EBP_reg(context) - 48) = EAX_reg(context); *(DWORD *)(EBP_reg(context) - 48) = EAX_reg(context);
*(DWORD *)(EBP_reg(context) - 52) = EDX_reg(context); *(DWORD *)(EBP_reg(context) - 52) = EDX_reg(context);
/* Push return address back onto stack */
STACK32_PUSH(context, EIP_reg(context));
} }
/********************************************************************** /**********************************************************************
@ -368,7 +362,7 @@ REGS_ENTRYPOINT(FT_Prolog)
* sufficient ... * sufficient ...
*/ */
REGS_ENTRYPOINT(FT_Thunk) void WINAPI REGS_FUNC(FT_Thunk)( CONTEXT *context )
{ {
DWORD mapESPrelative = *(DWORD *)(EBP_reg(context) - 20); DWORD mapESPrelative = *(DWORD *)(EBP_reg(context) - 20);
DWORD callTarget = *(DWORD *)(EBP_reg(context) - 52); DWORD callTarget = *(DWORD *)(EBP_reg(context) - 52);
@ -385,9 +379,9 @@ REGS_ENTRYPOINT(FT_Thunk)
EBP_reg(&context16) = OFFSETOF( thdb->cur_stack ) EBP_reg(&context16) = OFFSETOF( thdb->cur_stack )
+ (WORD)&((STACK16FRAME*)0)->bp; + (WORD)&((STACK16FRAME*)0)->bp;
argsize = EBP_reg(context)-ESP_reg(context)-0x44; argsize = EBP_reg(context)-ESP_reg(context)-0x40;
newstack = ((LPBYTE)THREAD_STACK16(thdb))-argsize; newstack = ((LPBYTE)THREAD_STACK16(thdb))-argsize;
oldstack = (LPBYTE)ESP_reg(context)+4; oldstack = (LPBYTE)ESP_reg(context);
memcpy( newstack, oldstack, argsize ); memcpy( newstack, oldstack, argsize );
@ -435,25 +429,23 @@ static void FT_Exit(CONTEXT *context, int nPopArgs)
EIP_reg(context) = STACK32_POP(context); EIP_reg(context) = STACK32_POP(context);
/* Remove arguments */ /* Remove arguments */
ESP_reg(context) += nPopArgs; ESP_reg(context) += nPopArgs;
/* Push return address back onto stack */
STACK32_PUSH(context, EIP_reg(context));
} }
REGS_ENTRYPOINT(FT_Exit0) { FT_Exit(context, 0); } void WINAPI REGS_FUNC(FT_Exit0)(CONTEXT *context) { FT_Exit(context, 0); }
REGS_ENTRYPOINT(FT_Exit4) { FT_Exit(context, 4); } void WINAPI REGS_FUNC(FT_Exit4)(CONTEXT *context) { FT_Exit(context, 4); }
REGS_ENTRYPOINT(FT_Exit8) { FT_Exit(context, 8); } void WINAPI REGS_FUNC(FT_Exit8)(CONTEXT *context) { FT_Exit(context, 8); }
REGS_ENTRYPOINT(FT_Exit12) { FT_Exit(context, 12); } void WINAPI REGS_FUNC(FT_Exit12)(CONTEXT *context) { FT_Exit(context, 12); }
REGS_ENTRYPOINT(FT_Exit16) { FT_Exit(context, 16); } void WINAPI REGS_FUNC(FT_Exit16)(CONTEXT *context) { FT_Exit(context, 16); }
REGS_ENTRYPOINT(FT_Exit20) { FT_Exit(context, 20); } void WINAPI REGS_FUNC(FT_Exit20)(CONTEXT *context) { FT_Exit(context, 20); }
REGS_ENTRYPOINT(FT_Exit24) { FT_Exit(context, 24); } void WINAPI REGS_FUNC(FT_Exit24)(CONTEXT *context) { FT_Exit(context, 24); }
REGS_ENTRYPOINT(FT_Exit28) { FT_Exit(context, 28); } void WINAPI REGS_FUNC(FT_Exit28)(CONTEXT *context) { FT_Exit(context, 28); }
REGS_ENTRYPOINT(FT_Exit32) { FT_Exit(context, 32); } void WINAPI REGS_FUNC(FT_Exit32)(CONTEXT *context) { FT_Exit(context, 32); }
REGS_ENTRYPOINT(FT_Exit36) { FT_Exit(context, 36); } void WINAPI REGS_FUNC(FT_Exit36)(CONTEXT *context) { FT_Exit(context, 36); }
REGS_ENTRYPOINT(FT_Exit40) { FT_Exit(context, 40); } void WINAPI REGS_FUNC(FT_Exit40)(CONTEXT *context) { FT_Exit(context, 40); }
REGS_ENTRYPOINT(FT_Exit44) { FT_Exit(context, 44); } void WINAPI REGS_FUNC(FT_Exit44)(CONTEXT *context) { FT_Exit(context, 44); }
REGS_ENTRYPOINT(FT_Exit48) { FT_Exit(context, 48); } void WINAPI REGS_FUNC(FT_Exit48)(CONTEXT *context) { FT_Exit(context, 48); }
REGS_ENTRYPOINT(FT_Exit52) { FT_Exit(context, 52); } void WINAPI REGS_FUNC(FT_Exit52)(CONTEXT *context) { FT_Exit(context, 52); }
REGS_ENTRYPOINT(FT_Exit56) { FT_Exit(context, 56); } void WINAPI REGS_FUNC(FT_Exit56)(CONTEXT *context) { FT_Exit(context, 56); }
/********************************************************************** /**********************************************************************
@ -560,7 +552,7 @@ DWORD WINAPI ThunkInitLS(
* (Those two values should be equal anyway ...?) * (Those two values should be equal anyway ...?)
* *
*/ */
REGS_ENTRYPOINT(Common32ThkLS) void WINAPI REGS_FUNC(Common32ThkLS)( CONTEXT *context )
{ {
CONTEXT context16; CONTEXT context16;
DWORD argsize; DWORD argsize;
@ -581,15 +573,12 @@ REGS_ENTRYPOINT(Common32ThkLS)
argsize = 6 * 4; argsize = 6 * 4;
memcpy( ((LPBYTE)THREAD_STACK16(thdb))-argsize, memcpy( ((LPBYTE)THREAD_STACK16(thdb))-argsize,
(LPBYTE)ESP_reg(context)+4, argsize ); (LPBYTE)ESP_reg(context), argsize );
EAX_reg(context) = Callbacks->CallRegisterLongProc(&context16, argsize + 32); EAX_reg(context) = Callbacks->CallRegisterLongProc(&context16, argsize + 32);
/* Clean up caller's stack frame */ /* Clean up caller's stack frame */
EIP_reg(context) = STACK32_POP(context);
ESP_reg(context) += argsize; ESP_reg(context) += argsize;
STACK32_PUSH(context, EIP_reg(context));
} }
/*********************************************************************** /***********************************************************************
@ -619,7 +608,7 @@ REGS_ENTRYPOINT(Common32ThkLS)
* (Note that this function seems only to be used for * (Note that this function seems only to be used for
* OLECLI32 -> OLECLI and OLESVR32 -> OLESVR thunking.) * OLECLI32 -> OLECLI and OLESVR32 -> OLESVR thunking.)
*/ */
REGS_ENTRYPOINT(OT_32ThkLSF) void WINAPI REGS_FUNC(OT_32ThkLSF)( CONTEXT *context )
{ {
CONTEXT context16; CONTEXT context16;
DWORD argsize; DWORD argsize;
@ -632,14 +621,14 @@ REGS_ENTRYPOINT(OT_32ThkLSF)
EBP_reg(&context16) = OFFSETOF( thdb->cur_stack ) EBP_reg(&context16) = OFFSETOF( thdb->cur_stack )
+ (WORD)&((STACK16FRAME*)0)->bp; + (WORD)&((STACK16FRAME*)0)->bp;
argsize = 2 * *(WORD *)(ESP_reg(context) + 4) + 2; argsize = 2 * *(WORD *)ESP_reg(context) + 2;
memcpy( ((LPBYTE)THREAD_STACK16(thdb))-argsize, memcpy( ((LPBYTE)THREAD_STACK16(thdb))-argsize,
(LPBYTE)ESP_reg(context)+4, argsize ); (LPBYTE)ESP_reg(context), argsize );
EAX_reg(context) = Callbacks->CallRegisterShortProc(&context16, argsize); EAX_reg(context) = Callbacks->CallRegisterShortProc(&context16, argsize);
memcpy( (LPBYTE)ESP_reg(context)+4, memcpy( (LPBYTE)ESP_reg(context),
((LPBYTE)THREAD_STACK16(thdb))-argsize, argsize ); ((LPBYTE)THREAD_STACK16(thdb))-argsize, argsize );
} }
@ -723,11 +712,12 @@ LPVOID WINAPI ThunkInitLSF(
* (this is where the FT_Prolog call stub gets written to) * (this is where the FT_Prolog call stub gets written to)
* *
* Note: The two DWORD arguments get popped from the stack. * Note: The two DWORD arguments get popped from the stack.
* The first arg is popped by the relay code and stored in EIP_reg.
* *
*/ */
REGS_ENTRYPOINT(FT_PrologPrime) void WINAPI REGS_FUNC(FT_PrologPrime)( CONTEXT *context )
{ {
DWORD targetTableOffset = STACK32_POP(context); DWORD targetTableOffset = EIP_reg(context);
LPBYTE relayCode = (LPBYTE)STACK32_POP(context); LPBYTE relayCode = (LPBYTE)STACK32_POP(context);
DWORD *targetTable = *(DWORD **)(relayCode+targetTableOffset); DWORD *targetTable = *(DWORD **)(relayCode+targetTableOffset);
DWORD targetNr = LOBYTE(ECX_reg(context)); DWORD targetNr = LOBYTE(ECX_reg(context));
@ -737,7 +727,7 @@ REGS_ENTRYPOINT(FT_PrologPrime)
/* We should actually call the relay code now, */ /* We should actually call the relay code now, */
/* but we skip it and go directly to FT_Prolog */ /* but we skip it and go directly to FT_Prolog */
EDX_reg(context) = targetTable[targetNr]; EDX_reg(context) = targetTable[targetNr];
__regs_FT_Prolog(context); REGS_FUNC(FT_Prolog)(context);
} }
/*********************************************************************** /***********************************************************************
@ -751,7 +741,7 @@ REGS_ENTRYPOINT(FT_PrologPrime)
* EAX start of relay code * EAX start of relay code
* *
*/ */
REGS_ENTRYPOINT(QT_ThunkPrime) void WINAPI REGS_FUNC(QT_ThunkPrime)( CONTEXT *context )
{ {
DWORD targetTableOffset = EDX_reg(context); DWORD targetTableOffset = EDX_reg(context);
LPBYTE relayCode = (LPBYTE)EAX_reg(context); LPBYTE relayCode = (LPBYTE)EAX_reg(context);
@ -763,7 +753,7 @@ REGS_ENTRYPOINT(QT_ThunkPrime)
/* We should actually call the relay code now, */ /* We should actually call the relay code now, */
/* but we skip it and go directly to QT_Thunk */ /* but we skip it and go directly to QT_Thunk */
EDX_reg(context) = targetTable[targetNr]; EDX_reg(context) = targetTable[targetNr];
__regs_QT_Thunk(context); REGS_FUNC(QT_Thunk)(context);
} }
/*********************************************************************** /***********************************************************************
@ -877,15 +867,15 @@ DWORD WINAPIV SSCall(
/********************************************************************** /**********************************************************************
* W32S_BackTo32 (KERNEL32.51) * W32S_BackTo32 (KERNEL32.51)
*/ */
REGS_ENTRYPOINT(W32S_BackTo32) void WINAPI REGS_FUNC(W32S_BackTo32)( CONTEXT *context )
{ {
LPDWORD stack = (LPDWORD)ESP_reg( context ); LPDWORD stack = (LPDWORD)ESP_reg( context );
FARPROC proc = (FARPROC) stack[0]; FARPROC proc = (FARPROC)EIP_reg(context);
EAX_reg( context ) = proc( stack[2], stack[3], stack[4], stack[5], stack[6], EAX_reg( context ) = proc( stack[1], stack[2], stack[3], stack[4], stack[5],
stack[7], stack[8], stack[9], stack[10], stack[11] ); stack[6], stack[7], stack[8], stack[9], stack[10] );
EIP_reg( context ) = stack[1]; EIP_reg( context ) = STACK32_POP(context);
} }
/********************************************************************** /**********************************************************************
@ -1021,7 +1011,7 @@ HANDLE WINAPI WOWHandle32(
/*********************************************************************** /***********************************************************************
* K32Thk1632Prolog (KERNEL32.492) * K32Thk1632Prolog (KERNEL32.492)
*/ */
REGS_ENTRYPOINT(K32Thk1632Prolog) void WINAPI REGS_FUNC(K32Thk1632Prolog)( CONTEXT *context )
{ {
LPBYTE code = (LPBYTE)EIP_reg(context) - 5; LPBYTE code = (LPBYTE)EIP_reg(context) - 5;
@ -1054,7 +1044,7 @@ REGS_ENTRYPOINT(K32Thk1632Prolog)
THDB *thdb = THREAD_Current(); THDB *thdb = THREAD_Current();
DWORD argSize = EBP_reg(context) - ESP_reg(context); DWORD argSize = EBP_reg(context) - ESP_reg(context);
char *stack16 = (char *)ESP_reg(context); char *stack16 = (char *)ESP_reg(context) - 4;
char *stack32 = (char *)thdb->cur_stack - argSize; char *stack32 = (char *)thdb->cur_stack - argSize;
STACK16FRAME *frame16 = (STACK16FRAME *)stack16 - 1; STACK16FRAME *frame16 = (STACK16FRAME *)stack16 - 1;
@ -1068,7 +1058,7 @@ REGS_ENTRYPOINT(K32Thk1632Prolog)
memcpy(stack32, stack16, argSize); memcpy(stack32, stack16, argSize);
thdb->cur_stack = PTR_SEG_OFF_TO_SEGPTR(stackSel, (DWORD)frame16 - stackBase); thdb->cur_stack = PTR_SEG_OFF_TO_SEGPTR(stackSel, (DWORD)frame16 - stackBase);
ESP_reg(context) = (DWORD)stack32; ESP_reg(context) = (DWORD)stack32 + 4;
EBP_reg(context) = ESP_reg(context) + argSize; EBP_reg(context) = ESP_reg(context) + argSize;
TRACE_(thunk)("after SYSTHUNK hack: EBP: %08lx ESP: %08lx cur_stack: %08lx\n", TRACE_(thunk)("after SYSTHUNK hack: EBP: %08lx ESP: %08lx cur_stack: %08lx\n",
@ -1081,7 +1071,7 @@ REGS_ENTRYPOINT(K32Thk1632Prolog)
/*********************************************************************** /***********************************************************************
* K32Thk1632Epilog (KERNEL32.491) * K32Thk1632Epilog (KERNEL32.491)
*/ */
REGS_ENTRYPOINT(K32Thk1632Epilog) void WINAPI REGS_FUNC(K32Thk1632Epilog)( CONTEXT *context )
{ {
LPBYTE code = (LPBYTE)EIP_reg(context) - 13; LPBYTE code = (LPBYTE)EIP_reg(context) - 13;

View file

@ -54,7 +54,7 @@ LPVOID WINAPI GetPK16SysVar(void)
/********************************************************************** /**********************************************************************
* CommonUnimpStub (KERNEL32.17) * CommonUnimpStub (KERNEL32.17)
*/ */
REGS_ENTRYPOINT(CommonUnimpStub) void WINAPI REGS_FUNC(CommonUnimpStub)( CONTEXT *context )
{ {
if (EAX_reg(context)) if (EAX_reg(context))
MESSAGE( "*** Unimplemented Win32 API: %s\n", (LPSTR)EAX_reg(context) ); MESSAGE( "*** Unimplemented Win32 API: %s\n", (LPSTR)EAX_reg(context) );