Saving settings and/or data in executable itself on permenent basis

This is a discussion on Saving settings and/or data in executable itself on permenent basis within the C++ Programming forums, part of the General Programming Boards category; Hi, Is it possible to save user settings, linear data such as log in the executable file of the running ...

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    6

    Lightbulb Saving settings and/or data in executable itself on permenent basis

    Hi,

    Is it possible to save user settings, linear data such as log in the executable file of the running programming itself (on permenent basis i.e. on HD, without using any other file)?

    if it is possible then how to read & append the data ?

    As it will increase the size of executable file , Will it slow the program down & affect memory occupied? if yes then how minimize it's effects?


    Justing asking out of curiosity to improve my knowledge, you can surely take your time if you would like to answer

  2. #2
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    You can't write to the program while it's running. You could create an invisible command prompt thread that writes it after the program closes. I am not sure about reading from it.
    Basically, the program should be quite unaffected of it, because the sizes of sections are set in the sections' section, so it will not load the end into the memory.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,484
    > Is it possible to save user settings, linear data such as log in the executable file
    What about multiple users?

    Most such programs store settings in either
    - the home directory of the user (on unix/linux say)
    - the current user in the windows registry (for win32)
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Under Win32, many programs use the APPDATA path, which is usually (in Windows XP): C:\Documents and Settings\User\Application Data

    Most of the programs I've seen, set themselves up to HKEY_LOCALMACHINE.

    Salem, can the executable be read, when it's open?
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  5. #5
    Registered User
    Join Date
    Sep 2006
    Posts
    835
    Quote Originally Posted by ruab
    Hi,

    Is it possible to save user settings, linear data such as log in the executable file of the running programming itself (on permenent basis i.e. on HD, without using any other file)?
    See the following thread which I found by googling on "self-modifying executable":

    http://www.gamedev.net/community/for...opic_id=384006

    I see no good reason for storing the data in the executable itself as opposed to a separate file. For one thing, there's no easy way anymore to verify that the executable isn't compromised if it's changing. Keeping the data in separate files means that a security audit can be restricted to those files only.

  6. #6
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Just cause MS saw fit to store data in the exe does not mean it's good practice. Store your data in a file. You could store the settings in the registry, but don't store tons of data there and certainly don't save the project in the registry. Registry is for simple settings you can load later.

  7. #7
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,484
    > Salem, can the executable be read, when it's open?
    Exe files contain a resource section, but that's only for read-only data as far as I know.

    Storing volatile data in exe files presents a whole host of problems.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  8. #8
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    I tested adding some random text to the end of an executable. That shouldn't be loaded into memory automatically, because it isn't in any section. It didn't give me any errors.

    Actually I would prefer using Application Data folder...
    "The Internet treats censorship as damage and routes around it." - John Gilmore

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sorting the matrix question..
    By transgalactic2 in forum C Programming
    Replies: 47
    Last Post: 12-22-2008, 02:17 PM
  2. CreateProcess with Resource of executable, not the Filename
    By Ktulu in forum Windows Programming
    Replies: 4
    Last Post: 11-04-2006, 12:07 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21