Using file memory to store hidden data

Discussion in 'C Programming' started by noridotjabi@gmail.com, Apr 27, 2006.

  1. Guest

    Say I'm writting a program. In this program for some reason I need to
    store data somewere were I will be able to access it again. I don't
    want to store it in a file because then it could be deleted by another
    program or user. So, is there anyway to save data onto a computer so
    that it will not apear as a file (actually idealy not apear as anything
    at all), but will not get overwritten by any other program or file. If
    this is OS spacific tell me because the more I think about it the more
    it seems like it would be. Let me give an example of what I am looking
    for:

    /* getfmemloc() doesn't really exist */
    /* putfmemloc() doesn't really exist */

    getfmemloc(fmemloc); /* This would get data from the hard disk */
    putfmemloc(fmemloc, data); /* This would put data to the hard disk at
    that spot */

    Is there anyway to do that (put data on to the hard disk and read it
    off without using files and without having to worry about other
    programs overwritting it)?

    Thanks in advanced for anyone who may offer some sort of hint as to if
    is this possible.
    Nori
     
    , Apr 27, 2006
    #1
    1. Advertising

  2. wrote:
    > Say I'm writting a program. In this program for some reason I need to
    > store data somewere were I will be able to access it again.

    I can't imagine why; my programs never work on data. They just...
    execute themselves.
    > I don't
    > want to store it in a file because then it could be deleted by another
    > program or user. So, is there anyway to save data onto a computer so
    > that it will not apear as a file (actually idealy not apear as anything
    > at all), but will not get overwritten by any other program or file.


    Well, my iPod runs standard C, and if I take a knife to it then any data
    you had "safely stored" will be overwritten. I know because I tried that.
    > If
    > this is OS spacific tell me because the more I think about it the more
    > it seems like it would be. Let me give an example of what I am looking
    > for:
    >
    > /* getfmemloc() doesn't really exist */
    > /* putfmemloc() doesn't really exist */
    >
    > getfmemloc(fmemloc); /* This would get data from the hard disk */
    > putfmemloc(fmemloc, data); /* This would put data to the hard disk at
    > that spot */
    >
    > Is there anyway to do that (put data on to the hard disk and read it
    > off without using files and without having to worry about other
    > programs overwritting it)?
    >
    > Thanks in advanced for anyone who may offer some sort of hint as to if
    > is this possible.
    > Nori
    >

    It's not possible, and I can't see why any OS would give you that
    capability unless it was inviting spyware. Are you writing spyware? And
    please use a spellchecker.

    --
    Andrew Poelstra <http://www.wpsoftware.net/blog>
    Every prime number in a series as a joke
    Made all the patterns clear when I took that final toke
     
    Andrew Poelstra, Apr 27, 2006
    #2
    1. Advertising

  3. "" <> writes:
    > Say I'm writting a program. In this program for some reason I need to
    > store data somewere were I will be able to access it again.


    There's a term for "somewhere where I will be able to access it
    again". It's called a "file".

    > I don't
    > want to store it in a file because then it could be deleted by another
    > program or user. So, is there anyway to save data onto a computer so
    > that it will not apear as a file (actually idealy not apear as anything
    > at all), but will not get overwritten by any other program or file.


    I think what you really want is to store the data in a file that can't
    be deleted by another program or user. Many systems provide ways of
    controlling who or what has permission to manipulate a specified file.

    No such mechanism can be 100% secure. The information is going to be
    stored in some form on some kind of hardware. Tossing the hardware
    into a blast furnace will more than likely destroy the information.
    Ways to alleviate this include controlling both physical and network
    access to the hardware, and making frequent backups.

    I have some important pieces of data that I store on a USB thumb
    drive; it's connected to a computer only when I'm actually using it.
    The data is, of course, stored as files.

    > If
    > this is OS spacific tell me because the more I think about it the more
    > it seems like it would be.


    Standard C lets you read and write files; anything beyond that is
    system-specific.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
     
    Keith Thompson, Apr 27, 2006
    #3
  4. wrote:
    > Say I'm writting a program. In this program for some reason I need to
    > store data somewere were I will be able to access it again. I don't
    > want to store it in a file because then it could be deleted by another
    > program or user. So, is there anyway to save data onto a computer so
    > that it will not apear as a file (actually idealy not apear as anything
    > at all), but will not get overwritten by any other program or file. If
    > this is OS spacific tell me because the more I think about it the more
    > it seems like it would be. Let me give an example of what I am looking
    > for:
    >
    > /* getfmemloc() doesn't really exist */
    > /* putfmemloc() doesn't really exist */
    >
    > getfmemloc(fmemloc); /* This would get data from the hard disk */
    > putfmemloc(fmemloc, data); /* This would put data to the hard disk at
    > that spot */
    >

    What is "femloc"? An inode? An int? Something else? This value is
    key to your question. Even if you can actually get at the persistent
    storage in some reasonable way, your approach will be tied to a specific
    implementation of a filesystem. That is, there is no universal value
    you can use for this argument that will translate into "a place on the
    disk".

    Anyway, this is security by obscurity which has very limited value.

    > Is there anyway to do that (put data on to the hard disk and read it
    > off without using files and without having to worry about other
    > programs overwritting it)?
    >

    Most operating systems offer resources like disk space in a highly
    abstract way.

    This is easily solved with a combination of file locking or memory
    mapping (and perhaps encryption).

    This is why some operating systems have high-level abstractions of
    encrypted file systems that look and taste just like ordinary resources
    that things like open() can get a handle on, even though they might be
    doing some magic under the covers.

    Another option is to do what databases did in the old days when they
    could neither trust the filesystem or the other processes present on a
    machine: build your own abstract filesystem out of big files. Grab some
    chunks of disk as regular files (perhaps a linked-list of chunks so you
    can dynamically grow and shrink as needed) and write your data to those
    file(s) in some clever manner. You can obfuscate or munge that data how
    you like. Judicious use of hashes and such will let you know if the
    data is not to be trusted because it was changed outside of normal
    processing.

    Locking and file protection is still an OS abstraction, and you have to
    trust that other process honour any ACLs (if present) you may have on
    those files.

    A related option is a small embedded database that you persist
    serialized data to. Row locking is pretty robust, and most people will
    never know your app has a little config file and database directory
    squirrelled away.
     
    void * clvrmnky(), Apr 27, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UnVkeQ==?=

    to store or not to store an image

    =?Utf-8?B?UnVkeQ==?=, Mar 29, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    666
    =?Utf-8?B?UnVkeQ==?=
    Mar 30, 2005
  2. thaosb
    Replies:
    0
    Views:
    1,299
    thaosb
    Apr 13, 2009
  3. Rick
    Replies:
    3
    Views:
    8,506
    Alexey Smirnov
    Apr 13, 2010
  4. jason
    Replies:
    6
    Views:
    407
    jason
    Nov 20, 2003
  5. SolarCanine
    Replies:
    2
    Views:
    326
    SolarCanine
    Sep 20, 2005
Loading...

Share This Page