11#pragma once
22
3+ #include " game.h"
4+
35#include " Handle.h"
46#include " Memory.h"
57
@@ -21,31 +23,60 @@ namespace Memory
2123 {
2224 Handle handle;
2325
24- handle = FindPattern (" 41 F7 F0 48 8B 05 ? ? ? 00 4C" );
25- if (!handle.IsValid ())
26- return pedModels;
26+ DWORD64 archetypeMap_Map;
27+ WORD archetypeMap_Slots;
28+ DWORD64 archetypePool_ElemSize;
29+ DWORD64 archetypePool_PoolPtr;
30+ DWORD archetypePool_Size;
31+ DWORD64 archetypePool_AllocatedMap_Bits;
32+
33+ if (IsLegacy ())
34+ {
35+ handle = FindPattern (" 41 F7 F0 48 8B 05 ? ? ? 00 4C" );
36+ if (!handle.IsValid ())
37+ return pedModels;
38+
39+ archetypeMap_Map = handle.At (5 ).Into ().Value <DWORD64>();
40+ archetypeMap_Slots = handle.At (-28 ).Into ().Value <WORD>();
2741
28- DWORD64 qword_7FF69DB37F30 = handle.At (5 ).Into ().Value <DWORD64>();
42+ handle = FindPattern (" 73 17 4C 0F AF 05" );
43+ if (!handle.IsValid ())
44+ return pedModels;
2945
30- WORD word_7FF69DB37F38 = handle.At (-28 ).Into ().Value <WORD>();
46+ archetypePool_ElemSize = handle.At (5 ).Into ().Value <DWORD64>();
47+ archetypePool_PoolPtr = handle.At (12 ).Into ().Value <DWORD64>();
3148
32- handle = FindPattern (" 73 17 4C 0F AF 05 " );
33- if (!handle.IsValid ())
34- return pedModels;
49+ handle = FindPattern (" 3B 05 ? ? ? 00 7D 35 " );
50+ if (!handle.IsValid ())
51+ return pedModels;
3552
36- DWORD64 qword_7FF69DB37EE8 = handle.At (5 ).Into ().Value <DWORD64>();
37- DWORD64 qword_7FF69DB37ED0 = handle.At (12 ).Into ().Value <DWORD64>();
53+ archetypePool_Size = handle.At (1 ).Into ().Value <DWORD>();
54+ archetypePool_AllocatedMap_Bits = handle.At (18 ).Into ().Value <DWORD64>();
55+ }
56+ else
57+ {
58+ handle = Memory::FindPattern (" 74 7C 49 89 D0 4C 8B 1D" );
3859
39- handle = FindPattern (" 3B 05 ? ? ? 00 7D 35" );
40- if (!handle.IsValid ())
41- return pedModels;
60+ if (!handle.IsValid ())
61+ return pedModels;
4262
43- DWORD dword_7FF69DB37ED8 = handle.At (1 ).Into ().Value <DWORD>();
44- DWORD64 qword_7FF69DB37F00 = handle.At (18 ).Into ().Value <DWORD64>();
63+ archetypeMap_Map = handle.At (7 ).Into ().Value <DWORD64>();
64+ archetypeMap_Slots = handle.At (-8 ).Into ().Value <WORD>();
65+
66+ handle = Memory::FindPattern (" 7D 36 48 8B 05" );
67+
68+ archetypePool_Size = handle.At (-5 ).Into ().Value <DWORD>();
69+ archetypePool_AllocatedMap_Bits = handle.At (4 ).Into ().Value <DWORD64>();
70+
71+ archetypePool_PoolPtr = handle.At (27 ).Into ().Value <DWORD64>();
72+ archetypePool_ElemSize = handle.At (43 ).Into ().Value <DWORD64>();
73+
74+ DEBUG_LOG (archetypeMap_Map << " " << archetypeMap_Slots << " " << archetypePool_Size << " " << archetypePool_AllocatedMap_Bits << " " << archetypePool_PoolPtr << " " << archetypePool_ElemSize);
75+ }
4576
46- for (WORD i = 0 ; i < word_7FF69DB37F38 ; i++)
77+ for (WORD i = 0 ; i < archetypeMap_Slots ; i++)
4778 {
48- auto model = *reinterpret_cast <Hash **>(qword_7FF69DB37F30 + 8 * i);
79+ auto model = *reinterpret_cast <Hash **>(archetypeMap_Map + 8 * i);
4980 if (!model)
5081 continue ;
5182
@@ -59,13 +90,13 @@ namespace Memory
5990 DWORD64 v5 = *reinterpret_cast <WORD *>(model + 4 );
6091 LONG v6;
6192 // IDA copy paste ftw
62- if (static_cast <DWORD>(v5) < dword_7FF69DB37ED8
63- && (v6 = *reinterpret_cast <DWORD *>(qword_7FF69DB37F00 + 4 * (v5 >> 5 )),
93+ if (static_cast <DWORD>(v5) < archetypePool_Size
94+ && (v6 = *reinterpret_cast <DWORD *>(archetypePool_AllocatedMap_Bits + 4 * (v5 >> 5 )),
6495 _bittest (&v6, v5 & 0x1F )))
6596 {
6697 v2 = *reinterpret_cast <__int64 *>(
67- qword_7FF69DB37ED0
68- + qword_7FF69DB37EE8 * *reinterpret_cast <WORD *>(reinterpret_cast <__int64>(model) + 4 ));
98+ archetypePool_PoolPtr
99+ + archetypePool_ElemSize * *reinterpret_cast <WORD *>(reinterpret_cast <__int64>(model) + 4 ));
69100 }
70101
71102 if (v2 && (*reinterpret_cast <BYTE *>(v2 + 157 ) & 31 ) == 6 ) // is a ped model
0 commit comments