I need to be able to change the value of an existing byte in a file. Primarily, this is because I need data stored towards the beginning of the file that I won't know until the end of creating the file.
How do I do this?
This is a file that has been created by the program (Int 21, 3Ch), so I'm guessing it's already open with write access. I would imagine all I need to do is change the pointer from the end of the file at that moment to the byte I need to patch and back again, but I have no idea where or how this pointer is stored. For what it's worth, I've got two files open: one file open for reading, and then this one which was created by the app - I don't know if this changes where the pointer would be stored.
Obviously, I'm a newbie. :) Oh, and this is for MASM compatible 16-bit code.
2 replies to this topic
#1
Posted 11 December 2011 - 08:52 PM
|
|
|
#2
Posted 12 December 2011 - 02:04 AM
File seek: int 21h, AH=42H
AL - Where your offset is relative to. 0 is beginning of the file, 1 is the current file position, 2 is from the end of the file.
BX - The file handle
CX:DX - The offset to move to as a signed two's complement 32-bit integer.
You can't modify the file pointer directly, only through this interrupt. To seek to the end of the file, set CX:DX to 0 and AL to 2. To move from the end of the file, CX:DX should be negative, though you're allowed to seek past the end of the file, in which case the file will automatically grow to accommodate the change.
AL - Where your offset is relative to. 0 is beginning of the file, 1 is the current file position, 2 is from the end of the file.
BX - The file handle
CX:DX - The offset to move to as a signed two's complement 32-bit integer.
You can't modify the file pointer directly, only through this interrupt. To seek to the end of the file, set CX:DX to 0 and AL to 2. To move from the end of the file, CX:DX should be negative, though you're allowed to seek past the end of the file, in which case the file will automatically grow to accommodate the change.
sudo rm -rf /
#3
Posted 12 December 2011 - 04:21 AM
Perfect, thank you so much for your help. :)
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









