flat assembler
Message board for the users of flat assembler.

Index > Linux > Having a program save itself as an executable

Author
Thread Post new topic Reply to topic
nyrtzi



Joined: 08 Jul 2006
Posts: 192
Location: Off the scale in the third direction
nyrtzi
Lets say that there is an interactive program that modifies
itself and needs to offer the user the possibility to stop the
program and resume later.

I'm thinking that one solution could be that the program
could save itself as an executable file with the accumulated
modifications. This way if the user wanted to resume a previous
session he/she would just need to run the desired saved image.

The question is... what would the program need to write in the new file?
I'm asking this because I'm not sure if I remembered everything.

Probably the ELF header (so that the saved image can be executed...
after all this is Linux), the actual code of the program and the data
(all of the relevant stuff in the heap and elsewhere).
Am I forgetting anything (anything Linux specific for example)?
Post 22 Nov 2007, 15:07
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Okay, on linux it *is* possible to dump your memory image to executable, unlike on Windows - but it's not really the best way to handle things...

You'd still need to reliably dump all memory structures you have allocated, and those most likely need pointer fixups etc... since you have to handle those, you might as well design a proper save/load routine and forget about simple image dumping Smile
Post 22 Nov 2007, 17:33
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.