| Csimbi I post too much
 
  Reputation: 97 
 Joined: 14 Jul 2007
 Posts: 3327
 
 
 | 
			
				|  Posted: Thu Oct 23, 2025 4:20 am    Post subject: |   |  
				| 
 |  
				| 2024 bugfix 
  	  | Code: |  	  | <?xml version="1.0" encoding="utf-8"?> <CheatTable CheatEngineTableVersion="46">
 <CheatEntries>
 <CheatEntry>
 <ID>0</ID>
 <Description>"one-liner and test"</Description>
 <VariableType>Auto Assembler Script</VariableType>
 <AssemblerScript>{$lua}
 
 -- assume LaunchMonoDataCollector has been called
 
 -- one liner (including the *2024 bug*)
 -- function reEscape(a)local b=[[().%+-*?[^]]a=a:gsub('.',function(c)if b:find(c,1,true)then return'%'..c end end)return a end;function findMethodAddrBySignature(d,e,f,g,h)local i=findMethodBySignature(d,e,f,g,h)if i~=nil and i>0 then return mono_compile_method(i)end end;function findMethodBySignature(d,e,f,g,h)assert(type(g)=='string',"invalid signature")g="^"..reEscape(g:gsub(";",","))local j=mono_findClass(d,e)if type(j)~='number'or j==0 then return nil end;local k=mono_class_enumMethods(j)if type(k)~='table'or#k<1 then return nil end;if h then print('check:'..f..": <"..g.."> vs ")end;for l=1,#k do if f==k[l].name then local m=mono_method_getSignature(k[l].method)if h then print("  >> <"..m..'>')end;if m:match(g)then return k[l].method end end end end;function tohex(n)return string.format('%X',n or 0)end
 
 -- one liner (including the *2024 bugfix*)
 ---- panraven's one-liner - all credits and thanks to panraven!
 ---- For more info, please refer to https://forum.cheatengine.org/viewtopic.php?p=5659670#5659670
 function reEscape(a)local b=[[().%+-*?[^]]a=a:gsub('.',function(c)if b:find(c,1,true)then return'%'..c end end)return a end;function findMethodAddrBySignature(d,e,f,g,h)local i=findMethodBySignature(d,e,f,g,h)if i~=nil and i>0 then return mono_compile_method(i) end end;function findMethodBySignature(d,e,f,g,h)assert(type(g)=='string',"invalid signature")local j=mono_findClass(d,e)if type(j)~='number'or j==0 then return nil end;local k=mono_class_enumMethods(j)if type(k)~='table'or#k<1 then return nil end;if h then print('check:'..f..": <"..g.."> vs ")end;for l=1,#k do if f==k[l].name then local m=mono_method_getSignature(k[l].method) if h then print("  >> <"..m..'>')end;if m == g then return k[l].method end end end end;function tohex(n)return string.format('%X',n or 0)end
 
 {$asm}
 /* This is the expanded version of the original.
 function reEscape(a)
 local b=[[().%+-*?[^]]
 a=a:gsub('.',function(c)if b:find(c,1,true)then return'%'..c end end)
 return a
 end;
 function findMethodAddrBySignature(d,e,f,g,h)
 local i=findMethodBySignature(d,e,f,g,h)
 if i~=nil and i>0 then
 return mono_compile_method(i)
 end
 end;
 function findMethodBySignature(d,e,f,g,h)
 assert(type(g)=='string',"invalid signature")
 g="^"..reEscape(g:gsub(";",","))
 local j=mono_findClass(d,e)
 if type(j)~='number'or j==0 then return nil end;
 local k=mono_class_enumMethods(j)
 if type(k)~='table'or#k<1 then return nil end;
 if h then print('check:'..f..": <"..g.."> vs ")end;
 for l=1,#k do
 if f==k[l].name then
 local m=mono_method_getSignature(k[l].method)
 if h then print("  >> <"..m..'>')end;
 if m:match(g)then
 return k[l].method
 end
 end
 end
 end;
 function tohex(n)return string.format('%X',n or 0)end
 */
 
 /* This is the expanded version of the 2024 bugfixed one.
 function reEscape(a)
 local b=[[().%+-*?[^]]
 a=a:gsub('.',function(c)if b:find(c,1,true)then return'%'..c end end)
 return a
 end;
 function findMethodAddrBySignature(d,e,f,g,h)
 local i=findMethodBySignature(d,e,f,g,h)
 if i~=nil and i>0 then
 return mono_compile_method(i)
 end
 end;
 function findMethodBySignature(d,e,f,g,h)
 assert(type(g)=='string',"invalid signature")
 -- g="^"..reEscape(g:gsub(";",",")) -- *2024 bugfix* <=== REMOVE this line
 local j=mono_findClass(d,e)
 if type(j)~='number'or j==0 then return nil end;
 local k=mono_class_enumMethods(j)
 if type(k)~='table'or#k<1 then return nil end;
 if h then print('check:'..f..": <"..g.."> vs ")end;
 for l=1,#k do
 if f==k[l].name then
 local m=mono_method_getSignature(k[l].method)
 if h then print("  >> <"..m..'>')end;
 if m == g then       -- *2024 bugfix* <=== ADD this line
 --if m:match(g)then  -- *2024 bugfix* <=== REMOVE this line
 return k[l].method
 end
 end
 end
 end;
 function tohex(n)return string.format('%X',n or 0)end
 */
 
 {$asm}
 
 {$lua}
 -- test
 print('--') -- test to show/print all signature of a given function name
 print(tohex(findMethodAddrBySignature('UnityEngine','Texture2D','.ctor','?',true)))
 print('--') -- test to match a specific (third) signature of a function name
 print(tohex(findMethodAddrBySignature('UnityEngine','Texture2D','.ctor','int,int,UnityEngine.TextureFormat,bool,bool$',true)))
 -- the last '$' is lua match end-of-string, wthout this, the match MAY succeed on fourth one.
 -- all other character should be compare as is, including upper/lower cases.
 {$asm}
 
 
 {$lua}
 --define a lua Global INTEGER type variable for use in AA script, ce 6.5 feature
 
 LUAVAR = findMethodAddrBySignature('UnityEngine','Texture2D','.ctor','int,int,UnityEngine.TextureFormat,bool,bool$')
 
 {$asm}
 
 [ENABLE]
 
 globalalloc(testarea,$10)
 
 testarea:
 dq $LUAVAR     // using the Lua Variable in AA Script by prefixing a '$' symbol, Lua variable is case-sensitive.
 dq $LUAVAR+111111
 
 [DISABLE]
 
 </AssemblerScript>
 </CheatEntry>
 <CheatEntry>
 <ID>1</ID>
 <Description>"full function defintion"</Description>
 <VariableType>Auto Assembler Script</VariableType>
 <AssemblerScript>{$lua}
 
 -- assume LaunchMonoDataCollector has been called
 
 function reEscape(s)
 local escPatChars = [[().%+-*?[^]]
 s = s:gsub('.',function(c) if escPatChars:find(c,1,true) then return '%'..c end end)
 return s
 end
 function findMethodAddrBySignature(namespace,classname,methodname,signature,check)
 local meth = findMethodBySignature(namespace,classname,methodname,signature,check)
 if meth~=nil and meth>0 then
 return mono_compile_method(meth)
 end
 end
 function findMethodBySignature(namespace,classname,methodname,signature,check)
 assert(type(signature)=='string',"invalid signature")
 --signature="^"..reEscape(signature:gsub(";",",")) -- *2024 bugfix* <=== REMOVE this line
 local class = mono_findClass(namespace,classname)
 if type(class)~='number' or class==0 then return nil end
 local methods=mono_class_enumMethods(class)
 if type(methods)~='table' or #methods<1 then return nil end
 if check then print('check:'..methodname..": <"..signature.."> vs ") end
 for i=1,#methods do
 if methodname == methods[i].name then
 local sign = mono_method_getSignature(methods[i].method)
 if check then  print("  >> <"..sign..'>') end
 if sign == signature then     -- *2024 bugfix* <=== ADD this line
 --     if sign:match(signature) then -- *2024 bugfix* <=== REMOVE this line
 return methods[i].method
 end
 end
 end
 end
 -- Test
 function tohex(n)return string.format('%X',n or 0)end
 {$asm}
 
 [ENABLE]
 
 
 
 [DISABLE]
 
 </AssemblerScript>
 </CheatEntry>
 </CheatEntries>
 </CheatTable>
 
 | 
 |  |