Skip to content

Fix for Antivirus Software block#192

Open
haobibo wants to merge 3 commits intomasterfrom
antivirus
Open

Fix for Antivirus Software block#192
haobibo wants to merge 3 commits intomasterfrom
antivirus

Conversation

@haobibo
Copy link
Copy Markdown

@haobibo haobibo commented Aug 31, 2022

Refer to: #142

I'm not sure this is necessary, but it seems worth doing.
Some antivirus programs override CreateProcess() and run the child process
initially in a sandbox, then after deciding the process is OK, they run it
again for real.  The initial instance of winpty-agent.exe connects to
libwinpty's control pipe, then when the actual agent process starts later,
it can't connect to the pipe because the pipe is in a disconnected/broken
state.

Work around the problem by creating multiple instances of the control pipe
in libwinpty, then waiting on any of them to connect.  An error on one pipe
is logged to trace() but otherwise ignored as long as one of the pipes
eventually connects. The error isn't reported until the agent dies or the
connection has timed out.

In practice, the initial sandbox connection's ConnectNamedPipe operation
will probably succeed, but its child PID will be wrong, so this function
quietly ignores verifyPipeClientPid failures (as long as one pipe
succeeds).

Fixes #142
The __attribute__((used)) annotation breaks the MSVC build.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants