Changeset 846


Ignore:
Timestamp:
1/2/2009 1:19:03 PM (3 years ago)
Author:
lowjoel
Message:

Fixed WintrustAPI for x86.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/Util/WintrustAPI.cs

    r845 r846  
    4040            fileinfo.cbStruct = (uint)Marshal.SizeOf(typeof(WINTRUST_FILE_INFO)); 
    4141            fileinfo.pcwszFilePath = pathToFile; 
    42             fileinfo.hFile = IntPtr.Zero; 
    4342 
    4443            WINTRUST_DATA data = new WINTRUST_DATA(); 
     
    4746            data.fdwRevocationChecks = WINTRUST_DATA.RevocationChecks.WTD_REVOKE_NONE; 
    4847            data.dwUnionChoice = WINTRUST_DATA.UnionChoices.WTD_CHOICE_FILE; 
    49             data.pUnion = Marshal.AllocHGlobal((int)data.cbStruct); 
     48            data.pUnion = Marshal.AllocHGlobal((int)fileinfo.cbStruct); 
    5049            Marshal.StructureToPtr(fileinfo, data.pUnion, false); 
    5150 
    52             int result = WinVerifyTrust(IntPtr.Zero, WINTRUST_ACTION_GENERIC_VERIFY_V2, data); 
     51            Guid guid = WINTRUST_ACTION_GENERIC_VERIFY_V2; 
     52            int result = WinVerifyTrust(IntPtr.Zero, ref guid, ref data); 
    5353            Marshal.FreeHGlobal(data.pUnion); 
    5454            return result == 0; 
     
    124124        ///                                 specified for the subject.</returns> 
    125125        [DllImport("Wintrust.dll", CharSet = CharSet.Unicode)] 
    126         private static extern int WinVerifyTrust(IntPtr hWnd, Guid pgActionID, 
    127             WINTRUST_DATA pWVTData); 
     126        private static extern int WinVerifyTrust(IntPtr hWnd, ref Guid pgActionID, 
     127            ref WINTRUST_DATA pWVTData); 
    128128 
    129129        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 
     
    133133            public string pcwszFilePath;    // required, file name to be verified 
    134134            public IntPtr hFile;            // optional, open handle to pcwszFilePath 
    135             public Guid pgKnownSubject;     // optional: fill if the subject type is known. 
     135            public IntPtr pgKnownSubject;   // optional: fill if the subject type is known. 
    136136        } 
    137137 
     138        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 
    138139        private struct WINTRUST_DATA 
    139140        { 
     
    142143            public IntPtr pPolicyCallbackData;          // optional: used to pass data between the app and policy 
    143144            public IntPtr pSIPClientData;               // optional: used to pass data between the app and SIP. 
     145            public UIChoices dwUIChoice;                // required: UI choice.  One of the following. 
     146            public RevocationChecks fdwRevocationChecks;// required: certificate revocation check options 
     147            public UnionChoices dwUnionChoice;          // required: which structure is being passed in? 
     148 
     149            public IntPtr pUnion; 
     150 
     151            public StateActions dwStateAction;          // optional (Catalog File Processing) 
     152            public IntPtr hWVTStateData;                // optional (Catalog File Processing) 
     153            private string pwszURLReference;            // optional: (future) used to determine zone. 
     154            public ProviderFlags dwProvFlags; 
     155            public UIContexts dwUIContext; 
    144156 
    145157            public enum UIChoices : uint 
     
    150162                WTD_UI_NOGOOD = 4, 
    151163            } 
    152             public UIChoices dwUIChoice;                // required: UI choice.  One of the following. 
    153  
    154164            public enum RevocationChecks : uint 
    155165            { 
     
    157167                WTD_REVOKE_WHOLECHAIN = 0x00000001 
    158168            } 
    159             public RevocationChecks fdwRevocationChecks;// required: certificate revocation check options 
    160  
    161169            public enum UnionChoices : uint 
    162170            { 
     
    167175                WTD_CHOICE_CERT = 5 
    168176            } 
    169             public UnionChoices dwUnionChoice;          // required: which structure is being passed in? 
    170  
    171             public IntPtr pUnion; 
    172177 
    173178            public enum StateActions : uint 
     
    179184                WTD_STATEACTION_AUTO_CACHE_FLUSH = 0x00000004 
    180185            } 
    181             public StateActions dwStateAction;      // optional (Catalog File Processing) 
    182             IntPtr hWVTStateData;                   // optional (Catalog File Processing) 
    183             string pwszURLReference;                // optional: (future) used to determine zone. 
    184  
    185186            public enum ProviderFlags : uint 
    186187            { 
     
    199200                WTD_CACHE_ONLY_URL_RETRIEVAL = 0x00001000 
    200201            } 
    201             public ProviderFlags dwProvFlags; 
    202  
    203  
    204             // 17-Dec-2004 JSchwart: re-added to fix build break in other depots 
    205202            public enum UIContexts 
    206203            { 
     
    208205                WTD_UICONTEXT_INSTALL = 1 
    209206            } 
    210             public UIContexts dwUIContext; 
    211207        } 
    212208 
Note: See TracChangeset for help on using the changeset viewer.