delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/08/01/11:23:50

X-Spam-Check-By: sourceware.org
Message-ID: <46B0A563.B672E63@dessent.net>
Date: Wed, 01 Aug 2007 08:23:15 -0700
From: Brian Dessent <brian AT dessent DOT net>
X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: is LD_PRELOAD available in cygwin?
References: <46B02E5F DOT 3080408 AT gmail DOT com>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
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
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id l71FNYWV014095

Günther Jedenastik wrote:

> using g++ to compile a dll which overload's the open(); glibc system call.
> Using preload i want to load my own dll with my open(); function. using 
> dlsym(); i try to load the glibc open(); function.

Cygwin does not use glibc.  glibc is Linux-specifc.

> Q1: is LD_PRELOAD available in cygwin? if yes, any hint's why it's not
> working? (maybe some configuration problem or so, any hint would be
> helpfull)
> Q2: are there any alternative ways to preloading causing the same result?

No, LD_PRELOAD is an aspect of ELF dynamic loaders and is not available
on Windows.  It's not something that Cygwin can provide since it is a
function provided by the program loader, i.e. the operating system.

If you have source of the target program and can modify it, then you can
dlopen() the DLL and use dlsym() to get a function pointer to the
replacement open() function, and then use that function pointer instead
of the libcall throughout.  But if you want this to be transparent, i.e.
without modifying or recompiling the target, then you'll have to use
some kind of low-level Windows-specific hackery because this is not a
feature the PE loader has.

http://research.microsoft.com/sn/detours/
http://www.internals.com/articles/apispy/apispy.htm

Brian

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