Skip to content

Commit

Permalink
Add BaseAdress_gcc_x64.cmake and use it in the CMakeLists
Browse files Browse the repository at this point in the history
  • Loading branch information
julenuri committed Oct 24, 2023
1 parent 501c2bd commit d14fc85
Show file tree
Hide file tree
Showing 4 changed files with 615 additions and 2 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,11 @@ Enable this if the module uses typeid or dynamic_cast. You will probably need to
include(sdk/cmake/baseaddress_msvc.cmake)
endif()
else()
include(sdk/cmake/baseaddress.cmake)
endif()
if (ARCH STREQUAL "amd64")
include(sdk/cmake/baseaddress_gcc_x64.cmake)
else()
include(sdk/cmake/baseaddress.cmake)
endif()

# For MSVC builds, this puts all debug symbols file in the same directory.
if(MSVC)
Expand Down
120 changes: 120 additions & 0 deletions GCC8x64-2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
diff --git a/dll/win32/advapi32/service/eventlog.c b/dll/win32/advapi32/service/eventlog.c
index 028e5d234ce..3ba4bee8e97 100644
--- a/dll/win32/advapi32/service/eventlog.c
+++ b/dll/win32/advapi32/service/eventlog.c
@@ -94,6 +94,9 @@ EVENTLOG_HANDLE_A_unbind(EVENTLOG_HANDLE_A UNCServerName,
handle_t __RPC_USER
EVENTLOG_HANDLE_W_bind(EVENTLOG_HANDLE_W UNCServerName)
{
+ #ifdef _M_AMD64
+ return NULL;
+ #endif
handle_t hBinding = NULL;
RPC_WSTR pszStringBinding;
RPC_STATUS status;
diff --git a/dll/win32/kernel32/client/debugger.c b/dll/win32/kernel32/client/debugger.c
index a466296f451..9d5529f4dc8 100644
--- a/dll/win32/kernel32/client/debugger.c
+++ b/dll/win32/kernel32/client/debugger.c
@@ -692,6 +692,7 @@ VOID
WINAPI
OutputDebugStringA(IN LPCSTR _OutputString)
{
+ #ifndef _M_AMD64
_SEH2_TRY
{
ULONG_PTR a_nArgs[2];
@@ -703,6 +704,7 @@ OutputDebugStringA(IN LPCSTR _OutputString)
RaiseException(DBG_PRINTEXCEPTION_C, 0, 2, a_nArgs);
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ #endif
{
/* no user-mode debugger: try the systemwide debug message monitor, or the
kernel debugger as a last resort */
@@ -740,6 +742,7 @@ OutputDebugStringA(IN LPCSTR _OutputString)

_SEH2_TRY
{
+ DPRINT1("SIMONE 1\n");
volatile PCHAR a_cBuffer = NULL;

/* opening the mutex failed */
@@ -790,6 +793,7 @@ OutputDebugStringA(IN LPCSTR _OutputString)

_SEH2_TRY
{
+ DPRINT1("SIMONE 1\n");
/* size of the current output block */
volatile SIZE_T nRoundLen;

@@ -885,6 +889,7 @@ OutputDebugStringA(IN LPCSTR _OutputString)
}
_SEH2_FINALLY
{
+ DPRINT1("SIMONE 2\n");
/* close all the still open resources */
if (hDBMonBufferReady) CloseHandle(hDBMonBufferReady);
if (pDBMonBuffer) UnmapViewOfFile(pDBMonBuffer);
@@ -897,7 +902,9 @@ OutputDebugStringA(IN LPCSTR _OutputString)
}
_SEH2_END;
}
+ #ifndef _M_AMD64
_SEH2_END;
+ #endif
}

/*
diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h
index c7bf663d1c8..95d5256f2c8 100644
--- a/ntoskrnl/include/internal/mm.h
+++ b/ntoskrnl/include/internal/mm.h
@@ -868,7 +868,8 @@ MmDeleteKernelStack(PVOID Stack,

/* balance.c / pagefile.c******************************************************/

-inline VOID UpdateTotalCommittedPages(LONG Delta)
+FORCEINLINE
+VOID UpdateTotalCommittedPages(LONG Delta)
{
/*
* Add up all the used "Committed" memory + pagefile.
diff --git a/ntoskrnl/ntos.cmake b/ntoskrnl/ntos.cmake
index 1bef231351f..10ca85a37ec 100644
--- a/ntoskrnl/ntos.cmake
+++ b/ntoskrnl/ntos.cmake
@@ -1,3 +1,4 @@
+add_compile_options(-O0)

include_directories(
${REACTOS_SOURCE_DIR}
diff --git a/sdk/cmake/baseaddress.cmake b/sdk/cmake/baseaddress.cmake
index 02ad613b9b9..fa58958bbb2 100644
--- a/sdk/cmake/baseaddress.cmake
+++ b/sdk/cmake/baseaddress.cmake
@@ -1,8 +1,8 @@
# Generated from output-MinGW-i386/
# Generated by sdk/tools/gen_baseaddress.py

-set(baseaddress_ntdll 0x7c920000) # should be above 0x7c920000
-set(baseaddress_kernel32 0x7c620000)
+set(baseaddress_ntdll 0x7c800000) # should be above 0x7c920000
+set(baseaddress_kernel32 0x77e40000)
set(baseaddress_msvcrt 0x7c530000)
set(baseaddress_advapi32 0x7c470000)
set(baseaddress_gdi32 0x7c210000)
diff --git a/sdk/lib/rtl/amd64/unwind.c b/sdk/lib/rtl/amd64/unwind.c
index dec55f7d3a5..a3413b3c56d 100644
--- a/sdk/lib/rtl/amd64/unwind.c
+++ b/sdk/lib/rtl/amd64/unwind.c
@@ -847,6 +847,9 @@ RtlpUnwindInternal(

/* We have successfully unwound a frame. Copy the unwind context back. */
*ContextRecord = UnwindContext;
+ #ifdef _M_AMD64
+ return TRUE;
+ #endif
}

if (ExceptionRecord->ExceptionCode != STATUS_UNWIND_CONSOLIDATE)
106 changes: 106 additions & 0 deletions GCC8x64-2new.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
diff --git a/dll/win32/advapi32/service/eventlog.c b/dll/win32/advapi32/service/eventlog.c
index 028e5d234ce..3ba4bee8e97 100644
--- a/dll/win32/advapi32/service/eventlog.c
+++ b/dll/win32/advapi32/service/eventlog.c
@@ -94,6 +94,9 @@ EVENTLOG_HANDLE_A_unbind(EVENTLOG_HANDLE_A UNCServerName,
handle_t __RPC_USER
EVENTLOG_HANDLE_W_bind(EVENTLOG_HANDLE_W UNCServerName)
{
+ #ifdef _M_AMD64
+ return NULL;
+ #endif
handle_t hBinding = NULL;
RPC_WSTR pszStringBinding;
RPC_STATUS status;
diff --git a/dll/win32/kernel32/client/debugger.c b/dll/win32/kernel32/client/debugger.c
index a466296f451..9d5529f4dc8 100644
--- a/dll/win32/kernel32/client/debugger.c
+++ b/dll/win32/kernel32/client/debugger.c
@@ -692,6 +692,7 @@ VOID
WINAPI
OutputDebugStringA(IN LPCSTR _OutputString)
{
+ #ifndef _M_AMD64
_SEH2_TRY
{
ULONG_PTR a_nArgs[2];
@@ -703,6 +704,7 @@ OutputDebugStringA(IN LPCSTR _OutputString)
RaiseException(DBG_PRINTEXCEPTION_C, 0, 2, a_nArgs);
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ #endif
{
/* no user-mode debugger: try the systemwide debug message monitor, or the
kernel debugger as a last resort */
@@ -740,6 +742,7 @@ OutputDebugStringA(IN LPCSTR _OutputString)

_SEH2_TRY
{
+ DPRINT1("SIMONE 1\n");
volatile PCHAR a_cBuffer = NULL;

/* opening the mutex failed */
@@ -790,6 +793,7 @@ OutputDebugStringA(IN LPCSTR _OutputString)

_SEH2_TRY
{
+ DPRINT1("SIMONE 1\n");
/* size of the current output block */
volatile SIZE_T nRoundLen;

@@ -885,6 +889,7 @@ OutputDebugStringA(IN LPCSTR _OutputString)
}
_SEH2_FINALLY
{
+ DPRINT1("SIMONE 2\n");
/* close all the still open resources */
if (hDBMonBufferReady) CloseHandle(hDBMonBufferReady);
if (pDBMonBuffer) UnmapViewOfFile(pDBMonBuffer);
@@ -897,7 +902,9 @@ OutputDebugStringA(IN LPCSTR _OutputString)
}
_SEH2_END;
}
+ #ifndef _M_AMD64
_SEH2_END;
+ #endif
}

/*
diff --git a/ntoskrnl/ntos.cmake b/ntoskrnl/ntos.cmake
index 1bef231351f..10ca85a37ec 100644
--- a/ntoskrnl/ntos.cmake
+++ b/ntoskrnl/ntos.cmake
@@ -1,3 +1,4 @@
+add_compile_options(-O0)

include_directories(
${REACTOS_SOURCE_DIR}
diff --git a/sdk/cmake/baseaddress.cmake b/sdk/cmake/baseaddress.cmake
index 02ad613b9b9..fa58958bbb2 100644
--- a/sdk/cmake/baseaddress.cmake
+++ b/sdk/cmake/baseaddress.cmake
@@ -1,8 +1,8 @@
# Generated from output-MinGW-i386/
# Generated by sdk/tools/gen_baseaddress.py

-set(baseaddress_ntdll 0x7c920000) # should be above 0x7c920000
-set(baseaddress_kernel32 0x7c620000)
+set(baseaddress_ntdll 0x7c800000) # should be above 0x7c920000
+set(baseaddress_kernel32 0x77e40000)
set(baseaddress_msvcrt 0x7c530000)
set(baseaddress_advapi32 0x7c470000)
set(baseaddress_gdi32 0x7c210000)
diff --git a/sdk/lib/rtl/amd64/unwind.c b/sdk/lib/rtl/amd64/unwind.c
index dec55f7d3a5..a3413b3c56d 100644
--- a/sdk/lib/rtl/amd64/unwind.c
+++ b/sdk/lib/rtl/amd64/unwind.c
@@ -847,6 +847,9 @@ RtlpUnwindInternal(

/* We have successfully unwound a frame. Copy the unwind context back. */
*ContextRecord = UnwindContext;
+ #ifdef _M_AMD64
+ return TRUE;
+ #endif
}

if (ExceptionRecord->ExceptionCode != STATUS_UNWIND_CONSOLIDATE)
Loading

0 comments on commit d14fc85

Please sign in to comment.