Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Antivirus Software block #192

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Fix for Antivirus Software block #192

wants to merge 3 commits into from

Conversation

haobibo
Copy link

@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