X-Recipient: archive-cygwin@delorie.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:references:in-reply-to:from:date
	:message-id:subject:to:content-type; q=dns; s=default; b=HpejE2K
	oxz8swFw2K7RjWbj81rwHUihfWaL5UTbB2MDpIKq/SI0Bvcq0fEZJh9wqsEwofbn
	MtsxRJfw8147Cn66CzBKFTAXP4ECJjUDjEUcNhGHifcOMH70rI5hxcRiwisO/oVK
	C+eopv8EalK1nFO3ZmExd+HAddPuGpvmhOSg=
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:references:in-reply-to:from:date
	:message-id:subject:to:content-type; s=default; bh=BmerAV8j3a5mJ
	Lnak59d6bSYXxo=; b=cn2MepiXYUaNlybmYJol3Jar5E1XnJEI7iFXmcWWUwp4w
	owpthcbfktmeac1TdlWfV+qf5mcS6a1E3yDuqpRDuRtLOF1mo2JQRummRAYMh0GY
	rdAc5F4oIjxdjm+epVy0avNITlAASfqDQbB144BXTzmqeXPntkVUHTepccHbDs=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=0.4 required=5.0 tests=AWL,BAYES_50,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.1 spammy=problemshtml, problems.html, UD:problems.html, docshtml
X-HELO: mail-vs1-f44.google.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;        d=gmail.com; s=20161025;        h=mime-version:references:in-reply-to:from:date:message-id:subject:to;        bh=zzeEXsU/x6w/ZMdXr9FSkXa8kg2iu9pTrHcZ6QqZ3wI=;        b=VIsLWnpIoCw7gNP7YjgAGRPY9wcHnxVmKVtusSH5niTxturt+xpepT19xO45kln0ES         dVHy5w16pT1XCgoz27FOkgU6wP9TScIRJMskoc83sLfdsK6BxtHWePcgAA5rVWg+AjBA         fcsEIaVlnHKMcL8ioix84ShySHNFONZjmfVmC4ipRYC/ciNVvbJVadeqOb0RCWYp8wPQ         I1/Cznhbgos5xoeuhjETP2jkucGCSBAsbFI/F4tyjij3SZX4NxJg7YwI2LbIEdqhoNGJ         WXBBTmIG5mYw7z9dsLwedDRUKzQ9gmGlgvLaOVq1cC69s4cRpX8c78ZCHq5mrDdhm/Vr         b3uA==
MIME-Version: 1.0
References: <CAJZVxRkk3K6jOtiXUsW6iOFzDAGm4yf393zcYTYphfCKY-qSQg@mail.gmail.com> <c9486fc4-b69f-2704-b759-ce8a5ab23965@gmail.com> <CAJZVxR=gFdeYeZYorqmxOL_BKXcrO22EqsMbteD-h+qT9igngg@mail.gmail.com> <5a745b381650978f29cb650757ffa3c4acc62f49.camel@Askesis.nl>
In-Reply-To: <5a745b381650978f29cb650757ffa3c4acc62f49.camel@Askesis.nl>
From: Olivia Nelson <the.warl0ck.1989@gmail.com>
Date: Sat, 8 Feb 2020 08:12:32 +0800
Message-ID: <CAJZVxR==EeX0y02Y5_ZhoFKnFCMmONg_-7jzv93pZqmrSdK-pA@mail.gmail.com>
Subject: Re: DllMain not called in CreateRemoteThread
To: cygwin@cygwin.com
Content-Type: text/plain; charset="UTF-8"
X-IsSubscribed: yes

Sorry, I made a mistake. I've updated the title ..

To summarize:

1. I can load the DLL compiled with cygwin with LoadLibraryA,
     but not remotely with CreateRemoteThread.
2. The same DLL compiled with msvc works with both LoadLibraryA and
CreateRemoteThread

Answer to Joost:
constructor and destructor are called with LoadLibraryA, but not with
CreateRemoteThread either

Answer to Marco
1. I can't use mingw, it does not provide sys/XXX.h, e,g socket
2. I copied cygwin1.dll to system32, and it works outside cygwin environment

Here's a implementation of the DLL injector in C#:
https://codingvision.net/miscellaneous/c-inject-a-dll-into-a-process-w-createremotethread


On Sat, Feb 8, 2020 at 3:10 AM Joost Kraaijeveld
<J.Kraaijeveld@askesis.nl> wrote:
>
> Does
>
> static void __attribute__((constructor))
> static void __attribute__((destructor))
>
> work?
>
>
> See e.g.
> https://stackoverflow.com/questions/2053029/how-exactly-does-attribute-constructor-work
>
>
>
>
> --
> 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
>

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

