Skip to content

Commit 67332ac

Browse files
committed
fix fieldsearch and don't lookup field static addresses for generic classes
1 parent 4d3d28b commit 67332ac

File tree

3 files changed

+54
-32
lines changed

3 files changed

+54
-32
lines changed

Cheat Engine/bin/autorun/dotnetinfo.lua

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,19 @@ local function getClassMethods(Class)
182182
end
183183

184184
local function getClassFields(Class)
185+
if CurrentProcess~=getOpenedProcessID() then return nil end
186+
185187
local r={}
186188

187189
local i
188-
if Class.Image.Domain.Control==CONTROL_MONO then
189-
local StaticFieldAddress=mono_class_getStaticFieldAddress(0,Class.Handle)
190-
190+
if Class.Image.Domain.Control==CONTROL_MONO then
191+
local isGeneric=mono_class_isgeneric(Class.Handle)
192+
local StaticFieldAddress=nil
193+
194+
if isGeneric==false then
195+
StaticFieldAddress=mono_class_getStaticFieldAddress(0,Class.Handle)
196+
end
197+
191198
local fields=mono_class_enumFields(Class.Handle, true)
192199
for i=1,#fields do
193200
local e={}
@@ -198,8 +205,10 @@ local function getClassFields(Class)
198205
e.Offset=fields[i].offset
199206
e.Static=fields[i].isStatic
200207
e.Const=fields[i].isConst
201-
if e.Static and StaticFieldAddress and StaticFieldAddress~=0 then
202-
e.Address=StaticFieldAddress+e.Offset
208+
if isGeneric==false then
209+
if e.Static and StaticFieldAddress and StaticFieldAddress~=0 then
210+
e.Address=StaticFieldAddress+e.Offset
211+
end
203212
end
204213

205214

@@ -350,7 +359,7 @@ end
350359

351360
local function getDomains()
352361
DataSource.Domains={}
353-
362+
354363
if monopipe then
355364
local mr=mono_enumDomains()
356365
local i
@@ -1813,12 +1822,14 @@ end
18131822
function miDotNetInfoClick(sender)
18141823
--print("miDotNetInfoClick")
18151824
--in case of a double case scenario where there's both .net and mono, go for net first if the user did not activate mono explicitly
1816-
if (DataSource.DotNetDataCollector==nil) or (CurrentProcess~=getOpenedProcessID) then
1825+
if (DataSource.DotNetDataCollector==nil) or (CurrentProcess~=getOpenedProcessID()) then
18171826
--print("getting getDotNetDataCollector")
18181827
DataSource={}
18191828
DataSource.DotNetDataCollector=getDotNetDataCollector()
18201829
end
18211830

1831+
CurrentProcess=getOpenedProcessID()
1832+
18221833

18231834
--print("miDotNetInfoClick 2")
18241835
if miMonoTopMenuItem and miMonoTopMenuItem.miMonoActivate.Visible and (monopipe==nil) then

Cheat Engine/bin/autorun/dotnetsearch.lua

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -205,37 +205,42 @@ function spawnDotNetSearchDialog(DataSource, frmDotNetInfo, searchtype)
205205
end)
206206
end
207207
elseif searchtype==1 then
208-
--field search
209-
if DataSource.Domains[i].Images[j].Classes[k].Fields==nil then
210-
getClassFields(DataSource.Domains[i].Images[j].Classes[k])
208+
--field search
209+
if DataSource.Domains[i].Images[j].Classes[k].Fields==nil then
210+
DataSource.getClassFields(DataSource.Domains[i].Images[j].Classes[k])
211211
end
212212

213-
for l=1,#DataSource.Domains[i].Images[j].Classes[k].Fields do
214-
local name=DataSource.Domains[i].Images[j].Classes[k].Fields[l].Name
215-
if not caseSensitive then
216-
name=name:upper()
217-
end
218-
219-
if name:find(searchInput) then
220-
synchronize(function()
221-
if t.Terminated then return end
222-
--add to the list
223-
local li=frmSearch.lvResults.Items.add()
224-
li.Caption=DataSource.Domains[i].Images[j].FileName
225-
li.SubItems.add(DataSource.Domains[i].Images[j].Classes[k].Name)
226-
li.SubItems.add(DataSource.Domains[i].Images[j].Classes[k].Fields[l].Name)
227-
228-
local e={}
229-
e.DomainIndex=i
230-
e.ImageIndex=j
231-
e.ClassIndex=k
232-
e.FieldIndex=l
233-
searchresults[li.Index+1]=e
234-
end)
213+
--print("parsing field list")
214+
if DataSource.Domains[i].Images[j].Classes[k].Fields then
215+
for l=1,#DataSource.Domains[i].Images[j].Classes[k].Fields do
216+
local name=DataSource.Domains[i].Images[j].Classes[k].Fields[l].Name
217+
if not caseSensitive then
218+
name=name:upper()
219+
end
235220

221+
if name:find(searchInput) then
222+
synchronize(function()
223+
if t.Terminated then return end
224+
--add to the list
225+
local li=frmSearch.lvResults.Items.add()
226+
li.Caption=DataSource.Domains[i].Images[j].FileName
227+
li.SubItems.add(DataSource.Domains[i].Images[j].Classes[k].Name)
228+
li.SubItems.add(DataSource.Domains[i].Images[j].Classes[k].Fields[l].Name)
229+
230+
local e={}
231+
e.DomainIndex=i
232+
e.ImageIndex=j
233+
e.ClassIndex=k
234+
e.FieldIndex=l
235+
searchresults[li.Index+1]=e
236+
end)
237+
238+
end
236239
end
237240
end
238241

242+
243+
239244
elseif searchtype==2 then
240245
--method search
241246
if DataSource.Domains[i].Images[j].Classes[k].Methods==nil then
@@ -270,6 +275,7 @@ function spawnDotNetSearchDialog(DataSource, frmDotNetInfo, searchtype)
270275
end
271276
end
272277
else
278+
print("wtf")
273279
return --wtf
274280
end
275281

Cheat Engine/bin/autorun/monoscript.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,11 @@ function mono_image_enumClasses(image)
11751175
end
11761176

11771177
function mono_class_isgeneric(class)
1178+
if class==nil then
1179+
print("mono_class_isgeneric with null pointer: ")
1180+
print(debug.traceback())
1181+
return nil
1182+
end
11781183
local result=''
11791184
monopipe.lock()
11801185
monopipe.writeByte(MONOCMD_ISCLASSGENERIC)

0 commit comments

Comments
 (0)