View previous topic :: View next topic |
Author |
Message |
azamalvi Cheater Reputation: 0
Joined: 16 Aug 2013 Posts: 26
|
Posted: Mon May 16, 2016 12:17 am Post subject: Auto search and then replace |
|
|
I want to know that is this possible to auto search and then replace. My scenario is below.
Suppose I have 2 values
val1 = 123
val2 = 456
and I need to change both values to 789. So currently I am doing it this way that first I scan val1 it returns 10 records then I replace all the 10 records value to 789 and same I do for val2. It makes me boring to do this every time. So I just want that I simply provide an array of val1,val2 or val3 and a final replacing value and it change all the val. This is what I want to achieve.
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4299
|
Posted: Mon May 16, 2016 8:54 am Post subject: |
|
|
You could convert the 4 byte integer to an AoB string and search for it directly using AOBScan. I made a function that will do this:
Code: | function replace(searchV, replaceV)
if type(searchV) ~= "table" then
searchV = {(assert(tonumber(searchV),"Could not convert first argument to number"))}
end
replaceV = math.floor(replaceV)
for i,v in ipairs(searchV) do
v = math.floor(v)
local res = AOBScan(string.format("%02X %02X %02X %02X", v & 0xff, v>>8 & 0xff, v>>16 & 0xff, v>>24 & 0xff), "+W-C", 1, 4)
if res then
for j=0, res.Count-1, 1 do
writeInteger(res[j], replaceV)
end
res.destroy()
end
end
end |
It uses the standard 4-byte aligned writable non-CoW memory scan for a 4-byte integer. Change the flags on the call to AOBScan if you want to.
After you define that function, you can call it like this:
Code: | replace(1234, 5678) -- replaces all occurrences of the value 1234 with 5678
replace({123, 456}, 789) -- replaces all occurrences of the values 123 and 456 with the value 789 |
The MemScan class might be more appropriate for this, but who ever wants to do things the easy way?
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
azamalvi Cheater Reputation: 0
Joined: 16 Aug 2013 Posts: 26
|
Posted: Mon May 16, 2016 9:13 am Post subject: |
|
|
ParkourPenguin it looks that this will done what I want. Only problem is that how can I use this. I first press CTRL+A in the memory browser, then I copy paste your code and then execute it throws error. Could you please tell me how can I pass values to that function?
Btw thanks for your effort
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4299
|
Posted: Mon May 16, 2016 9:20 am Post subject: |
|
|
This is Lua code. I figured you expected that since you made this topic in the Lua forum.
If you want this in an AA script, you can use the {$lua} tag or luacall:
Code: | [ENABLE]
{$lua}
-- run Lua code here
{$asm}
// run asm here
[DISABLE]
luacall(replace(1234,5678)) |
IMO it would be better to put the function declaration in the Lua script window (main CE window -> Table -> Show Cheat Table Lua Script).
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
azamalvi Cheater Reputation: 0
Joined: 16 Aug 2013 Posts: 26
|
Posted: Mon May 16, 2016 9:31 am Post subject: |
|
|
ParkourPenguin , thank you very very much you saved my time. It's time to rock
|
|
Back to top |
|
|
azamalvi Cheater Reputation: 0
Joined: 16 Aug 2013 Posts: 26
|
Posted: Sun May 29, 2016 11:39 pm Post subject: |
|
|
I am facing script issue with my other laptop. Both laptop has different cheat engine version because my first laptop has 4k Resolution so it has special cheat engine provide by Dark Byte. In other laptop the Replace function throw error. I am Attaching a picture.
Description: |
|
Filesize: |
3.96 KB |
Viewed: |
13448 Time(s) |
|
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4299
|
Posted: Mon May 30, 2016 8:48 am Post subject: |
|
|
If I had to guess, that's probably running Lua 5.1 instead of Lua 5.3. Updating CE to the latest version would fix the problem. If you can't update it, then make your own bitwise AND function and right shift function. Use Google if you don't know where to start for the bitwise AND. The right shift is easy; just divide by powers of 2. Alternatively, I'm sure there are other ways of doing this besides the example I showed.
Why does a 4k resolution laptop need special CE support in the first place?
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
azamalvi Cheater Reputation: 0
Joined: 16 Aug 2013 Posts: 26
|
Posted: Tue May 31, 2016 2:39 am Post subject: |
|
|
Because when I open cheat engine in my 4k Resolution then the size is very very small and it's too much difficult to read. The buttons are also not fully labeled so there is a special version for 4k resolution. But it has also bug in that version too.
|
|
Back to top |
|
|
++METHOS I post too much Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Tue May 31, 2016 2:55 am Post subject: |
|
|
Change your resolution while running CE, or, get a secondary, non-4k monitor to run things like CE in. Or wait for CE to support it.
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25295 Location: The netherlands
|
Posted: Tue May 31, 2016 3:16 am Post subject: |
|
|
or get 6.5 or later which has fixed that
_________________
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 |
|
|
++METHOS I post too much Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Tue May 31, 2016 3:24 am Post subject: |
|
|
|
|
Back to top |
|
|
forested Newbie cheater Reputation: 0
Joined: 04 Jul 2015 Posts: 23
|
Posted: Sun Jun 05, 2016 3:00 am Post subject: |
|
|
ParkourPenguin wrote: | You could convert the 4 byte integer to an AoB string and search for it directly using AOBScan. I made a function that will do this:
Code: | function replace(searchV, replaceV)
if type(searchV) ~= "table" then
searchV = {(assert(tonumber(searchV),"Could not convert first argument to number"))}
end
replaceV = math.floor(replaceV)
for i,v in ipairs(searchV) do
v = math.floor(v)
local res = AOBScan(string.format("%02X %02X %02X %02X", v & 0xff, v>>8 & 0xff, v>>16 & 0xff, v>>24 & 0xff), "+W-C", 1, 4)
if res then
for j=0, res.Count-1, 1 do
writeInteger(res[j], replaceV)
end
res.destroy()
end
end
end |
It uses the standard 4-byte aligned writable non-CoW memory scan for a 4-byte integer. Change the flags on the call to AOBScan if you want to.
After you define that function, you can call it like this:
Code: | replace(1234, 5678) -- replaces all occurrences of the value 1234 with 5678
replace({123, 456}, 789) -- replaces all occurrences of the values 123 and 456 with the value 789 |
The MemScan class might be more appropriate for this, but who ever wants to do things the easy way? |
will this work with string to? Example: replace('SBiaPBBPAT', 'AAAAAAAAAAAAA')
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4299
|
Posted: Sun Jun 05, 2016 8:33 am Post subject: |
|
|
No. Just use the memscan class for that:
Code: | local memsc = createMemScan()
memsc.firstScan(soExactValue, vtString, nil, "SBiaPBBPAT", nil, 0, 0x7fffffffffffffff, "+W-C", fsmNotAligned, nil, nil, nil, false, true)
memsc.waitTillDone()
local foundlist = createFoundList(memsc)
foundlist.initialize()
for i=0, foundlist.Count-1 do
writeString(foundlist.Address[i], "AAAAAAAAAAAAA")
end
foundlist.deinitialize()
foundlist.destroy()
memsc.destroy() |
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
|