Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Cleanup aobscan results?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
bugzor
How do I cheat?
Reputation: 0

Joined: 20 Oct 2018
Posts: 5

PostPosted: Thu Oct 25, 2018 4:04 am    Post subject: Cleanup aobscan results? Reply with quote

I've managed to create a pseudo 1-hit kill script that basically spams aobscans to find the enemies hp, and changes them to 1.

The problem is that i haven't found a way to automatically cleanup the aobscan results, as in, the scan files in the temp folder, and the problem with that is that the aobscan function seems to go through every scan file in the temp folder. The result is that the script gets slower the longer it runs.

So my question is; is there a proper way to delete the aobscan results?

Also, the reason that i didn't created a proper 1-hit kill script is partially because i'm a n00b, and partially because the "Find out what..." stuff doesn't work on the target.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25785
Location: The netherlands

PostPosted: Thu Oct 25, 2018 6:01 am    Post subject: Reply with quote

is this the lua aobscan? If so just call .destroy() on the returned stringlist object
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
bugzor
How do I cheat?
Reputation: 0

Joined: 20 Oct 2018
Posts: 5

PostPosted: Fri Oct 26, 2018 12:52 pm    Post subject: Reply with quote

This is indeed lua.

i tried fiddling with .destroy(), and while it does indeed destroy the object, it doesnt actually do anything to the scan files in the temp folder.

On a related note, i found that when using the gui to scan, the new scan button properly cleans up the scan files.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25785
Location: The netherlands

PostPosted: Fri Oct 26, 2018 1:35 pm    Post subject: Reply with quote

could be a bug in lua aobscan (though i can't quickly see what the issue is)

do the temp files also not get deleted if you don't look at the folder ?

you can also try the memscan class to do an aob scan

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
bugzor
How do I cheat?
Reputation: 0

Joined: 20 Oct 2018
Posts: 5

PostPosted: Fri Oct 26, 2018 3:10 pm    Post subject: Reply with quote

Yup, the issue is present whether or not the folder is open.

I also noticed that the files stay even when the scan doesn't find anything, which is strange as aobscan returns nil in that case.

I've changed the script to use memscan instead now, which properly cleans up after itself.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4697

PostPosted: Fri Oct 26, 2018 3:10 pm    Post subject: Reply with quote

I can't replicate it.

It shouldn't have anything to do with destroying the stringlist- the memscan object is cleaned up before control is passed back to Lua.

Some other process might have an open handle to the file when CE tries to delete it.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
bugzor
How do I cheat?
Reputation: 0

Joined: 20 Oct 2018
Posts: 5

PostPosted: Fri Oct 26, 2018 3:51 pm    Post subject: Reply with quote

I just replicated it by opening cheat engine, targeting a random program and running this line in the cheat table:

Code:
AOBScan("20 30 40 50 60 70 80 FF FE", 1, 8)


and again, the issue is not present when i use memscan instead.

and just to be clear, the default location for the scan files that im talking about is

Code:
%USERNAME%\AppData\Local\Temp\Cheat Engine
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4697

PostPosted: Fri Oct 26, 2018 4:11 pm    Post subject: Reply with quote

You're using AOBScan incorrectly. Seems like CE as it is doesn't deal with this very well.

Please refer to celua.txt and defines.lua for documentation. You're probably looking for something like this:
Code:
AOBScan("20 30 40 50 60 70 80 FF FE", "", fsmAligned, "8")

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
bugzor
How do I cheat?
Reputation: 0

Joined: 20 Oct 2018
Posts: 5

PostPosted: Fri Oct 26, 2018 5:38 pm    Post subject: Reply with quote

I just pasted your code into a new cheat table and the issue is still present.

I also looked into celua.txt and saw that the third argument should be an integer, so i changed it... which didn't make a difference.

What's weirder is that i managed to make it work at some point by changing the array to 20 20 20 20 20 20 20 20, however changing any of those bytes to 30 made the issue pop up again. Unfortunately i can't seem to replicate this anymore.

One thing i did test while i could replicate it was whether the searches were returning any results, and both of them were, so that doesn't seem to be the problem.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25785
Location: The netherlands

PostPosted: Sat Oct 27, 2018 1:53 am    Post subject: Reply with quote

it's very likely that you may have an anti virus or other protection that still has the temp files open at the time they get deleted.

So do the memscan method but after the scan is done start a timer for a few seconds which will then destroy the memscan object and hope the AV has released the file by then

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4697

PostPosted: Sat Oct 27, 2018 11:57 am    Post subject: Reply with quote

I think I found it. There's a race condition between the SaveFirstScanThread and the main thread. If the memscan is destroyed before the SaveFirstScanThread releases the file handle, the files won't get deleted (sharing violation).
_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25785
Location: The netherlands

PostPosted: Sat Oct 27, 2018 12:21 pm    Post subject: Reply with quote

I'm not sure. The Memscan destructor terminates and destroys the saveFirstScanThread before it goes and deletes the results (free also calls terminate and waits for it (TThread.Destroy calls SysDestroy which calls terminate and waitfor))
And saveFirstScan always releases the files on thread exit (finally section)

but I do see it not cleaning results on my win10 test system as well. Could be it's a cached filesystem copy and windows being 'smart' again. (Just like their shutdown which is actually just sleep)

edit: I commented out the threadcode of TSaveFirstScanThread and still non-deleted files but removing the creation of TSaveFirstScanThread does stop it

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping


Last edited by Dark Byte on Sat Oct 27, 2018 12:51 pm; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4697

PostPosted: Sat Oct 27, 2018 12:49 pm    Post subject: Reply with quote

I say that based on what I'm seeing from Process Monitor.
  1. scanController creates saveFirstScanThread
  2. scanController exits
  3. saveFirstScanThread gets a handle to ADDRESSES.TMP
  4. main thread starts iterating over files in the temp directory (i.e. ADDRESSES.TMP and MEMORY.TMP)
  5. saveFirstScanThread gets a handle to MEMORY.TMP
  6. saveFirstScanThread reads from ADDRESSES.TMP
  7. main thread tries to destroy ADDRESSES.TMP, results in sharing violation
  8. main thread gives up

I can't see why this would happen either.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25785
Location: The netherlands

PostPosted: Sat Oct 27, 2018 12:57 pm    Post subject: Reply with quote

Does this also happen on a non-ssd harddisk ?
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4697

PostPosted: Sat Oct 27, 2018 1:01 pm    Post subject: Reply with quote

For me, yes. I'm on an old computer that doesn't have an ssd. (running win7; CE 6.8.1)

Edit: If saveFirstScanThread is never created, everything is destroyed as intended (tested 1000+ times).
Code:
define(address,"cheatengine-x86_64.exe"+11AC86)
define(bytes,E8 65 C5 FE FF 48 8b 55 f8 48 8b 92 88 00 00 00 48 89 42 18)
[ENABLE]
assert(address,bytes)
address:
  db 90 90 90 90 90 48 8b 55 f8 48 8b 92 88 00 00 00 90 90 90 90
  // E8 65 C5 FE FF 48 8b 55 f8 48 8b 92 88 00 00 00 48 89 42 18

[DISABLE]
address:
  db bytes

{
"cheatengine-x86_64.exe"+11AC5D: 48 8B 45 F8                    -  mov rax,[rbp-08]
"cheatengine-x86_64.exe"+11AC61: 48 8B 80 88 00 00 00           -  mov rax,[rax+00000088]
"cheatengine-x86_64.exe"+11AC68: 4C 8B 80 88 00 00 00           -  mov r8,[rax+00000088]
"cheatengine-x86_64.exe"+11AC6F: 48 8D 0D AA 8B 68 00           -  lea rcx,[cheatengine-x86_64.exe+7A3820]
"cheatengine-x86_64.exe"+11AC76: 41 B9 00 00 00 00              -  mov r9d,00000000
"cheatengine-x86_64.exe"+11AC7C: 48 BA 01 00 00 00 00 00 00 00  -  mov rdx,0000000000000001
// ---------- REMOVE THIS ----------
"cheatengine-x86_64.exe"+11AC86: E8 65 C5 FE FF                 -  call cheatengine-x86_64.exe+1071F0
// ---------------------------------
"cheatengine-x86_64.exe"+11AC8B: 48 8B 55 F8                    -  mov rdx,[rbp-08]
"cheatengine-x86_64.exe"+11AC8F: 48 8B 92 88 00 00 00           -  mov rdx,[rdx+00000088]
// ---------- REMOVE THIS ----------
"cheatengine-x86_64.exe"+11AC96: 48 89 42 18                    -  mov [rdx+18],rax
// ---------------------------------
"cheatengine-x86_64.exe"+11AC9A: E9 68 01 00 00                 -  jmp cheatengine-x86_64.exe+11AE07
"cheatengine-x86_64.exe"+11AC9F: 48 8D 0D 8A B7 68 00           -  lea rcx,[cheatengine-x86_64.exe+7A6430]
"cheatengine-x86_64.exe"+11ACA6: E8 75 15 F8 FF                 -  call cheatengine-x86_64.exe+9C220
}

_________________
I don't know where I'm going, but I'll figure it out when I get there.


Last edited by ParkourPenguin on Sat Oct 27, 2018 1:59 pm; edited 1 time in total
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites