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 


Stop AOBScan after first result is found

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Kamd
Cheater
Reputation: 1

Joined: 02 May 2018
Posts: 28

PostPosted: Thu Feb 21, 2019 7:59 pm    Post subject: Stop AOBScan after first result is found Reply with quote

Hi, I am using a unique AOB to locate a value in memory.
On the CE GUI I see that it tells me "Found 1 result" before the scanning progress is completely finished.

Is there a way to terminate/stop AOBScan in Lua after the first result is found, to make it complete faster?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Fri Feb 22, 2019 12:37 am    Post subject: Reply with quote

Lua AOBScan is designed to find ALL
If you don't want that use the Memscan class instead and set OnlyOneResult to true
or use AutoAssembler with registerSymbol instead and afterwards use getAddress

_________________
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
Kamd
Cheater
Reputation: 1

Joined: 02 May 2018
Posts: 28

PostPosted: Mon Apr 29, 2019 5:01 am    Post subject: Reply with quote

Sorry for really late reply.

I have tried using MemScan and ms.OnlyOneResult = true with returning ms.getOnlyResult()

Code:

function aobScanUnique(aob)

    local ms = createMemScan()
    ms.OnlyOneResult = true

    ms.firstScan(
        soExactValue,
        vtByteArray,
        rtRounded,
        aob,
        "",
        0,
        0xffffffffffffffff,
        "",
        fsmNotAligned,
        "",
        true,
        false,
        false,
        false
    )

    ms.waitTillDone()

    return ms.getOnlyResult()

end


This seems to work fine, though it is actually slower than regular AOBScan function, so I must be doing something wrong?

My speed tests, with same game and AOB, around of time:
AOBScan: 986ms - 1027ms
MemScan: 1500ms - 1532ms

My whole purpose is to try make AOB scan as fast as possible for unique AOB scans (where there is only 1 result) - I think I'm doing something wrong
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Mon Apr 29, 2019 4:03 pm    Post subject: Reply with quote

maybe don't create and free the memscan but reuse it

besides that it's the same code that aobscan uses

_________________
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
Kamd
Cheater
Reputation: 1

Joined: 02 May 2018
Posts: 28

PostPosted: Mon Apr 29, 2019 10:53 pm    Post subject: Reply with quote

Dark Byte wrote:
besides that it's the same code that aobscan uses


Really strange then. Is it possible in future CE version to give more optional parameters to AOBScan (e.g. onlyOneResult), so I don't have to use MemScan.


I actually see that AOBScan uses way more CPU than MemScan:
AOBScan: 32%-42%-49%
MemScan: 10%-11% [gradual increase: 4%-9%-11%]

So I assume MemScan is being slower largely due to not utilizing as much CPU. Is this a bug, intentional, or anyway to make it faster/use more CPU (assuming you couldn't just directly add an onlyOneResult param to regular AOBScan function)?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Mon Apr 29, 2019 11:24 pm    Post subject: Reply with quote

Do you have kernelmode memory scanning enabled? If so, limit to 7fffffffffffffff instead

This is the lua aobscan code:
https://github.com/cheat-engine/cheat-engine/blob/741e3009e36baf1575fd48e73da1814d09fdcadf/Cheat%20Engine/simpleaobscanner.pas#L23

as you see it just uses a memscan object

But yes, only one result limits the scan to only one thread as otherwise you may get a random result if there are more results

you can also use autoassembler in lua
Code:

autoAssemble([[
aobscan(xxx,xx xx xx xx)
registersymbol(xxx)
]]
)

address=getAddressSafe('xxx')

Of course, will be just as fast as it's the same method using onlyone


Anyhow, you do know that you can have multiple memscans going at the same time ? so if you have more than one, you can let the other cpu's scan at the same time. You don't have to wait till the previous one is done

_________________
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
Kamd
Cheater
Reputation: 1

Joined: 02 May 2018
Posts: 28

PostPosted: Wed May 01, 2019 7:59 pm    Post subject: Reply with quote

Dark Byte wrote:
you can also use autoassembler in lua
Code:

autoAssemble([[
aobscan(xxx,xx xx xx xx)
registersymbol(xxx)
]]
)

address=getAddressSafe('xxx')

Of course, will be just as fast as it's the same method using onlyone


Anyhow, you do know that you can have multiple memscans going at the same time ? so if you have more than one, you can let the other cpu's scan at the same time. You don't have to wait till the previous one is done


Will autoAssemble only return 1 result/faster than lua AOBScan?
Otherwise maybe I will have to look into multiple memscans, but I don't know how to do it efficiently and so it will be faster than regular AOBScan
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Wed May 01, 2019 9:08 pm    Post subject: Reply with quote

autoAssemble will be exactly as fast lua AOBScan
But if you havbe multiple aobscans in the script e.g
Code:

aobscan(s1,xx xx xx xx xx)
aobscan(s2,xx xx xx xx xx)
aobscan(s3,xx xx xx xx xx)


it will group them into one scan that returns 3 results, or split them up into several different scans, up to the maximum number of CPU's you have

_________________
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: 4706

PostPosted: Wed May 01, 2019 9:24 pm    Post subject: Reply with quote

I forget whether or not I ever tested this, but you should be able to do that from Lua by using the vartype vtByteArrays (enum value = 15) and a correctly formatted search string (I think "(aob1)(aob2)...").
_________________
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
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
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