Skip to content

Commit

Permalink
remove problem changes
Browse files Browse the repository at this point in the history
  • Loading branch information
KZedan committed Apr 29, 2021
1 parent f8a8643 commit b7abc3c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ internal static unsafe string GetMessage(int errorCode, IntPtr moduleHandle)
// We got back an error. If the error indicated that there wasn't enough room to store
// the error message, then call FormatMessage again, but this time rather than passing in
// a buffer, have the method allocate one, which we then need to free.
if (Marshal.GetLastPInvokeError() == ERROR_INSUFFICIENT_BUFFER)
if (Marshal.GetLastWin32Error() == ERROR_INSUFFICIENT_BUFFER)
{
IntPtr nativeMsgPtr = default;
try
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/Common/src/System/IO/Win32Marshal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal static class Win32Marshal
/// including the specified path in the error message.
/// </summary>
internal static Exception GetExceptionForLastWin32Error(string? path = "")
=> GetExceptionForWin32Error(Marshal.GetLastPInvokeError(), path);
=> GetExceptionForWin32Error(Marshal.GetLastWin32Error(), path);

/// <summary>
/// Converts the specified Win32 error into a corresponding <see cref="Exception"/> object, optionally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private static void GetFullPathName(ReadOnlySpan<char> path, ref ValueStringBuil
if (result == 0)
{
// Failure, get the error and throw
int errorCode = Marshal.GetLastPInvokeError();
int errorCode = Marshal.GetLastWin32Error();
if (errorCode == 0)
errorCode = Interop.Errors.ERROR_BAD_PATHNAME;
throw Win32Marshal.GetExceptionForWin32Error(errorCode, path.ToString());
Expand Down Expand Up @@ -185,7 +185,7 @@ internal static string TryExpandShortFileName(ref ValueStringBuilder outputBuild
if (result == 0)
{
// Look to see if we couldn't find the file
int error = Marshal.GetLastPInvokeError();
int error = Marshal.GetLastWin32Error();
if (error != Interop.Errors.ERROR_FILE_NOT_FOUND && error != Interop.Errors.ERROR_PATH_NOT_FOUND)
{
// Some other failure, give up
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1279,5 +1279,10 @@ public static void InitHandle(SafeHandle safeHandle, IntPtr handle)
// To help maximize performance of P/Invokes, don't check if safeHandle is null.
safeHandle.SetHandle(handle);
}

public static int GetLastWin32Error()
{
return GetLastPInvokeError();
}
}
}

0 comments on commit b7abc3c

Please sign in to comment.