Application Reading Itself



I'm writing an application that will store some hidden and encrypted
data at the end of the file, however, I'm having trouble getting the
application to read itself. Here's the code I have:

FILE *myself = NULL;
if(!(myself = fopen("AppReader.exe", "rb")))
{
fprintf(stderr, "Cannot open file to read.");
}
fseek(myself, -8, SEEK_END);
char buffer[10];
fread(buffer, 1, 8, myself);
buffer[8] = '\0';
printf("String: %s\n", buffer);
fclose(myself);

I realize that this isn't exactly the safest application, and that I
have no real error measures in place, however this is just a test to
see if it will work.

So the question is, does anyone know how to get it to work?

.



Relevant Pages

  • Re: Eden of the East - Some criticisms
    ... writing) but that room isn't a Vegas stage. ... Diana when the wings sprout, the window breaks, and the feathers fly. ... they are owned by the store owners. ... See what I mean about "video game writing"? ...
    (rec.arts.anime.misc)
  • Eden of the East - Some criticisms
    ... As of episode 8 of "Eden of the East" I have become rather ticked off at the ... writing in the series. ... BTW - "illusion" or not, if that window was blown in, everyone in that room ... they are owned by the store owners. ...
    (rec.arts.anime.misc)
  • Re: Please help with PHP/MySQL form select
    ... url that the user clicks, or you can store it in a session, or store it ... I would echo Antonio's advice - there is more to writing a program than ... simply chucking functions together in a language - the language is ... hosting it from home over a broadband link - Broadband will not serve ...
    (alt.php)
  • Re: AES trickery ;-)
    ... > using it in pseudocode seems bizarre unless you are writing a compiler ... > and posting pseudo-code for its internals, then a comment, which is not ... My point though was that I've had little trouble ... recently writing code that "just works" without modification. ...
    (sci.crypt)
  • Re: OT:Snit tells more lies...
    ... So here it is in writing: ... store effort ended in failure in 2001. ... influenced by Apple's success, and the thinking may be, "Hey, ... mortar strategy was copied from MS's failed strategy with one store. ...
    (comp.sys.mac.advocacy)