8000 Invalid INVALID_HANDLE_VALUE values · Issue #3540 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content
Invalid INVALID_HANDLE_VALUE values #3540
@0xfeeddeadbeef

Description

@0xfeeddeadbeef

INVALID_HANDLE_VALUE should be defined as IntPtr(-1) and not as IntPtr.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, CreateFile fails, 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 from GetCurrentProcess() Win32 API function is compared to INVALID_HANDLE_VALUE. This time value is correct, but its usage is incorrect, because GetCurrentProcess() pseudo-handle is exactly same as value of INVALID_HANDLE_VALUE: both are ((HANDLE)-1). Because of this IsWow64() function always returns FALSE. 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

> $PSVersionTable
Name                           Value
----                           -----
SerializationVersion           1.1.0.1
PSVersion                      6.0.0-alpha
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSEdition                      Core
BuildVersion                   3.0.0.0
CLRVersion
GitCommitId                    v6.0.0-alpha.18-9-g8d4db01a5d4b5dcd981ef216d3d7f24b484c7c60-dirty
PSRemotingProtocolVersion      2.3
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0