 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Fri Mar 06, 2020 7:18 am Post subject: |
|
|
| Quote: | | Aylin: @Corroder, the function you provided doesn't want wildcards (in the exchange code) |
That just an example for I am usually used to scan AOB. If need scan and replace AOB contains some wild char, then, of course, we can use other methods, for example as shown by Panraven, DaSpammer, Zanzer scripts, etc. Anyhow, I agree with DaSpammer:
| Quote: |
Anyway we have given you some solutions and ideas, the very same result can be done through many different techinques, it isnt really related to ce functionallity, if you dont like it then change it or they way you are working. |
The other thing is important to me is:
The first, hacks code works then how much progress times spent for those hacks code is the last thing.
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
| Back to top |
|
 |
AylinCE Grandmaster Cheater Supreme
Reputation: 37
Joined: 16 Feb 2017 Posts: 1549
|
Posted: Fri Mar 06, 2020 8:38 am Post subject: |
|
|
Thanks for the example @DaSpamer.
Also, thank you for deciding to help.
Every step; it is an aid, an idea, and a lesson.
Thank you for this test idea.
| Code: | local ts = os.clock();
...
print('it took',os.clock()-ts,'sec'); |
I pushed your code a bit, the results are below.
| Code: | aobswap('02 00 00 00 02 00 00 00 00 00 00 00 ?? ?? ?? ?? ?? 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01','64 00 00 00 64 00 00 00')
Aobs Count: 1418
changed bytes? - true
it took 6.0710000000008 sec |
or
| Code: | aobswap('03 00 00 00 03 00 00 00 00 00 00 00 ?? ?? ?? ?? ?? 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01','64 00 00 00 64 00 00 00')
Aobs Count: 967
changed bytes? - true
it took 5.527 sec |
This code; I think the AobSwap method is the first level increase.
It works fine. Thanks again.
Hopefully, ideas come from other masters on the list.
Comparing together will increase the experience.
------------------------- EDIT :
@Corroder;
The code you share has something similar in the subject title.
I wrote an answer to indicate this.
In addition, this opened topic (Forum); It is only to request more advanced "Search - Change" code samples (if they have time and patience) from the masters.
Although this request seems personal; People will use these codes and will benefit from this code.
So the desire is not personal but global.
Result; Contributing to the code of CE.
I am sorry if I hurt you.
_________________
Last edited by AylinCE on Fri Mar 06, 2020 8:55 am; edited 1 time in total |
|
| Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Fri Mar 06, 2020 8:51 am Post subject: |
|
|
6 seconds is quite reasonable (depends on computer spec), especially when your aob has to be filtered from several (hundreds?) thousands of results because of the single byte led by zeros pattern, which is really the culprit, either get an aob with a bit more 'meat' into it, or limit scan range by using memscan with probably several threads.
Another way to optimize it a bit would be supplying only required bytes
so instead of
| Code: | | '64 00 00 00 64 00 00 00' |
supply
you will save 3 calls to writeBytes per aob result.
another method to optimize would be call writeBytes with chunk(s)
lets say you want to write
| Code: | | 64 00 00 00 64 00 00 00 |
calling
| Code: | | writeBytes(address,{100,0,0,0,100,0,0,0}); or writeBytes(address,100,0,0,0,100,0,0,0); |
would be much better than calling for each byte separately, but once you insert wildcards to replace pattern then you must split it.
| Code: | | 64 00 00 ?? 64 00 00 00 |
it would result in 2 different calls (in this case)
| Code: | writeBytes(address,100,0,0);
writeBytes(address+4,100,0,0,0); |
it might save you some (insignificant) time, but I think it is fine as it is.
_________________
I'm rusty and getting older, help me re-learn lua. |
|
| Back to top |
|
 |
AylinCE Grandmaster Cheater Supreme
Reputation: 37
Joined: 16 Feb 2017 Posts: 1549
|
Posted: Fri Mar 06, 2020 9:47 am Post subject: |
|
|
| DaSpamer wrote: |
it might save you some (insignificant) time, but I think it is fine as it is. |
Yes, I am considering using it as it is.
However, I do not set exchange codes.
I have some functions that delegate this right to the user.
Sample;
| Code: | function CEButton3Click(sender)
UDF1.CEButton3.Caption="Wait";
newvalue = UDF1.CEEdit1.Text
newvalue = tonumber(newvalue)
if not newvalue then return end
newvalue = dwordToByteTable(newvalue)
newvalue = byteTableToAobString(newvalue)
codescan2 = '?? 02 00 00 00 02 00 00 00 00 00 00 00 ?? ?? ?? ?? ?? 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 '
codescan3 = '?? 03 00 00 00 03 00 00 00 00 00 00 00 ?? ?? ?? ?? ?? 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 '
codescan4 = '?? 04 00 00 00 04 00 00 00 00 00 00 00 ?? ?? ?? ?? ?? 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 '
codescan5 = '?? 05 00 00 00 05 00 00 00 00 00 00 00 ?? ?? ?? ?? ?? 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 '
codescan6 = '?? 06 00 00 00 06 00 00 00 00 00 00 00 ?? ?? ?? ?? ?? 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 '
codescan7 = '?? 07 00 00 00 07 00 00 00 00 00 00 00 ?? ?? ?? ?? ?? 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 '
Aobswap(codescan2,('?? %s %s '):format(newvalue, newvalue))
Aobswap(codescan3,('?? %s %s '):format(newvalue, newvalue))
Aobswap(codescan4,('?? %s %s '):format(newvalue, newvalue))
Aobswap(codescan5,('?? %s %s '):format(newvalue, newvalue))
Aobswap(codescan6,('?? %s %s '):format(newvalue, newvalue))
Aobswap(codescan7,('?? %s %s '):format(newvalue, newvalue))
UDF1.CEButton3.Caption="ON";
end |
Here is a test;
| Code: | Aobs Count: 1416
changed bytes2? - true
Aobs Count: 846
changed bytes3? - true
Aobs Count: 154
changed bytes4? - true
Aobs Count: 984
changed bytes5? - true
Aobs Count: 184
changed bytes6? - true
Aobs Count: 967
changed bytes7? - true
Aobs Count: 366
changed bytes8? - true
it took 36.475 sec |
Again Thanks @DaSpamer
_________________
|
|
| Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Fri Mar 06, 2020 10:59 am Post subject: |
|
|
| Aylin wrote: | | DaSpamer wrote: |
it might save you some (insignificant) time, but I think it is fine as it is. |
Yes, I am considering using it as it is.
However, I do not set exchange codes.
I have some functions that delegate this right to the user.
Sample;
| Code: | function CEButton3Click(sender)
UDF1.CEButton3.Caption="Wait";
newvalue = UDF1.CEEdit1.Text
newvalue = tonumber(newvalue)
if not newvalue then return end
newvalue = dwordToByteTable(newvalue)
newvalue = byteTableToAobString(newvalue)
codescan2 = '?? 02 00 00 00 02 00 00 00 00 00 00 00 ?? ?? ?? ?? ?? 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 '
codescan3 = '?? 03 00 00 00 03 00 00 00 00 00 00 00 ?? ?? ?? ?? ?? 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 '
codescan4 = '?? 04 00 00 00 04 00 00 00 00 00 00 00 ?? ?? ?? ?? ?? 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 '
codescan5 = '?? 05 00 00 00 05 00 00 00 00 00 00 00 ?? ?? ?? ?? ?? 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 '
codescan6 = '?? 06 00 00 00 06 00 00 00 00 00 00 00 ?? ?? ?? ?? ?? 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 '
codescan7 = '?? 07 00 00 00 07 00 00 00 00 00 00 00 ?? ?? ?? ?? ?? 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 '
Aobswap(codescan2,('?? %s %s '):format(newvalue, newvalue))
Aobswap(codescan3,('?? %s %s '):format(newvalue, newvalue))
Aobswap(codescan4,('?? %s %s '):format(newvalue, newvalue))
Aobswap(codescan5,('?? %s %s '):format(newvalue, newvalue))
Aobswap(codescan6,('?? %s %s '):format(newvalue, newvalue))
Aobswap(codescan7,('?? %s %s '):format(newvalue, newvalue))
UDF1.CEButton3.Caption="ON";
end |
Here is a test;
| Code: | Aobs Count: 1416
changed bytes2? - true
Aobs Count: 846
changed bytes3? - true
Aobs Count: 154
changed bytes4? - true
Aobs Count: 984
changed bytes5? - true
Aobs Count: 184
changed bytes6? - true
Aobs Count: 967
changed bytes7? - true
Aobs Count: 366
changed bytes8? - true
it took 36.475 sec |
Again Thanks @DaSpamer |
Remove the leading ??, as it penalizes the performance quite much!
Try to place as much as you can static data at the beginning of the aob.
By removing leading ?? (first byte), performance improved by almost 20%
Perhaps threads might help a bit more,
Shoving some random aobscan into thread at 300MB process size yields 0.5-0.6sec reductions or about ~10%, without any flag assigned, with flag set performance increased by another ~20% or ~1.2 second less!
| Code: |
myThreads = myThreads or threadClass(); -- auto created 12 threads earlier..
myTracker = myTracker or threadClass().createThread();
local ts = os.clock();
local taskCount,totalWork = 0,12;
myTracker.addQueue(function(thread,threadid) -- thread class splits work across threads... can accidentally assign the tracking thread a job
print('Thread work');
while taskCount < totalWork do
sleep(100)
end
print('took in total',os.clock()-ts,'secs');
end)
for i=1,totalWork do
myThreads.addQueue(function(thread,threadid)
local ts = os.clock();
aobs = AOBScan("AA BB CC");
if (aobs) then
aobs.destroy();
end
taskCount = taskCount + 1;
print('took',os.clock()-ts,'secs \tthreadid =',threadid);
end);
end
print('Normal work');
local ts = os.clock();
local taskCount,totalWork = 0,12;
for i=1,totalWork do
(function()
local ts = os.clock();
aobs = AOBScan("AA BB CC");
if (aobs) then
aobs.destroy();
end
print('took',os.clock()-ts,'secs');
end)();
end
print('took in total',os.clock()-ts,'secs');
|
yields this
| Code: | Thread work
took 2.5519999999997 secs threadid = 3
took 4.9000000000015 secs threadid = 11
took 4.9020000000019 secs threadid = 5
took 4.9200000000019 secs threadid = 10
took 4.9629999999997 secs threadid = 12
took 4.9629999999997 secs threadid = 4
took 4.9639999999999 secs threadid = 2
took 4.9639999999999 secs threadid = 1
took 5.0610000000015 secs threadid = 9
took 5.0889999999999 secs threadid = 6
took 5.1730000000025 secs threadid = 7
took 5.331000000002 secs threadid = 8
took in total 5.3460000000014 secs
Thread work
took 4.7950000000019 secs threadid = 9
took 4.9180000000015 secs threadid = 5
took 4.9180000000015 secs threadid = 7
took 4.9390000000021 secs threadid = 6
took 4.974000000002 secs threadid = 10
took 4.9830000000002 secs threadid = 8
took 4.9840000000004 secs threadid = 11
took 4.9860000000008 secs threadid = 12
took 4.987000000001 secs threadid = 1
took 4.9940000000024 secs threadid = 2
took 4.9960000000028 secs threadid = 3
took 5.1680000000015 secs threadid = 4
took in total 5.2479999999996 secs
Thread work
took 4.9310000000005 secs threadid = 11
took 4.9360000000015 secs threadid = 9
took 5.010000000002 secs threadid = 1
took 5.010000000002 secs threadid = 6
took 5.0280000000021 secs threadid = 3
took 5.1700000000019 secs threadid = 8
took 5.1920000000027 secs threadid = 10
took 5.2010000000009 secs threadid = 2
took 5.2020000000011 secs threadid = 12
took 5.2020000000011 secs threadid = 5
took 5.2330000000002 secs threadid = 4
took 5.4459999999999 secs threadid = 7
took in total 5.4470000000001 secs
==========================
==========================
==========================
Normal work
took 0.48800000000119 secs
took 0.48799999999756 secs
took 0.48699999999735 secs
took 0.48400000000038 secs
took 0.48800000000119 secs
took 0.48500000000058 secs
took 0.48600000000079 secs
took 0.48500000000058 secs
took 0.48599999999715 secs
took 0.49499999999898 secs
took 0.48799999999756 secs
took 0.4900000000016 secs
took in total 5.9700000000012 secs
Normal work
took 0.48100000000341 secs
took 0.48300000000017 secs
took 0.50300000000061 secs
took 0.47999999999956 secs
took 0.48699999999735 secs
took 0.48999999999796 secs
took 0.48600000000079 secs
took 0.48800000000119 secs
took 0.48899999999776 secs
took 0.49199999999837 secs
took 0.48600000000079 secs
took 0.48400000000038 secs
took in total 5.9390000000021 secs
Normal work
took 0.48800000000119 secs
took 0.48700000000099 secs
took 0.47599999999875 secs
took 0.48099999999977 secs
took 0.48700000000099 secs
took 0.48899999999776 secs
took 0.47899999999936 secs
took 0.53399999999965 secs
took 0.49099999999817 secs
took 0.4890000000014 secs
took 0.48099999999977 secs
took 0.4800000000032 secs
took in total 5.9249999999993 secs |
It wouldn't really speed things up as long as we are using aobscan, but if you really 'maximize' potential then perhaps a thread might help your case.
Edit:
Posted my threads class source;
https://forum.cheatengine.org/viewtopic.php?p=5758759#5758759
_________________
I'm rusty and getting older, help me re-learn lua. |
|
| Back to top |
|
 |
|
|
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
|
|