dahall / Vanara

A set of .NET libraries for Windows implementing PInvoke calls to many native Windows APIs with supporting wrappers.
MIT License
1.75k stars 190 forks source link

CRYPT_PROVIDER_DATA duplicates CRYPT_PROVUI_DATA #461

Closed urielginsburg closed 2 months ago

urielginsburg commented 2 months ago

In WinTrust.cs, the CRYPT_PROVIDER_DATA structure duplicates CRYPT_PROVUI_DATA.

What code is involved

CRYPT_PROVUI_DATA:

    [PInvokeData("wintrust.h", MSDNShortId = "86f819f0-c243-45ba-8b7b-97ed906e6e8a")]
    public struct CRYPT_PROVUI_DATA
    {
        //
        // Summary:
        //     The size, in bytes, of this structure.
        public uint cbStruct;

        //
        // Summary:
        //     Error code, if applicable.
        public Win32Error dwFinalError;

        //
        // Summary:
        //     A pointer to a null-terminated string for the Yes button text. If this parameter
        //     is NULL, then "&Yes" is used.
        public StrPtrUni pYesButtonText;
...

CRYPT_PROVIDER_DATA:

    [PInvokeData("wintrust.h", MSDNShortId = "86f819f0-c243-45ba-8b7b-97ed906e6e8a")]
    public struct CRYPT_PROVIDER_DATA
    {
        //
        // Summary:
        //     The size, in bytes, of this structure.
        public uint cbStruct;

        //
        // Summary:
        //     Error code, if applicable.
        public uint dwFinalError;

        //
        // Summary:
        //     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;
...

Expected behavior

CRYPT_PROVIDER_DATA should be defined (shortened for brevity):

    [StructLayout(LayoutKind.Sequential)]
    public struct CRYPT_PROVIDER_DATA
    {
        private readonly int _cbStruct;
        private IntPtr _pWinTrustData;
        private bool _fOpenedFile;
        private IntPtr _hWndParent;
        private IntPtr _pgActionID;
        private IntPtr _hProv;
        private uint _dwError;
        private uint _dwRegSecuritySettings;
        private uint _dwRegPolicySettings;
        private IntPtr _psPfns;
        private uint _cdwTrustStepErrors;
        private IntPtr _padwTrustStepErrors;
        private uint _chStores;
        private IntPtr _pahStores;
        private uint _dwEncoding;
        private IntPtr _hMsg;
        private uint _csSigners;
        private IntPtr _pasSigners;
        private uint csProvPrivData;
        private IntPtr pasProvPrivData;
        private uint _dwSubjectChoice;
        private IntPtr _pInfoStruct;
        private IntPtr _pszUsageOID;
        private bool _fRecallWithState;
        private System.Runtime.InteropServices.ComTypes.FILETIME _sftSystemTime;
        private IntPtr _pszCTLSignerUsageOID;
        private uint _dwProvFlags;
        private uint _dwFinalError;
        private IntPtr _pRequestUsage;
        private uint _dwTrustPubSettings;
        private uint _dwUIStateFlags;
        private IntPtr _pSigState;
        private IntPtr _pSigSettings;
    }
dahall commented 2 months ago

Thanks for finding this bug. It has been around a long time. Fixed in 4.0.2.