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 


how do i read all bytes exe file? [help]

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Lynxz Gaming
Expert Cheater
Reputation: 4

Joined: 01 Jul 2017
Posts: 208
Location: help

PostPosted: Tue Apr 16, 2019 10:00 pm    Post subject: how do i read all bytes exe file? [help] Reply with quote

How do i read all bytes exe file?
cuz i tried to io.open("file.exe","r") when i print it out it only shows "MZ?"
and i replace the \0 to blank its only get 2030 lengths
i want to read all the byte of the exe until below the assembly
any solution?

thanks

_________________
my english is bad
discord : rynx#9828
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Tue Apr 16, 2019 10:56 pm    Post subject: Reply with quote

try rb instead of r
_________________
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
Lynxz Gaming
Expert Cheater
Reputation: 4

Joined: 01 Jul 2017
Posts: 208
Location: help

PostPosted: Wed Apr 17, 2019 12:41 am    Post subject: Reply with quote

thanks but its still read MZ?

maybe later i must search google up first then asking
this is the solution for sharing

Code:
local fileName = 'filename.exe'
local file = assert(io.open(fileName, 'rb'))
local t = {}
repeat
   local str = file:read(4*1024)
   print(str) -- read the whole file
   for c in (str or ''):gmatch'.' do
      t[#t+1] = c:byte()
   end
until not str
file:close()
print(#t) --string lengths

_________________
my english is bad
discord : rynx#9828
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8517
Location: 127.0.0.1

PostPosted: Fri Apr 19, 2019 4:44 pm    Post subject: Reply with quote

You can't print the raw data and expect it to print everything. The print call is going to handle the data as a normal string, meaning the first 00 byte it hits, the string will be terminated and cut off. You are only seeing the MZ because a typical PE header will have a ton of 00's in it for most of the data.

If you want to print everything, convert the data to hex bytes and print that instead.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
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