ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
April 2021
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
21 participants
173 discussions
Start a n
N
ew thread
[reactos] 28/29: [CRT] Sync tlssup.c with mingw-w64
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=439aefb31d9a09eb79a7a…
commit 439aefb31d9a09eb79a7a0417f57b7a6eee17400 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Apr 23 15:30:41 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed Apr 28 13:10:23 2021 +0200 [CRT] Sync tlssup.c with mingw-w64 This allows amd64 built binary to be loaded. --- sdk/lib/crt/startup/tlssup.c | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/sdk/lib/crt/startup/tlssup.c b/sdk/lib/crt/startup/tlssup.c index e52a554536c..15abfb0fa12 100644 --- a/sdk/lib/crt/startup/tlssup.c +++ b/sdk/lib/crt/startup/tlssup.c @@ -1,6 +1,6 @@ /** * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the w64 mingw-runtime package. + * This file is part of the mingw-w64 runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. * * Written by Kai Tietz <kai.tietz(a)onevision.com> @@ -12,27 +12,18 @@ #include <sect_attribs.h> -/*#ifndef WIN32_LEAN_AND_MEAN +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif -#include <windows.h>*/ - -#include <stdarg.h> -#include <windef.h> -#include <winbase.h> +#include <windows.h> #include <stdio.h> #include <memory.h> #include <malloc.h> -#ifndef _WIN64 -#include <stdlib.h> /* for _winmajor */ -#endif - -#ifndef __INTERNAL_FUNC_DEFINED -#define __INTERNAL_FUNC_DEFINED -typedef void (__cdecl *_PVFV)(void); -typedef int (__cdecl *_PIFV)(void); -typedef void (__cdecl *_PVFI)(int); +#ifndef __REACTOS__ +#include <corecrt_startup.h> +#else +#include <internal.h> #endif extern WINBOOL __mingw_TLScallback (HANDLE hDllHandle, DWORD reason, LPVOID reserved); @@ -47,15 +38,18 @@ typedef struct TlsDtorNode { ULONG _tls_index = 0; -/* TLS raw template data start and end. */ -_CRTALLOC(".tls") char _tls_start = 0; -_CRTALLOC(".tls$ZZZ") char _tls_end = 0; +/* TLS raw template data start and end. + We use here pointer-types for start/end so that tls-data remains + aligned on pointer-size-width. This seems to be required for + pe-loader. */ +_CRTALLOC(".tls") char *_tls_start = NULL; +_CRTALLOC(".tls$ZZZ") char *_tls_end = NULL; _CRTALLOC(".CRT$XLA") PIMAGE_TLS_CALLBACK __xl_a = 0; _CRTALLOC(".CRT$XLZ") PIMAGE_TLS_CALLBACK __xl_z = 0; -_CRTALLOC(".rdata$T") const IMAGE_TLS_DIRECTORY _tls_used = { - (ULONG_PTR) &_tls_start+1, (ULONG_PTR) &_tls_end, +const IMAGE_TLS_DIRECTORY _tls_used = { + (ULONG_PTR) &_tls_start, (ULONG_PTR) &_tls_end, (ULONG_PTR) &_tls_index, (ULONG_PTR) (&__xl_a+1), (ULONG) 0, (ULONG) 0 }; @@ -80,10 +74,6 @@ static __CRT_THREAD TlsDtorNode dtor_list_head; extern int _CRT_MT; -#ifndef _WIN64 -int __mingw_usemthread_dll; -#endif - BOOL WINAPI __dyn_tls_init (HANDLE, DWORD, LPVOID); BOOL WINAPI
3 years, 8 months
1
0
0
0
[reactos] 27/29: [CRT] We never use the mthread library
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fe3278d4d68a0fedc3815…
commit fe3278d4d68a0fedc381527be538b6c334f3b2fe Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Apr 23 15:30:18 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed Apr 28 13:10:23 2021 +0200 [CRT] We never use the mthread library --- sdk/lib/crt/startup/tlsmthread.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/sdk/lib/crt/startup/tlsmthread.c b/sdk/lib/crt/startup/tlsmthread.c index 9e77c34d7f1..91be7e2dc8d 100644 --- a/sdk/lib/crt/startup/tlsmthread.c +++ b/sdk/lib/crt/startup/tlsmthread.c @@ -18,21 +18,10 @@ int __mingwthr_remove_key_dtor (DWORD key); extern int ___w64_mingwthr_remove_key_dtor (DWORD key); extern int ___w64_mingwthr_add_key_dtor (DWORD key, void (*dtor)(void *)); - -#ifndef _WIN64 -extern int __mingw_usemthread_dll; -#endif - int __mingwthr_remove_key_dtor (DWORD key) { -#ifndef _WIN64 - if (!__mingw_usemthread_dll) -#endif - return ___w64_mingwthr_remove_key_dtor (key); -#ifndef _WIN64 - return 0; -#endif + return ___w64_mingwthr_remove_key_dtor (key); } int @@ -40,9 +29,6 @@ __mingwthr_key_dtor (DWORD key, void (*dtor)(void *)) { if (dtor) { -#ifndef _WIN64 - if (!__mingw_usemthread_dll) -#endif return ___w64_mingwthr_add_key_dtor (key, dtor); } return 0;
3 years, 8 months
1
0
0
0
[reactos] 26/29: [KDGDB] Avoid looping for ever when something unexpected happens
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3ee1eb42a5ec447df568d…
commit 3ee1eb42a5ec447df568d8dd7d9ba69d96282e47 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Apr 23 15:26:33 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed Apr 28 13:10:23 2021 +0200 [KDGDB] Avoid looping for ever when something unexpected happens --- drivers/base/kdgdb/gdb_input.c | 25 +++++++++++++++++-------- drivers/base/kdgdb/kdgdb.h | 2 +- drivers/base/kdgdb/kdpacket.c | 36 +++++++++++++++--------------------- 3 files changed, 33 insertions(+), 30 deletions(-) diff --git a/drivers/base/kdgdb/gdb_input.c b/drivers/base/kdgdb/gdb_input.c index 23f030686d4..c10d7750c84 100644 --- a/drivers/base/kdgdb/gdb_input.c +++ b/drivers/base/kdgdb/gdb_input.c @@ -430,7 +430,7 @@ handle_gdb_registers( #endif static -void +BOOLEAN ReadMemorySendHandler( _In_ ULONG PacketType, _In_ PSTRING MessageHeader, @@ -442,12 +442,13 @@ ReadMemorySendHandler( { // KdAssert KDDBGPRINT("Wrong packet type (%lu) received after DbgKdReadVirtualMemoryApi request.\n", PacketType); - while (1); + return FALSE; } if (State->ApiNumber != DbgKdReadVirtualMemoryApi) { KDDBGPRINT("Wrong API number (%lu) after DbgKdReadVirtualMemoryApi request.\n", State->ApiNumber); + return FALSE; } /* Check status. Allow to send partial data. */ @@ -469,6 +470,8 @@ ReadMemorySendHandler( if (ProcessListHead->Flink) __writecr3(PsGetCurrentProcess()->Pcb.DirectoryTableBase[0]); } + + return TRUE; } static @@ -531,7 +534,7 @@ handle_gdb_read_mem( } static -void +BOOLEAN WriteMemorySendHandler( _In_ ULONG PacketType, _In_ PSTRING MessageHeader, @@ -543,12 +546,13 @@ WriteMemorySendHandler( { // KdAssert KDDBGPRINT("Wrong packet type (%lu) received after DbgKdWriteVirtualMemoryApi request.\n", PacketType); - while (1); + return FALSE; } if (State->ApiNumber != DbgKdWriteVirtualMemoryApi) { KDDBGPRINT("Wrong API number (%lu) after DbgKdWriteVirtualMemoryApi request.\n", State->ApiNumber); + return FALSE; } /* Check status */ @@ -570,6 +574,7 @@ WriteMemorySendHandler( if (ProcessListHead->Flink) __writecr3(PsGetCurrentProcess()->Pcb.DirectoryTableBase[0]); } + return TRUE; } static @@ -669,7 +674,7 @@ handle_gdb_write_mem( } static -void +BOOLEAN WriteBreakPointSendHandler( _In_ ULONG PacketType, _In_ PSTRING MessageHeader, @@ -681,12 +686,13 @@ WriteBreakPointSendHandler( { // KdAssert KDDBGPRINT("Wrong packet type (%lu) received after DbgKdWriteBreakPointApi request.\n", PacketType); - while (1); + return FALSE; } if (State->ApiNumber != DbgKdWriteBreakPointApi) { KDDBGPRINT("Wrong API number (%lu) after DbgKdWriteBreakPointApi request.\n", State->ApiNumber); + return FALSE; } /* Check status */ @@ -712,6 +718,7 @@ WriteBreakPointSendHandler( } KdpSendPacketHandler = NULL; KdpManipulateStateHandler = NULL; + return TRUE; } static @@ -767,7 +774,7 @@ handle_gdb_insert_breakpoint( } static -void +BOOLEAN RestoreBreakPointSendHandler( _In_ ULONG PacketType, _In_ PSTRING MessageHeader, @@ -780,12 +787,13 @@ RestoreBreakPointSendHandler( { // KdAssert KDDBGPRINT("Wrong packet type (%lu) received after DbgKdRestoreBreakPointApi request.\n", PacketType); - while (1); + return FALSE; } if (State->ApiNumber != DbgKdRestoreBreakPointApi) { KDDBGPRINT("Wrong API number (%lu) after DbgKdRestoreBreakPointApi request.\n", State->ApiNumber); + return FALSE; } /* We ignore failure here. If DbgKdRestoreBreakPointApi fails, @@ -804,6 +812,7 @@ RestoreBreakPointSendHandler( KdpSendPacketHandler = NULL; KdpManipulateStateHandler = NULL; + return TRUE; } static diff --git a/drivers/base/kdgdb/kdgdb.h b/drivers/base/kdgdb/kdgdb.h index a260e570319..4e365b77e27 100644 --- a/drivers/base/kdgdb/kdgdb.h +++ b/drivers/base/kdgdb/kdgdb.h @@ -57,7 +57,7 @@ InitManipulateFromStateChange( } /* Callbacks to simulate a KdReceive <-> KdSend loop without GDB being aware of it */ -typedef VOID (*KDP_SEND_HANDLER)( +typedef BOOLEAN (*KDP_SEND_HANDLER)( _In_ ULONG PacketType, _In_ PSTRING MessageHeader, _In_ PSTRING MessageData diff --git a/drivers/base/kdgdb/kdpacket.c b/drivers/base/kdgdb/kdpacket.c index dfe4ee7f261..ba5cd44dd25 100644 --- a/drivers/base/kdgdb/kdpacket.c +++ b/drivers/base/kdgdb/kdpacket.c @@ -9,7 +9,7 @@ /* LOCALS *********************************************************************/ static -VOID +BOOLEAN FirstSendHandler( _In_ ULONG PacketType, _In_ PSTRING MessageHeader, @@ -33,7 +33,7 @@ PETHREAD TheIdleThread; /* PRIVATE FUNCTIONS **********************************************************/ static -VOID +BOOLEAN GetContextSendHandler( _In_ ULONG PacketType, _In_ PSTRING MessageHeader, @@ -47,14 +47,14 @@ GetContextSendHandler( || (State->ApiNumber != DbgKdGetContextApi) || (MessageData->Length < sizeof(*Context))) { - /* Should we bugcheck ? */ KDDBGPRINT("ERROR: Received wrong packet from KD.\n"); - while (1); + return FALSE; } /* Just copy it */ RtlCopyMemory(&CurrentContext, Context, sizeof(*Context)); KdpSendPacketHandler = NULL; + return TRUE; } static @@ -80,7 +80,7 @@ GetContextManipulateHandler( } static -VOID +BOOLEAN SetContextSendHandler( _In_ ULONG PacketType, _In_ PSTRING MessageHeader, @@ -96,10 +96,11 @@ SetContextSendHandler( { /* Should we bugcheck ? */ KDDBGPRINT("BAD BAD BAD not manipulating state for sending context.\n"); - while (1); + return FALSE; } KdpSendPacketHandler = NULL; + return TRUE; } KDSTATUS @@ -236,7 +237,7 @@ ContinueManipulateStateHandler( } static -VOID +BOOLEAN GetVersionSendHandler( _In_ ULONG PacketType, _In_ PSTRING MessageHeader, @@ -250,9 +251,8 @@ GetVersionSendHandler( || (State->ApiNumber != DbgKdGetVersionApi) || !NT_SUCCESS(State->ReturnStatus)) { - /* FIXME: should detach from KD and go along without debugging */ KDDBGPRINT("Wrong packet received after asking for data.\n"); - while(1); + return FALSE; } /* Copy the relevant data */ @@ -265,6 +265,7 @@ GetVersionSendHandler( /* Now we can get the context for the current state */ KdpSendPacketHandler = NULL; KdpManipulateStateHandler = GetContextManipulateHandler; + return TRUE; } static @@ -288,7 +289,7 @@ GetVersionManipulateStateHandler( } static -VOID +BOOLEAN FirstSendHandler( _In_ ULONG PacketType, _In_ PSTRING MessageHeader, @@ -297,18 +298,10 @@ FirstSendHandler( DBGKD_ANY_WAIT_STATE_CHANGE* StateChange = (DBGKD_ANY_WAIT_STATE_CHANGE*)MessageHeader->Buffer; PETHREAD Thread; - if (PacketType == PACKET_TYPE_KD_DEBUG_IO) - { - /* This is not the packet we are waiting for */ - send_kd_debug_io((DBGKD_DEBUG_IO*)MessageHeader->Buffer, MessageData); - return; - } - if (PacketType != PACKET_TYPE_KD_STATE_CHANGE64) { KDDBGPRINT("First KD packet is not a state change!\n"); - /* FIXME: What should we send back to KD ? */ - while(1); + return FALSE; } KDDBGPRINT("KDGDB: START!\n"); @@ -332,6 +325,7 @@ FirstSendHandler( /* The next receive call will be asking for the version data */ KdpSendPacketHandler = NULL; KdpManipulateStateHandler = GetVersionManipulateStateHandler; + return TRUE; } /* PUBLIC FUNCTIONS ***********************************************************/ @@ -426,9 +420,9 @@ KdSendPacket( } /* Maybe we are in a send <-> receive loop that GDB doesn't need to know about */ - if (KdpSendPacketHandler) + if (KdpSendPacketHandler + && KdpSendPacketHandler(PacketType, MessageHeader, MessageData)) { - KdpSendPacketHandler(PacketType, MessageHeader, MessageData); return; }
3 years, 8 months
1
0
0
0
[reactos] 25/29: [SDK] Use GAS SEH capabilities instead of CFI
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2413530acf14120faa517…
commit 2413530acf14120faa517bd65de324c879dbf060 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Thu Apr 22 17:35:54 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed Apr 28 13:10:23 2021 +0200 [SDK] Use GAS SEH capabilities instead of CFI Also remove a hack for x86 GAS which no longer holds --- sdk/include/asm/asm.inc | 46 ++++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/sdk/include/asm/asm.inc b/sdk/include/asm/asm.inc index d13b06e8ead..d879b44ca7f 100644 --- a/sdk/include/asm/asm.inc +++ b/sdk/include/asm/asm.inc @@ -260,19 +260,22 @@ ENDM /* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */ .macro .PROC name .func \name -#ifdef _X86_ - /* x86 GAS expects a label with _ prefix */ - _\name: -#endif \name: +#ifdef _X86_ .cfi_startproc - .equ cfa_current_offset, -8 +#else + .seh_proc \name +#endif .endm #define FUNC .PROC /* ... and .ENDP, replacing ENDP */ .macro .ENDP +#ifdef _X86_ .cfi_endproc +#else + .seh_endproc +#endif .endfunc .endm #define ENDFUNC .ENDP @@ -339,45 +342,36 @@ ENDM .endm /* Macros for x64 stack unwind OPs */ - .macro .allocstack size - .cfi_adjust_cfa_offset \size - .set cfa_current_offset, cfa_current_offset - \size + .seh_stackalloc \size .endm -code = 1 -.macro .pushframe param=0 - .if (\param) - .cfi_adjust_cfa_offset 0x30 - .set cfa_current_offset, cfa_current_offset - 0x30 - .else - .cfi_adjust_cfa_offset 0x28 - .set cfa_current_offset, cfa_current_offset - 0x28 - .endif +.macro .pushframe param + /* + * FIXME. .seh_pushframe doesn't accept code argument. + * Patch sent. + */ + .seh_pushframe \param .endm .macro .pushreg reg - .cfi_adjust_cfa_offset 8 - .equ cfa_current_offset, cfa_current_offset - 8 - .cfi_offset \reg, cfa_current_offset + .seh_pushreg \reg .endm .macro .savereg reg, offset - // checkme!!! - .cfi_offset \reg, \offset + .seh_savereg \reg, \offset .endm .macro .savexmm128 reg, offset - // checkme!!! - .cfi_offset \reg, \offset + .seh_savexmm \reg, \offset .endm .macro .setframe reg, offset - .cfi_def_cfa reg, \offset - .equ cfa_current_offset, \offset + .seh_setframe \reg, \offset .endm .macro .endprolog + .seh_endprologue .endm .macro absolute address
3 years, 8 months
1
0
0
0
[reactos] 24/29: [NTOS:KE] Explicitly use sysretq instruction
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5e29e98f91cbb7ecba24d…
commit 5e29e98f91cbb7ecba24da573d31c4c1ba066099 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Thu Apr 22 17:33:24 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed Apr 28 13:10:23 2021 +0200 [NTOS:KE] Explicitly use sysretq instruction --- ntoskrnl/ke/amd64/trap.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ntoskrnl/ke/amd64/trap.S b/ntoskrnl/ke/amd64/trap.S index b32d0ef4a4b..db7684d9b96 100644 --- a/ntoskrnl/ke/amd64/trap.S +++ b/ntoskrnl/ke/amd64/trap.S @@ -837,7 +837,7 @@ no_user_apc_pending: /* return to user mode */ .byte HEX(48) // REX prefix to return to long mode - sysret + sysretq .ENDP @@ -1071,7 +1071,7 @@ KiInitializeSegments: */ PUBLIC KiSwitchKernelStackHelper KiSwitchKernelStackHelper: - + /* Pop return address from the current stack */ pop rax
3 years, 8 months
1
0
0
0
[reactos] 23/29: [CMAKE] Disable SSE instruction on GCC amd64 builds
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=63944988a25335a5ac97f…
commit 63944988a25335a5ac97f4028e759aede04a8458 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Thu Apr 22 17:31:39 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed Apr 28 13:10:23 2021 +0200 [CMAKE] Disable SSE instruction on GCC amd64 builds Except for user-mode modules --- sdk/cmake/gcc.cmake | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sdk/cmake/gcc.cmake b/sdk/cmake/gcc.cmake index f542d34ef19..25893031e52 100644 --- a/sdk/cmake/gcc.cmake +++ b/sdk/cmake/gcc.cmake @@ -172,6 +172,14 @@ add_definitions(-D_inline=__inline) # Fix build with GLIBCXX + our c++ headers add_definitions(-D_GLIBCXX_HAVE_BROKEN_VSWPRINTF) +# Disable SSE globally on amd64 builds. +# We can't disable it for kernel mode modules only, +# as we don't call set_module_type on static libraries +# Instead we disable this options for user-mode modules +if(ARCH STREQUAL "amd64") + add_compile_options(-mno-sse) +endif() + # Alternative arch name if(ARCH STREQUAL "amd64") set(ARCH2 x86_64) @@ -314,6 +322,9 @@ function(set_module_type_toolchain MODULE TYPE) # Believe it or not, cmake doesn't do that set_property(TARGET ${MODULE} APPEND PROPERTY LINK_DEPENDS $<TARGET_PROPERTY:native-pefixup,IMPORTED_LOCATION>) + else() + # We can safely use SSE for user-mode parts + remove_target_compile_option(${MODULE} -mno-sse) endif() endfunction()
3 years, 8 months
1
0
0
0
[reactos] 22/29: [PSEH] Add implementation for GCC amd64
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ba74a05a1761691ff4cc2…
commit ba74a05a1761691ff4cc20cd6e1804cb375c1e36 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Thu Apr 22 11:11:34 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed Apr 28 13:10:23 2021 +0200 [PSEH] Add implementation for GCC amd64 Also, put include directory next to the library and use target_include_directories(.. INTERFACE ..) to get this right. This is because : - Having includes & implementation in two different places buggers me - This makes sure that there is no "if it compiles everything is fine" behaviour from anyone because now even static libraries need it for GCC amd64 build Also add __USE_PSEH2__ define for the non SEH-aware compilers out there and use it in a few headers where we define macros involving __try --- modules/rostests/apitests/include/apitest.h | 23 ++- sdk/cmake/host-tools.cmake | 1 + sdk/include/psdk/rpc.h | 4 +- sdk/include/reactos/libs/pseh/pseh2_64.h | 37 ----- sdk/include/reactos/wine/exception.h | 18 ++- sdk/lib/pseh/CMakeLists.txt | 17 ++- .../reactos/libs => lib/pseh/include}/pseh/excpt.h | 0 .../libs => lib/pseh/include}/pseh/framebased.h | 0 .../pseh/include}/pseh/framebased/internal.h | 0 .../reactos/libs => lib/pseh/include}/pseh/pseh.h | 0 .../reactos/libs => lib/pseh/include}/pseh/pseh2.h | 4 + sdk/lib/pseh/include/pseh/pseh2_64.h | 169 +++++++++++++++++++++ .../reactos/libs => lib/pseh/include}/pseh/pseh3.h | 0 sdk/tools/CMakeLists.txt | 7 +- 14 files changed, 230 insertions(+), 50 deletions(-) diff --git a/modules/rostests/apitests/include/apitest.h b/modules/rostests/apitests/include/apitest.h index 27777f7a730..50bf98b5930 100644 --- a/modules/rostests/apitests/include/apitest.h +++ b/modules/rostests/apitests/include/apitest.h @@ -8,12 +8,13 @@ #include <wine/test.h> #undef WIN32_NO_STATUS -#include <pseh/pseh2.h> - /* See kmtests/include/kmt_test.h */ #define InvalidPointer ((PVOID)0x5555555555555555ULL) // #define InvalidPointer ((PVOID)0x0123456789ABCDEFULL) +#ifdef __USE_PSEH2__ +#include <pseh/pseh2.h> + #define StartSeh() \ { \ NTSTATUS ExceptionStatus = STATUS_SUCCESS; \ @@ -31,6 +32,24 @@ "Exception 0x%08lx, expected 0x%08lx\n", \ ExceptionStatus, (ExpectedStatus)); \ } +#else +#define StartSeh() \ +{ \ + NTSTATUS ExceptionStatus = STATUS_SUCCESS; \ + __try \ + { + +#define EndSeh(ExpectedStatus) \ + } \ + __except(EXCEPTION_EXECUTE_HANDLER) \ + { \ + ExceptionStatus = GetExceptionCode(); \ + } \ + ok(ExceptionStatus == (ExpectedStatus), \ + "Exception 0x%08lx, expected 0x%08lx\n", \ + ExceptionStatus, (ExpectedStatus)); \ +} +#endif #define ok_hr(status, expected) ok_hex(status, expected) #define ok_hr_(file, line, status, expected) ok_hex_(file, line, status, expected) diff --git a/sdk/cmake/host-tools.cmake b/sdk/cmake/host-tools.cmake index 4633b1097d1..5d426e1b863 100644 --- a/sdk/cmake/host-tools.cmake +++ b/sdk/cmake/host-tools.cmake @@ -35,6 +35,7 @@ function(setup_host_tools) -DCMAKE_INSTALL_PREFIX=${REACTOS_BINARY_DIR}/host-tools -DTOOLS_FOLDER=${REACTOS_BINARY_DIR}/host-tools/bin -DGCC_PLUGIN_DIR=${GCC_PLUGIN_DIR} + -DTARGET_COMPILER_ID=${CMAKE_C_COMPILER_ID} BUILD_ALWAYS TRUE INSTALL_COMMAND ${CMAKE_COMMAND} -E true BUILD_BYPRODUCTS ${HOST_TOOLS_OUTPUT} diff --git a/sdk/include/psdk/rpc.h b/sdk/include/psdk/rpc.h index 800abf44fe2..b35c35fcad1 100644 --- a/sdk/include/psdk/rpc.h +++ b/sdk/include/psdk/rpc.h @@ -5,7 +5,7 @@ #endif /* _INC_WINDOWS */ #endif -#ifndef RC_INVOKED +#if defined(__USE_PSEH2__) && !defined(RC_INVOKED) #include <pseh/pseh2.h> #endif @@ -122,7 +122,7 @@ typedef int RPC_STATUS; #include <excpt.h> #include <winerror.h> - #ifndef __GNUC__ + #ifndef __USE_PSEH2__ #define RpcTryExcept __try { #define RpcExcept(expr) } __except (expr) { #define RpcEndExcept } diff --git a/sdk/include/reactos/libs/pseh/pseh2_64.h b/sdk/include/reactos/libs/pseh/pseh2_64.h deleted file mode 100644 index fd582a1e1f3..00000000000 --- a/sdk/include/reactos/libs/pseh/pseh2_64.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef KJK_PSEH2_H_ -#define KJK_PSEH2_H_ - - -#define _SEH2_TRY if(1) { -#define _SEH2_EXCEPT(...) } if(0) { -#define _SEH2_END } -#define _SEH2_YIELD(STMT_) STMT_ -#define _SEH2_LEAVE -#define _SEH2_FINALLY } if(1) { -#define _SEH2_GetExceptionInformation() (GetExceptionInformation()) -#define _SEH2_GetExceptionCode() (0) -#define _SEH2_AbnormalTermination() (0) - -struct _EXCEPTION_RECORD; -struct _EXCEPTION_POINTERS; -struct _CONTEXT; - -typedef int (__cdecl * _SEH2FrameHandler_t) -( - struct _EXCEPTION_RECORD *, - void *, - struct _CONTEXT *, - void * -); - -typedef struct __SEH2Registration -{ - struct __SEH2Registration * SER_Prev; - _SEH2FrameHandler_t SER_Handler; -} -_SEH2Registration_t; - - -#endif - -/* EOF */ diff --git a/sdk/include/reactos/wine/exception.h b/sdk/include/reactos/wine/exception.h index 9b29f2e470f..f9333e8ff2a 100644 --- a/sdk/include/reactos/wine/exception.h +++ b/sdk/include/reactos/wine/exception.h @@ -3,8 +3,10 @@ #include <setjmp.h> #include <intrin.h> -#include <pseh/pseh2.h> -#include <pseh/excpt.h> +#ifdef __USE_PSEH2__ +# include <pseh/pseh2.h> +# include <pseh/excpt.h> +#endif #ifdef __cplusplus extern "C" { @@ -56,6 +58,7 @@ typedef struct _WINE_EXCEPTION_REGISTRATION_RECORD #define PEXCEPTION_REGISTRATION_RECORD PWINE_EXCEPTION_REGISTRATION_RECORD #endif +#ifdef __USE_PSEH2__ #define __TRY _SEH2_TRY #define __EXCEPT(func) _SEH2_EXCEPT(func(_SEH2_GetExceptionInformation())) #define __EXCEPT_CTX(func, ctx) _SEH2_EXCEPT((func)(GetExceptionInformation(), ctx)) @@ -76,7 +79,16 @@ typedef struct _WINE_EXCEPTION_REGISTRATION_RECORD #ifndef AbnormalTermination #define AbnormalTermination() _SEH2_AbnormalTermination() #endif - +#else +#define __TRY __try +#define __EXCEPT(func) __except(func(GetExceptionInformation())) +#define __EXCEPT_CTX(func, ctx) __except((func)(GetExceptionInformation(), ctx)) +#define __EXCEPT_PAGE_FAULT __except(GetExceptionCode() == STATUS_ACCESS_VIOLATION) +#define __EXCEPT_ALL __except(1) +#define __ENDTRY +#define __FINALLY(func) __finally { func(!AbnormalTermination()); } +#define __FINALLY_CTX(func, ctx) __finally { func(!AbnormalTermination(), ctx); } +#endif #if defined(__MINGW32__) || defined(__CYGWIN__) #define sigjmp_buf jmp_buf diff --git a/sdk/lib/pseh/CMakeLists.txt b/sdk/lib/pseh/CMakeLists.txt index 3a5f46e282e..604e56614ed 100644 --- a/sdk/lib/pseh/CMakeLists.txt +++ b/sdk/lib/pseh/CMakeLists.txt @@ -12,13 +12,15 @@ elseif(ARCH STREQUAL "arm") arm/seh_prolog.s) endif() -if(MSVC OR ARCH STREQUAL "amd64") - +if(MSVC OR ((CMAKE_C_COMPILER_ID STREQUAL "Clang") AND (ARCH STREQUAL "amd64"))) list(APPEND SOURCE dummy.c) add_asm_files(pseh_asm ${ASM_SOURCE}) add_library(pseh ${SOURCE} ${pseh_asm}) add_dependencies(pseh asm) - +elseif((CMAKE_C_COMPILER_ID STREQUAL "GNU") AND (ARCH STREQUAL "amd64")) + # for GCC amd64 this is just an interface library, with our home-made plugin + add_library(pseh INTERFACE) + target_compile_options(pseh INTERFACE -fplugin=$<TARGET_FILE:native-gcc_plugin_seh>) else() if(USE_PSEH3) @@ -43,4 +45,13 @@ else() target_link_libraries(pseh chkstk) add_dependencies(pseh psdk) + target_include_directories(pseh PRIVATE include/pseh) +endif() + +target_include_directories(pseh INTERFACE include) + +# Make it clear that we are using PSEH2 +if ((CMAKE_C_COMPILER_ID STREQUAL "GNU") OR + ((CMAKE_C_COMPILER_ID STREQUAL "Clang") AND (NOT (ARCH STREQUAL "amd64")))) + target_compile_definitions(pseh INTERFACE __USE_PSEH2__) endif() diff --git a/sdk/include/reactos/libs/pseh/excpt.h b/sdk/lib/pseh/include/pseh/excpt.h similarity index 100% rename from sdk/include/reactos/libs/pseh/excpt.h rename to sdk/lib/pseh/include/pseh/excpt.h diff --git a/sdk/include/reactos/libs/pseh/framebased.h b/sdk/lib/pseh/include/pseh/framebased.h similarity index 100% rename from sdk/include/reactos/libs/pseh/framebased.h rename to sdk/lib/pseh/include/pseh/framebased.h diff --git a/sdk/include/reactos/libs/pseh/framebased/internal.h b/sdk/lib/pseh/include/pseh/framebased/internal.h similarity index 100% rename from sdk/include/reactos/libs/pseh/framebased/internal.h rename to sdk/lib/pseh/include/pseh/framebased/internal.h diff --git a/sdk/include/reactos/libs/pseh/pseh.h b/sdk/lib/pseh/include/pseh/pseh.h similarity index 100% rename from sdk/include/reactos/libs/pseh/pseh.h rename to sdk/lib/pseh/include/pseh/pseh.h diff --git a/sdk/include/reactos/libs/pseh/pseh2.h b/sdk/lib/pseh/include/pseh/pseh2.h similarity index 99% rename from sdk/include/reactos/libs/pseh/pseh2.h rename to sdk/lib/pseh/include/pseh/pseh2.h index 45f872e7757..fd985dd8702 100644 --- a/sdk/include/reactos/libs/pseh/pseh2.h +++ b/sdk/lib/pseh/include/pseh/pseh2.h @@ -37,6 +37,10 @@ #define _SEH2_LEAVE __leave #define _SEH2_VOLATILE +#elif defined(__GNUC__) && !defined(__clang__) && defined(_M_AMD64) + +#include "pseh2_64.h" + #elif defined(_USE_DUMMY_PSEH) || defined (__arm__) || defined(_M_AMD64) extern int _SEH2_Volatile0; diff --git a/sdk/lib/pseh/include/pseh/pseh2_64.h b/sdk/lib/pseh/include/pseh/pseh2_64.h new file mode 100644 index 00000000000..21be52477ca --- /dev/null +++ b/sdk/lib/pseh/include/pseh/pseh2_64.h @@ -0,0 +1,169 @@ + +#pragma once + +/* Declare our global trampoline function for filter and unwinder */ +__asm__( + ".p2align 4, 0x90\n" + ".seh_proc __seh2_global_filter_func\n" + "__seh2_global_filter_func:\n" + "\tpush %rbp\n" + "\t.seh_pushreg %rbp\n" + "\tsub $32, %rsp\n" + "\t.seh_stackalloc 32\n" + "\t.seh_endprologue\n" + /* Restore frame pointer. */ + "\tmov %rdx, %rbp\n" + /* Actually execute the filter funclet */ + "\tjmp *%rax\n" + "__seh2_global_filter_func_exit:\n" + "\t.p2align 4\n" + "\tadd $32, %rsp\n" + "\tpop %rbp\n" + "\tret\n" + "\t.seh_endproc"); + +#define _SEH2_TRY \ +{ \ + __label__ __seh2$$begin_try__; \ + __label__ __seh2$$end_try__; \ + /* \ + * We close the current SEH block for this function and install our own. \ + * At this point GCC emitted its prologue, and if it saves more \ + * registers, the relevant instruction will be valid for our scope as well. \ + * We also count the number of try blocks at assembly level \ + * to properly set the handler data when we're done. \ + */ \ +__seh2$$begin_try__: \ + { \ + __label__ __seh2$$leave_scope__; + +#define _SEH2_EXCEPT(...) \ +__seh2$$leave_scope__: __MINGW_ATTRIB_UNUSED; \ + } \ +__seh2$$end_try__: \ + /* Call our home-made pragma */ \ + _Pragma("REACTOS seh(except)") \ + if (0) \ + { \ + __label__ __seh2$$leave_scope__; \ + __label__ __seh2$$filter__; \ + __label__ __seh2$$begin_except__; \ + LONG __MINGW_ATTRIB_UNUSED __seh2$$exception_code__ = 0; \ + /* Add our handlers to the list */ \ + __asm__ __volatile__ goto ("\n" \ + "\t.seh_handlerdata\n" \ + "\t.rva %l0\n" /* Begin of tried code */ \ + "\t.rva %l1 + 1\n" /* End of tried code */ \ + "\t.rva %l2\n" /* Filter function */ \ + "\t.rva %l3\n" /* Called on except */ \ + "\t.seh_code\n" \ + : /* No output */ \ + : /* No input */ \ + : /* No clobber */ \ + : __seh2$$begin_try__, \ + __seh2$$end_try__, \ + __seh2$$filter__, \ + __seh2$$begin_except__); \ + if (0) \ + { \ + /* Jump to the global filter. Tell it where the filter funclet lies */ \ + __label__ __seh2$$filter_funclet__; \ + __seh2$$filter__: \ + __asm__ __volatile__ goto( \ + "\tleaq %l0(%%rip), %%rax\n" \ + "\tjmp __seh2_global_filter_func\n" \ + : /* No output */ \ + : /* No input */ \ + : "%rax" \ + : __seh2$$filter_funclet__); \ + /* Actually declare our filter funclet */ \ + struct _EXCEPTION_POINTERS* __seh2$$exception_ptr__; \ + __seh2$$filter_funclet__: \ + /* At this point, the compiler can't count on any register being valid */ \ + __asm__ __volatile__("" \ + : "=c"(__seh2$$exception_ptr__) /* First argument of the filter function */ \ + : /* No input */ \ + : /* Everything */ \ + "%rax", "%rbx","%rdx", "%rdi", "%rsi", \ + "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15"); \ + /* Save exception code */ \ + __seh2$$exception_code__ = __seh2$$exception_ptr__->ExceptionRecord->ExceptionCode; \ + /* Actually evaluate our filter */ \ + register long __MINGW_ATTRIB_UNUSED __seh2$$filter_funclet_ret __asm__("eax") = \ + ((__VA_ARGS__)); \ + /* Go back to the global filter function */ \ + __asm__("jmp __seh2_global_filter_func_exit"); \ + } \ + /* Protect us from emitting instructions to jump back to the filter function */ \ + enum \ + { \ + __seh2$$abnormal_termination__ = 0 \ + }; \ + __seh2$$begin_except__: + +#define _SEH2_FINALLY \ +__seh2$$leave_scope__: __MINGW_ATTRIB_UNUSED; \ + } \ +__seh2$$end_try__: \ + /* Call our home-made pragma */ \ + _Pragma("REACTOS seh(finally)") \ + if (1) \ + { \ + __label__ __seh2$$finally__; \ + __label__ __seh2$$begin_finally__; \ + __label__ __seh2$$leave_scope__; \ + int __seh2$$abnormal_termination__; \ + /* Add our handlers to the list */ \ + __asm__ __volatile__ goto ("\n" \ + "\t.seh_handlerdata\n" \ + "\t.rva %l0\n" /* Begin of tried code */ \ + "\t.rva %l1 + 1\n" /* End of tried code */ \ + "\t.rva %l2\n" /* Filter function */ \ + "\t.long 0\n" /* Nothing for unwind code */ \ + "\t.seh_code\n" \ + : /* No output */ \ + : /* No input */ \ + : /* No clobber */ \ + : __seh2$$begin_try__, \ + __seh2$$end_try__, \ + __seh2$$finally__); \ + if (0) \ + { \ + /* Jump to the global trampoline. Tell it where the unwind code really lies */ \ + __seh2$$finally__: \ + __asm__ __volatile__ goto( \ + "\tleaq %l0(%%rip), %%rax\n" \ + "\tjmp __seh2_global_filter_func\n" \ + : /* No output */ \ + : /* No input */ \ + : /* No clobber */ \ + : __seh2$$begin_finally__); \ + } \ + \ + /* Zero-out rcx to indicate normal termination */ \ + __asm__ __volatile__("xor %%rcx, %%rcx" \ + : /* No output */ \ + : /* No input */ \ + : /* Everything - We might come from __C_specific_handler here */ \ + "%rax", "%rbx", "%rcx", "%rdx", "%rdi", "%rsi", \ + "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15"); \ + /* Actually declare our finally funclet */ \ + __seh2$$begin_finally__: \ + __asm__ __volatile__("" \ + : "=c" (__seh2$$abnormal_termination__)); + +#define _SEH2_END \ + __seh2$$leave_scope__: __MINGW_ATTRIB_UNUSED; \ + if (__seh2$$abnormal_termination__) \ + { \ + __asm__("jmp __seh2_global_filter_func_exit"); \ + } \ + } \ +} + +#define _SEH2_GetExceptionInformation() __seh2$$exception_ptr__ +#define _SEH2_GetExceptionCode() __seh2$$exception_code__ +#define _SEH2_AbnormalTermination() __seh2$$abnormal_termination__ +#define _SEH2_LEAVE goto __seh2$$leave_scope__ +#define _SEH2_YIELD(__stmt) __stmt +#define _SEH2_VOLATILE volatile diff --git a/sdk/include/reactos/libs/pseh/pseh3.h b/sdk/lib/pseh/include/pseh/pseh3.h similarity index 100% rename from sdk/include/reactos/libs/pseh/pseh3.h rename to sdk/lib/pseh/include/pseh/pseh3.h diff --git a/sdk/tools/CMakeLists.txt b/sdk/tools/CMakeLists.txt index 956a6dc7060..c27c9ac3683 100644 --- a/sdk/tools/CMakeLists.txt +++ b/sdk/tools/CMakeLists.txt @@ -40,12 +40,13 @@ add_subdirectory(widl) add_subdirectory(wpp) add_subdirectory(xml2sdb) +if ((ARCH STREQUAL "amd64") AND (TARGET_COMPILER_ID STREQUAL "GNU")) + add_subdirectory(gcc_plugin_seh) +endif() + if(NOT MSVC) add_subdirectory(log2lines) add_subdirectory(rsym) -if (ARCH STREQUAL "amd64") - add_subdirectory(gcc_plugin_seh) -endif() add_host_tool(pefixup pefixup.c) if (ARCH STREQUAL "amd64")
3 years, 8 months
1
0
0
0
[reactos] 21/29: [CRT] Do not include unneeded PSEH header
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d31856cda15b477ab597c…
commit d31856cda15b477ab597c039f782df97b208c805 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Apr 23 16:22:01 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed Apr 28 13:10:23 2021 +0200 [CRT] Do not include unneeded PSEH header --- sdk/lib/crt/include/internal/wine/cppexcept.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/sdk/lib/crt/include/internal/wine/cppexcept.h b/sdk/lib/crt/include/internal/wine/cppexcept.h index d4dbbee2f34..b2c98ddc7ac 100644 --- a/sdk/lib/crt/include/internal/wine/cppexcept.h +++ b/sdk/lib/crt/include/internal/wine/cppexcept.h @@ -21,8 +21,6 @@ #ifndef __MSVCRT_CPPEXCEPT_H #define __MSVCRT_CPPEXCEPT_H -#include <pseh/pseh2.h> - #define CXX_FRAME_MAGIC_VC6 0x19930520 #define CXX_FRAME_MAGIC_VC7 0x19930521 #define CXX_FRAME_MAGIC_VC8 0x19930522
3 years, 8 months
1
0
0
0
[reactos] 20/29: [REACTOS] Explicitly link against pseh & include pseh headers in a few places
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e470b583761e392641def…
commit e470b583761e392641defc5b9b029e2889d02afc Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Thu Apr 22 17:28:52 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed Apr 28 13:10:23 2021 +0200 [REACTOS] Explicitly link against pseh & include pseh headers in a few places --- base/applications/mscutils/eventvwr/eventvwr.c | 20 +++++++++++--------- base/system/services/CMakeLists.txt | 5 +---- base/system/services/rpcserver.c | 2 ++ dll/np/nfs/nfs41_np.c | 2 ++ dll/win32/advapi32/service/sctrl.c | 2 ++ dll/win32/kernel32/CMakeLists.txt | 2 +- dll/win32/lsasrv/database.c | 2 ++ dll/win32/olecli32/CMakeLists.txt | 2 +- dll/win32/samsrv/database.c | 2 ++ dll/win32/setupapi/cfgmgr.c | 2 ++ dll/win32/setupapi/devinst.c | 2 ++ modules/rostests/apitests/apphelp/apphelp.c | 4 +++- modules/rostests/apitests/apphelp/db.cpp | 8 +++++--- modules/rostests/apitests/apphelp/env.c | 2 ++ .../rostests/apitests/compiler/ms/seh/CMakeLists.txt | 1 + modules/rostests/apitests/gdi32/AddFontResourceEx.c | 2 ++ modules/rostests/apitests/gdi32/CreateDIBitmap.c | 2 ++ modules/rostests/apitests/gdi32/ExtCreatePen.c | 2 ++ modules/rostests/apitests/gdi32/GetObject.c | 2 ++ modules/rostests/apitests/gdi32/SetBrushOrgEx.c | 2 ++ modules/rostests/apitests/kernel32/FLS.c | 2 ++ modules/rostests/apitests/kernel32/SystemFirmware.c | 2 ++ .../rostests/apitests/localspl/dll/fpEnumPrinters.c | 2 ++ modules/rostests/apitests/ntdll/LdrEnumResources.c | 2 ++ .../apitests/ntdll/NtAllocateVirtualMemory.c | 2 ++ modules/rostests/apitests/ntdll/NtMapViewOfSection.c | 2 ++ modules/rostests/apitests/ntdll/RtlAllocateHeap.c | 2 ++ modules/rostests/apitests/ntdll/RtlBitmap.c | 2 ++ .../apitests/ntdll/RtlMultipleAllocateHeap.c | 2 ++ modules/rostests/apitests/ntdll/StackOverflow.c | 2 ++ modules/rostests/apitests/ntdll/load_notifications.c | 2 ++ modules/rostests/apitests/sdk/delayimp.cpp | 6 ++++-- modules/rostests/apitests/shlwapi/PathFindOnPath.c | 2 ++ modules/rostests/apitests/shlwapi/SHAreIconsEqual.c | 2 ++ .../rostests/apitests/shlwapi/SHLoadIndirectString.c | 2 ++ modules/rostests/apitests/spoolss/ReallocSplStr.c | 2 ++ modules/rostests/winetests/kernel32/CMakeLists.txt | 1 + modules/rostests/winetests/ntdll/CMakeLists.txt | 2 ++ sdk/lib/atl/CMakeLists.txt | 2 ++ sdk/lib/atl/atlcom.h | 1 + sdk/lib/crt/crt.cmake | 2 +- sdk/lib/drivers/copysup/CMakeLists.txt | 1 + sdk/lib/drivers/rdbsslib/CMakeLists.txt | 1 + sdk/lib/drivers/rxce/CMakeLists.txt | 1 + sdk/lib/rtl/CMakeLists.txt | 2 ++ win32ss/gdi/gdi32/objects/bitmap.c | 2 ++ win32ss/gdi/gdi32/wine/CMakeLists.txt | 1 + win32ss/printing/base/winspool/utils.c | 4 +++- win32ss/user/winsrv/consrv.cmake | 1 + win32ss/user/winsrv/usersrv.cmake | 1 + 50 files changed, 103 insertions(+), 23 deletions(-) diff --git a/base/applications/mscutils/eventvwr/eventvwr.c b/base/applications/mscutils/eventvwr/eventvwr.c index 5bc96ced583..94e67095b73 100644 --- a/base/applications/mscutils/eventvwr/eventvwr.c +++ b/base/applications/mscutils/eventvwr/eventvwr.c @@ -33,6 +33,8 @@ #include <shellapi.h> #include <shlwapi.h> +#include <pseh/pseh2.h> + // #include "resource.h" #define LVM_PROGRESS (WM_APP + 1) // Used by the subclassed ListView @@ -3895,7 +3897,7 @@ InitPropertiesDlg(HWND hDlg, PEVENTLOG EventLog) /* By default, it is 604800 (secs) == 7 days. On Server, the retention is zeroed out. */ dwRetention = 0; } - /* Convert in days, rounded up */ + /* Convert in days, rounded up */ if (dwRetention != INFINITE) dwRetention = (dwRetention + 24*3600 - 1) / (24*3600); @@ -4023,7 +4025,7 @@ SavePropertiesDlg(HWND hDlg, PEVENTLOG EventLog) LONG Result; DWORD dwMaxSize = 0, dwRetention = 0; HKEY hLogKey; - WCHAR *KeyPath; + WCHAR *KeyPath; SIZE_T cbKeyPath; if (!EventLog->Permanent) @@ -4054,7 +4056,7 @@ SavePropertiesDlg(HWND hDlg, PEVENTLOG EventLog) 0, REG_DWORD, (LPBYTE)&dwMaxSize, - sizeof(dwMaxSize)); + sizeof(dwMaxSize)); if (IsDlgButtonChecked(hDlg, IDC_OVERWRITE_AS_NEEDED) == BST_CHECKED) dwRetention = 0; @@ -4069,7 +4071,7 @@ SavePropertiesDlg(HWND hDlg, PEVENTLOG EventLog) REG_DWORD, (LPBYTE)&dwRetention, sizeof(dwRetention)); - + RegCloseKey(hLogKey); } @@ -4100,14 +4102,14 @@ EventLogPropProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_NOTIFY: switch (((LPNMHDR)lParam)->code) - { + { case PSN_APPLY: PropSheet_UnChanged(GetParent(hDlg), hDlg); SavePropertiesDlg(hDlg, EventLog); return (INT_PTR)TRUE; } break; - + case WM_COMMAND: switch (LOWORD(wParam)) { @@ -4126,7 +4128,7 @@ EventLogPropProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) } return (INT_PTR)TRUE; } - + case IDC_EDIT_EVENTS_AGE: case IDC_EDIT_MAXLOGSIZE: if (HIWORD(wParam) == EN_CHANGE) @@ -4134,7 +4136,7 @@ EventLogPropProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) PropSheet_Changed(GetParent(hDlg), hDlg); } return (INT_PTR)TRUE; - + case IDC_OVERWRITE_AS_NEEDED: { CheckRadioButton(hDlg, IDC_OVERWRITE_AS_NEEDED, IDC_NO_OVERWRITE, IDC_OVERWRITE_AS_NEEDED); @@ -4161,7 +4163,7 @@ EventLogPropProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) PropSheet_Changed(GetParent(hDlg), hDlg); return (INT_PTR)TRUE; } - + case IDC_RESTOREDEFAULTS: { LoadStringW(hInst, IDS_RESTOREDEFAULTS, szText, _countof(szText)); diff --git a/base/system/services/CMakeLists.txt b/base/system/services/CMakeLists.txt index 0005294b04b..ba38f656da2 100644 --- a/base/system/services/CMakeLists.txt +++ b/base/system/services/CMakeLists.txt @@ -20,10 +20,7 @@ list(APPEND SOURCE ${CMAKE_CURRENT_BINARY_DIR}/svcctl_s.c) add_executable(services ${SOURCE} services.rc) - -if(NOT MSVC) - target_link_libraries(services ${PSEH_LIB}) -endif() +target_link_libraries(services ${PSEH_LIB}) set_module_type(services win32gui UNICODE) add_importlibs(services userenv user32 advapi32 rpcrt4 msvcrt kernel32 ntdll) diff --git a/base/system/services/rpcserver.c b/base/system/services/rpcserver.c index 0c1dbcfb08a..136d86b1e50 100644 --- a/base/system/services/rpcserver.c +++ b/base/system/services/rpcserver.c @@ -15,6 +15,8 @@ #include <winnls.h> #include <strsafe.h> +#include <pseh/pseh2.h> + #define NDEBUG #include <debug.h> diff --git a/dll/np/nfs/nfs41_np.c b/dll/np/nfs/nfs41_np.c index ce03c419996..161f7407e6c 100644 --- a/dll/np/nfs/nfs41_np.c +++ b/dll/np/nfs/nfs41_np.c @@ -28,6 +28,8 @@ #include "nfs41_np.h" #include "options.h" +#include <pseh/pseh2.h> + #ifdef DBG #define DbgP(_x_) NFS41DbgPrint _x_ #else diff --git a/dll/win32/advapi32/service/sctrl.c b/dll/win32/advapi32/service/sctrl.c index c0cf0f42288..f437d8e6ecc 100644 --- a/dll/win32/advapi32/service/sctrl.c +++ b/dll/win32/advapi32/service/sctrl.c @@ -12,6 +12,8 @@ /* INCLUDES ******************************************************************/ #include <advapi32.h> +#include <pseh/pseh2.h> + WINE_DEFAULT_DEBUG_CHANNEL(advapi); diff --git a/dll/win32/kernel32/CMakeLists.txt b/dll/win32/kernel32/CMakeLists.txt index 4f4eddc4f8f..11339a91e60 100644 --- a/dll/win32/kernel32/CMakeLists.txt +++ b/dll/win32/kernel32/CMakeLists.txt @@ -10,7 +10,7 @@ add_library(kernel32_shared client/shared_utils.c client/file/fileutils.c ) - +target_link_libraries(kernel32_shared PRIVATE pseh) add_dependencies(kernel32_shared psdk) list(APPEND SOURCE diff --git a/dll/win32/lsasrv/database.c b/dll/win32/lsasrv/database.c index af35f3a9b5f..591cb0131e9 100644 --- a/dll/win32/lsasrv/database.c +++ b/dll/win32/lsasrv/database.c @@ -8,6 +8,8 @@ #include "lsasrv.h" +#include <pseh/pseh2.h> + /* GLOBALS *****************************************************************/ static HANDLE SecurityKeyHandle = NULL; diff --git a/dll/win32/olecli32/CMakeLists.txt b/dll/win32/olecli32/CMakeLists.txt index 5ade3f7433b..e9f3f0cdc65 100644 --- a/dll/win32/olecli32/CMakeLists.txt +++ b/dll/win32/olecli32/CMakeLists.txt @@ -10,6 +10,6 @@ list(APPEND SOURCE add_library(olecli32 MODULE ${SOURCE}) set_module_type(olecli32 win32dll) -target_link_libraries(olecli32 wine) +target_link_libraries(olecli32 wine ${PSEH_LIB}) add_importlibs(olecli32 ole32 gdi32 msvcrt kernel32 ntdll) add_cd_file(TARGET olecli32 DESTINATION reactos/system32 FOR all) diff --git a/dll/win32/samsrv/database.c b/dll/win32/samsrv/database.c index 512e7e1f8a2..7887f613db7 100644 --- a/dll/win32/samsrv/database.c +++ b/dll/win32/samsrv/database.c @@ -8,6 +8,8 @@ #include "samsrv.h" +#include <pseh/pseh2.h> + /* GLOBALS *****************************************************************/ static HANDLE SamKeyHandle = NULL; diff --git a/dll/win32/setupapi/cfgmgr.c b/dll/win32/setupapi/cfgmgr.c index b63feb46c44..923f16c2b2c 100644 --- a/dll/win32/setupapi/cfgmgr.c +++ b/dll/win32/setupapi/cfgmgr.c @@ -25,6 +25,8 @@ #include <pnp_c.h> #include <winsvc.h> +#include <pseh/pseh2.h> + #include "rpc_private.h" DWORD diff --git a/dll/win32/setupapi/devinst.c b/dll/win32/setupapi/devinst.c index a20c96b9c07..c3d4a68f977 100644 --- a/dll/win32/setupapi/devinst.c +++ b/dll/win32/setupapi/devinst.c @@ -21,6 +21,8 @@ #include "setupapi_private.h" +#include <pseh/pseh2.h> + /* Unicode constants */ static const WCHAR BackSlash[] = {'\\',0}; static const WCHAR DateFormat[] = {'%','u','-','%','u','-','%','u',0}; diff --git a/modules/rostests/apitests/apphelp/apphelp.c b/modules/rostests/apitests/apphelp/apphelp.c index 7f4151289b9..13a52ca0f6f 100644 --- a/modules/rostests/apitests/apphelp/apphelp.c +++ b/modules/rostests/apitests/apphelp/apphelp.c @@ -24,6 +24,8 @@ #include <shlguid.h> #include <shobjidl.h> +#include <pseh/pseh2.h> + #include "wine/test.h" #include "apphelp_apitest.h" @@ -299,7 +301,7 @@ static struct "PROBLEMSEVERITY", "LANGID", "VER_LANGUAGE", "InvalidTag", "ENGINE", "HTMLHELPID", "INDEX_FLAGS", "FLAGS", "DATA_VALUETYPE", "DATA_DWORD", "LAYER_TAGID", "MSI_TRANSFORM_TAGID", "LINKER_VERSION", "LINK_DATE", "UPTO_LINK_DATE", "OS_SERVICE_PACK", "FLAG_TAGID", "RUNTIME_PLATFORM", "OS_SKU", "OS_PLATFORM", "APP_NAME_RC_ID", "VENDOR_NAME_RC_ID", "SUMMARY_MSG_RC_ID", "VISTA_SKU", - "DESCRIPTION_RC_ID", "PARAMETER1_RC_ID", "InvalidTag", "InvalidTag", "InvalidTag", "InvalidTag", "InvalidTag", "InvalidTag", + "DESCRIPTION_RC_ID", "PARAMETER1_RC_ID", "InvalidTag", "InvalidTag", "InvalidTag", "InvalidTag", "InvalidTag", "InvalidTag", "CONTEXT_TAGID", "EXE_WRAPPER", "URL_ID", NULL } }, diff --git a/modules/rostests/apitests/apphelp/db.cpp b/modules/rostests/apitests/apphelp/db.cpp index 4f6f3b76423..a96fb463901 100644 --- a/modules/rostests/apitests/apphelp/db.cpp +++ b/modules/rostests/apitests/apphelp/db.cpp @@ -22,6 +22,8 @@ #include <stdio.h> #include <initguid.h> +#include <pseh/pseh2.h> + #include "wine/test.h" #include "apphelp_apitest.h" @@ -1081,7 +1083,7 @@ static void test_GetDatabaseInformation(PDB pdb) ok(pInfo[1].dwSomething == 0xdededede, "Cookie1 corrupt: 0x%x\n", pInfo[1].dwSomething); ok(pInfo[1].dwMajor == 0xdededede, "Cookie2 corrupt: 0x%x\n", pInfo[1].dwMajor); } - + } free(pInfo); } @@ -1185,7 +1187,7 @@ static BOOL IsUserAdmin() { BOOL Result; SID_IDENTIFIER_AUTHORITY NtAuthority = { SECURITY_NT_AUTHORITY }; - PSID AdministratorsGroup; + PSID AdministratorsGroup; Result = AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, @@ -1196,7 +1198,7 @@ static BOOL IsUserAdmin() { if (!CheckTokenMembership( NULL, AdministratorsGroup, &Result)) Result = FALSE; - FreeSid(AdministratorsGroup); + FreeSid(AdministratorsGroup); } return Result; diff --git a/modules/rostests/apitests/apphelp/env.c b/modules/rostests/apitests/apphelp/env.c index 74e7d3b5dc1..26fcadbb611 100644 --- a/modules/rostests/apitests/apphelp/env.c +++ b/modules/rostests/apitests/apphelp/env.c @@ -21,6 +21,8 @@ #include "wine/test.h" +#include <pseh/pseh2.h> + #include "apphelp_apitest.h" typedef void* HSDB; diff --git a/modules/rostests/apitests/compiler/ms/seh/CMakeLists.txt b/modules/rostests/apitests/compiler/ms/seh/CMakeLists.txt index 34da6e3e4bc..46df43a266a 100644 --- a/modules/rostests/apitests/compiler/ms/seh/CMakeLists.txt +++ b/modules/rostests/apitests/compiler/ms/seh/CMakeLists.txt @@ -12,6 +12,7 @@ foreach(num RANGE 10 58) endforeach() add_library(ms_seh_test ${SOURCE}) +target_link_libraries(ms_seh_test pseh) add_dependencies(ms_seh_test psdk) if(MSVC) diff --git a/modules/rostests/apitests/gdi32/AddFontResourceEx.c b/modules/rostests/apitests/gdi32/AddFontResourceEx.c index 9448a6ff1c6..c65a00090d4 100644 --- a/modules/rostests/apitests/gdi32/AddFontResourceEx.c +++ b/modules/rostests/apitests/gdi32/AddFontResourceEx.c @@ -7,6 +7,8 @@ #include "precomp.h" +#include <pseh/pseh2.h> + void Test_AddFontResourceExW() { WCHAR szFileName[MAX_PATH]; diff --git a/modules/rostests/apitests/gdi32/CreateDIBitmap.c b/modules/rostests/apitests/gdi32/CreateDIBitmap.c index cee2bb476d6..cc11cab28c5 100644 --- a/modules/rostests/apitests/gdi32/CreateDIBitmap.c +++ b/modules/rostests/apitests/gdi32/CreateDIBitmap.c @@ -9,6 +9,8 @@ #include "init.h" +#include <pseh/pseh2.h> + #define CBM_CREATDIB 2 #define INVALID_POINTER ((PVOID)(ULONG_PTR)0xC0000000C0000000ULL) diff --git a/modules/rostests/apitests/gdi32/ExtCreatePen.c b/modules/rostests/apitests/gdi32/ExtCreatePen.c index d565ad9306e..b82c34b8f23 100644 --- a/modules/rostests/apitests/gdi32/ExtCreatePen.c +++ b/modules/rostests/apitests/gdi32/ExtCreatePen.c @@ -7,6 +7,8 @@ #include "precomp.h" +#include <pseh/pseh2.h> + #define ok_lasterror(err) \ ok(GetLastError() == err, "expected last error " #err " but got 0x%lx\n", GetLastError()); diff --git a/modules/rostests/apitests/gdi32/GetObject.c b/modules/rostests/apitests/gdi32/GetObject.c index df2a87170f7..6cd0d1c8ac5 100644 --- a/modules/rostests/apitests/gdi32/GetObject.c +++ b/modules/rostests/apitests/gdi32/GetObject.c @@ -7,6 +7,8 @@ #include "precomp.h" +#include <pseh/pseh2.h> + #define INVALID_POINTER ((PVOID)(ULONG_PTR)0xdeadbeefdeadbeefULL) void diff --git a/modules/rostests/apitests/gdi32/SetBrushOrgEx.c b/modules/rostests/apitests/gdi32/SetBrushOrgEx.c index e708fef180d..9d510ab4ce8 100644 --- a/modules/rostests/apitests/gdi32/SetBrushOrgEx.c +++ b/modules/rostests/apitests/gdi32/SetBrushOrgEx.c @@ -7,6 +7,8 @@ #include "precomp.h" +#include <pseh/pseh2.h> + void Test_Set(ULONG ulLine, HDC hdc, INT x, INT y, LPPOINT ppt, BOOL bExp, DWORD dwErrExp) { BOOL bResult; diff --git a/modules/rostests/apitests/kernel32/FLS.c b/modules/rostests/apitests/kernel32/FLS.c index 712a87403e8..44241b1e5a8 100644 --- a/modules/rostests/apitests/kernel32/FLS.c +++ b/modules/rostests/apitests/kernel32/FLS.c @@ -9,6 +9,8 @@ #include <ndk/pstypes.h> #include <ndk/rtlfuncs.h> +#include <pseh/pseh2.h> + /* XP does not have these functions */ static DWORD (WINAPI *pFlsAlloc)(PFLS_CALLBACK_FUNCTION); static BOOL (WINAPI *pFlsFree)(DWORD); diff --git a/modules/rostests/apitests/kernel32/SystemFirmware.c b/modules/rostests/apitests/kernel32/SystemFirmware.c index 47ef3a33bac..8a1ee03af4e 100644 --- a/modules/rostests/apitests/kernel32/SystemFirmware.c +++ b/modules/rostests/apitests/kernel32/SystemFirmware.c @@ -8,6 +8,8 @@ #include "precomp.h" +#include <pseh/pseh2.h> + static UINT (WINAPI * pEnumSystemFirmwareTables)(DWORD, PVOID, DWORD); static UINT (WINAPI * pGetSystemFirmwareTable)(DWORD, DWORD, PVOID, DWORD); diff --git a/modules/rostests/apitests/localspl/dll/fpEnumPrinters.c b/modules/rostests/apitests/localspl/dll/fpEnumPrinters.c index b3d1625687d..346682ca946 100644 --- a/modules/rostests/apitests/localspl/dll/fpEnumPrinters.c +++ b/modules/rostests/apitests/localspl/dll/fpEnumPrinters.c @@ -15,6 +15,8 @@ #include <winspool.h> #include <winsplp.h> +#include <pseh/pseh2.h> + #include "../localspl_apitest.h" #include <spoolss.h> diff --git a/modules/rostests/apitests/ntdll/LdrEnumResources.c b/modules/rostests/apitests/ntdll/LdrEnumResources.c index e20cfd2bef5..1e0a0787f08 100644 --- a/modules/rostests/apitests/ntdll/LdrEnumResources.c +++ b/modules/rostests/apitests/ntdll/LdrEnumResources.c @@ -7,6 +7,8 @@ #include "precomp.h" +#include <pseh/pseh2.h> + typedef struct _TEST_RESOURCES { IMAGE_RESOURCE_DIRECTORY TypeDirectory; diff --git a/modules/rostests/apitests/ntdll/NtAllocateVirtualMemory.c b/modules/rostests/apitests/ntdll/NtAllocateVirtualMemory.c index aae94052e6b..235eaaf0095 100644 --- a/modules/rostests/apitests/ntdll/NtAllocateVirtualMemory.c +++ b/modules/rostests/apitests/ntdll/NtAllocateVirtualMemory.c @@ -10,6 +10,8 @@ #include "precomp.h" +#include <pseh/pseh2.h> + static PVOID Allocations[4096] = { NULL }; static ULONG CurrentAllocation = 0; diff --git a/modules/rostests/apitests/ntdll/NtMapViewOfSection.c b/modules/rostests/apitests/ntdll/NtMapViewOfSection.c index a191126df20..8723696c924 100644 --- a/modules/rostests/apitests/ntdll/NtMapViewOfSection.c +++ b/modules/rostests/apitests/ntdll/NtMapViewOfSection.c @@ -8,6 +8,8 @@ #include "precomp.h" +#include <pseh/pseh2.h> + void Test_PageFileSection(void) { diff --git a/modules/rostests/apitests/ntdll/RtlAllocateHeap.c b/modules/rostests/apitests/ntdll/RtlAllocateHeap.c index 6a327bb09f0..af3a8a7aecd 100644 --- a/modules/rostests/apitests/ntdll/RtlAllocateHeap.c +++ b/modules/rostests/apitests/ntdll/RtlAllocateHeap.c @@ -7,6 +7,8 @@ #include "precomp.h" +#include <pseh/pseh2.h> + PVOID Buffers[0x100]; START_TEST(RtlAllocateHeap) diff --git a/modules/rostests/apitests/ntdll/RtlBitmap.c b/modules/rostests/apitests/ntdll/RtlBitmap.c index 3b224be1e66..0c6bc7d59e5 100644 --- a/modules/rostests/apitests/ntdll/RtlBitmap.c +++ b/modules/rostests/apitests/ntdll/RtlBitmap.c @@ -2,6 +2,8 @@ #include "precomp.h" #include <versionhelpers.h> +#include <pseh/pseh2.h> + static BOOL IsBroken = FALSE; void diff --git a/modules/rostests/apitests/ntdll/RtlMultipleAllocateHeap.c b/modules/rostests/apitests/ntdll/RtlMultipleAllocateHeap.c index b2eb3132afa..1ae645facf5 100644 --- a/modules/rostests/apitests/ntdll/RtlMultipleAllocateHeap.c +++ b/modules/rostests/apitests/ntdll/RtlMultipleAllocateHeap.c @@ -6,6 +6,8 @@ */ #include "precomp.h" +#include <pseh/pseh2.h> + typedef ULONG (NTAPI *FN_RtlMultipleAllocateHeap)(IN PVOID, IN ULONG, IN SIZE_T, IN ULONG, OUT PVOID *); typedef ULONG (NTAPI *FN_RtlMultipleFreeHeap)(IN PVOID, IN ULONG, IN ULONG, OUT PVOID *); diff --git a/modules/rostests/apitests/ntdll/StackOverflow.c b/modules/rostests/apitests/ntdll/StackOverflow.c index 175142d01a3..1c3007079ee 100644 --- a/modules/rostests/apitests/ntdll/StackOverflow.c +++ b/modules/rostests/apitests/ntdll/StackOverflow.c @@ -7,6 +7,8 @@ #include "precomp.h" +#include <pseh/pseh2.h> + #ifdef _MSC_VER #pragma warning(disable : 4717) // disable warning about recursive function #endif diff --git a/modules/rostests/apitests/ntdll/load_notifications.c b/modules/rostests/apitests/ntdll/load_notifications.c index 8543f2f478a..6fca52939a5 100644 --- a/modules/rostests/apitests/ntdll/load_notifications.c +++ b/modules/rostests/apitests/ntdll/load_notifications.c @@ -7,6 +7,8 @@ #include "precomp.h" +#include <pseh/pseh2.h> + WCHAR dllpath[MAX_PATH]; LONG g_TlsCalled = 0; diff --git a/modules/rostests/apitests/sdk/delayimp.cpp b/modules/rostests/apitests/sdk/delayimp.cpp index ca8c76e1ffe..7073f001932 100644 --- a/modules/rostests/apitests/sdk/delayimp.cpp +++ b/modules/rostests/apitests/sdk/delayimp.cpp @@ -20,6 +20,8 @@ #include <imagehlp.h> #include <mmddk.h> +#include <pseh/pseh2.h> + /* Compatibility with the MS defines */ #ifndef FACILITY_VISUALCPP @@ -198,7 +200,7 @@ FARPROC WINAPI DliHook(unsigned dliNotify, PDelayLoadInfo pdli) g_VersionDll = LoadLibraryA("version.dll"); return (FARPROC)1; } - + } else if (dliNotify == dliNotePreGetProcAddress) { @@ -482,7 +484,7 @@ START_TEST(delayimp) ok(err == MMSYSERR_INVALHANDLE, "Expected err to be MMSYSERR_INVALHANDLE, was 0x%lx\n", err); CheckDliDone(); ok(g_BreakFunctionName == false, "Expected the functionname to be changed\n"); - + /* Make the LoadLib fail, manually load the library in the Failure Hook, Respond to the dliNotePreGetProcAddress with an alternate function address */ SetExpectedDli(g_sfc_key); diff --git a/modules/rostests/apitests/shlwapi/PathFindOnPath.c b/modules/rostests/apitests/shlwapi/PathFindOnPath.c index 9a4ba21ed6b..4b4f67d67b2 100644 --- a/modules/rostests/apitests/shlwapi/PathFindOnPath.c +++ b/modules/rostests/apitests/shlwapi/PathFindOnPath.c @@ -20,6 +20,8 @@ #include <shlwapi.h> #include <assert.h> +#include <pseh/pseh2.h> + #define EF_FULLPATH 1 #define EF_TESTDATA 2 #define EF_WIN_DIR 4 diff --git a/modules/rostests/apitests/shlwapi/SHAreIconsEqual.c b/modules/rostests/apitests/shlwapi/SHAreIconsEqual.c index 27592325c79..efaaea4d688 100644 --- a/modules/rostests/apitests/shlwapi/SHAreIconsEqual.c +++ b/modules/rostests/apitests/shlwapi/SHAreIconsEqual.c @@ -9,6 +9,8 @@ #include <shlwapi.h> #include "resource.h" +#include <pseh/pseh2.h> + static BOOL (WINAPI *pSHAreIconsEqual)(HICON hIcon1, HICON hIcon2); static const char* names[] = diff --git a/modules/rostests/apitests/shlwapi/SHLoadIndirectString.c b/modules/rostests/apitests/shlwapi/SHLoadIndirectString.c index 0eac5b04db6..5aeef6de517 100644 --- a/modules/rostests/apitests/shlwapi/SHLoadIndirectString.c +++ b/modules/rostests/apitests/shlwapi/SHLoadIndirectString.c @@ -9,6 +9,8 @@ #include <shlwapi.h> #include "resource.h" +#include <pseh/pseh2.h> + static void execute_test(LPCWSTR DllFile) { WCHAR DllBuffer[MAX_PATH + 20]; diff --git a/modules/rostests/apitests/spoolss/ReallocSplStr.c b/modules/rostests/apitests/spoolss/ReallocSplStr.c index 161d07070a9..a19aab3acbb 100644 --- a/modules/rostests/apitests/spoolss/ReallocSplStr.c +++ b/modules/rostests/apitests/spoolss/ReallocSplStr.c @@ -12,6 +12,8 @@ #include <winbase.h> #include <spoolss.h> +#include <pseh/pseh2.h> + START_TEST(ReallocSplStr) { const WCHAR wszTestString1[] = L"Test"; diff --git a/modules/rostests/winetests/kernel32/CMakeLists.txt b/modules/rostests/winetests/kernel32/CMakeLists.txt index d652970ff98..c46d3fdf669 100644 --- a/modules/rostests/winetests/kernel32/CMakeLists.txt +++ b/modules/rostests/winetests/kernel32/CMakeLists.txt @@ -55,6 +55,7 @@ if(USE_CLANG_CL OR (NOT MSVC)) endif() set_module_type(kernel32_winetest win32cui) +target_link_libraries(kernel32_winetest pseh) add_importlibs(kernel32_winetest user32 advapi32 msvcrt kernel32 ntdll) add_pch(kernel32_winetest precomp.h "${PCH_SKIP_SOURCE}") add_rostests_file(TARGET kernel32_winetest) diff --git a/modules/rostests/winetests/ntdll/CMakeLists.txt b/modules/rostests/winetests/ntdll/CMakeLists.txt index 21b6b7bdc97..33863166474 100644 --- a/modules/rostests/winetests/ntdll/CMakeLists.txt +++ b/modules/rostests/winetests/ntdll/CMakeLists.txt @@ -36,6 +36,8 @@ add_executable(ntdll_winetest ${SOURCE} ${PCH_SKIP_SOURCE}) +target_link_libraries(ntdll_winetest pseh) + if(USE_CLANG_CL OR (NOT MSVC)) target_compile_options(ntdll_winetest PRIVATE "-Wno-format") endif() diff --git a/sdk/lib/atl/CMakeLists.txt b/sdk/lib/atl/CMakeLists.txt index 3a0fb3ce0dc..9fb5d548228 100644 --- a/sdk/lib/atl/CMakeLists.txt +++ b/sdk/lib/atl/CMakeLists.txt @@ -9,3 +9,5 @@ target_include_directories(atl_classes INTERFACE target_compile_definitions(atl_classes INTERFACE "$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<NOT:$<BOOL:$<TARGET_PROPERTY:WITH_CXX_EXCEPTIONS>>>>:_ATL_NO_EXCEPTIONS>") + +target_link_libraries(atl_classes INTERFACE pseh) diff --git a/sdk/lib/atl/atlcom.h b/sdk/lib/atl/atlcom.h index 544de73244c..c9d92edbd9c 100644 --- a/sdk/lib/atl/atlcom.h +++ b/sdk/lib/atl/atlcom.h @@ -22,6 +22,7 @@ #pragma once #include <cguid.h> // for GUID_NULL +#include <pseh/pseh2.h> namespace ATL { diff --git a/sdk/lib/crt/crt.cmake b/sdk/lib/crt/crt.cmake index 3997ea778a9..6a1111789d7 100644 --- a/sdk/lib/crt/crt.cmake +++ b/sdk/lib/crt/crt.cmake @@ -603,7 +603,7 @@ if(USE_CLANG_CL) endif() add_library(crt ${CRT_SOURCE} ${CRT_WINE_SOURCE} ${crt_asm}) -target_link_libraries(crt chkstk) +target_link_libraries(crt chkstk ${PSEH_LIB}) target_compile_definitions(crt PRIVATE __MINGW_IMPORT=extern USE_MSVCRT_PREFIX diff --git a/sdk/lib/drivers/copysup/CMakeLists.txt b/sdk/lib/drivers/copysup/CMakeLists.txt index c84d41ed97d..fb009964639 100644 --- a/sdk/lib/drivers/copysup/CMakeLists.txt +++ b/sdk/lib/drivers/copysup/CMakeLists.txt @@ -4,4 +4,5 @@ list(APPEND SOURCE copysup.c) add_library(copysup ${SOURCE}) +target_link_libraries(copysup PRIVATE pseh) add_dependencies(copysup bugcodes xdk) diff --git a/sdk/lib/drivers/rdbsslib/CMakeLists.txt b/sdk/lib/drivers/rdbsslib/CMakeLists.txt index 7b6ec545500..5c1b9005f8c 100644 --- a/sdk/lib/drivers/rdbsslib/CMakeLists.txt +++ b/sdk/lib/drivers/rdbsslib/CMakeLists.txt @@ -7,4 +7,5 @@ list(APPEND SOURCE rdbss.c) add_library(rdbsslib ${SOURCE}) +target_link_libraries(rdbsslib PRIVATE pseh) add_dependencies(rdbsslib bugcodes xdk) diff --git a/sdk/lib/drivers/rxce/CMakeLists.txt b/sdk/lib/drivers/rxce/CMakeLists.txt index 38168bf6022..905c08b8136 100644 --- a/sdk/lib/drivers/rxce/CMakeLists.txt +++ b/sdk/lib/drivers/rxce/CMakeLists.txt @@ -6,4 +6,5 @@ list(APPEND SOURCE rxce.c) add_library(rxce ${SOURCE}) +target_link_libraries(rxce PRIVATE pseh) add_dependencies(rxce bugcodes xdk) diff --git a/sdk/lib/rtl/CMakeLists.txt b/sdk/lib/rtl/CMakeLists.txt index 1fe48a7817c..c2b2e5d1025 100644 --- a/sdk/lib/rtl/CMakeLists.txt +++ b/sdk/lib/rtl/CMakeLists.txt @@ -112,6 +112,7 @@ endif() add_asm_files(rtl_asm ${ASM_SOURCE}) add_library(rtl ${SOURCE} ${rtl_asm}) +target_link_libraries(rtl PRIVATE pseh) add_pch(rtl rtl.h SOURCE) add_dependencies(rtl psdk asm) @@ -124,3 +125,4 @@ list(APPEND SOURCE_VISTA add_library(rtl_vista ${SOURCE_VISTA}) add_pch(rtl_vista rtl_vista.h SOURCE_VISTA) add_dependencies(rtl_vista psdk) +target_link_libraries(rtl_vista PRIVATE pseh) diff --git a/win32ss/gdi/gdi32/objects/bitmap.c b/win32ss/gdi/gdi32/objects/bitmap.c index 3e56194ce95..91e8a0be9ee 100644 --- a/win32ss/gdi/gdi32/objects/bitmap.c +++ b/win32ss/gdi/gdi32/objects/bitmap.c @@ -1,5 +1,7 @@ #include <precomp.h> +#include <pseh/pseh2.h> + #define NDEBUG #include <debug.h> diff --git a/win32ss/gdi/gdi32/wine/CMakeLists.txt b/win32ss/gdi/gdi32/wine/CMakeLists.txt index 63e139cd8c9..4f70a336d05 100644 --- a/win32ss/gdi/gdi32/wine/CMakeLists.txt +++ b/win32ss/gdi/gdi32/wine/CMakeLists.txt @@ -23,4 +23,5 @@ list(APPEND SOURCE rosglue.c) add_library(winegdi ${SOURCE}) +target_link_libraries(winegdi PRIVATE pseh) add_dependencies(winegdi psdk) diff --git a/win32ss/printing/base/winspool/utils.c b/win32ss/printing/base/winspool/utils.c index 3fa4a37ef2d..1128f3d801e 100644 --- a/win32ss/printing/base/winspool/utils.c +++ b/win32ss/printing/base/winspool/utils.c @@ -9,6 +9,8 @@ #include <shlobj.h> #include <undocshell.h> +#include <pseh/pseh2.h> + #define MAX_GETPRINTER_SIZE 4096 - MAX_PATH typedef void (WINAPI *PPfpSHChangeNotify)(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2); @@ -160,7 +162,7 @@ IntProtectHandle( HANDLE hSpooler, BOOL Close ) // 2 : Close and/or shared // 1 : Failed Handle // 0 : In use. - return Ret; + return Ret; } // // This one too. diff --git a/win32ss/user/winsrv/consrv.cmake b/win32ss/user/winsrv/consrv.cmake index 48fb96d2de2..d2ef3a2b5ec 100644 --- a/win32ss/user/winsrv/consrv.cmake +++ b/win32ss/user/winsrv/consrv.cmake @@ -53,6 +53,7 @@ else() endif() add_library(consrv ${CONSRV_SOURCE}) +target_link_libraries(consrv pseh) add_dependencies(consrv psdk) add_pch(consrv consrv/consrv.h CONSRV_SOURCE) #add_object_library(consrv ${CONSRV_SOURCE}) diff --git a/win32ss/user/winsrv/usersrv.cmake b/win32ss/user/winsrv/usersrv.cmake index e7cbb1bae13..8db138e5a27 100644 --- a/win32ss/user/winsrv/usersrv.cmake +++ b/win32ss/user/winsrv/usersrv.cmake @@ -10,6 +10,7 @@ list(APPEND USERSRV_SOURCE usersrv/usersrv.h) add_library(usersrv ${USERSRV_SOURCE}) +target_link_libraries(usersrv pseh) add_dependencies(usersrv xdk) add_pch(usersrv usersrv/usersrv.h USERSRV_SOURCE) #add_object_library(usersrv ${USERSRV_SOURCE})
3 years, 8 months
1
0
0
0
[reactos] 19/29: [CMAKE] Introduce a GCC plugin for helping with amd64 SEH implementation
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=37bc01f42b6d940c763b0…
commit 37bc01f42b6d940c763b0d346f44971c7abe08d9 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Thu Apr 22 10:37:50 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed Apr 28 13:10:23 2021 +0200 [CMAKE] Introduce a GCC plugin for helping with amd64 SEH implementation \#pragma REACTOS SEH(except) \#pragma REACTOS SEH(finally) What it does is counting the number of SEH __try blocks and emit the proper assembly statements at function prologue It also checks for mixing C++ & SEH exception handling, which wouldn't work --- sdk/cmake/host-tools.cmake | 23 ++++- sdk/tools/CMakeLists.txt | 8 ++ sdk/tools/gcc_plugin_seh/CMakeLists.txt | 4 + sdk/tools/gcc_plugin_seh/main.cpp | 177 ++++++++++++++++++++++++++++++++ 4 files changed, 211 insertions(+), 1 deletion(-) diff --git a/sdk/cmake/host-tools.cmake b/sdk/cmake/host-tools.cmake index a738ff64c09..4633b1097d1 100644 --- a/sdk/cmake/host-tools.cmake +++ b/sdk/cmake/host-tools.cmake @@ -6,6 +6,13 @@ function(setup_host_tools) if(NOT MSVC) list(APPEND HOST_TOOLS rsym pefixup) endif() + if ((ARCH STREQUAL "amd64") AND (CMAKE_C_COMPILER_ID STREQUAL "GNU")) + execute_process( + COMMAND ${CMAKE_C_COMPILER} --print-file-name=plugin + OUTPUT_VARIABLE GCC_PLUGIN_DIR) + string(STRIP ${GCC_PLUGIN_DIR} GCC_PLUGIN_DIR) + list(APPEND HOST_MODULES gcc_plugin_seh) + endif() list(TRANSFORM HOST_TOOLS PREPEND "${REACTOS_BINARY_DIR}/host-tools/bin/" OUTPUT_VARIABLE HOST_TOOLS_OUTPUT) if (CMAKE_HOST_WIN32) list(TRANSFORM HOST_TOOLS_OUTPUT APPEND ".exe") @@ -13,13 +20,21 @@ function(setup_host_tools) set(HOST_EXTRA_DIR "$(ConfigurationName)/") endif() set(HOST_EXE_SUFFIX ".exe") + set(HOST_MODULE_SUFFIX ".dll") + else() + set(HOST_MODULE_SUFFIX ".so") endif() ExternalProject_Add(host-tools SOURCE_DIR ${REACTOS_SOURCE_DIR} PREFIX ${REACTOS_BINARY_DIR}/host-tools BINARY_DIR ${REACTOS_BINARY_DIR}/host-tools/bin - CMAKE_ARGS -UCMAKE_TOOLCHAIN_FILE -DARCH:STRING=${ARCH} -DCMAKE_INSTALL_PREFIX=${REACTOS_BINARY_DIR}/host-tools -DTOOLS_FOLDER=${REACTOS_BINARY_DIR}/host-tools/bin + CMAKE_ARGS + -UCMAKE_TOOLCHAIN_FILE + -DARCH:STRING=${ARCH} + -DCMAKE_INSTALL_PREFIX=${REACTOS_BINARY_DIR}/host-tools + -DTOOLS_FOLDER=${REACTOS_BINARY_DIR}/host-tools/bin + -DGCC_PLUGIN_DIR=${GCC_PLUGIN_DIR} BUILD_ALWAYS TRUE INSTALL_COMMAND ${CMAKE_COMMAND} -E true BUILD_BYPRODUCTS ${HOST_TOOLS_OUTPUT} @@ -32,4 +47,10 @@ function(setup_host_tools) set_target_properties(native-${_tool} PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/bin/${HOST_EXTRA_DIR}${_tool}${HOST_EXE_SUFFIX}) add_dependencies(native-${_tool} host-tools ${INSTALL_DIR}/bin/${HOST_EXTRA_DIR}${_tool}${HOST_EXE_SUFFIX}) endforeach() + + foreach(_module ${HOST_MODULES}) + add_library(native-${_module} MODULE IMPORTED) + set_target_properties(native-${_module} PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/bin/${HOST_EXTRA_DIR}${_module}${HOST_MODULE_SUFFIX}) + add_dependencies(native-${_module} host-tools ${INSTALL_DIR}/bin/${HOST_EXTRA_DIR}${_module}${HOST_MODULE_SUFFIX}) + endforeach() endfunction() diff --git a/sdk/tools/CMakeLists.txt b/sdk/tools/CMakeLists.txt index 3f836f8e9bf..956a6dc7060 100644 --- a/sdk/tools/CMakeLists.txt +++ b/sdk/tools/CMakeLists.txt @@ -4,6 +4,11 @@ function(add_host_tool _tool) set_target_properties(${_tool} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${TOOLS_FOLDER}) endfunction() +function(add_host_module _module) + add_library(${_module} MODULE ${ARGN}) + set_target_properties(${_module} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${TOOLS_FOLDER}) +endfunction() + if(MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -DHAVE_IO_H=1) add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:/EHsc>") @@ -38,6 +43,9 @@ add_subdirectory(xml2sdb) if(NOT MSVC) add_subdirectory(log2lines) add_subdirectory(rsym) +if (ARCH STREQUAL "amd64") + add_subdirectory(gcc_plugin_seh) +endif() add_host_tool(pefixup pefixup.c) if (ARCH STREQUAL "amd64") diff --git a/sdk/tools/gcc_plugin_seh/CMakeLists.txt b/sdk/tools/gcc_plugin_seh/CMakeLists.txt new file mode 100644 index 00000000000..b96571f7fbe --- /dev/null +++ b/sdk/tools/gcc_plugin_seh/CMakeLists.txt @@ -0,0 +1,4 @@ + +add_host_module(gcc_plugin_seh main.cpp) +target_include_directories(gcc_plugin_seh PRIVATE ${GCC_PLUGIN_DIR}/include) +set_target_properties(gcc_plugin_seh PROPERTIES POSITION_INDEPENDENT_CODE ON) diff --git a/sdk/tools/gcc_plugin_seh/main.cpp b/sdk/tools/gcc_plugin_seh/main.cpp new file mode 100644 index 00000000000..22df978e0c6 --- /dev/null +++ b/sdk/tools/gcc_plugin_seh/main.cpp @@ -0,0 +1,177 @@ +/* + * PROJECT: ReactOS SDK + * LICENSE: BSD Zero Clause License (
https://spdx.org/licenses/0BSD.html
) + * PURPOSE: Helper pragma implementation for pseh library (amd64) + * COPYRIGHT: Copyright 2021 Jérôme Gardou + */ + +#include <gcc-plugin.h> +#include <plugin-version.h> +#include <function.h> +#include <tree.h> +#include <c-family/c-pragma.h> +#include <c-family/c-common.h> + +#include <iostream> +#include <sstream> +#include <unordered_map> +#include <vector> + +#define is_alpha(c) (((c)>64 && (c)<91) || ((c)>96 && (c)<123)) + +#if defined(_WIN32) || defined(WIN32) +#define VISIBLE __decspec(dllexport) +#else +#define VISIBLE __attribute__((__visibility__("default"))) +#endif + +#define UNUSED __attribute__((__unused__)) + +int +VISIBLE +plugin_is_GPL_compatible = 1; + +struct seh_function +{ + bool unwind; + bool except; + tree asm_header_text; + tree asm_header; + size_t count; + + seh_function(struct function* fun) + : unwind(false) + , except(false) + , count(0) + { + /* Reserve space for our header statement */ + char buf[256]; + memset(buf, 0, sizeof(buf)); + asm_header_text = build_string(sizeof(buf), buf); + asm_header = build_stmt(fun->function_start_locus, ASM_EXPR, asm_header_text, NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE); + ASM_VOLATILE_P(asm_header) = 1; + add_stmt(asm_header); + } +}; + +static std::unordered_map<struct function*, struct seh_function*> func_seh_map = {}; + +static +struct seh_function* +get_seh_function() +{ + auto search = func_seh_map.find(cfun); + if (search != func_seh_map.end()) + return search->second; + + auto seh_fun = new seh_function(cfun); + func_seh_map.insert({cfun, seh_fun}); + + return seh_fun; +} + +static +void +handle_seh_pragma(cpp_reader* UNUSED parser) +{ + tree x, arg; + std::stringstream label_decl; + + if (!cfun) + { + error("%<#pragma REACTOS seh%> is not allowed outside functions"); + return; + } + + if ((pragma_lex(&x) != CPP_OPEN_PAREN) || + (pragma_lex(&arg) != CPP_NAME) || + (pragma_lex(&x) != CPP_CLOSE_PAREN) || + (pragma_lex(&x) != CPP_EOF)) + { + error("%<#pragma REACTOS seh%> needs one parameter%>"); + return; + } + + const char* op = IDENTIFIER_POINTER(arg); + + seh_function* seh_fun = get_seh_function(); + if (strcmp(op, "except") == 0) + seh_fun->except = true; + else if (strcmp(op, "finally") == 0) + seh_fun->unwind = true; + else + { + error("Wrong argument for %<#pragma REACTOS seh%>. Expected \"except\" or \"finally\""); + return; + } + seh_fun->count++; + + /* Make sure we use a frame pointer. REACTOS' PSEH depends on this */ + cfun->machine->accesses_prev_frame = 1; +} + +static +void +finish_seh_function(void* event_data, void* UNUSED user_data) +{ + tree fndef = (tree)event_data; + struct function* fun = DECL_STRUCT_FUNCTION(fndef); + + auto search = func_seh_map.find(fun); + if (search == func_seh_map.end()) + return; + + /* Get our SEH details and remove us from the map */ + seh_function* seh_fun = search->second; + func_seh_map.erase(search); + + if (DECL_FUNCTION_PERSONALITY(fndef) != nullptr) + { + error("Function %s has a personality. Are you mixing SEH with C++ exceptions ?", + IDENTIFIER_POINTER(fndef)); + return; + } + + /* Update asm statement */ + std::stringstream asm_str; + asm_str << ".seh_handler __C_specific_handler"; + if (seh_fun->unwind) + asm_str << ", @unwind"; + if (seh_fun->except) + asm_str << ", @except"; + asm_str << "\n"; + asm_str << "\t.seh_handlerdata\n"; + asm_str << "\t.long " << seh_fun->count << "\n"; + asm_str << "\t.seh_code"; + + strncpy(const_cast<char*>(TREE_STRING_POINTER(seh_fun->asm_header_text)), + asm_str.str().c_str(), + TREE_STRING_LENGTH(seh_fun->asm_header_text)); + + delete seh_fun; +} + +static +void +register_seh_pragmas(void* UNUSED event_data, void* UNUSED user_data) +{ + c_register_pragma("REACTOS", "seh", handle_seh_pragma); +} + +/* Return 0 on success or error code on failure */ +extern "C" +VISIBLE +int plugin_init(struct plugin_name_args *info, /* Argument infor */ + struct plugin_gcc_version *version) /* Version of GCC */ +{ + if (!plugin_default_version_check (version, &gcc_version)) + { + std::cerr << "This GCC plugin is for version " << GCCPLUGIN_VERSION_MAJOR << "." << GCCPLUGIN_VERSION_MINOR << "\n"; + return 1; + } + + register_callback(info->base_name, PLUGIN_PRAGMAS, register_seh_pragmas, NULL); + register_callback(info->base_name, PLUGIN_FINISH_PARSE_FUNCTION, finish_seh_function, NULL); + + return 0; +}
3 years, 8 months
1
0
0
0
← Newer
1
2
3
4
5
...
18
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Results per page:
10
25
50
100
200