Exemplo n.º 1
0
 private void Dispose(bool disposing)
 {
     if (dwUnionChoice == UnionChoice.File)
     {
         WintrustFileInfo info = new WintrustFileInfo();
         Marshal.PtrToStructure(pInfoStruct, info);
         info.Dispose();
         Marshal.DestroyStructure(pInfoStruct, typeof(WintrustFileInfo));
     }
     Marshal.FreeHGlobal(pInfoStruct);
 }
Exemplo n.º 2
0
 public WintrustData(WintrustFileInfo fileInfo)
 {
     this.cbStruct = (uint)Marshal.SizeOf(typeof(WintrustData));
     pInfoStruct   = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(WintrustFileInfo)));
     Marshal.StructureToPtr(fileInfo, pInfoStruct, false);
     this.dwUnionChoice  = UnionChoice.File;
     pPolicyCallbackData = IntPtr.Zero;
     pSIPCallbackData    = IntPtr.Zero;
     dwUIChoice          = UiChoice.NoUI;
     fdwRevocationChecks = RevocationCheckFlags.None;
     dwStateAction       = StateAction.Ignore;
     hWVTStateData       = IntPtr.Zero;
     pwszURLReference    = IntPtr.Zero;
     dwProvFlags         = TrustProviderFlags.Safer;
     dwUIContext         = UiContext.Execute;
 }
Exemplo n.º 3
0
        private static uint WinVerifyTrust(string fileName)
        {
            uint result = 1;

            if (!System.IO.File.Exists(fileName))
            {
                return(result);
            }
            var wintrustActionGenericVerifyV2 = new Guid("{00AAC56B-CD44-11d0-8CC2-00C04FC295EE}");

            using (var fileInfo = new WintrustFileInfo(fileName, Guid.Empty))
                using (var guidPtr = new UnmanagedPointer(Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Guid))), AllocMethod.HGlobal))
                    using (var wvtDataPtr = new UnmanagedPointer(Marshal.AllocHGlobal(Marshal.SizeOf(typeof(WintrustData))), AllocMethod.HGlobal))
                    {
                        var    data  = new WintrustData(fileInfo);
                        IntPtr pGuid = guidPtr;
                        IntPtr pData = wvtDataPtr;
                        Marshal.StructureToPtr(wintrustActionGenericVerifyV2, pGuid, true);
                        Marshal.StructureToPtr(data, pData, true);
                        result = WinVerifyTrust(IntPtr.Zero, pGuid, pData);
                    }
            return(result);
        }