1. Modifying the Original EXE File

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?

T'anks!
ck

new topic     » topic index » view message » categorize

2. Re: Modifying the Original EXE File

>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

new topic     » goto parent     » topic index » view message » categorize

3. Re: Modifying the Original EXE File

>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?


Some one build a resource binder.
I think it was David.
Go look in the archives.

Ralf

new topic     » goto parent     » topic index » view message » categorize

4. Re: Modifying the Original EXE File

ck wrote:

> 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?

Some time ago I posted a toolkit called RES. Among other things, you can:

   - Bind a large number of files into a single resource file
   - Bind a resource file to an executable

Each file in the resource file can be read and written to just as if they
were normal files. The only caveat is that you cannot make a bound resource
file *larger*. This allows delivering applications that consist of many
files as either a single executable, or as an executable and a resource
file.

The method that it uses is the same as that described by Daniel in his post,
but it takes care of all the details (calculating file size, etc) for you. I
think it's fairly simple to use. It's probably been moved to the archives by
now.

-- David Cuny

new topic     » goto parent     » topic index » view message » categorize

5. Re: Modifying the Original EXE File

Wow! Coolness personified/codified.

Mr. Cuny is a coding whirlwind. How come RDS hasn't hired him? hehe

Thanks Ralf and Daniel and David...

David Cuny wrote:
>
> Some time ago I posted a toolkit called RES. Among other things, you can:


<description of just what I need snipped for brevity>

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu