From 8d335c795b5d83ea54a7ad4c09ff0aae108f9a30 Mon Sep 17 00:00:00 2001 From: maybegreat48 <96936658+maybegreat48@users.noreply.github.com> Date: Sat, 23 Sep 2023 21:47:58 +0000 Subject: [PATCH] Add rlMetric (#3) * feat(metric): add rlMetric * fix(metric): serializer fix * feat(tls): add tlsContext --------- Co-authored-by: maybegreat48 --- classes.cpp | 3 +++ rage/rlJson.hpp | 38 ++++++++++++++++++++++++++++++++++++++ rage/rlMetric.hpp | 21 +++++++++++++++++++++ rage/tlsContext.hpp | 26 ++++++++++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 rage/rlJson.hpp create mode 100644 rage/rlMetric.hpp create mode 100644 rage/tlsContext.hpp diff --git a/classes.cpp b/classes.cpp index a5c5201..94456f1 100644 --- a/classes.cpp +++ b/classes.cpp @@ -9,6 +9,9 @@ #include "player/CPlayerInfo.hpp" #include "rage/atArray.hpp" #include "rage/joaat.hpp" +#include "rage/rlJson.hpp" +#include "rage/rlMetric.hpp" +#include "rage/tlsContext.hpp" #include "rage/vector.hpp" #include "script/scriptHandlerNetComponent.hpp" #include "script/scrNativeHandler.hpp" diff --git a/rage/rlJson.hpp b/rage/rlJson.hpp new file mode 100644 index 0000000..44b1235 --- /dev/null +++ b/rage/rlJson.hpp @@ -0,0 +1,38 @@ +#pragma once +#include + +#pragma pack(push, 4) +namespace rage +{ + class rlJson + { + uint32_t unk0; // 0x00 + uint32_t unk1; // 0x04 + char* buffer; // 0x08 + uint32_t curlen;// 0x10 + uint32_t maxlen;// 0x14 + uint32_t unk4; // 0x18 + uint32_t flags; // 0x1C + uint8_t flags2; // 0x20 + + public: + rlJson(char* _buffer, uint32_t _length) : + buffer(_buffer), + maxlen(_length) + { + unk0 = 0; + unk1 = 0; + curlen = 0; + unk4 = 1; + flags = 0; + flags2 = 0; + } + + inline char* GetBuffer() const + { + return buffer; + } + }; + static_assert(sizeof(rage::rlJson) == 0x24); +} +#pragma pack(pop) \ No newline at end of file diff --git a/rage/rlMetric.hpp b/rage/rlMetric.hpp new file mode 100644 index 0000000..f223602 --- /dev/null +++ b/rage/rlMetric.hpp @@ -0,0 +1,21 @@ +#pragma once +#include "joaat.hpp" + +namespace rage +{ + class rlJson; + class rlMetric + { + public: + virtual ~rlMetric() = default; // 0x00 + virtual int GetType() = 0; // 0x08 + virtual int GetType2() = 0; // 0x10 + virtual const char* GetName() = 0; // 0x18 + virtual bool Serialize(rage::rlJson* serializer) = 0; // 0x20 + virtual int GetSize() = 0; // 0x28 + virtual joaat_t GetNameHash() = 0; // 0x30 + virtual bool _0x38() = 0; + virtual bool _0x40() = 0; + }; + static_assert(sizeof(rage::rlMetric) == 0x8); +} \ No newline at end of file diff --git a/rage/tlsContext.hpp b/rage/tlsContext.hpp new file mode 100644 index 0000000..1f7293b --- /dev/null +++ b/rage/tlsContext.hpp @@ -0,0 +1,26 @@ +#pragma once + +#if _WIN32 +#include +#endif + +namespace rage +{ +#pragma pack(push, 8) + class tlsContext + { + char pad[0x1700]; + public: + bool m_RunningScript; // 0x1700 + +#if _WIN32 + static tlsContext* Get() + { + constexpr std::uint32_t TlsIndex = 0x0; + return *reinterpret_cast(__readgsqword(0x58) + TlsIndex); + } +#endif + }; +#pragma pack(pop) + static_assert(sizeof(rage::tlsContext) == 0x1701); +} \ No newline at end of file