Store data in executable

前端 未结 6 1948
梦毁少年i
梦毁少年i 2021-01-02 07:15

I\'m just curious about this for a long time.

Is it possible for an application to store some changeable data (like configurations and options) inside its own execut

6条回答
  •  盖世英雄少女心
    2021-01-02 07:32

    Difficult. Difficult. Difficult.

    But in order to do this you basically have to read in the file into a buffer, or into another file, you can use direct fstream. However make sure you use the ios::binary flag. And append the buffer or file, I mean it's a horribly simple matter of actually appending the data. The problem lies in adding to itself.

    Here's what I'd do:

    first write a program to pack programs into other programs. You probably possess the knowledge already. Once you have that, have it pack itself into another program, be sure you've arranged for outside messaging or passing of arguments. Then on your main program you can simply unpack that program and pass in a link to a file you create (temporary) which you would like to append yourself with. kill your current program. Let the slave append the data and call your program again.

    blam appended executable.

提交回复
热议问题