Windows Attach API client creates named pipe to communicate with target VM (CreateNamedPipe).
It makes sense to update the pipe mode:
Add FILE_FLAG_FIRST_PIPE_INSTANCE to the open mode.
The pipe is created with max instances argument == 1, so if another clients tries to create a pipe with the same name, it fails with ERROR_PIPE_BUSY.
But max instances value is set by the 1st creator of the pipe.
With FILE_FLAG_FIRST_PIPE_INSTANCE CreateNamedPipe fails with ERROR_ACCESS_DENIED error.
Add PIPE_REJECT_REMOTE_CLIENTS to the pipe mode.
Attach API works only with local JVM processes, and the flag causes connections from remote clients are automatically rejected.
It makes sense to update the pipe mode:
Add FILE_FLAG_FIRST_PIPE_INSTANCE to the open mode.
The pipe is created with max instances argument == 1, so if another clients tries to create a pipe with the same name, it fails with ERROR_PIPE_BUSY.
But max instances value is set by the 1st creator of the pipe.
With FILE_FLAG_FIRST_PIPE_INSTANCE CreateNamedPipe fails with ERROR_ACCESS_DENIED error.
Add PIPE_REJECT_REMOTE_CLIENTS to the pipe mode.
Attach API works only with local JVM processes, and the flag causes connections from remote clients are automatically rejected.