public static unsafe SignatureVerificationResult VerifyAuthenticodeTrust( ProviderFlags flags, string file) { var fileInfo = new WINTRUST_FILE_INFO(); var wintrustData = new WINTRUST_DATA(); try { fileInfo.cbStruct = Marshal.SizeOf(typeof(WINTRUST_FILE_INFO)); fileInfo.pcwszFilePath = Marshal.StringToHGlobalAuto(file); wintrustData.cbStruct = Marshal.SizeOf(typeof(WINTRUST_DATA)); wintrustData.dwUIChoice = WTD_UI_NONE; wintrustData.dwUnionChoice = WTD_CHOICE_FILE; wintrustData.fdwRevocationChecks = WTD_REVOKE_WHOLECHAIN; wintrustData.pFile = &fileInfo; wintrustData.dwStateAction = WTD_STATEACTION_VERIFY; wintrustData.dwProvFlags = flags; wintrustData.dwUIContext = WTD_UICONTEXT_INSTALL; try { fixed(Guid *pgActionID = &WINTRUST_ACTION_GENERIC_VERIFY_V2) return(WinVerifyTrust(IntPtr.Zero, pgActionID, &wintrustData)); } finally { wintrustData.dwStateAction = WTD_STATEACTION_CLOSE; fixed(Guid *pgActionID = &WINTRUST_ACTION_GENERIC_VERIFY_V2) WinVerifyTrust(IntPtr.Zero, pgActionID, &wintrustData); } } finally { Marshal.FreeHGlobal(fileInfo.pcwszFilePath); } }
public static bool Has(this ProviderFlags flags, ProviderFlags flag) { return((flags & flag) != 0); }
public RegistrationData For(ProviderFlags flags) { Providers = flags; return(this); }