Ejemplo n.º 1
0
        static void ParseErrors(PeVerifyResult result, string stdOut)
        {
            result.Errors = new List <string>();

            int startIndex = 0;

            while (startIndex < stdOut.Length)
            {
                startIndex = stdOut.IndexOf("[IL]:", startIndex);
                if (startIndex == -1)
                {
                    break;
                }

                int endIndex = stdOut.IndexOf("[IL]:", startIndex + 1);
                if (endIndex == -1)
                {
                    // Look for the last line...
                    endIndex = stdOut.IndexOf("\r\n", startIndex + 1);
                }

                result.Errors.Add(result.NormalizeErrorString(stdOut.Substring(startIndex, endIndex - startIndex)));
                startIndex = endIndex;
            }
        }
Ejemplo n.º 2
0
        public static PeVerifyResult VerifyAssembly(string assemblyName)
        {
            PeVerifyResult result = new PeVerifyResult();

            result.AssemblyName = assemblyName;

            string stdOut, stdErr;

            result.ExitCode = StartAndWaitForResult(PeVerifyPath, assemblyName + " /UNIQUE /IL /NOLOGO", out stdOut, out stdErr);
            ParseErrors(result, stdOut);

            return(result);
        }
Ejemplo n.º 3
0
        public static void Assert(PeVerifyResult expectedResult, PeVerifyResult actualResult)
        {
            foreach (var e in expectedResult.Errors)
            {
                actualResult.Errors.Remove(e);
            }

            // TODO: Ideally this will be with peverify v4.0, and this won't be needed.
            if (actualResult.Errors.Count > expectedResult.Errors.Count)
            {
                Console.WriteLine("Expected:");
                expectedResult.Errors.ForEach(Console.WriteLine);
                Console.WriteLine();

                Console.WriteLine("Actual:");
                actualResult.Errors.ForEach(Console.WriteLine);
                Console.WriteLine("PeVerify: {0}", expectedResult.AssemblyName);

                throw new Exception("PeVerify Failed with " + actualResult.Errors.Count + " different errors.");
            }
        }
Ejemplo n.º 4
0
        public static void Assert(PeVerifyResult expectedResult, PeVerifyResult actualResult)
        {
            foreach (var e in expectedResult.Errors)
            {
                actualResult.Errors.Remove(e);
            }

            // TODO: Ideally this will be with peverify v4.0, and this won't be needed.
            if (actualResult.Errors.Count > expectedResult.Errors.Count)
            {
                Console.WriteLine("Expected:");
                expectedResult.Errors.ForEach(Console.WriteLine);
                Console.WriteLine();

                Console.WriteLine("Actual:");
                actualResult.Errors.ForEach(Console.WriteLine);
                Console.WriteLine("PeVerify: {0}", expectedResult.AssemblyName);

                throw new Exception("PeVerify Failed with " + actualResult.Errors.Count + " different errors.");
            }
        }
Ejemplo n.º 5
0
        static void ParseErrors(PeVerifyResult result, string stdOut)
        {
            result.Errors = new List<string>();

            int startIndex = 0;
            while (startIndex < stdOut.Length)
            {
                startIndex = stdOut.IndexOf("[IL]:", startIndex);
                if (startIndex == -1) break;

                int endIndex = stdOut.IndexOf("[IL]:", startIndex + 1);
                if (endIndex == -1)
                {
                    // Look for the last line...
                    endIndex = stdOut.IndexOf("\r\n", startIndex + 1);
                }

                result.Errors.Add(result.NormalizeErrorString(stdOut.Substring(startIndex, endIndex - startIndex)));
                startIndex = endIndex;
            }
        }
Ejemplo n.º 6
0
        public static PeVerifyResult VerifyAssembly(string assemblyName)
        {
            PeVerifyResult result = new PeVerifyResult();
            result.AssemblyName = assemblyName;

            string stdOut, stdErr;
            result.ExitCode = StartAndWaitForResult(PeVerifyPath, assemblyName + " /UNIQUE /IL /NOLOGO", out stdOut, out stdErr);
            ParseErrors(result, stdOut);

            return result;
        }