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

X

Xilo Musimene

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
 
X

Xilo Musimene

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...)

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top