delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2013/10/26/02:33:13

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:content-type
:content-transfer-encoding:date:from:to:subject:message-id; q=
dns; s=default; b=DHlnDIA8x59py3OAkcBGZ14nI2WkmtoL1Sf5U8QV38OJwF
Ralkg1lmekFfdg9wVjozD08oWJaZJ+vSA1YeDgWkgb1eVsva7IByRXoAKAWoWnyS
I8xuJbU8zdw+TSc8FGNzhKcNMPqfOo9h2kVe9EnG8CkOqKvBfcQDT+rMJfLLU=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:content-type
:content-transfer-encoding:date:from:to:subject:message-id; s=
default; bh=PeLqB3tY5UlrrRtRzceSJz00X2c=; b=LR0B54J4ZuPD52N+j0aC
yC6955X5FusDft1z1a8wHuB5uPl6B0IHXFAn4qxZNY1ktL+1GO7rFM996XfauWZ9
1zAJUvxuqsfSDlW6ClABy4TvTzwVfuQ3sAZu0iTjspSVkPvaZGWULomMhdzRJFU8
92n6h8liuclGGyIiJOt0D7s=
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
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: Yes, score=5.1 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS autolearn=no version=3.3.2
X-HELO: diserzione.investici.org
X-DKIM: OpenDKIM Filter v2.6.8 diserzione.investici.org D742B181147
MIME-Version: 1.0
Date: Sat, 26 Oct 2013 10:32:51 +0400
From: niXman <i DOT nixman AT autistici DOT org>
To: Cygwin <cygwin AT cygwin DOT com>
Subject: Hooks do not =?UTF-8?Q?work=3F?=
Message-ID: <81f61e1925b5d6639ac9ba6a64b80ae7@autistici.org>
X-Sender: i DOT nixman AT autistici DOT org
User-Agent: autistici.org webmail
X-IsSubscribed: yes

Hi,

I try to create the hooks for open()/fopen().

hook code:
#include <stdio.h>

int open(const char *fname, int mode, ...) {
	printf("fname=%s\n", fname);
}

FILE* fopen(const char *fname, const char *mode) {
	printf("fname=%s\n", fname);
}


test code:
#include <stdio.h>

int main() {
	FILE *file = fopen("main.c", "rb");
	if ( file ) fclose(file);
}


compiled as:
gcc hook.c -shared -oopenhook.dll
gcc main.c -omain

run as:
LD_PRELOAD=/home/niXman/openhook.dll ./main

But a can't see the output.
What I am doing wrongly?

Thanks!

-- 
Regards, niXman
___________________________________________________
Dual-target(32 & 64-bit) MinGW-W64 compilers for 32 and 64-bit Windows:
http://sourceforge.net/projects/mingw-w64/
___________________________________________________
Another online IDE: http://liveworkspace.org/

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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