delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/08/07/00:02:44

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
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 <cgf AT cygnus DOT com>
To: "Brian D. Carlstrom" <bdc AT ai DOT mit DOT edu>
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" <bdc AT ai DOT mit DOT edu>, cookj AT cs DOT man DOT ac DOT uk,
cygwin AT sourceware DOT cygnus DOT com
References: <E13Ldqn-0008PJ-00 AT nestle DOT ai DOT mit DOT edu>
Mime-Version: 1.0
User-Agent: Mutt/1.3.6i
In-Reply-To: <E13Ldqn-0008PJ-00@nestle.ai.mit.edu>; 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 <dlfcn.h>
>#include <stdio.h>
>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

- Raw text -


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