Mail Archives: djgpp/1997/11/07/07:31:51
J P Morris wrote:
>
> Hello all,
>
> How can I succesfully produce a .DXE file that references my
> main program?
>
> I am trying to use .dxe files to provide natively-executed
> code modules for a game. (Quake 2 uses DLLs to do this).
>
> If I make a .dxe file that uses no functions, it works correctly.
> (Setting a pointer to NULL and dereferencing it works :-))
>
> However, to use DXEs in any useful way, I need to call functions.
>
> I considered that fixups to the game itself might cause a
> problem, so I made a library of my own to sit between the game
> and the .dxe.
>
> GAME -> syslib.o -> mainproc.dxe
>
> This should mean that I can compile .DXEs that reference the
> game, without having to include the whole source of the game
> when the DXE is built.
>
> Unfortunately it doesn't work.
>
> When I try to build my DXE that uses functions from SYSLIB, it
> tries to resolve all the symbols in THAT. This is precisely what
> I DON'T want it to do.
> Syslib is there to fill in EXISTING fixups, not to create new ones.
>
> What format does my system library need to be in? .o or .a?
> What needs doing to dxegen.c to make it work?
>
> Any suggestions?
>
I've got a suggestion if it's appliable:
define a structure containing pointers to functions that need
to be called from the dxe and in the dxe and make the dxe
return it at load time:
struct dxe_interface {
/* These are the functions exported by the dxe */
void (*initialize)(void);
void (*do_funky_stuff)(void);
void (*shutdown)(void);
/* Theses are the functions called by the dxe
* and must be filled in by the main program */
void *(*malloc)(size_t);
int (*get_dos_mem_selector)(void);
void (*crash_system)(void);
};
Now, your dxe returns a pointer to this structure (which is
static within the dxe) when it loads. You fill in the
called-by-dxe members (not necessarily functions, may be data
members as well of course) and call the dxe_interface->initialize().
The most common C library functions (malloc in this case)
have to be used this way too, since otherwise the dxe gets its own
copy of them and most of them are not reentrant thus can skrew up.
Is this any good at all?
Martynas
- Raw text -