예제 #1
0
        public static int Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.Error.WriteLine(Resources.Pdb2PdbUsage);
                return(1);
            }

            string peFile = args[0];
            var    srcPdb = GetArgumentValue(args, "/src:") ?? Path.ChangeExtension(peFile, "pdb");
            var    dstPdb = GetArgumentValue(args, "/dst:") ?? Path.ChangeExtension(peFile, "pdb2");

            if (!File.Exists(peFile))
            {
                Console.Error.WriteLine(string.Format(Resources.FileNotFound, peFile));
                return(2);
            }

            if (!File.Exists(srcPdb))
            {
                Console.Error.WriteLine(string.Format(Resources.FileNotFound, srcPdb));
                return(2);
            }

            try
            {
                using (var peStream = new FileStream(peFile, FileMode.Open, FileAccess.Read))
                    using (var srcPdbStream = new FileStream(srcPdb, FileMode.Open, FileAccess.Read))
                        using (var dstPdbStream = new FileStream(dstPdb, FileMode.Create, FileAccess.ReadWrite))
                        {
                            PdbConverter.Convert(peStream, srcPdbStream, dstPdbStream);
                        }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.Message);
                return(3);
            }

            return(0);
        }
예제 #2
0
        public static int Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("Usage: Pdb2Pdb <PE file> [/src:<PDB path>] [/dst:<Portable PDB path>]");
                return(1);
            }

            string peFile = args[0];
            var    srcPdb = GetArgumentValue(args, "/src:") ?? Path.ChangeExtension(peFile, "pdb");
            var    dstPdb = GetArgumentValue(args, "/dst:") ?? Path.ChangeExtension(peFile, "pdbx");

            if (!File.Exists(peFile))
            {
                Console.WriteLine($"PE file not: {peFile}");
                return(1);
            }

            if (!File.Exists(srcPdb))
            {
                Console.WriteLine($"PDB file not: {srcPdb}");
                return(1);
            }

            using (var peStream = new FileStream(peFile, FileMode.Open, FileAccess.Read))
            {
                using (var nativePdbStream = new FileStream(srcPdb, FileMode.Open, FileAccess.Read))
                {
                    using (var portablePdbStream = new FileStream(dstPdb, FileMode.Create, FileAccess.ReadWrite))
                    {
                        PdbConverter.Convert(peStream, nativePdbStream, portablePdbStream);
                    }
                }
            }

            return(0);
        }