Unable to create named pipe on certain WS2012, Win 10 Pro machines #280
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In a lab setting of multiple Windows machines, several machines were unable to create a named pipe server:
It is unclear why some of these machines failed, because other machines with the same OS were not affected.
This issue was solved by modifying the ObjectAttributes.Attributes flag being passed to
NtCreateNamedPipeFile
. This change did not impact previously working machines so it appears safe for general use.Background:
Inspecting the output from the system call, ntCreateNamedPipeFile() returned the following:
Retval: 3221225530
Status: -1073741766
There was no named pipe present in the PowerShell output:
Get-ChildItem -Path "\\.\pipe\"
To rule out machine specific issues, an alternate named pipe server was built from the Named Pipe C++ example from Microsoft: https://learn.microsoft.com/en-us/windows/win32/ipc/multithreaded-pipe-server
Notably, this example uses
CreateNamedPipeW
versusNtCreateNamedPipeFile
. The named pipe was successfully created with retval=0, and the pipe was observed in the PowerShell output:Get-ChildItem -Path "\\.\pipe\"
Now, there were 2 executables with different retvals from the same machine.
Knowing that
CreateNamedPipeW
eventually callsNtCreateNamedPipeFile
, WinDBG was used to trace the call.The outcome of the investigation was that
CreateNamedPipeW
was passing a 0x40 in ObjectAttributes.Attributes flag, whereas go-winio was passing 0x0. The issue was resolved by setting ObjectAttributes.Attributes to 0x40, corresponding to OBJ_CASE_INSENSITIVE.