Thetotoman
12th February 2003 22:03 UTC
FileReadByte...
Hi! I would like to know if I can read a targetted byte on a file, or if I can only read the first byte of a file with FileReadByte. For example if I want to read the 1221st byte of a file "file.exe", how can I do.
If it works, it will work with FileWriteByte that could be very usefull to patch files...
Thank you for your help and excuse me for my language, I'm french ;)
kichik
13th February 2003 09:11 UTC
Use:
# Open the file for both reading and writing
>FileOpen $0 "filename" "a"
># Move the file pointer to the right position
>FileSeek $0 1221
># Read
>FileReadByte $0 $1
># Do stuff with read byte...
# Write something instead, first, seek back
>FileSeek $0 1221
FileWriteByte$0 0xA9
># Close the file
>FileClose $0
>
Thetotoman
13th February 2003 19:48 UTC
thanx for your help kichik ;)
Thetotoman
13th February 2003 21:09 UTC
Sorry: it works, but only if I want to read a byte smaller than 9 (0-9).If I want to read a byte larger than 9, for example 15, or 1221, the output is wrong: it is 0, or an integer who does't correspond with the decimal convertion of the offset. So I can use it only with the small offsets, between 0 and 9... I don't know what it is! I tryed a lot of thing, but nothing works. what a f*@#!
If you can help me...
kichik
13th February 2003 22:31 UTC
Are you sure you didn't hit any block of zeros in the code? It works perfectly fine for me. If you're sure, attach the script and the file if possible so I can have a look.