diff --git a/Android.mk b/Android.mk new file mode 100644 index 0000000..daeb59a --- /dev/null +++ b/Android.mk @@ -0,0 +1,17 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) +LOCAL_CPP_EXTENSION := .cpp .cc +ifeq ($(TARGET_ARCH_ABI), armeabi-v7a) + LOCAL_MODULE := GtaSdk +else + LOCAL_MODULE := GtaSdk64 +endif +LOCAL_SRC_FILES := main.cpp mod/logger.cpp mod/config.cpp include/Events.cpp +ifeq ($(TARGET_ARCH_ABI), armeabi-v7a) + LOCAL_CFLAGS += -O2 -mfloat-abi=softfp -DNDEBUG -std=c++17 +else + LOCAL_CFLAGS += -O2 -DNDEBUG -std=c++17 +endif +LOCAL_LDLIBS += -llog +include $(BUILD_SHARED_LIBRARY) diff --git a/Application.mk b/Application.mk new file mode 100644 index 0000000..4606a45 --- /dev/null +++ b/Application.mk @@ -0,0 +1,3 @@ +APP_STL := c++_static +APP_ABI := armeabi-v7a arm64-v8a +APP_OPTIM := release \ No newline at end of file diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..76db0f1 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,13 @@ +$NDKPath = Get-Content $PSScriptRoot/NDKPath.txt +Write-Output "NDK located at: $NDKPath" + +$buildScript = "$NDKPath/build/ndk-build" +if (-not ($PSVersionTable.PSEdition -eq "Core")) { + $buildScript += ".cmd" +} + +Write-Output "[BUILD] Starting NDK..." +& $buildScript NDK_PROJECT_PATH=$PSScriptRoot APP_BUILD_SCRIPT=$PSScriptRoot/Android.mk NDK_APPLICATION_MK=$PSScriptRoot/Application.mk NDK_DEBUG=0 +Write-Output "[BUILD] Done!" + +Exit $LASTEXITCODE \ No newline at end of file diff --git a/include/Call.h b/include/Call.h new file mode 100644 index 0000000..d8ee48e --- /dev/null +++ b/include/Call.h @@ -0,0 +1,68 @@ +#pragma once // Call.h by XMDS(ARMHook) +#include + +class Call +{ +public: + template + static Ret FunctionCdecl(uintptr_t address, Args... args) { + volatile uintptr_t address_ = address; + return reinterpret_cast(address_)(args...); + } + + template + static Ret FunctionFastCall(uintptr_t address, Args... args) { + volatile uintptr_t address_ = address; + return reinterpret_cast(address_)(args...); + } + + template + static Ret FunctionStdCall(uintptr_t address, Args... args) { + volatile uintptr_t address_ = address; + return reinterpret_cast(address_)(args...); + } + + template + static Ret Function(uintptr_t address, Args... args) { + uintptr_t address_ = address; + return reinterpret_cast(address_)(args...); + } + + template + static Ret Method(uintptr_t address, C _this, Args... args) { + volatile uintptr_t address_ = address; + return reinterpret_cast(address_)(_this, args...); + } + + /* I removed '__decl', '__thiscall' etc... as it is not necessary and warnings appear when compiling + template + static Ret FunctionCdecl(uintptr_t address, Args... args) { + volatile uintptr_t address_ = address; + return reinterpret_cast(address_)(args...); + } + + template + static Ret FunctionFastCall(uintptr_t address, Args... args) { + volatile uintptr_t address_ = address; + return reinterpret_cast(address_)(args...); + } + + template + static Ret FunctionStdCall(uintptr_t address, Args... args) { + volatile uintptr_t address_ = address; + return reinterpret_cast(address_)(args...); + } + + template + static Ret Function(uintptr_t address, Args... args) { + uintptr_t address_ = address; + return reinterpret_cast(address_)(args...); + } + + template + static Ret Method(uintptr_t address, C _this, Args... args) { + volatile uintptr_t address_ = address; + return reinterpret_cast(address_)(_this, args...); + } + */ +}; \ No newline at end of file diff --git a/include/ISdk.h b/include/ISdk.h new file mode 100644 index 0000000..3fb8255 --- /dev/null +++ b/include/ISdk.h @@ -0,0 +1,11 @@ +#ifndef ISDK_H +#define ISDK_H + +class ISdk { +public: + // get the current version of the SDK + virtual const char* GetVersion(); + +}; + +#endif \ No newline at end of file diff --git a/include/sdk.h b/include/sdk.h new file mode 100644 index 0000000..90d10f1 --- /dev/null +++ b/include/sdk.h @@ -0,0 +1,59 @@ +#ifndef SDKLIBRARY_H +#define SDKLIBRARY_H + +#include "ISdk.h" + +class Sdk : public ISdk { +public: + uintptr_t m_pGameBase; + + Sdk() { + // At the moment we will focus on GTA SA and Vice City + uintptr_t m_pSA = aml->GetLib("libGTASA.so"), m_pVC = aml->GetLib("libGTAVC.so"); + + logger->SetTag("GtaSdk"); + if(!m_pSA && !m_pVC) { + logger->Error("GtaSdk is not supported on this game"); + } else { + if(m_pSA) m_pGameBase = m_pSA; + else m_pGameBase = m_pVC; + logger->Info("GtaSdk v%s loaded successfully", GetVersion()); + } + } + + // get the current version of the SDK + const char* GetVersion(); +}; + +extern Sdk* sdk; + +extern CEvents renderCloudsEvent; +extern CEvents initScriptsEvent; +extern CEvents processScriptsEvent; +extern CEvents initRwEvent; +extern CEvents shutdownRwEvent; +extern CEvents initPoolsEvent; +extern CEvents pedCtorEvent; +extern CEvents pedDtorEvent; +extern CEvents pedRenderEvent; +extern CEvents objectRenderEvent; +extern CEvents objectPreRenderEvent; +extern CEvents touchEvent; +extern CEvents drawHudEvent; +extern CEvents drawingEvent; +extern CEvents drawAfterFadeEvent; +extern CEvents drawRadarEvent; +extern CEvents drawBlipsEvent; +extern CEvents drawRadarOverlayEvent; +extern CEvents drawMenuEvent; +extern CEvents vehicleRenderEvent; +extern CEvents vehicleCtorEvent; +extern CEvents vehicleDtorEvent; +extern CEvents objectCtorEvent; +extern CEvents objectDtorEvent; +extern CEvents initGameEvent; + +// new events +extern CEvents updateWidgetsEvent; + +#endif diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..8b4912a --- /dev/null +++ b/main.cpp @@ -0,0 +1,15 @@ +#include +#include + +MYMOD(net.Android.GtaSdk, Gta Android SDK, 1.0, XMDS and KillerSA) + +#include + +Sdk* sdk = new Sdk(); + +inline const char* Sdk::GetVersion(){ return modinfo->VersionString(); } + +extern "C" void OnModPreLoad() +{ + RegisterInterface("GtaSdk", sdk); +} diff --git a/ndkpath.txt b/ndkpath.txt new file mode 100644 index 0000000..2f2f86e --- /dev/null +++ b/ndkpath.txt @@ -0,0 +1 @@ +F:\ndk \ No newline at end of file diff --git a/sdkmod.h b/sdkmod.h new file mode 100644 index 0000000..0c0e291 --- /dev/null +++ b/sdkmod.h @@ -0,0 +1,12 @@ +#ifndef SDKMOD_H +#define SDKMOD_H + +// use this in your plugins to get the sdk interface +#include +#include +#include + +#define MYSDKDECL() + Sdk* sdk = (Sdk*)GetInterface("GtaSdk"); + +#endif \ No newline at end of file