using System;
using System.Runtime.InteropServices;
using Vanara.InteropServices;
using static Vanara.PInvoke.Crypt32;
namespace Vanara.PInvoke
{
public static partial class WinTrust
{
///
/// The CryptSIPCreateIndirectData function returns a SIP_INDIRECT_DATA structure that contains a hash of the supplied
/// SIP_SUBJECTINFO structure, the digest algorithm, and an encoding attribute. The hash can be used as an indirect reference to the data.
///
///
/// A pointer to a SIP_SUBJECTINFO structure that contains the subject to which the indirect data reference will point.
///
/// A pointer to a DWORD value to receive the size of the returned SIP_INDIRECT_DATA structure.
/// A pointer to a SIP_INDIRECT_DATA structure to receive the catalog item.
///
/// The return value is TRUE if the function succeeds; otherwise, FALSE.
///
/// If this function returns FALSE, additional error information can be obtained by calling the GetLastError function.
/// GetLastError will return one of the following error codes.
///
///
///
/// Return code
/// Description
///
/// -
/// ERROR_BAD_FORMAT
/// The file or data format is not correct for the specified subject interface package (SIP) type.
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the parameters are not valid.
///
/// -
/// ERROR_NOT_ENOUGH_MEMORY
/// There was an error allocating memory.
///
/// -
/// NTE_BAD_ALGID
/// The specified algorithm is not supported by the SIP.
///
/// -
/// TRUST_E_SUBJECT_FORM_UNKNOWN
/// The subject type is not recognized.
///
///
///
///
/// If pcbIndirectData points to a DWORD and pIndirectData points to NULL, the size of the data will be returned in pcbIndirectData.
///
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/nf-mssip-cryptsipcreateindirectdata BOOL CryptSIPCreateIndirectData( IN
// SIP_SUBJECTINFO *pSubjectInfo, IN OUT DWORD *pcbIndirectData, OUT SIP_INDIRECT_DATA *pIndirectData );
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
[PInvokeData("mssip.h", MSDNShortId = "bb4ecc95-972f-415c-9722-59b00a27cddc")]
[return: MarshalAs(UnmanagedType.Bool)]
public delegate bool pCryptSIPCreateIndirectData(in SIP_SUBJECTINFO pSubjectInfo, ref uint pcbIndirectData, IntPtr pIndirectData);
/// The pCryptSIPGetCaps function is implemented by an subject interface package (SIP) to report capabilities.
/// Pointer to a SIP_SUBJECTINFO structure that specifies subject information data to the SIP APIs.
/// Pointer to a SIP_CAP_SET structure that defines the capabilities of an SIP.
/// None
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/nc-mssip-pcryptsipgetcaps pCryptSIPGetCaps Pcryptsipgetcaps; BOOL
// Pcryptsipgetcaps( SIP_SUBJECTINFO *pSubjInfo, SIP_CAP_SET *pCaps ) {...}
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
[PInvokeData("mssip.h", MSDNShortId = "8EA46B67-F542-4B15-81F4-3DD83DD45764")]
[return: MarshalAs(UnmanagedType.Bool)]
public delegate bool pCryptSIPGetCaps(in SIP_SUBJECTINFO pSubjInfo, IntPtr pCaps);
/// The CryptSIPGetSignedDataMsg function retrieves an Authenticode signature from the file.
/// A pointer to a SIP_SUBJECTINFO structure that contains information about the message subject.
///
/// The encoding type of the Authenticode signature.
/// This parameter can be a combination of one or more of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// PKCS_7_ASN_ENCODING 65536 (0x10000)
/// Specifies PKCS #7 message encoding.
///
/// -
/// X509_ASN_ENCODING 1 (0x1)
/// Specifies X.509 certificate encoding.
///
///
///
/// This parameter is reserved and should be set to zero.
/// The length, in bytes, of the buffer pointed to by the pbSignedDataMsg parameter.
///
/// A pointer to a buffer to receive the returned Authenticode signature.
///
/// To determine the size of the buffer needed, set the pbSignedDataMsg parameter to NULL and call the
/// CryptSIPGetSignedDataMsg function. This function will place the required size of the buffer, in bytes, in the value
/// pointed to by pcbSignedDataMsg. For more information, see Retrieving Data of Unknown Length.
///
///
///
/// If the function succeeds, the function returns TRUE.
///
/// If the function fails, it returns FALSE. For extended error information, call GetLastError. Some possible error codes follow.
///
///
///
/// Return code
/// Description
///
/// -
/// CRYPT_E_NO_MATCH
/// The signature specified by the index could not be found.
///
/// -
/// ERROR_BAD_FORMAT
/// The specified data or file format of the subject interface package (SIP) is not valid.
///
/// -
/// ERROR_INVALID_PARAMETER
/// The pSubjectInfo parameter or the pgSubjectType member of the SIP_SUBJECTINFO structure is a null pointer.
///
/// -
/// ERROR_INSUFFICIENT_BUFFER
///
/// The size of the message buffer was insufficient to hold the retrieved data, the pcbSignedDataMsgparameter has been set to
/// indicate the required buffer size.
///
///
/// -
/// TRUST_E_SUBJECT_FORM_UNKNOWN
/// The specified subject type is not valid.
///
///
///
///
/// Subjects include, but are not limited to, portable executable images (.exe), cabinet (.cab) images, flat files, and catalog
/// files. Each subject type uses a different subset of its data for hash calculation and requires a different procedure for storage
/// and retrieval. Therefore, each subject type has a unique SIP specification.
///
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/nf-mssip-cryptsipgetsigneddatamsg BOOL CryptSIPGetSignedDataMsg( IN
// SIP_SUBJECTINFO *pSubjectInfo, OUT DWORD *pdwEncodingType, IN DWORD dwIndex, IN OUT DWORD *pcbSignedDataMsg, OUT BYTE
// *pbSignedDataMsg );
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
[PInvokeData("mssip.h", MSDNShortId = "e3fabaa7-2dda-4c6c-8d1a-3ee5363e10b5")]
[return: MarshalAs(UnmanagedType.Bool)]
public delegate bool pCryptSIPGetSignedDataMsg(in SIP_SUBJECTINFO pSubjectInfo, out CertEncodingType pdwEncodingType, uint dwIndex, ref uint pcbSignedDataMsg, [Out] IntPtr pbSignedDataMsg);
/// The CryptSIPPutSignedDataMsg function stores an Authenticode signature in the target file.
/// Pointer to a SIP_SUBJECTINFO structure that contains information about the message subject.
///
/// The encoding type of the message. This can be a combination of one or more of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// PKCS_7_ASN_ENCODING 65536 (0x10000)
/// Specifies PKCS #7 message encoding.
///
/// -
/// X509_ASN_ENCODING 1 (0x1)
/// Specifies X.509 certificate encoding.
///
///
///
/// Pointer to the message index.
/// Length, in bytes, of the buffer pointed to by the pbSignedDataMsg parameter.
/// Pointer to the buffer that contains the message.
///
/// If the function succeeds, the function returns TRUE.
///
/// If the function fails, it returns FALSE. For extended error information, call GetLastError. Some possible error codes follow.
///
///
///
/// Return code
/// Description
///
/// -
/// ERROR_BAD_FORMAT
/// The specified data or file format of the subject interface package (SIP) is not valid.
///
/// -
/// ERROR_INVALID_PARAMETER
/// This code can be returned for the following reasons:
///
/// -
/// TRUST_E_SUBJECT_FORM_UNKNOWN
/// The specified subject type is not valid.
///
///
///
///
/// Each subject type uses a different subset of its data for hash calculation and requires a different procedure for storage and
/// retrieval. Therefore, each subject type has a unique SIP specification.
///
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/nf-mssip-cryptsipputsigneddatamsg BOOL CryptSIPPutSignedDataMsg( IN
// SIP_SUBJECTINFO *pSubjectInfo, IN DWORD dwEncodingType, OUT DWORD *pdwIndex, IN DWORD cbSignedDataMsg, IN BYTE *pbSignedDataMsg );
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
[PInvokeData("mssip.h", MSDNShortId = "731f64bf-49f0-4799-b84a-9ca04292aa91")]
[return: MarshalAs(UnmanagedType.Bool)]
public delegate bool pCryptSIPPutSignedDataMsg(in SIP_SUBJECTINFO pSubjectInfo, CertEncodingType dwEncodingType, out uint pdwIndex, uint cbSignedDataMsg, [In] IntPtr pbSignedDataMsg);
/// The CryptSIPRemoveSignedDataMsg function removes a specified Authenticode signature.
/// A pointer to a SIP_SUBJECTINFO structure that contains information about the message subject.
/// This parameter is reserved and should be set to zero.
///
/// If the function succeeds, the function returns TRUE.
/// If the function fails, it returns FALSE. For extended error information, call GetLastError.
///
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/nf-mssip-cryptsipremovesigneddatamsg BOOL CryptSIPRemoveSignedDataMsg(
// IN SIP_SUBJECTINFO *pSubjectInfo, IN DWORD dwIndex );
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
[PInvokeData("mssip.h", MSDNShortId = "c3ea46bb-931a-4ca6-93f5-db7e07b4cb7a")]
[return: MarshalAs(UnmanagedType.Bool)]
public delegate bool pCryptSIPRemoveSignedDataMsg(in SIP_SUBJECTINFO pSubjectInfo, uint dwIndex = 0);
/// The CryptSIPVerifyIndirectData function validates the indirect hashed data against the supplied subject.
/// A pointer to a SIP_SUBJECTINFO structure that contains information about the message subject.
/// A pointer to a SIP_INDIRECT_DATA structure that contains information about the hashed subject information.
///
/// The return value is TRUE if the function succeeds; otherwise, FALSE.
///
/// If this function returns FALSE, additional error information can be obtained by calling the GetLastError function.
/// GetLastError will return one of the following error codes.
///
///
///
/// Return code
/// Description
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the parameters are not valid.
///
/// -
/// TRUST_E_SUBJECT_FORM_UNKNOWN
/// The subject type is an unknown type.
///
///
///
///
/// Subjects include, but are not limited to, portable executable images (.exe), cabinet (.cab) images, flat files, and catalog
/// files. Each subject type uses a different subset of its data for hash calculation and requires a different procedure for storage
/// and retrieval. Therefore each subject type has a unique subject interface package specification.
///
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/nf-mssip-cryptsipverifyindirectdata BOOL CryptSIPVerifyIndirectData( IN
// SIP_SUBJECTINFO *pSubjectInfo, IN SIP_INDIRECT_DATA *pIndirectData );
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
[PInvokeData("mssip.h", MSDNShortId = "137b8858-a31f-4ef6-96bd-c5e26ae7b3e8")]
[return: MarshalAs(UnmanagedType.Bool)]
public delegate bool pCryptSIPVerifyIndirectData(in SIP_SUBJECTINFO pSubjectInfo, in SIP_INDIRECT_DATA pIndirectData);
///
/// The pfnIsFileSupported callback function queries the subject interface packages (SIPs) listed in the registry to
/// determine which SIP handles the file type.
///
/// A handle to the file.
///
///
/// If the function succeeds, the function returns TRUE.
/// If the function fails, it returns FALSE. For extended error information, call GetLastError.
///
///
///
/// If the SIP supports the file type passed by hfile, the function returns TRUE, and sets pgSubject to the GUID that
/// identifies the SIP for handling the file type.
///
///
/// Each SIP implements its own version of the function that determines whether the file type is supported. The specific name of the
/// function may vary depending on the implementation of the SIP, but the signature of the function will match that of the
/// pfnIsFileSupported function. The function name is added to the registry by the CryptSIPAddProvider function, which takes
/// the function name as a parameter in the pwszIsFunctionName field of the SIP_ADD_NEWPROVIDER structure.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/nc-mssip-pfnisfilesupported pfnIsFileSupported Pfnisfilesupported; BOOL
// Pfnisfilesupported( IN HANDLE hFile, OUT GUID *pgSubject ) {...}
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
[PInvokeData("mssip.h", MSDNShortId = "cf12d057-328a-4975-b7e5-842c4ea2e760")]
[return: MarshalAs(UnmanagedType.Bool)]
public delegate bool pfnIsFileSupported(HFILE hFile, out Guid pgSubject);
///
/// The pfnIsFileSupportedName callback function queries the subject interface packages (SIPs) listed in the registry to
/// determine which SIP handles the file type.
///
///
///
///
/// The return value is TRUE if the function succeeds; FALSE if the function fails. If the function fails, call the
/// GetLastError function to determine the reason for failure.
///
///
///
/// If the SIP supports the file type passed by hfile, the function returns TRUE, and sets pgSubject to the GUID that
/// identifies the SIP for handling the file type.
///
///
/// Each SIP implements its own version of the function that determines if the file type is supported. The specific name of the
/// function may vary depending on the implementation of the SIP, but the signature of the function will match that of the
/// pfnIsFileSupportedName function. The function name is added to the registry by the CryptSIPAddProvider function, which
/// takes the function name as parameter in the pwszIsFunctionNameFmt2 field in the SIP_ADD_NEWPROVIDER structure.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/nc-mssip-pfnisfilesupportedname pfnIsFileSupportedName
// Pfnisfilesupportedname; BOOL Pfnisfilesupportedname( IN WCHAR *pwszFileName, OUT GUID *pgSubject ) {...}
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
[PInvokeData("mssip.h", MSDNShortId = "cc2304ef-c319-45eb-b2ec-7410510af213")]
[return: MarshalAs(UnmanagedType.Bool)]
public delegate bool pfnIsFileSupportedName([MarshalAs(UnmanagedType.LPWStr)] string pwszFileName, out Guid pgSubject);
///
/// The CryptSIPAddProvider function registers functions that are exported by a given DLL file that implements a Subject
/// Interface Package (SIP).
///
/// A pointer to a SIP_ADD_NEWPROVIDER structure that specifies the DLL file and function names to register.
///
/// The return value is TRUE if the function succeeds; FALSE if the function fails. If the function fails, call the
/// GetLastError function to determine the reason for failure.
///
///
///
/// Typically, you call this function as part of an in-process COM server registration. The CryptSIPAddProvider function
/// persists the appropriate Registry entries for the SIP provider functions.
///
/// When you have finished using the added SIP provider, remove it by calling the CryptSIPRemoveProvider function.
///
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/nf-mssip-cryptsipaddprovider BOOL CryptSIPAddProvider( IN
// SIP_ADD_NEWPROVIDER *psNewProv );
[DllImport(Lib.Crypt32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("mssip.h", MSDNShortId = "99633c2f-e5ed-49e4-9c98-7501f66e5571")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptSIPAddProvider([In] in SIP_ADD_NEWPROVIDER psNewProv);
///
/// The CryptSIPCreateIndirectData function returns a SIP_INDIRECT_DATA structure that contains a hash of the supplied
/// SIP_SUBJECTINFO structure, the digest algorithm, and an encoding attribute. The hash can be used as an indirect reference to the data.
///
///
/// A pointer to a SIP_SUBJECTINFO structure that contains the subject to which the indirect data reference will point.
///
/// A pointer to a DWORD value to receive the size of the returned SIP_INDIRECT_DATA structure.
/// A pointer to a SIP_INDIRECT_DATA structure to receive the catalog item.
///
/// The return value is TRUE if the function succeeds; otherwise, FALSE.
///
/// If this function returns FALSE, additional error information can be obtained by calling the GetLastError function.
/// GetLastError will return one of the following error codes.
///
///
///
/// Return code
/// Description
///
/// -
/// ERROR_BAD_FORMAT
/// The file or data format is not correct for the specified subject interface package (SIP) type.
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the parameters are not valid.
///
/// -
/// ERROR_NOT_ENOUGH_MEMORY
/// There was an error allocating memory.
///
/// -
/// NTE_BAD_ALGID
/// The specified algorithm is not supported by the SIP.
///
/// -
/// TRUST_E_SUBJECT_FORM_UNKNOWN
/// The subject type is not recognized.
///
///
///
///
/// If pcbIndirectData points to a DWORD and pIndirectData points to NULL, the size of the data will be returned in pcbIndirectData.
///
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/nf-mssip-cryptsipcreateindirectdata BOOL CryptSIPCreateIndirectData( IN
// SIP_SUBJECTINFO *pSubjectInfo, IN OUT DWORD *pcbIndirectData, OUT SIP_INDIRECT_DATA *pIndirectData );
[DllImport(Lib.Crypt32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("mssip.h", MSDNShortId = "bb4ecc95-972f-415c-9722-59b00a27cddc")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptSIPCreateIndirectData(in SIP_SUBJECTINFO pSubjectInfo, ref uint pcbIndirectData, IntPtr pIndirectData);
/// The CryptSIPGetCaps function retrieves the capabilities of a subject interface package (SIP).
/// Pointer to a SIP_SUBJECTINFO structure that specifies subject information data to the SIP APIs.
/// Pointer to a SIP_CAP_SET structure that defines the capabilities of an SIP.
/// None
///
/// Unlike other SIP functions, CryptSIPGetCaps is not registered in the dispatch table. For more information, see the
/// SIP_DISPATCH_INFO structure. Instead, callers must map the object identifier (OID) to the function entry point.
///
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/nf-mssip-cryptsipgetcaps BOOL CryptSIPGetCaps( SIP_SUBJECTINFO
// *pSubjInfo, SIP_CAP_SET *pCaps );
[DllImport(Lib.Crypt32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("mssip.h", MSDNShortId = "F939F6D5-DDFE-478F-8FDD-8FA9FAB26010")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptSIPGetCaps(in SIP_SUBJECTINFO pSubjInfo, ref SIP_CAP_SET_V2 pCaps);
/// The CryptSIPGetCaps function retrieves the capabilities of a subject interface package (SIP).
/// Pointer to a SIP_SUBJECTINFO structure that specifies subject information data to the SIP APIs.
/// Pointer to a SIP_CAP_SET structure that defines the capabilities of an SIP.
/// None
///
/// Unlike other SIP functions, CryptSIPGetCaps is not registered in the dispatch table. For more information, see the
/// SIP_DISPATCH_INFO structure. Instead, callers must map the object identifier (OID) to the function entry point.
///
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/nf-mssip-cryptsipgetcaps BOOL CryptSIPGetCaps( SIP_SUBJECTINFO
// *pSubjInfo, SIP_CAP_SET *pCaps );
[DllImport(Lib.Crypt32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("mssip.h", MSDNShortId = "F939F6D5-DDFE-478F-8FDD-8FA9FAB26010")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptSIPGetCaps(in SIP_SUBJECTINFO pSubjInfo, ref SIP_CAP_SET_V3 pCaps);
/// The CryptSIPGetSignedDataMsg function retrieves an Authenticode signature from the file.
/// A pointer to a SIP_SUBJECTINFO structure that contains information about the message subject.
///
/// The encoding type of the Authenticode signature.
/// This parameter can be a combination of one or more of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// PKCS_7_ASN_ENCODING 65536 (0x10000)
/// Specifies PKCS #7 message encoding.
///
/// -
/// X509_ASN_ENCODING 1 (0x1)
/// Specifies X.509 certificate encoding.
///
///
///
/// This parameter is reserved and should be set to zero.
/// The length, in bytes, of the buffer pointed to by the pbSignedDataMsg parameter.
///
/// A pointer to a buffer to receive the returned Authenticode signature.
///
/// To determine the size of the buffer needed, set the pbSignedDataMsg parameter to NULL and call the
/// CryptSIPGetSignedDataMsg function. This function will place the required size of the buffer, in bytes, in the value
/// pointed to by pcbSignedDataMsg. For more information, see Retrieving Data of Unknown Length.
///
///
///
/// If the function succeeds, the function returns TRUE.
///
/// If the function fails, it returns FALSE. For extended error information, call GetLastError. Some possible error codes follow.
///
///
///
/// Return code
/// Description
///
/// -
/// CRYPT_E_NO_MATCH
/// The signature specified by the index could not be found.
///
/// -
/// ERROR_BAD_FORMAT
/// The specified data or file format of the subject interface package (SIP) is not valid.
///
/// -
/// ERROR_INVALID_PARAMETER
/// The pSubjectInfo parameter or the pgSubjectType member of the SIP_SUBJECTINFO structure is a null pointer.
///
/// -
/// ERROR_INSUFFICIENT_BUFFER
///
/// The size of the message buffer was insufficient to hold the retrieved data, the pcbSignedDataMsgparameter has been set to
/// indicate the required buffer size.
///
///
/// -
/// TRUST_E_SUBJECT_FORM_UNKNOWN
/// The specified subject type is not valid.
///
///
///
///
/// Subjects include, but are not limited to, portable executable images (.exe), cabinet (.cab) images, flat files, and catalog
/// files. Each subject type uses a different subset of its data for hash calculation and requires a different procedure for storage
/// and retrieval. Therefore, each subject type has a unique SIP specification.
///
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/nf-mssip-cryptsipgetsigneddatamsg BOOL CryptSIPGetSignedDataMsg( IN
// SIP_SUBJECTINFO *pSubjectInfo, OUT DWORD *pdwEncodingType, IN DWORD dwIndex, IN OUT DWORD *pcbSignedDataMsg, OUT BYTE
// *pbSignedDataMsg );
[DllImport(Lib.Crypt32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("mssip.h", MSDNShortId = "e3fabaa7-2dda-4c6c-8d1a-3ee5363e10b5")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptSIPGetSignedDataMsg(in SIP_SUBJECTINFO pSubjectInfo, out CertEncodingType pdwEncodingType, uint dwIndex, ref uint pcbSignedDataMsg, [Out] IntPtr pbSignedDataMsg);
///
/// The CryptSIPLoad function loads the dynamic-link library (DLL) that implements a subject interface package (SIP) and
/// assigns appropriate library export functions to a SIP_DISPATCH_INFO structure. The exported functions must have been previously
/// registered by calling the CryptSIPAddProvider function.
///
/// A pointer to a GUID returned by calling the CryptSIPRetrieveSubjectGuid function.
/// This parameter is reserved and must be set to zero.
///
/// A pointer to a SIP_DISPATCH_INFO structure that contains pointers to SIP provider functions that are specific to the subject
/// type. The caller must initialize this structure to binary zeros, and set the cbSize member to before calling the
/// CryptSIPLoad function.
///
///
/// If the function succeeds, the function returns TRUE.
/// If the function fails, it returns FALSE. For extended error information, call GetLastError.
///
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/nf-mssip-cryptsipload BOOL CryptSIPLoad( IN const GUID *pgSubject, IN
// DWORD dwFlags, IN OUT SIP_DISPATCH_INFO *pSipDispatch );
[DllImport(Lib.Crypt32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("mssip.h", MSDNShortId = "3378ecee-bd5d-45e5-9a1f-a3734d086782")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptSIPLoad(in Guid pgSubject, [Optional] uint dwFlags, ref SIP_DISPATCH_INFO pSipDispatch);
/// The CryptSIPPutSignedDataMsg function stores an Authenticode signature in the target file.
/// Pointer to a SIP_SUBJECTINFO structure that contains information about the message subject.
///
/// The encoding type of the message. This can be a combination of one or more of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// PKCS_7_ASN_ENCODING 65536 (0x10000)
/// Specifies PKCS #7 message encoding.
///
/// -
/// X509_ASN_ENCODING 1 (0x1)
/// Specifies X.509 certificate encoding.
///
///
///
/// Pointer to the message index.
/// Length, in bytes, of the buffer pointed to by the pbSignedDataMsg parameter.
/// Pointer to the buffer that contains the message.
///
/// If the function succeeds, the function returns TRUE.
///
/// If the function fails, it returns FALSE. For extended error information, call GetLastError. Some possible error codes follow.
///
///
///
/// Return code
/// Description
///
/// -
/// ERROR_BAD_FORMAT
/// The specified data or file format of the subject interface package (SIP) is not valid.
///
/// -
/// ERROR_INVALID_PARAMETER
/// This code can be returned for the following reasons:
///
/// -
/// TRUST_E_SUBJECT_FORM_UNKNOWN
/// The specified subject type is not valid.
///
///
///
///
/// Each subject type uses a different subset of its data for hash calculation and requires a different procedure for storage and
/// retrieval. Therefore, each subject type has a unique SIP specification.
///
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/nf-mssip-cryptsipputsigneddatamsg BOOL CryptSIPPutSignedDataMsg( IN
// SIP_SUBJECTINFO *pSubjectInfo, IN DWORD dwEncodingType, OUT DWORD *pdwIndex, IN DWORD cbSignedDataMsg, IN BYTE *pbSignedDataMsg );
[DllImport(Lib.Crypt32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("mssip.h", MSDNShortId = "731f64bf-49f0-4799-b84a-9ca04292aa91")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptSIPPutSignedDataMsg(in SIP_SUBJECTINFO pSubjectInfo, CertEncodingType dwEncodingType, out uint pdwIndex, uint cbSignedDataMsg, [In] IntPtr pbSignedDataMsg);
///
/// The CryptSIPRemoveProvider function removes registry details of a Subject Interface Package (SIP) DLL file added by a
/// previous call to the CryptSIPAddProvider function.
///
/// A pointer to the GUID that identifies the SIP DLL to remove.
///
/// The return value is TRUE if the function succeeds; FALSE if the function fails. If the function fails, call the
/// GetLastError function to determine the reason for failure.
///
///
/// Typically you call this function to unregister an in-process COM server. The CryptSIPRemoveProvider function removes the
/// appropriate Registry entries for the SIP provider functions.
///
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/nf-mssip-cryptsipremoveprovider BOOL CryptSIPRemoveProvider( IN GUID
// *pgProv );
[DllImport(Lib.Crypt32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("mssip.h", MSDNShortId = "0a269956-b2c7-414a-b002-7cec0d52bfd6")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptSIPRemoveProvider(in Guid pgProv);
/// The CryptSIPRemoveSignedDataMsg function removes a specified Authenticode signature.
/// A pointer to a SIP_SUBJECTINFO structure that contains information about the message subject.
/// This parameter is reserved and should be set to zero.
///
/// If the function succeeds, the function returns TRUE.
/// If the function fails, it returns FALSE. For extended error information, call GetLastError.
///
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/nf-mssip-cryptsipremovesigneddatamsg BOOL CryptSIPRemoveSignedDataMsg(
// IN SIP_SUBJECTINFO *pSubjectInfo, IN DWORD dwIndex );
[DllImport(Lib.Crypt32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("mssip.h", MSDNShortId = "c3ea46bb-931a-4ca6-93f5-db7e07b4cb7a")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptSIPRemoveSignedDataMsg(in SIP_SUBJECTINFO pSubjectInfo, uint dwIndex = 0);
///
/// The CryptSIPRetrieveSubjectGuid function retrieves a GUID based on the header information in a specified file. The GUID
/// is used by the CryptSIPLoad function to load the subject interface package (SIP) implementation for the given file type.
///
/// The name of the file.
/// A handle to the file to check.
/// A GUID that identifies the subject.
///
/// If the function succeeds, the function returns TRUE.
/// If the function fails, it returns FALSE. For extended error information, call GetLastError.
///
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/nf-mssip-cryptsipretrievesubjectguid BOOL CryptSIPRetrieveSubjectGuid(
// IN LPCWSTR FileName, IN HANDLE hFileIn, OUT GUID *pgSubject );
[DllImport(Lib.Crypt32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("mssip.h", MSDNShortId = "b81472bc-6d9c-4634-a378-e39786a0ca09")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptSIPRetrieveSubjectGuid([MarshalAs(UnmanagedType.LPWStr)] string FileName, HFILE hFileIn, out Guid pgSubject);
///
/// The CryptSIPRetrieveSubjectGuidForCatalogFile function retrieves the subject GUID associated with the specified file.
///
/// The name of the file. If the hFileIn parameter is set, the value in this parameter is ignored.
///
/// A handle to the file to check. This parameter must contain a valid handle if the FileName parameter is NULL.
///
/// A globally unique ID that identifies the subject.
///
/// The return value is TRUE if the function succeeds; otherwise, FALSE.
///
/// If this function returns FALSE, additional error information can be obtained by calling the GetLastError function.
/// GetLastError will return one of the following error codes.
///
///
///
/// Return code
/// Description
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the parameters are not valid.
///
///
///
///
/// This function only supports subject interface packages (SIPs) that are used for portable executable images (.exe), cabinet
/// (.cab) images, and flat files.
///
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/nf-mssip-cryptsipretrievesubjectguidforcatalogfile BOOL
// CryptSIPRetrieveSubjectGuidForCatalogFile( IN LPCWSTR FileName, IN HANDLE hFileIn, OUT GUID *pgSubject );
[DllImport(Lib.Crypt32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("mssip.h", MSDNShortId = "7f757dc8-948c-476e-aca3-a9051e962ed4")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptSIPRetrieveSubjectGuidForCatalogFile([MarshalAs(UnmanagedType.LPWStr)] string FileName, HFILE hFileIn, out Guid pgSubject);
/// The CryptSIPVerifyIndirectData function validates the indirect hashed data against the supplied subject.
/// A pointer to a SIP_SUBJECTINFO structure that contains information about the message subject.
/// A pointer to a SIP_INDIRECT_DATA structure that contains information about the hashed subject information.
///
/// The return value is TRUE if the function succeeds; otherwise, FALSE.
///
/// If this function returns FALSE, additional error information can be obtained by calling the GetLastError function.
/// GetLastError will return one of the following error codes.
///
///
///
/// Return code
/// Description
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the parameters are not valid.
///
/// -
/// TRUST_E_SUBJECT_FORM_UNKNOWN
/// The subject type is an unknown type.
///
///
///
///
/// Subjects include, but are not limited to, portable executable images (.exe), cabinet (.cab) images, flat files, and catalog
/// files. Each subject type uses a different subset of its data for hash calculation and requires a different procedure for storage
/// and retrieval. Therefore each subject type has a unique subject interface package specification.
///
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/nf-mssip-cryptsipverifyindirectdata BOOL CryptSIPVerifyIndirectData( IN
// SIP_SUBJECTINFO *pSubjectInfo, IN SIP_INDIRECT_DATA *pIndirectData );
[DllImport(Lib.Crypt32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("mssip.h", MSDNShortId = "137b8858-a31f-4ef6-96bd-c5e26ae7b3e8")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptSIPVerifyIndirectData(in SIP_SUBJECTINFO pSubjectInfo, in SIP_INDIRECT_DATA pIndirectData);
/// The MS_ADDINFO_BLOB structure provides additional information for in-memory BLOB subject types.
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/ns-mssip-ms_addinfo_blob typedef struct MS_ADDINFO_BLOB_ { DWORD
// cbStruct; DWORD cbMemObject; BYTE *pbMemObject; DWORD cbMemSignedMsg; BYTE *pbMemSignedMsg; } MS_ADDINFO_BLOB, *PMS_ADDINFO_BLOB;
[PInvokeData("mssip.h", MSDNShortId = "236c8778-0b80-4157-8a81-24712ebf9a77")]
[StructLayout(LayoutKind.Sequential)]
public struct MS_ADDINFO_BLOB
{
/// The size, in bytes, of this structure.
public uint cbStruct;
/// The size, in bytes, of the data in the pbMemObject member.
public uint cbMemObject;
/// A pointer to the in-memory BLOB subject.
public IntPtr pbMemObject;
/// The size, in bytes, of the data in the pbMemSignedMsg member.
public uint cbMemSignedMsg;
/// A pointer to the signed message.
public IntPtr pbMemSignedMsg;
}
/// The MS_ADDINFO_CATALOGMEMBER structure provides additional information for catalog member subject types.
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/ns-mssip-ms_addinfo_catalogmember typedef struct
// MS_ADDINFO_CATALOGMEMBER_ { DWORD cbStruct; struct CRYPTCATSTORE_ *pStore; struct CRYPTCATMEMBER_ *pMember; }
// MS_ADDINFO_CATALOGMEMBER, *PMS_ADDINFO_CATALOGMEMBER;
[PInvokeData("mssip.h", MSDNShortId = "40a00c8a-95e4-406c-b04e-0d29beb70d67")]
[StructLayout(LayoutKind.Sequential)]
public struct MS_ADDINFO_CATALOGMEMBER
{
/// The size, in bytes, of this structure.
public uint cbStruct;
/// A CRYPTCATSTORE structure that contains a catalog file store.
public IntPtr pStore;
/// A CRYPTCATMEMBER structure that contains a catalog member.
public IntPtr pMember;
}
/// The MS_ADDINFO_FLAT structure provides additional information about flat or end-to-end subject types.
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/ns-mssip-ms_addinfo_flat typedef struct MS_ADDINFO_FLAT_ { DWORD
// cbStruct; struct SIP_INDIRECT_DATA_ *pIndirectData; } MS_ADDINFO_FLAT, *PMS_ADDINFO_FLAT;
[PInvokeData("mssip.h", MSDNShortId = "9f5bebd1-8eda-456d-9339-3334a19c0ea4")]
[StructLayout(LayoutKind.Sequential)]
public struct MS_ADDINFO_FLAT
{
/// The size, in bytes, of this structure.
public uint cbStruct;
/// A SIP_INDIRECT_DATA structure that contains the hash of a flat file subject.
public IntPtr pIndirectData;
}
///
/// The SIP_ADD_NEWPROVIDER structure defines a subject interface package (SIP). This structure is used by the
/// CryptSIPAddProvider function.
///
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/ns-mssip-sip_add_newprovider typedef struct SIP_ADD_NEWPROVIDER_ { DWORD
// cbStruct; GUID *pgSubject; WCHAR *pwszDLLFileName; WCHAR *pwszMagicNumber; WCHAR *pwszIsFunctionName; WCHAR *pwszGetFuncName;
// WCHAR *pwszPutFuncName; WCHAR *pwszCreateFuncName; WCHAR *pwszVerifyFuncName; WCHAR *pwszRemoveFuncName; WCHAR
// *pwszIsFunctionNameFmt2; PWSTR pwszGetCapFuncName; } SIP_ADD_NEWPROVIDER, *PSIP_ADD_NEWPROVIDER;
[PInvokeData("mssip.h", MSDNShortId = "5ca88c0c-a7c9-4517-a874-49d38c1bc7c3")]
[StructLayout(LayoutKind.Sequential)]
public struct SIP_ADD_NEWPROVIDER
{
/// The size, in bytes, of this structure. Set this value to .
public uint cbStruct;
/// Pointer to the GUID that identifies the SIP.
public GuidPtr pgSubject;
/// Pointer to a null-terminated string that contains the name of the DLL file.
[MarshalAs(UnmanagedType.LPWStr)] public string pwszDLLFileName;
/// This member is not used.
[MarshalAs(UnmanagedType.LPWStr)] public string pwszMagicNumber;
///
/// Pointer to a null-terminated string that contains the name of the function that determines whether the file contents are
/// supported by this SIP. This member can be NULL. The signature for this function pointer is described in pfnIsFileSupported.
///
[MarshalAs(UnmanagedType.LPWStr)] public string pwszIsFunctionName;
///
/// Pointer to a null-terminated string that contains the name of the function that retrieves the signed data. The signature for
/// this function pointer is described in CryptSIPGetSignedDataMsg.
///
[MarshalAs(UnmanagedType.LPWStr)] public string pwszGetFuncName;
///
/// Pointer to a null-terminated string that contains the name of the function that stores the Authenticode signature in the
/// target file. The signature for this function pointer is described in CryptSIPPutSignedDataMsg.
///
[MarshalAs(UnmanagedType.LPWStr)] public string pwszPutFuncName;
///
/// Pointer to a null-terminated string that contains the name of the function that creates the hash. The signature for this
/// function pointer is described in CryptSIPCreateIndirectData.
///
[MarshalAs(UnmanagedType.LPWStr)] public string pwszCreateFuncName;
///
/// Pointer to a null-terminated string that contains the name of the function that verifies the hash. The signature for this
/// function pointer is described in CryptSIPVerifyIndirectData.
///
[MarshalAs(UnmanagedType.LPWStr)] public string pwszVerifyFuncName;
///
/// Pointer to a null-terminated string that contains the name of the function that removes the signed data. The signature for
/// this function pointer is described in CryptSIPRemoveSignedDataMsg.
///
[MarshalAs(UnmanagedType.LPWStr)] public string pwszRemoveFuncName;
///
/// Pointer to a null-terminated string that contains the name of the function that determines whether the file name extension
/// is supported by this SIP. This member can be NULL. The signature for this function pointer is described in pfnIsFileSupportedName.
///
[MarshalAs(UnmanagedType.LPWStr)] public string pwszIsFunctionNameFmt2;
///
///
/// Pointer to a null-terminated string that contains the name of the function that determines the capabilities of the SIP. If
/// this parameter is set to NULL, multiple signatures are not available for this SIP. The signature for this function
/// pointer is described in pCryptSIPGetCaps.
///
///
/// Windows Server 2008 R2, Windows 7, Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: This
/// member is not available.
///
///
[MarshalAs(UnmanagedType.LPWStr)] public string pwszGetCapFuncName;
}
/// The SIP_CAP_SET structure defines the capabilities of a subject interface package (SIP).
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/ns-mssip-sip_cap_set_v2 typedef struct _SIP_CAP_SET_V2 { DWORD cbSize;
// DWORD dwVersion; BOOL isMultiSign; DWORD dwReserved; } SIP_CAP_SET_V2, *PSIP_CAP_SET_V2;
[PInvokeData("mssip.h", MSDNShortId = "0B6D173B-0183-4A7C-BB92-2D451F746164")]
[StructLayout(LayoutKind.Sequential)]
public struct SIP_CAP_SET_V2
{
/// Size, in bytes, of this structure.
public uint cbSize;
/// The SIP version. By default, this value is two (2).
public uint dwVersion;
///
/// A value of one (1) indicates that the SIP supports multiple embedded signatures. Otherwise, set this value to zero (0).
///
[MarshalAs(UnmanagedType.Bool)] public bool isMultiSign;
/// Reserved for future use. Set this value to zero (0).
public uint dwReserved;
}
/// The SIP_CAP_SET structure defines the capabilities of a subject interface package (SIP).
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/ns-mssip-sip_cap_set_v3 typedef struct _SIP_CAP_SET_V3 { DWORD cbSize;
// DWORD dwVersion; BOOL isMultiSign; union { DWORD dwFlags; DWORD dwReserved; }; } SIP_CAP_SET_V3, *PSIP_CAP_SET_V3;
[PInvokeData("mssip.h", MSDNShortId = "0B6D173B-0183-4A7C-BB92-2D451F746164")]
[StructLayout(LayoutKind.Sequential)]
public struct SIP_CAP_SET_V3
{
/// Size, in bytes, of this structure.
public uint cbSize;
/// The SIP version. By default, this value is two (2).
public uint dwVersion;
///
/// A value of one (1) indicates that the SIP supports multiple embedded signatures. Otherwise, set this value to zero (0).
///
[MarshalAs(UnmanagedType.Bool)] public bool isMultiSign;
///
public uint dwFlags;
/// Reserved for future use. Set this value to zero (0).
public uint dwReserved;
}
///
/// The SIP_DISPATCH_INFO structure contains a set of function pointers assigned by the CryptSIPLoad function that your
/// application uses to perform subject interface package (SIP) operations.
///
///
/// Your application must initialize this structure to binary zeros and set cbSize to by calling the memset function before
/// calling the CryptSIPLoad function. Your application can use the function pointers in the returned SIP_DISPATCH_INFO
/// structure to perform the necessary SIP operations. The function pointers can point to functions exported by third party SIPs.
///
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/ns-mssip-sip_dispatch_info typedef struct SIP_DISPATCH_INFO_ { DWORD
// cbSize; HANDLE hSIP; pCryptSIPGetSignedDataMsg pfGet; pCryptSIPPutSignedDataMsg pfPut; pCryptSIPCreateIndirectData pfCreate;
// pCryptSIPVerifyIndirectData pfVerify; pCryptSIPRemoveSignedDataMsg pfRemove; } SIP_DISPATCH_INFO, *LPSIP_DISPATCH_INFO;
[PInvokeData("mssip.h", MSDNShortId = "d34b5081-0af8-4dcc-8133-a91d0603d419")]
[StructLayout(LayoutKind.Sequential)]
public struct SIP_DISPATCH_INFO
{
/// The size, in bytes, of this structure.
public uint cbSize;
/// This member is reserved and must be set to NULL.
public HANDLE hSIP;
///
/// A pointer to the function that retrieves the signed data for the subject. The signature for this function pointer is
/// described in CryptSIPGetSignedDataMsg.
///
public pCryptSIPGetSignedDataMsg pfGet;
///
/// A pointer to the function that stores the signed data for the subject. The signature for this function pointer is described
/// in CryptSIPPutSignedDataMsg.
///
public pCryptSIPPutSignedDataMsg pfPut;
///
/// A pointer to the function that returns a SIP_INDIRECT_DATA structure that contains the subject data. This structure contains
/// the hash of the target. The signature for this function pointer is described in CryptSIPCreateIndirectData.
///
public pCryptSIPCreateIndirectData pfCreate;
///
/// A pointer to the function that verifies the SIP_INDIRECT_DATA structure that contains the subject data. This structure
/// contains the hash of the target. The signature for this function pointer is described in CryptSIPVerifyIndirectData.
///
public pCryptSIPVerifyIndirectData pfVerify;
///
/// A pointer to the function that removes the signed data for the subject. The signature for this function pointer is described
/// in CryptSIPRemoveSignedDataMsg.
///
public pCryptSIPRemoveSignedDataMsg pfRemove;
}
/// The SIP_INDIRECT_DATA structure contains the digest of the hashed subject information.
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/ns-mssip-sip_indirect_data typedef struct SIP_INDIRECT_DATA_ {
// CRYPT_ATTRIBUTE_TYPE_VALUE Data; CRYPT_ALGORITHM_IDENTIFIER DigestAlgorithm; CRYPT_HASH_BLOB Digest; } SIP_INDIRECT_DATA, *PSIP_INDIRECT_DATA;
[PInvokeData("mssip.h", MSDNShortId = "d34b599b-fe49-47c4-bb52-73ee14d73253")]
[StructLayout(LayoutKind.Sequential)]
public struct SIP_INDIRECT_DATA
{
/// A CRYPT_ATTRIBUTE_TYPE_VALUE structure used to encode the attribute.
public CRYPT_ATTRIBUTE_TYPE_VALUE Data;
/// A CRYPT_ALGORITHM_IDENTIFIER structure that contains the digest algorithm to use to create the hash.
public CRYPT_ALGORITHM_IDENTIFIER DigestAlgorithm;
///
/// A CRYPT_HASH_BLOB structure that contains the hash of the subject. For information about CRYPT_HASH_BLOB, see CRYPT_INTEGER_BLOB.
///
public CRYPTOAPI_BLOB Digest;
}
/// The SIP_SUBJECTINFO structure specifies subject information data to the subject interface package (SIP) APIs.
///
///
/// Upon first use of the SIP_SUBJECTINFO structure, initialize the entire structure to binary zero. Do not initialize the
/// structure between SIP function calls.
///
///
/// Subjects include, but are not limited to, portable executable images (.exe), cabinet (.cab) images, flat files, and catalog
/// files. Each subject type uses a different subset of its data for hash calculation and requires a different procedure for storage
/// and retrieval. Therefore each subject type has a unique subject interface package specification.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/mssip/ns-mssip-sip_subjectinfo typedef struct SIP_SUBJECTINFO_ { DWORD cbSize;
// GUID *pgSubjectType; HANDLE hFile; LPCWSTR pwsFileName; LPCWSTR pwsDisplayName; DWORD dwReserved1; DWORD dwIntVersion; HCRYPTPROV
// hProv; CRYPT_ALGORITHM_IDENTIFIER DigestAlgorithm; DWORD dwFlags; DWORD dwEncodingType; DWORD dwReserved2; DWORD fdwCAPISettings;
// DWORD fdwSecuritySettings; DWORD dwIndex; DWORD dwUnionChoice; union { #if ... MS_ADDINFO_FLAT_ *psFlat; #else struct
// MS_ADDINFO_FLAT_ *psFlat; #endif #if ... MS_ADDINFO_CATALOGMEMBER_ *psCatMember; #else struct MS_ADDINFO_CATALOGMEMBER_
// *psCatMember; #endif #if ... MS_ADDINFO_BLOB_ *psBlob; #else struct MS_ADDINFO_BLOB_ *psBlob; #endif }; LPVOID pClientData; }
// SIP_SUBJECTINFO, *LPSIP_SUBJECTINFO;
[PInvokeData("mssip.h", MSDNShortId = "6274cd08-d67f-410d-9303-3a42b7f1edc6")]
[StructLayout(LayoutKind.Sequential)]
public struct SIP_SUBJECTINFO
{
/// The size, in bytes, of this structure.
public uint cbSize;
/// A pointer to a GUID structure that identifies the subject type.
public GuidPtr pgSubjectType;
///
/// A file handle that represents the subject. If the storage type of the subject is a file, set hFile to
/// INVALID_HANDLE_VALUE and set the pwsFileName parameter to the name of the file.
///
public HFILE hFile;
/// A pointer to a null-terminated Unicode string that contains the file name of the subject.
[MarshalAs(UnmanagedType.LPWStr)] public string pwsFileName;
/// A pointer to a null-terminated Unicode string that contains the display name of the subject.
[MarshalAs(UnmanagedType.LPWStr)] public string pwsDisplayName;
/// This member is reserved for future use.
public uint dwReserved1;
///
/// This member is reserved. Do not modify this member. It is used by the SIP to pass the internal version number between get
/// and verify functions.
///
public uint dwIntVersion;
/// An HCRYPTPROV handle to the cryptography provider.
public HCRYPTPROV hProv;
///
/// A CRYPT_ALGORITHM_IDENTIFIER structure that contains the identifier for the hash algorithm used to hash the file.
///
public CRYPT_ALGORITHM_IDENTIFIER DigestAlgorithm;
///
/// A value that modifies the behavior of the functions that use this structure. For more information about possible values for
/// this member, see the dwFlags parameter of SignerSignEx.
///
public uint dwFlags;
///
/// A value that specifies the encoding type used for the file. Currently, only X509_ASN_ENCODING and
/// PKCS_7_ASN_ENCODING are being used; however, additional encoding types may be added in the future. For either current
/// encoding type, use: X509_ASN_ENCODING | PKCS_7_ASN_ENCODING.
///
public CertEncodingType dwEncodingType;
/// This member is reserved for future use.
public uint dwReserved2;
/// This member is not used.
public uint fdwCAPISettings;
/// This member is not used.
public uint fdwSecuritySettings;
/// The message index of the last call to CryptSIPGetSignedDataMsg. operation.
public uint dwIndex;
///
/// Specifies the type of additional information provided.
///
///
/// Defined constant/value
/// Meaning
///
/// -
/// MSSIP_ADDINFO_NONE 0
/// There is no additional information about the subject.
///
/// -
/// MSSIP_ADDINFO_FLAT 1
/// The additional information is a flat file.
///
/// -
/// MSSIP_ADDINFO_CATMEMBER 2
/// The additional information is a catalog member.
///
/// -
/// MSSIP_ADDINFO_BLOB 3
/// The additional information is a BLOB.
///
/// -
/// MSSIP_ADDINFO_NONMSSIP 500
/// The additional information is in a user defined format.
///
///
///
public uint dwUnionChoice;
/// A pointer to either a MS_ADDINFO_FLAT, MS_ADDINFO_CATALOGMEMBER, or MS_ADDINFO_BLOB structure.
public IntPtr pUnionData;
/// A pointer to SIP-specific data.
public IntPtr pClientData;
}
}
}