-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Invalid INVALID_HANDLE_VALUE values #3540
Copy link
Copy link
Closed
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.The issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Milestone
Metadata
Metadata
Assignees
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.The issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
INVALID_HANDLE_VALUEshould be defined asIntPtr(-1)and not asIntPtr.Zero(It is declared as((HANDLE)-1)in Windows SDK headers).In PlatformInvokes.cs file, it is declared as
IntPtr.Zero. This value is used in SSHConnectionInfo.GetNamedPipeHandle(string pipeName) method, and, if for some reason,CreateFilefails, it will be unable to detect error condition. Attempt to use invalid named pipe handle will certainly not go well.In Process.cs file, it is declared as
IntPtr.Zero. Fortunately, this value is not used anywhere else, but, nonetheless, it is invalid.In MainEntry.cpp file, in
IsWow64()function, a pseudo-handle returned fromGetCurrentProcess()Win32 API function is compared toINVALID_HANDLE_VALUE. This time value is correct, but its usage is incorrect, becauseGetCurrentProcess()pseudo-handle is exactly same as value ofINVALID_HANDLE_VALUE: both are((HANDLE)-1). Because of thisIsWow64()function always returnsFALSE.IsWow64()function is used to decide correct file paths of Start Menu shortcuts for PowerShell and PowerShell ISE. Since FullCLR build is not supported currently, I can't verify this, but, just by reading code, it seems that shortcut targets will be messed up.Environment data