Browse Source

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.
jp9000 9 years ago
parent
commit
e148087636
1 changed files with 8 additions and 2 deletions
  1. 8 2
      plugins/win-capture/graphics-hook/graphics-hook.c

+ 8 - 2
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 */