|
// <auto-generated/>
internal static unsafe partial class Interop
{
internal static unsafe partial class Advapi32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
public static partial bool CryptAcquireContext(out global::System.Security.Cryptography.SafeProvHandle phProv, string szContainer, string szProvider, int dwProvType, uint dwFlags)
{
int __lastError;
bool __invokeSucceeded = default;
phProv = default;
nint __phProv_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeProvHandle>.ManagedToUnmanagedOut __phProv_native__marshaller = new();
try
{
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (void* __szProvider_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(szProvider))
fixed (void* __szContainer_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(szContainer))
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(&__phProv_native, (ushort*)__szContainer_native, (ushort*)__szProvider_native, dwProvType, dwFlags);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__phProv_native__marshaller.FromUnmanaged(__phProv_native);
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
phProv = __phProv_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__phProv_native__marshaller.Free();
}
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "CryptAcquireContextW", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe int __PInvoke(nint* __phProv_native, ushort* __szContainer_native, ushort* __szProvider_native, int __dwProvType_native, uint __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Advapi32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial bool CryptAcquireContext(out nint psafeProvHandle, char* pszContainer, char* pszProvider, int dwProvType, global::Interop.Crypt32.CryptAcquireContextFlags dwFlags)
{
int __lastError;
psafeProvHandle = default;
bool __retVal;
int __retVal_native;
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (nint* __psafeProvHandle_native = &psafeProvHandle)
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__psafeProvHandle_native, pszContainer, pszProvider, dwProvType, dwFlags);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "CryptAcquireContextW", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe int __PInvoke(nint* __psafeProvHandle_native, char* __pszContainer_native, char* __pszProvider_native, int __dwProvType_native, global::Interop.Crypt32.CryptAcquireContextFlags __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Advapi32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial bool CryptCreateHash(global::System.Security.Cryptography.SafeProvHandle hProv, int Algid, global::System.Security.Cryptography.SafeCapiKeyHandle hKey, global::Interop.Advapi32.CryptCreateHashFlags dwFlags, out global::System.Security.Cryptography.SafeHashHandle phHash)
{
int __lastError;
bool __invokeSucceeded = default;
phHash = default;
nint __hProv_native = default;
nint __hKey_native = default;
nint __phHash_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeHashHandle>.ManagedToUnmanagedOut __phHash_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeCapiKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeProvHandle>.ManagedToUnmanagedIn __hProv_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hKey_native__marshaller.FromManaged(hKey);
__hProv_native__marshaller.FromManaged(hProv);
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
__hProv_native = __hProv_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__hProv_native, Algid, __hKey_native, dwFlags, &__phHash_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__phHash_native__marshaller.FromUnmanaged(__phHash_native);
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
phHash = __phHash_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__phHash_native__marshaller.Free();
}
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hKey_native__marshaller.Free();
__hProv_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "CryptCreateHash", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hProv_native, int __Algid_native, nint __hKey_native, global::Interop.Advapi32.CryptCreateHashFlags __dwFlags_native, nint* __phHash_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Advapi32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
public static partial bool CryptDecrypt(global::System.Security.Cryptography.SafeCapiKeyHandle hKey, global::System.Security.Cryptography.SafeHashHandle hHash, bool Final, int dwFlags, byte[] pbData, ref int pdwDataLen)
{
int __lastError;
nint __hKey_native = default;
nint __hHash_native = default;
int __Final_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeHashHandle>.ManagedToUnmanagedIn __hHash_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeCapiKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__Final_native = (int)(Final ? 1 : 0);
__hHash_native__marshaller.FromManaged(hHash);
__hKey_native__marshaller.FromManaged(hKey);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pdwDataLen_native = &pdwDataLen)
fixed (void* __pbData_native = &global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbData))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hHash_native = __hHash_native__marshaller.ToUnmanaged();
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__hKey_native, __hHash_native, __Final_native, dwFlags, (byte*)__pbData_native, __pdwDataLen_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hHash_native__marshaller.Free();
__hKey_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "CryptDecrypt", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hKey_native, nint __hHash_native, int __Final_native, int __dwFlags_native, byte* __pbData_native, int* __pdwDataLen_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Advapi32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial bool CryptDeriveKey(global::System.Security.Cryptography.SafeProvHandle hProv, int Algid, global::System.Security.Cryptography.SafeHashHandle hBaseData, int dwFlags, out global::System.Security.Cryptography.SafeCapiKeyHandle phKey)
{
int __lastError;
bool __invokeSucceeded = default;
phKey = default;
nint __hProv_native = default;
nint __hBaseData_native = default;
nint __phKey_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeCapiKeyHandle>.ManagedToUnmanagedOut __phKey_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeHashHandle>.ManagedToUnmanagedIn __hBaseData_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeProvHandle>.ManagedToUnmanagedIn __hProv_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hBaseData_native__marshaller.FromManaged(hBaseData);
__hProv_native__marshaller.FromManaged(hProv);
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hBaseData_native = __hBaseData_native__marshaller.ToUnmanaged();
__hProv_native = __hProv_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__hProv_native, Algid, __hBaseData_native, dwFlags, &__phKey_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__phKey_native__marshaller.FromUnmanaged(__phKey_native);
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
phKey = __phKey_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__phKey_native__marshaller.Free();
}
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hBaseData_native__marshaller.Free();
__hProv_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "CryptDeriveKey", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hProv_native, int __Algid_native, nint __hBaseData_native, int __dwFlags_native, nint* __phKey_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Advapi32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
public static partial bool CryptDestroyHash(nint hHash)
{
int __lastError;
bool __retVal;
int __retVal_native;
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(hHash);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "CryptDestroyHash", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hHash_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Advapi32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
public static partial bool CryptDestroyKey(nint hKey)
{
int __lastError;
bool __retVal;
int __retVal_native;
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(hKey);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "CryptDestroyKey", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hKey_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Advapi32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
public static partial bool CryptEncrypt(global::System.Security.Cryptography.SafeCapiKeyHandle hKey, global::System.Security.Cryptography.SafeHashHandle hHash, bool Final, int dwFlags, byte[] pbData, ref int pdwDataLen, int dwBufLen)
{
int __lastError;
nint __hKey_native = default;
nint __hHash_native = default;
int __Final_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeHashHandle>.ManagedToUnmanagedIn __hHash_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeCapiKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__Final_native = (int)(Final ? 1 : 0);
__hHash_native__marshaller.FromManaged(hHash);
__hKey_native__marshaller.FromManaged(hKey);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pdwDataLen_native = &pdwDataLen)
fixed (void* __pbData_native = &global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbData))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hHash_native = __hHash_native__marshaller.ToUnmanaged();
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__hKey_native, __hHash_native, __Final_native, dwFlags, (byte*)__pbData_native, __pdwDataLen_native, dwBufLen);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hHash_native__marshaller.Free();
__hKey_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "CryptEncrypt", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hKey_native, nint __hHash_native, int __Final_native, int __dwFlags_native, byte* __pbData_native, int* __pdwDataLen_native, int __dwBufLen_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Advapi32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
public static partial bool CryptExportKey(global::System.Security.Cryptography.SafeCapiKeyHandle hKey, global::System.Security.Cryptography.SafeCapiKeyHandle hExpKey, int dwBlobType, int dwFlags, byte[] pbData, ref int dwDataLen)
{
int __lastError;
nint __hKey_native = default;
nint __hExpKey_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeCapiKeyHandle>.ManagedToUnmanagedIn __hExpKey_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeCapiKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hExpKey_native__marshaller.FromManaged(hExpKey);
__hKey_native__marshaller.FromManaged(hKey);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __dwDataLen_native = &dwDataLen)
fixed (void* __pbData_native = &global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbData))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hExpKey_native = __hExpKey_native__marshaller.ToUnmanaged();
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__hKey_native, __hExpKey_native, dwBlobType, dwFlags, (byte*)__pbData_native, __dwDataLen_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hExpKey_native__marshaller.Free();
__hKey_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "CryptExportKey", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hKey_native, nint __hExpKey_native, int __dwBlobType_native, int __dwFlags_native, byte* __pbData_native, int* __dwDataLen_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Advapi32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial bool CryptGenKey(global::System.Security.Cryptography.SafeProvHandle hProv, int Algid, int dwFlags, out global::System.Security.Cryptography.SafeCapiKeyHandle phKey)
{
int __lastError;
bool __invokeSucceeded = default;
phKey = default;
nint __hProv_native = default;
nint __phKey_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeCapiKeyHandle>.ManagedToUnmanagedOut __phKey_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeProvHandle>.ManagedToUnmanagedIn __hProv_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hProv_native__marshaller.FromManaged(hProv);
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hProv_native = __hProv_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__hProv_native, Algid, dwFlags, &__phKey_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__phKey_native__marshaller.FromUnmanaged(__phKey_native);
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
phKey = __phKey_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__phKey_native__marshaller.Free();
}
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hProv_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "CryptGenKey", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hProv_native, int __Algid_native, int __dwFlags_native, nint* __phKey_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Advapi32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
public static partial bool CryptGetDefaultProvider(int dwProvType, nint pdwReserved, global::Interop.Advapi32.GetDefaultProviderFlags dwFlags, char[] pszProvName, ref int pcbProvName)
{
int __lastError;
bool __retVal;
int __retVal_native;
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbProvName_native = &pcbProvName)
fixed (void* __pszProvName_native = &global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<char, char>.ManagedToUnmanagedIn.GetPinnableReference(pszProvName))
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(dwProvType, pdwReserved, dwFlags, (char*)__pszProvName_native, __pcbProvName_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "CryptGetDefaultProviderW", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe int __PInvoke(int __dwProvType_native, nint __pdwReserved_native, global::Interop.Advapi32.GetDefaultProviderFlags __dwFlags_native, char* __pszProvName_native, int* __pcbProvName_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Advapi32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
public static partial bool CryptGetHashParam(global::System.Security.Cryptography.SafeHashHandle hHash, global::Interop.Advapi32.CryptHashProperty dwParam, out int pbData, ref int pdwDataLen, int dwFlags)
{
int __lastError;
pbData = default;
nint __hHash_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeHashHandle>.ManagedToUnmanagedIn __hHash_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hHash_native__marshaller.FromManaged(hHash);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pdwDataLen_native = &pdwDataLen)
fixed (int* __pbData_native = &pbData)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hHash_native = __hHash_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__hHash_native, dwParam, __pbData_native, __pdwDataLen_native, dwFlags);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hHash_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "CryptGetHashParam", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hHash_native, global::Interop.Advapi32.CryptHashProperty __dwParam_native, int* __pbData_native, int* __pdwDataLen_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Advapi32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
public static partial bool CryptSetHashParam(global::System.Security.Cryptography.SafeHashHandle hHash, global::Interop.Advapi32.CryptHashProperty dwParam, byte[] buffer, int dwFlags)
{
int __lastError;
nint __hHash_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeHashHandle>.ManagedToUnmanagedIn __hHash_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hHash_native__marshaller.FromManaged(hHash);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (void* __buffer_native = &global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(buffer))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hHash_native = __hHash_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__hHash_native, dwParam, (byte*)__buffer_native, dwFlags);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hHash_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "CryptSetHashParam", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hHash_native, global::Interop.Advapi32.CryptHashProperty __dwParam_native, byte* __buffer_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Advapi32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
public static partial bool CryptGetKeyParam(global::System.Security.Cryptography.SafeCapiKeyHandle hKey, global::Interop.Advapi32.CryptGetKeyParamFlags dwParam, byte[] pbData, ref int pdwDataLen, int dwFlags)
{
int __lastError;
nint __hKey_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeCapiKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hKey_native__marshaller.FromManaged(hKey);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pdwDataLen_native = &pdwDataLen)
fixed (void* __pbData_native = &global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbData))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__hKey_native, dwParam, (byte*)__pbData_native, __pdwDataLen_native, dwFlags);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hKey_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "CryptGetKeyParam", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hKey_native, global::Interop.Advapi32.CryptGetKeyParamFlags __dwParam_native, byte* __pbData_native, int* __pdwDataLen_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Advapi32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
public static partial bool CryptSetProvParam(global::System.Runtime.InteropServices.SafeHandle safeProvHandle, global::Interop.Advapi32.CryptProvParam dwParam, nint pbData, int dwFlags)
{
int __lastError;
nint __safeProvHandle_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Runtime.InteropServices.SafeHandle>.ManagedToUnmanagedIn __safeProvHandle_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__safeProvHandle_native__marshaller.FromManaged(safeProvHandle);
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__safeProvHandle_native = __safeProvHandle_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__safeProvHandle_native, dwParam, pbData, dwFlags);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__safeProvHandle_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "CryptSetProvParam", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __safeProvHandle_native, global::Interop.Advapi32.CryptProvParam __dwParam_native, nint __pbData_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Advapi32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
public static partial bool CryptSetProvParam(global::System.Security.Cryptography.SafeProvHandle hProv, global::Interop.Advapi32.CryptProvParam dwParam, ref nint pbData, int dwFlags)
{
int __lastError;
nint __hProv_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeProvHandle>.ManagedToUnmanagedIn __hProv_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hProv_native__marshaller.FromManaged(hProv);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (nint* __pbData_native = &pbData)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hProv_native = __hProv_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__hProv_native, dwParam, __pbData_native, dwFlags);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hProv_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "CryptSetProvParam", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hProv_native, global::Interop.Advapi32.CryptProvParam __dwParam_native, nint* __pbData_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Advapi32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
public static partial bool CryptGetProvParam(global::System.Runtime.InteropServices.SafeHandle safeProvHandle, global::Interop.Advapi32.CryptProvParam dwParam, nint pbData, ref int dwDataLen, int dwFlags)
{
int __lastError;
nint __safeProvHandle_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Runtime.InteropServices.SafeHandle>.ManagedToUnmanagedIn __safeProvHandle_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__safeProvHandle_native__marshaller.FromManaged(safeProvHandle);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __dwDataLen_native = &dwDataLen)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__safeProvHandle_native = __safeProvHandle_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__safeProvHandle_native, dwParam, pbData, __dwDataLen_native, dwFlags);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__safeProvHandle_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "CryptGetProvParam", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __safeProvHandle_native, global::Interop.Advapi32.CryptProvParam __dwParam_native, nint __pbData_native, int* __dwDataLen_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Advapi32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial bool CryptGetUserKey(global::System.Security.Cryptography.SafeProvHandle hProv, int dwKeySpec, out global::System.Security.Cryptography.SafeCapiKeyHandle phUserKey)
{
int __lastError;
bool __invokeSucceeded = default;
phUserKey = default;
nint __hProv_native = default;
nint __phUserKey_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeCapiKeyHandle>.ManagedToUnmanagedOut __phUserKey_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeProvHandle>.ManagedToUnmanagedIn __hProv_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hProv_native__marshaller.FromManaged(hProv);
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hProv_native = __hProv_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__hProv_native, dwKeySpec, &__phUserKey_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__phUserKey_native__marshaller.FromUnmanaged(__phUserKey_native);
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
phUserKey = __phUserKey_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__phUserKey_native__marshaller.Free();
}
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hProv_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "CryptGetUserKey", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hProv_native, int __dwKeySpec_native, nint* __phUserKey_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Advapi32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
public static partial bool CryptHashData(global::System.Security.Cryptography.SafeHashHandle hHash, byte[] pbData, int dwDataLen, int dwFlags)
{
int __lastError;
nint __hHash_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeHashHandle>.ManagedToUnmanagedIn __hHash_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hHash_native__marshaller.FromManaged(hHash);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (void* __pbData_native = &global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbData))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hHash_native = __hHash_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__hHash_native, (byte*)__pbData_native, dwDataLen, dwFlags);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hHash_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "CryptHashData", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hHash_native, byte* __pbData_native, int __dwDataLen_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Advapi32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial bool CryptImportKey(global::System.Security.Cryptography.SafeProvHandle hProv, byte* pbData, int dwDataLen, global::System.Security.Cryptography.SafeCapiKeyHandle hPubKey, int dwFlags, out global::System.Security.Cryptography.SafeCapiKeyHandle phKey)
{
int __lastError;
bool __invokeSucceeded = default;
phKey = default;
nint __hProv_native = default;
nint __hPubKey_native = default;
nint __phKey_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeCapiKeyHandle>.ManagedToUnmanagedOut __phKey_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeCapiKeyHandle>.ManagedToUnmanagedIn __hPubKey_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeProvHandle>.ManagedToUnmanagedIn __hProv_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hPubKey_native__marshaller.FromManaged(hPubKey);
__hProv_native__marshaller.FromManaged(hProv);
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hPubKey_native = __hPubKey_native__marshaller.ToUnmanaged();
__hProv_native = __hProv_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__hProv_native, pbData, dwDataLen, __hPubKey_native, dwFlags, &__phKey_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__phKey_native__marshaller.FromUnmanaged(__phKey_native);
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
phKey = __phKey_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__phKey_native__marshaller.Free();
}
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hPubKey_native__marshaller.Free();
__hProv_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "CryptImportKey", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hProv_native, byte* __pbData_native, int __dwDataLen_native, nint __hPubKey_native, int __dwFlags_native, nint* __phKey_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Advapi32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
public static partial bool CryptReleaseContext(nint hProv, int dwFlags)
{
int __lastError;
bool __retVal;
int __retVal_native;
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(hProv, dwFlags);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "CryptReleaseContext", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hProv_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Advapi32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
public static partial bool CryptSetKeyParam(global::System.Security.Cryptography.SafeCapiKeyHandle hKey, int dwParam, byte[] pbData, int dwFlags)
{
int __lastError;
nint __hKey_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeCapiKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hKey_native__marshaller.FromManaged(hKey);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (void* __pbData_native = &global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbData))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__hKey_native, dwParam, (byte*)__pbData_native, dwFlags);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hKey_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "CryptSetKeyParam", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hKey_native, int __dwParam_native, byte* __pbData_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Advapi32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
public static partial bool CryptSetKeyParam(global::System.Security.Cryptography.SafeCapiKeyHandle safeKeyHandle, int dwParam, ref int pdw, int dwFlags)
{
int __lastError;
nint __safeKeyHandle_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeCapiKeyHandle>.ManagedToUnmanagedIn __safeKeyHandle_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__safeKeyHandle_native__marshaller.FromManaged(safeKeyHandle);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pdw_native = &pdw)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__safeKeyHandle_native = __safeKeyHandle_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__safeKeyHandle_native, dwParam, __pdw_native, dwFlags);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__safeKeyHandle_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "CryptSetKeyParam", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __safeKeyHandle_native, int __dwParam_native, int* __pdw_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Advapi32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
public static partial bool CryptSignHash(global::System.Security.Cryptography.SafeHashHandle hHash, global::Interop.Advapi32.KeySpec dwKeySpec, string szDescription, global::Interop.Advapi32.CryptSignAndVerifyHashFlags dwFlags, byte[] pbSignature, ref int pdwSigLen)
{
int __lastError;
nint __hHash_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeHashHandle>.ManagedToUnmanagedIn __hHash_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hHash_native__marshaller.FromManaged(hHash);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pdwSigLen_native = &pdwSigLen)
fixed (void* __pbSignature_native = &global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbSignature))
fixed (void* __szDescription_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(szDescription))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hHash_native = __hHash_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__hHash_native, dwKeySpec, (ushort*)__szDescription_native, dwFlags, (byte*)__pbSignature_native, __pdwSigLen_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hHash_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "CryptSignHashW", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe int __PInvoke(nint __hHash_native, global::Interop.Advapi32.KeySpec __dwKeySpec_native, ushort* __szDescription_native, global::Interop.Advapi32.CryptSignAndVerifyHashFlags __dwFlags_native, byte* __pbSignature_native, int* __pdwSigLen_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Advapi32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
public static partial bool CryptVerifySignature(global::System.Security.Cryptography.SafeHashHandle hHash, byte[] pbSignature, int dwSigLen, global::System.Security.Cryptography.SafeCapiKeyHandle hPubKey, string szDescription, global::Interop.Advapi32.CryptSignAndVerifyHashFlags dwFlags)
{
int __lastError;
nint __hHash_native = default;
nint __hPubKey_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeCapiKeyHandle>.ManagedToUnmanagedIn __hPubKey_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Security.Cryptography.SafeHashHandle>.ManagedToUnmanagedIn __hHash_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hPubKey_native__marshaller.FromManaged(hPubKey);
__hHash_native__marshaller.FromManaged(hHash);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (void* __szDescription_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(szDescription))
fixed (void* __pbSignature_native = &global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbSignature))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hPubKey_native = __hPubKey_native__marshaller.ToUnmanaged();
__hHash_native = __hHash_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__hHash_native, (byte*)__pbSignature_native, dwSigLen, __hPubKey_native, (ushort*)__szDescription_native, dwFlags);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hPubKey_native__marshaller.Free();
__hHash_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint = "CryptVerifySignatureW", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe int __PInvoke(nint __hHash_native, byte* __pbSignature_native, int __dwSigLen_native, nint __hPubKey_native, ushort* __szDescription_native, global::Interop.Advapi32.CryptSignAndVerifyHashFlags __dwFlags_native);
}
}
}
namespace Internal.NativeCrypto
{
internal static unsafe partial class Cng
{
internal static unsafe partial class Interop
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
public static partial global::Interop.BCrypt.NTSTATUS BCryptOpenAlgorithmProvider(out global::Internal.NativeCrypto.SafeAlgorithmHandle phAlgorithm, string pszAlgId, string pszImplementation, int dwFlags)
{
bool __invokeSucceeded = default;
phAlgorithm = default;
nint __phAlgorithm_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Internal.NativeCrypto.SafeAlgorithmHandle>.ManagedToUnmanagedOut __phAlgorithm_native__marshaller = new();
try
{
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (void* __pszImplementation_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pszImplementation))
fixed (void* __pszAlgId_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pszAlgId))
{
__retVal = __PInvoke(&__phAlgorithm_native, (ushort*)__pszAlgId_native, (ushort*)__pszImplementation_native, dwFlags);
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__phAlgorithm_native__marshaller.FromUnmanaged(__phAlgorithm_native);
// Unmarshal - Convert native data to managed data.
phAlgorithm = __phAlgorithm_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__phAlgorithm_native__marshaller.Free();
}
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptOpenAlgorithmProvider", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint* __phAlgorithm_native, ushort* __pszAlgId_native, ushort* __pszImplementation_native, int __dwFlags_native);
}
}
}
}
namespace Internal.NativeCrypto
{
internal static unsafe partial class Cng
{
internal static unsafe partial class Interop
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
public static partial global::Interop.BCrypt.NTSTATUS BCryptSetProperty(global::Internal.NativeCrypto.SafeAlgorithmHandle hObject, string pszProperty, string pbInput, int cbInput, int dwFlags)
{
nint __hObject_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Internal.NativeCrypto.SafeAlgorithmHandle>.ManagedToUnmanagedIn __hObject_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hObject_native__marshaller.FromManaged(hObject);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (void* __pbInput_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pbInput))
fixed (void* __pszProperty_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pszProperty))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hObject_native = __hObject_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hObject_native, (ushort*)__pszProperty_native, (ushort*)__pbInput_native, cbInput, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hObject_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptSetProperty", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint __hObject_native, ushort* __pszProperty_native, ushort* __pbInput_native, int __cbInput_native, int __dwFlags_native);
}
}
}
}
namespace Internal.NativeCrypto
{
internal static unsafe partial class Cng
{
internal static unsafe partial class Interop
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
private static partial global::Interop.BCrypt.NTSTATUS BCryptSetIntPropertyPrivate(global::Microsoft.Win32.SafeHandles.SafeBCryptHandle hObject, string pszProperty, ref int pdwInput, int cbInput, int dwFlags)
{
nint __hObject_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptHandle>.ManagedToUnmanagedIn __hObject_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hObject_native__marshaller.FromManaged(hObject);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pdwInput_native = &pdwInput)
fixed (void* __pszProperty_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pszProperty))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hObject_native = __hObject_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hObject_native, (ushort*)__pszProperty_native, __pdwInput_native, cbInput, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hObject_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptSetProperty", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint __hObject_native, ushort* __pszProperty_native, int* __pdwInput_native, int __cbInput_native, int __dwFlags_native);
}
}
}
}
namespace Internal.NativeCrypto
{
internal static unsafe partial class Cng
{
internal static unsafe partial class Interop
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
public static partial global::Interop.BCrypt.NTSTATUS BCryptSetProperty(global::Microsoft.Win32.SafeHandles.SafeBCryptHandle hObject, string pszProperty, global::System.ReadOnlySpan<byte> pbInput, int cbInput, int dwFlags)
{
nint __hObject_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptHandle>.ManagedToUnmanagedIn __hObject_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hObject_native__marshaller.FromManaged(hObject);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (void* __pbInput_native = &global::System.Runtime.InteropServices.Marshalling.ReadOnlySpanMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbInput))
fixed (void* __pszProperty_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pszProperty))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hObject_native = __hObject_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hObject_native, (ushort*)__pszProperty_native, (byte*)__pbInput_native, cbInput, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hObject_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptSetProperty", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint __hObject_native, ushort* __pszProperty_native, byte* __pbInput_native, int __cbInput_native, int __dwFlags_native);
}
}
}
}
namespace Internal.NativeCrypto
{
internal sealed unsafe partial class SafeAlgorithmHandle
{
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptCloseAlgorithmProvider", ExactSpelling = true)]
private static extern partial uint BCryptCloseAlgorithmProvider(nint hAlgorithm, int dwFlags);
}
}
namespace Internal.NativeCrypto
{
internal sealed unsafe partial class SafeKeyHandle
{
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptDestroyKey", ExactSpelling = true)]
private static extern partial uint BCryptDestroyKey(nint hKey);
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptCloseAlgorithmProvider", ExactSpelling = true)]
internal static extern partial global::Interop.BCrypt.NTSTATUS BCryptCloseAlgorithmProvider(nint hAlgorithm, int dwFlags);
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial global::Interop.BCrypt.NTSTATUS BCryptCreateHash(global::Microsoft.Win32.SafeHandles.SafeBCryptAlgorithmHandle hAlgorithm, out global::Microsoft.Win32.SafeHandles.SafeBCryptHashHandle phHash, nint pbHashObject, int cbHashObject, global::System.ReadOnlySpan<byte> secret, int cbSecret, global::Interop.BCrypt.BCryptCreateHashFlags dwFlags)
{
bool __invokeSucceeded = default;
phHash = default;
nint __hAlgorithm_native = default;
nint __phHash_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptHashHandle>.ManagedToUnmanagedOut __phHash_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptAlgorithmHandle>.ManagedToUnmanagedIn __hAlgorithm_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hAlgorithm_native__marshaller.FromManaged(hAlgorithm);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (void* __secret_native = &global::System.Runtime.InteropServices.Marshalling.ReadOnlySpanMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(secret))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hAlgorithm_native = __hAlgorithm_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hAlgorithm_native, &__phHash_native, pbHashObject, cbHashObject, (byte*)__secret_native, cbSecret, dwFlags);
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__phHash_native__marshaller.FromUnmanaged(__phHash_native);
// Unmarshal - Convert native data to managed data.
phHash = __phHash_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__phHash_native__marshaller.Free();
}
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hAlgorithm_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptCreateHash", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint __hAlgorithm_native, nint* __phHash_native, nint __pbHashObject_native, int __cbHashObject_native, byte* __secret_native, int __cbSecret_native, global::Interop.BCrypt.BCryptCreateHashFlags __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial global::Interop.BCrypt.NTSTATUS BCryptCreateHash(nuint hAlgorithm, out global::Microsoft.Win32.SafeHandles.SafeBCryptHashHandle phHash, nint pbHashObject, int cbHashObject, global::System.ReadOnlySpan<byte> secret, int cbSecret, global::Interop.BCrypt.BCryptCreateHashFlags dwFlags)
{
bool __invokeSucceeded = default;
phHash = default;
nint __phHash_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptHashHandle>.ManagedToUnmanagedOut __phHash_native__marshaller = new();
try
{
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (void* __secret_native = &global::System.Runtime.InteropServices.Marshalling.ReadOnlySpanMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(secret))
{
__retVal = __PInvoke(hAlgorithm, &__phHash_native, pbHashObject, cbHashObject, (byte*)__secret_native, cbSecret, dwFlags);
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__phHash_native__marshaller.FromUnmanaged(__phHash_native);
// Unmarshal - Convert native data to managed data.
phHash = __phHash_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__phHash_native__marshaller.Free();
}
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptCreateHash", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nuint __hAlgorithm_native, nint* __phHash_native, nint __pbHashObject_native, int __cbHashObject_native, byte* __secret_native, int __cbSecret_native, global::Interop.BCrypt.BCryptCreateHashFlags __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
private static unsafe partial global::Interop.BCrypt.NTSTATUS BCryptDecapsulate(global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle hKey, byte* pbCipherText, uint cbCipherText, byte* pbSecretKey, uint cbSecretKey, out uint pcbSecretKey, uint dwFlags)
{
pcbSecretKey = default;
nint __hKey_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hKey_native__marshaller.FromManaged(hKey);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (uint* __pcbSecretKey_native = &pcbSecretKey)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hKey_native, pbCipherText, cbCipherText, pbSecretKey, cbSecretKey, __pcbSecretKey_native, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hKey_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptDecapsulate", ExactSpelling = true)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint __hKey_native, byte* __pbCipherText_native, uint __cbCipherText_native, byte* __pbSecretKey_native, uint __cbSecretKey_native, uint* __pcbSecretKey_native, uint __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
private static unsafe partial global::Interop.BCrypt.NTSTATUS BCryptEncapsulate(global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle hKey, byte* pbSecretKey, uint cbSecretKey, out uint pcbSecretKey, byte* pbCipherText, uint cbCipherText, out uint pcbCipherText, uint dwFlags)
{
pcbSecretKey = default;
pcbCipherText = default;
nint __hKey_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hKey_native__marshaller.FromManaged(hKey);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (uint* __pcbCipherText_native = &pcbCipherText)
fixed (uint* __pcbSecretKey_native = &pcbSecretKey)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hKey_native, pbSecretKey, cbSecretKey, __pcbSecretKey_native, pbCipherText, cbCipherText, __pcbCipherText_native, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hKey_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptEncapsulate", ExactSpelling = true)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint __hKey_native, byte* __pbSecretKey_native, uint __cbSecretKey_native, uint* __pcbSecretKey_native, byte* __pbCipherText_native, uint __cbCipherText_native, uint* __pcbCipherText_native, uint __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
private static unsafe partial global::Interop.BCrypt.NTSTATUS BCryptDeriveKey(global::Microsoft.Win32.SafeHandles.SafeBCryptSecretHandle hSharedSecret, string pwszKDF, ref readonly global::Interop.BCrypt.BCryptBufferDesc pParameterList, global::System.Span<byte> pbDerivedKey, uint cbDerivedKey, out uint pcbResult, uint dwFlags)
{
pcbResult = default;
nint __hSharedSecret_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptSecretHandle>.ManagedToUnmanagedIn __hSharedSecret_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hSharedSecret_native__marshaller.FromManaged(hSharedSecret);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (uint* __pcbResult_native = &pcbResult)
fixed (void* __pbDerivedKey_native = &global::System.Runtime.InteropServices.Marshalling.SpanMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbDerivedKey))
fixed (global::Interop.BCrypt.BCryptBufferDesc* __pParameterList_native = &pParameterList)
fixed (void* __pwszKDF_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pwszKDF))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hSharedSecret_native = __hSharedSecret_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hSharedSecret_native, (ushort*)__pwszKDF_native, __pParameterList_native, (byte*)__pbDerivedKey_native, cbDerivedKey, __pcbResult_native, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hSharedSecret_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptDeriveKey", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint __hSharedSecret_native, ushort* __pwszKDF_native, global::Interop.BCrypt.BCryptBufferDesc* __pParameterList_native, byte* __pbDerivedKey_native, uint __cbDerivedKey_native, uint* __pcbResult_native, uint __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptDestroyHash", ExactSpelling = true)]
internal static extern partial global::Interop.BCrypt.NTSTATUS BCryptDestroyHash(nint hHash);
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptDestroyKey", ExactSpelling = true)]
internal static extern partial global::Interop.BCrypt.NTSTATUS BCryptDestroyKey(nint hKey);
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptDestroySecret", ExactSpelling = true)]
internal static extern partial global::Interop.BCrypt.NTSTATUS BCryptDestroySecret(nint hSecret);
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
private static partial global::Interop.BCrypt.NTSTATUS BCryptDuplicateHash(global::Microsoft.Win32.SafeHandles.SafeBCryptHashHandle hHash, out global::Microsoft.Win32.SafeHandles.SafeBCryptHashHandle phNewHash, nint pbHashObject, int cbHashObject, int dwFlags)
{
bool __invokeSucceeded = default;
phNewHash = default;
nint __hHash_native = default;
nint __phNewHash_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptHashHandle>.ManagedToUnmanagedOut __phNewHash_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptHashHandle>.ManagedToUnmanagedIn __hHash_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hHash_native__marshaller.FromManaged(hHash);
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hHash_native = __hHash_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hHash_native, &__phNewHash_native, pbHashObject, cbHashObject, dwFlags);
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__phNewHash_native__marshaller.FromUnmanaged(__phNewHash_native);
// Unmarshal - Convert native data to managed data.
phNewHash = __phNewHash_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__phNewHash_native__marshaller.Free();
}
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hHash_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptDuplicateHash", ExactSpelling = true)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint __hHash_native, nint* __phNewHash_native, nint __pbHashObject_native, int __cbHashObject_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
public static unsafe partial global::Interop.BCrypt.NTSTATUS BCryptEncrypt(global::Internal.NativeCrypto.SafeKeyHandle hKey, byte* pbInput, int cbInput, nint paddingInfo, byte[] pbIV, int cbIV, byte* pbOutput, int cbOutput, out int cbResult, int dwFlags)
{
cbResult = default;
nint __hKey_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Internal.NativeCrypto.SafeKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hKey_native__marshaller.FromManaged(hKey);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __cbResult_native = &cbResult)
fixed (void* __pbIV_native = &global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbIV))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hKey_native, pbInput, cbInput, paddingInfo, (byte*)__pbIV_native, cbIV, pbOutput, cbOutput, __cbResult_native, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hKey_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptEncrypt", ExactSpelling = true)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint __hKey_native, byte* __pbInput_native, int __cbInput_native, nint __paddingInfo_native, byte* __pbIV_native, int __cbIV_native, byte* __pbOutput_native, int __cbOutput_native, int* __cbResult_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
public static unsafe partial global::Interop.BCrypt.NTSTATUS BCryptDecrypt(global::Internal.NativeCrypto.SafeKeyHandle hKey, byte* pbInput, int cbInput, nint paddingInfo, byte[] pbIV, int cbIV, byte* pbOutput, int cbOutput, out int cbResult, int dwFlags)
{
cbResult = default;
nint __hKey_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Internal.NativeCrypto.SafeKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hKey_native__marshaller.FromManaged(hKey);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __cbResult_native = &cbResult)
fixed (void* __pbIV_native = &global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbIV))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hKey_native, pbInput, cbInput, paddingInfo, (byte*)__pbIV_native, cbIV, pbOutput, cbOutput, __cbResult_native, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hKey_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptDecrypt", ExactSpelling = true)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint __hKey_native, byte* __pbInput_native, int __cbInput_native, nint __paddingInfo_native, byte* __pbIV_native, int __cbIV_native, byte* __pbOutput_native, int __cbOutput_native, int* __cbResult_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
private static unsafe partial global::Interop.BCrypt.NTSTATUS BCryptEncrypt(global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle hKey, byte* pbInput, int cbInput, void* paddingInfo, byte* pbIV, int cbIV, byte* pbOutput, int cbOutput, out int cbResult, global::Interop.BCrypt.BCryptEncryptFlags dwFlags)
{
cbResult = default;
nint __hKey_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hKey_native__marshaller.FromManaged(hKey);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __cbResult_native = &cbResult)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hKey_native, pbInput, cbInput, paddingInfo, pbIV, cbIV, pbOutput, cbOutput, __cbResult_native, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hKey_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptEncrypt", ExactSpelling = true)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint __hKey_native, byte* __pbInput_native, int __cbInput_native, void* __paddingInfo_native, byte* __pbIV_native, int __cbIV_native, byte* __pbOutput_native, int __cbOutput_native, int* __cbResult_native, global::Interop.BCrypt.BCryptEncryptFlags __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
private static unsafe partial global::Interop.BCrypt.NTSTATUS BCryptDecrypt(global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle hKey, byte* pbInput, int cbInput, void* paddingInfo, byte* pbIV, int cbIV, byte* pbOutput, int cbOutput, out int cbResult, global::Interop.BCrypt.BCryptEncryptFlags dwFlags)
{
cbResult = default;
nint __hKey_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hKey_native__marshaller.FromManaged(hKey);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __cbResult_native = &cbResult)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hKey_native, pbInput, cbInput, paddingInfo, pbIV, cbIV, pbOutput, cbOutput, __cbResult_native, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hKey_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptDecrypt", ExactSpelling = true)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint __hKey_native, byte* __pbInput_native, int __cbInput_native, void* __paddingInfo_native, byte* __pbIV_native, int __cbIV_native, byte* __pbOutput_native, int __cbOutput_native, int* __cbResult_native, global::Interop.BCrypt.BCryptEncryptFlags __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
private static partial global::Interop.BCrypt.NTSTATUS BCryptExportKey(global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle hKey, nint hExportKey, string pszBlobType, byte[] pbOutput, int cbOutput, out int pcbResult, int dwFlags)
{
pcbResult = default;
nint __hKey_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hKey_native__marshaller.FromManaged(hKey);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbResult_native = &pcbResult)
fixed (void* __pbOutput_native = &global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbOutput))
fixed (void* __pszBlobType_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pszBlobType))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hKey_native, hExportKey, (ushort*)__pszBlobType_native, (byte*)__pbOutput_native, cbOutput, __pcbResult_native, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hKey_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptExportKey", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint __hKey_native, nint __hExportKey_native, ushort* __pszBlobType_native, byte* __pbOutput_native, int __cbOutput_native, int* __pcbResult_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
private static unsafe partial global::Interop.BCrypt.NTSTATUS BCryptFinalizeKeyPair(global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle hKey, uint dwFlags)
{
nint __hKey_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hKey_native__marshaller.FromManaged(hKey);
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hKey_native, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hKey_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptFinalizeKeyPair", ExactSpelling = true)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint __hKey_native, uint __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial global::Interop.BCrypt.NTSTATUS BCryptFinishHash(global::Microsoft.Win32.SafeHandles.SafeBCryptHashHandle hHash, global::System.Span<byte> pbOutput, int cbOutput, int dwFlags)
{
nint __hHash_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptHashHandle>.ManagedToUnmanagedIn __hHash_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hHash_native__marshaller.FromManaged(hHash);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (void* __pbOutput_native = &global::System.Runtime.InteropServices.Marshalling.SpanMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbOutput))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hHash_native = __hHash_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hHash_native, (byte*)__pbOutput_native, cbOutput, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hHash_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptFinishHash", ExactSpelling = true)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint __hHash_native, byte* __pbOutput_native, int __cbOutput_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial global::Interop.BCrypt.NTSTATUS BCryptFinishHash(global::Microsoft.Win32.SafeHandles.SafeBCryptHashHandle hHash, byte* pbOutput, int cbOutput, int dwFlags)
{
nint __hHash_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptHashHandle>.ManagedToUnmanagedIn __hHash_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hHash_native__marshaller.FromManaged(hHash);
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hHash_native = __hHash_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hHash_native, pbOutput, cbOutput, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hHash_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptFinishHash", ExactSpelling = true)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint __hHash_native, byte* __pbOutput_native, int __cbOutput_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptGenRandom", ExactSpelling = true)]
internal static unsafe extern partial global::Interop.BCrypt.NTSTATUS BCryptGenRandom(nint hAlgorithm, byte* pbBuffer, int cbBuffer, int dwFlags);
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
private static unsafe partial global::Interop.BCrypt.NTSTATUS BCryptGenerateKeyPair(global::Microsoft.Win32.SafeHandles.SafeBCryptAlgorithmHandle hAlgorithm, out global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle phKey, int dwLength, uint dwFlags)
{
bool __invokeSucceeded = default;
phKey = default;
nint __hAlgorithm_native = default;
nint __phKey_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle>.ManagedToUnmanagedOut __phKey_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptAlgorithmHandle>.ManagedToUnmanagedIn __hAlgorithm_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hAlgorithm_native__marshaller.FromManaged(hAlgorithm);
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hAlgorithm_native = __hAlgorithm_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hAlgorithm_native, &__phKey_native, dwLength, dwFlags);
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__phKey_native__marshaller.FromUnmanaged(__phKey_native);
// Unmarshal - Convert native data to managed data.
phKey = __phKey_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__phKey_native__marshaller.Free();
}
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hAlgorithm_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptGenerateKeyPair", ExactSpelling = true)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint __hAlgorithm_native, nint* __phKey_native, int __dwLength_native, uint __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial global::Interop.BCrypt.NTSTATUS BCryptGenerateSymmetricKey(global::Microsoft.Win32.SafeHandles.SafeBCryptAlgorithmHandle hAlgorithm, out global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle phKey, nint pbKeyObject, int cbKeyObject, byte* pbSecret, int cbSecret, uint dwFlags)
{
bool __invokeSucceeded = default;
phKey = default;
nint __hAlgorithm_native = default;
nint __phKey_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle>.ManagedToUnmanagedOut __phKey_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptAlgorithmHandle>.ManagedToUnmanagedIn __hAlgorithm_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hAlgorithm_native__marshaller.FromManaged(hAlgorithm);
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hAlgorithm_native = __hAlgorithm_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hAlgorithm_native, &__phKey_native, pbKeyObject, cbKeyObject, pbSecret, cbSecret, dwFlags);
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__phKey_native__marshaller.FromUnmanaged(__phKey_native);
// Unmarshal - Convert native data to managed data.
phKey = __phKey_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__phKey_native__marshaller.Free();
}
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hAlgorithm_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptGenerateSymmetricKey", ExactSpelling = true)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint __hAlgorithm_native, nint* __phKey_native, nint __pbKeyObject_native, int __cbKeyObject_native, byte* __pbSecret_native, int __cbSecret_native, uint __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial global::Interop.BCrypt.NTSTATUS BCryptGenerateSymmetricKey(nuint hAlgorithm, out global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle phKey, nint pbKeyObject, int cbKeyObject, byte* pbSecret, int cbSecret, uint dwFlags)
{
bool __invokeSucceeded = default;
phKey = default;
nint __phKey_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle>.ManagedToUnmanagedOut __phKey_native__marshaller = new();
try
{
{
__retVal = __PInvoke(hAlgorithm, &__phKey_native, pbKeyObject, cbKeyObject, pbSecret, cbSecret, dwFlags);
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__phKey_native__marshaller.FromUnmanaged(__phKey_native);
// Unmarshal - Convert native data to managed data.
phKey = __phKey_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__phKey_native__marshaller.Free();
}
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptGenerateSymmetricKey", ExactSpelling = true)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nuint __hAlgorithm_native, nint* __phKey_native, nint __pbKeyObject_native, int __cbKeyObject_native, byte* __pbSecret_native, int __cbSecret_native, uint __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial global::Interop.BCrypt.NTSTATUS BCryptGetProperty(global::Microsoft.Win32.SafeHandles.SafeBCryptHandle hObject, string pszProperty, void* pbOutput, int cbOutput, out int pcbResult, int dwFlags)
{
pcbResult = default;
nint __hObject_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptHandle>.ManagedToUnmanagedIn __hObject_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hObject_native__marshaller.FromManaged(hObject);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbResult_native = &pcbResult)
fixed (void* __pszProperty_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pszProperty))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hObject_native = __hObject_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hObject_native, (ushort*)__pszProperty_native, pbOutput, cbOutput, __pcbResult_native, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hObject_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptGetProperty", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint __hObject_native, ushort* __pszProperty_native, void* __pbOutput_native, int __cbOutput_native, int* __pcbResult_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptHash", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
internal static unsafe extern partial global::Interop.BCrypt.NTSTATUS BCryptHash(nuint hAlgorithm, byte* pbSecret, int cbSecret, byte* pbInput, int cbInput, byte* pbOutput, int cbOutput);
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial global::Interop.BCrypt.NTSTATUS BCryptHashData(global::Microsoft.Win32.SafeHandles.SafeBCryptHashHandle hHash, global::System.ReadOnlySpan<byte> pbInput, int cbInput, int dwFlags)
{
nint __hHash_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptHashHandle>.ManagedToUnmanagedIn __hHash_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hHash_native__marshaller.FromManaged(hHash);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (void* __pbInput_native = &global::System.Runtime.InteropServices.Marshalling.ReadOnlySpanMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbInput))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hHash_native = __hHash_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hHash_native, (byte*)__pbInput_native, cbInput, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hHash_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptHashData", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint __hHash_native, byte* __pbInput_native, int __cbInput_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
private static unsafe partial global::Interop.BCrypt.NTSTATUS BCryptImportKey(global::Internal.NativeCrypto.SafeAlgorithmHandle hAlgorithm, nint hImportKey, string pszBlobType, out global::Internal.NativeCrypto.SafeKeyHandle hKey, nint pbKeyObject, int cbKeyObject, byte* pbInput, int cbInput, int dwFlags)
{
bool __invokeSucceeded = default;
hKey = default;
nint __hAlgorithm_native = default;
nint __hKey_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Internal.NativeCrypto.SafeKeyHandle>.ManagedToUnmanagedOut __hKey_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Internal.NativeCrypto.SafeAlgorithmHandle>.ManagedToUnmanagedIn __hAlgorithm_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hAlgorithm_native__marshaller.FromManaged(hAlgorithm);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (void* __pszBlobType_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pszBlobType))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hAlgorithm_native = __hAlgorithm_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hAlgorithm_native, hImportKey, (ushort*)__pszBlobType_native, &__hKey_native, pbKeyObject, cbKeyObject, pbInput, cbInput, dwFlags);
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__hKey_native__marshaller.FromUnmanaged(__hKey_native);
// Unmarshal - Convert native data to managed data.
hKey = __hKey_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__hKey_native__marshaller.Free();
}
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hAlgorithm_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptImportKey", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint __hAlgorithm_native, nint __hImportKey_native, ushort* __pszBlobType_native, nint* __hKey_native, nint __pbKeyObject_native, int __cbKeyObject_native, byte* __pbInput_native, int __cbInput_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
private static unsafe partial global::Interop.BCrypt.NTSTATUS BCryptImportKeyPair(global::Microsoft.Win32.SafeHandles.SafeBCryptAlgorithmHandle hAlgorithm, nint hImportKey, string pszBlobType, out global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle phKey, byte* pbInput, int cbInput, uint dwFlags)
{
bool __invokeSucceeded = default;
phKey = default;
nint __hAlgorithm_native = default;
nint __phKey_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle>.ManagedToUnmanagedOut __phKey_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptAlgorithmHandle>.ManagedToUnmanagedIn __hAlgorithm_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hAlgorithm_native__marshaller.FromManaged(hAlgorithm);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (void* __pszBlobType_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pszBlobType))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hAlgorithm_native = __hAlgorithm_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hAlgorithm_native, hImportKey, (ushort*)__pszBlobType_native, &__phKey_native, pbInput, cbInput, dwFlags);
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__phKey_native__marshaller.FromUnmanaged(__phKey_native);
// Unmarshal - Convert native data to managed data.
phKey = __phKey_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__phKey_native__marshaller.Free();
}
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hAlgorithm_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptImportKeyPair", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint __hAlgorithm_native, nint __hImportKey_native, ushort* __pszBlobType_native, nint* __phKey_native, byte* __pbInput_native, int __cbInput_native, uint __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial global::Interop.BCrypt.NTSTATUS BCryptKeyDerivation(global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle hKey, global::Interop.BCrypt.BCryptBufferDesc* pParameterList, byte* pbDerivedKey, int cbDerivedKey, out uint pcbResult, int dwFlags)
{
pcbResult = default;
nint __hKey_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hKey_native__marshaller.FromManaged(hKey);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (uint* __pcbResult_native = &pcbResult)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hKey_native, pParameterList, pbDerivedKey, cbDerivedKey, __pcbResult_native, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hKey_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptKeyDerivation", ExactSpelling = true)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint __hKey_native, global::Interop.BCrypt.BCryptBufferDesc* __pParameterList_native, byte* __pbDerivedKey_native, int __cbDerivedKey_native, uint* __pcbResult_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial global::Interop.BCrypt.NTSTATUS BCryptOpenAlgorithmProvider(out global::Microsoft.Win32.SafeHandles.SafeBCryptAlgorithmHandle phAlgorithm, string pszAlgId, string pszImplementation, global::Interop.BCrypt.BCryptOpenAlgorithmProviderFlags dwFlags)
{
bool __invokeSucceeded = default;
phAlgorithm = default;
nint __phAlgorithm_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptAlgorithmHandle>.ManagedToUnmanagedOut __phAlgorithm_native__marshaller = new();
try
{
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (void* __pszImplementation_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pszImplementation))
fixed (void* __pszAlgId_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pszAlgId))
{
__retVal = __PInvoke(&__phAlgorithm_native, (ushort*)__pszAlgId_native, (ushort*)__pszImplementation_native, dwFlags);
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__phAlgorithm_native__marshaller.FromUnmanaged(__phAlgorithm_native);
// Unmarshal - Convert native data to managed data.
phAlgorithm = __phAlgorithm_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__phAlgorithm_native__marshaller.Free();
}
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptOpenAlgorithmProvider", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint* __phAlgorithm_native, ushort* __pszAlgId_native, ushort* __pszImplementation_native, global::Interop.BCrypt.BCryptOpenAlgorithmProviderFlags __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
private static unsafe partial global::Interop.BCrypt.NTSTATUS BCryptSecretAgreement(global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle hPrivKey, global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle hPubKey, out global::Microsoft.Win32.SafeHandles.SafeBCryptSecretHandle phAgreedSecret, uint dwFlags)
{
bool __invokeSucceeded = default;
phAgreedSecret = default;
nint __hPrivKey_native = default;
nint __hPubKey_native = default;
nint __phAgreedSecret_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptSecretHandle>.ManagedToUnmanagedOut __phAgreedSecret_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle>.ManagedToUnmanagedIn __hPubKey_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle>.ManagedToUnmanagedIn __hPrivKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hPubKey_native__marshaller.FromManaged(hPubKey);
__hPrivKey_native__marshaller.FromManaged(hPrivKey);
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hPubKey_native = __hPubKey_native__marshaller.ToUnmanaged();
__hPrivKey_native = __hPrivKey_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hPrivKey_native, __hPubKey_native, &__phAgreedSecret_native, dwFlags);
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__phAgreedSecret_native__marshaller.FromUnmanaged(__phAgreedSecret_native);
// Unmarshal - Convert native data to managed data.
phAgreedSecret = __phAgreedSecret_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__phAgreedSecret_native__marshaller.Free();
}
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hPubKey_native__marshaller.Free();
__hPrivKey_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptSecretAgreement", ExactSpelling = true)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint __hPrivKey_native, nint __hPubKey_native, nint* __phAgreedSecret_native, uint __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial global::Interop.BCrypt.NTSTATUS BCryptSetProperty(global::Microsoft.Win32.SafeHandles.SafeBCryptHandle hObject, string pszProperty, void* pbInput, uint cbInput, uint dwFlags)
{
nint __hObject_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptHandle>.ManagedToUnmanagedIn __hObject_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hObject_native__marshaller.FromManaged(hObject);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (void* __pszProperty_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pszProperty))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hObject_native = __hObject_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hObject_native, (ushort*)__pszProperty_native, pbInput, cbInput, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hObject_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptSetProperty", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint __hObject_native, ushort* __pszProperty_native, void* __pbInput_native, uint __cbInput_native, uint __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
private static unsafe partial global::Interop.BCrypt.NTSTATUS BCryptSignHash(global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle hKey, void* pPaddingInfo, byte* pbInput, int cbInput, byte* pbOutput, int cbOutput, out int pcbResult, global::Interop.BCrypt.BCryptSignVerifyFlags dwFlags)
{
pcbResult = default;
nint __hKey_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hKey_native__marshaller.FromManaged(hKey);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbResult_native = &pcbResult)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hKey_native, pPaddingInfo, pbInput, cbInput, pbOutput, cbOutput, __pcbResult_native, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hKey_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptSignHash", ExactSpelling = true)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint __hKey_native, void* __pPaddingInfo_native, byte* __pbInput_native, int __cbInput_native, byte* __pbOutput_native, int __cbOutput_native, int* __pcbResult_native, global::Interop.BCrypt.BCryptSignVerifyFlags __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class BCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
private static unsafe partial global::Interop.BCrypt.NTSTATUS BCryptVerifySignature(global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle hKey, void* pPaddingInfo, byte* pbHash, int cbHash, byte* pbSignature, int cbSignature, global::Interop.BCrypt.BCryptSignVerifyFlags dwFlags)
{
nint __hKey_native = default;
global::Interop.BCrypt.NTSTATUS __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hKey_native__marshaller.FromManaged(hKey);
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hKey_native, pPaddingInfo, pbHash, cbHash, pbSignature, cbSignature, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hKey_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("BCrypt.dll", EntryPoint = "BCryptVerifySignature", ExactSpelling = true)]
static extern unsafe global::Interop.BCrypt.NTSTATUS __PInvoke(nint __hKey_native, void* __pPaddingInfo_native, byte* __pbHash_native, int __cbHash_native, byte* __pbSignature_native, int __cbSignature_native, global::Interop.BCrypt.BCryptSignVerifyFlags __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial bool CertAddCertificateContextToStore(global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle hCertStore, global::Microsoft.Win32.SafeHandles.SafeCertContextHandle pCertContext, global::Interop.Crypt32.CertStoreAddDisposition dwAddDisposition, nint ppStoreContext)
{
int __lastError;
nint __hCertStore_native = default;
nint __pCertContext_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertContextHandle>.ManagedToUnmanagedIn __pCertContext_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle>.ManagedToUnmanagedIn __hCertStore_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__pCertContext_native__marshaller.FromManaged(pCertContext);
__hCertStore_native__marshaller.FromManaged(hCertStore);
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__pCertContext_native = __pCertContext_native__marshaller.ToUnmanaged();
__hCertStore_native = __hCertStore_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__hCertStore_native, __pCertContext_native, dwAddDisposition, ppStoreContext);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__pCertContext_native__marshaller.Free();
__hCertStore_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertAddCertificateContextToStore", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hCertStore_native, nint __pCertContext_native, global::Interop.Crypt32.CertStoreAddDisposition __dwAddDisposition_native, nint __ppStoreContext_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial bool CertAddCertificateLinkToStore(global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle hCertStore, global::Microsoft.Win32.SafeHandles.SafeCertContextHandle pCertContext, global::Interop.Crypt32.CertStoreAddDisposition dwAddDisposition, nint ppStoreContext)
{
int __lastError;
nint __hCertStore_native = default;
nint __pCertContext_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertContextHandle>.ManagedToUnmanagedIn __pCertContext_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle>.ManagedToUnmanagedIn __hCertStore_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__pCertContext_native__marshaller.FromManaged(pCertContext);
__hCertStore_native__marshaller.FromManaged(hCertStore);
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__pCertContext_native = __pCertContext_native__marshaller.ToUnmanaged();
__hCertStore_native = __hCertStore_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__hCertStore_native, __pCertContext_native, dwAddDisposition, ppStoreContext);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__pCertContext_native__marshaller.Free();
__hCertStore_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertAddCertificateLinkToStore", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hCertStore_native, nint __pCertContext_native, global::Interop.Crypt32.CertStoreAddDisposition __dwAddDisposition_native, nint __ppStoreContext_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial bool CertCloseStore(nint hCertStore, uint dwFlags)
{
int __lastError;
bool __retVal;
int __retVal_native;
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(hCertStore, dwFlags);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertCloseStore", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hCertStore_native, uint __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial bool CertControlStore(global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle hCertStore, global::Interop.Crypt32.CertControlStoreFlags dwFlags, global::Interop.Crypt32.CertControlStoreType dwControlType, nint pvCtrlPara)
{
int __lastError;
nint __hCertStore_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle>.ManagedToUnmanagedIn __hCertStore_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hCertStore_native__marshaller.FromManaged(hCertStore);
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hCertStore_native = __hCertStore_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__hCertStore_native, dwFlags, dwControlType, pvCtrlPara);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hCertStore_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertControlStore", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hCertStore_native, global::Interop.Crypt32.CertControlStoreFlags __dwFlags_native, global::Interop.Crypt32.CertControlStoreType __dwControlType_native, nint __pvCtrlPara_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial bool CertCreateCertificateChainEngine(ref global::Interop.Crypt32.CERT_CHAIN_ENGINE_CONFIG pConfig, out global::Microsoft.Win32.SafeHandles.SafeChainEngineHandle hChainEngineHandle)
{
int __lastError;
bool __invokeSucceeded = default;
hChainEngineHandle = default;
nint __hChainEngineHandle_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeChainEngineHandle>.ManagedToUnmanagedOut __hChainEngineHandle_native__marshaller = new();
try
{
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (global::Interop.Crypt32.CERT_CHAIN_ENGINE_CONFIG* __pConfig_native = &pConfig)
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__pConfig_native, &__hChainEngineHandle_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__hChainEngineHandle_native__marshaller.FromUnmanaged(__hChainEngineHandle_native);
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
hChainEngineHandle = __hChainEngineHandle_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__hChainEngineHandle_native__marshaller.Free();
}
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertCreateCertificateChainEngine", ExactSpelling = true)]
static extern unsafe int __PInvoke(global::Interop.Crypt32.CERT_CHAIN_ENGINE_CONFIG* __pConfig_native, nint* __hChainEngineHandle_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial bool CertDeleteCertificateFromStore(global::Interop.Crypt32.CERT_CONTEXT* pCertContext)
{
int __lastError;
bool __retVal;
int __retVal_native;
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(pCertContext);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertDeleteCertificateFromStore", ExactSpelling = true)]
static extern unsafe int __PInvoke(global::Interop.Crypt32.CERT_CONTEXT* __pCertContext_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial global::Microsoft.Win32.SafeHandles.SafeX509ChainHandle CertDuplicateCertificateChain(nint pChainContext)
{
int __lastError;
bool __invokeSucceeded = default;
global::Microsoft.Win32.SafeHandles.SafeX509ChainHandle __retVal = default;
nint __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeX509ChainHandle>.ManagedToUnmanagedOut __retVal_native__marshaller = new();
try
{
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(pChainContext);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__retVal_native__marshaller.FromUnmanaged(__retVal_native);
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__retVal_native__marshaller.Free();
}
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertDuplicateCertificateChain", ExactSpelling = true)]
static extern unsafe nint __PInvoke(nint __pChainContext_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial global::Microsoft.Win32.SafeHandles.SafeCertContextHandle CertDuplicateCertificateContext(nint pCertContext)
{
int __lastError;
bool __invokeSucceeded = default;
global::Microsoft.Win32.SafeHandles.SafeCertContextHandle __retVal = default;
nint __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertContextHandle>.ManagedToUnmanagedOut __retVal_native__marshaller = new();
try
{
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(pCertContext);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__retVal_native__marshaller.FromUnmanaged(__retVal_native);
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__retVal_native__marshaller.Free();
}
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertDuplicateCertificateContext", ExactSpelling = true)]
static extern unsafe nint __PInvoke(nint __pCertContext_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial global::Microsoft.Win32.SafeHandles.SafeCertContextHandleWithKeyContainerDeletion CertDuplicateCertificateContextWithKeyContainerDeletion(nint pCertContext)
{
int __lastError;
bool __invokeSucceeded = default;
global::Microsoft.Win32.SafeHandles.SafeCertContextHandleWithKeyContainerDeletion __retVal = default;
nint __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertContextHandleWithKeyContainerDeletion>.ManagedToUnmanagedOut __retVal_native__marshaller = new();
try
{
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(pCertContext);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__retVal_native__marshaller.FromUnmanaged(__retVal_native);
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__retVal_native__marshaller.Free();
}
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertDuplicateCertificateContext", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe nint __PInvoke(nint __pCertContext_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle CertDuplicateStore(nint hCertStore)
{
int __lastError;
bool __invokeSucceeded = default;
global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle __retVal = default;
nint __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle>.ManagedToUnmanagedOut __retVal_native__marshaller = new();
try
{
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(hCertStore);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__retVal_native__marshaller.FromUnmanaged(__retVal_native);
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__retVal_native__marshaller.Free();
}
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertDuplicateStore", ExactSpelling = true)]
static extern unsafe nint __PInvoke(nint __hCertStore_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial global::Interop.Crypt32.CERT_CONTEXT* CertEnumCertificatesInStore(global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle hCertStore, global::Interop.Crypt32.CERT_CONTEXT* pPrevCertContext)
{
int __lastError;
nint __hCertStore_native = default;
global::Interop.Crypt32.CERT_CONTEXT* __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle>.ManagedToUnmanagedIn __hCertStore_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hCertStore_native__marshaller.FromManaged(hCertStore);
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hCertStore_native = __hCertStore_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal = __PInvoke(__hCertStore_native, pPrevCertContext);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hCertStore_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertEnumCertificatesInStore", ExactSpelling = true)]
static extern unsafe global::Interop.Crypt32.CERT_CONTEXT* __PInvoke(nint __hCertStore_native, global::Interop.Crypt32.CERT_CONTEXT* __pPrevCertContext_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial global::Microsoft.Win32.SafeHandles.SafeCertContextHandle CertFindCertificateInStore(global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle hCertStore, global::Interop.Crypt32.CertEncodingType dwCertEncodingType, global::Interop.Crypt32.CertFindFlags dwFindFlags, global::Interop.Crypt32.CertFindType dwFindType, void* pvFindPara, global::Interop.Crypt32.CERT_CONTEXT* pPrevCertContext)
{
int __lastError;
bool __invokeSucceeded = default;
nint __hCertStore_native = default;
global::Microsoft.Win32.SafeHandles.SafeCertContextHandle __retVal = default;
nint __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertContextHandle>.ManagedToUnmanagedOut __retVal_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle>.ManagedToUnmanagedIn __hCertStore_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hCertStore_native__marshaller.FromManaged(hCertStore);
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hCertStore_native = __hCertStore_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__hCertStore_native, dwCertEncodingType, dwFindFlags, dwFindType, pvFindPara, pPrevCertContext);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__retVal_native__marshaller.FromUnmanaged(__retVal_native);
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__retVal_native__marshaller.Free();
}
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hCertStore_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertFindCertificateInStore", ExactSpelling = true)]
static extern unsafe nint __PInvoke(nint __hCertStore_native, global::Interop.Crypt32.CertEncodingType __dwCertEncodingType_native, global::Interop.Crypt32.CertFindFlags __dwFindFlags_native, global::Interop.Crypt32.CertFindType __dwFindType_native, void* __pvFindPara_native, global::Interop.Crypt32.CERT_CONTEXT* __pPrevCertContext_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial global::Interop.Crypt32.CERT_EXTENSION* CertFindExtension(string pszObjId, int cExtensions, nint rgExtensions)
{
int __lastError;
byte* __pszObjId_native = default;
global::Interop.Crypt32.CERT_EXTENSION* __retVal = default;
// Setup - Perform required setup.
scoped global::System.Runtime.InteropServices.Marshalling.AnsiStringMarshaller.ManagedToUnmanagedIn __pszObjId_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__pszObjId_native__marshaller.FromManaged(pszObjId, stackalloc byte[global::System.Runtime.InteropServices.Marshalling.AnsiStringMarshaller.ManagedToUnmanagedIn.BufferSize]);
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__pszObjId_native = __pszObjId_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal = __PInvoke(__pszObjId_native, cExtensions, rgExtensions);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__pszObjId_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertFindExtension", ExactSpelling = true)]
static extern unsafe global::Interop.Crypt32.CERT_EXTENSION* __PInvoke(byte* __pszObjId_native, int __cExtensions_native, nint __rgExtensions_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial void CertFreeCertificateChain(nint pChainContext)
{
int __lastError;
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__PInvoke(pChainContext);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertFreeCertificateChain", ExactSpelling = true)]
static extern unsafe void __PInvoke(nint __pChainContext_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertFreeCertificateChainEngine", ExactSpelling = true)]
internal static extern partial void CertFreeCertificateChainEngine(nint hChainEngine);
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial bool CertGetCertificateChain(nint hChainEngine, global::Microsoft.Win32.SafeHandles.SafeCertContextHandle pCertContext, global::Interop.Crypt32.FILETIME* pTime, global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle hStore, ref global::Interop.Crypt32.CERT_CHAIN_PARA pChainPara, global::Interop.Crypt32.CertChainFlags dwFlags, nint pvReserved, out global::Microsoft.Win32.SafeHandles.SafeX509ChainHandle ppChainContext)
{
int __lastError;
bool __invokeSucceeded = default;
ppChainContext = default;
nint __pCertContext_native = default;
nint __hStore_native = default;
nint __ppChainContext_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeX509ChainHandle>.ManagedToUnmanagedOut __ppChainContext_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle>.ManagedToUnmanagedIn __hStore_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertContextHandle>.ManagedToUnmanagedIn __pCertContext_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hStore_native__marshaller.FromManaged(hStore);
__pCertContext_native__marshaller.FromManaged(pCertContext);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (global::Interop.Crypt32.CERT_CHAIN_PARA* __pChainPara_native = &pChainPara)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hStore_native = __hStore_native__marshaller.ToUnmanaged();
__pCertContext_native = __pCertContext_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(hChainEngine, __pCertContext_native, pTime, __hStore_native, __pChainPara_native, dwFlags, pvReserved, &__ppChainContext_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__ppChainContext_native__marshaller.FromUnmanaged(__ppChainContext_native);
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
ppChainContext = __ppChainContext_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__ppChainContext_native__marshaller.Free();
}
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hStore_native__marshaller.Free();
__pCertContext_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertGetCertificateChain", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hChainEngine_native, nint __pCertContext_native, global::Interop.Crypt32.FILETIME* __pTime_native, nint __hStore_native, global::Interop.Crypt32.CERT_CHAIN_PARA* __pChainPara_native, global::Interop.Crypt32.CertChainFlags __dwFlags_native, nint __pvReserved_native, nint* __ppChainContext_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial bool CertGetCertificateContextProperty(global::Microsoft.Win32.SafeHandles.SafeCertContextHandle pCertContext, global::Interop.Crypt32.CertContextPropId dwPropId, byte[] pvData, ref int pcbData)
{
int __lastError;
nint __pCertContext_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertContextHandle>.ManagedToUnmanagedIn __pCertContext_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__pCertContext_native__marshaller.FromManaged(pCertContext);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbData_native = &pcbData)
fixed (void* __pvData_native = &global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pvData))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__pCertContext_native = __pCertContext_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__pCertContext_native, dwPropId, (byte*)__pvData_native, __pcbData_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__pCertContext_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertGetCertificateContextProperty", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __pCertContext_native, global::Interop.Crypt32.CertContextPropId __dwPropId_native, byte* __pvData_native, int* __pcbData_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial bool CertGetCertificateContextPropertyPtr(global::Microsoft.Win32.SafeHandles.SafeCertContextHandle pCertContext, global::Interop.Crypt32.CertContextPropId dwPropId, byte* pvData, ref int pcbData)
{
int __lastError;
nint __pCertContext_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertContextHandle>.ManagedToUnmanagedIn __pCertContext_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__pCertContext_native__marshaller.FromManaged(pCertContext);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbData_native = &pcbData)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__pCertContext_native = __pCertContext_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__pCertContext_native, dwPropId, pvData, __pcbData_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__pCertContext_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertGetCertificateContextProperty", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __pCertContext_native, global::Interop.Crypt32.CertContextPropId __dwPropId_native, byte* __pvData_native, int* __pcbData_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial bool CertGetCertificateContextProperty(global::Microsoft.Win32.SafeHandles.SafeCertContextHandle pCertContext, global::Interop.Crypt32.CertContextPropId dwPropId, out nint pvData, ref int pcbData)
{
int __lastError;
pvData = default;
nint __pCertContext_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertContextHandle>.ManagedToUnmanagedIn __pCertContext_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__pCertContext_native__marshaller.FromManaged(pCertContext);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbData_native = &pcbData)
fixed (nint* __pvData_native = &pvData)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__pCertContext_native = __pCertContext_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__pCertContext_native, dwPropId, __pvData_native, __pcbData_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__pCertContext_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertGetCertificateContextProperty", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __pCertContext_native, global::Interop.Crypt32.CertContextPropId __dwPropId_native, nint* __pvData_native, int* __pcbData_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial bool CertGetCertificateContextProperty(global::Microsoft.Win32.SafeHandles.SafeCertContextHandle pCertContext, global::Interop.Crypt32.CertContextPropId dwPropId, out global::Interop.Crypt32.DATA_BLOB pvData, ref int pcbData)
{
int __lastError;
pvData = default;
nint __pCertContext_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertContextHandle>.ManagedToUnmanagedIn __pCertContext_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__pCertContext_native__marshaller.FromManaged(pCertContext);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbData_native = &pcbData)
fixed (global::Interop.Crypt32.DATA_BLOB* __pvData_native = &pvData)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__pCertContext_native = __pCertContext_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__pCertContext_native, dwPropId, __pvData_native, __pcbData_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__pCertContext_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertGetCertificateContextProperty", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __pCertContext_native, global::Interop.Crypt32.CertContextPropId __dwPropId_native, global::Interop.Crypt32.DATA_BLOB* __pvData_native, int* __pcbData_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial bool CertGetCertificateContextPropertyString(global::Microsoft.Win32.SafeHandles.SafeCertContextHandle pCertContext, global::Interop.Crypt32.CertContextPropId dwPropId, byte* pvData, ref uint pcbData)
{
int __lastError;
nint __pCertContext_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertContextHandle>.ManagedToUnmanagedIn __pCertContext_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__pCertContext_native__marshaller.FromManaged(pCertContext);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (uint* __pcbData_native = &pcbData)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__pCertContext_native = __pCertContext_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__pCertContext_native, dwPropId, pvData, __pcbData_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__pCertContext_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertGetCertificateContextProperty", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe int __PInvoke(nint __pCertContext_native, global::Interop.Crypt32.CertContextPropId __dwPropId_native, byte* __pvData_native, uint* __pcbData_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial bool CertGetIntendedKeyUsage(global::Interop.Crypt32.CertEncodingType dwCertEncodingType, global::Interop.Crypt32.CERT_INFO* pCertInfo, out global::Interop.Crypt32.X509KeyUsageFlags pbKeyUsage, int cbKeyUsage)
{
int __lastError;
pbKeyUsage = default;
bool __retVal;
int __retVal_native;
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (global::Interop.Crypt32.X509KeyUsageFlags* __pbKeyUsage_native = &pbKeyUsage)
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(dwCertEncodingType, pCertInfo, __pbKeyUsage_native, cbKeyUsage);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertGetIntendedKeyUsage", ExactSpelling = true)]
static extern unsafe int __PInvoke(global::Interop.Crypt32.CertEncodingType __dwCertEncodingType_native, global::Interop.Crypt32.CERT_INFO* __pCertInfo_native, global::Interop.Crypt32.X509KeyUsageFlags* __pbKeyUsage_native, int __cbKeyUsage_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial int CertGetNameString(global::Microsoft.Win32.SafeHandles.SafeCertContextHandle pCertContext, global::Interop.Crypt32.CertNameType dwType, global::Interop.Crypt32.CertNameFlags dwFlags, in global::Interop.Crypt32.CertNameStringType pvTypePara, char* pszNameString, int cchNameString)
{
int __lastError;
nint __pCertContext_native = default;
int __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertContextHandle>.ManagedToUnmanagedIn __pCertContext_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__pCertContext_native__marshaller.FromManaged(pCertContext);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (global::Interop.Crypt32.CertNameStringType* __pvTypePara_native = &pvTypePara)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__pCertContext_native = __pCertContext_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal = __PInvoke(__pCertContext_native, dwType, dwFlags, __pvTypePara_native, pszNameString, cchNameString);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__pCertContext_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertGetNameStringW", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe int __PInvoke(nint __pCertContext_native, global::Interop.Crypt32.CertNameType __dwType_native, global::Interop.Crypt32.CertNameFlags __dwFlags_native, global::Interop.Crypt32.CertNameStringType* __pvTypePara_native, char* __pszNameString_native, int __cchNameString_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial bool CertGetValidUsages(int cCerts, ref global::Microsoft.Win32.SafeHandles.SafeCertContextHandle rghCerts, out int cNumOIDs, void* rghOIDs, ref int pcbOIDs)
{
int __lastError;
bool __invokeSucceeded = default;
cNumOIDs = default;
nint __rghCerts_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertContextHandle>.ManagedToUnmanagedRef __rghCerts_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__rghCerts_native__marshaller.FromManaged(rghCerts);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbOIDs_native = &pcbOIDs)
fixed (int* __cNumOIDs_native = &cNumOIDs)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__rghCerts_native = __rghCerts_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(cCerts, &__rghCerts_native, __cNumOIDs_native, rghOIDs, __pcbOIDs_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// NotifyForSuccessfulInvoke - Keep alive any managed objects that need to stay alive across the call.
__rghCerts_native__marshaller.OnInvoked();
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__rghCerts_native__marshaller.FromUnmanaged(__rghCerts_native);
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
if (__invokeSucceeded)
{
// GuaranteedUnmarshal - Convert native data to managed data even in the case of an exception during the non-cleanup phases.
rghCerts = __rghCerts_native__marshaller.ToManagedFinally();
}
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__rghCerts_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertGetValidUsages", ExactSpelling = true)]
static extern unsafe int __PInvoke(int __cCerts_native, nint* __rghCerts_native, int* __cNumOIDs_native, void* __rghOIDs_native, int* __pcbOIDs_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial bool CertFreeCertificateContext(nint pCertContext)
{
int __lastError;
bool __retVal;
int __retVal_native;
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(pCertContext);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertFreeCertificateContext", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __pCertContext_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial bool CertVerifyCertificateChainPolicy(nint pszPolicyOID, global::Microsoft.Win32.SafeHandles.SafeX509ChainHandle pChainContext, ref global::Interop.Crypt32.CERT_CHAIN_POLICY_PARA pPolicyPara, ref global::Interop.Crypt32.CERT_CHAIN_POLICY_STATUS pPolicyStatus)
{
int __lastError;
nint __pChainContext_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeX509ChainHandle>.ManagedToUnmanagedIn __pChainContext_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__pChainContext_native__marshaller.FromManaged(pChainContext);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (global::Interop.Crypt32.CERT_CHAIN_POLICY_STATUS* __pPolicyStatus_native = &pPolicyStatus)
fixed (global::Interop.Crypt32.CERT_CHAIN_POLICY_PARA* __pPolicyPara_native = &pPolicyPara)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__pChainContext_native = __pChainContext_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(pszPolicyOID, __pChainContext_native, __pPolicyPara_native, __pPolicyStatus_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__pChainContext_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertVerifyCertificateChainPolicy", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __pszPolicyOID_native, nint __pChainContext_native, global::Interop.Crypt32.CERT_CHAIN_POLICY_PARA* __pPolicyPara_native, global::Interop.Crypt32.CERT_CHAIN_POLICY_STATUS* __pPolicyStatus_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial int CertNameToStr(int dwCertEncodingType, void* pName, int dwStrType, char* psz, int csz)
{
int __lastError;
int __retVal;
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal = __PInvoke(dwCertEncodingType, pName, dwStrType, psz, csz);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertNameToStrW", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe int __PInvoke(int __dwCertEncodingType_native, void* __pName_native, int __dwStrType_native, char* __psz_native, int __csz_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle CertOpenStore(nint lpszStoreProvider, global::Interop.Crypt32.CertEncodingType dwMsgAndCertEncodingType, nint hCryptProv, global::Interop.Crypt32.CertStoreFlags dwFlags, string pvPara)
{
int __lastError;
bool __invokeSucceeded = default;
global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle __retVal = default;
nint __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle>.ManagedToUnmanagedOut __retVal_native__marshaller = new();
try
{
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (void* __pvPara_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pvPara))
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(lpszStoreProvider, dwMsgAndCertEncodingType, hCryptProv, dwFlags, (ushort*)__pvPara_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__retVal_native__marshaller.FromUnmanaged(__retVal_native);
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__retVal_native__marshaller.Free();
}
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertOpenStore", ExactSpelling = true)]
static extern unsafe nint __PInvoke(nint __lpszStoreProvider_native, global::Interop.Crypt32.CertEncodingType __dwMsgAndCertEncodingType_native, nint __hCryptProv_native, global::Interop.Crypt32.CertStoreFlags __dwFlags_native, ushort* __pvPara_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
public static partial bool CertSaveStore(global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle hCertStore, global::Interop.Crypt32.CertEncodingType dwMsgAndCertEncodingType, global::Interop.Crypt32.CertStoreSaveAs dwSaveAs, global::Interop.Crypt32.CertStoreSaveTo dwSaveTo, ref global::Interop.Crypt32.DATA_BLOB pvSaveToPara, int dwFlags)
{
int __lastError;
nint __hCertStore_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle>.ManagedToUnmanagedIn __hCertStore_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hCertStore_native__marshaller.FromManaged(hCertStore);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (global::Interop.Crypt32.DATA_BLOB* __pvSaveToPara_native = &pvSaveToPara)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hCertStore_native = __hCertStore_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__hCertStore_native, dwMsgAndCertEncodingType, dwSaveAs, dwSaveTo, __pvSaveToPara_native, dwFlags);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hCertStore_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertSaveStore", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hCertStore_native, global::Interop.Crypt32.CertEncodingType __dwMsgAndCertEncodingType_native, global::Interop.Crypt32.CertStoreSaveAs __dwSaveAs_native, global::Interop.Crypt32.CertStoreSaveTo __dwSaveTo_native, global::Interop.Crypt32.DATA_BLOB* __pvSaveToPara_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial bool CertSerializeCertificateStoreElement(global::Microsoft.Win32.SafeHandles.SafeCertContextHandle pCertContext, int dwFlags, byte[] pbElement, ref int pcbElement)
{
int __lastError;
nint __pCertContext_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertContextHandle>.ManagedToUnmanagedIn __pCertContext_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__pCertContext_native__marshaller.FromManaged(pCertContext);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbElement_native = &pcbElement)
fixed (void* __pbElement_native = &global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbElement))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__pCertContext_native = __pCertContext_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__pCertContext_native, dwFlags, (byte*)__pbElement_native, __pcbElement_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__pCertContext_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertSerializeCertificateStoreElement", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __pCertContext_native, int __dwFlags_native, byte* __pbElement_native, int* __pcbElement_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial bool CertSetCertificateContextProperty(global::Microsoft.Win32.SafeHandles.SafeCertContextHandle pCertContext, global::Interop.Crypt32.CertContextPropId dwPropId, global::Interop.Crypt32.CertSetPropertyFlags dwFlags, global::Interop.Crypt32.CRYPT_KEY_PROV_INFO* pvData)
{
int __lastError;
nint __pCertContext_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertContextHandle>.ManagedToUnmanagedIn __pCertContext_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__pCertContext_native__marshaller.FromManaged(pCertContext);
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__pCertContext_native = __pCertContext_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__pCertContext_native, dwPropId, dwFlags, pvData);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__pCertContext_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertSetCertificateContextProperty", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __pCertContext_native, global::Interop.Crypt32.CertContextPropId __dwPropId_native, global::Interop.Crypt32.CertSetPropertyFlags __dwFlags_native, global::Interop.Crypt32.CRYPT_KEY_PROV_INFO* __pvData_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial bool CertSetCertificateContextProperty(nint pCertContext, global::Interop.Crypt32.CertContextPropId dwPropId, global::Interop.Crypt32.CertSetPropertyFlags dwFlags, global::Interop.Crypt32.CRYPT_KEY_PROV_INFO* pvData)
{
int __lastError;
bool __retVal;
int __retVal_native;
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(pCertContext, dwPropId, dwFlags, pvData);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertSetCertificateContextProperty", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __pCertContext_native, global::Interop.Crypt32.CertContextPropId __dwPropId_native, global::Interop.Crypt32.CertSetPropertyFlags __dwFlags_native, global::Interop.Crypt32.CRYPT_KEY_PROV_INFO* __pvData_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial bool CertSetCertificateContextProperty(global::Microsoft.Win32.SafeHandles.SafeCertContextHandle pCertContext, global::Interop.Crypt32.CertContextPropId dwPropId, global::Interop.Crypt32.CertSetPropertyFlags dwFlags, global::Interop.Crypt32.DATA_BLOB* pvData)
{
int __lastError;
nint __pCertContext_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertContextHandle>.ManagedToUnmanagedIn __pCertContext_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__pCertContext_native__marshaller.FromManaged(pCertContext);
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__pCertContext_native = __pCertContext_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__pCertContext_native, dwPropId, dwFlags, pvData);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__pCertContext_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertSetCertificateContextProperty", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __pCertContext_native, global::Interop.Crypt32.CertContextPropId __dwPropId_native, global::Interop.Crypt32.CertSetPropertyFlags __dwFlags_native, global::Interop.Crypt32.DATA_BLOB* __pvData_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial bool CertSetCertificateContextProperty(global::Microsoft.Win32.SafeHandles.SafeCertContextHandle pCertContext, global::Interop.Crypt32.CertContextPropId dwPropId, global::Interop.Crypt32.CertSetPropertyFlags dwFlags, global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle keyHandle)
{
int __lastError;
nint __pCertContext_native = default;
nint __keyHandle_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle>.ManagedToUnmanagedIn __keyHandle_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertContextHandle>.ManagedToUnmanagedIn __pCertContext_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__keyHandle_native__marshaller.FromManaged(keyHandle);
__pCertContext_native__marshaller.FromManaged(pCertContext);
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__keyHandle_native = __keyHandle_native__marshaller.ToUnmanaged();
__pCertContext_native = __pCertContext_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__pCertContext_native, dwPropId, dwFlags, __keyHandle_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__keyHandle_native__marshaller.Free();
__pCertContext_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertSetCertificateContextProperty", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __pCertContext_native, global::Interop.Crypt32.CertContextPropId __dwPropId_native, global::Interop.Crypt32.CertSetPropertyFlags __dwFlags_native, nint __keyHandle_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial bool CertSetCertificateContextProperty(nint pCertContext, global::Interop.Crypt32.CertContextPropId dwPropId, global::Interop.Crypt32.CertSetPropertyFlags dwFlags, global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle keyHandle)
{
int __lastError;
nint __keyHandle_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle>.ManagedToUnmanagedIn __keyHandle_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__keyHandle_native__marshaller.FromManaged(keyHandle);
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__keyHandle_native = __keyHandle_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(pCertContext, dwPropId, dwFlags, __keyHandle_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__keyHandle_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertSetCertificateContextProperty", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __pCertContext_native, global::Interop.Crypt32.CertContextPropId __dwPropId_native, global::Interop.Crypt32.CertSetPropertyFlags __dwFlags_native, nint __keyHandle_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial bool CertStrToName(global::Interop.Crypt32.CertEncodingType dwCertEncodingType, string pszX500, global::Interop.Crypt32.CertNameStrTypeAndFlags dwStrType, nint pvReserved, byte[] pbEncoded, ref int pcbEncoded, nint ppszError)
{
int __lastError;
bool __retVal;
int __retVal_native;
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbEncoded_native = &pcbEncoded)
fixed (void* __pbEncoded_native = &global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbEncoded))
fixed (void* __pszX500_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pszX500))
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(dwCertEncodingType, (ushort*)__pszX500_native, dwStrType, pvReserved, (byte*)__pbEncoded_native, __pcbEncoded_native, ppszError);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertStrToNameW", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe int __PInvoke(global::Interop.Crypt32.CertEncodingType __dwCertEncodingType_native, ushort* __pszX500_native, global::Interop.Crypt32.CertNameStrTypeAndFlags __dwStrType_native, nint __pvReserved_native, byte* __pbEncoded_native, int* __pcbEncoded_native, nint __ppszError_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial int CertVerifyTimeValidity(ref global::Interop.Crypt32.FILETIME pTimeToVerify, global::Interop.Crypt32.CERT_INFO* pCertInfo)
{
int __lastError;
int __retVal;
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (global::Interop.Crypt32.FILETIME* __pTimeToVerify_native = &pTimeToVerify)
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal = __PInvoke(__pTimeToVerify_native, pCertInfo);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CertVerifyTimeValidity", ExactSpelling = true)]
static extern unsafe int __PInvoke(global::Interop.Crypt32.FILETIME* __pTimeToVerify_native, global::Interop.Crypt32.CERT_INFO* __pCertInfo_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
public static partial bool CryptAcquireCertificatePrivateKey(global::Microsoft.Win32.SafeHandles.SafeCertContextHandle pCert, global::Interop.Crypt32.CryptAcquireCertificatePrivateKeyFlags dwFlags, nint pvParameters, out global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle phCryptProvOrNCryptKey, out global::Interop.Crypt32.CryptKeySpec pdwKeySpec, out bool pfCallerFreeProvOrNCryptKey)
{
int __lastError;
bool __invokeSucceeded = default;
phCryptProvOrNCryptKey = default;
pdwKeySpec = default;
pfCallerFreeProvOrNCryptKey = default;
nint __pCert_native = default;
nint __phCryptProvOrNCryptKey_native = default;
int __pfCallerFreeProvOrNCryptKey_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle>.ManagedToUnmanagedOut __phCryptProvOrNCryptKey_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertContextHandle>.ManagedToUnmanagedIn __pCert_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__pCert_native__marshaller.FromManaged(pCert);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (global::Interop.Crypt32.CryptKeySpec* __pdwKeySpec_native = &pdwKeySpec)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__pCert_native = __pCert_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__pCert_native, dwFlags, pvParameters, &__phCryptProvOrNCryptKey_native, __pdwKeySpec_native, &__pfCallerFreeProvOrNCryptKey_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__phCryptProvOrNCryptKey_native__marshaller.FromUnmanaged(__phCryptProvOrNCryptKey_native);
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
pfCallerFreeProvOrNCryptKey = __pfCallerFreeProvOrNCryptKey_native != 0;
phCryptProvOrNCryptKey = __phCryptProvOrNCryptKey_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__phCryptProvOrNCryptKey_native__marshaller.Free();
}
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__pCert_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CryptAcquireCertificatePrivateKey", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __pCert_native, global::Interop.Crypt32.CryptAcquireCertificatePrivateKeyFlags __dwFlags_native, nint __pvParameters_native, nint* __phCryptProvOrNCryptKey_native, global::Interop.Crypt32.CryptKeySpec* __pdwKeySpec_native, int* __pfCallerFreeProvOrNCryptKey_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial bool CryptDecodeObject(global::Interop.Crypt32.CertEncodingType dwCertEncodingType, nint lpszStructType, byte[] pbEncoded, int cbEncoded, global::Interop.Crypt32.CryptDecodeObjectFlags dwFlags, byte[] pvStructInfo, ref int pcbStructInfo)
{
int __lastError;
bool __retVal;
int __retVal_native;
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbStructInfo_native = &pcbStructInfo)
fixed (void* __pvStructInfo_native = &global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pvStructInfo))
fixed (void* __pbEncoded_native = &global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbEncoded))
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(dwCertEncodingType, lpszStructType, (byte*)__pbEncoded_native, cbEncoded, dwFlags, (byte*)__pvStructInfo_native, __pcbStructInfo_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CryptDecodeObject", ExactSpelling = true)]
static extern unsafe int __PInvoke(global::Interop.Crypt32.CertEncodingType __dwCertEncodingType_native, nint __lpszStructType_native, byte* __pbEncoded_native, int __cbEncoded_native, global::Interop.Crypt32.CryptDecodeObjectFlags __dwFlags_native, byte* __pvStructInfo_native, int* __pcbStructInfo_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial bool CryptDecodeObjectPointer(global::Interop.Crypt32.CertEncodingType dwCertEncodingType, nint lpszStructType, byte[] pbEncoded, int cbEncoded, global::Interop.Crypt32.CryptDecodeObjectFlags dwFlags, void* pvStructInfo, ref int pcbStructInfo)
{
int __lastError;
bool __retVal;
int __retVal_native;
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbStructInfo_native = &pcbStructInfo)
fixed (void* __pbEncoded_native = &global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbEncoded))
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(dwCertEncodingType, lpszStructType, (byte*)__pbEncoded_native, cbEncoded, dwFlags, pvStructInfo, __pcbStructInfo_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CryptDecodeObject", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe int __PInvoke(global::Interop.Crypt32.CertEncodingType __dwCertEncodingType_native, nint __lpszStructType_native, byte* __pbEncoded_native, int __cbEncoded_native, global::Interop.Crypt32.CryptDecodeObjectFlags __dwFlags_native, void* __pvStructInfo_native, int* __pcbStructInfo_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial bool CryptDecodeObjectPointer(global::Interop.Crypt32.CertEncodingType dwCertEncodingType, nint lpszStructType, byte* pbEncoded, int cbEncoded, global::Interop.Crypt32.CryptDecodeObjectFlags dwFlags, void* pvStructInfo, ref int pcbStructInfo)
{
int __lastError;
bool __retVal;
int __retVal_native;
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbStructInfo_native = &pcbStructInfo)
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(dwCertEncodingType, lpszStructType, pbEncoded, cbEncoded, dwFlags, pvStructInfo, __pcbStructInfo_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CryptDecodeObject", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe int __PInvoke(global::Interop.Crypt32.CertEncodingType __dwCertEncodingType_native, nint __lpszStructType_native, byte* __pbEncoded_native, int __cbEncoded_native, global::Interop.Crypt32.CryptDecodeObjectFlags __dwFlags_native, void* __pvStructInfo_native, int* __pcbStructInfo_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial bool CryptDecodeObjectPointer(global::Interop.Crypt32.CertEncodingType dwCertEncodingType, string lpszStructType, byte[] pbEncoded, int cbEncoded, global::Interop.Crypt32.CryptDecodeObjectFlags dwFlags, void* pvStructInfo, ref int pcbStructInfo)
{
int __lastError;
byte* __lpszStructType_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
scoped global::System.Runtime.InteropServices.Marshalling.AnsiStringMarshaller.ManagedToUnmanagedIn __lpszStructType_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__lpszStructType_native__marshaller.FromManaged(lpszStructType, stackalloc byte[global::System.Runtime.InteropServices.Marshalling.AnsiStringMarshaller.ManagedToUnmanagedIn.BufferSize]);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbStructInfo_native = &pcbStructInfo)
fixed (void* __pbEncoded_native = &global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbEncoded))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__lpszStructType_native = __lpszStructType_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(dwCertEncodingType, __lpszStructType_native, (byte*)__pbEncoded_native, cbEncoded, dwFlags, pvStructInfo, __pcbStructInfo_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__lpszStructType_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CryptDecodeObject", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe int __PInvoke(global::Interop.Crypt32.CertEncodingType __dwCertEncodingType_native, byte* __lpszStructType_native, byte* __pbEncoded_native, int __cbEncoded_native, global::Interop.Crypt32.CryptDecodeObjectFlags __dwFlags_native, void* __pvStructInfo_native, int* __pcbStructInfo_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial bool CryptEncodeObject(global::Interop.Crypt32.CertEncodingType dwCertEncodingType, nint lpszStructType, void* pvStructInfo, byte[] pbEncoded, ref int pcbEncoded)
{
int __lastError;
bool __retVal;
int __retVal_native;
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbEncoded_native = &pcbEncoded)
fixed (void* __pbEncoded_native = &global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbEncoded))
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(dwCertEncodingType, lpszStructType, pvStructInfo, (byte*)__pbEncoded_native, __pcbEncoded_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CryptEncodeObject", ExactSpelling = true)]
static extern unsafe int __PInvoke(global::Interop.Crypt32.CertEncodingType __dwCertEncodingType_native, nint __lpszStructType_native, void* __pvStructInfo_native, byte* __pbEncoded_native, int* __pcbEncoded_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial bool CryptEncodeObject(global::Interop.Crypt32.CertEncodingType dwCertEncodingType, string lpszStructType, void* pvStructInfo, byte[] pbEncoded, ref int pcbEncoded)
{
int __lastError;
byte* __lpszStructType_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
scoped global::System.Runtime.InteropServices.Marshalling.AnsiStringMarshaller.ManagedToUnmanagedIn __lpszStructType_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__lpszStructType_native__marshaller.FromManaged(lpszStructType, stackalloc byte[global::System.Runtime.InteropServices.Marshalling.AnsiStringMarshaller.ManagedToUnmanagedIn.BufferSize]);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbEncoded_native = &pcbEncoded)
fixed (void* __pbEncoded_native = &global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbEncoded))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__lpszStructType_native = __lpszStructType_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(dwCertEncodingType, __lpszStructType_native, pvStructInfo, (byte*)__pbEncoded_native, __pcbEncoded_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__lpszStructType_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CryptEncodeObject", ExactSpelling = true)]
static extern unsafe int __PInvoke(global::Interop.Crypt32.CertEncodingType __dwCertEncodingType_native, byte* __lpszStructType_native, void* __pvStructInfo_native, byte* __pbEncoded_native, int* __pcbEncoded_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial bool CryptFormatObject(int dwCertEncodingType, int dwFormatType, int dwFormatStrType, nint pFormatStruct, byte* lpszStructType, byte[] pbEncoded, int cbEncoded, void* pbFormat, ref int pcbFormat)
{
int __lastError;
bool __retVal;
int __retVal_native;
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbFormat_native = &pcbFormat)
fixed (void* __pbEncoded_native = &global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbEncoded))
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(dwCertEncodingType, dwFormatType, dwFormatStrType, pFormatStruct, lpszStructType, (byte*)__pbEncoded_native, cbEncoded, pbFormat, __pcbFormat_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CryptFormatObject", ExactSpelling = true)]
static extern unsafe int __PInvoke(int __dwCertEncodingType_native, int __dwFormatType_native, int __dwFormatStrType_native, nint __pFormatStruct_native, byte* __lpszStructType_native, byte* __pbEncoded_native, int __cbEncoded_native, void* __pbFormat_native, int* __pcbFormat_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial bool CryptImportPublicKeyInfoEx2(global::Interop.Crypt32.CertEncodingType dwCertEncodingType, global::Interop.Crypt32.CERT_PUBLIC_KEY_INFO* pInfo, global::Interop.Crypt32.CryptImportPublicKeyInfoFlags dwFlags, void* pvAuxInfo, out global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle phKey)
{
int __lastError;
bool __invokeSucceeded = default;
phKey = default;
nint __phKey_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeBCryptKeyHandle>.ManagedToUnmanagedOut __phKey_native__marshaller = new();
try
{
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(dwCertEncodingType, pInfo, dwFlags, pvAuxInfo, &__phKey_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__phKey_native__marshaller.FromUnmanaged(__phKey_native);
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
phKey = __phKey_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__phKey_native__marshaller.Free();
}
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CryptImportPublicKeyInfoEx2", ExactSpelling = true)]
static extern unsafe int __PInvoke(global::Interop.Crypt32.CertEncodingType __dwCertEncodingType_native, global::Interop.Crypt32.CERT_PUBLIC_KEY_INFO* __pInfo_native, global::Interop.Crypt32.CryptImportPublicKeyInfoFlags __dwFlags_native, void* __pvAuxInfo_native, nint* __phKey_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial bool CryptMsgClose(nint hCryptMsg)
{
int __lastError;
bool __retVal;
int __retVal_native;
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(hCryptMsg);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CryptMsgClose", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hCryptMsg_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial bool CryptMsgGetParam(global::Microsoft.Win32.SafeHandles.SafeCryptMsgHandle hCryptMsg, global::Interop.Crypt32.CryptMsgParamType dwParamType, int dwIndex, out int pvData, ref int pcbData)
{
int __lastError;
pvData = default;
nint __hCryptMsg_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCryptMsgHandle>.ManagedToUnmanagedIn __hCryptMsg_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hCryptMsg_native__marshaller.FromManaged(hCryptMsg);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbData_native = &pcbData)
fixed (int* __pvData_native = &pvData)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hCryptMsg_native = __hCryptMsg_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__hCryptMsg_native, dwParamType, dwIndex, __pvData_native, __pcbData_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hCryptMsg_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CryptMsgGetParam", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hCryptMsg_native, global::Interop.Crypt32.CryptMsgParamType __dwParamType_native, int __dwIndex_native, int* __pvData_native, int* __pcbData_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial bool CryptMsgGetParam(global::Microsoft.Win32.SafeHandles.SafeCryptMsgHandle hCryptMsg, global::Interop.Crypt32.CryptMsgParamType dwParamType, int dwIndex, byte* pvData, ref int pcbData)
{
int __lastError;
nint __hCryptMsg_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCryptMsgHandle>.ManagedToUnmanagedIn __hCryptMsg_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hCryptMsg_native__marshaller.FromManaged(hCryptMsg);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbData_native = &pcbData)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hCryptMsg_native = __hCryptMsg_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__hCryptMsg_native, dwParamType, dwIndex, pvData, __pcbData_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hCryptMsg_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CryptMsgGetParam", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hCryptMsg_native, global::Interop.Crypt32.CryptMsgParamType __dwParamType_native, int __dwIndex_native, byte* __pvData_native, int* __pcbData_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial bool CryptMsgGetParam(global::Microsoft.Win32.SafeHandles.SafeCryptMsgHandle hCryptMsg, global::Interop.Crypt32.CryptMsgParamType dwParamType, int dwIndex, out global::Interop.Crypt32.CryptMsgType pvData, ref int pcbData)
{
int __lastError;
pvData = default;
nint __hCryptMsg_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCryptMsgHandle>.ManagedToUnmanagedIn __hCryptMsg_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hCryptMsg_native__marshaller.FromManaged(hCryptMsg);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbData_native = &pcbData)
fixed (global::Interop.Crypt32.CryptMsgType* __pvData_native = &pvData)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hCryptMsg_native = __hCryptMsg_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__hCryptMsg_native, dwParamType, dwIndex, __pvData_native, __pcbData_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hCryptMsg_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CryptMsgGetParam", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hCryptMsg_native, global::Interop.Crypt32.CryptMsgParamType __dwParamType_native, int __dwIndex_native, global::Interop.Crypt32.CryptMsgType* __pvData_native, int* __pcbData_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial bool CryptMsgGetParam(global::Microsoft.Win32.SafeHandles.SafeCryptMsgHandle hCryptMsg, global::Interop.Crypt32.CryptMsgParamType dwParamType, int dwIndex, nint pvData, ref int pcbData)
{
int __lastError;
nint __hCryptMsg_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCryptMsgHandle>.ManagedToUnmanagedIn __hCryptMsg_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hCryptMsg_native__marshaller.FromManaged(hCryptMsg);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbData_native = &pcbData)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hCryptMsg_native = __hCryptMsg_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__hCryptMsg_native, dwParamType, dwIndex, pvData, __pcbData_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hCryptMsg_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CryptMsgGetParam", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hCryptMsg_native, global::Interop.Crypt32.CryptMsgParamType __dwParamType_native, int __dwIndex_native, nint __pvData_native, int* __pcbData_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial bool CryptQueryObject(global::Interop.Crypt32.CertQueryObjectType dwObjectType, void* pvObject, global::Interop.Crypt32.ExpectedContentTypeFlags dwExpectedContentTypeFlags, global::Interop.Crypt32.ExpectedFormatTypeFlags dwExpectedFormatTypeFlags, int dwFlags, out global::Interop.Crypt32.CertEncodingType pdwMsgAndCertEncodingType, out global::Interop.Crypt32.ContentType pdwContentType, out global::Interop.Crypt32.FormatType pdwFormatType, out global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle phCertStore, out global::Microsoft.Win32.SafeHandles.SafeCryptMsgHandle phMsg, out global::Microsoft.Win32.SafeHandles.SafeCertContextHandle ppvContext)
{
int __lastError;
bool __invokeSucceeded = default;
pdwMsgAndCertEncodingType = default;
pdwContentType = default;
pdwFormatType = default;
phCertStore = default;
phMsg = default;
ppvContext = default;
nint __phCertStore_native = default;
nint __phMsg_native = default;
nint __ppvContext_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertContextHandle>.ManagedToUnmanagedOut __ppvContext_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCryptMsgHandle>.ManagedToUnmanagedOut __phMsg_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle>.ManagedToUnmanagedOut __phCertStore_native__marshaller = new();
try
{
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (global::Interop.Crypt32.FormatType* __pdwFormatType_native = &pdwFormatType)
fixed (global::Interop.Crypt32.ContentType* __pdwContentType_native = &pdwContentType)
fixed (global::Interop.Crypt32.CertEncodingType* __pdwMsgAndCertEncodingType_native = &pdwMsgAndCertEncodingType)
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(dwObjectType, pvObject, dwExpectedContentTypeFlags, dwExpectedFormatTypeFlags, dwFlags, __pdwMsgAndCertEncodingType_native, __pdwContentType_native, __pdwFormatType_native, &__phCertStore_native, &__phMsg_native, &__ppvContext_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__ppvContext_native__marshaller.FromUnmanaged(__ppvContext_native);
__phMsg_native__marshaller.FromUnmanaged(__phMsg_native);
__phCertStore_native__marshaller.FromUnmanaged(__phCertStore_native);
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
ppvContext = __ppvContext_native__marshaller.ToManaged();
phMsg = __phMsg_native__marshaller.ToManaged();
phCertStore = __phCertStore_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__ppvContext_native__marshaller.Free();
__phMsg_native__marshaller.Free();
__phCertStore_native__marshaller.Free();
}
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CryptQueryObject", ExactSpelling = true)]
static extern unsafe int __PInvoke(global::Interop.Crypt32.CertQueryObjectType __dwObjectType_native, void* __pvObject_native, global::Interop.Crypt32.ExpectedContentTypeFlags __dwExpectedContentTypeFlags_native, global::Interop.Crypt32.ExpectedFormatTypeFlags __dwExpectedFormatTypeFlags_native, int __dwFlags_native, global::Interop.Crypt32.CertEncodingType* __pdwMsgAndCertEncodingType_native, global::Interop.Crypt32.ContentType* __pdwContentType_native, global::Interop.Crypt32.FormatType* __pdwFormatType_native, nint* __phCertStore_native, nint* __phMsg_native, nint* __ppvContext_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial bool CryptQueryObject(global::Interop.Crypt32.CertQueryObjectType dwObjectType, void* pvObject, global::Interop.Crypt32.ExpectedContentTypeFlags dwExpectedContentTypeFlags, global::Interop.Crypt32.ExpectedFormatTypeFlags dwExpectedFormatTypeFlags, int dwFlags, nint pdwMsgAndCertEncodingType, out global::Interop.Crypt32.ContentType pdwContentType, nint pdwFormatType, nint phCertStore, nint phMsg, nint ppvContext)
{
int __lastError;
pdwContentType = default;
bool __retVal;
int __retVal_native;
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (global::Interop.Crypt32.ContentType* __pdwContentType_native = &pdwContentType)
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(dwObjectType, pvObject, dwExpectedContentTypeFlags, dwExpectedFormatTypeFlags, dwFlags, pdwMsgAndCertEncodingType, __pdwContentType_native, pdwFormatType, phCertStore, phMsg, ppvContext);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CryptQueryObject", ExactSpelling = true)]
static extern unsafe int __PInvoke(global::Interop.Crypt32.CertQueryObjectType __dwObjectType_native, void* __pvObject_native, global::Interop.Crypt32.ExpectedContentTypeFlags __dwExpectedContentTypeFlags_native, global::Interop.Crypt32.ExpectedFormatTypeFlags __dwExpectedFormatTypeFlags_native, int __dwFlags_native, nint __pdwMsgAndCertEncodingType_native, global::Interop.Crypt32.ContentType* __pdwContentType_native, nint __pdwFormatType_native, nint __phCertStore_native, nint __phMsg_native, nint __ppvContext_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial bool CryptQueryObject(global::Interop.Crypt32.CertQueryObjectType dwObjectType, void* pvObject, global::Interop.Crypt32.ExpectedContentTypeFlags dwExpectedContentTypeFlags, global::Interop.Crypt32.ExpectedFormatTypeFlags dwExpectedFormatTypeFlags, int dwFlags, nint pdwMsgAndCertEncodingType, out global::Interop.Crypt32.ContentType pdwContentType, nint pdwFormatType, out global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle phCertStore, nint phMsg, nint ppvContext)
{
int __lastError;
bool __invokeSucceeded = default;
pdwContentType = default;
phCertStore = default;
nint __phCertStore_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle>.ManagedToUnmanagedOut __phCertStore_native__marshaller = new();
try
{
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (global::Interop.Crypt32.ContentType* __pdwContentType_native = &pdwContentType)
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(dwObjectType, pvObject, dwExpectedContentTypeFlags, dwExpectedFormatTypeFlags, dwFlags, pdwMsgAndCertEncodingType, __pdwContentType_native, pdwFormatType, &__phCertStore_native, phMsg, ppvContext);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__phCertStore_native__marshaller.FromUnmanaged(__phCertStore_native);
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
phCertStore = __phCertStore_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__phCertStore_native__marshaller.Free();
}
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CryptQueryObject", ExactSpelling = true)]
static extern unsafe int __PInvoke(global::Interop.Crypt32.CertQueryObjectType __dwObjectType_native, void* __pvObject_native, global::Interop.Crypt32.ExpectedContentTypeFlags __dwExpectedContentTypeFlags_native, global::Interop.Crypt32.ExpectedFormatTypeFlags __dwExpectedFormatTypeFlags_native, int __dwFlags_native, nint __pdwMsgAndCertEncodingType_native, global::Interop.Crypt32.ContentType* __pdwContentType_native, nint __pdwFormatType_native, nint* __phCertStore_native, nint __phMsg_native, nint __ppvContext_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial bool CryptQueryObject(global::Interop.Crypt32.CertQueryObjectType dwObjectType, void* pvObject, global::Interop.Crypt32.ExpectedContentTypeFlags dwExpectedContentTypeFlags, global::Interop.Crypt32.ExpectedFormatTypeFlags dwExpectedFormatTypeFlags, int dwFlags, nint pdwMsgAndCertEncodingType, out global::Interop.Crypt32.ContentType pdwContentType, nint pdwFormatType, nint phCertStore, nint phMsg, out global::Microsoft.Win32.SafeHandles.SafeCertContextHandle ppvContext)
{
int __lastError;
bool __invokeSucceeded = default;
pdwContentType = default;
ppvContext = default;
nint __ppvContext_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertContextHandle>.ManagedToUnmanagedOut __ppvContext_native__marshaller = new();
try
{
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (global::Interop.Crypt32.ContentType* __pdwContentType_native = &pdwContentType)
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(dwObjectType, pvObject, dwExpectedContentTypeFlags, dwExpectedFormatTypeFlags, dwFlags, pdwMsgAndCertEncodingType, __pdwContentType_native, pdwFormatType, phCertStore, phMsg, &__ppvContext_native);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__ppvContext_native__marshaller.FromUnmanaged(__ppvContext_native);
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
ppvContext = __ppvContext_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__ppvContext_native__marshaller.Free();
}
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CryptQueryObject", ExactSpelling = true)]
static extern unsafe int __PInvoke(global::Interop.Crypt32.CertQueryObjectType __dwObjectType_native, void* __pvObject_native, global::Interop.Crypt32.ExpectedContentTypeFlags __dwExpectedContentTypeFlags_native, global::Interop.Crypt32.ExpectedFormatTypeFlags __dwExpectedFormatTypeFlags_native, int __dwFlags_native, nint __pdwMsgAndCertEncodingType_native, global::Interop.Crypt32.ContentType* __pdwContentType_native, nint __pdwFormatType_native, nint __phCertStore_native, nint __phMsg_native, nint* __ppvContext_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CryptFindOIDInfo", ExactSpelling = true)]
private static unsafe extern partial global::Interop.Crypt32.CRYPT_OID_INFO* CryptFindOIDInfo(global::Interop.Crypt32.CryptOidInfoKeyType dwKeyType, nint pvKey, global::System.Security.Cryptography.OidGroup group);
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "CryptFindOIDInfo", ExactSpelling = true)]
private static unsafe extern partial global::Interop.Crypt32.CRYPT_OID_INFO* CryptFindOIDInfo(global::Interop.Crypt32.CryptOidInfoKeyType dwKeyType, void* pvKey, global::System.Security.Cryptography.OidGroup group);
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial bool PFXExportCertStoreEx(global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle hStore, ref global::Interop.Crypt32.DATA_BLOB pPFX, global::Microsoft.Win32.SafeHandles.SafePasswordHandle szPassword, global::Interop.Crypt32.PKCS12_PBES2_EXPORT_PARAMS* pvPara, global::Interop.Crypt32.PFXExportFlags dwFlags)
{
int __lastError;
nint __hStore_native = default;
nint __szPassword_native = default;
bool __retVal = default;
int __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafePasswordHandle>.ManagedToUnmanagedIn __szPassword_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle>.ManagedToUnmanagedIn __hStore_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__szPassword_native__marshaller.FromManaged(szPassword);
__hStore_native__marshaller.FromManaged(hStore);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (global::Interop.Crypt32.DATA_BLOB* __pPFX_native = &pPFX)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__szPassword_native = __szPassword_native__marshaller.ToUnmanaged();
__hStore_native = __hStore_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__hStore_native, __pPFX_native, __szPassword_native, pvPara, dwFlags);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native != 0;
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__szPassword_native__marshaller.Free();
__hStore_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "PFXExportCertStoreEx", ExactSpelling = true)]
static extern unsafe int __PInvoke(nint __hStore_native, global::Interop.Crypt32.DATA_BLOB* __pPFX_native, nint __szPassword_native, global::Interop.Crypt32.PKCS12_PBES2_EXPORT_PARAMS* __pvPara_native, global::Interop.Crypt32.PFXExportFlags __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle PFXImportCertStore(ref global::Interop.Crypt32.DATA_BLOB pPFX, global::Microsoft.Win32.SafeHandles.SafePasswordHandle password, global::Interop.Crypt32.PfxCertStoreFlags dwFlags)
{
int __lastError;
bool __invokeSucceeded = default;
nint __password_native = default;
global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle __retVal = default;
nint __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle>.ManagedToUnmanagedOut __retVal_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafePasswordHandle>.ManagedToUnmanagedIn __password_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__password_native__marshaller.FromManaged(password);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (global::Interop.Crypt32.DATA_BLOB* __pPFX_native = &pPFX)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__password_native = __password_native__marshaller.ToUnmanaged();
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__pPFX_native, __password_native, dwFlags);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__retVal_native__marshaller.FromUnmanaged(__retVal_native);
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__retVal_native__marshaller.Free();
}
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__password_native__marshaller.Free();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "PFXImportCertStore", ExactSpelling = true)]
static extern unsafe nint __PInvoke(global::Interop.Crypt32.DATA_BLOB* __pPFX_native, nint __password_native, global::Interop.Crypt32.PfxCertStoreFlags __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Crypt32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle PFXImportCertStore(ref global::Interop.Crypt32.DATA_BLOB pPFX, char* password, global::Interop.Crypt32.PfxCertStoreFlags dwFlags)
{
int __lastError;
bool __invokeSucceeded = default;
global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle __retVal = default;
nint __retVal_native = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeCertStoreHandle>.ManagedToUnmanagedOut __retVal_native__marshaller = new();
try
{
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (global::Interop.Crypt32.DATA_BLOB* __pPFX_native = &pPFX)
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal_native = __PInvoke(__pPFX_native, password, dwFlags);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__retVal_native__marshaller.FromUnmanaged(__retVal_native);
// Unmarshal - Convert native data to managed data.
__retVal = __retVal_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__retVal_native__marshaller.Free();
}
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("crypt32.dll", EntryPoint = "PFXImportCertStore", ExactSpelling = true)]
static extern unsafe nint __PInvoke(global::Interop.Crypt32.DATA_BLOB* __pPFX_native, char* __password_native, global::Interop.Crypt32.PfxCertStoreFlags __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class Kernel32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
private static unsafe partial int FormatMessage(int dwFlags, nint lpSource, uint dwMessageId, int dwLanguageId, void* lpBuffer, int nSize, nint arguments)
{
int __lastError;
int __retVal;
{
global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
__retVal = __PInvoke(dwFlags, lpSource, dwMessageId, dwLanguageId, lpBuffer, nSize, arguments);
__lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
}
global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("kernel32.dll", EntryPoint = "FormatMessageW", ExactSpelling = true)]
static extern unsafe int __PInvoke(int __dwFlags_native, nint __lpSource_native, uint __dwMessageId_native, int __dwLanguageId_native, void* __lpBuffer_native, int __nSize_native, nint __arguments_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class NCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial global::Interop.NCrypt.ErrorCode NCryptEncrypt(global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle hKey, global::System.ReadOnlySpan<byte> pbInput, int cbInput, void* pPaddingInfo, global::System.Span<byte> pbOutput, int cbOutput, out int pcbResult, global::Interop.NCrypt.AsymmetricPaddingMode dwFlags)
{
pcbResult = default;
nint __hKey_native = default;
global::Interop.NCrypt.ErrorCode __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hKey_native__marshaller.FromManaged(hKey);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbResult_native = &pcbResult)
fixed (void* __pbOutput_native = &global::System.Runtime.InteropServices.Marshalling.SpanMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbOutput))
fixed (void* __pbInput_native = &global::System.Runtime.InteropServices.Marshalling.ReadOnlySpanMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbInput))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hKey_native, (byte*)__pbInput_native, cbInput, pPaddingInfo, (byte*)__pbOutput_native, cbOutput, __pcbResult_native, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hKey_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("ncrypt.dll", EntryPoint = "NCryptEncrypt", ExactSpelling = true)]
static extern unsafe global::Interop.NCrypt.ErrorCode __PInvoke(nint __hKey_native, byte* __pbInput_native, int __cbInput_native, void* __pPaddingInfo_native, byte* __pbOutput_native, int __cbOutput_native, int* __pcbResult_native, global::Interop.NCrypt.AsymmetricPaddingMode __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class NCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial global::Interop.NCrypt.ErrorCode NCryptDecrypt(global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle hKey, global::System.ReadOnlySpan<byte> pbInput, int cbInput, void* pPaddingInfo, global::System.Span<byte> pbOutput, int cbOutput, out int pcbResult, global::Interop.NCrypt.AsymmetricPaddingMode dwFlags)
{
pcbResult = default;
nint __hKey_native = default;
global::Interop.NCrypt.ErrorCode __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hKey_native__marshaller.FromManaged(hKey);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbResult_native = &pcbResult)
fixed (void* __pbOutput_native = &global::System.Runtime.InteropServices.Marshalling.SpanMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbOutput))
fixed (void* __pbInput_native = &global::System.Runtime.InteropServices.Marshalling.ReadOnlySpanMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbInput))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hKey_native, (byte*)__pbInput_native, cbInput, pPaddingInfo, (byte*)__pbOutput_native, cbOutput, __pcbResult_native, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hKey_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("ncrypt.dll", EntryPoint = "NCryptDecrypt", ExactSpelling = true)]
static extern unsafe global::Interop.NCrypt.ErrorCode __PInvoke(nint __hKey_native, byte* __pbInput_native, int __cbInput_native, void* __pPaddingInfo_native, byte* __pbOutput_native, int __cbOutput_native, int* __pcbResult_native, global::Interop.NCrypt.AsymmetricPaddingMode __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class NCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial global::Interop.NCrypt.ErrorCode NCryptOpenKey(global::Microsoft.Win32.SafeHandles.SafeNCryptProviderHandle hProvider, out global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle phKey, string pszKeyName, int dwLegacyKeySpec, global::System.Security.Cryptography.CngKeyOpenOptions dwFlags)
{
bool __invokeSucceeded = default;
phKey = default;
nint __hProvider_native = default;
nint __phKey_native = default;
global::Interop.NCrypt.ErrorCode __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle>.ManagedToUnmanagedOut __phKey_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptProviderHandle>.ManagedToUnmanagedIn __hProvider_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hProvider_native__marshaller.FromManaged(hProvider);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (void* __pszKeyName_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pszKeyName))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hProvider_native = __hProvider_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hProvider_native, &__phKey_native, (ushort*)__pszKeyName_native, dwLegacyKeySpec, dwFlags);
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__phKey_native__marshaller.FromUnmanaged(__phKey_native);
// Unmarshal - Convert native data to managed data.
phKey = __phKey_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__phKey_native__marshaller.Free();
}
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hProvider_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("ncrypt.dll", EntryPoint = "NCryptOpenKey", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.NCrypt.ErrorCode __PInvoke(nint __hProvider_native, nint* __phKey_native, ushort* __pszKeyName_native, int __dwLegacyKeySpec_native, global::System.Security.Cryptography.CngKeyOpenOptions __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class NCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial global::Interop.NCrypt.ErrorCode NCryptImportKey(global::Microsoft.Win32.SafeHandles.SafeNCryptProviderHandle hProvider, nint hImportKey, string pszBlobType, nint pParameterList, out global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle phKey, ref byte pbData, int cbData, int dwFlags)
{
bool __invokeSucceeded = default;
phKey = default;
nint __hProvider_native = default;
nint __phKey_native = default;
global::Interop.NCrypt.ErrorCode __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle>.ManagedToUnmanagedOut __phKey_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptProviderHandle>.ManagedToUnmanagedIn __hProvider_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hProvider_native__marshaller.FromManaged(hProvider);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (byte* __pbData_native = &pbData)
fixed (void* __pszBlobType_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pszBlobType))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hProvider_native = __hProvider_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hProvider_native, hImportKey, (ushort*)__pszBlobType_native, pParameterList, &__phKey_native, __pbData_native, cbData, dwFlags);
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__phKey_native__marshaller.FromUnmanaged(__phKey_native);
// Unmarshal - Convert native data to managed data.
phKey = __phKey_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__phKey_native__marshaller.Free();
}
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hProvider_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("ncrypt.dll", EntryPoint = "NCryptImportKey", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.NCrypt.ErrorCode __PInvoke(nint __hProvider_native, nint __hImportKey_native, ushort* __pszBlobType_native, nint __pParameterList_native, nint* __phKey_native, byte* __pbData_native, int __cbData_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class NCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial global::Interop.NCrypt.ErrorCode NCryptImportKey(global::Microsoft.Win32.SafeHandles.SafeNCryptProviderHandle hProvider, nint hImportKey, string pszBlobType, ref global::Interop.NCrypt.NCryptBufferDesc pParameterList, out global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle phKey, ref byte pbData, int cbData, int dwFlags)
{
bool __invokeSucceeded = default;
phKey = default;
nint __hProvider_native = default;
nint __phKey_native = default;
global::Interop.NCrypt.ErrorCode __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle>.ManagedToUnmanagedOut __phKey_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptProviderHandle>.ManagedToUnmanagedIn __hProvider_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hProvider_native__marshaller.FromManaged(hProvider);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (byte* __pbData_native = &pbData)
fixed (global::Interop.NCrypt.NCryptBufferDesc* __pParameterList_native = &pParameterList)
fixed (void* __pszBlobType_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pszBlobType))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hProvider_native = __hProvider_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hProvider_native, hImportKey, (ushort*)__pszBlobType_native, __pParameterList_native, &__phKey_native, __pbData_native, cbData, dwFlags);
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__phKey_native__marshaller.FromUnmanaged(__phKey_native);
// Unmarshal - Convert native data to managed data.
phKey = __phKey_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__phKey_native__marshaller.Free();
}
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hProvider_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("ncrypt.dll", EntryPoint = "NCryptImportKey", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.NCrypt.ErrorCode __PInvoke(nint __hProvider_native, nint __hImportKey_native, ushort* __pszBlobType_native, global::Interop.NCrypt.NCryptBufferDesc* __pParameterList_native, nint* __phKey_native, byte* __pbData_native, int __cbData_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class NCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial global::Interop.NCrypt.ErrorCode NCryptExportKey(global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle hKey, nint hExportKey, string pszBlobType, nint pParameterList, byte[] pbOutput, int cbOutput, out int pcbResult, int dwFlags)
{
pcbResult = default;
nint __hKey_native = default;
global::Interop.NCrypt.ErrorCode __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hKey_native__marshaller.FromManaged(hKey);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbResult_native = &pcbResult)
fixed (void* __pbOutput_native = &global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbOutput))
fixed (void* __pszBlobType_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pszBlobType))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hKey_native, hExportKey, (ushort*)__pszBlobType_native, pParameterList, (byte*)__pbOutput_native, cbOutput, __pcbResult_native, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hKey_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("ncrypt.dll", EntryPoint = "NCryptExportKey", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.NCrypt.ErrorCode __PInvoke(nint __hKey_native, nint __hExportKey_native, ushort* __pszBlobType_native, nint __pParameterList_native, byte* __pbOutput_native, int __cbOutput_native, int* __pcbResult_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class NCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial global::Interop.NCrypt.ErrorCode NCryptExportKey(global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle hKey, nint hExportKey, string pszBlobType, nint pParameterList, ref byte pbOutput, int cbOutput, out int pcbResult, int dwFlags)
{
pcbResult = default;
nint __hKey_native = default;
global::Interop.NCrypt.ErrorCode __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hKey_native__marshaller.FromManaged(hKey);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbResult_native = &pcbResult)
fixed (byte* __pbOutput_native = &pbOutput)
fixed (void* __pszBlobType_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pszBlobType))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hKey_native, hExportKey, (ushort*)__pszBlobType_native, pParameterList, __pbOutput_native, cbOutput, __pcbResult_native, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hKey_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("ncrypt.dll", EntryPoint = "NCryptExportKey", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.NCrypt.ErrorCode __PInvoke(nint __hKey_native, nint __hExportKey_native, ushort* __pszBlobType_native, nint __pParameterList_native, byte* __pbOutput_native, int __cbOutput_native, int* __pcbResult_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class NCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial global::Interop.NCrypt.ErrorCode NCryptExportKey(global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle hKey, nint hExportKey, string pszBlobType, nint pParameterList, global::System.Span<byte> pbOutput, int cbOutput, out int pcbResult, int dwFlags)
{
pcbResult = default;
nint __hKey_native = default;
global::Interop.NCrypt.ErrorCode __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hKey_native__marshaller.FromManaged(hKey);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbResult_native = &pcbResult)
fixed (void* __pbOutput_native = &global::System.Runtime.InteropServices.Marshalling.SpanMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbOutput))
fixed (void* __pszBlobType_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pszBlobType))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hKey_native, hExportKey, (ushort*)__pszBlobType_native, pParameterList, (byte*)__pbOutput_native, cbOutput, __pcbResult_native, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hKey_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("ncrypt.dll", EntryPoint = "NCryptExportKey", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.NCrypt.ErrorCode __PInvoke(nint __hKey_native, nint __hExportKey_native, ushort* __pszBlobType_native, nint __pParameterList_native, byte* __pbOutput_native, int __cbOutput_native, int* __pcbResult_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class NCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial global::Interop.NCrypt.ErrorCode NCryptExportKey(global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle hKey, nint hExportKey, string pszBlobType, ref global::Interop.NCrypt.NCryptBufferDesc pParameterList, ref byte pbOutput, int cbOutput, out int pcbResult, int dwFlags)
{
pcbResult = default;
nint __hKey_native = default;
global::Interop.NCrypt.ErrorCode __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hKey_native__marshaller.FromManaged(hKey);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbResult_native = &pcbResult)
fixed (byte* __pbOutput_native = &pbOutput)
fixed (global::Interop.NCrypt.NCryptBufferDesc* __pParameterList_native = &pParameterList)
fixed (void* __pszBlobType_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pszBlobType))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hKey_native, hExportKey, (ushort*)__pszBlobType_native, __pParameterList_native, __pbOutput_native, cbOutput, __pcbResult_native, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hKey_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("ncrypt.dll", EntryPoint = "NCryptExportKey", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.NCrypt.ErrorCode __PInvoke(nint __hKey_native, nint __hExportKey_native, ushort* __pszBlobType_native, global::Interop.NCrypt.NCryptBufferDesc* __pParameterList_native, byte* __pbOutput_native, int __cbOutput_native, int* __pcbResult_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class NCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial global::Interop.NCrypt.ErrorCode NCryptDeleteKey(global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle hKey, int dwFlags)
{
nint __hKey_native = default;
global::Interop.NCrypt.ErrorCode __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hKey_native__marshaller.FromManaged(hKey);
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hKey_native, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hKey_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("ncrypt.dll", EntryPoint = "NCryptDeleteKey", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.NCrypt.ErrorCode __PInvoke(nint __hKey_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class NCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial global::Interop.NCrypt.ErrorCode NCryptCreatePersistedKey(global::Microsoft.Win32.SafeHandles.SafeNCryptProviderHandle hProvider, out global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle phKey, string pszAlgId, string pszKeyName, int dwLegacyKeySpec, global::System.Security.Cryptography.CngKeyCreationOptions dwFlags)
{
bool __invokeSucceeded = default;
phKey = default;
nint __hProvider_native = default;
nint __phKey_native = default;
global::Interop.NCrypt.ErrorCode __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle>.ManagedToUnmanagedOut __phKey_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptProviderHandle>.ManagedToUnmanagedIn __hProvider_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hProvider_native__marshaller.FromManaged(hProvider);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (void* __pszKeyName_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pszKeyName))
fixed (void* __pszAlgId_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pszAlgId))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hProvider_native = __hProvider_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hProvider_native, &__phKey_native, (ushort*)__pszAlgId_native, (ushort*)__pszKeyName_native, dwLegacyKeySpec, dwFlags);
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__phKey_native__marshaller.FromUnmanaged(__phKey_native);
// Unmarshal - Convert native data to managed data.
phKey = __phKey_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__phKey_native__marshaller.Free();
}
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hProvider_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("ncrypt.dll", EntryPoint = "NCryptCreatePersistedKey", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.NCrypt.ErrorCode __PInvoke(nint __hProvider_native, nint* __phKey_native, ushort* __pszAlgId_native, ushort* __pszKeyName_native, int __dwLegacyKeySpec_native, global::System.Security.Cryptography.CngKeyCreationOptions __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class NCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial global::Interop.NCrypt.ErrorCode NCryptFinalizeKey(global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle hKey, int dwFlags)
{
nint __hKey_native = default;
global::Interop.NCrypt.ErrorCode __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hKey_native__marshaller.FromManaged(hKey);
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hKey_native, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hKey_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("ncrypt.dll", EntryPoint = "NCryptFinalizeKey", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.NCrypt.ErrorCode __PInvoke(nint __hKey_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class NCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
private static unsafe partial global::Interop.NCrypt.ErrorCode NCryptDecapsulate(global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle hKey, byte* pbCipherText, uint cbCipherText, byte* pbSecretKey, uint cbSecretKey, out uint pcbSecretKey, uint dwFlags)
{
pcbSecretKey = default;
nint __hKey_native = default;
global::Interop.NCrypt.ErrorCode __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hKey_native__marshaller.FromManaged(hKey);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (uint* __pcbSecretKey_native = &pcbSecretKey)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hKey_native, pbCipherText, cbCipherText, pbSecretKey, cbSecretKey, __pcbSecretKey_native, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hKey_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("ncrypt.dll", EntryPoint = "NCryptDecapsulate", ExactSpelling = true)]
static extern unsafe global::Interop.NCrypt.ErrorCode __PInvoke(nint __hKey_native, byte* __pbCipherText_native, uint __cbCipherText_native, byte* __pbSecretKey_native, uint __cbSecretKey_native, uint* __pcbSecretKey_native, uint __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class NCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
private static unsafe partial global::Interop.NCrypt.ErrorCode NCryptEncapsulate(global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle hKey, byte* pbSecretKey, uint cbSecretKey, out uint pcbSecretKey, byte* pbCipherText, uint cbCipherText, out uint pcbCipherText, uint dwFlags)
{
pcbSecretKey = default;
pcbCipherText = default;
nint __hKey_native = default;
global::Interop.NCrypt.ErrorCode __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hKey_native__marshaller.FromManaged(hKey);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (uint* __pcbCipherText_native = &pcbCipherText)
fixed (uint* __pcbSecretKey_native = &pcbSecretKey)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hKey_native, pbSecretKey, cbSecretKey, __pcbSecretKey_native, pbCipherText, cbCipherText, __pcbCipherText_native, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hKey_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("ncrypt.dll", EntryPoint = "NCryptEncapsulate", ExactSpelling = true)]
static extern unsafe global::Interop.NCrypt.ErrorCode __PInvoke(nint __hKey_native, byte* __pbSecretKey_native, uint __cbSecretKey_native, uint* __pcbSecretKey_native, byte* __pbCipherText_native, uint __cbCipherText_native, uint* __pcbCipherText_native, uint __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class NCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
private static partial global::Interop.NCrypt.ErrorCode NCryptDeriveKey(global::Microsoft.Win32.SafeHandles.SafeNCryptSecretHandle hSharedSecret, string pwszKDF, ref global::Interop.NCrypt.NCryptBufferDesc pParameterList, byte[] pbDerivedKey, int cbDerivedKey, out int pcbResult, global::Interop.NCrypt.SecretAgreementFlags dwFlags)
{
pcbResult = default;
nint __hSharedSecret_native = default;
global::Interop.NCrypt.ErrorCode __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptSecretHandle>.ManagedToUnmanagedIn __hSharedSecret_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hSharedSecret_native__marshaller.FromManaged(hSharedSecret);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbResult_native = &pcbResult)
fixed (void* __pbDerivedKey_native = &global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbDerivedKey))
fixed (global::Interop.NCrypt.NCryptBufferDesc* __pParameterList_native = &pParameterList)
fixed (void* __pwszKDF_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pwszKDF))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hSharedSecret_native = __hSharedSecret_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hSharedSecret_native, (ushort*)__pwszKDF_native, __pParameterList_native, (byte*)__pbDerivedKey_native, cbDerivedKey, __pcbResult_native, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hSharedSecret_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("ncrypt.dll", EntryPoint = "NCryptDeriveKey", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.NCrypt.ErrorCode __PInvoke(nint __hSharedSecret_native, ushort* __pwszKDF_native, global::Interop.NCrypt.NCryptBufferDesc* __pParameterList_native, byte* __pbDerivedKey_native, int __cbDerivedKey_native, int* __pcbResult_native, global::Interop.NCrypt.SecretAgreementFlags __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class NCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
private static partial global::Interop.NCrypt.ErrorCode NCryptDeriveKey(global::Microsoft.Win32.SafeHandles.SafeNCryptSecretHandle hSharedSecret, string pwszKDF, nint pParameterList, global::System.Span<byte> pbDerivedKey, int cbDerivedKey, out int pcbResult, global::Interop.NCrypt.SecretAgreementFlags dwFlags)
{
pcbResult = default;
nint __hSharedSecret_native = default;
global::Interop.NCrypt.ErrorCode __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptSecretHandle>.ManagedToUnmanagedIn __hSharedSecret_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hSharedSecret_native__marshaller.FromManaged(hSharedSecret);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbResult_native = &pcbResult)
fixed (void* __pbDerivedKey_native = &global::System.Runtime.InteropServices.Marshalling.SpanMarshaller<byte, byte>.ManagedToUnmanagedIn.GetPinnableReference(pbDerivedKey))
fixed (void* __pwszKDF_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pwszKDF))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hSharedSecret_native = __hSharedSecret_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hSharedSecret_native, (ushort*)__pwszKDF_native, pParameterList, (byte*)__pbDerivedKey_native, cbDerivedKey, __pcbResult_native, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hSharedSecret_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("ncrypt.dll", EntryPoint = "NCryptDeriveKey", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.NCrypt.ErrorCode __PInvoke(nint __hSharedSecret_native, ushort* __pwszKDF_native, nint __pParameterList_native, byte* __pbDerivedKey_native, int __cbDerivedKey_native, int* __pcbResult_native, global::Interop.NCrypt.SecretAgreementFlags __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class NCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
private static partial global::Interop.NCrypt.ErrorCode NCryptSecretAgreement(global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle hPrivKey, global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle hPubKey, out global::Microsoft.Win32.SafeHandles.SafeNCryptSecretHandle phSecret, int dwFlags)
{
bool __invokeSucceeded = default;
phSecret = default;
nint __hPrivKey_native = default;
nint __hPubKey_native = default;
nint __phSecret_native = default;
global::Interop.NCrypt.ErrorCode __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptSecretHandle>.ManagedToUnmanagedOut __phSecret_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle>.ManagedToUnmanagedIn __hPubKey_native__marshaller = new();
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle>.ManagedToUnmanagedIn __hPrivKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hPubKey_native__marshaller.FromManaged(hPubKey);
__hPrivKey_native__marshaller.FromManaged(hPrivKey);
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hPubKey_native = __hPubKey_native__marshaller.ToUnmanaged();
__hPrivKey_native = __hPrivKey_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hPrivKey_native, __hPubKey_native, &__phSecret_native, dwFlags);
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__phSecret_native__marshaller.FromUnmanaged(__phSecret_native);
// Unmarshal - Convert native data to managed data.
phSecret = __phSecret_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__phSecret_native__marshaller.Free();
}
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hPubKey_native__marshaller.Free();
__hPrivKey_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("ncrypt.dll", EntryPoint = "NCryptSecretAgreement", ExactSpelling = true)]
static extern unsafe global::Interop.NCrypt.ErrorCode __PInvoke(nint __hPrivKey_native, nint __hPubKey_native, nint* __phSecret_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class NCrypt
{
[global::System.Runtime.InteropServices.DllImportAttribute("ncrypt.dll", EntryPoint = "NCryptFreeObject", ExactSpelling = true)]
internal static extern partial global::Interop.NCrypt.ErrorCode NCryptFreeObject(nint hObject);
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class NCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static partial global::Interop.NCrypt.ErrorCode NCryptOpenStorageProvider(out global::Microsoft.Win32.SafeHandles.SafeNCryptProviderHandle phProvider, string pszProviderName, int dwFlags)
{
bool __invokeSucceeded = default;
phProvider = default;
nint __phProvider_native = default;
global::Interop.NCrypt.ErrorCode __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptProviderHandle>.ManagedToUnmanagedOut __phProvider_native__marshaller = new();
try
{
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (void* __pszProviderName_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pszProviderName))
{
__retVal = __PInvoke(&__phProvider_native, (ushort*)__pszProviderName_native, dwFlags);
}
__invokeSucceeded = true;
// UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
__phProvider_native__marshaller.FromUnmanaged(__phProvider_native);
// Unmarshal - Convert native data to managed data.
phProvider = __phProvider_native__marshaller.ToManaged();
}
finally
{
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__phProvider_native__marshaller.Free();
}
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("ncrypt.dll", EntryPoint = "NCryptOpenStorageProvider", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.NCrypt.ErrorCode __PInvoke(nint* __phProvider_native, ushort* __pszProviderName_native, int __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class NCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial global::Interop.NCrypt.ErrorCode NCryptGetProperty(global::Microsoft.Win32.SafeHandles.SafeNCryptHandle hObject, string pszProperty, void* pbOutput, int cbOutput, out int pcbResult, global::System.Security.Cryptography.CngPropertyOptions dwFlags)
{
pcbResult = default;
nint __hObject_native = default;
global::Interop.NCrypt.ErrorCode __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptHandle>.ManagedToUnmanagedIn __hObject_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hObject_native__marshaller.FromManaged(hObject);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbResult_native = &pcbResult)
fixed (void* __pszProperty_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pszProperty))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hObject_native = __hObject_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hObject_native, (ushort*)__pszProperty_native, pbOutput, cbOutput, __pcbResult_native, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hObject_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("ncrypt.dll", EntryPoint = "NCryptGetProperty", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.NCrypt.ErrorCode __PInvoke(nint __hObject_native, ushort* __pszProperty_native, void* __pbOutput_native, int __cbOutput_native, int* __pcbResult_native, global::System.Security.Cryptography.CngPropertyOptions __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class NCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
internal static unsafe partial global::Interop.NCrypt.ErrorCode NCryptSetProperty(global::Microsoft.Win32.SafeHandles.SafeNCryptHandle hObject, string pszProperty, void* pbInput, int cbInput, global::System.Security.Cryptography.CngPropertyOptions dwFlags)
{
nint __hObject_native = default;
global::Interop.NCrypt.ErrorCode __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptHandle>.ManagedToUnmanagedIn __hObject_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hObject_native__marshaller.FromManaged(hObject);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (void* __pszProperty_native = &global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.GetPinnableReference(pszProperty))
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hObject_native = __hObject_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hObject_native, (ushort*)__pszProperty_native, pbInput, cbInput, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hObject_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("ncrypt.dll", EntryPoint = "NCryptSetProperty", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.NCrypt.ErrorCode __PInvoke(nint __hObject_native, ushort* __pszProperty_native, void* __pbInput_native, int __cbInput_native, global::System.Security.Cryptography.CngPropertyOptions __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class NCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
private static unsafe partial global::Interop.NCrypt.ErrorCode NCryptSignHash(global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle hKey, void* pPaddingInfo, byte* pbHashValue, int cbHashValue, byte* pbSignature, int cbSignature, out int pcbResult, global::Interop.NCrypt.AsymmetricPaddingMode dwFlags)
{
pcbResult = default;
nint __hKey_native = default;
global::Interop.NCrypt.ErrorCode __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hKey_native__marshaller.FromManaged(hKey);
// Pin - Pin data in preparation for calling the P/Invoke.
fixed (int* __pcbResult_native = &pcbResult)
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hKey_native, pPaddingInfo, pbHashValue, cbHashValue, pbSignature, cbSignature, __pcbResult_native, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hKey_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("ncrypt.dll", EntryPoint = "NCryptSignHash", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.NCrypt.ErrorCode __PInvoke(nint __hKey_native, void* __pPaddingInfo_native, byte* __pbHashValue_native, int __cbHashValue_native, byte* __pbSignature_native, int __cbSignature_native, int* __pcbResult_native, global::Interop.NCrypt.AsymmetricPaddingMode __dwFlags_native);
}
}
}
internal static unsafe partial class Interop
{
internal static unsafe partial class NCrypt
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.26904")]
private static unsafe partial global::Interop.NCrypt.ErrorCode NCryptVerifySignature(global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle hKey, void* pPaddingInfo, byte* pbHashValue, int cbHashValue, byte* pbSignature, int cbSignature, global::Interop.NCrypt.AsymmetricPaddingMode dwFlags)
{
nint __hKey_native = default;
global::Interop.NCrypt.ErrorCode __retVal = default;
// Setup - Perform required setup.
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle>.ManagedToUnmanagedIn __hKey_native__marshaller = new();
try
{
// Marshal - Convert managed data to native data.
__hKey_native__marshaller.FromManaged(hKey);
{
// PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
__hKey_native = __hKey_native__marshaller.ToUnmanaged();
__retVal = __PInvoke(__hKey_native, pPaddingInfo, pbHashValue, cbHashValue, pbSignature, cbSignature, dwFlags);
}
}
finally
{
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__hKey_native__marshaller.Free();
}
return __retVal;
// Local P/Invoke
[global::System.Runtime.InteropServices.DllImportAttribute("ncrypt.dll", EntryPoint = "NCryptVerifySignature", ExactSpelling = true, CharSet = global::System.Runtime.InteropServices.CharSet.Unicode)]
static extern unsafe global::Interop.NCrypt.ErrorCode __PInvoke(nint __hKey_native, void* __pPaddingInfo_native, byte* __pbHashValue_native, int __cbHashValue_native, byte* __pbSignature_native, int __cbSignature_native, global::Interop.NCrypt.AsymmetricPaddingMode __dwFlags_native);
}
}
}
|