Connecting Tech Pros Worldwide Help | Site Map

executing a file with a byte offset? (pipe?)

  #1  
Old July 22nd, 2005, 06:11 AM
Xilo Musimene
Guest
 
Posts: n/a
Hi there,
I'm programming an archiving class and the archive is currently able
to read files, concatenate them in one and compress the archive (or
specific files that can be compressed) with the zlib.

I think I will be concatenating this archive to a binary executable that
will read itself to find its data (btw, it's an OpenGL program with
textures).

So we have:
1. OpenGL program
2. Archive
1. TextureA
2. TextureB
3. TextureC

OpenGL program (1.0) reads the archive (2.0), finds the textures and
loads TextureA (2.1), TextureB (2.2), TextureC (2.3).

Currently my program can succesfully read all textures and run the
OpenGL animation.

What I'm thinking is if it is possible to execute an archived
(uncompressed, raw binary) program in such an archive.

1. Program
2. Archive
1. DataA
2. Program I want to exec
3. DataB

Program (1.0) reads the archive (2.0), reads DataA (2.1), start the
execution of the second program in the archive (2.2), etc...

How I read the data:

Normally i open an ifstream, read the header of my archive, finds the
byte position of the start of the file I wish to read, then jump the
cursor position to that place and pass the ifstream to whatever wish to
read that file (ie, loadJPEG()).

Now I'd like to move the cursor to the start of an archived program and
start executing it as a new program or as a child of the current
program. (Doesn't matter...)

Is this possible?
My OpenGL program is running fine under linux and windows. Is this
possible for linux and windows (is the code I need compatible?)

Thanks a lot!
Xilo

  #2  
Old July 22nd, 2005, 06:12 AM
Xilo Musimene
Guest
 
Posts: n/a

re: executing a file with a byte offset? (pipe?)


> Now I'd like to move the cursor to the start of an archived program and[color=blue]
> start executing it as a new program or as a child of the current
> program. (Doesn't matter...)[/color]

I will soon start to learn Assembler and I think it should be able to do
this for me... since the assembler doesn't know difference between data
and executable binary I think the archive (which is considered data)
could be executed this way (not using C++).

I think I could write a small "executor" at the start of the archive
like so:

1.0 - Assembly executor
2.0 - Archive (uncompressed)
2.1 - Main program (C++)
2.2 - Some Data here (compressed)
2.3 - Secondary program

I guess the assembly executor should know the address of the begining of
all programs within the archive, the addresses should be built-in and it
should be possible to start the hole program (1.0) with arguments to
tell the assembly executor which program to execute.

I'm not sure if it is easy to read files on the disk with the assembler,
nor if the whole thing is possible...

But since it is so easy for a CPU to mistake data and exe. binary I
guess there should be a function to execute data in C++, isn't there any?

If there is a function that can execute data, then I can read my program
to memory and execute the given string (char* of a few hundred kilobytes).

Thanks for any information,
Xilo

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit answers 0 November 14th, 2005 08:57 PM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit answers 0 November 14th, 2005 07:46 PM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit answers 0 November 14th, 2005 03:55 PM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit answers 5 November 14th, 2005 12:36 PM