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 


dumping hex from executable

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

Joined: 02 Sep 2018
Posts: 101

PostPosted: Sun Jul 28, 2019 4:04 pm    Post subject: dumping hex from executable Reply with quote

Code:

local f = assert(io.open("test.exe", "rb"))
local block = 10
while true do
  local bytes = f:read(block)
  if not bytes then break end
  for b in string.gfind(bytes, ".") do
    io.write(string.format("%02X ", string.byte(b)))
  end
  io.write(string.rep("   ", block - string.len(bytes) + 1))
  io.write(string.gsub(bytes, "%c", "."), "\n")
end

this code works great but its slow i see hex editors that loads 100mb files fast but when i try 500kb file it takes forever is there a faster way to do this?

_________________
hi
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Sun Jul 28, 2019 4:33 pm    Post subject: Reply with quote

openFileAsProcess(filename) and then use read/write memory functions, or open the hexview window
_________________
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
exohaxor
Expert Cheater
Reputation: 1

Joined: 02 Sep 2018
Posts: 101

PostPosted: Mon Jul 29, 2019 5:10 am    Post subject: Reply with quote

but i want dump hex into txt file
_________________
hi
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Mon Jul 29, 2019 8:00 am    Post subject: Reply with quote

get some form of linux and use objdump?
_________________
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: 1668

PostPosted: Mon Jul 29, 2019 11:38 pm    Post subject: Reply with quote

exohaxor wrote:
but i want dump hex into txt file


Just make little modification your code.

Code:
local f = assert(io.open("E:\\test.exe", "rb"))
local output = assert(io.open("E:\\output.txt", "w"))
local block = 16

while true do
  local bytes = f:read(block)
  if not bytes then break end
  for b in string.gfind(bytes, ".") do
    output:write(string.format("%02X ", string.byte(b)))
  end
  output:write(string.rep("   ", block - string.len(bytes) + 1))
  output:write(string.gsub(bytes, "%c", "."), "\n")
end

f:close()
output:close()


output.txt contains:

Code:
4D 5A 90 00 03 00 00 00 04 00 00 00 FF FF 00 00    MZ...........
B8 00 00 00 00 00 00 00 40 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 00 00 00 00 00 00 00 00 00 E8 00 00 00    ...............
0E 1F BA 0E 00 B4 09 CD 21 B8 01 4C CD 21 54 68    .....!.L!Th
69 73 20 70 72 6F 67 72 61 6D 20 63 61 6E 6E 6F    is program canno
74 20 62 65 20 72 75 6E 20 69 6E 20 44 4F 53 20    t be run in DOS
6D 6F 64 65 2E 0D 0D 0A 24 00 00 00 00 00 00 00    mode....$.......
97 EF 55 84 D3 8E 3B D7 D3 8E 3B D7 D3 8E 3B D7    Uӎ;ӎ;ӎ;
CD DC BF D7 CC 8E 3B D7 CD DC AE D7 C3 8E 3B D7    ܿ̎;ܮÎ;
CD DC B8 D7 B3 8E 3B D7 F4 48 40 D7 DA 8E 3B D7    ܸ׳;H@ڎ;
D3 8E 3A D7 B0 8E 3B D7 CD DC B1 D7 D1 8E 3B D7    ӎ:װ;ܱю;
CD DC AF D7 D2 8E 3B D7 CD DC AA D7 D2 8E 3B D7    ܯҎ;ܪҎ;
52 69 63 68 D3 8E 3B D7 00 00 00 00 00 00 00 00    Richӎ;........
00 00 00 00 00 00 00 00 50 45 00 00 4C 01 05 00    ........PE..L...
98 A1 CD 51 00 00 00 00 00 00 00 00 E0 00 02 01    Q...........
0B 01 09 00 00 8E 00 00 00 F0 42 00 00 00 00 00    ........B.....
EB 15 00 00 00 10 00 00 00 A0 00 00 00 00 40 00    ............@.
00 10 00 00 00 02 00 00 05 00 00 00 00 00 00 00    ................
05 00 00 00 00 00 00 00 00 C0 43 00 00 04 00 00   


and so on

EDIT :
The easy way is using HxD Editor

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
predprey
Master Cheater
Reputation: 24

Joined: 08 Oct 2015
Posts: 486

PostPosted: Tue Jul 30, 2019 3:54 am    Post subject: Re: dumping hex from executable Reply with quote

exohaxor wrote:
Code:

local f = assert(io.open("test.exe", "rb"))
local block = 10
while true do
  local bytes = f:read(block)
  if not bytes then break end
  for b in string.gfind(bytes, ".") do
    io.write(string.format("%02X ", string.byte(b)))
  end
  io.write(string.rep("   ", block - string.len(bytes) + 1))
  io.write(string.gsub(bytes, "%c", "."), "\n")
end

this code works great but its slow i see hex editors that loads 100mb files fast but when i try 500kb file it takes forever is there a faster way to do this?


I think why HxD load 100mb files fast is because it doesn't load the file in its entirety but on demand as the user scrolls through.
Back to top
View user's profile Send private message
exohaxor
Expert Cheater
Reputation: 1

Joined: 02 Sep 2018
Posts: 101

PostPosted: Tue Jul 30, 2019 5:34 am    Post subject: Reply with quote

corroder thanks it worked faster
_________________
hi
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