Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Date: Mon, 7 Aug 2000 00:01:50 -0400 From: Chris Faylor To: "Brian D. Carlstrom" Cc: cookj AT cs DOT man DOT ac DOT uk, cygwin AT sourceware DOT cygnus DOT com Subject: Re: dlopen a.exe Message-ID: <20000807000150.A10713@cygnus.com> Reply-To: cygwin AT sources DOT redhat DOT com Mail-Followup-To: "Brian D. Carlstrom" , cookj AT cs DOT man DOT ac DOT uk, cygwin AT sourceware DOT cygnus DOT com References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.6i In-Reply-To: ; from bdc@zurich.ai.mit.edu on Sun, Aug 06, 2000 at 08:45:17PM -0700 On Sun, Aug 06, 2000 at 08:45:17PM -0700, Brian D. Carlstrom wrote: >This is from a while back, I haven't been on the list for a while, but >I'm trying to upgrade a tool called scsh from cygwin-b20 and I came >across this: > >Chris Faylor wrote: >> On Wed, May 31, 2000 at 11:32:36AM +0100, Jon Cook wrote: >> > Can you use dlopen with the pathname set to 0 to open a.exe? >> No. >> cgf > >huh? This used to work, and is required for my tool unless I want to >totally rework it. I copied all sorts of crap with dlltool and gcc >-Wl,scshvm.exp from the tcl port, as well as hacking my autocong >configure script. Perhaps I misunderstood the question. Take a look at the source code for dlopen. If you pass a NULL as the first parameter it returns a handle to the current program, not an arbitrary program called "a.exe". Regardless, you won't be able to retrieve anything with dlsym() unless either the function/variable has been defined with the __declspec(dllexport) attribute or you've included it in a linker .def file. cgf >This small program used to work. The mesage was old. Is there any way to >do this now or am I going to have to stay with cygwin-b20 indefinitely? > >-bri > >#include >#include >fnord() >{ > int i=42; >} >main() >{ > void *self, *ptr1, *ptr2; > self=dlopen(NULL,RTLD_LAZY); > if (self) { > printf("foo\n"); > ptr1=dlsym(self,"fnord"); > ptr2=dlsym(self,"_fnord"); > printf("ptr1 %x\n", ptr1); > printf("ptr2 %x\n", ptr2); > if(ptr1 && !ptr2) { > printf("bar\n"); > exit(0); > } > printf("qux\n"); > } > printf("baz\n"); > exit(1); >} -- cgf AT cygnus DOT com Cygnus Solutions, a Red Hat company http://sourceware.cygnus.com/ http://www.redhat.com/ -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com