delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/07/22/08:18:57

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: "Dave Korn" <dk AT artimi DOT com>
To: <cygwin AT cygwin DOT com>
Subject: RE: DLLs and LoadLibrary
Date: Thu, 22 Jul 2004 13:16:15 +0100
MIME-Version: 1.0
In-reply-to: <40FF6963.3030001@berezniker.com>
Message-ID: <NUTMEGXdxxHXWfrHiig000009f5@NUTMEG.CAM.ARTIMI.COM>
X-OriginalArrivalTime: 22 Jul 2004 12:16:16.0015 (UTC) FILETIME=[AFC231F0:01C46FE5]

> -----Original Message-----
> From: cygwin-owner On Behalf Of Vadim Berezniker
> Sent: 22 July 2004 08:15

> Jani tiainen wrote:
> 
> > Vadim Berezniker wrote:
> >
> >> I followed the FAQ and the various mailing list messages 
> and was able 
> >> to build a dll that I can load with LoadLibrary.
> >> The code inside the DLL makes calls to code in other libraries and 
> >> for the most part this is okay.
> >> When I make calls to one library, everything is OK. As soon as I 
> >> uncomment one line which is simply a call to a function in another 
> >> library, the resulting DLL cannot be loaded with LoadLibrary.
> >
> >
> > There is various reasons why loading fails. If you get NULL from 
> > LoadLibrary call, use GetLastError to retrieve real reason 
> for error.
> >
> > BTW, where are you calling those LoadLibrary calls? It's 
> unsafe (and 
> > not really recommended) to call them in DllMain.
> >
> LoadLibrary never returns. An exception occurs within LoadLibrary. 
> However if I comment that one line, it loads the library just fine.
> I'm not calling LoadLibrary from a DLL.

  If there's an exception in LoadLibrary when your dll contains a call to
this secondary dll, I can think of two possibilities:

1)  The secondary dll has some kind of corruption or problem with it's
format that causes the dll loader to crash.

2)  The secondary dll has a bug in its DllMain routine.

  The only real difference you're making to the situation by adding the
function call to your dll is that a) when your dll is loaded, the loader has
to also load the secondary dll, and b) that implies that the secondary dll's
DllMain will be called during the loading process.  So I expect one of these
two effects is to blame.


    cheers, 
      DaveK
-- 
Can't think of a witty .sigline today....


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


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