8000 Use IntPtr(-1) for INVALID_HANDLE_VALUE instead of IntPtr.Zero (#3544) · PowerShell/PowerShell@47ec6b2 · GitHub 8000
[go: up one dir, main page]

Skip to content

Commit 47ec6b2

Browse files
0xfeeddeadbeefdaxian-dbw
authored andcommitted
Use IntPtr(-1) for INVALID_HANDLE_VALUE instead of IntPtr.Zero (#3544)
- Fix incorrect handling of 'GetCurrentProcess()' API return value in 'IsWow64()' function (MainEntry.cpp) - Remove unused INVALID_HANDLE_VALUE field from 'ProcessNativeMethods' class (Process.cs)
1 parent 4ad4b19 commit 47ec6b2

File tree

3 files changed

+2
-8
lines changed

3 files changed

+2
-8
lines changed

src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2608,7 +2608,6 @@ internal struct JOBOBJECT_BASIC_PROCESS_ID_LIST
26082608
internal static class ProcessNativeMethods
26092609
{
26102610
// Fields
2611-
internal static readonly IntPtr INVALID_HANDLE_VALUE = IntPtr.Zero;
26122611
internal static UInt32 GENERIC_READ = 0x80000000;
26132612
internal static UInt32 GENERIC_WRITE = 0x40000000;
26142613
internal static UInt32 FILE_ATTRIBUTE_NORMAL = 0x80000000;

src/System.Management.Automation/utils/PlatformInvokes.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ internal struct PRIVILEGE_SET
558558
#if !UNIX
559559

560560
// Fields
561-
internal static readonly IntPtr INVALID_HANDLE_VALUE = IntPtr.Zero;
561+
internal static readonly IntPtr INVALID_HANDLE_VALUE = new IntPtr(-1);
562562
internal static UInt32 GENERIC_READ = 0x80000000;
563563
internal static UInt32 GENERIC_WRITE = 0x40000000;
564564
internal static UInt32 FILE_ATTRIBUTE_NORMAL = 0x80000000;

src/powershell-native/nativemsh/pwrshexe/MainEntry.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,11 +1139,6 @@ BOOL IsWow64()
11391139
{
11401140
HANDLE hCurrentProc = GetCurrentProcess();
11411141

1142-
if (INVALID_HANDLE_VALUE == hCurrentProc)
1143-
{
1144-
return false;
1145-
}
1146-
11471142
BOOL isWow64Process = FALSE;
11481143
BOOL ret = IsWow64Process(hCurrentProc, &isWow64Process);
11491144

@@ -1152,7 +1147,7 @@ BOOL IsWow64()
11521147
return isWow64Process;
11531148
}
11541149

1155-
return false;
1150+
return FALSE;
11561151
}
11571152

11581153
/**********************************************************************

0 commit comments

Comments
 (0)
0