🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #2971

Re: Combining program and data in an executable.

#2971
From: Markus Fischer
Date: Fri, 09 Nov 1990 01:03
33 lines
1899 bytes
In article <1990Nov6.133618.23396@jarvis.csri.toronto.edu>, west@turing.toronto.edu (Tom West) writes:
>   I have a program that acts upon data currently stored in a file.  I would
> like to somehow be able to combine the program with the data, so that a 
> separate data file would not be necessary.  (i.e. spreadsheet data with a 
> viewer builtin.)  Is there any way that one can do this?
> [...]

Hello,

Isn't this exactly what you do when you say `printf("Hello world!\n")'? i.e.
a compilable code referencing static data?
(note: examples are in (Turbo)C)

A quick-and-dirty solution would be to create a program module like
] static char data[] =
] "here comes your text-file, remember to \"escape\" quotes, new lines\
] and the like...\n";

If your data is in binary format, you can dump it as in
] static char data[] = {
]    0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f, 0x72, 0x6c,
]    0x74, 0x21, ... /* or do you prefer octal notation? */
] };
The program to generate such a listing for any file seems easy to write...

Of course, a hacker might provide us a program creating directly the object
module, without having to recompile it, but the above solution is more
portable.  After this step, compile the module, modify the file-io of your
program into direct memory read, and link the whole thing.

Hope this helps

Markus Fischer, Dpt of Anthropology, Geneva.
Technical Details
Message-ID: <290@sc2a.unige.ch>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!mintaka!bloom-beacon!eru!hagbard!sunic!mcsun!cernvax!chx400!ugun2b!ugsc2a!fisher
References: <1990Nov6.133618.23396@jarvis.csri.toronto.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!mintaka!bloom-beacon!eru!hagbard!sunic!mcsun!cernvax!chx400!ugun2b!ugsc2a!fisher
From: fisher@sc2a.unige.ch (Markus Fischer)
Newsgroups: comp.os.msdos.programmer
Subject: Re: Combining program and data in an executable.
Message-ID: <290@sc2a.unige.ch>
Date: 9 Nov 90 01:03:34 GMT
References: <1990Nov6.133618.23396@jarvis.csri.toronto.edu>
Organization: University of Geneva, Switzerland
Lines: 33