Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Yano <takashi.yano@nifty.ne.jp>2022-07-28 15:58:04 +0300
committerTakashi Yano <takashi.yano@nifty.ne.jp>2022-07-28 17:38:44 +0300
commit28d69dc863a60dc8b997d7f8e025d46d4b57e097 (patch)
tree8f14f0070c8d3282365d25026083e7312abe8d9f
parent0853f89176eb66f50b015adfa6530983d3aa38ee (diff)
Cygwin: console: Add workaround for ConEmu cygwin connector.
- ConEmu cygwin connector conflicts with cons_master_thread since it does not use read() to read console input. With this patch, cons_master_thread is disabled in ConEmu cygwin connector.
-rw-r--r--winsup/cygwin/fhandler_console.cc33
1 files changed, 33 insertions, 0 deletions
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index e90b8d5ee..c7dc8c609 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -1602,6 +1602,8 @@ fhandler_console::dup (fhandler_base *child, int flags)
return 0;
}
+static void hook_conemu_cygwin_connector();
+
int
fhandler_console::open (int flags, mode_t)
{
@@ -1689,6 +1691,12 @@ fhandler_console::open (int flags, mode_t)
if (myself->pid == con.owner)
{
+#ifdef __x86_64__
+ if (GetModuleHandle ("ConEmuHk64.dll"))
+#else
+ if (GetModuleHandle ("ConEmuHk.dll"))
+#endif
+ hook_conemu_cygwin_connector ();
char name[MAX_PATH];
shared_name (name, CONS_THREAD_SYNC, get_minor ());
thread_sync_event = CreateEvent(NULL, FALSE, FALSE, name);
@@ -3980,6 +3988,7 @@ fhandler_console::set_console_mode_to_native ()
DEF_HOOK (CreateProcessA);
DEF_HOOK (CreateProcessW);
DEF_HOOK (ContinueDebugEvent);
+DEF_HOOK (LoadLibraryA); /* Hooked for ConEmu cygwin connector */
static BOOL WINAPI
CreateProcessA_Hooked
@@ -4021,6 +4030,24 @@ ContinueDebugEvent_Hooked
return ContinueDebugEvent_Orig (p, t, s);
}
+/* Hooked for ConEmu cygwin connector */
+static HMODULE WINAPI
+LoadLibraryA_Hooked (LPCSTR m)
+{
+ const char *p;
+ if ((p = strrchr(m, '\\')))
+ p++;
+ else
+ p = m;
+#ifdef __x86_64__
+ if (strcasecmp(p, "ConEmuHk64.dll") == 0)
+#else
+ if (strcasecmp(p, "ConEmuHk.dll") == 0)
+#endif
+ fhandler_console::set_disable_master_thread (true);
+ return LoadLibraryA_Orig (m);
+}
+
void
fhandler_console::fixup_after_fork_exec (bool execing)
{
@@ -4044,6 +4071,12 @@ fhandler_console::fixup_after_fork_exec (bool execing)
DO_HOOK (NULL, ContinueDebugEvent);
}
+static void
+hook_conemu_cygwin_connector()
+{
+ DO_HOOK (NULL, LoadLibraryA);
+}
+
// #define WINSTA_ACCESS (WINSTA_READATTRIBUTES | STANDARD_RIGHTS_READ | STANDARD_RIGHTS_WRITE | WINSTA_CREATEDESKTOP | WINSTA_EXITWINDOWS)
#define WINSTA_ACCESS WINSTA_ALL_ACCESS