delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/05/02/10:42:18

From: mlx AT san DOT rr DOT com (Steve Biskis)
Subject: Re: Delphi problem with DLL
2 May 1998 10:42:18 -0700 :
Message-ID: <199805020112.SAA02582.cygnus.gnu-win32@prefetch.san.rr.com>
Reply-To: <mlx AT san DOT rr DOT com>
Mime-Version: 1.0
To: "Laurent Merckx" <Laurent DOT merckx AT eurodb DOT be>
Cc: <gnu-win32 AT cygnus DOT com>

Yep,  but only finally with beta # 19,  it just plain dun't werk with
anythang earlier.

Its a clever hack I adapted from Ton Van Overbeek
<tvoverbe AT wk DOT estec DOT esa DOT nl> :
Just make this your entry module & you can even make calls from as
brain-dead
an .exe as Excel spreadsheets !!!

My version (BTW: I do lots of ObjC & NO C++, not ever) 

BEGIN
----------

#include <stdio.h>
#include <windows.h>
#include <objc/runtime.h>

extern void __main( void );
extern struct _reent *__imp_reent_data;
extern void cygwin_crt0( void *mainFunc );

static struct Globals
{
  HANDLE cygwinDLLEvent;
  HANDLE cygwinDLLThread;
} G;

static int MLXCygwinDLLCallback( int argc, char **argv )
{
  //MessageBox(0,"Entered ...","CygwinDLL",MB_OK);
  __main();   // Initialize ObjC & C++ runtime ...
  G.cygwinDLLEvent=CreateEvent(NULL,FALSE,FALSE,NULL);
  WaitForSingleObject(G.cygwinDLLEvent,INFINITE);
  //MessageBox(0,"Exits ...","CygwinDLL",MB_OK);
  return 0;
}

static DWORD WINAPI initCygwinDLL( void *dummy )
{
  //MessageBox(0,"Pre: Cygwin init.","initCygwinDLL()",MB_OK);
  cygwin_crt0(MLXCygwinDLLCallback);
  //MessageBox(0,"Post: Cygwin init.","initCygwinDLL()",MB_OK);
  return 0;
}

BOOL WINAPI DLLMain( HANDLE h, DWORD reason, void *ptr )
{
  DWORD threadId;
  _impure_ptr=__imp_reent_data;
  switch ( reason )
  {
    case DLL_PROCESS_ATTACH:
      //MessageBox(0,"Entered ...","DLLMain(PROC_ATTACH)",MB_OK);
      G.cygwinDLLThread =
      CreateThread(NULL,0,initCygwinDLL,(void *)NULL,0,&threadId);
      SetThreadPriority(G.cygwinDLLThread,THREAD_PRIORITY_HIGHEST);
      //MessageBox(0,"EXITS","DLLMain(PROC_ATTACH)",MB_OK); 
    break;
    case DLL_PROCESS_DETACH:
      //MessageBox(0,"Entered ...","DLLMain(PROC_DETACH)",MB_OK);
      PulseEvent(G.cygwinDLLEvent);
      //WaitForSingleObject(G.cygwinDLLThread,INFINITE);
      //MessageBox(0,"EXITS","DLLMain(PROC_DETACH)",MB_OK);
    break;
    case DLL_THREAD_ATTACH:
    break;
    case DLL_THREAD_DETACH:
    break;
  }
  return 1;
}

asm(".section .idata$3\n" ".long 0,0,0,0, 0,0,0,0");

------------------
END

Just uncomment the test code & you'll get the flow ...

If/when you improve upon it, let me know !


Your welcome in arrears,

da bisk.


----------
> From: Laurent Merckx <Laurent DOT merckx AT eurodb DOT be>
> To: mlx AT san DOT rr DOT com
> Subject: Delphi problem with DLL
> Date: Thursday, April 30, 1998 6:12 AM
> 
> > Hi,
> >
> > I've been quietly following this list for some time, haven't really had
any
> > problems that I couldn't eventually overcome (w/list's help) till now.
> >
> > Here's my problem:
> >
> > Trying to initialize the cygwin32 runtime via a call from my own dll.
> > I've got a cygwin generated dll of my own home-brew that works fine in
> > delphi executables until I try to call malloc & the like.  So I've >
turned
> > to trying to init cygwin.dll from my dll.
> 
> Hello,
> I have the same problem but when I search the archive mail-list of
> Cygnus, I didn't find any answer of your question.
> Have you solved your problem ? If yes, can you tell me how you did ?
> 
> Thank you in advance
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


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