public void SudSaveProject()
 {
     Project project = new Project
     {
         Programs = 
         {
             new Program
             {
                 Image = new LoadedImage(Address.SegPtr(0x1000, 0), new byte[100]),
                 DisassemblyFilename = "foo.asm",
                 IntermediateFilename = "foo.cod",
                 UserProcedures = new SortedList<Address,Procedure_v1> 
                 {
                     { 
                         Address.SegPtr(0x1000, 0x10), 
                         new Procedure_v1
                         {
                             Name = "foo",
                             Signature = new SerializedSignature
                             {
                                 ReturnValue = new Argument_v1 { Kind = new Register_v1("eax") },
                                 Arguments = new Argument_v1[]
                                 {
                                     new Argument_v1
                                     {
                                         Kind = new StackVariable_v1(),
                                         Type = new PrimitiveType_v1(Domain.SignedInt, 4)
                                     },
                                     new Argument_v1
                                     {
                                         Kind = new StackVariable_v1(),
                                         Type = new PrimitiveType_v1(Domain.SignedInt, 4)
                                     }
                                 }
                             }
                         }
                     }
                 },
                 UserGlobalData =
                 {
                     { 
                       Address.SegPtr(0x2000, 0) ,
                       new GlobalDataItem_v2 {
                            Address = Address.SegPtr(0x2000, 0).ToString(),
                            DataType = new StringType_v2 { 
                                Termination=StringType_v2.ZeroTermination, 
                                CharType = new PrimitiveType_v1 { Domain = Domain.Character, ByteSize = 1 }
                            }
                       }
                       }
                 }
             }
         }
     };
     using (FileUnitTester fut = new FileUnitTester("Core/SudSaveProject.txt"))
     {
         FilteringXmlWriter writer = new FilteringXmlWriter(fut.TextWriter);
         writer.Formatting = System.Xml.Formatting.Indented;
         XmlSerializer ser = SerializedLibrary.CreateSerializer_v2(typeof(Project_v2));
         Project_v2 ud = new ProjectSaver().Save(project);
         ser.Serialize(writer, ud);
         fut.AssertFilesEqual();
     }
 }
 public void Sud_SaveMetadataReference()
 {
     var project = new Project
     {
         Programs =
         {
             new Program
             {
                 Filename = "c:\\test\\foo.exe",
             }
         },
         MetadataFiles =
         {
             new MetadataFile
             {
                 Filename = "c:\\test\\foo.def",
                 ModuleName = "foo.def",
             }
         }
     };
     var ps = new ProjectSaver();
     var sProject = ps.Save(project);
     Assert.AreEqual(1, project.MetadataFiles.Count);
     Assert.AreEqual("c:\\test\\foo.def", project.MetadataFiles[0].Filename);
     Assert.AreEqual("foo.def", project.MetadataFiles[0].ModuleName);
 }
        public void SudSaveProgramOptions()
        {
            var program = new Program();
            program.Options.HeuristicScanning = true;
            
            var pSaver = new ProjectSaver();
            var file = pSaver.VisitProgram(program);
            var ip = (DecompilerInput_v2)file;
            Assert.IsTrue(ip.Options.HeuristicScanning);

        }
示例#4
0
        /// <summary>
        /// Saves the project. 
        /// </summary>
        /// <returns>False if the user cancelled the save, true otherwise.</returns>
        public bool Save()
        {
            if (string.IsNullOrEmpty(this.ProjectFileName))
            {
                string newName = PromptForFilename(
                    Path.ChangeExtension(
                        decompilerSvc.Decompiler.Project.Programs[0].Filename,
                        Project_v1.FileExtension));
                if (newName == null)
                    return false;
                ProjectFileName = newName;
                mru.Use(newName);
            }

            using (TextWriter sw = CreateTextWriter(ProjectFileName))
            {
                //$REFACTOR: rule of Demeter, push this into a Save() method.
                var sp =  new ProjectSaver().Save(decompilerSvc.Decompiler.Project);
                new ProjectLoader(loader).Save(sp, sw);
            }
            return true;
        }