예제 #1
0
 private static string Trace(
     Configuration configuration,
     string message,
     string category
     )
 {
     return(TraceOps.Trace(configuration, message, category));
 }
예제 #2
0
 private static string Trace(
     Configuration configuration,
     Exception exception,
     string category
     )
 {
     return(TraceOps.Trace(configuration, exception, category));
 }
예제 #3
0
        ///////////////////////////////////////////////////////////////////////

        #region Public Methods
        public static bool IsFileTrusted(
            Configuration configuration,
            string fileName,
            IntPtr fileHandle,
            bool userInterface,
            bool userPrompt,
            bool revocation,
            bool install,
            ref string error
            )
        {
#if !DEBUG
            /* !SUCCESS */
            int    returnValue = (int)UnsafeNativeMethods.ERROR_SUCCESS + 1;
            string localError  = null;

            if ((IsFileTrusted(
                     fileName, fileHandle, userInterface,
                     userPrompt, revocation,
                     install, ref returnValue,
                     ref localError)) &&
                (returnValue == UnsafeNativeMethods.ERROR_SUCCESS))
            {
                return(true);
            }
            else
            {
                if (localError != null)
                {
                    error = localError;
                }
                else if (returnValue != UnsafeNativeMethods.ERROR_SUCCESS)
                {
                    error = String.Format(
                        "WinVerifyTrust() failed with error 0x{0:X}.",
                        returnValue);
                }

                return(false);
            }
#else
            //
            // NOTE: Emit a log entry so that the user knows for sure
            //       that we did NOT actually verify the file trust.
            //
            TraceOps.Trace(configuration, String.Format(
                               "File \"{0}\" certificate unchecked: " +
                               "WinVerifyTrust use is disabled.",
                               fileName), typeof(WinTrustEx).Name);

            //
            // NOTE: In-development version, fake it.  We can do this
            //       because DEBUG builds are never officially released.
            //
            return(true);
#endif
        }
예제 #4
0
        ///////////////////////////////////////////////////////////////////////

        #region Public Methods
        public static bool IsStrongNameSigned(
            Configuration configuration,
            string fileName,
            bool force,
            ref string error
            )
        {
#if !DEBUG
            bool   returnValue = false;
            bool   verified    = false;
            string localError  = null;

            if ((IsStrongNameSigned(
                     fileName, force, ref returnValue, ref verified,
                     ref localError)) &&
                returnValue && verified)
            {
                return(true);
            }
            else
            {
                if (localError != null)
                {
                    error = localError;
                }
                else
                {
                    error = "StrongNameSignatureVerificationEx() failed.";
                }

                return(false);
            }
#else
            //
            // NOTE: Emit a log entry so that the user knows for sure
            //       that we did NOT actually verify the strong name
            //       signature.
            //
            TraceOps.Trace(configuration, String.Format(
                               "File \"{0}\" strong name unchecked: " +
                               "StrongNameSignatureVerificationEx use is disabled.",
                               fileName), typeof(StrongNameEx).Name);

            //
            // NOTE: In-development version, fake it.  We can do this
            //       because DEBUG builds are never officially released.
            //
            return(true);
#endif
        }