delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/21/15:04:07

Message-Id: <199809211907.UAA13417@rochefort.ns.easynet.net>
Comments: Authenticated sender is <mert0407 AT sable DOT ox DOT ac DOT uk>
From: "George Foot" <george DOT foot AT merton DOT ox DOT ac DOT uk>
To: Doug Gale <dgale AT mailexcite DOT com>
Date: Mon, 21 Sep 1998 20:00:16 +0000
MIME-Version: 1.0
Subject: Re: DJGPP and windows?
Reply-to: mert0407 AT sable DOT ox DOT ac DOT uk
CC: djgpp AT delorie DOT com

On 21 Sep 98 at 2:11, Doug Gale wrote:

> What exactly do you mean by "can't access the location it
> points to". Do you get a GPF or page fault or something?

It generated a SIGSEGV (RSXNT popped up a dialog telling me 
that).

> Another idea would be to make a DLL as described in the
> RSXNTDJ help with a variable in it. Then link to that DLL
> and see if you can access the variable the same way.

Yes, I tried the RSXNTDJ DLL examples, which worked fine.

The problem is now solved, though.  It was due to a bug (IMHO) 
in makelib, which I've corrected in my version.  Perhaps we 
need somewhere to share these patches.

I really don't know much about DLL internals, but looking
through the makelib source code (or more accurately the
dllexp.c source file) I see that the DLL has an export table,
which contains a range of information.  It has a certain
number of `functions' (pointers into the data) and a number of
`names' (which are the symbol names).  These numbers aren't
the same though -- the number of functions can be larger than
the number of names.  The original dllexp.c code read the
first NumberOfNames entries from each of a few lists (function
pointers, names, ordinal numbers) -- but this is wrong.  What
you need to do is for each of these, read its name and ordinal
number, then use the ordinal number as an index into the
function array.  Maybe someone who knows more can confirm
this; it was really just pure guesswork, but the resulting DLL
now works fine.

The problem I mentioned was due to the fact that Stefan had 
spaced out his ordinal numbers.  This meant that there were 
many function pointers that did not correspond to any symbol; 
these were set to 0 (by MSVC).  Then the old dllexp.c tried to 
match these up to symbols.  But what on earth could a value of 
0 mean?  It's basically a NULL pointer.  Elsewhere in dllexp.c 
where it decides which symbols are variables and which are 
functions it uses the function pointer -- if the pointer lies 
in the .text segment or the .rdata segment then it's a 
function, otherwise it's data.  It makes a special case of zero 
function pointers, for some bizarre reason, assuming that 
they're code.  I really have no idea what this achieves.  It 
made everything more confusing because now the pointer wasn't 
NULL (which would have stood out like a sore thumb) -- it was 
the code for "jmp *0" IIRC.

If anyone would like the patch to dllexp.c I can post it here.  
I think you need it if you're making an import library from a 
DLL which either doesn't assign all ordinal numbers to symbols, 
or which doesn't list the symbols in the correct order in the 
DLL.

I also couldn't get the makefile to work to rebuild makelib -- 
I did it by hand in the end, making it a dedicated GUI 
application.

> >ones.  I mentioned it anyway, partly because you might like to 
> >do the same, and partly in case it can have caused the problem.
> >
> >I described my installation procedure on the Allegro mailing 
> >list yesterday; I can send you a copy if you need to see it.

I've also uploaded my instructions to a web site.

    http://www.canvaslink.com/gfoot/winallegro/

There are links to instructions for installing RSXNTDJ and for 
installing WinAllegro to work with it.  I'd appreciate comments 
on the RSXNTDJ instructions, especially if they are likely to 
cause problems using it.

> The licence agreement is questionable. It says send money to
> the author, but I have been unable to locate him and the
> supplied email address doesn't work.

The author of WinAllegro, Stefan Schimanski, told me that he 
lives near the author.

> I find the requested commercial licencing fee very
> reasonable ($40) considering how much work it must have been
> to get import libraries and building dlls working.

I agree that it is reasonable, if you're going to make money 
out of the use of the program.

Does anyone know where the source code to NTBIND can be found?  
I want to add some switches to it -- at the moment it makes 
console applications if it finds a `main' function, whether or 
not a `WinMain' exists, and I need a switch to tell it exactly 
what type of application to make.  This is because WinAllegro 
provides a wrapper WinMain function that calls `main' as if the 
program was a normal console application.  I can't use this 
wrapper because as soon as I make `main' NTBIND decides it 
really is a console application.

-- 
george DOT foot AT merton DOT oxford DOT ac DOT uk

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019