From 14bcb3ad18e211e3b172c875512bdb754fdef052 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Mon, 5 Jan 2015 00:16:00 -0800 Subject: [PATCH] win-capture: Change inject-hook intervals This makes a minor adjustment to the interval at which the inject helper tries to post the inject message to the target process. Only 2 seconds before, now up to 4 seconds, with the PostThreadMessage called every half second for the duration. The reason I did this is because I noticed that on rare occasions that it wouldn't hook due to the low interval; usually just because the target process is busy and isn't able to process its message queue, and therefor the hook wouldn't go through due to the fact that SetWindowsHookEx won't inject until the set event has occurred. The inject helper program would just close before the thread message had finally been processed, which would cancel the SetWindowsHookEx hooking. --- plugins/win-capture/inject-helper/inject-helper.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/win-capture/inject-helper/inject-helper.c b/plugins/win-capture/inject-helper/inject-helper.c index a52d4e4ea..0a04cba03 100644 --- a/plugins/win-capture/inject-helper/inject-helper.c +++ b/plugins/win-capture/inject-helper/inject-helper.c @@ -61,12 +61,10 @@ static int inject_library_safe(DWORD thread_id, const char *dll) return -5; } - for (i = 0; i < 20; i++) + for (i = 0; i < 8; i++) { + Sleep(500); PostThreadMessage(thread_id, WM_USER + 432, 0, (LPARAM)hook); - Sleep(1000); - for (i = 0; i < 20; i++) - PostThreadMessage(thread_id, WM_USER + 432, 0, (LPARAM)hook); - Sleep(1000); + } return 0; }