From 07d80a9fcecdcdcc8f98fb07db2386dba17a88bf Mon Sep 17 00:00:00 2001 From: Yimura <24669514+Yimura@users.noreply.github.com> Date: Fri, 25 Nov 2022 17:12:06 +0100 Subject: [PATCH] feat(Security): Added RageSecurity class (#79) --- network/Network.hpp | 6 ++--- security/Obf32.hpp | 25 ------------------- security/ObfVar.hpp | 51 +++++++++++++++++++++++++++++++++++++++ security/RageSecurity.hpp | 12 +++++++++ 4 files changed, 66 insertions(+), 28 deletions(-) delete mode 100644 security/Obf32.hpp create mode 100644 security/ObfVar.hpp create mode 100644 security/RageSecurity.hpp diff --git a/network/Network.hpp b/network/Network.hpp index 3f86e10..bdb0995 100644 --- a/network/Network.hpp +++ b/network/Network.hpp @@ -1,6 +1,6 @@ #pragma once #include "../rage/rlMetric.hpp" -#include "../security/Obf32.hpp" +#include "../security/ObfVar.hpp" #include "CNetComplaintMgr.hpp" #include "snSession.hpp" #include @@ -171,8 +171,8 @@ class Network { public: class rage::rlSessionInfo m_session_info; //0x0000 - class Obf32 m_num_dinput8_instances; //0x0070 - class Obf32 m_last_time_dinput8_checked; //0x0080 + rage::Obf32 m_num_dinput8_instances; //0x0070 + rage::Obf32 m_last_time_dinput8_checked; //0x0080 class rage::snSession* m_game_session_ptr; //0x0090 class rage::snSession* m_transition_session_ptr; //0x0098 char pad_00A0[24]; //0x00A0 diff --git a/security/Obf32.hpp b/security/Obf32.hpp deleted file mode 100644 index cabc07c..0000000 --- a/security/Obf32.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once -#include - -#pragma pack(push, 1) -class Obf32 -{ - std::uint32_t a; - std::uint32_t b; - std::uint32_t c; - std::uint32_t d; - -public: - inline void operator=(std::uint32_t val) - { - a = val & d; - b = val & ~d; - } - - inline operator std::uint32_t() - { - return (a & d) | (b & ~d); - } -}; -static_assert(sizeof(Obf32) == 0x10); -#pragma pack(pop) \ No newline at end of file diff --git a/security/ObfVar.hpp b/security/ObfVar.hpp new file mode 100644 index 0000000..02c6e26 --- /dev/null +++ b/security/ObfVar.hpp @@ -0,0 +1,51 @@ +#pragma once +#include + +namespace rage +{ + template + class ObfVar + { + private: + T m_unk1; + T m_unk2; + T m_unk3; + T m_unk4; + + public: + T getData() + { + auto v105 = m_unk4; + auto v28 = m_unk1 & v105; + auto v94 = m_unk2 & ~v105; + return v28 | v94; + } + + operator T () + { + return getData(); + } + +#if _WIN32 + void setData(T val) + { + auto seed = time(nullptr); + m_unk3 = seed; + seed = time(nullptr); + m_unk4 = seed; + + auto v48 = val & ~seed; + m_unk1 = seed & val; + m_unk2 = v48; + } + + void operator =(T val) + { + setData(val); + } +#endif + }; + + using Obf16 = ObfVar; + using Obf32 = ObfVar; +} \ No newline at end of file diff --git a/security/RageSecurity.hpp b/security/RageSecurity.hpp new file mode 100644 index 0000000..b0bf0a1 --- /dev/null +++ b/security/RageSecurity.hpp @@ -0,0 +1,12 @@ +#pragma once +#include "ObfVar.hpp" + +namespace rage +{ + class RageSecurity + { + public: + Obf32 m_lastRun; + Obf32 m_interval; + }; +} \ No newline at end of file