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 


AOB code: how bytes replaced by Text?
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
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1246

PostPosted: Sat Mar 17, 2018 6:16 pm    Post subject: AOB code: how bytes replaced by Text? Reply with quote

I have never worked with this coding.
I know there are very lacking in content.
For example: Where do I write the AOB code and
How do I change with the number entered in the EDIT text?

Code:
function CEEdit1Change(sender)
local s=sender.Text
if s=='' then return end
local b=tonumber(sender.Text)
if b~=nil then
if b>350 then
messageDialog('max 350', mtWarning, mbOK)
UDF1_CEEdit1.Text= "";
end
else
UDF1_CEEdit1.Text= "";
end
end
--------------------------------------------------------------------------------
function CEButton1Click(sender)
UDF1_CEEdit1.Text= "";
end


Here's the sample code:

Code:
LuaCall(Aobswap("40 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF FF","40 5E 01 00 00 5E 01")) -- or UDF1_CEEdit1.Text= "250";


'Edit Text' to see the AOB code, and
How can the exchange of bytes?

I share a CT specimen.
https://www.dropbox.com/s/ixkhh06i1hnya8j/Edit%20Text%20Replace%20Aobs.CT?dl=0

Thanks in advance for help with a reasonable example.

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past


Last edited by AylinCE on Tue Feb 26, 2019 8:32 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sat Mar 17, 2018 8:41 pm    Post subject: Reply with quote

Quote:
For example: Where do I write the AOB code and
How do I change with the number entered in the EDIT text?


Where is you WRITE AOB code ? on CEEdit1 ? or
Is it you mean convert input TEXT on CEEdit1 to number and then to AOB ?

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1246

PostPosted: Sun Mar 18, 2018 11:14 am    Post subject: Reply with quote

Maybe something like this:

Code:
function CEButton1Click(sender)
UDF1.CEButton1.Caption = ("10%")
processMessages()
local hex1 = control_getCaption(UDF1_CEEdit1)
local hex2 = kk(hex1)
--spaces hex---
local hex = getBreak(" %02X %02X 00 00 ", unpack(hex2))
UDF1_AoB2.Text = ("40"..hex..hex)
hex4=pp(UDF1_AoB2)
hex3=pp(UDF1_AoB1)
codescan=("40 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF FF")
search= (hex3..codescan)
change=(hex4)
SearchChange(search,change)
if(ERROR==1) then
UDF1.CEButton1.Caption = ("ON")
UDF1_AoB1.Text = UDF1_AoB2.Text
beep()
else
UDF1.CEButton1.Caption = ("ERROR")
UDF1_AoB1.Text=("01 00 00 00 01 00") -- 5E 01 00 00 5E 01 ..text=350
end
end


but I still can not figure out how to change it with byte text.
As you do research, a new code is added and
I can not combine these codes and get results. Rolling Eyes

search the main code:
Code:
codescan=("40 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF FF")


and replace this code with the Edit text:
Code:
local hex1 = control_getCaption(UDF1_CEEdit1)


and do this change with Button click:
Code:
CEButton1Click


I need such a result. Rolling Eyes

If there is still an idea thank you in advance

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Sun Mar 18, 2018 2:56 pm    Post subject: Reply with quote

If you're trying to get an AOB string from the user and write that into memory then this may be helpful
Code:
function aobStringToByteTable(str)
  if str:find('[?*]') then
    local name = debug.getinfo(1, 'n').name
    error(name .. ' does not handle wildcards!', 2)
  end
  local t = {}
  for byte in str:gmatch('%x%x?%s*') do
    t[#t+1] = tonumber(byte,16)
  end
  return t
end

-- example
writeBytes(someAddress, aobStringToByteTable('Fe Ed BeeF'))


if it's just a number like 127 then use tonumber(thestring) and then write* (integer/float/double etc.), if it's supposed to be hex then add ,16 so it's converted as base 16 aka hex.

If it's a string like "my new name" then you can pass it to writeString but that doesn't seem to 0 terminate, if it's a wide string pass true after the string. I feel like a way to write a zero terminated string probably exists but I don't work with strings often enough to know, so I just created a simple function that does it using stringToByteTable and writeBytes.
Code:
writeString(address, 'this is a test', isWide) -- does not 0 terminate

-- zero terminates (I feel like there should already be a way but... maybe not)
-- btw, some strings are prefixed with the size or have a size stored next to a pointer
function writeStringZ(address, string, wide)
  local bytes = (wide and wideStringToByteTable or stringToByteTable)(string)
  bytes[#bytes+1] = 0
  if wide then bytes[#bytes+1] = 0 end
  writeBytes(address, bytes)
end

writeStringZ(address, 'good?')


edit: presumably if the functions you needed were already globally defined you could call them inside luacall/aobswap but I don't use either of those so I'm not 100% certain.

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1246

PostPosted: Sun Mar 18, 2018 3:43 pm    Post subject: Reply with quote

I may have put the wrong title.
My English; Up to the limit of Google Translate. Sad

I'm just going to write the script I want to do.
The scenarios I gave above, I see you do it,
so I gave those examples.

I want to make is this:

Type the desired digit in UDF1.CEEdit1. (For example: 250)

After:
Provide the exchange with UDF1.CEButton1Click.

Example code to call:
40 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF FF

Partitions to change to 250: (UDF1.CEEdit1.Text= ""Wink

01 00 00 00 01 00 00 00 = FA 00 00 00 FA 00 00 00 = 1 = 250 .. 1 = 250

With a ready CEButtonClick:

LuaCall(Aobswap("40 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF FF","40 FA 00 00 00 FA 00"))
I was doing!

But I want to get the user selects the figures to be changed.
Can write and change a number between 1-350.

I hope I can tell you now. Rolling Eyes

The following codes are for this operation.
But how have I failed to blend.

Code:
-----------------------------------------------------------
function CEButton1Click(sender)
UDF1.CEButton1.Caption = ("10%")
processMessages()
local hex1 = control_getCaption(UDF1_CEEdit1)
local hex2 = kk(hex1)
--spaces hex---
local hex = getBreak(" %02X %02X 00 00 ", unpack(hex2))
UDF1_AoB2.Text = ("40"..hex..hex)
hex4=pp(UDF1_AoB2)
hex3=pp(UDF1_AoB1)
codescan=("40 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF FF")
search= (hex3..codescan)
change=(hex4)
SearchChange(search,change)
if(ERROR==1) then
UDF1.CEButton1.Caption = ("ON")
UDF1_AoB1.Text = UDF1_AoB2.Text
beep()
else
UDF1.CEButton1.Caption = ("ERROR")
UDF1_AoB1.Text=("01 00 00 00 01 00") -- 5E 01 00 00 5E 01 ..text=350
end
end
--------------------------------------------------------------------
function CEEdit1Change(sender)
local s=sender.Text
if s=='' then return end
local b=tonumber(sender.Text)
if b~=nil then
if b>350 then
messageDialog('max 350', mtWarning, mbOK)
UDF1_CEEdit1.Text= "";
end
else
UDF1_CEEdit1.Text= "";
end
end
--------------------------------------------------------------------------------
function CEButton1Click(sender)
UDF1_CEEdit1.Text= "";
end


And it must still be hope. Smile

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Sun Mar 18, 2018 4:14 pm    Post subject: Reply with quote

something like

Code:
-----------------------------------------------------------
function byteTableToAobString(t)
  for k,v in ipairs(t) do
    t[k] = ('%02X'):format(v)
  end
  return table.concat(t, ' ')
end

function CEButton1Click(sender)
  --commenting out anything not directly related or not provided by CE since I don't know how they work
  --UDF1.CEButton1.Caption = ("10%")
  --processMessages()
  --local hex1 = control_getCaption(UDF1_CEEdit1)
  --local hex2 = kk(hex1)
  --spaces hex---
  --local hex = getBreak(" %02X %02X 00 00 ", unpack(hex2))
  --UDF1_AoB2.Text = ("40"..hex..hex)
  --hex4=pp(UDF1_AoB2)
  --hex3=pp(UDF1_AoB1)
  codescan = '40 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF FF'
  newvalue = UDF1.CEEdit1.Text
  newvalue = tonumber(newvalue)
  if not newvalue then return end -- if not a number we're done
  newvalue = dwordToByteTable(newvalue) -- alternatively qwordToByteTable(newvalue << 32 | newvalue) and don't double in AOB
  newvalue = byteTableToAobString(newvalue)

  Aobswap(codescan, ('40 %s %s '):format(newvalue, newvalue)) -- replace 40 with wildcard if supported
  -- alternatively aobscan for address, writeInteger(address+1, tonumber(UDF1.CEEdit1.Text)) and writeInteger(address+5, tonumber...)

  --search = (hex3..codescan)
  --change=(hex4)
  --[[
  SearchChange(search,change)
  if(ERROR==1) then
    UDF1.CEButton1.Caption = ("ON")
    UDF1_AoB1.Text = UDF1_AoB2.Text
    beep()
  else
    UDF1.CEButton1.Caption = ("ERROR")
    UDF1_AoB1.Text=("01 00 00 00 01 00") -- 5E 01 00 00 5E 01 ..text=350
  end
  ]]
end
--------------------------------------------------------------------
function CEEdit1Change(sender)
  local s=sender.Text
  if s=='' then return end
  local b=tonumber(sender.Text)
  if b~=nil then
    if b>350 then
      messageDialog('max 350', mtWarning, mbOK)
      UDF1_CEEdit1.Text= "";
    -- elseif b< -- min?
    end
  else -- if not a valid number set to empty string
    UDF1_CEEdit1.Text= "";
  end
end

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sun Mar 18, 2018 5:44 pm    Post subject: Reply with quote

If I am not misunderstood :

Code:
function byte2aob(b) return type(b)=='number' and b<256 and b>=0 and string.format('%02X',b) or '??' end
function aob2byte(a) a = tonumber(a,16) return type(a)=='number' and a <256 and a>=0 and a or -1 end
function imap(t,f) local s={} for i=1,#t do s[i]=f(t[i]) end return s end
function n2bt(n,t) t=type(t)=='string' and t or 'dword'  return rawget(_G,t..'ToByteTable')(n) end
function t2aob(t,sep) return table.concat(imap(t,byte2aob),type(sep)=='string' and sep or ' ') end
function n2aob(n,t) return t2aob(n2bt(n,t)) end

function CEEdit1Change(sender)
local s=sender.Text
if s=='' then return end
local b=tonumber(sender.Text)
if b~=nil then
if b>350 then
messageDialog('max 350', mtWarning, mbOK)
UDF1_CEEdit1.Text= "";
end
else
UDF1_CEEdit1.Text= "";
end
end

-- test
print(n2aob(350))  -- 5E 01 00 00
--------------------------------------------------------------------------------
function CEButton1Click(sender)
hex = n2aob(b)  --- tonumber(UDF1.CEEdit1.Text)
LuaCall(Aobswap("40 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF FF",'"'..hex..'"'))
-- bla bla bla
UDF1_CEEdit1.Text= "";
end
form_show(UDF1)



With freeER function :

Code:
function byteTableToAobString(t)
  for k,v in ipairs(t) do
    t[k] = ('%02X'):format(v)
  end
  return table.concat(t, ' ')
end

--- test
x = dwordToByteTable(350)    ----- x = tonumber(UDF1.CEEdit1.Text)
print(byteTableToAobString(x))   ---- result : 5E 01 00 00

function CEButton1Click(sender)
hex =  tonumber(UDF1.CEEdit1.Text)
hex =  dwordToByteTable(hex)
hex = byteTableToAobString(hex)
LuaCall(Aobswap("40 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF FF",'"'..hex..'"'))
-- bla bla bla
UDF1_CEEdit1.Text= "";
end
form_show(UDF1)


Seem like UDF1.CEEdit1.text has prevent to accept entry type : minus and non number texts...

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1246

PostPosted: Sun Mar 18, 2018 7:33 pm    Post subject: Reply with quote

I tried all the recommended combinations.
FreeER's proposal worked.

@FreeER Code: (and Thanks)

Code:
-----------------------------------------------------------
function byteTableToAobString(t)
  for k,v in ipairs(t) do
    t[k] = ('%02X'):format(v)
  end
  return table.concat(t, ' ')
end

function CEButton1Click(sender)
  codescan = '40 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF FF'
  newvalue = UDF1.CEEdit1.Text
  newvalue = tonumber(newvalue)
  if not newvalue then return end -- if not a number we're done
  newvalue = dwordToByteTable(newvalue) -- alternatively qwordToByteTable(newvalue << 32 | newvalue) and don't double in AOB
  newvalue = byteTableToAobString(newvalue)

  Aobswap(codescan, ('40 %s %s '):format(newvalue, newvalue)) -- replace 40 with wildcard if supported

end
--------------------------------------------------------------------
function CEEdit1Change(sender)
  local s=sender.Text
  if s=='' then return end
  local b=tonumber(sender.Text)
  if b~=nil then
    if b>350 then
      messageDialog('max 350', mtWarning, mbOK)
      UDF1_CEEdit1.Text= "";
showMessage('DONE!')
    end
  else -- if not a valid number set to empty string
    UDF1_CEEdit1.Text= "";
showMessage('ERROR!')
end
end
form_show(UDF1)



This is for only 1 code.
I would like a recommendation for other codes.
For example, there is a multiple encoding:

Code:
DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01


Code:
DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01


Code:
DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01


Code:
DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01


Code:
DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01


Code:
DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01



Code:
codescan = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
codescan = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
codescan = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
codescan = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
codescan = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
codescan = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'


and:

Code:
Aobswap(codescan, ('DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00  %s %s '):format(newvalue, newvalue))


Multi-coding did not work.
How can I provide this? Rolling Eyes

it did not work alone.
it only works with the first code. (codescan = '40 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF FF')

Code:
function CEButton1Click(sender)
--  codescan = '40 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF FF'
codescan = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
--codescan = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
--codescan = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
--codescan = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
--codescan = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
--codescan = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
  newvalue = UDF1.CEEdit1.Text
  newvalue = tonumber(newvalue)
  if not newvalue then return end -- if not a number we're done
  newvalue = dwordToByteTable(newvalue) -- alternatively qwordToByteTable(newvalue << 32 | newvalue) and don't double in AOB
  newvalue = byteTableToAobString(newvalue)

--  Aobswap(codescan, ('40 %s %s '):format(newvalue, newvalue)) -- replace 40 with wildcard if supported
Aobswap(codescan, ('DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00  %s %s '):format(newvalue, newvalue))
end

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Sun Mar 18, 2018 8:12 pm    Post subject: Reply with quote

If you want to replace all of them with the same value then use a wildcard for what changes, otherwise my suggestion is go to whoever wrote the AOBSwap function/plugin and ask them to write a version that accepts some kind of wildcard so that this would work

Code:
local sharedAob = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00'
local codescan = sharedAob .. '04 00 00 00 04 00 00 00'
Aobswap(codescan, ('%s %s %s '):format(sharedAob, newvalue, newvalue))


or more properly
Code:
local sharedAob = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00'
local codescan = sharedAob .. '04 00 00 00 04 00 00 00'
local replaceAob = sharedAob:gsub('%x', '?') -- all wildcards, just for positioning
Aobswap(codescan, ('%s %s %s '):format(replaceAob, newvalue, newvalue))

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1246

PostPosted: Sun Mar 18, 2018 8:55 pm    Post subject: Reply with quote

FreeER wrote:
If you want to replace all of them with the same value then use a wildcard for what changes, otherwise my suggestion is go to whoever wrote the AOBSwap function/plugin and ask them to write a version that accepts some kind of wildcard so that this would work

Code:
local sharedAob = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00'
local codescan = sharedAob .. '04 00 00 00 04 00 00 00'
Aobswap(codescan, ('%s %s %s '):format(sharedAob, newvalue, newvalue))


or more properly
Code:
local sharedAob = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00'
local codescan = sharedAob .. '04 00 00 00 04 00 00 00'
local replaceAob = sharedAob:gsub('%x', '?') -- all wildcards, just for positioning
Aobswap(codescan, ('%s %s %s '):format(replaceAob, newvalue, newvalue))


I apologize.
but it did not work.
The first encoding worked well.
needed to pass a slightly different size for multiple encoding. Rolling Eyes

This scenario is working:
Code:
function CEButton1Click(sender)
codescan = '40 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF FF'
  newvalue = UDF1.CEEdit1.Text
  newvalue = tonumber(newvalue)
  if not newvalue then return end -- if not a number we're done
  newvalue = dwordToByteTable(newvalue) -- alternatively qwordToByteTable(newvalue << 32 | newvalue) and don't double in AOB
  newvalue = byteTableToAobString(newvalue)

Aobswap(codescan, ('40 %s %s '):format(newvalue, newvalue)) -- replace 40 with wildcard if supported


but this does not work:

Code:
function CEButton1Click(sender)
codescan = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
  newvalue = UDF1.CEEdit1.Text
  newvalue = tonumber(newvalue)
  if not newvalue then return end -- if not a number we're done
  newvalue = dwordToByteTable(newvalue) -- alternatively qwordToByteTable(newvalue << 32 | newvalue) and don't double in AOB
  newvalue = byteTableToAobString(newvalue)

Aobswap(codescan, ('DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 %s %s '):format(newvalue, newvalue)) -- replace 40 with wildcard if supported
UDF1.CETimer1.enabled = true
end


If the second scenario worked,
Maybe I could move other codes with onTimer!

Code:
function CETimer1Timer(sender)
codescan = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
  newvalue = UDF1.CEEdit1.Text
  newvalue = tonumber(newvalue)
  if not newvalue then return end -- if not a number we're done
  newvalue = dwordToByteTable(newvalue) -- alternatively qwordToByteTable(newvalue << 32 | newvalue) and don't double in AOB
  newvalue = byteTableToAobString(newvalue)

Aobswap(codescan, ('DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 %s %s '):format(newvalue, newvalue)) -- replace 40 with wildcard if supported
UDF1.CETimer1.enabled = false
UDF1.CETimer2.enabled = true
end


it could be an idea like Rolling Eyes

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sun Mar 18, 2018 9:49 pm    Post subject: Reply with quote

Why not use :

Code:
codescan1
codescan2
etc... ??


Code:
function CEButton1Click(sender)
  newvalue = UDF1.CEEdit1.Text
  newvalue = tonumber(newvalue)
  if not newvalue then return end -- if not a number we're done
  newvalue = dwordToByteTable(newvalue) -- alternatively qwordToByteTable(newvalue << 32 | newvalue) and don't double in AOB
  newvalue = byteTableToAobString(newvalue)

codescan1 = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
codescan2 = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
codescan3 = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
codescan4 = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
codescan5 = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
codescan6 = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'

Aobswap(codescan1,('DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 %s %s '):format(newvalue, newvalue))
Aobswap(codescan2,('DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 %s %s '):format(newvalue, newvalue))
Aobswap(codescan3,('DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 %s %s '):format(newvalue, newvalue))
Aobswap(codescan4,('DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 %s %s '):format(newvalue, newvalue))
Aobswap(codescan5,('DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 %s %s '):format(newvalue, newvalue))
Aobswap(codescan6,('DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 %s %s '):format(newvalue, newvalue))
end

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1246

PostPosted: Mon Mar 19, 2018 4:25 am    Post subject: Reply with quote

Corroder wrote:
Why not use :

Code:
codescan1
codescan2
etc... ??


Code:
function CEButton1Click(sender)
  newvalue = UDF1.CEEdit1.Text
  newvalue = tonumber(newvalue)
  if not newvalue then return end -- if not a number we're done
  newvalue = dwordToByteTable(newvalue) -- alternatively qwordToByteTable(newvalue << 32 | newvalue) and don't double in AOB
  newvalue = byteTableToAobString(newvalue)

codescan1 = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
codescan2 = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
codescan3 = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
codescan4 = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
codescan5 = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
codescan6 = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'

Aobswap(codescan1,('DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 %s %s '):format(newvalue, newvalue))
Aobswap(codescan2,('DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 %s %s '):format(newvalue, newvalue))
Aobswap(codescan3,('DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 %s %s '):format(newvalue, newvalue))
Aobswap(codescan4,('DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 %s %s '):format(newvalue, newvalue))
Aobswap(codescan5,('DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 %s %s '):format(newvalue, newvalue))
Aobswap(codescan6,('DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 %s %s '):format(newvalue, newvalue))
end


Thanks @Corroder
But it did not work. Rolling Eyes

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Mon Mar 19, 2018 5:23 am    Post subject: Reply with quote

Then what you need to do is :

1. Test your codescan if exist or not in game.
i.e :
Code:

--scan manual AOB :
'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
-- result found or not


2. If found then the problem is about concatenating replace code
i.e :

Code:
byteTableToAobString(350) ---> result = 5E 01 00 00
-- follow by your code then ...
codescan = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
codereplace = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 '..result..' 00 00 00 00 00 ?? ?? ?? ?? ?? ?? 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01'
LuaCall(Aobswap(codescan,codereplace))
-- and so on with other codes....


By my side, more like 'tradional way' to scan and replace AOB code,example :

Code:
function dohackClick(sender)
s = AOBScan("66 97 c2 01 24 01", "+W*X+C")    --- #1 AOB
if (s) then
lngt = s.getCount()
for x=0, lngt-1, 1 do
writeBytes(s[x], 0x66, 0x97, 0xc2, 0x01, 0x24, 0x00)
end
print('Good...')
s.Destroy()
s = nil
else
print('Ooops...fail')
end
s = AOBScan("d0 66 d4 3f 24 01 d1 11 0b 00 00 24 75", "+W*X+C")    --- #2 AOB
if (s) then
lngt = s.getCount()
for x=0, lngt-1, 1 do
writeBytes(s[x], 0xd0, 0x66, 0xd4, 0x3f, 0x24, 0x00, 0xd1, 0x11, 0x0b, 0x00, 0x00, 0x24c, 0x75)
end
print('Good...')
s.Destroy()
s = nil
else
print('Ooops...fail')
end
end


Btw, it's your choice....

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1246

PostPosted: Mon Mar 19, 2018 9:36 am    Post subject: Reply with quote

Corroder wrote:
Then what you need to do is :

1. Test your codescan if exist or not in game.
i.e :
Code:

--scan manual AOB :
'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
-- result found or not


2. If found then the problem is about concatenating replace code
i.e :

Code:
byteTableToAobString(350) ---> result = 5E 01 00 00
-- follow by your code then ...
codescan = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
codereplace = 'DC ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 '..result..' 00 00 00 00 00 ?? ?? ?? ?? ?? ?? 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01'
LuaCall(Aobswap(codescan,codereplace))
-- and so on with other codes....


By my side, more like 'tradional way' to scan and replace AOB code,example :

Code:
function dohackClick(sender)
s = AOBScan("66 97 c2 01 24 01", "+W*X+C")    --- #1 AOB
if (s) then
lngt = s.getCount()
for x=0, lngt-1, 1 do
writeBytes(s[x], 0x66, 0x97, 0xc2, 0x01, 0x24, 0x00)
end
print('Good...')
s.Destroy()
s = nil
else
print('Ooops...fail')
end
s = AOBScan("d0 66 d4 3f 24 01 d1 11 0b 00 00 24 75", "+W*X+C")    --- #2 AOB
if (s) then
lngt = s.getCount()
for x=0, lngt-1, 1 do
writeBytes(s[x], 0xd0, 0x66, 0xd4, 0x3f, 0x24, 0x00, 0xd1, 0x11, 0x0b, 0x00, 0x00, 0x24c, 0x75)
end
print('Good...')
s.Destroy()
s = nil
else
print('Ooops...fail')
end
end


Btw, it's your choice....


@FreeER and @Corroder Sorry! Sad
The error is in my code.
I found the code again and tried it, it worked.
Code:
DC ?? = 48 ?? ??

I apologize again for this problem



Code:
codescan1 = '48 ?? ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
codescan2 = '48 ?? ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
codescan3 = '48 ?? ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
codescan4 = '48 ?? ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
codescan5 = '48 ?? ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'
codescan6 = '48 ?? ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 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 01'

Aobswap(codescan1,('48 ?? ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 %s %s '):format(newvalue, newvalue))
UDF1.CEButton1.Caption="15%";
Aobswap(codescan2,('48 ?? ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 %s %s '):format(newvalue, newvalue))
UDF1.CEButton1.Caption="35%";
Aobswap(codescan3,('48 ?? ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 %s %s '):format(newvalue, newvalue))
UDF1.CEButton1.Caption="55%";
Aobswap(codescan4,('48 ?? ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 %s %s '):format(newvalue, newvalue))
UDF1.CEButton1.Caption="75%";
Aobswap(codescan5,('48 ?? ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 %s %s '):format(newvalue, newvalue))
UDF1.CEButton1.Caption="95%";
Aobswap(codescan6,('48 ?? ?? ?? ?? 00 00 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 00 %s %s '):format(newvalue, newvalue))
UDF1.CEButton1.Caption="ON";
showMessage('DONE!')
end


and thanks.
This solution; To save me from a very Button and scenarios. Wink

Edit:
One more request:
How can this scenario work with Double?

Code:
function CEButton1Click(sender)
  newvalue = UDF1.CEEdit1.Text
  newvalue = tonumber(newvalue)
  if not newvalue then return end -- if not a number we're done
  newvalue = dwordToByteTable(newvalue) -- alternatively qwordToByteTable(newvalue << 32 | newvalue) and don't double in AOB
  newvalue = byteTableToAobString(newvalue)

codescan1 = '01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ?? ?? ?? ?? ?? ?? 00 00 00 00 00 00 00 ?? ?? 40'

-- Replace = 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ?? ?? ?? ?? ?? ?? 00 00 00 00 00 00 00 40 8F 40 = Byte/Text: 1000

Aobswap(codescan1,('01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ?? ?? ?? ?? ?? ?? 00 00 00 00 00 00 00 %s %s '):format(newvalue, newvalue))

UDF1.CEButton1.Caption="ON";
showMessage('DONE!')
end


Rolling Eyes Rolling Eyes Rolling Eyes

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Mon Mar 19, 2018 1:07 pm    Post subject: This post has 1 review(s) Reply with quote

use doubleToByteTable and writeDouble Smile
_________________
https://github.com/FreeER/ has a few CE related repos
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