Re: Modifying the Original EXE File
- Posted by Daniel Berstein <daber at PAIR.COM> Nov 23, 1998
- 510 views
>If I wanted to store some variable information IN THE EXE file (for >instance, at the end of the exe I would put encoded info like user's >name, etc.), would this be possible? If so, how so? Yes, it can be done. The steps are: 1.- Create a constant in your source that hold the size (in bytes) of the bounded (.exe) file. 2.- To read/write data make a seek() to the above offset 3.- The very last statement in your source must be abort(0) 4.- Iterate step 1 until you match the exact size of the exe (using bind and then dir) Example: constant ExeLength = 150000 .... function GetUserName() integer fn sequence exename, -- Name of the executable username -- Data to be read exename = command_line() -- Get command line exename = exename[2] -- Get executable name fn = open(exename,"rb") -- Open file for binary read seek(exename, ExeLength) -- Let's get to the end of the EXE -- In this example we'll read 20 bytes that hold the user name for loop = 1 to 20 do username = username & getc(fn) end for close(fn) -- Close file return username -- Return info end function .... abort(0) -- The interpreter won't read after this Regards, Daniel Berstein daber at pair.com