Re: self-modifying exe... possible?

new topic     » goto parent     » topic index » view thread      » older message » newer message

>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 thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu