flat assembler
Message board for the users of flat assembler.

Index > Main > help me :-) [newbie]

Author
Thread Post new topic Reply to topic
ansik



Joined: 09 Dec 2005
Posts: 6
ansik
help me plz. I need algorythm to find and replace hex-codes in binary file.
e.g: 'ff 00 ff 6b' replace to 'f1 02 cc 6a'
help me plz. Smile
Post 21 Dec 2005, 13:16
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
Do you mean replacing some bytes pattern with the same amount of bytes, without shifting the rest of the file?
Post 21 Dec 2005, 17:31
View user's profile Send private message Visit poster's website Reply with quote
ansik



Joined: 09 Dec 2005
Posts: 6
ansik
yes. and which "read block size" use? 1byte is slow (file~3Mb), and in order to use bigger "read block size" i need an algorythm Smile)
Post 21 Dec 2005, 21:11
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
In which operating system? In Windows you could use the file mapping and thus "read block" wouldn't be necessary at all.
Post 21 Dec 2005, 21:50
View user's profile Send private message Visit poster's website Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend
Map whole file. If it's PE .exe/.dll then get to section's data (to prevent searching in headers unless you wish to). Than if it's always dword value you seek, the best solution imho would be using scasd instruction like this:
Code:
        mov     ecx, size / 4
        mov     eax, pattern_you_seek
        mov     edi, start_of_block_to_search_within ; Smile
        repnz   scasd
        jnz     .not_found    
Post 22 Dec 2005, 20:45
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
look at FASMLIB, file 'fasmlib\str.inc', procedure 'str.pos'
Post 23 Dec 2005, 02:16
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.