From e1480876360f7cb3b6b9fbec71f21c9b1f549bd0 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Mon, 31 Oct 2016 01:39:35 -0700 Subject: [PATCH] win-capture: Only duplicate to get cur thread handle Instead of calling OpenThread, use DuplicateHandle with the minimal access rights (SYNCHRONIZE) to be able to get the current thread handle within a UWP program. --- plugins/win-capture/graphics-hook/graphics-hook.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/win-capture/graphics-hook/graphics-hook.c b/plugins/win-capture/graphics-hook/graphics-hook.c index 8a0aff292..15b96efe0 100644 --- a/plugins/win-capture/graphics-hook/graphics-hook.c +++ b/plugins/win-capture/graphics-hook/graphics-hook.c @@ -791,8 +791,14 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID unused1) dll_inst = hinst; - HANDLE cur_thread = OpenThread(THREAD_ALL_ACCESS, false, - GetCurrentThreadId()); + HANDLE cur_thread; + bool success = DuplicateHandle(GetCurrentProcess(), + GetCurrentThread(), + GetCurrentProcess(), &cur_thread, + SYNCHRONIZE, false, 0); + + if (!success) + DbgOut("Failed to get current thread handle"); /* this prevents the library from being automatically unloaded * by the next FreeLibrary call */