Пример #1
0
        public static WinVerifyTrustResult VerifyEmbeddedSignature(string fileName)
        {
            using var wtfi = new WinTrustFileInfo(fileName);
            using var wtd  = new WinTrustData(wtfi);
            var guidAction = new Guid(WINTRUST_ACTION_GENERIC_VERIFY_V2);

            return(WinVerifyTrust(INVALID_HANDLE_VALUE, guidAction, wtd));
        }
Пример #2
0
        // constructor for silent WinTrustDataChoice.File check
        public WinTrustData(WinTrustFileInfo fileInfo)
        {
            var wtfiData = fileInfo;

            FileInfoPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(WinTrustFileInfo)));
            Marshal.StructureToPtr(wtfiData, FileInfoPtr, false);

            using var signatureSettings = new WinTrustSignatureSettings();
            SignatureSettings           = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(WinTrustSignatureSettings)));
            Marshal.StructureToPtr(signatureSettings, SignatureSettings, false);
        }