Calling ghc dll's with MSVC++ code

Kevin S. Millikin
Fri, 31 Jan 2003 12:51:56 -0600

>>>>> "Sigbjorn" == Sigbjorn Finne <> writes:

    Sigbjorn> That's the system trap interrupt (i.e., transition to
    Sigbjorn> ring 0 / kernel mode to perform a system call/service.)

Thanks!  I've learned more about Windows and DLLs in a few days than I
ever expected or wanted to.  The problem appears to be related to


int 0x2e is (presumably) an attempt to attach to the (my) DLL.
DllMain is (by design) not reentrant.  An attempt to create a thread
from DllMain would attach to the DLL, calling DllMain with a reason of
DLL_THREAD_ATTACH.  This latter call will hang until the original call
returns (which will never happen, now).  timeSetEvent creates a new
thread; and the callback is in the same DLL as the call to

The workaround appears to be to not put code that might possibly
create a new thread (that needs the DLL) in DllMain; instead such code
should go in an initialization function that is called after DllMain

I'll test it out and post code that corrects the example from the
User's Guide.
Kevin S. Millikin      Architecture Technology Corporation
Research Scientist     Specialists in Computer Architecture
(952)829-5864 x. 162