public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Olivia Nelson <the.warl0ck.1989@gmail.com>
To: cygwin@cygwin.com
Subject: Re: DllMain not called in CreateRemoteThread
Date: Sat, 08 Feb 2020 00:12:00 -0000	[thread overview]
Message-ID: <CAJZVxR==EeX0y02Y5_ZhoFKnFCMmONg_-7jzv93pZqmrSdK-pA@mail.gmail.com> (raw)
In-Reply-To: <5a745b381650978f29cb650757ffa3c4acc62f49.camel@Askesis.nl>

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

  reply	other threads:[~2020-02-08  0:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-07  8:47 DllMain not called Olivia Nelson
2020-02-07 14:49 ` Marco Atzeri
2020-02-07 15:07   ` Olivia Nelson
2020-02-07 15:46     ` Marco Atzeri
2020-02-07 18:19     ` Joost Kraaijeveld
2020-02-07 19:10     ` Joost Kraaijeveld
2020-02-08  0:12       ` Olivia Nelson [this message]
2020-02-08  5:40         ` DllMain not called in CreateRemoteThread Marco Atzeri
2020-02-09 14:52           ` Olivia Nelson
2020-02-10 18:50             ` Andrey Repin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJZVxR==EeX0y02Y5_ZhoFKnFCMmONg_-7jzv93pZqmrSdK-pA@mail.gmail.com' \
    --to=the.warl0ck.1989@gmail.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).