Skip to content

Commit

Permalink
Convert Win32 statuses to HResults.
Browse files Browse the repository at this point in the history
  • Loading branch information
vcsjones committed Dec 11, 2019
1 parent 1dd7d9f commit 058e5b0
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ internal static class CryptoThrowHelper
public static CryptographicException ToCryptographicException(this int hr)
{
string message = Interop.Kernel32.GetMessage(hr);

if ((hr & 0x80000000) != 0x80000000)
hr = (hr & 0x0000FFFF) | unchecked((int)0x80070000);

return new WindowsCryptographicException(hr, message);
}

Expand Down

0 comments on commit 058e5b0

Please sign in to comment.