fix(Clang&MinGW): Fix Clang and MinGW builds on linux. (#303)

* fix(Clang&MinGW): Fix Clang and MinGW builds on linux.

This may break building with clang for windows-gnu target, but it
probably doesn't work anyway.

* chore(FormatMoney): Cast like the other hooks.

---------

Co-authored-by: tupoy-ya <tupoy-ya@users.noreply.github.com>
This commit is contained in:
tupoy-ya
2025-05-17 07:30:20 +05:00
committed by GitHub
parent ff5d776c47
commit 61c2eab432
18 changed files with 28 additions and 23 deletions
+1
View File
@@ -1,2 +1,3 @@
build/ build/
.cache
.vs .vs
+2 -3
View File
@@ -33,9 +33,8 @@ message(STATUS "Setting up include directories.")
target_include_directories(${PROJECT_NAME} PRIVATE target_include_directories(${PROJECT_NAME} PRIVATE
"${SRC_DIR}" "${SRC_DIR}"
"${imgui_SOURCE_DIR}" "${imgui_SOURCE_DIR}"
"${minhook_SOURCE_DIR}/include" "${minhook_SOURCE_DIR}/include"
"${minhook_SOURCE_DIR}/src/hde" "${minhook_SOURCE_DIR}/src/hde"
"${gtav_classes_SOURCE_DIR}"
) )
message(STATUS "Setting up linked libraries") message(STATUS "Setting up linked libraries")
+6 -5
View File
@@ -8,11 +8,8 @@ if(USE_GCC OR USE_CLANG)
set(TOOLCHAIN_PREFIX "x86_64-w64-mingw32" CACHE STRING "Set toolchain. Default: x86_64-w64-mingw32") set(TOOLCHAIN_PREFIX "x86_64-w64-mingw32" CACHE STRING "Set toolchain. Default: x86_64-w64-mingw32")
message(STATUS "Using ${TOOLCHAIN_PREFIX} toolchain") message(STATUS "Using ${TOOLCHAIN_PREFIX} toolchain")
set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32) set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
set(CMAKE_SYSTEM_NAME "Windows")
set(CMAKE_ASM_MASM_COMPILER "uasm") set(CMAKE_ASM_MASM_COMPILER "uasm")
set(CMAKE_C_COMPILER_TARGET x86_64-windows-gnu)
set(CMAKE_CXX_COMPILER_TARGET x86_64-windows-gnu)
set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran) set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran)
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres) set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
@@ -30,16 +27,20 @@ if(USE_GCC OR USE_CLANG)
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-fpermissive;-fno-rtti${CXX_FLAGS}>") add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-fpermissive;-fno-rtti${CXX_FLAGS}>")
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++) set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
set(CMAKE_C_COMPILER_TARGET x86_64-windows-gnu)
set(CMAKE_CXX_COMPILER_TARGET x86_64-windows-gnu)
endif() endif()
if(USE_CLANG) if(USE_CLANG)
message(STATUS "Using clang compiler.") message(STATUS "Using clang compiler.")
set(CMAKE_C_COMPILER clang) set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++) set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_C_COMPILER_TARGET x86_64-windows-msvc)
set(CMAKE_CXX_COMPILER_TARGET x86_64-windows-msvc)
# Disable RTTI to work around libstdc++ issue https://stackoverflow.com/a/77025827 # Disable RTTI to work around libstdc++ issue https://stackoverflow.com/a/77025827
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-fuse-ld=lld;-femulated-tls;-fno-rtti${CXX_FLAGS}>") add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-fuse-ld=lld;-fno-rtti${CXX_FLAGS}>")
add_link_options(-fuse-ld=lld -femulated-tls -fno-rtti) add_link_options(-fuse-ld=lld -fno-rtti)
endif() endif()
endif() endif()
+1 -1
View File
@@ -1,6 +1,6 @@
include(FetchContent) include(FetchContent)
message(STATUS "Setting up nlohmann::json") message(STATUS "Setting up nlohmann::json")
FetchContent_Declare(json GIT_REPOSITORY "https://github.com/nlohmann/json/" GIT_TAG v3.11.2 GIT_SHALLOW TRUE) FetchContent_Declare(json GIT_REPOSITORY "https://github.com/nlohmann/json/" GIT_TAG v3.12.0 GIT_SHALLOW TRUE)
option(JSON_MultipleHeaders "Disable nlohmann JSON multi header default." OFF) option(JSON_MultipleHeaders "Disable nlohmann JSON multi header default." OFF)
FetchContent_MakeAvailable(json) FetchContent_MakeAvailable(json)
+1 -1
View File
@@ -6,7 +6,7 @@ message(STATUS "Setting up ${LIB_NAME}")
FetchContent_Declare( FetchContent_Declare(
${LIB_NAME} ${LIB_NAME}
GIT_REPOSITORY https://github.com/TsudaKageyu/minhook.git GIT_REPOSITORY https://github.com/TsudaKageyu/minhook.git
GIT_TAG 98b74f1fc12d00313d91f10450e5b3e0036175e3 GIT_TAG 2b003bb063d66f016cc1aef7d63951350ce60f35
GIT_PROGRESS TRUE GIT_PROGRESS TRUE
) )
FetchContent_MakeAvailable(${LIB_NAME}) FetchContent_MakeAvailable(${LIB_NAME})
+1 -1
View File
@@ -60,7 +60,7 @@ namespace ImGui
} }
if (i % 4 == 0) if (i % 4 == 0)
{ {
ImGui::Text("%i", i); ImGui::Text("%zu", i);
ImGui::EndGroup(); ImGui::EndGroup();
} }
if (i % 16 != 0) if (i % 16 != 0)
+1 -1
View File
@@ -57,7 +57,7 @@ namespace YimMenu
template<typename T> template<typename T>
T GetOriginal() T GetOriginal()
{ {
return static_cast<T>(m_OriginalFunction); return reinterpret_cast<T>(m_OriginalFunction);
} }
}; };
+2 -2
View File
@@ -19,12 +19,12 @@ namespace YimMenu::Features
{ {
if (!formatIntCaller1Hook) if (!formatIntCaller1Hook)
{ {
formatIntCaller1Hook = CallSiteHook::AddHook(Pointers.FormatIntCaller1, FormatIntHook); formatIntCaller1Hook = CallSiteHook::AddHook(Pointers.FormatIntCaller1, reinterpret_cast<void*>(FormatIntHook));
} }
formatIntCaller1Hook->Enable(); formatIntCaller1Hook->Enable();
if (!formatIntCaller2Hook) if (!formatIntCaller2Hook)
{ {
formatIntCaller2Hook = CallSiteHook::AddHook(Pointers.FormatIntCaller2, FormatIntHook); formatIntCaller2Hook = CallSiteHook::AddHook(Pointers.FormatIntCaller2, reinterpret_cast<void*>(FormatIntHook));
} }
formatIntCaller2Hook->Enable(); formatIntCaller2Hook->Enable();
NativeHooks::AddHook("shop_controller"_J, NativeIndex::SCALEFORM_MOVIE_METHOD_ADD_PARAM_INT, &ScaleformAddIntHook); NativeHooks::AddHook("shop_controller"_J, NativeIndex::SCALEFORM_MOVIE_METHOD_ADD_PARAM_INT, &ScaleformAddIntHook);
+2 -2
View File
@@ -85,8 +85,8 @@ namespace YimMenu::Submenus
ImGui::Text("Thread ID: %d", curThread->m_Context.m_ThreadId); ImGui::Text("Thread ID: %d", curThread->m_Context.m_ThreadId);
ImGui::Text("Stack Size: %d", curThread->m_Context.m_StackSize); ImGui::Text("Stack Size: %d", curThread->m_Context.m_StackSize);
ImGui::Text("Stack Pointer: 0x%X", &curThread->m_Context.m_StackPointer); ImGui::Text("Stack Pointer: 0x%X", curThread->m_Context.m_StackPointer);
ImGui::Text("Program Counter: 0x%X", &curThread->m_Context.m_ProgramCounter); // This is not really accurate (always points to the WAIT) ImGui::Text("Program Counter: 0x%X", curThread->m_Context.m_ProgramCounter); // This is not really accurate (always points to the WAIT)
if (curThread->m_Context.m_State == rage::scrThread::State::KILLED) if (curThread->m_Context.m_State == rage::scrThread::State::KILLED)
ImGui::Text("Exit Reason: %s", curThread->m_ErrorMessage); ImGui::Text("Exit Reason: %s", curThread->m_ErrorMessage);
})); }));
+1 -1
View File
@@ -4,7 +4,7 @@
#include "game/frontend/items/Items.hpp" #include "game/frontend/items/Items.hpp"
#include "game/frontend/submenus/Network/SavedPlayers.hpp" #include "game/frontend/submenus/Network/SavedPlayers.hpp"
#include "game/gta/Network.hpp" #include "game/gta/Network.hpp"
#include "game/frontend/submenus/Network/RandomEvents.hpp" #include "game/frontend/submenus/network/RandomEvents.hpp"
namespace YimMenu::Submenus namespace YimMenu::Submenus
{ {
+1 -1
View File
@@ -159,7 +159,7 @@ namespace YimMenu
ENTITY_ASSERT_VALID(); ENTITY_ASSERT_VALID();
ENTITY_ASSERT_CONTROL(); ENTITY_ASSERT_CONTROL();
WEAPON::SET_PED_INFINITE_AMMO(GetHandle(), infinite, NULL); WEAPON::SET_PED_INFINITE_AMMO(GetHandle(), infinite, 0);
} }
void Ped::SetInfiniteClip(bool infinite) void Ped::SetInfiniteClip(bool infinite)
+1 -1
View File
@@ -3,7 +3,7 @@
#include <type_traits> #include <type_traits>
#include <types/script/scrThread.hpp> #include <types/script/scrThread.hpp>
#include <core/util/Joaat.hpp> #include <core/util/Joaat.hpp>
#include <src/game/gta/Scripts.hpp> #include <game/gta/Scripts.hpp>
namespace YimMenu namespace YimMenu
{ {
+1 -1
View File
@@ -2,7 +2,7 @@
namespace YimMenu namespace YimMenu
{ {
static constexpr std::array scriptNames = { static constexpr const char* scriptNames[] = {
"abigail1", "abigail1",
"abigail2", "abigail2",
"achievement_controller", "achievement_controller",
@@ -54,7 +54,6 @@ namespace YimMenu::Hooks
if (arx_score >= 2) if (arx_score >= 2)
{ {
auto from_offset = *reinterpret_cast<std::uint64_t*>(_AddressOfReturnAddress()) - ModuleMgr.Get("GTA5_Enhanced.exe"_J)->Base();
return; return;
} }
+1
View File
@@ -28,6 +28,7 @@ namespace rage
std::uint32_t m_CxnId; // 0x0044 std::uint32_t m_CxnId; // 0x0044
rage::netEvent* m_This; // 0x0048 rage::netEvent* m_This; // 0x0048
uint32_t m_PeerId; // 0x0050 uint32_t m_PeerId; // 0x0050
char pad_0084[4]; // 0x0054
}; };
static_assert(sizeof(rage::netEvent) == 0x58); static_assert(sizeof(rage::netEvent) == 0x58);
+4
View File
@@ -248,8 +248,10 @@ class CExplosionEvent : public rage::netGameEvent
public: public:
void Deserialize(rage::datBitBuffer& buffer); void Deserialize(rage::datBitBuffer& buffer);
#if !__GNUC__
struct struct
{ {
#endif
ExplosionType m_ExplosionType; // 0x30 ExplosionType m_ExplosionType; // 0x30
rage::fvector3 m_Position; // 0x40 rage::fvector3 m_Position; // 0x40
uint64_t m_0x50; // 0x50 uint64_t m_0x50; // 0x50
@@ -282,7 +284,9 @@ public:
bool m_Expected; // 0xC2 -- for telemetry bool m_Expected; // 0xC2 -- for telemetry
uint32_t m_ScriptHash; // 0xC4 -- for telemetry uint32_t m_ScriptHash; // 0xC4 -- for telemetry
uint32_t m_ProgramCounter; // 0xC8 -- for telemetry uint32_t m_ProgramCounter; // 0xC8 -- for telemetry
#if !__GNUC__
}; };
#endif
uint16_t m_TargetEntity; // 0xD0 uint16_t m_TargetEntity; // 0xD0
uint16_t m_TargetEnt2; // 0xD2 uint16_t m_TargetEnt2; // 0xD2
uint16_t m_OwnerNetId; // 0xD4 uint16_t m_OwnerNetId; // 0xD4
+1 -1
View File
@@ -10,4 +10,4 @@ private: \
virtual bool _0x28(void**) = 0; \ virtual bool _0x28(void**) = 0; \
virtual void destructor() = 0; \ virtual void destructor() = 0; \
\ \
public: public:
+1 -1
View File
@@ -42,7 +42,7 @@ namespace rage
v11 = 8; v11 = 8;
if (size > 8) if (size > 8)
{ {
v12 = 1i64; v12 = 1;
do do
{ {
if (v12 > v9) if (v12 > v9)