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>
This commit is contained in:
tyackman 2024-06-13 16:05:36 -05:00 committed by GitHub
parent 515edbcad8
commit 57dea47acc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 79 additions and 1 deletions

View File

@ -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"
#include "rage/Guid.hpp"

65
rage/fwBasePool.hpp Normal file
View File

@ -0,0 +1,65 @@
#pragma once
#include <cstdint>
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<int64_t>(m_Size) - static_cast<int>((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);
}

11
rage/pools.hpp Normal file
View File

@ -0,0 +1,11 @@
#pragma once
#include <cstdint>
class PoolEncryption
{
public:
bool m_IsSet; //0x0000
uint64_t m_First; //0x0008
uint64_t m_Second; //0x0010
}; //Size: 0x0018
static_assert(sizeof(PoolEncryption) == 0x18);