From 2c7a24805532fcb00a304fe456e342084de494ee Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Sat, 7 May 2005 18:25:51 +0000 Subject: [PATCH] Converted all the kernel32 register functions to the DEFINE_REGS_ENTRYPOINT mechanism. --- dlls/kernel/heap.c | 11 ++- dlls/kernel/kernel32.spec | 130 ++++++++++++------------ dlls/kernel/krnl386.exe.spec | 4 +- dlls/kernel/ne_module.c | 20 +++- dlls/kernel/selector.c | 183 +++++++++++++--------------------- dlls/kernel/thunk.c | 187 ++++++++++++++++++----------------- dlls/kernel/vxd.c | 5 +- 7 files changed, 263 insertions(+), 277 deletions(-) diff --git a/dlls/kernel/heap.c b/dlls/kernel/heap.c index 4c441368e8a..eb1fa9b10e9 100644 --- a/dlls/kernel/heap.c +++ b/dlls/kernel/heap.c @@ -980,7 +980,7 @@ BOOL WINAPI LocalUnlock( * * The SEGPTR is used by the caller! */ -void AllocMappedBuffer( CONTEXT86 *context ) +void WINAPI __regs_AllocMappedBuffer( CONTEXT86 *context ) { HGLOBAL handle = GlobalAlloc(0, context->Edi + 8); DWORD *buffer = (DWORD *)GlobalLock(handle); @@ -1004,7 +1004,9 @@ void AllocMappedBuffer( CONTEXT86 *context ) context->Edi = (DWORD)(buffer + 2); } } - +#ifdef DEFINE_REGS_ENTRYPOINT +DEFINE_REGS_ENTRYPOINT( AllocMappedBuffer, 0, 0 ); +#endif /********************************************************************** * FreeMappedBuffer (KERNEL32.39) @@ -1013,7 +1015,7 @@ void AllocMappedBuffer( CONTEXT86 *context ) * * Input: EDI register: pointer to buffer */ -void FreeMappedBuffer( CONTEXT86 *context ) +void WINAPI __regs_FreeMappedBuffer( CONTEXT86 *context ) { if (context->Edi) { @@ -1025,6 +1027,9 @@ void FreeMappedBuffer( CONTEXT86 *context ) GlobalFree((HGLOBAL)buffer[0]); } } +#ifdef DEFINE_REGS_ENTRYPOINT +DEFINE_REGS_ENTRYPOINT( FreeMappedBuffer, 0, 0 ); +#endif /*********************************************************************** * GlobalMemoryStatusEx (KERNEL32.@) diff --git a/dlls/kernel/kernel32.spec b/dlls/kernel/kernel32.spec index 566469d64ed..1da01f01d68 100644 --- a/dlls/kernel/kernel32.spec +++ b/dlls/kernel/kernel32.spec @@ -8,15 +8,15 @@ # - code generated by the MS Thunk Compiler # - symbols exported by the Oct 94 beta version of kernel32.dll - 1 stdcall -register -i386 VxDCall0(long) VxDCall - 2 stdcall -register -i386 VxDCall1(long) VxDCall - 3 stdcall -register -i386 VxDCall2(long) VxDCall - 4 stdcall -register -i386 VxDCall3(long) VxDCall - 5 stdcall -register -i386 VxDCall4(long) VxDCall - 6 stdcall -register -i386 VxDCall5(long) VxDCall - 7 stdcall -register -i386 VxDCall6(long) VxDCall - 8 stdcall -register -i386 VxDCall7(long) VxDCall - 9 stdcall -register -i386 VxDCall8(long) VxDCall + 1 stdcall -i386 VxDCall0(long) VxDCall + 2 stdcall -i386 VxDCall1(long) VxDCall + 3 stdcall -i386 VxDCall2(long) VxDCall + 4 stdcall -i386 VxDCall3(long) VxDCall + 5 stdcall -i386 VxDCall4(long) VxDCall + 6 stdcall -i386 VxDCall5(long) VxDCall + 7 stdcall -i386 VxDCall6(long) VxDCall + 8 stdcall -i386 VxDCall7(long) VxDCall + 9 stdcall -i386 VxDCall8(long) VxDCall 10 stdcall k32CharToOemA(str ptr) 11 stdcall k32CharToOemBuffA(str ptr long) 12 stdcall k32OemToCharA(ptr ptr) @@ -24,7 +24,7 @@ 14 stdcall k32LoadStringA(long long ptr long) 15 varargs k32wsprintfA(str str) 16 stdcall k32wvsprintfA(ptr str ptr) - 17 stdcall -register -i386 CommonUnimpStub() + 17 stdcall -i386 CommonUnimpStub() 18 stdcall GetProcessDword(long long) 19 stub ThunkTheTemplateHandle 20 stdcall DosFileHandleToWin32Handle(long) @@ -45,20 +45,20 @@ 35 stdcall LoadLibrary16(str) 36 stdcall FreeLibrary16(long) 37 stdcall GetProcAddress16(long str) WIN32_GetProcAddress16 - 38 stdcall -register -i386 AllocMappedBuffer() - 39 stdcall -register -i386 FreeMappedBuffer() - 40 stdcall -register -i386 OT_32ThkLSF() + 38 stdcall -i386 AllocMappedBuffer() + 39 stdcall -i386 FreeMappedBuffer() + 40 stdcall -i386 OT_32ThkLSF() 41 stdcall ThunkInitLSF(long str long str str) - 42 stdcall -register -i386 LogApiThkLSF(str) + 42 stdcall -i386 LogApiThkLSF(str) 43 stdcall ThunkInitLS(long str long str str) - 44 stdcall -register -i386 LogApiThkSL(str) - 45 stdcall -register -i386 Common32ThkLS() + 44 stdcall -i386 LogApiThkSL(str) + 45 stdcall -i386 Common32ThkLS() 46 stdcall ThunkInitSL(long str long str str) - 47 stdcall -register -i386 LogCBThkSL(str) + 47 stdcall -i386 LogCBThkSL(str) 48 stdcall ReleaseThunkLock(ptr) 49 stdcall RestoreThunkLock(long) - 51 stdcall -register -i386 W32S_BackTo32() + 51 stdcall -i386 W32S_BackTo32() 52 stdcall GetThunkBuff() 53 stdcall GetThunkStuff(str str) 54 stdcall K32WOWCallback16(long long) @@ -96,8 +96,8 @@ 86 stdcall @(ptr) _KERNEL32_86 87 stdcall SSOnBigStack() 88 varargs SSCall(long long ptr) - 89 stdcall -register -i386 FT_PrologPrime() - 90 stdcall -register -i386 QT_ThunkPrime() + 89 stdcall -i386 FT_PrologPrime() + 90 stdcall -i386 QT_ThunkPrime() 91 stdcall PK16FNF(ptr) 92 stdcall GetPK16SysVar() 93 stdcall GetpWin16Lock(ptr) @@ -278,23 +278,23 @@ @ stdcall ExitThread(long) @ stdcall ExpandEnvironmentStringsA(str ptr long) @ stdcall ExpandEnvironmentStringsW(wstr ptr long) -@ stdcall -register -i386 FT_Exit0() -@ stdcall -register -i386 FT_Exit12() -@ stdcall -register -i386 FT_Exit16() -@ stdcall -register -i386 FT_Exit20() -@ stdcall -register -i386 FT_Exit24() -@ stdcall -register -i386 FT_Exit28() -@ stdcall -register -i386 FT_Exit32() -@ stdcall -register -i386 FT_Exit36() -@ stdcall -register -i386 FT_Exit40() -@ stdcall -register -i386 FT_Exit44() -@ stdcall -register -i386 FT_Exit48() -@ stdcall -register -i386 FT_Exit4() -@ stdcall -register -i386 FT_Exit52() -@ stdcall -register -i386 FT_Exit56() -@ stdcall -register -i386 FT_Exit8() -@ stdcall -register -i386 FT_Prolog() -@ stdcall -register -i386 FT_Thunk() +@ stdcall -i386 FT_Exit0() +@ stdcall -i386 FT_Exit12() +@ stdcall -i386 FT_Exit16() +@ stdcall -i386 FT_Exit20() +@ stdcall -i386 FT_Exit24() +@ stdcall -i386 FT_Exit28() +@ stdcall -i386 FT_Exit32() +@ stdcall -i386 FT_Exit36() +@ stdcall -i386 FT_Exit40() +@ stdcall -i386 FT_Exit44() +@ stdcall -i386 FT_Exit48() +@ stdcall -i386 FT_Exit4() +@ stdcall -i386 FT_Exit52() +@ stdcall -i386 FT_Exit56() +@ stdcall -i386 FT_Exit8() +@ stdcall -i386 FT_Prolog() +@ stdcall -i386 FT_Thunk() @ stdcall FatalAppExitA(long str) @ stdcall FatalAppExitW(long wstr) @ stdcall FatalExit(long) @@ -590,8 +590,8 @@ @ stdcall IsValidCodePage(long) @ stdcall IsValidLanguageGroup(long long) @ stdcall IsValidLocale(long long) -@ stdcall -register -i386 K32Thk1632Epilog() -@ stdcall -register -i386 K32Thk1632Prolog() +@ stdcall -i386 K32Thk1632Epilog() +@ stdcall -i386 K32Thk1632Prolog() @ stdcall LCMapStringA(long long str long ptr long) @ stdcall LCMapStringW(long long wstr long ptr long) @ stdcall LeaveCriticalSection(ptr) ntdll.RtlLeaveCriticalSection @@ -616,10 +616,10 @@ @ stdcall LockFileEx(long long long long long ptr) @ stdcall LockResource(long) @ stdcall MakeCriticalSectionGlobal(ptr) -@ stdcall -register -i386 MapHInstLS() -@ stdcall -register -i386 MapHInstLS_PN() -@ stdcall -register -i386 MapHInstSL() -@ stdcall -register -i386 MapHInstSL_PN() +@ stdcall -i386 MapHInstLS() +@ stdcall -i386 MapHInstLS_PN() +@ stdcall -i386 MapHInstSL() +@ stdcall -i386 MapHInstSL_PN() @ stdcall MapHModuleLS(long) @ stdcall MapHModuleSL(long) @ stdcall MapLS(ptr) @@ -666,7 +666,7 @@ @ stdcall Process32NextW (ptr ptr) @ stdcall PulseEvent(long) @ stdcall PurgeComm(long long) -@ stdcall -register -i386 QT_Thunk() +@ stdcall -i386 QT_Thunk() @ stdcall QueryDosDeviceA(str ptr long) @ stdcall QueryDosDeviceW(wstr ptr long) @ stub QueryInformationJobObject @@ -713,26 +713,26 @@ @ stdcall RtlMoveMemory(ptr ptr long) ntdll.RtlMoveMemory @ stdcall RtlUnwind(ptr ptr ptr long) ntdll.RtlUnwind @ stdcall RtlZeroMemory(ptr long) ntdll.RtlZeroMemory -@ stdcall -register -i386 SMapLS() -@ stdcall -register -i386 SMapLS_IP_EBP_12() -@ stdcall -register -i386 SMapLS_IP_EBP_16() -@ stdcall -register -i386 SMapLS_IP_EBP_20() -@ stdcall -register -i386 SMapLS_IP_EBP_24() -@ stdcall -register -i386 SMapLS_IP_EBP_28() -@ stdcall -register -i386 SMapLS_IP_EBP_32() -@ stdcall -register -i386 SMapLS_IP_EBP_36() -@ stdcall -register -i386 SMapLS_IP_EBP_40() -@ stdcall -register -i386 SMapLS_IP_EBP_8() -@ stdcall -register -i386 SUnMapLS() -@ stdcall -register -i386 SUnMapLS_IP_EBP_12() -@ stdcall -register -i386 SUnMapLS_IP_EBP_16() -@ stdcall -register -i386 SUnMapLS_IP_EBP_20() -@ stdcall -register -i386 SUnMapLS_IP_EBP_24() -@ stdcall -register -i386 SUnMapLS_IP_EBP_28() -@ stdcall -register -i386 SUnMapLS_IP_EBP_32() -@ stdcall -register -i386 SUnMapLS_IP_EBP_36() -@ stdcall -register -i386 SUnMapLS_IP_EBP_40() -@ stdcall -register -i386 SUnMapLS_IP_EBP_8() +@ stdcall -i386 SMapLS() +@ stdcall -i386 SMapLS_IP_EBP_8() +@ stdcall -i386 SMapLS_IP_EBP_12() +@ stdcall -i386 SMapLS_IP_EBP_16() +@ stdcall -i386 SMapLS_IP_EBP_20() +@ stdcall -i386 SMapLS_IP_EBP_24() +@ stdcall -i386 SMapLS_IP_EBP_28() +@ stdcall -i386 SMapLS_IP_EBP_32() +@ stdcall -i386 SMapLS_IP_EBP_36() +@ stdcall -i386 SMapLS_IP_EBP_40() +@ stdcall -i386 SUnMapLS() +@ stdcall -i386 SUnMapLS_IP_EBP_8() +@ stdcall -i386 SUnMapLS_IP_EBP_12() +@ stdcall -i386 SUnMapLS_IP_EBP_16() +@ stdcall -i386 SUnMapLS_IP_EBP_20() +@ stdcall -i386 SUnMapLS_IP_EBP_24() +@ stdcall -i386 SUnMapLS_IP_EBP_28() +@ stdcall -i386 SUnMapLS_IP_EBP_32() +@ stdcall -i386 SUnMapLS_IP_EBP_36() +@ stdcall -i386 SUnMapLS_IP_EBP_40() @ stdcall ScrollConsoleScreenBufferA(long ptr ptr ptr ptr) @ stdcall ScrollConsoleScreenBufferW(long ptr ptr ptr ptr) @ stdcall SearchPathA(str str str long ptr ptr) @@ -838,7 +838,7 @@ @ stdcall UTRegister(long str str str ptr ptr ptr) @ stdcall UTUnRegister(long) @ stdcall UnMapLS(long) -@ stdcall -register -i386 UnMapSLFixArray(long long) +@ stdcall -i386 UnMapSLFixArray(long long) @ stdcall UnhandledExceptionFilter(ptr) @ stdcall UninitializeCriticalSection(ptr) @ stdcall UnlockFile(long long long long long) diff --git a/dlls/kernel/krnl386.exe.spec b/dlls/kernel/krnl386.exe.spec index a1dc1a2b6eb..8ad235c29ba 100644 --- a/dlls/kernel/krnl386.exe.spec +++ b/dlls/kernel/krnl386.exe.spec @@ -374,8 +374,8 @@ 469 stub WOAGimmeTitle 470 stub WOADestroyConsole 471 pascal GetCurrentProcessId() GetCurrentProcessId -472 pascal -register MapHInstLS() MapHInstLS -473 pascal -register MapHInstSL() MapHInstSL +472 pascal -register MapHInstLS() __regs_MapHInstLS +473 pascal -register MapHInstSL() __regs_MapHInstSL 474 pascal CloseW32Handle(long) CloseHandle 475 pascal -ret16 GetTEBSelectorFS() GetTEBSelectorFS16 476 pascal ConvertToGlobalHandle(long) ConvertToGlobalHandle diff --git a/dlls/kernel/ne_module.c b/dlls/kernel/ne_module.c index 5565fdd3127..6c47822988f 100644 --- a/dlls/kernel/ne_module.c +++ b/dlls/kernel/ne_module.c @@ -2263,32 +2263,44 @@ HMODULE WINAPI MapHModuleSL(HMODULE16 hmod) * MapHInstLS (KERNEL32.@) * MapHInstLS (KERNEL.472) */ -void MapHInstLS( CONTEXT86 *context ) +void WINAPI __regs_MapHInstLS( CONTEXT86 *context ) { context->Eax = MapHModuleLS( (HMODULE)context->Eax ); } +#ifdef DEFINE_REGS_ENTRYPOINT +DEFINE_REGS_ENTRYPOINT( MapHInstLS, 0, 0 ); +#endif /*************************************************************************** * MapHInstSL (KERNEL32.@) * MapHInstSL (KERNEL.473) */ -void MapHInstSL( CONTEXT86 *context ) +void WINAPI __regs_MapHInstSL( CONTEXT86 *context ) { context->Eax = (DWORD)MapHModuleSL( context->Eax ); } +#ifdef DEFINE_REGS_ENTRYPOINT +DEFINE_REGS_ENTRYPOINT( MapHInstSL, 0, 0 ); +#endif /*************************************************************************** * MapHInstLS_PN (KERNEL32.@) */ -void MapHInstLS_PN( CONTEXT86 *context ) +void WINAPI __regs_MapHInstLS_PN( CONTEXT86 *context ) { if (context->Eax) context->Eax = MapHModuleLS( (HMODULE)context->Eax ); } +#ifdef DEFINE_REGS_ENTRYPOINT +DEFINE_REGS_ENTRYPOINT( MapHInstLS_PN, 0, 0 ); +#endif /*************************************************************************** * MapHInstSL_PN (KERNEL32.@) */ -void MapHInstSL_PN( CONTEXT86 *context ) +void WINAPI __regs_MapHInstSL_PN( CONTEXT86 *context ) { if (context->Eax) context->Eax = (DWORD)MapHModuleSL( context->Eax ); } +#ifdef DEFINE_REGS_ENTRYPOINT +DEFINE_REGS_ENTRYPOINT( MapHInstSL_PN, 0, 0 ); +#endif diff --git a/dlls/kernel/selector.c b/dlls/kernel/selector.c index d5f21cf83da..965f5a570b1 100644 --- a/dlls/kernel/selector.c +++ b/dlls/kernel/selector.c @@ -564,11 +564,13 @@ LPVOID WINAPI MapSLFix( SEGPTR sptr ) /*********************************************************************** * UnMapSLFixArray (KERNEL32.@) */ - -void UnMapSLFixArray( SEGPTR sptr[], INT length, CONTEXT86 *context ) +void WINAPI __regs_UnMapSLFixArray( SEGPTR sptr[], INT length, CONTEXT86 *context ) { /* Must not change EAX, hence defined as 'register' function */ } +#ifdef DEFINE_REGS_ENTRYPOINT +DEFINE_REGS_ENTRYPOINT( UnMapSLFixArray, 8, 8 ); +#endif /*********************************************************************** * GetThreadSelectorEntry (KERNEL32.@) @@ -637,77 +639,12 @@ BOOL WINAPI GetThreadSelectorEntry( HANDLE hthread, DWORD sel, LPLDT_ENTRY ldten } -/********************************************************************** - * SMapLS* (KERNEL32) - * These functions map linear pointers at [EBP+xxx] to segmented pointers - * and return them. - * Win95 uses some kind of alias structs, which it stores in [EBP+x] to - * unravel them at SUnMapLS. We just store the segmented pointer there. - */ -static void x_SMapLS_IP_EBP_x(CONTEXT86 *context,int argoff) -{ - DWORD val,ptr; - - val =*(DWORD*)(context->Ebp + argoff); - if (val<0x10000) { - ptr=val; - *(DWORD*)(context->Ebp + argoff) = 0; - } else { - ptr = MapLS((LPVOID)val); - *(DWORD*)(context->Ebp + argoff) = ptr; - } - context->Eax = ptr; -} - -/*********************************************************************** - * SMapLS_IP_EBP_8 (KERNEL32.@) - */ -void SMapLS_IP_EBP_8 (CONTEXT86 *context) {x_SMapLS_IP_EBP_x(context, 8);} - -/*********************************************************************** - * SMapLS_IP_EBP_12 (KERNEL32.@) - */ -void SMapLS_IP_EBP_12(CONTEXT86 *context) {x_SMapLS_IP_EBP_x(context,12);} - -/*********************************************************************** - * SMapLS_IP_EBP_16 (KERNEL32.@) - */ -void SMapLS_IP_EBP_16(CONTEXT86 *context) {x_SMapLS_IP_EBP_x(context,16);} - -/*********************************************************************** - * SMapLS_IP_EBP_20 (KERNEL32.@) - */ -void SMapLS_IP_EBP_20(CONTEXT86 *context) {x_SMapLS_IP_EBP_x(context,20);} - -/*********************************************************************** - * SMapLS_IP_EBP_24 (KERNEL32.@) - */ -void SMapLS_IP_EBP_24(CONTEXT86 *context) {x_SMapLS_IP_EBP_x(context,24);} - -/*********************************************************************** - * SMapLS_IP_EBP_28 (KERNEL32.@) - */ -void SMapLS_IP_EBP_28(CONTEXT86 *context) {x_SMapLS_IP_EBP_x(context,28);} - -/*********************************************************************** - * SMapLS_IP_EBP_32 (KERNEL32.@) - */ -void SMapLS_IP_EBP_32(CONTEXT86 *context) {x_SMapLS_IP_EBP_x(context,32);} - -/*********************************************************************** - * SMapLS_IP_EBP_36 (KERNEL32.@) - */ -void SMapLS_IP_EBP_36(CONTEXT86 *context) {x_SMapLS_IP_EBP_x(context,36);} - -/*********************************************************************** - * SMapLS_IP_EBP_40 (KERNEL32.@) - */ -void SMapLS_IP_EBP_40(CONTEXT86 *context) {x_SMapLS_IP_EBP_x(context,40);} +#ifdef DEFINE_REGS_ENTRYPOINT /*********************************************************************** * SMapLS (KERNEL32.@) */ -void SMapLS( CONTEXT86 *context ) +void WINAPI __regs_SMapLS( CONTEXT86 *context ) { if (HIWORD(context->Eax)) { @@ -717,67 +654,87 @@ void SMapLS( CONTEXT86 *context ) context->Edx = 0; } } +DEFINE_REGS_ENTRYPOINT( SMapLS, 0, 0 ); /*********************************************************************** * SUnMapLS (KERNEL32.@) */ - -void SUnMapLS( CONTEXT86 *context ) +void WINAPI __regs_SUnMapLS( CONTEXT86 *context ) { if (HIWORD(context->Eax)) UnMapLS( (SEGPTR)context->Eax ); } +DEFINE_REGS_ENTRYPOINT( SUnMapLS, 0, 0 ); + + +/*********************************************************************** + * SMapLS_IP_EBP_8 (KERNEL32.@) + * SMapLS_IP_EBP_12 (KERNEL32.@) + * SMapLS_IP_EBP_16 (KERNEL32.@) + * SMapLS_IP_EBP_20 (KERNEL32.@) + * SMapLS_IP_EBP_24 (KERNEL32.@) + * SMapLS_IP_EBP_28 (KERNEL32.@) + * SMapLS_IP_EBP_32 (KERNEL32.@) + * SMapLS_IP_EBP_36 (KERNEL32.@) + * SMapLS_IP_EBP_40 (KERNEL32.@) + * + * These functions map linear pointers at [EBP+xxx] to segmented pointers + * and return them. + * Win95 uses some kind of alias structs, which it stores in [EBP+x] to + * unravel them at SUnMapLS. We just store the segmented pointer there. + */ +#define DEFINE_SMapLS(n) \ +void WINAPI __regs_SMapLS_IP_EBP_ ## n (CONTEXT86 *context) \ +{ \ + SEGPTR *ptr = (SEGPTR *)(context->Ebp + n); \ + if (!HIWORD(*ptr)) \ + { \ + context->Eax = *ptr; \ + *ptr = 0; \ + } \ + else *ptr = context->Eax = MapLS((LPVOID)*ptr); \ +} \ +DEFINE_REGS_ENTRYPOINT( SMapLS_IP_EBP_ ## n, 0, 0 ) + +DEFINE_SMapLS(8); +DEFINE_SMapLS(12); +DEFINE_SMapLS(16); +DEFINE_SMapLS(20); +DEFINE_SMapLS(24); +DEFINE_SMapLS(28); +DEFINE_SMapLS(32); +DEFINE_SMapLS(36); +DEFINE_SMapLS(40); -inline static void x_SUnMapLS_IP_EBP_x(CONTEXT86 *context,int argoff) -{ - SEGPTR *ptr = (SEGPTR *)(context->Ebp + argoff); - if (*ptr) - { - UnMapLS( *ptr ); - *ptr = 0; - } -} /*********************************************************************** * SUnMapLS_IP_EBP_8 (KERNEL32.@) - */ -void SUnMapLS_IP_EBP_8 (CONTEXT86 *context) { x_SUnMapLS_IP_EBP_x(context, 8); } - -/*********************************************************************** * SUnMapLS_IP_EBP_12 (KERNEL32.@) - */ -void SUnMapLS_IP_EBP_12(CONTEXT86 *context) { x_SUnMapLS_IP_EBP_x(context,12); } - -/*********************************************************************** * SUnMapLS_IP_EBP_16 (KERNEL32.@) - */ -void SUnMapLS_IP_EBP_16(CONTEXT86 *context) { x_SUnMapLS_IP_EBP_x(context,16); } - -/*********************************************************************** * SUnMapLS_IP_EBP_20 (KERNEL32.@) - */ -void SUnMapLS_IP_EBP_20(CONTEXT86 *context) { x_SUnMapLS_IP_EBP_x(context,20); } - -/*********************************************************************** * SUnMapLS_IP_EBP_24 (KERNEL32.@) - */ -void SUnMapLS_IP_EBP_24(CONTEXT86 *context) { x_SUnMapLS_IP_EBP_x(context,24); } - -/*********************************************************************** * SUnMapLS_IP_EBP_28 (KERNEL32.@) - */ -void SUnMapLS_IP_EBP_28(CONTEXT86 *context) { x_SUnMapLS_IP_EBP_x(context,28); } - -/*********************************************************************** * SUnMapLS_IP_EBP_32 (KERNEL32.@) - */ -void SUnMapLS_IP_EBP_32(CONTEXT86 *context) { x_SUnMapLS_IP_EBP_x(context,32); } - -/*********************************************************************** * SUnMapLS_IP_EBP_36 (KERNEL32.@) - */ -void SUnMapLS_IP_EBP_36(CONTEXT86 *context) { x_SUnMapLS_IP_EBP_x(context,36); } - -/*********************************************************************** * SUnMapLS_IP_EBP_40 (KERNEL32.@) */ -void SUnMapLS_IP_EBP_40(CONTEXT86 *context) { x_SUnMapLS_IP_EBP_x(context,40); } + +#define DEFINE_SUnMapLS(n) \ +void WINAPI __regs_SUnMapLS_IP_EBP_ ## n (CONTEXT86 *context) \ +{ \ + SEGPTR *ptr = (SEGPTR *)(context->Ebp + n); \ + UnMapLS( *ptr ); \ + *ptr = 0; \ +} \ +DEFINE_REGS_ENTRYPOINT( SUnMapLS_IP_EBP_ ## n, 0, 0 ) + +DEFINE_SUnMapLS(8); +DEFINE_SUnMapLS(12); +DEFINE_SUnMapLS(16); +DEFINE_SUnMapLS(20); +DEFINE_SUnMapLS(24); +DEFINE_SUnMapLS(28); +DEFINE_SUnMapLS(32); +DEFINE_SUnMapLS(36); +DEFINE_SUnMapLS(40); + +#endif /* DEFINE_REGS_ENTRYPOINT */ diff --git a/dlls/kernel/thunk.c b/dlls/kernel/thunk.c index 76492dc7e09..f44ee64fcd9 100644 --- a/dlls/kernel/thunk.c +++ b/dlls/kernel/thunk.c @@ -21,6 +21,7 @@ */ #include "config.h" +#include "wine/port.h" #include #include @@ -185,30 +186,39 @@ void WINAPI LogApiThk( LPSTR func ) * * NOTE: needs to preserve all registers! */ -void LogApiThkLSF( LPSTR func, CONTEXT86 *context ) +void WINAPI __regs_LogApiThkLSF( LPSTR func, CONTEXT86 *context ) { TRACE( "%s\n", debugstr_a(func) ); } +#ifdef DEFINE_REGS_ENTRYPOINT +DEFINE_REGS_ENTRYPOINT( LogApiThkLSF, 4, 4 ); +#endif /*********************************************************************** * LogApiThkSL (KERNEL32.44) * * NOTE: needs to preserve all registers! */ -void LogApiThkSL( LPSTR func, CONTEXT86 *context ) +void WINAPI __regs_LogApiThkSL( LPSTR func, CONTEXT86 *context ) { TRACE( "%s\n", debugstr_a(func) ); } +#ifdef DEFINE_REGS_ENTRYPOINT +DEFINE_REGS_ENTRYPOINT( LogApiThkSL, 4, 4 ); +#endif /*********************************************************************** * LogCBThkSL (KERNEL32.47) * * NOTE: needs to preserve all registers! */ -void LogCBThkSL( LPSTR func, CONTEXT86 *context ) +void WINAPI __regs_LogCBThkSL( LPSTR func, CONTEXT86 *context ) { TRACE( "%s\n", debugstr_a(func) ); } +#ifdef DEFINE_REGS_ENTRYPOINT +DEFINE_REGS_ENTRYPOINT( LogCBThkSL, 4, 4 ); +#endif /*********************************************************************** * Generates a FT_Prolog call. @@ -438,7 +448,7 @@ UINT WINAPI ThunkConnect32( * FIXME: DDJ talks of certain register usage rules; I'm not sure * whether we cover this 100%. */ -void QT_Thunk( CONTEXT86 *context ) +void WINAPI __regs_QT_Thunk( CONTEXT86 *context ) { CONTEXT86 context16; DWORD argsize; @@ -476,6 +486,9 @@ void QT_Thunk( CONTEXT86 *context ) context->Esp += LOWORD(context16.Esp) - ( OFFSETOF( NtCurrentTeb()->cur_stack ) - argsize ); } +#ifdef DEFINE_REGS_ENTRYPOINT +DEFINE_REGS_ENTRYPOINT( QT_Thunk, 0, 0 ); +#endif /********************************************************************** @@ -521,7 +534,7 @@ void QT_Thunk( CONTEXT86 *context ) * ESP is EBP-64 after return. * */ -void FT_Prolog( CONTEXT86 *context ) +void WINAPI __regs_FT_Prolog( CONTEXT86 *context ) { /* Build stack frame */ stack32_push(context, context->Ebp); @@ -541,6 +554,9 @@ void FT_Prolog( CONTEXT86 *context ) *(DWORD *)(context->Ebp - 48) = context->Eax; *(DWORD *)(context->Ebp - 52) = context->Edx; } +#ifdef DEFINE_REGS_ENTRYPOINT +DEFINE_REGS_ENTRYPOINT( FT_Prolog, 0, 0 ); +#endif /********************************************************************** * FT_Thunk (KERNEL32.@) @@ -562,7 +578,7 @@ void FT_Prolog( CONTEXT86 *context ) * of arguments, so that the single DWORD bitmap is no longer * sufficient ... */ -void FT_Thunk( CONTEXT86 *context ) +void WINAPI __regs_FT_Thunk( CONTEXT86 *context ) { DWORD mapESPrelative = *(DWORD *)(context->Ebp - 20); DWORD callTarget = *(DWORD *)(context->Ebp - 52); @@ -607,9 +623,26 @@ void FT_Thunk( CONTEXT86 *context ) /* Copy modified buffers back to 32-bit stack */ memcpy( oldstack, newstack, argsize ); } +#ifdef DEFINE_REGS_ENTRYPOINT +DEFINE_REGS_ENTRYPOINT( FT_Thunk, 0, 0 ); +#endif -/********************************************************************** - * FT_ExitNN (KERNEL32.218 - 232) +/*********************************************************************** + * FT_Exit0 (KERNEL32.@) + * FT_Exit4 (KERNEL32.@) + * FT_Exit8 (KERNEL32.@) + * FT_Exit12 (KERNEL32.@) + * FT_Exit16 (KERNEL32.@) + * FT_Exit20 (KERNEL32.@) + * FT_Exit24 (KERNEL32.@) + * FT_Exit28 (KERNEL32.@) + * FT_Exit32 (KERNEL32.@) + * FT_Exit36 (KERNEL32.@) + * FT_Exit40 (KERNEL32.@) + * FT_Exit44 (KERNEL32.@) + * FT_Exit48 (KERNEL32.@) + * FT_Exit52 (KERNEL32.@) + * FT_Exit56 (KERNEL32.@) * * One of the FT_ExitNN functions is called at the end of the thunk code. * It removes the stack frame created by FT_Prolog, moves the function @@ -619,7 +652,7 @@ void FT_Thunk( CONTEXT86 *context ) * and perform a return to the CALLER of the thunk code (while removing * the given number of arguments from the caller's stack). */ -static void FT_Exit(CONTEXT86 *context, int nPopArgs) +static inline void FT_Exit(CONTEXT86 *context) { /* Return value is in EBX */ context->Eax = context->Ebx; @@ -635,84 +668,36 @@ static void FT_Exit(CONTEXT86 *context, int nPopArgs) /* Pop return address to CALLER of thunk code */ context->Eip = stack32_pop(context); - /* Remove arguments */ - context->Esp += nPopArgs; } -/*********************************************************************** - * FT_Exit0 (KERNEL32.@) - */ -void FT_Exit0(CONTEXT86 *context) { FT_Exit(context, 0); } +#ifdef DEFINE_REGS_ENTRYPOINT -/*********************************************************************** - * FT_Exit4 (KERNEL32.@) - */ -void FT_Exit4(CONTEXT86 *context) { FT_Exit(context, 4); } +#define DEFINE_FT_Exit(n) \ +void WINAPI __regs_FT_Exit ## n(CONTEXT86 *context) \ +{ \ + FT_Exit(context); \ + context->Esp += n; \ +} \ +DEFINE_REGS_ENTRYPOINT( FT_Exit ## n, 0, 0 ) -/*********************************************************************** - * FT_Exit8 (KERNEL32.@) - */ -void FT_Exit8(CONTEXT86 *context) { FT_Exit(context, 8); } +DEFINE_FT_Exit(0); +DEFINE_FT_Exit(4); +DEFINE_FT_Exit(8); +DEFINE_FT_Exit(12); +DEFINE_FT_Exit(16); +DEFINE_FT_Exit(20); +DEFINE_FT_Exit(24); +DEFINE_FT_Exit(28); +DEFINE_FT_Exit(32); +DEFINE_FT_Exit(36); +DEFINE_FT_Exit(40); +DEFINE_FT_Exit(44); +DEFINE_FT_Exit(48); +DEFINE_FT_Exit(52); +DEFINE_FT_Exit(56); -/*********************************************************************** - * FT_Exit12 (KERNEL32.@) - */ -void FT_Exit12(CONTEXT86 *context) { FT_Exit(context, 12); } +#endif /* DEFINE_REGS_ENTRYPOINT */ -/*********************************************************************** - * FT_Exit16 (KERNEL32.@) - */ -void FT_Exit16(CONTEXT86 *context) { FT_Exit(context, 16); } - -/*********************************************************************** - * FT_Exit20 (KERNEL32.@) - */ -void FT_Exit20(CONTEXT86 *context) { FT_Exit(context, 20); } - -/*********************************************************************** - * FT_Exit24 (KERNEL32.@) - */ -void FT_Exit24(CONTEXT86 *context) { FT_Exit(context, 24); } - -/*********************************************************************** - * FT_Exit28 (KERNEL32.@) - */ -void FT_Exit28(CONTEXT86 *context) { FT_Exit(context, 28); } - -/*********************************************************************** - * FT_Exit32 (KERNEL32.@) - */ -void FT_Exit32(CONTEXT86 *context) { FT_Exit(context, 32); } - -/*********************************************************************** - * FT_Exit36 (KERNEL32.@) - */ -void FT_Exit36(CONTEXT86 *context) { FT_Exit(context, 36); } - -/*********************************************************************** - * FT_Exit40 (KERNEL32.@) - */ -void FT_Exit40(CONTEXT86 *context) { FT_Exit(context, 40); } - -/*********************************************************************** - * FT_Exit44 (KERNEL32.@) - */ -void FT_Exit44(CONTEXT86 *context) { FT_Exit(context, 44); } - -/*********************************************************************** - * FT_Exit48 (KERNEL32.@) - */ -void FT_Exit48(CONTEXT86 *context) { FT_Exit(context, 48); } - -/*********************************************************************** - * FT_Exit52 (KERNEL32.@) - */ -void FT_Exit52(CONTEXT86 *context) { FT_Exit(context, 52); } - -/*********************************************************************** - * FT_Exit56 (KERNEL32.@) - */ -void FT_Exit56(CONTEXT86 *context) { FT_Exit(context, 56); } /*********************************************************************** * ThunkInitLS (KERNEL32.43) @@ -780,7 +765,7 @@ DWORD WINAPI ThunkInitLS( * in the BL register by the called 16-bit routine. * */ -void Common32ThkLS( CONTEXT86 *context ) +void WINAPI __regs_Common32ThkLS( CONTEXT86 *context ) { CONTEXT86 context16; DWORD argsize; @@ -811,6 +796,9 @@ void Common32ThkLS( CONTEXT86 *context ) /* Clean up caller's stack frame */ context->Esp += LOBYTE(context16.Ebx); } +#ifdef DEFINE_REGS_ENTRYPOINT +DEFINE_REGS_ENTRYPOINT( Common32ThkLS, 0, 0 ); +#endif /*********************************************************************** * OT_32ThkLSF (KERNEL32.40) @@ -839,7 +827,7 @@ void Common32ThkLS( CONTEXT86 *context ) * (Note that this function seems only to be used for * OLECLI32 -> OLECLI and OLESVR32 -> OLESVR thunking.) */ -void OT_32ThkLSF( CONTEXT86 *context ) +void WINAPI __regs_OT_32ThkLSF( CONTEXT86 *context ) { CONTEXT86 context16; DWORD argsize; @@ -866,6 +854,9 @@ void OT_32ThkLSF( CONTEXT86 *context ) context->Esp += LOWORD(context16.Esp) - ( OFFSETOF( NtCurrentTeb()->cur_stack ) - argsize ); } +#ifdef DEFINE_REGS_ENTRYPOINT +DEFINE_REGS_ENTRYPOINT( OT_32ThkLSF, 0, 0 ); +#endif /*********************************************************************** * ThunkInitLSF (KERNEL32.41) @@ -948,7 +939,7 @@ LPVOID WINAPI ThunkInitLSF( * Note: The two DWORD arguments get popped off the stack. * */ -void FT_PrologPrime( CONTEXT86 *context ) +void WINAPI __regs_FT_PrologPrime( CONTEXT86 *context ) { DWORD targetTableOffset; LPBYTE relayCode; @@ -965,6 +956,9 @@ void FT_PrologPrime( CONTEXT86 *context ) /* Jump to the call stub just created */ context->Eip = (DWORD)relayCode; } +#ifdef DEFINE_REGS_ENTRYPOINT +DEFINE_REGS_ENTRYPOINT( FT_PrologPrime, 0, 0 ); +#endif /*********************************************************************** * QT_ThunkPrime (KERNEL32.90) @@ -977,7 +971,7 @@ void FT_PrologPrime( CONTEXT86 *context ) * EAX start of relay code * */ -void QT_ThunkPrime( CONTEXT86 *context ) +void WINAPI __regs_QT_ThunkPrime( CONTEXT86 *context ) { DWORD targetTableOffset; LPBYTE relayCode; @@ -994,6 +988,9 @@ void QT_ThunkPrime( CONTEXT86 *context ) /* Jump to the call stub just created */ context->Eip = (DWORD)relayCode; } +#ifdef DEFINE_REGS_ENTRYPOINT +DEFINE_REGS_ENTRYPOINT( QT_ThunkPrime, 0, 0 ); +#endif /*********************************************************************** * ThunkInitSL (KERNEL32.46) @@ -1118,7 +1115,7 @@ DWORD WINAPIV SSCall( /********************************************************************** * W32S_BackTo32 (KERNEL32.51) */ -void W32S_BackTo32( CONTEXT86 *context ) +void WINAPI __regs_W32S_BackTo32( CONTEXT86 *context ) { LPDWORD stack = (LPDWORD)context->Esp; FARPROC proc = (FARPROC)context->Eip; @@ -1128,6 +1125,9 @@ void W32S_BackTo32( CONTEXT86 *context ) context->Eip = stack32_pop(context); } +#ifdef DEFINE_REGS_ENTRYPOINT +DEFINE_REGS_ENTRYPOINT( W32S_BackTo32, 0, 0 ); +#endif /********************************************************************** * AllocSLCallback (KERNEL32.@) @@ -1241,7 +1241,7 @@ BOOL16 WINAPI IsPeFormat16( /*********************************************************************** * K32Thk1632Prolog (KERNEL32.@) */ -void K32Thk1632Prolog( CONTEXT86 *context ) +void WINAPI __regs_K32Thk1632Prolog( CONTEXT86 *context ) { LPBYTE code = (LPBYTE)context->Eip - 5; @@ -1298,11 +1298,14 @@ void K32Thk1632Prolog( CONTEXT86 *context ) been called. Thus we re-use it to hold the Win16Lock count */ ReleaseThunkLock(&CURRENT_STACK16->entry_point); } +#ifdef DEFINE_REGS_ENTRYPOINT +DEFINE_REGS_ENTRYPOINT( K32Thk1632Prolog, 0, 0 ); +#endif /*********************************************************************** * K32Thk1632Epilog (KERNEL32.@) */ -void K32Thk1632Epilog( CONTEXT86 *context ) +void WINAPI __regs_K32Thk1632Epilog( CONTEXT86 *context ) { LPBYTE code = (LPBYTE)context->Eip - 13; @@ -1332,6 +1335,9 @@ void K32Thk1632Epilog( CONTEXT86 *context ) context->Ebp, context->Esp, NtCurrentTeb()->cur_stack); } } +#ifdef DEFINE_REGS_ENTRYPOINT +DEFINE_REGS_ENTRYPOINT( K32Thk1632Epilog, 0, 0 ); +#endif /********************************************************************* * PK16FNF [KERNEL32.91] @@ -2101,7 +2107,7 @@ LPVOID WINAPI GetPK16SysVar(void) /********************************************************************** * CommonUnimpStub (KERNEL32.17) */ -void CommonUnimpStub( CONTEXT86 *context ) +void WINAPI __regs_CommonUnimpStub( CONTEXT86 *context ) { FIXME("generic stub: %s\n", ((LPSTR)context->Eax ? (LPSTR)context->Eax : "?")); @@ -2116,6 +2122,9 @@ void CommonUnimpStub( CONTEXT86 *context ) context->Esp += (context->Ecx & 0x0f) * 4; } +#ifdef DEFINE_REGS_ENTRYPOINT +DEFINE_REGS_ENTRYPOINT( CommonUnimpStub, 0, 0 ); +#endif /********************************************************************** * HouseCleanLogicallyDeadHandles (KERNEL32.33) diff --git a/dlls/kernel/vxd.c b/dlls/kernel/vxd.c index 91808968c1a..7656b121653 100644 --- a/dlls/kernel/vxd.c +++ b/dlls/kernel/vxd.c @@ -278,7 +278,7 @@ done: * VxDCall7 (KERNEL32.8) * VxDCall8 (KERNEL32.9) */ -void VxDCall( DWORD service, CONTEXT86 *context ) +void WINAPI __regs_VxDCall( DWORD service, CONTEXT86 *context ) { int i; VxDCallProc proc = NULL; @@ -304,6 +304,9 @@ void VxDCall( DWORD service, CONTEXT86 *context ) context->Eax = 0xffffffff; /* FIXME */ } } +#ifdef DEFINE_REGS_ENTRYPOINT +DEFINE_REGS_ENTRYPOINT( VxDCall, 4, 4 ); +#endif /***********************************************************************