Skip to content

Commit b7abc3c

Browse files
committed
remove problem changes
1 parent f8a8643 commit b7abc3c

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FormatMessage.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ internal static unsafe string GetMessage(int errorCode, IntPtr moduleHandle)
5353
// We got back an error. If the error indicated that there wasn't enough room to store
5454
// the error message, then call FormatMessage again, but this time rather than passing in
5555
// a buffer, have the method allocate one, which we then need to free.
56-
if (Marshal.GetLastPInvokeError() == ERROR_INSUFFICIENT_BUFFER)
56+
if (Marshal.GetLastWin32Error() == ERROR_INSUFFICIENT_BUFFER)
5757
{
5858
IntPtr nativeMsgPtr = default;
5959
try

src/libraries/Common/src/System/IO/Win32Marshal.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ internal static class Win32Marshal
1616
/// including the specified path in the error message.
1717
/// </summary>
1818
internal static Exception GetExceptionForLastWin32Error(string? path = "")
19-
=> GetExceptionForWin32Error(Marshal.GetLastPInvokeError(), path);
19+
=> GetExceptionForWin32Error(Marshal.GetLastWin32Error(), path);
2020

2121
/// <summary>
2222
/// Converts the specified Win32 error into a corresponding <see cref="Exception"/> object, optionally

src/libraries/System.Private.CoreLib/src/System/IO/PathHelper.Windows.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ private static void GetFullPathName(ReadOnlySpan<char> path, ref ValueStringBuil
8383
if (result == 0)
8484
{
8585
// Failure, get the error and throw
86-
int errorCode = Marshal.GetLastPInvokeError();
86+
int errorCode = Marshal.GetLastWin32Error();
8787
if (errorCode == 0)
8888
errorCode = Interop.Errors.ERROR_BAD_PATHNAME;
8989
throw Win32Marshal.GetExceptionForWin32Error(errorCode, path.ToString());
@@ -185,7 +185,7 @@ internal static string TryExpandShortFileName(ref ValueStringBuilder outputBuild
185185
if (result == 0)
186186
{
187187
// Look to see if we couldn't find the file
188-
int error = Marshal.GetLastPInvokeError();
188+
int error = Marshal.GetLastWin32Error();
189189
if (error != Interop.Errors.ERROR_FILE_NOT_FOUND && error != Interop.Errors.ERROR_PATH_NOT_FOUND)
190190
{
191191
// Some other failure, give up

src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs

+5
Original file line numberDiff line numberDiff line change
@@ -1279,5 +1279,10 @@ public static void InitHandle(SafeHandle safeHandle, IntPtr handle)
12791279
// To help maximize performance of P/Invokes, don't check if safeHandle is null.
12801280
safeHandle.SetHandle(handle);
12811281
}
1282+
1283+
public static int GetLastWin32Error()
1284+
{
1285+
return GetLastPInvokeError();
1286+
}
12821287
}
12831288
}

0 commit comments

Comments
 (0)