Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Invalid INVALID_HANDLE_VALUE values #3540

Copy link
Copy link
@0xfeeddeadbeef

Description

@0xfeeddeadbeef
Issue body actions

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
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    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

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.