From 57dea47acc3645921ae630fee10350567f1461bb Mon Sep 17 00:00:00 2001 From: tyackman <38179522+tyackman@users.noreply.github.com> Date: Thu, 13 Jun 2024 16:05:36 -0500 Subject: [PATCH] fwBasePool and encryption (#10) * Create pools.hpp Handles variable encryption for memory pools * Add missing include to classes.cpp * Create fwBasePool.hpp * I might do it right one day * Add missing pragma directive peabrain moment --------- Co-authored-by: Ryan <80224521+Rxann@users.noreply.github.com> --- classes.cpp | 4 ++- rage/fwBasePool.hpp | 65 +++++++++++++++++++++++++++++++++++++++++++++ rage/pools.hpp | 11 ++++++++ 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 rage/fwBasePool.hpp create mode 100644 rage/pools.hpp diff --git a/classes.cpp b/classes.cpp index 14f17ce..5e2488e 100644 --- a/classes.cpp +++ b/classes.cpp @@ -35,7 +35,9 @@ #include "rage/atArray.hpp" #include "rage/atPlayerBits.hpp" #include "rage/datBitBuffer.hpp" +#include "rage/fwBasePool.hpp" #include "rage/joaat.hpp" +#include "rage/pools.hpp" #include "rage/rlJson.hpp" #include "rage/rlMetric.hpp" #include "rage/tlsContext.hpp" @@ -48,4 +50,4 @@ #include "script/scrThreadContext.hpp" #include "script/scrVector.hpp" #include "script/types.hpp" -#include "rage/Guid.hpp" \ No newline at end of file +#include "rage/Guid.hpp" diff --git a/rage/fwBasePool.hpp b/rage/fwBasePool.hpp new file mode 100644 index 0000000..8bab8fc --- /dev/null +++ b/rage/fwBasePool.hpp @@ -0,0 +1,65 @@ +#pragma once +#include + +namespace rage +{ + class fwBasePool + { + public: + virtual ~fwBasePool() = 0; // 0x0000 + uintptr_t m_Entries; // 0x0008 + uint8_t* m_Flags; // 0x0010 + uint32_t m_Size; // 0x0018 + uint32_t m_ItemSize; // 0x001C + uint32_t m_0020; // 0x0020 + uint32_t m_0024; // 0x0024 + uint32_t m_FreeSlotIndex; // 0x0028 + + bool Full() const + { + return m_Size - (m_FreeSlotIndex & 0x3FFFFFFF) <= 256; + } + + int64_t GetNumFreeSlots() const + { + return static_cast(m_Size) - static_cast((m_FreeSlotIndex * 4) >> 2); + } + + int32_t GetScriptGuid(int32_t Index) const + { + return (Index << 8) + m_Flags[Index]; + } + + int32_t GetIndex(int32_t ScriptGuid) const + { + return ScriptGuid >> 8; + } + + bool IsValid(int32_t Index) const + { + return !(m_Flags[Index] & 0x80); + } + + void* GetAt(size_t Index) const + { + if (m_Flags[Index]) + { + if (_fwObj* obj = reinterpret_cast<_fwObj*>(m_Entries + Index * m_ItemSize); obj->m_0010) + return obj; + } + + return nullptr; + } + + // Helper class to check object validity (m_0010) + class _fwObj + { + public: + virtual ~_fwObj() = 0; + uint64_t m_0008; + void* m_0010; + }; + + }; //Size: 0x0030 + static_assert(sizeof(fwBasePool) == 0x30); +} diff --git a/rage/pools.hpp b/rage/pools.hpp new file mode 100644 index 0000000..3bb3e48 --- /dev/null +++ b/rage/pools.hpp @@ -0,0 +1,11 @@ +#pragma once +#include + +class PoolEncryption +{ +public: + bool m_IsSet; //0x0000 + uint64_t m_First; //0x0008 + uint64_t m_Second; //0x0010 +}; //Size: 0x0018 +static_assert(sizeof(PoolEncryption) == 0x18);