Fix incompatibilities with fla & crashes

This commit is contained in:
Grinch_ 2021-01-10 02:06:53 +06:00
parent a4a262722b
commit 5ad3db3170
26 changed files with 462 additions and 163 deletions

View File

@ -14,7 +14,20 @@
"GTASA", "GTASA",
"_DEBUG", "_DEBUG",
"UNICODE", "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", "windowsSdkVersion": "10.0.10240.0",
"compilerPath": "cl.exe", "compilerPath": "cl.exe",

View File

@ -117,6 +117,7 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE
"_DX9_SDK_INSTALLED;" "_DX9_SDK_INSTALLED;"
"PLUGIN_SGV_10US;" "PLUGIN_SGV_10US;"
"_MBCS" "_MBCS"
"IS_PLATFORM_WIN"
) )
################################################################################ ################################################################################

View File

@ -49,7 +49,7 @@ CheatMenu::CheatMenu()
Hook::window_func = std::bind(&ProcessWindow); Hook::window_func = std::bind(&ProcessWindow);
Events::initRwEvent += []() Events::initRwEvent += []()
{ {
// Load menu settings // Load menu settings
Globals::header_id = config.GetValue("window.id",std::string("")); Globals::header_id = config.GetValue("window.id",std::string(""));
Globals::menu_size.x = config.GetValue("window.sizeX", screen::GetScreenWidth() / 4.0f); Globals::menu_size.x = config.GetValue("window.sizeX", screen::GetScreenWidth() / 4.0f);

View File

@ -64,6 +64,7 @@ public:
if (launch) if (launch)
{ {
flog << "Loading CheatMenu" << std::endl; flog << "Loading CheatMenu" << std::endl;
CFastman92limitAdjuster::Init();
static CheatMenu cheatmenu; static CheatMenu cheatmenu;
} }
}; };

31
src/Dllmain.cpp Normal file
View File

@ -0,0 +1,31 @@
// #include <Windows.h>
// #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.
}

View File

@ -172,7 +172,6 @@ void Hook::ShowMouse(bool state)
patch::SetUChar(0x6194A0, 0xC3); patch::SetUChar(0x6194A0, 0xC3);
patch::Nop(0x53F417, 5); // don't call CPad__getMouseState patch::Nop(0x53F417, 5); // don't call CPad__getMouseState
patch::SetRaw(0x53F41F, (void*)"\x33\xC0\x0F\x84", 4); // disable camera mouse movement patch::SetRaw(0x53F41F, (void*)"\x33\xC0\x0F\x84", 4); // disable camera mouse movement
//patch::Nop(0x4EB9F4, 5); // disable radio scroll
} }
else 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 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 // jz loc_53F526 -> jl loc_53F526
patch::SetUChar(0x6194A0, 0xE9); // jmp setup patch::SetUChar(0x6194A0, 0xE9); // jmp setup
//patch::SetRaw(0x4EB9F4, (void*)"\xE8\x67\xFC\xFF\xFF", 5); // enable radio scroll
} }
ImGui::GetIO().MouseDrawCursor = state; ImGui::GetIO().MouseDrawCursor = state;

View File

@ -421,7 +421,7 @@ void Menu::Main()
ImGui::Dummy(ImVec2(0, 10)); ImGui::Dummy(ImVec2(0, 10));
ImGui::TextWrapped("Thanks to Junior-Djjr"); ImGui::TextWrapped("Thanks to Junior-Djjr");
ImGui::Dummy(ImVec2(0, 10)); ImGui::Dummy(ImVec2(0, 10));
ImGui::TextWrapped("Copyright GPLv3 2019-2021 Grinch_"); Ui::CenterdText("Copyright GPLv3 2019-2021 Grinch_");
ImGui::EndChild(); ImGui::EndChild();
} }

View File

@ -1,5 +1,5 @@
#pragma once #pragma once
#define MENU_NAME "Cheat Menu" #define MENU_NAME "Cheat Menu"
#define MENU_VERSION "2.5-beta" #define MENU_VERSION "2.5-beta"
#define BUILD_NUMBER "20210108" #define BUILD_NUMBER "20210110"
#define MENU_TITLE MENU_NAME " v" MENU_VERSION "(" BUILD_NUMBER ")" #define MENU_TITLE MENU_NAME " v" MENU_VERSION "(" BUILD_NUMBER ")"

View File

@ -20,7 +20,7 @@ NeonAPI::NeonAPI()
NeonData *data = &VehNeon.Get(pVeh); NeonData *data = &VehNeon.Get(pVeh);
if (data->neon_installed && !pVeh->IsUpsideDown()) 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 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 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; CVector right = pVeh->TransformFromObjectSpace(CVector(Pos.x + data->val, 0.0f, 0.0f)) - center;

View File

@ -4,6 +4,9 @@
#include "Ui.h" #include "Ui.h"
#include "Util.h" #include "Util.h"
// FlA
tRadarTrace* CRadar::ms_RadarTrace = reinterpret_cast<tRadarTrace *>(patch::GetPointer(0x5838B0 + 2));
bool Teleport::insert_coord = false; bool Teleport::insert_coord = false;
bool Teleport::quick_teleport = false; bool Teleport::quick_teleport = false;
char Teleport::input_buffer[INPUT_BUFFER_SIZE] = ""; char Teleport::input_buffer[INPUT_BUFFER_SIZE] = "";

View File

@ -1000,7 +1000,7 @@ void Vehicle::Main()
for (int color_id = 0; color_id < count; ++color_id) 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))) if (Ui::ColorButton(color_id, carcols_color_values[color_id], ImVec2(btn_size,btn_size)))
patch::Set<BYTE>(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) if ((color_id + 1) % btns_in_row != 0)
ImGui::SameLine(0.0, 4.0); ImGui::SameLine(0.0, 4.0);
@ -1010,14 +1010,13 @@ void Vehicle::Main()
std::string veh_name = GetNameFromModel(player->m_pVehicle->m_nModelIndex); std::string veh_name = GetNameFromModel(player->m_pVehicle->m_nModelIndex);
for (auto entry : carcols_car_data) for (auto entry : carcols_car_data)
{ {
if (entry.first == veh_name) if (entry.first == veh_name)
{ {
int count = 1; int count = 1;
for (int color_id : entry.second) for (int color_id : entry.second)
{ {
if (Ui::ColorButton(color_id, carcols_color_values[color_id], ImVec2(btn_size, btn_size))) if (Ui::ColorButton(color_id, carcols_color_values[color_id], ImVec2(btn_size, btn_size)))
patch::Set<BYTE>(int(veh) + 1075 + color::radio_btn, color_id); *(uint8_replacement *)(int(veh) + 0x433 + color::radio_btn) = color_id;
if (count % btns_in_row != 0) if (count % btns_in_row != 0)
ImGui::SameLine(0.0, 4.0); ImGui::SameLine(0.0, 4.0);

View File

@ -76,7 +76,7 @@ Weapon::Weapon()
pweapon_info->m_nFlags.bReload2Start = true; 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; 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)) if (dual_weild && (weapon_type == WEAPON_PISTOL || weapon_type == WEAPON_MICRO_UZI || weapon_type == WEAPON_TEC9 || weapon_type == WEAPON_SAWNOFF))

View File

@ -51,6 +51,7 @@
#include "eVehicleClass.h" #include "eVehicleClass.h"
#include "extensions/Paths.h" #include "extensions/Paths.h"
#include "vendor/fla/IDaccess.h"
#include "vendor/imgui/imgui.h" #include "vendor/imgui/imgui.h"
#include "vendor/imgui/imgui_internal.h" #include "vendor/imgui/imgui_internal.h"
#include "vendor/imgui/imgui_impl_dx9.h" #include "vendor/imgui/imgui_impl_dx9.h"

View File

@ -9,7 +9,18 @@ project(Test)
################################################################################ ################################################################################
# Target # 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" string(CONCAT "MSVC_RUNTIME_LIBRARY_STR"
$<$<CONFIG:Release>: $<$<CONFIG:Release>:
@ -34,7 +45,6 @@ include_directories(
"${PLUGIN_SDK_DIR}/plugin_sa/game_sa" "${PLUGIN_SDK_DIR}/plugin_sa/game_sa"
"${PLUGIN_SDK_DIR}/shared" "${PLUGIN_SDK_DIR}/shared"
"${PLUGIN_SDK_DIR}/shared/game" "${PLUGIN_SDK_DIR}/shared/game"
"${DIRECTX9_SDK_DIR}/include"
) )
################################################################################ ################################################################################
@ -59,6 +69,7 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE
"_DX9_SDK_INSTALLED;" "_DX9_SDK_INSTALLED;"
"PLUGIN_SGV_10US;" "PLUGIN_SGV_10US;"
"_MBCS" "_MBCS"
"IS_PLATFORM_WIN"
) )
################################################################################ ################################################################################

View File

@ -1,4 +1,6 @@
#include "plugin.h" #include "plugin.h"
#include "../vendor/fla/IDaccess.h"
#include "CHud.h"
using namespace plugin; using namespace plugin;
@ -6,17 +8,26 @@ class Test
{ {
public: public:
Test() Test()
{ {
Events::initRwEvent += []
{
CFastman92limitAdjuster::Init();
};
Events::processScriptsEvent += [] Events::processScriptsEvent += []
{ {
if(KeyPressed(VK_UP)) CPlayerPed *player = FindPlayerPed();
{
patch::Nop(0x4EB9F4, 5); // disable if(KeyPressed(VK_UP) && player && player->m_pVehicle)
} {
if(KeyPressed(VK_DOWN)) uint8_replacement &primary_color = *(uint8_replacement *)(int(player->m_pVehicle) + 0x434);
{ primary_color = 74;
patch::SetRaw(0x4EB9F4, (void*)"\xE8\x67\xFC\xFF\xFF", 5); // enable CHud::SetHelpMessage("Color changed",false,false,false);
} }
if(KeyPressed(VK_DOWN))
{
}
}; };
} }
} test; } test;

View File

@ -6,6 +6,12 @@ cmake_minimum_required(VERSION 3.0)
project(Vendor) project(Vendor)
set(vendor_files 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/imconfig.h"
"imgui/imgui.cpp" "imgui/imgui.cpp"
"imgui/imgui.h" "imgui/imgui.h"
@ -58,6 +64,7 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE
"_DX9_SDK_INSTALLED;" "_DX9_SDK_INSTALLED;"
"PLUGIN_SGV_10US;" "PLUGIN_SGV_10US;"
"_MBCS" "_MBCS"
"IS_PLATFORM_WIN"
) )
include_directories( include_directories(

97
src/vendor/fla/IDaccess.cpp vendored Normal file
View File

@ -0,0 +1,97 @@
/*
* Copyright (C) fastman92 <fastman92@gmail.com>, 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;
}

70
src/vendor/fla/IDaccess.h vendored Normal file
View File

@ -0,0 +1,70 @@
/*
* Copyright (C) fastman92 <fastman92@gmail.com>, 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 <stdint.h>
// 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<uint16_t, int32_t, IDaccess::GetExtendedIDfrom16bitBefore, IDaccess::SetExtendedIDfrom16bitBefore> CFileID;
typedef CValueExtensionNum<uint8_t, int32_t, IDaccess::GetExtendedIDfrom8bitBefore, IDaccess::SetExtendedIDfrom8bitBefore> uint8_replacement;
#endif

11
src/vendor/fla/Library/Library.cpp vendored Normal file
View File

@ -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
}

25
src/vendor/fla/Library/Library.h vendored Normal file
View File

@ -0,0 +1,25 @@
#pragma once
#ifdef IS_PLATFORM_WIN
#include <Windows.h>
#endif
#ifdef IS_PLATFORM_ANDROID
#include <dlfcn.h>
#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);
};

30
src/vendor/fla/Main.cpp vendored Normal file
View File

@ -0,0 +1,30 @@
/*
* Copyright (C) fastman92 <fastman92@gmail.com>, 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 <dlfcn.h>
#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();
}

21
src/vendor/fla/Main.h vendored Normal file
View File

@ -0,0 +1,21 @@
/*
* Copyright (C) fastman92 <fastman92@gmail.com>, 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();
};

56
src/vendor/fla/common/CValueExtension.h vendored Normal file
View File

@ -0,0 +1,56 @@
/*
* Copyright (C) fastman92 <fastman92@gmail.com>, website: http://fastman92.com
* Licensed under the MIT License, see LICENSE at top level directory.
*
*/
#pragma once
// CValueExtension
template <typename from, typename to, to(*GetFunc)(const void* basicPtr), void SetFunc(void* basicPtr, to ID)> 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 <typename from, typename to, to(*GetFunc)(const void* basicPtr), void SetFunc(void* basicPtr, to ID)> class CValueExtensionNum
: public CValueExtension<from, to, GetFunc, SetFunc>
{
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(); }
};

25
src/vendor/fla/common/CdDirectory.h vendored Normal file
View File

@ -0,0 +1,25 @@
/*
* Copyright (C) fastman92 <fastman92@gmail.com>, website: http://fastman92.com
* Licensed under the MIT License, see LICENSE at top level directory.
*
*/
#pragma once
#include <stdint.h>
#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)

29
src/vendor/fla/common/common.h vendored Normal file
View File

@ -0,0 +1,29 @@
/*
* Copyright (C) fastman92 <fastman92@gmail.com>, 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

View File

@ -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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:include>
)
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 .
)