forked from god12l/olympia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobjects.py
204 lines (170 loc) · 6.79 KB
/
objects.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
from __future__ import annotations
from synapse import Synapse
class ReturnValue:
def __init__(self, address: int, synapse: Synapse) -> ReturnValue:
self.self = address
self.synapse = synapse
self.offsets = {
"vftable": 0x0,
"value": 0x8,
}
@property
def Value(self) -> str:
try:
ptr = self.synapse.memory.read_longlong(self.self + self.offsets["value"])
fl = self.synapse.memory.read_longlong(ptr + 0x18)
if fl == 0x1F:
ptr = self.synapse.memory.read_longlong(ptr)
return self.synapse.readRobloxString(ptr)
except:
return "???"
class PropertyDescriptor:
def __init__(self, address: int, synapse: Synapse) -> PropertyDescriptor:
self.self = address
self.synapse = synapse
self.offsets = {
"vftable": 0x0,
"name": 0x8,
"return_value": 0x30,
"get_set_impl": 0x48
}
@property
def Name(self) -> str:
try:
ptr = self.synapse.memory.read_longlong(self.self + self.offsets["name"])
fl = self.synapse.memory.read_longlong(ptr + 0x18)
if fl == 0x1F:
ptr = self.synapse.memory.read_longlong(ptr)
return self.synapse.readRobloxString(ptr)
except:
return "???"
@property
def Value(self) -> str:
try:
returnValue = ReturnValue(self.synapse.memory.read_longlong(self.self + self.offsets["return_value"]), self.synapse)
return returnValue.Value
except:
return "???"
class ClassDescriptor:
def __init__(self, address: int, synapse: Synapse) -> ClassDescriptor:
self.self = address
self.synapse = synapse
self.offsets = {
"vftable": 0x0,
"class_name": 0x8,
"properties": 0x40, # 0x20
}
@property
def ClassName(self) -> str:
try:
ptr = self.synapse.memory.read_longlong(self.self + self.offsets["class_name"])
fl = self.synapse.memory.read_longlong(ptr + 0x18)
if fl == 0x1F:
ptr = self.synapse.memory.read_longlong(ptr)
return self.synapse.readRobloxString(ptr)
except:
return "???"
def GetProperties(self) -> list[PropertyDescriptor]:
prop_begin = self.synapse.memory.read_longlong(self.self + self.offsets["properties"])
prop_end = self.synapse.memory.read_longlong(self.self + self.offsets["properties"] + 0x8)
children = []
if prop_begin == 0 or prop_end == 0:
return []
while prop_begin != prop_end:
current_prop = self.synapse.memory.read_longlong(prop_begin)
if (current_prop != 0):
prop = PropertyDescriptor(current_prop, self.synapse)
if not prop.Name == "???":
children.append(prop)
prop_begin += 0x8
return children
class Instance:
def __init__(self, address: int, synapse: Synapse) -> Instance:
self.self = address
self.synapse = synapse
self.offsets = {
"vftable": 0x0,
"self": 0x8,
"class_descriptor": 0x18,
"name": 0x48,
"children": 0x50,
"parent": 0x60
}
@property
def ClassDescriptor(self) -> ClassDescriptor:
try:
ptr = self.synapse.memory.read_longlong(self.self + self.offsets["class_descriptor"])
classDescriptor = ClassDescriptor(ptr, self.synapse)
return classDescriptor
except:
return None
@property
def ClassName(self) -> str:
try:
return self.ClassDescriptor.ClassName
except:
return "???"
@property
def Name(self) -> str:
try:
ptr = self.synapse.memory.read_longlong(self.self + self.offsets["name"])
fl = self.synapse.memory.read_longlong(ptr + 0x18)
if fl == 0x1F:
ptr = self.synapse.memory.read_longlong(ptr)
name = self.synapse.readRobloxString(ptr)
if len(name.strip()) > 1:
return name
else:
return self.ClassName
except:
return self.ClassName
@property
def Parent(self) -> Instance:
try:
if self.synapse.memory.read_longlong(self.self + self.offsets["parent"]) != 0:
return Instance(self.synapse.memory.read_longlong(self.self + self.offsets["parent"]), self.synapse)
return None
except:
return None
@property
def HasChildren(self) -> bool:
if self.self != 0:
child_list = self.synapse.memory.read_longlong(self.self + self.offsets["children"])
if child_list != 0:
child_begin = self.synapse.memory.read_longlong(child_list)
end_child = self.synapse.memory.read_longlong(child_list + 0x8)
child_offset = 0x10
return int((end_child - child_begin) / child_offset) > 0
return False
def GetChildren(self) -> list[Instance]:
children = []
if self.self != 0:
child_list = self.synapse.memory.read_longlong(self.self + self.offsets["children"])
if child_list != 0:
child_begin = self.synapse.memory.read_longlong(child_list)
end_child = self.synapse.memory.read_longlong(child_list + 0x8)
child_offset = 0x10
while child_begin != end_child:
current_instance = self.synapse.memory.read_longlong(child_begin)
if current_instance !=0:
child = Instance(current_instance, self.synapse)
if not child.Name == "???" and not child.ClassName == "???":
children.append(child)
child_begin = child_begin + child_offset
return children
def GetProperties(self) -> list[PropertyDescriptor]:
return self.ClassDescriptor.GetProperties()
def FindFirstChild(self, name: str) -> Instance:
for child in self.GetChildren():
if child.Name == name:
return child
return None
def FindFirstChildOfClass(self, className: str) -> Instance:
for child in self.GetChildren():
if child.ClassName == className:
return child
return None
def IsA(self, className: str) -> bool:
return self.ClassName == className
def __getattr__(self, name: str) -> Instance:
return self.FindFirstChild(name)