From 5ad3db3170db38e85d83cc566f22c4cf82f12f9a Mon Sep 17 00:00:00 2001 From: Grinch_ Date: Sun, 10 Jan 2021 02:06:53 +0600 Subject: [PATCH] Fix incompatibilities with fla & crashes --- .vscode/c_cpp_properties.json | 15 ++- CMakeLists.txt | 1 + src/CheatMenu.cpp | 2 +- src/CheatMenu.h | 1 + src/Dllmain.cpp | 31 ++++++ src/Hook.cpp | 2 - src/Menu.cpp | 2 +- src/MenuInfo.h | 2 +- src/NeonAPI.cpp | 2 +- src/Teleport.cpp | 3 + src/Vehicle.cpp | 5 +- src/Weapon.cpp | 2 +- src/pch.h | 1 + src/tests/CMakeLists.txt | 15 ++- src/tests/Test.cpp | 29 +++-- src/vendor/CMakeLists.txt | 7 ++ src/vendor/fla/IDaccess.cpp | 97 ++++++++++++++++ src/vendor/fla/IDaccess.h | 70 ++++++++++++ src/vendor/fla/Library/Library.cpp | 11 ++ src/vendor/fla/Library/Library.h | 25 +++++ src/vendor/fla/Main.cpp | 30 +++++ src/vendor/fla/Main.h | 21 ++++ src/vendor/fla/common/CValueExtension.h | 56 ++++++++++ src/vendor/fla/common/CdDirectory.h | 25 +++++ src/vendor/fla/common/common.h | 29 +++++ src/vendor/kiero/minhook/CMakeLists.txt | 141 ------------------------ 26 files changed, 462 insertions(+), 163 deletions(-) create mode 100644 src/Dllmain.cpp create mode 100644 src/vendor/fla/IDaccess.cpp create mode 100644 src/vendor/fla/IDaccess.h create mode 100644 src/vendor/fla/Library/Library.cpp create mode 100644 src/vendor/fla/Library/Library.h create mode 100644 src/vendor/fla/Main.cpp create mode 100644 src/vendor/fla/Main.h create mode 100644 src/vendor/fla/common/CValueExtension.h create mode 100644 src/vendor/fla/common/CdDirectory.h create mode 100644 src/vendor/fla/common/common.h delete mode 100644 src/vendor/kiero/minhook/CMakeLists.txt diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 10e228b..94549b4 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -14,7 +14,20 @@ "GTASA", "_DEBUG", "UNICODE", - "_UNICODE" + "_UNICODE", + "_CRT_SECURE_NO_WARNINGS", + "_CRT_NON_CONFORMING_SWPRINTFS;", + "GTASA;", + "GTAGAME_NAME=\"San Andreas\"", + "GTAGAME_ABBR=\"SA\"", + "GTAGAME_ABBRLOW=\"sa\"", + "GTAGAME_PROTAGONISTNAME=\"CJ\"", + "GTAGAME_CITYNAME=\"San Andreas\"", + "_LA_SUPPORT", + "_DX9_SDK_INSTALLED", + "PLUGIN_SGV_10US", + "_MBCS", + "IS_PLATFORM_WIN" ], "windowsSdkVersion": "10.0.10240.0", "compilerPath": "cl.exe", diff --git a/CMakeLists.txt b/CMakeLists.txt index 38ec64a..d3dc482 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -117,6 +117,7 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE "_DX9_SDK_INSTALLED;" "PLUGIN_SGV_10US;" "_MBCS" + "IS_PLATFORM_WIN" ) ################################################################################ diff --git a/src/CheatMenu.cpp b/src/CheatMenu.cpp index f24a319..fbdd3d4 100644 --- a/src/CheatMenu.cpp +++ b/src/CheatMenu.cpp @@ -49,7 +49,7 @@ CheatMenu::CheatMenu() Hook::window_func = std::bind(&ProcessWindow); Events::initRwEvent += []() - { + { // Load menu settings Globals::header_id = config.GetValue("window.id",std::string("")); Globals::menu_size.x = config.GetValue("window.sizeX", screen::GetScreenWidth() / 4.0f); diff --git a/src/CheatMenu.h b/src/CheatMenu.h index 078cd33..3871c4c 100644 --- a/src/CheatMenu.h +++ b/src/CheatMenu.h @@ -64,6 +64,7 @@ public: if (launch) { flog << "Loading CheatMenu" << std::endl; + CFastman92limitAdjuster::Init(); static CheatMenu cheatmenu; } }; diff --git a/src/Dllmain.cpp b/src/Dllmain.cpp new file mode 100644 index 0000000..3b7c09f --- /dev/null +++ b/src/Dllmain.cpp @@ -0,0 +1,31 @@ +// #include +// #include "../vendor\fla\Main.h" + +BOOL WINAPI DllMain( + HINSTANCE hinstDLL, // handle to DLL module + DWORD fdwReason, // reason for calling function + LPVOID lpReserved ) // reserved +{ + // Perform actions based on the reason for calling. + switch( fdwReason ) + { + case DLL_PROCESS_ATTACH: + // Initialize once for each new process. + // Return FALSE to fail DLL load. + CFastman92limitAdjuster::Init(); + break; + + case DLL_THREAD_ATTACH: + // Do thread-specific initialization. + break; + + case DLL_THREAD_DETACH: + // Do thread-specific cleanup. + break; + + case DLL_PROCESS_DETACH: + // Perform any necessary cleanup. + break; + } + return TRUE; // Successful DLL_PROCESS_ATTACH. +} \ No newline at end of file diff --git a/src/Hook.cpp b/src/Hook.cpp index bdfa4cb..304905a 100644 --- a/src/Hook.cpp +++ b/src/Hook.cpp @@ -172,7 +172,6 @@ void Hook::ShowMouse(bool state) patch::SetUChar(0x6194A0, 0xC3); patch::Nop(0x53F417, 5); // don't call CPad__getMouseState patch::SetRaw(0x53F41F, (void*)"\x33\xC0\x0F\x84", 4); // disable camera mouse movement - //patch::Nop(0x4EB9F4, 5); // disable radio scroll } else { @@ -181,7 +180,6 @@ void Hook::ShowMouse(bool state) patch::SetRaw(0x53F41F, (void*)"\x85\xC0\x0F\x8C", 4); // xor eax, eax -> test eax, eax , enable camera mouse movement // jz loc_53F526 -> jl loc_53F526 patch::SetUChar(0x6194A0, 0xE9); // jmp setup - //patch::SetRaw(0x4EB9F4, (void*)"\xE8\x67\xFC\xFF\xFF", 5); // enable radio scroll } ImGui::GetIO().MouseDrawCursor = state; diff --git a/src/Menu.cpp b/src/Menu.cpp index 19b887b..03d95a2 100644 --- a/src/Menu.cpp +++ b/src/Menu.cpp @@ -421,7 +421,7 @@ void Menu::Main() ImGui::Dummy(ImVec2(0, 10)); ImGui::TextWrapped("Thanks to Junior-Djjr"); ImGui::Dummy(ImVec2(0, 10)); - ImGui::TextWrapped("Copyright GPLv3 2019-2021 Grinch_"); + Ui::CenterdText("Copyright GPLv3 2019-2021 Grinch_"); ImGui::EndChild(); } diff --git a/src/MenuInfo.h b/src/MenuInfo.h index fe7eee5..462bce8 100644 --- a/src/MenuInfo.h +++ b/src/MenuInfo.h @@ -1,5 +1,5 @@ #pragma once #define MENU_NAME "Cheat Menu" #define MENU_VERSION "2.5-beta" -#define BUILD_NUMBER "20210108" +#define BUILD_NUMBER "20210110" #define MENU_TITLE MENU_NAME " v" MENU_VERSION "(" BUILD_NUMBER ")" \ No newline at end of file diff --git a/src/NeonAPI.cpp b/src/NeonAPI.cpp index befe74b..b50f7b4 100644 --- a/src/NeonAPI.cpp +++ b/src/NeonAPI.cpp @@ -20,7 +20,7 @@ NeonAPI::NeonAPI() NeonData *data = &VehNeon.Get(pVeh); if (data->neon_installed && !pVeh->IsUpsideDown()) { - CVector Pos = CModelInfo::ms_modelInfoPtrs[pVeh->m_nModelIndex]->m_pColModel->m_boundBox.m_vecMin; + CVector Pos = CModelInfo::GetModelInfo(pVeh->m_nModelIndex)->m_pColModel->m_boundBox.m_vecMin; CVector center = pVeh->TransformFromObjectSpace(CVector(0.0f, 0.0f, 0.0f)); CVector up = pVeh->TransformFromObjectSpace(CVector(0.0f, -Pos.y - data->val, 0.0f)) - center; CVector right = pVeh->TransformFromObjectSpace(CVector(Pos.x + data->val, 0.0f, 0.0f)) - center; diff --git a/src/Teleport.cpp b/src/Teleport.cpp index 7362340..c1fd612 100644 --- a/src/Teleport.cpp +++ b/src/Teleport.cpp @@ -4,6 +4,9 @@ #include "Ui.h" #include "Util.h" +// FlA +tRadarTrace* CRadar::ms_RadarTrace = reinterpret_cast(patch::GetPointer(0x5838B0 + 2)); + bool Teleport::insert_coord = false; bool Teleport::quick_teleport = false; char Teleport::input_buffer[INPUT_BUFFER_SIZE] = ""; diff --git a/src/Vehicle.cpp b/src/Vehicle.cpp index 9779872..93cf8a0 100644 --- a/src/Vehicle.cpp +++ b/src/Vehicle.cpp @@ -1000,7 +1000,7 @@ void Vehicle::Main() for (int color_id = 0; color_id < count; ++color_id) { if (Ui::ColorButton(color_id, carcols_color_values[color_id], ImVec2(btn_size,btn_size))) - patch::Set(int(veh) + 1075 + color::radio_btn, color_id); + *(uint8_replacement *)(int(veh) + 0x433 + color::radio_btn) = color_id; if ((color_id + 1) % btns_in_row != 0) ImGui::SameLine(0.0, 4.0); @@ -1010,14 +1010,13 @@ void Vehicle::Main() std::string veh_name = GetNameFromModel(player->m_pVehicle->m_nModelIndex); for (auto entry : carcols_car_data) { - if (entry.first == veh_name) { int count = 1; for (int color_id : entry.second) { if (Ui::ColorButton(color_id, carcols_color_values[color_id], ImVec2(btn_size, btn_size))) - patch::Set(int(veh) + 1075 + color::radio_btn, color_id); + *(uint8_replacement *)(int(veh) + 0x433 + color::radio_btn) = color_id; if (count % btns_in_row != 0) ImGui::SameLine(0.0, 4.0); diff --git a/src/Weapon.cpp b/src/Weapon.cpp index 51cea82..ac8017d 100644 --- a/src/Weapon.cpp +++ b/src/Weapon.cpp @@ -76,7 +76,7 @@ Weapon::Weapon() pweapon_info->m_nFlags.bReload2Start = true; } - if (rapid_fire) + if (rapid_fire && weapon_type != WEAPON_MINIGUN) // mingun doesn't work with rapidfire pweapon_info->m_nFlags.bContinuosFire = true; if (dual_weild && (weapon_type == WEAPON_PISTOL || weapon_type == WEAPON_MICRO_UZI || weapon_type == WEAPON_TEC9 || weapon_type == WEAPON_SAWNOFF)) diff --git a/src/pch.h b/src/pch.h index 7f9f2ac..801bfc6 100644 --- a/src/pch.h +++ b/src/pch.h @@ -51,6 +51,7 @@ #include "eVehicleClass.h" #include "extensions/Paths.h" +#include "vendor/fla/IDaccess.h" #include "vendor/imgui/imgui.h" #include "vendor/imgui/imgui_internal.h" #include "vendor/imgui/imgui_impl_dx9.h" diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 24b3221..71299cf 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -9,7 +9,18 @@ project(Test) ################################################################################ # Target ################################################################################ -add_library(${PROJECT_NAME} SHARED "Test.cpp") + +set(test_files + "../vendor/fla/Main.h" + "../vendor/fla/Main.cpp" + "../vendor/fla/IDaccess.h" + "../vendor/fla/IDaccess.cpp" + "../vendor/fla/Library/Library.h" + "../vendor/fla/Library/Library.cpp" + "Test.cpp" +) + +add_library(${PROJECT_NAME} SHARED ${test_files}) string(CONCAT "MSVC_RUNTIME_LIBRARY_STR" $<$: @@ -34,7 +45,6 @@ include_directories( "${PLUGIN_SDK_DIR}/plugin_sa/game_sa" "${PLUGIN_SDK_DIR}/shared" "${PLUGIN_SDK_DIR}/shared/game" - "${DIRECTX9_SDK_DIR}/include" ) ################################################################################ @@ -59,6 +69,7 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE "_DX9_SDK_INSTALLED;" "PLUGIN_SGV_10US;" "_MBCS" + "IS_PLATFORM_WIN" ) ################################################################################ diff --git a/src/tests/Test.cpp b/src/tests/Test.cpp index 68cd27d..2e7c23a 100644 --- a/src/tests/Test.cpp +++ b/src/tests/Test.cpp @@ -1,4 +1,6 @@ #include "plugin.h" +#include "../vendor/fla/IDaccess.h" +#include "CHud.h" using namespace plugin; @@ -6,17 +8,26 @@ class Test { public: Test() - { + { + Events::initRwEvent += [] + { + CFastman92limitAdjuster::Init(); + }; + Events::processScriptsEvent += [] { - if(KeyPressed(VK_UP)) - { - patch::Nop(0x4EB9F4, 5); // disable - } - if(KeyPressed(VK_DOWN)) - { - patch::SetRaw(0x4EB9F4, (void*)"\xE8\x67\xFC\xFF\xFF", 5); // enable - } + CPlayerPed *player = FindPlayerPed(); + + if(KeyPressed(VK_UP) && player && player->m_pVehicle) + { + uint8_replacement &primary_color = *(uint8_replacement *)(int(player->m_pVehicle) + 0x434); + primary_color = 74; + CHud::SetHelpMessage("Color changed",false,false,false); + } + if(KeyPressed(VK_DOWN)) + { + + } }; } } test; diff --git a/src/vendor/CMakeLists.txt b/src/vendor/CMakeLists.txt index 83c31d2..be16f18 100644 --- a/src/vendor/CMakeLists.txt +++ b/src/vendor/CMakeLists.txt @@ -6,6 +6,12 @@ cmake_minimum_required(VERSION 3.0) project(Vendor) set(vendor_files + "fla/Main.h" + "fla/Main.cpp" + "fla/IDaccess.h" + "fla/IDaccess.cpp" + "fla/Library/Library.h" + "fla/Library/Library.cpp" "imgui/imconfig.h" "imgui/imgui.cpp" "imgui/imgui.h" @@ -58,6 +64,7 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE "_DX9_SDK_INSTALLED;" "PLUGIN_SGV_10US;" "_MBCS" + "IS_PLATFORM_WIN" ) include_directories( diff --git a/src/vendor/fla/IDaccess.cpp b/src/vendor/fla/IDaccess.cpp new file mode 100644 index 0000000..a0a9624 --- /dev/null +++ b/src/vendor/fla/IDaccess.cpp @@ -0,0 +1,97 @@ +/* +* Copyright (C) fastman92 , website: http://fastman92.com +* Licensed under the MIT License, see LICENSE at top level directory. +* +*/ + +#include "IDaccess.h" + +// pointers of functions +tIDaccessFuncs IDaccess::funcs; + +// Initializes +void IDaccess::Init() +{ + tGenericLibraryModule* phModule = &CFastman92limitAdjuster::hModule; + + SET_FUNCTION_ADDRESS(AreDifficultIDsExtended); + SET_FUNCTION_ADDRESS(GetExtendedIDfrom16bitBefore); + SET_FUNCTION_ADDRESS(SetExtendedIDfrom16bitBefore); + + SET_FUNCTION_ADDRESS(AreVehicleColourIDsextended); + SET_FUNCTION_ADDRESS(GetExtendedIDfrom8bitBefore); + SET_FUNCTION_ADDRESS(SetExtendedIDfrom8bitBefore); +} + +// Tells if DFF/TXD 32-bit IDs are enabled. +bool IDaccess::AreDifficultIDsExtended() +{ + return funcs.AreDifficultIDsExtended ? funcs.AreDifficultIDsExtended() : false; +} + +// Returns extended ID for the pointer, where an ID of 16-bit size was available before. +int32_t IDaccess::GetExtendedIDfrom16bitBefore(const void* basicPtr) +{ + if (funcs.GetExtendedIDfrom16bitBefore) + return funcs.GetExtendedIDfrom16bitBefore(basicPtr); + else + { + uint16_t uID = *(uint16_t*)basicPtr; + + if (uID > MAX_FILE_ID_UINT16) // is it negative ID? + return *(int16_t*)basicPtr; + else + return uID; + } +} + +// Sets extended ID for the pointer, where an ID of 16-bit size was available before. +void IDaccess::SetExtendedIDfrom16bitBefore(void* basicPtr, int32_t ID) +{ + if (funcs.SetExtendedIDfrom16bitBefore) + funcs.SetExtendedIDfrom16bitBefore(basicPtr, ID); + else + *(uint16_t*)basicPtr = ID; +} + +// Compares only a significiant part, uses for patches such as "cmp ax, 520" or so. +// Where only 16-bit would be used before, but now it may be 32-bit +int32_t IDaccess::CompareDifficultIDonlySignificiantPart(int32_t a, uint16_t b) +{ + if (IDaccess::AreDifficultIDsExtended()) + return a == b; + else + return (uint16_t)a == b; +} + +// Returns true if vehicles colour IDs extended. +bool IDaccess::AreVehicleColourIDsextended() +{ + return funcs.AreVehicleColourIDsextended + ? funcs.AreVehicleColourIDsextended() : false; +} + +// Returns extended ID for the pointer, where an ID of 8-bit size was available before. +int32_t IDaccess::GetExtendedIDfrom8bitBefore(const void* basicPtr) +{ + if (funcs.GetExtendedIDfrom8bitBefore) + return funcs.GetExtendedIDfrom8bitBefore(basicPtr); + else + { + uint8_t uID = *(uint8_t*)basicPtr; + + if (uID == 0xFF) // is it unset ID? + return -1; + else + return uID; + } +} + +// Returns extended ID for the pointer, where an ID of 8-bit size was available before. +void IDaccess::SetExtendedIDfrom8bitBefore(void* basicPtr, int32_t ID) +{ + if (funcs.SetExtendedIDfrom8bitBefore) + funcs.SetExtendedIDfrom8bitBefore(basicPtr, ID); + else + *(uint8_t*)basicPtr = ID; +} \ No newline at end of file diff --git a/src/vendor/fla/IDaccess.h b/src/vendor/fla/IDaccess.h new file mode 100644 index 0000000..fb0e337 --- /dev/null +++ b/src/vendor/fla/IDaccess.h @@ -0,0 +1,70 @@ +/* +* Copyright (C) fastman92 , website: http://fastman92.com +* Licensed under the MIT License, see LICENSE at top level directory. +* +*/ + +#pragma once +#include "common/CValueExtension.h" +#include "Main.h" + +#include + +// Function pointers +struct tIDaccessFuncs +{ +public: + // Tells if DFF/TXD 32-bit IDs are enabled. + bool (F92_LA_CONVENTION* AreDifficultIDsExtended)(); + + int32_t (F92_LA_CONVENTION* GetExtendedIDfrom16bitBefore)(const void* basicPtr); + void (F92_LA_CONVENTION* SetExtendedIDfrom16bitBefore)(void* basicPtr, int32_t ID); + + ///////////////////////////// + // Returns true if vehicles colour IDs extended. + bool(F92_LA_CONVENTION* AreVehicleColourIDsextended)(); + + int32_t (F92_LA_CONVENTION* GetExtendedIDfrom8bitBefore)(const void* basicPtr); + void (F92_LA_CONVENTION* SetExtendedIDfrom8bitBefore)(void* basicPtr, int32_t ID); +}; + +// ID access +class IDaccess +{ +public: + // pointers of functions + static tIDaccessFuncs funcs; + + // actual functions + // Tells if DFF/TXD 32-bit IDs are enabled. + static bool AreDifficultIDsExtended(); + + // Returns extended ID for the pointer, where an ID of 16-bit size was available before. + static int32_t GetExtendedIDfrom16bitBefore(const void* basicPtr); + + // Sets extended ID for the pointer, where an ID of 16-bit size was available before. + static void SetExtendedIDfrom16bitBefore(void* basicPtr, int32_t ID); + + // Compares only a significiant part, uses for patches such as "cmp ax, 520" or so. + // Where only 16-bit would be used before, but now it may be 32-bit + static int32_t CompareDifficultIDonlySignificiantPart(int32_t a, uint16_t b); + + //////////////////////////////////// + // Returns true if vehicles colour IDs extended. + bool AreVehicleColourIDsextended(); + + // Returns extended ID for the pointer, where an ID of 8-bit size was available before. + static int32_t GetExtendedIDfrom8bitBefore(const void* basicPtr); + + // Returns extended ID for the pointer, where an ID of 8-bit size was available before. + static void SetExtendedIDfrom8bitBefore(void* basicPtr, int32_t ID); + + // Initializes + static void Init(); +}; + +// Declare CFileID +#ifndef FASTMAN92_LIMIT_ADJUSTER +typedef CValueExtensionNum CFileID; +typedef CValueExtensionNum uint8_replacement; +#endif \ No newline at end of file diff --git a/src/vendor/fla/Library/Library.cpp b/src/vendor/fla/Library/Library.cpp new file mode 100644 index 0000000..dd2de27 --- /dev/null +++ b/src/vendor/fla/Library/Library.cpp @@ -0,0 +1,11 @@ +#include "Library.h" + +// Returns symbol address +void* Library::GetSymbolAddress(const tGenericLibraryModule* pModule, const char* symbolName) +{ +#ifdef IS_PLATFORM_WIN + return GetProcAddress(pModule->windows, symbolName); +#elif defined(IS_PLATFORM_ANDROID) + return dlsym(pModule->linux_os, symbolName); +#endif +} \ No newline at end of file diff --git a/src/vendor/fla/Library/Library.h b/src/vendor/fla/Library/Library.h new file mode 100644 index 0000000..d65f9e3 --- /dev/null +++ b/src/vendor/fla/Library/Library.h @@ -0,0 +1,25 @@ +#pragma once + +#ifdef IS_PLATFORM_WIN +#include +#endif + +#ifdef IS_PLATFORM_ANDROID +#include +#endif + +union tGenericLibraryModule +{ +#ifdef IS_PLATFORM_WIN + HMODULE windows; +#elif defined(IS_PLATFORM_ANDROID) + void* linux_os; +#endif +}; + +class Library +{ +public: + // Returns symbol address + static void* GetSymbolAddress(const tGenericLibraryModule* pModule, const char* symbolName); +}; \ No newline at end of file diff --git a/src/vendor/fla/Main.cpp b/src/vendor/fla/Main.cpp new file mode 100644 index 0000000..848a980 --- /dev/null +++ b/src/vendor/fla/Main.cpp @@ -0,0 +1,30 @@ +/* +* Copyright (C) fastman92 , website: http://fastman92.com +* Licensed under the MIT License, see LICENSE at top level directory. +* +*/ + +#include "Main.h" + +#include "IDaccess.h" + +#ifdef IS_PLATFORM_ANDROID +#include +#endif + +// hModule_of_the_FLA +tGenericLibraryModule CFastman92limitAdjuster::hModule = { 0 }; + +// Initializes everything related to the FLA +void CFastman92limitAdjuster::Init() +{ + // Get library address +#ifdef IS_PLATFORM_WIN + hModule.windows = GetModuleHandleA("$fastman92limitAdjuster.asi"); +#elif defined(IS_PLATFORM_ANDROID) + hModule.linux_os = dlopen(FLA_FILENAME, 4); // 4 - RTLD_NOLOAD +#endif + + ////////////////////////////// + IDaccess::Init(); +} \ No newline at end of file diff --git a/src/vendor/fla/Main.h b/src/vendor/fla/Main.h new file mode 100644 index 0000000..2a1f813 --- /dev/null +++ b/src/vendor/fla/Main.h @@ -0,0 +1,21 @@ +/* +* Copyright (C) fastman92 , website: http://fastman92.com +* Licensed under the MIT License, see LICENSE at top level directory. +* +*/ + +#pragma once +#include "common/common.h" +#include "Library/Library.h" + +#define SET_FUNCTION_ADDRESS(functionName) if(phModule)*(void**)&funcs.functionName = Library::GetSymbolAddress(phModule, TOSTRING(functionName)); else funcs.functionName = 0; + +class CFastman92limitAdjuster +{ +public: + // hModule_of_the_FLA + static tGenericLibraryModule hModule; + + // Initializes everything related to the FLA + static void Init(); +}; \ No newline at end of file diff --git a/src/vendor/fla/common/CValueExtension.h b/src/vendor/fla/common/CValueExtension.h new file mode 100644 index 0000000..00b87d7 --- /dev/null +++ b/src/vendor/fla/common/CValueExtension.h @@ -0,0 +1,56 @@ +/* +* Copyright (C) fastman92 , website: http://fastman92.com +* Licensed under the MIT License, see LICENSE at top level directory. +* +*/ + +#pragma once + +// CValueExtension +template class CValueExtension +{ + from m_Value; + + // Constructor + CValueExtension() = delete; + +public: + // Returns ID + to Get() const + { + return GetFunc(&this->m_Value); + } + + // Sets ID + void Set(to ID) + { + SetFunc(&this->m_Value, ID); + } +}; + +// CValueExtensionInt +template class CValueExtensionNum + : public CValueExtension +{ +public: + // Assignnment operators + CValueExtensionNum& operator=(to dwModelIndex) { this->Set(dwModelIndex); return *this; } + CValueExtensionNum& operator=(const CValueExtensionNum& dwModelIndex) { this->Set(dwModelIndex.Get()); return *this; } + + // Comparison operators + bool operator==(to dwModelIndex) { return this->Get() == dwModelIndex; } + bool operator==(const CValueExtensionNum& dwModelIndex) { return this->Get() == dwModelIndex.Get(); } + bool operator>=(to dwModelIndex) { return this->Get() >= dwModelIndex; } + bool operator>=(const CValueExtensionNum& dwModelIndex) { return this->Get() >= dwModelIndex.Get(); } + bool operator<=(to dwModelIndex) { return this->Get() <= dwModelIndex; } + bool operator<=(const CValueExtensionNum& dwModelIndex) { return this->Get() <= dwModelIndex.Get(); } + bool operator>(to dwModelIndex) { return this->Get() > dwModelIndex; } + bool operator>(const CValueExtensionNum& dwModelIndex) { return this->Get() > dwModelIndex.Get(); } + bool operator<(to dwModelIndex) { return this->Get() < dwModelIndex; } + bool operator<(const CValueExtensionNum& dwModelIndex) { return this->Get() < dwModelIndex.Get(); } + bool operator!=(to dwModelIndex) { return this->Get() != dwModelIndex; } + bool operator!=(const CValueExtensionNum& dwModelIndex) { return this->Get() != dwModelIndex.Get(); } + + // Conversion operators + operator to() const { return this->Get(); } +}; \ No newline at end of file diff --git a/src/vendor/fla/common/CdDirectory.h b/src/vendor/fla/common/CdDirectory.h new file mode 100644 index 0000000..d49a052 --- /dev/null +++ b/src/vendor/fla/common/CdDirectory.h @@ -0,0 +1,25 @@ +/* +* Copyright (C) fastman92 , website: http://fastman92.com +* Licensed under the MIT License, see LICENSE at top level directory. +* +*/ + +#pragma once +#include + +#define IMG_FASTMAN92_GTASA_MAX_FILENAME_LENGTH 39 + +#pragma pack(push, 1) +class tImgFastman92GTASAdirectoryEntry +{ +public: + uint32_t PositionInSectors; + uint16_t OriginalSizeInSectors; + uint16_t NumberOfPaddedBytesInAlignedOriginalSize; + uint16_t PackedSizeInSectors; + uint16_t NumberOfPaddedBytesInAlignedPackedSize; + uint32_t Flags; + char Name[IMG_FASTMAN92_GTASA_MAX_FILENAME_LENGTH + 1]; + char Reserved[8]; // should have NULL values when reserved. +}; +#pragma pack(pop) \ No newline at end of file diff --git a/src/vendor/fla/common/common.h b/src/vendor/fla/common/common.h new file mode 100644 index 0000000..e5e29cd --- /dev/null +++ b/src/vendor/fla/common/common.h @@ -0,0 +1,29 @@ +/* +* Copyright (C) fastman92 , website: http://fastman92.com +* Licensed under the MIT License, see LICENSE at top level directory. +* +*/ + +#pragma once +#define F92_LA_CONVENTION + +#define UNDEFINED_FILE_ID_UINT16 0xFFFF +#define UNDEFINED_FILE_ID_INT32 -1 +#define UNKNOWN_MODEL_ID_MINUS_2 -2 +#define MAX_FILE_ID_UINT16 0xFFFC +#define MAX_FILE_ID_INT32 0x7FFFFFFF + +// Stringify +#if !defined(STRINGIFY) || defined(TOSTRING) +#define STRINGIFY(str) #str +#define TOSTRING(x) STRINGIFY(x) +#endif + +// FLA library filename +#ifdef IS_PLATFORM_WIN_X86 +#define FLA_FILENAME "$fastman92limitAdjuster.asi" +#elif defined(IS_PLATFORM_WIN_X64) +#define FLA_FILENAME "$fastman92limitAdjusterX64.asi" +#elif defined(IS_PLATFORM_ANDROID) +#define FLA_FILENAME "libplugin_fastman92limitAdjuster_" TOSTRING(SOLUTION_PLATFORM) ".so" +#endif diff --git a/src/vendor/kiero/minhook/CMakeLists.txt b/src/vendor/kiero/minhook/CMakeLists.txt deleted file mode 100644 index df947af..0000000 --- a/src/vendor/kiero/minhook/CMakeLists.txt +++ /dev/null @@ -1,141 +0,0 @@ -# MinHook - The Minimalistic API Hooking Library for x64/x86 -# Copyright (C) 2009-2017 Tsuda Kageyu. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER -# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -cmake_minimum_required(VERSION 3.0) - -project(minhook LANGUAGES C) - -include(CMakePackageConfigHelpers) - -set(MINHOOK_MAJOR_VERSION 1) -set(MINHOOK_MINOR_VERSION 3) -set(MINHOOK_PATCH_VERSION 3) -set(MINHOOK_VERSION ${MINHOOK_MAJOR_VERSION}.${MINHOOK_MINOR_VERSION}.${MINHOOK_PATCH_VERSION}) - -################ -# BUILD # -################ - -option(BUILD_SHARED_LIBS "build shared version" OFF) - -set(SOURCES_MINHOOK - "src/buffer.c" - "src/hook.c" - "src/trampoline.c" -) - -if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(SOURCES_HDE "src/hde/hde64.c") -else() - set(SOURCES_HDE "src/hde/hde32.c") -endif() - -if(BUILD_SHARED_LIBS) - set(RESOURCES - "dll_resources/minhook.rc" - "dll_resources/minhook.def" - ) -endif() - -add_library(minhook ${SOURCES_MINHOOK} ${SOURCES_HDE} ${RESOURCES}) - -target_include_directories(minhook PUBLIC - $ - $ -) - -target_include_directories(minhook PRIVATE "src/") -target_include_directories(minhook PRIVATE "src/hde/") - -if(WIN32) - set_target_properties(minhook PROPERTIES PREFIX "") - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set_target_properties(minhook PROPERTIES DEBUG_POSTFIX ".x64d") - set_target_properties(minhook PROPERTIES RELEASE_POSTFIX ".x64") - set_target_properties(minhook PROPERTIES RELWITHDEBINFO_POSTFIX ".x64") - set_target_properties(minhook PROPERTIES MINSIZEREL_POSTFIX ".x64") - else() - set_target_properties(minhook PROPERTIES DEBUG_POSTFIX ".x32d") - set_target_properties(minhook PROPERTIES RELEASE_POSTFIX ".x32") - set_target_properties(minhook PROPERTIES RELWITHDEBINFO_POSTFIX ".x32") - set_target_properties(minhook PROPERTIES MINSIZEREL_POSTFIX ".x64") - endif() -else() - set_target_properties(minhook PROPERTIES PREFIX "lib") - set_target_properties(minhook PROPERTIES POSTFIX "") - set_target_properties(minhook PROPERTIES DEBUG_POSTFIX "d") -endif() - -################ -# CMAKE CONFIG # -################ - -configure_package_config_file( - "cmake/minhook-config.cmake.in" - "minhook-config.cmake" - INSTALL_DESTINATION - "lib/minhook" -) - -write_basic_package_version_file( - "minhook-config-version.cmake" -VERSION - ${MINHOOK_VERSION} -COMPATIBILITY - AnyNewerVersion -) - -install( - FILES - "${CMAKE_CURRENT_BINARY_DIR}/minhook-config.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/minhook-config-version.cmake" - DESTINATION - "lib/minhook" -) - -################### -# INSTALL # -################### - -install(TARGETS minhook - EXPORT minhook-targets - RUNTIME DESTINATION "bin" - ARCHIVE DESTINATION "lib" - LIBRARY DESTINATION "lib" -) - -install( - EXPORT - minhook-targets - NAMESPACE - minhook:: - DESTINATION - "lib/minhook" -) - -install( - DIRECTORY include DESTINATION . -)