参考
- wine 8.14
-
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-waitforinputidle
作用:等待特定进程完成它的初始化输入,等待用户输入(且没有挂起的输入)直到等待时间超时。
DWORD WINAPI NtUserWaitForInputIdle(HANDLE process, DWORD timeout, BOOL wow)
{
......
SERVER_START_REQ(get_process_idle_event)
{
...
handles[1] = wine_server_ptr_handle(reply->event);
}
...
if(!handles[1]) return WAIT_FAILED; //no event to wait on
start_time = NtGetTickCount();
...
for(;;)
{
ret = NtUserMsgWaitForMultipleObjectsEx(2,handles, timeout-elapsed, QS_SENDMESSAGE, 0);
switch(ret)
{
case WAIT_OBJECT_0:
return 0;
case WAIT_OBJECT_0+2:
process_sent_messages();
break;
case WAIT_TIMEOUT:
case WAIT_FAILED:
return ret;
default:
return 0;
}
if(timeout != INFINITE)
{
elapsed = NtGetTickCount() - start_time;
if(elapsed > timeout)
break;
}
}
return WAIT_TIMEOUT;
}
调用get_process_idle_event查看是否有需要等待的输入事件,如果存在,则调用函数NtUserMsgWaitForMultipleObjectsEx根据输入事件的不同状态进行处理。