From f409ee78ceb0244a2bc8a75e01828ade09a99fa8 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Sun, 2 Dec 2018 15:55:02 -0500 Subject: [PATCH] small fixes --- GUI/host/host.cpp | 6 ++++-- GUI/host/util.h | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/GUI/host/host.cpp b/GUI/host/host.cpp index fd5c63e..a578ddd 100644 --- a/GUI/host/host.cpp +++ b/GUI/host/host.cpp @@ -72,7 +72,9 @@ namespace InitializeSecurityDescriptor(&pipeSD, SECURITY_DESCRIPTOR_REVISION); SetSecurityDescriptorDacl(&pipeSD, TRUE, NULL, FALSE); // Allow non-admin processes to connect to pipe created by admin host SECURITY_ATTRIBUTES pipeSA = { sizeof(SECURITY_ATTRIBUTES), &pipeSD, FALSE }; - AutoHandle + + struct NamedPipeHandleCloser { void operator()(void* h) { DisconnectNamedPipe(h); CloseHandle(h); } }; + AutoHandle hookPipe = CreateNamedPipeW(HOOK_PIPE, PIPE_ACCESS_INBOUND, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE, PIPE_UNLIMITED_INSTANCES, 0, PIPE_BUFFER_SIZE, MAXDWORD, &pipeSA), hostPipe = CreateNamedPipeW(HOST_PIPE, PIPE_ACCESS_OUTBOUND, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE, PIPE_UNLIMITED_INSTANCES, PIPE_BUFFER_SIZE, 0, MAXDWORD, &pipeSA); ConnectNamedPipe(hookPipe, nullptr); @@ -117,7 +119,7 @@ namespace { std::thread([] { - for (std::wstring last; true; Sleep(50)) + for (std::wstring last; true; Sleep(500)) if (auto text = Util::GetClipboardText()) if (last != text.value()) Host::GetThread(CLIPBOARD)->AddSentence(last = text.value()); diff --git a/GUI/host/util.h b/GUI/host/util.h index 53cc087..70a4e60 100644 --- a/GUI/host/util.h +++ b/GUI/host/util.h @@ -4,7 +4,6 @@ namespace Util { - struct NamedPipeHandleCloser { void operator()(void* h) { DisconnectNamedPipe(h); CloseHandle(h); } }; std::optional GetModuleFileName(DWORD processId, HMODULE module = NULL); std::optional GetModuleFileName(HMODULE module = NULL); std::optional GetClipboardText();