コード例 #1
0
ファイル: Pinvoke.cs プロジェクト: wilsonleeee/PoshInternals
        private static uint WinVerifyTrust(string fileName)
        {
            Guid wintrust_action_generic_verify_v2 = new Guid("{00AAC56B-CD44-11d0-8CC2-00C04FC295EE}");
            uint result = 0;

            using (WINTRUST_FILE_INFO fileInfo = new WINTRUST_FILE_INFO(fileName, Guid.Empty))
                using (UnmanagedPointer guidPtr = new UnmanagedPointer(Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Guid))), AllocMethod.HGlobal))
                    using (UnmanagedPointer wvtDataPtr = new UnmanagedPointer(Marshal.AllocHGlobal(Marshal.SizeOf(typeof(WINTRUST_DATA))), AllocMethod.HGlobal))
                    {
                        WINTRUST_DATA data  = new WINTRUST_DATA(fileInfo);
                        IntPtr        pGuid = guidPtr;
                        IntPtr        pData = wvtDataPtr;
                        Marshal.StructureToPtr(wintrust_action_generic_verify_v2, pGuid, true);
                        Marshal.StructureToPtr(data, pData, true);
                        result = WinTrust.WinVerifyTrust(IntPtr.Zero, pGuid, pData);
                    }
            return(result);
        }
コード例 #2
0
ファイル: Pinvoke.cs プロジェクト: adamdriscoll/PoshInternals
 private static uint WinVerifyTrust(string fileName)
 {
     Guid wintrust_action_generic_verify_v2 = new Guid("{00AAC56B-CD44-11d0-8CC2-00C04FC295EE}");
     uint result = 0;
     using (WINTRUST_FILE_INFO fileInfo = new WINTRUST_FILE_INFO(fileName, Guid.Empty))
     using (UnmanagedPointer guidPtr = new UnmanagedPointer(Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Guid))), AllocMethod.HGlobal))
     using (UnmanagedPointer wvtDataPtr = new UnmanagedPointer(Marshal.AllocHGlobal(Marshal.SizeOf(typeof(WINTRUST_DATA))), AllocMethod.HGlobal))
     {
         WINTRUST_DATA data = new WINTRUST_DATA(fileInfo);
         IntPtr pGuid = guidPtr;
         IntPtr pData = wvtDataPtr;
         Marshal.StructureToPtr(wintrust_action_generic_verify_v2, pGuid, true);
         Marshal.StructureToPtr(data, pData, true);
         result = WinTrust.WinVerifyTrust(IntPtr.Zero, pGuid, pData);
     }
     return result;
 }