internal static extern bool CryptMsgGetParam( #endif SafeCryptMsgHandle hCryptMsg, CryptMsgParamType dwParamType, int dwIndex, IntPtr pvData, ref int pcbData);
public static extern bool CryptMsgGetParam ( [param: In] CryptMsgSafeHandle hCryptMsg, [param: In, MarshalAs(UnmanagedType.U4)] CryptMsgParamType dwParamType, [param: In, MarshalAs(UnmanagedType.U4)] uint dwIndex, [param: In] LocalBufferSafeHandle pvData, [param: In, Out, MarshalAs(UnmanagedType.U4)] ref uint pcbData );
// Used for binary blobs with internal pointers. public static SafeHandle GetMsgParamAsMemory(this SafeCryptMsgHandle hCryptMsg, CryptMsgParamType paramType, int index = 0) { int cbData = 0; if (!Interop.Crypt32.CryptMsgGetParam(hCryptMsg, paramType, index, null, ref cbData)) throw Marshal.GetLastWin32Error().ToCryptographicException(); SafeHandle pvData = SafeHeapAllocHandle.Alloc(cbData); if (!Interop.Crypt32.CryptMsgGetParam(hCryptMsg, paramType, index, pvData.DangerousGetHandle(), ref cbData)) throw Marshal.GetLastWin32Error().ToCryptographicException(); return pvData; }
// Used for binary blobs without internal pointers. public static byte[] GetMsgParamAsByteArray(this SafeCryptMsgHandle hCryptMsg, CryptMsgParamType paramType, int index = 0) { int cbData = 0; if (!Interop.Crypt32.CryptMsgGetParam(hCryptMsg, paramType, index, null, ref cbData)) throw Marshal.GetLastWin32Error().ToCryptographicException(); byte[] pvData = new byte[cbData]; if (!Interop.Crypt32.CryptMsgGetParam(hCryptMsg, paramType, index, pvData, ref cbData)) throw Marshal.GetLastWin32Error().ToCryptographicException(); return pvData.Resize(cbData); }
// Used for binary blobs with internal pointers. public static SafeHandle GetMsgParamAsMemory(this SafeCryptMsgHandle hCryptMsg, CryptMsgParamType paramType, int index = 0) { int cbData = 0; if (!Interop.Crypt32.CryptMsgGetParam(hCryptMsg, paramType, index, null, ref cbData)) { throw Interop.CPError.GetLastWin32Error().ToCryptographicException(); } SafeHandle pvData = SafeHeapAllocHandle.Alloc(cbData); if (!Interop.Crypt32.CryptMsgGetParam(hCryptMsg, paramType, index, pvData.DangerousGetHandle(), ref cbData)) { throw Interop.CPError.GetLastWin32Error().ToCryptographicException(); } return(pvData); }
// Used for binary blobs without internal pointers. public static byte[] GetMsgParamAsByteArray(this SafeCryptMsgHandle hCryptMsg, CryptMsgParamType paramType, int index = 0) { int cbData = 0; if (!Interop.Crypt32.CryptMsgGetParam(hCryptMsg, paramType, index, null, ref cbData)) { throw Interop.CPError.GetLastWin32Error().ToCryptographicException(); } byte[] pvData = new byte[cbData]; if (!Interop.Crypt32.CryptMsgGetParam(hCryptMsg, paramType, index, pvData, ref cbData)) { throw Interop.CPError.GetLastWin32Error().ToCryptographicException(); } return(pvData.Resize(cbData)); }
internal static extern bool CryptMsgGetParam(SafeCryptMsgHandle hCryptMsg, CryptMsgParamType dwParamType, int dwIndex, IntPtr pvData, [In, Out] ref int pcbData);
internal static extern bool CryptMsgGetParam(SafeCryptMsgHandle hCryptMsg, CryptMsgParamType dwParamType, int dwIndex, [Out] byte[] pvData, [In, Out] ref int pcbData);
// Used for binary blobs without internal pointers. public static unsafe byte[] GetMsgParamAsByteArray(this SafeCryptMsgHandle hCryptMsg, CryptMsgParamType paramType, int index = 0) { int cbData = 0; if (!Interop.Crypt32.CryptMsgGetParam(hCryptMsg, paramType, index, IntPtr.Zero, ref cbData)) { throw Marshal.GetLastWin32Error().ToCryptographicException(); } byte[] data = new byte[cbData]; fixed(byte *pvData = data) { if (!Interop.Crypt32.CryptMsgGetParam(hCryptMsg, paramType, index, pvData, ref cbData)) { throw Marshal.GetLastWin32Error().ToCryptographicException(); } } return(data.Resize(cbData)); }
internal static partial bool CryptMsgGetParam( SafeCryptMsgHandle hCryptMsg, CryptMsgParamType dwParamType, int dwIndex, IntPtr pvData, ref int pcbData);
internal static unsafe partial bool CryptMsgGetParam( SafeCryptMsgHandle hCryptMsg, CryptMsgParamType dwParamType, int dwIndex, byte *pvData, ref int pcbData);
// Used for binary blobs with internal pointers. public static SafeHandle GetMsgParamAsMemory(this SafeCryptMsgHandle hCryptMsg, CryptMsgParamType paramType, int index = 0) { int cbData = 0; if (!Interop.Crypt32.CryptMsgGetParam(hCryptMsg, paramType, index, IntPtr.Zero, ref cbData)) { throw Marshal.GetLastPInvokeError().ToCryptographicException(); } SafeHandle pvData = SafeHeapAllocHandle.Alloc(cbData); if (!Interop.Crypt32.CryptMsgGetParam(hCryptMsg, paramType, index, pvData.DangerousGetHandle(), ref cbData)) { Exception e = Marshal.GetLastPInvokeError().ToCryptographicException(); pvData.Dispose(); throw e; } return(pvData); }