Handling AOBScanModule errors

Anything Cheat Engine related, bugs, suggestions, helping others, etc..
Post Reply
User avatar
gibberishh
Table Makers
Table Makers
Posts: 331
Joined: Fri Jul 02, 2021 5:48 pm
Reputation: 225

Handling AOBScanModule errors

Post by gibberishh »

Is there a way to handle AOBScanModule errors in autoassembler? I tried {$try} {$except}, but that only seems to work in code blocks, not if a scan fails.

I have 2 byte patterns. If one scan fails, I want to use the other. No, this cannot be achieved via wildcards because the patterns are totally different.

Lua's AOBScan function throws a syntaxcheck error and prevents the script from running, so I can't achieve this via Lua either. I'm using CE 7.2.

If you need more info, let me know.

Thanks.

aSwedishMagyar
Table Makers
Table Makers
Posts: 670
Joined: Mon Jul 06, 2020 3:19 am
Reputation: 1190

Re: Handling AOBScanModule errors

Post by aSwedishMagyar »

Do you have a code block so we can see what you are trying to accomplish? Obviously we can't give you suggestions on your code unless we see it.

I'll generalize though and make an assumption.

If you want to register either one scan or the other then running through a list is all you need:

Code: Select all

--symbolName and bytePattern are both strings, easy enough to figure out what needs to go where
local symbolName = 'MySymbol'
local bytePattern1 = '0FxxxxxxxxxxE8xxxxxxxx40'
local bytePattern2 = '0FxxxxxxxxxxE8xxxxxxxx48'
local listAOB = {{symbolName,bytePattern1},{symbolName,bytePattern2}}
--iterate through your list and register the scan result as your given symbol name
for i = 1,#listAOB do
	local scanResults = AOBScan(listAOB[i][2],'+X')--the '+X' means it will only scan executable memory
	if scanResults and scanResults.Count == 1 then
		unregisterSymbol(listAOB[i][1])
		registerSymbol(listAOB[i][1],scanResults[0])
		break	--makes sure you only use the first valid result if that's what you're going for
	end
end
if getAddressSafe(symbolName) == nil then error(symbolName.." AOB not Found") end
Just replace MySymbol with whatever symbol name you want and replace the two byte patterns with your own.

User avatar
gibberishh
Table Makers
Table Makers
Posts: 331
Joined: Fri Jul 02, 2021 5:48 pm
Reputation: 225

Re: Handling AOBScanModule errors

Post by gibberishh »

aSwedishMagyar wrote:
Thu Aug 12, 2021 8:54 pm
Do you have a code block so we can see what you are trying to accomplish? Obviously we can't give you suggestions on your code unless we see it.
Thanks a bunch. I'll try this out. I'm also posting my code in case you have any suggestions on a better way to achieve the result:

Code: Select all

[ENABLE]
aobscanmodule(xp,$process,8B 80 BC 01 00 00 3B C2) // Searches for the address of the player's XP
alloc(CharAdr,4)                // CharAdr is the symbol used for all cheats. All pointers are CharAdr +offset

registersymbol(CharAdr)
registersymbol(xp)

xp:
  mov [CharAdr],eax            // Stores CharAdr: Unfortunately, this also overwrites the bytes, 
                            { which means if I close the table, I can't just open it again and reload. 
                             I have to restart the game too, to reset the original bytes. Or, I can't 
                             have 2 instances of the table loading (which is useful when I'm coding).
                             So my current solution is to search for these bytes, or the replaced bytes.
                             That will obviously create a further problem of twice-replaced bytes, 
                             but I don't have a plan for it yet.
                             The best solution for me would be if the bytes are not replaced at all! }
  ret

[DISABLE]
xp:
  db 8B 80 BC 01 00 00         // Replaces the original bytes
  unregistersymbol(xp)
  unregistersymbol(CharAdr)
  dealloc(CharAdr)
The code above contains hard-coded bytes and not wildcards for clarity.

Post Reply

Who is online

Users browsing this forum: No registered users