Skip to content

Commit cc952f7

Browse files
committed
Merge remote-tracking branch 'origin/pr/6' into accept-drivers
* origin/pr/6: Automatically accept test-signed driver installation
2 parents ab698e9 + 0b6a52a commit cc952f7

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

src/install-helper/install-helper.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,50 @@ DWORD StopXenbusMonitor()
127127
return status;
128128
}
129129

130+
/*
131+
* Automatically accept the prompt for installing test-signed drivers.
132+
*/
133+
DWORD ApproveTestSign(void* param)
134+
{
135+
while (TRUE)
136+
{
137+
HWND window = FindWindow(NULL, L"Windows Security");
138+
if (window)
139+
{
140+
DWORD fg_tid = GetWindowThreadProcessId(GetForegroundWindow(), NULL);
141+
DWORD tid = GetCurrentThreadId();
142+
// Without this, focus-stealing mitigations can prevent activating the target window.
143+
if (tid != fg_tid)
144+
AttachThreadInput(fg_tid, tid, TRUE);
145+
146+
BringWindowToTop(window);
147+
ShowWindow(window, SW_SHOW);
148+
149+
while (GetForegroundWindow() != window)
150+
Sleep(100);
151+
152+
INPUT inputs[2];
153+
inputs[0].type = INPUT_KEYBOARD;
154+
inputs[0].ki.wVk = 'i';
155+
inputs[1].type = INPUT_KEYBOARD;
156+
inputs[1].ki.dwFlags = KEYEVENTF_KEYUP;
157+
inputs[1].ki.wVk = 'i';
158+
SendInput(ARRAYSIZE(inputs), inputs, sizeof(INPUT));
159+
break;
160+
}
161+
else
162+
{
163+
Sleep(100);
164+
}
165+
}
166+
return 0;
167+
}
168+
130169
int WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nShowCmd)
131170
{
132171
(void)AddSymlinkRightToUsers();
172+
HANDLE thread = CreateThread(NULL, 0, ApproveTestSign, NULL, 0, NULL);
173+
if (WaitForSingleObject(thread, 30000) == WAIT_TIMEOUT)
174+
TerminateThread(thread, 0);
133175
return (int)StopXenbusMonitor();
134176
}

0 commit comments

Comments
 (0)