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 


Using Cheat Engine to Make a Hex Editor?

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

Joined: 09 Jun 2015
Posts: 64

PostPosted: Mon Dec 10, 2018 6:39 pm    Post subject: Using Cheat Engine to Make a Hex Editor? Reply with quote

Alright, so I know how to make executable trainers and I've noticed that Cheat Engine can open files as memory and write to them. Knowing this, I have files for a video game I'd like to hex edit. Instead of hex editing myself in HxD, I'd like to make a program to do it automatically for me as the addresses in these physical files never change and they aren't encrypted. The value I'd need to write is also always the same. So, I'd need to make a tool (preferably with Cheat Engine) that opens a file, replaces hex values in said file at certain addresses, and then either saves those changes to the file or exports a new file with the hex edited changes. How would I go about doing that with a Cheat Engine UI?
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 67

Joined: 06 Jul 2014
Posts: 2143

PostPosted: Mon Dec 10, 2018 9:36 pm    Post subject: Reply with quote

The easiest way to do this with CE is probably to just use the Lua IO library.
Relevant section of the manual; search for examples anywhere (CE's API is unrelated).

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 360

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

PostPosted: Tue Dec 11, 2018 1:45 am    Post subject: Reply with quote

openFileAsProcess
then aobscan or whatever, edit

and when done saveOpenedFile

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Back to top
View user's profile Send private message MSN Messenger
Reclaimer Shawn
Advanced Cheater
Reputation: 0

Joined: 09 Jun 2015
Posts: 64

PostPosted: Tue Dec 11, 2018 1:54 pm    Post subject: Reply with quote

Dark Byte wrote:
openFileAsProcess
then aobscan or whatever, edit

and when done saveOpenedFile


Thanks Dark Byte! What you told me has worked. The code that I'd use to modify the file is below:

Code:

function CEButton1Click(sender)
local path = "D:/Desktop Files/Gaming/Halo CE Stuff/maps/bloodgulch.map"
openFileAsProcess(path, r)
writeBytes ("00000004", 7, 0)
saveOpenedFile(path)
end


That works for me considering I've set the path in the code and I'll never move my directory for modifying my files. Now, the only problem is I want the user to be able to set the path themselves without modifying the code. It'd basically be opening a windows prompt to open the file, and after selecting said file, the path becomes the path of the file selected. How would I go about doing that?[/code]
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 146

Joined: 25 Jan 2006
Posts: 7571
Location: 127.0.0.1

PostPosted: Tue Dec 11, 2018 2:03 pm    Post subject: Reply with quote

Check out the celua.txt file that comes with Cheat Engine, it has all the info on what's available to the Lua state.

You would want to look into:
- OpenDialog
- FileDialog

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Reclaimer Shawn
Advanced Cheater
Reputation: 0

Joined: 09 Jun 2015
Posts: 64

PostPosted: Tue Dec 11, 2018 4:59 pm    Post subject: Reply with quote

atom0s wrote:
Check out the celua.txt file that comes with Cheat Engine, it has all the info on what's available to the Lua state.

You would want to look into:
- OpenDialog
- FileDialog


Thanks atom0s! That got it working for me. Here's the finished code:
Code:

function CEButton1Click(sender) 
load_dialog = createOpenDialog(self)
load_dialog.InitalDir = os.getenv('%USERPROFILE%')
load_dialog.execute()
local path = load_dialog.FileName
openFileAsProcess(path, r) 
writeBytes ("00000004", 7, 0) 
saveOpenedFile(path) 
end
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