1. self-modifying exe... possible?

Hi all!

is there a simple way to save (or update) some data directly into the
executable (binded) euphoria program?.
i've made a program and binded it with ex.exe. the program needs
to save the filename that was lastly handled by the user. for the present,
i made another separate file to save that information.
yes..., it's simplest way to do it. however, i am interested to know
if it's possible to save or update that information directly into binded
executable to get rid of the necessity to maintain another separate file
only to save one-line information(file-name lastly handled by user).

Bye!

from Lee, woo seob...

new topic     » topic index » view message » categorize

2. Re: self-modifying exe... possible?

>is there a simple way to save (or update) some data directly into the
>executable (binded) euphoria program?.

    Yes, simply open your own program and add or remove some lines.
    You could even update your program code for the next time the program is
run.
    (Change some constants, however this last is very hard when binden,
because your code is shrouded..)

>i've made a program and binded it with ex.exe. the program needs
>to save the filename that was lastly handled by the user. for the present,
>i made another separate file to save that information.
>yes..., it's simplest way to do it. however, i am interested to know
>if it's possible to save or update that information directly into binded
>executable to get rid of the necessity to maintain another separate file
>only to save one-line information(file-name lastly handled by user).

Yes, easy...
You open your program for read-binairy and then seek to the place where the
filename is stored. (for the first time you have to keep space over for
this, or insert a file name your self.
Best is to keep this at then end of a file...
You get the size of a file, by getting info about the files in the current
directory.
Then you (know you reserved space by having 13 spaces quated at the end,
something like this:

-- Begin

    ..code...
    abort(0)    -- So the Euphoria doesn't generate an error with the next
line
    "             "

-- End

    The shrouding won't mess with the qouted stuff unless you tell him to
mess with it. (encode strings to sequences)
    Well then the string starts at file_size - 14
    You can put in a file name their: "example .ex "
    Notice that you have to keep spaces...
    You could also write this: "example.ex  "
    But always write all 13 chars, and strip it when you need to read it.
    Even cleaner but nearly impossible is (because of shrouding) having a
constant that is at the beginning of your program. (that would start at the
file size of ex.exe +1 or something simelar, try, maybe it's one or two off)

    Hope this helps..

Ralf

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

3. Re: self-modifying exe... possible?

On Tue, 30 Dec 1997 15:11:28 +0900 Lee woo seob <wslee at HHI.CO.KR> writes:
>---------------------- Information from the mail header
>-----------------------
>Sender:       Euphoria Programming for MS-DOS
><EUPHORIA at MIAMIU.ACS.MUOHIO.EDU>
>Poster:       Lee woo seob <wslee at HHI.CO.KR>
>Subject:      self-modifying exe... possible?
>-------------------------------------------------------------------------------
>
>Hi all!
>
>is there a simple way to save (or update) some data directly into the
>executable (binded) euphoria program?.
>i've made a program and binded it with ex.exe. the program needs
>to save the filename that was lastly handled by the user. for the
>present,
>i made another separate file to save that information.
>yes..., it's simplest way to do it. however, i am interested to know
>if it's possible to save or update that information directly into
>binded
>executable to get rid of the necessity to maintain another separate
>file
>only to save one-line information(file-name lastly handled by user).
>
>Bye!
>
>from Lee, woo seob...
>
        Yes, make a call in the current proggie or maybe a secondary
prog, to poke or "push" data into a specific area of the dump of the
program and set the variable in that area.... atleast, it works that way
in pascal and c++.... Robert? Any Ideas?

        And also to Robert Craig, what did <do> you use to create the
many versions of Euphoria?

                                L8TRZ,
                           Piotr Andrzej Frackowiak

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

4. Re: self-modifying exe... possible?

Lee woo seob wrote:
> is there a simple way to save (or update) some data directly into the
> executable (binded) euphoria program?.

The answer that Ralf gave the other day was
essentially correct.

When bind.bat creates a .exe for you, it puts the
Public Domain ex.exe (or exw.exe) first, followed by
the shrouded version of your source code.

If you want to add some data
to your .exe file, for either reading or writing, you can do it.
Just end your source program with abort(0). This will
make sure that Euphoria stops reading the file at that point.
You can then have as much data as you like after that point
in your .exe file. You can check the size of your .exe using DIR
before you add your data to it.

   | ex.exe | your shrouded source | your data |

A simple program that opens your .exe file and your data
in binary read mode and uses getc() and puts(),
could be used to append your data to the bound .exe file.

Your program can open() your .exe file (i.e. open itself!)
and use seek() to position the file pointer to the place
where the .exe would normally end. This is where your
data can begin.

You'll have to be careful changing your source program because
the size of the .exe will change and you'll have to
update the seek position.

Piotr Andrzej Frackowiak writes:
> And also to Robert Craig, what did you use to create the
> many versions of Euphoria?

Euphoria is written in WATCOM C/C++ 10.6
using the DOS32 and WIN32 target platforms
for that compiler. For DOS32, Euphoria uses
the "CauseWay" DOS extender to create a 32-bit
memory address environment. Originally (pre 1.4)
the DOS4GW extender supplied free with WATCOM
was used, but CauseWay has proved to be much
superior for Euphoria's needs.

There's also some low-level assembly code in a few
critical areas.

Regards,
     Rob Craig
     Rapid Deployment Software

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

Search



Quick Links

User menu

Not signed in.

Misc Menu