diff --git a/PInvoke/WinTrust/WinTrust.cs b/PInvoke/WinTrust/WinTrust.cs index 44b85450..68081d1e 100644 --- a/PInvoke/WinTrust/WinTrust.cs +++ b/PInvoke/WinTrust/WinTrust.cs @@ -32,6 +32,33 @@ public static partial class WinTrust CERT_CONFIDENCE_HIGHEST = 0x11111000, } + /// Flags for . + [PInvokeData("wintrust.h")] + [Flags] + public enum CPD : uint + { + /// Use Windows 2000 chaining. + CPD_USE_NT5_CHAIN_FLAG = 0x80000000, + + /// No revocation checking is performed. + CPD_REVOCATION_CHECK_NONE = 0x00010000, + + /// Revocation checking for the end certificate is performed. + CPD_REVOCATION_CHECK_END_CERT = 0x00020000, + + /// Revocation checking for the certificate chain is performed. + CPD_REVOCATION_CHECK_CHAIN = 0x00040000, + + /// Revocation checking for the certificate chain, excluding the root certificate, is performed. + CPD_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT = 0x00080000, + + /// + CPD_RETURN_LOWER_QUALITY_CHAINS = 0x00100000, + + /// + CPD_RFC3161v21 = 0x00200000, + } + /// Action to perform. [PInvokeData("wintrust.h", MSDNShortId = "B2ED5489-792F-4B00-A21E-EE1B1462D1C8")] public enum DWACTION @@ -1495,61 +1522,156 @@ public static partial class WinTrust public IntPtr pChainElement; } - /// - /// [The CRYPT_PROVUI_DATA structure is available for use in the operating systems specified in the Requirements section. It may be - /// altered or unavailable in subsequent versions.] - /// - /// The CRYPT_PROVUI_DATA structure provides user interface (UI) data for a provider.This structure is used by the - /// CRYPT_PROVUI_FUNCS structure. - /// - /// - [PInvokeData("wintrust.h", MSDNShortId = "86f819f0-c243-45ba-8b7b-97ed906e6e8a")] - [StructLayout(LayoutKind.Sequential)] + /// The CRYPT_PROVIDER_DATA structure is used to pass data between WinVerifyTrust and trust providers. + // https://learn.microsoft.com/en-us/windows/win32/api/wintrust/ns-wintrust-crypt_provider_data typedef struct _CRYPT_PROVIDER_DATA { + // DWORD cbStruct; WINTRUST_DATA *pWintrustData; BOOL fOpenedFile; HWND hWndParent; GUID *pgActionID; HCRYPTPROV hProv; DWORD dwError; + // DWORD dwRegSecuritySettings; DWORD dwRegPolicySettings; struct _CRYPT_PROVIDER_FUNCTIONS *psPfns; DWORD cdwTrustStepErrors; DWORD + // *padwTrustStepErrors; DWORD chStores; HCERTSTORE *pahStores; DWORD dwEncoding; HCRYPTMSG hMsg; DWORD csSigners; struct + // _CRYPT_PROVIDER_SGNR *pasSigners; DWORD csProvPrivData; struct _CRYPT_PROVIDER_PRIVDATA *pasProvPrivData; DWORD dwSubjectChoice; union + // { #if ... _PROVDATA_SIP *pPDSip; #else struct _PROVDATA_SIP *pPDSip; #endif }; char *pszUsageOID; BOOL fRecallWithState; FILETIME + // sftSystemTime; char *pszCTLSignerUsageOID; DWORD dwProvFlags; DWORD dwFinalError; PCERT_USAGE_MATCH pRequestUsage; DWORD + // dwTrustPubSettings; DWORD dwUIStateFlags; struct _CRYPT_PROVIDER_SIGSTATE *pSigState; struct WINTRUST_SIGNATURE_SETTINGS_ + // *pSigSettings; } CRYPT_PROVIDER_DATA, *PCRYPT_PROVIDER_DATA; + [PInvokeData("wintrust.h", MSDNShortId = "NS:wintrust._CRYPT_PROVIDER_DATA")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct CRYPT_PROVIDER_DATA { /// The size, in bytes, of this structure. public uint cbStruct; - /// Error code, if applicable. + /// A pointer to a WINTRUST_DATA structure that contains the information to verify. + public IntPtr pWintrustData; + + /// A Boolean value that indicates whether the trust provider opened the file handle, if applicable. + [MarshalAs(UnmanagedType.Bool)] + public bool fOpenedFile; + + /// A handle to the parent window. If not specified, a handle to the desktop window is used. + public HWND hWndParent; + + /// A pointer to a GUID structure that identifies an action and the trust provider that supports that action. + public GuidPtr pgActionID; + + /// + /// A handle to the cryptographic service provider (CSP). If this parameter is NULL, then the operating system will provide a + /// default CSP. + /// + public HCRYPTPROV hProv; + + /// An error level if a low-level system error was encountered. + public uint dwError; + + /// The registry security settings. + public uint dwRegSecuritySettings; + + /// The registry policy settings. + public uint dwRegPolicySettings; + + /// A pointer to a CRYPT_PROVIDER_FUNCTIONS structure. + public IntPtr psPfns; + + /// The number of elements in the padwTrustStepErrors array. + public uint cdwTrustStepErrors; + + /// An array of DWORD values that specify trust step errors. + public IntPtr padwTrustStepErrors; + + /// The number of elements in the pahStores array. + public uint chStores; + + /// An array of certificate store handles. + public IntPtr pahStores; + + /// A value that specifies the encoding type. + public uint dwEncoding; + + /// A handle to the cryptographic message. + public HCRYPTMSG hMsg; + + /// The number of elements in the pasSigners array. + public uint csSigners; + + /// A pointer to an array of CRYPT_PROVIDER_SGNR structures. + public IntPtr pasSigners; + + /// The number of elements in the pasProvPrivData array. + public uint csProvPrivData; + + /// A pointer to an array of CRYPT_PROVIDER_PRIVDATA structures. + public IntPtr pasProvPrivData; + + /// A value that specifies the subject choice. + public uint dwSubjectChoice; + + /// A pointer to a _PROVDATA_SIP structure. + public IntPtr pPDSip; + + /// A pointer to a null-terminated string that contains the usage object identifier (OID). + [MarshalAs(UnmanagedType.LPStr)] + public string pszUsageOID; + + /// A Boolean value that indicates whether state was maintained for catalog files. + [MarshalAs(UnmanagedType.Bool)] + public bool fRecallWithState; + + /// The system time. + public FILETIME sftSystemTime; + + /// A pointer to a null-terminated string that represents the certificate trust list (CTL) signer usage OID. + [MarshalAs(UnmanagedType.LPStr)] + public string pszCTLSignerUsageOID; + + /// + /// A bitwise combination of one or more of the following flags. + /// + /// + /// Value + /// Meaning + /// + /// + /// CPD_USE_NT5_CHAIN_FLAG 0x80000000 + /// Use Windows 2000 chaining. + /// + /// + /// CPD_REVOCATION_CHECK_NONE 0x00010000 + /// No revocation checking is performed. + /// + /// + /// CPD_REVOCATION_CHECK_END_CERT 0x00020000 + /// Revocation checking for the end certificate is performed. + /// + /// + /// CPD_REVOCATION_CHECK_CHAIN 0x00040000 + /// Revocation checking for the certificate chain is performed. + /// + /// + /// CPD_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT 0x00080000 + /// Revocation checking for the certificate chain, excluding the root certificate, is performed. + /// + /// + /// + public CPD dwProvFlags; + + /// A value for the final error. public uint dwFinalError; - /// A pointer to a null-terminated string for the Yes button text. If this parameter is NULL, then "&Yes" is used. - [MarshalAs(UnmanagedType.LPWStr)] - public string pYesButtonText; + /// A pointer to a CERT_USAGE_MATCH structure. + public IntPtr pRequestUsage; - /// A pointer to a null-terminated string for the No button text. If this parameter is NULL, then "&No" is used. - [MarshalAs(UnmanagedType.LPWStr)] - public string pNoButtonText; - - /// A pointer to a null-terminated string for the More Info button text. If this parameter is NULL, then "&More Info" - /// is used. - [MarshalAs(UnmanagedType.LPWStr)] - public string pMoreInfoButtonText; - - /// A pointer to a null-terminated string for the Advanced button text. - [MarshalAs(UnmanagedType.LPWStr)] - public string pAdvancedLinkText; + /// A value for the trust publisher settings. + public uint dwTrustPubSettings; /// - /// A pointer to a null-terminated string for the text used when the trust is valid and a time stamp is used. If this parameter - /// is NULL, then "Do you want to install and run ""%1"" signed on %2 and distributed by:" is used. + /// A DWORD value that specifies state data that is passed between a trust provider and the user interface. + /// Windows XP with SP1 and Windows XP:   This member is ignored. /// - [MarshalAs(UnmanagedType.LPWStr)] - public string pCopyActionText; + public uint dwUIStateFlags; - /// - /// A pointer to a null-terminated string for the text used when the trust is valid but a time stamp is not used. If this - /// parameter is NULL, then "Do you want to install and run ""%1"" signed on an unknown date/time and distributed by:" is used. - /// - [MarshalAs(UnmanagedType.LPWStr)] - public string pCopyActionTextNoTS; + /// + public IntPtr pSigState; - /// - /// A pointer to a null-terminated string for the text used when a signature is not provided. If this parameter is NULL, then - /// "Do you want to install and run ""%1""?" is used. - /// - [MarshalAs(UnmanagedType.LPWStr)] - public string pCopyActionTextNotSigned; + /// + public IntPtr pSigSettings; } ///