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 


Help with writing Array of Bytes using editbox

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

Joined: 16 Apr 2010
Posts: 96

PostPosted: Tue Jun 20, 2017 1:36 pm    Post subject: Help with writing Array of Bytes using editbox Reply with quote

Hi, I have problem with editbox, hope someone can help me out as im not good with lua.

so i wrote my own interface using the form editor.
I added a button and editbox and connected the button to editbox
Been using that method for long time, that's easy, but here's the problem.

I have address "_myaddress+100" and it's shown as "array of bytes" in cheat table and has length of 132 bytes.

Usually i just do this:

Code:
function CEButton53Click(sender)
writeBytes('[_myaddress]+68', getProperty(UDF1_CEEdit53,'Text'))
end


or

Code:
function CEButton53Click(sender)
writeInteger('[_myaddress]+68', getProperty(UDF1_CEEdit53,'Text'))
end


But if i use writeBytes, it only writes the 1st byte. I need it to write entire array of bytes which is 132 bytes long.
How can i do that?

I tried "writeString" but it doesn't work as there are some weird symbols ..etc and to be honest i don't want to use string.

I tried using string, but problem is that i have to convert string into numbers and then write it as hex, but that's a lot of work and i would not know how to do that, so if anyone could show me how i can write "array of bytes" in lua, that would be nice.

and i'm talking about reading the array of bytes from editbox and then writing it, it's not a fixed thing.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 372

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

PostPosted: Tue Jun 20, 2017 2:15 pm    Post subject: Reply with quote

you need to parse the input and convert it to a table of bytes

there is no built in function that converts the user input to a bytetable so you have to do this from scratch

alternatively, you could use a memory record of the array of byte type, and then assign the value property the input string

(letting the user input a 132 byte long string is generally seen as not user friendly)

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

Joined: 16 Apr 2010
Posts: 96

PostPosted: Tue Jun 20, 2017 2:34 pm    Post subject: Reply with quote

Dark Byte wrote:
you need to parse the input and convert it to a table of bytes

there is no built in function that converts the user input to a bytetable so you have to do this from scratch

alternatively, you could use a memory record of the array of byte type, and then assign the value property the input string

(letting the user input a 132 byte long string is generally seen as not user friendly)


thanks for quick reply, but this is very confusing to me. can you give me some examples pls?

It doesn't matter how i get it, i just need a method to write a 132 array of bytes using the editbox.

so perhaps there's a way to increase the writeInteger to 132 bytes?
or is there something like "writeAoB" instead?

my friend wrote this, but it doesn't really work:

Code:

-- function CEButton54Click(sender)
--  print('\n\n-------')
--  local inputText = getProperty(UDF1_CEEdit54,'Text')
--
--  local k=0
--
--  for i in string.gmatch(inputText, "%S+") do
--     print(tonumber(i,16))
--     local offset=150+(k*4)
--
--     writeBytes(string.format("[_myaddress]+%d",offset), tonumber(i,16))
----     writeBytes("[_myaddress]+150", tonumber(i,16))
--     k=k+1
-- end
--
--
--  print('\n\n-------')
--end


I'm confused now, but some of that code was commented out, adding it all will conflict, i know. he got it working up to a point where it took the input as String (using writeString) and it threw the numbers all over the place. i input 01 02 03 04 into editbox, then in memory view (in hex) it puts like 01 xx xx xx xx xx 02 xx xx xx 03 xx xx .......................... 04 < you get the idea.


Honestly i think having a built-in function to overwrite bytes is very important. I use this method all the time. It's easiest way of testing stuff. for example i replace a big chunk in memory and see what changes, then i narrow it down by cutting it in half ..etc.
however this 132 byte chunk is all needed. It contains lot of different stuff and i need to overwrite all of it to get desired effect (it's like replacing a gun with another, so pistol would turn into a gun that was characteristics of a machine gun).

i did this in resident evil 4 long ago, but i used pointers back then as i did not know how to use lua. In cheat table i simply set a hot key with a long hex attached to it and it worked fine, but i want to put this into a trainer so there's editbox and people can write their own value and then overwrite the current weapon with new one. this is why i need 132 bytes.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 372

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

PostPosted: Tue Jun 20, 2017 2:46 pm    Post subject: This post has 1 review(s) Reply with quote

something like this:
Code:

AddressList.getMemoryRecordByDescription('entrywithaddress').Value=UDF1.CEEdit3.Text


alternatively, you can do a quick create and destroy:
Code:

local mr=AddressList.createMemoryRecord()
mr.Address="00400500"  --replace this with the address. Can be user input
mr.Type=vtByteArray
mr.ShowAsHex=true
mr.Aob.Size=6 --important for readonly regions
mr.Value=UDF1.CEEdit3.Text
mr.destroy()
mr=nil

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

Joined: 16 Apr 2010
Posts: 96

PostPosted: Tue Jun 20, 2017 3:43 pm    Post subject: Reply with quote

Thanks for the help, but i'm still in a pickle here. I tried the first one, it says

Error:[string "
..."]:654: attempt to index a nil value (global 'AddressList')

here's the actual code i used:

Code:
function CEButton54Click(sender)
AddressList.getMemoryRecordByDescription('Weapon Hack').Value=UDF1.CEEdit54.Text
end


on second one i get similar error:
Error:[string "
..."]:656: attempt to index a nil value (global 'AddressList')

here's the code I used
Code:
function CEButton54Click(sender)
local mr=AddressList.createMemoryRecord()
mr.Address='[_wephack]+150'
mr.Type=vtByteArray
mr.ShowAsHex=true
mr.Aob.Size=132
mr.Value=UDF1.CEEdit54.Text
mr.destroy()
mr=nil
end



it's probably a stupid mistake, but as I mentioned, i'm not that great with lua. I understand what most stuff does, but syntaxes and small errors are over my head :(
hope you can point out what i did wrong.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 372

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

PostPosted: Tue Jun 20, 2017 3:48 pm    Post subject: Reply with quote

I am of course assuming you're on 6.7
If you're on an older version you need to define the addresslist yourself
Code:

AddressList=getAddressList()

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

Joined: 16 Apr 2010
Posts: 96

PostPosted: Tue Jun 20, 2017 4:46 pm    Post subject: Reply with quote

Dark Byte wrote:
I am of course assuming you're on 6.7
If you're on an older version you need to define the addresslist yourself
Code:

AddressList=getAddressList()


perfect, thanks a lot for quick help! got it working with 1st example, the problem was CE version :)

ahahah i'm slow with updates, still at 6.5.1. I use a "custom" edition because some games detect "cheat engine" as threat and then game closes or you get banned, even when playing single player.
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