delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/06/22/13:18:42

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
To: cygwin AT cygwin DOT com
From: Patrick Rotsaert <patrick DOT rotsaert AT tts-online DOT be>
Subject: Re: How to make DLLs in cygwin for MSVC and BCB
Date: Wed, 22 Jun 2005 18:17:58 +0200
Lines: 66
Message-ID: <d9c2k1$q7v$1@sea.gmane.org>
References: <d9bu24$aa1$1 AT sea DOT gmane DOT org> <42B9854D DOT DBC0BD AT dessent DOT net>
Mime-Version: 1.0
User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
In-Reply-To: <42B9854D.DBC0BD@dessent.net>
X-IsSubscribed: yes

> http://cygwin.com/faq/faq.html#TOC102
> 
> Note that this just references loading cygwin1.dll and getting it
> initialized.  If you have your own DLL that depends on cygwin1.dll you
> will probably first have to load and initialize Cygwin, and then load
> your own DLL.

Loading the cygwin1.dll dynamically is certainly an option. I tried it, 
although I'm not quite sure how to make sure I have "4K of scratch space 
at the bottom of the stack", like the faq says.

My test program crashes once cygwin_dll_init is called. :-((

#include <windows.h>
#include <stdio.h>

int main(void)
{
	char blah[4096];
	int rc;
	
	HMODULE h = LoadLibrary("cygwin1.dll");
	printf("LoadLibrary: %d\n", (int)h);
	if ((int)h < 32) {
		return 1;
	}
	
	void (*cyginit)() = (void (*)())GetProcAddress(h, "cygwin_dll_init");
	printf("cyginit: %p\n", cyginit);
	if (cyginit) {
		printf("calling...\n");
		cyginit();
		printf("call ok\n");
	}
	
	FreeLibrary(h);
	return 0;
}

This is the program output:

LoadLibrary: 1627389952
cyginit: 61006F00
calling...
       6 [main] ? 2820 handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
Exception: STATUS_ACCESS_VIOLATION at eip=610B93F3
eax=0012F084 ebx=003A0043 ecx=003A0043 edx=00130000 esi=000000A8 
edi=00000000
ebp=0012EEDC esp=0012EEDC program=, pid 0, thread main
cs=001B ds=0023 es=0023 fs=003B gs=0000 ss=0023
Stack trace:
Frame     Function  Args
0012EEDC  610B93F3  (003A0043, 0012EE70, 0012EF0C, 610BB331)
0012EF0C  610B92E0  (61128014, 6110F1B4, 00000000, 00000000)
0012EF4C  61006775  (00000000, FFFFFFFE, 00000504, 6110F1B4)
0012EF7C  61006FBD  (0040A0B8, 7FFD8000, 00000001, 00000080)
0012FF8C  004011AE  (00000001, 00D621CC, 00D6267C, C10040A1)
0012FFB8  00407CF2  (0040A0B8, 7C816D4F, C10040A1, 13A302E0)
End of stack trace


What is going wrong here?

Thanks,
Patrick.



--
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