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 


Any better alternative to writeBytes for 4 bytes variables?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
LalzDS
Newbie cheater
Reputation: 0

Joined: 17 Sep 2013
Posts: 11

PostPosted: Sun Mar 05, 2017 5:53 pm    Post subject: Any better alternative to writeBytes for 4 bytes variables? Reply with quote

Greetings.

I'm currently using writeBytes to set values for 4 bytes variables.

As an example, I would use
Code:
writeBytes("20123456", 78, 97, 188, 0)

To set value 00BC614E to variable 20123456.

This requires, however, manual value conversions. Is there no direct way to set the HEX value? Or any other better alternative.

Regards,
Lalz.
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 50

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Sun Mar 05, 2017 5:56 pm    Post subject: Reply with quote

Code:

writeInteger('theAddress', 0x123ABC)
writeInteger('theAddress', tonumber('123ABC', 16))

_________________
Back to top
View user's profile Send private message Visit poster's website
LalzDS
Newbie cheater
Reputation: 0

Joined: 17 Sep 2013
Posts: 11

PostPosted: Mon Mar 06, 2017 1:08 pm    Post subject: Reply with quote

Even though CE doesn't complain about the code not being injectable, neither seems to work. Are you sure your code isn't wrong?

UPDATE: "tonumber" function is working but "writeInteger" isn't. That reminds me, Isn't integer just up to 2 bytes? Because we're trying to write 4 here.
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Mon Mar 06, 2017 2:25 pm    Post subject: Reply with quote

writeInteger (and other similar functions) will only work when memory is writable.

writeBytes is the only one which uses VirtualProtectEx to change flags.


So, you have few options:

1
fullAccess('theAddress', 4)
writeInteger('theAddress', 0x00BC614E)


2
autoAssemble('theAddress:\ndd 00BC614E')

_________________
Back to top
View user's profile Send private message MSN Messenger
LalzDS
Newbie cheater
Reputation: 0

Joined: 17 Sep 2013
Posts: 11

PostPosted: Mon Mar 06, 2017 2:36 pm    Post subject: Reply with quote

Only the latter works, but that's already an improvement. No idea why the former won't.
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Mon Mar 06, 2017 6:56 pm    Post subject: Reply with quote

Code:
writeBytes("address", dwordToByteTable(0x00BC614E))
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Mon Mar 06, 2017 8:14 pm    Post subject: Reply with quote

try fullAccess(getAddress('theAddress'), 4 )
_________________
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
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