Пример #1
0
        public void Prld_LoadUserDefinedMetadata()
        {
            var sProject = new Project_v4
            {
                ArchitectureName = "testArch",
                PlatformName     = "testOS",
                Inputs           =
                {
                    new DecompilerInput_v4
                    {
                        Filename = "foo.exe",
                    },
                    new MetadataFile_v3 {
                        Filename = "meta1.xml",
                    },
                    new MetadataFile_v3 {
                        Filename = "meta2.xml",
                    },
                }
            };

            var types1 = new Dictionary <string, DataType>()
            {
                { "USRTYPE1", PrimitiveType.Word16 }
            };
            var types2 = new Dictionary <string, DataType>()
            {
                { "USRTYPE2", PrimitiveType.Word32 }
            };

            var ldr = mockFactory.CreateLoader();

            Given_TestArch();
            Given_TestOS();

            mockFactory.CreateLoadMetadataStub(
                OsPath.Absolute("meta1.xml"),
                this.platform,
                new TypeLibrary(
                    types1, new Dictionary <string, ProcedureSignature>()
                    )
                );
            mockFactory.CreateLoadMetadataStub(
                OsPath.Absolute("meta2.xml"),
                this.platform,
                new TypeLibrary(
                    types2, new Dictionary <string, ProcedureSignature>()
                    )
                );
            mr.ReplayAll();

            var prld    = new ProjectLoader(sc, ldr);
            var project = prld.LoadProject(OsPath.Absolute("foo.project"), sProject);

            Assert.AreEqual(2, project.Programs[0].EnvironmentMetadata.Types.Count);
            Assert.AreEqual(
                "word16",
                project.Programs[0].EnvironmentMetadata.Types["USRTYPE1"].ToString()
                );
            Assert.AreEqual(
                "word32",
                project.Programs[0].EnvironmentMetadata.Types["USRTYPE2"].ToString()
                );
        }
Пример #2
0
        public void Prld_LoadUserDefinedMetadata()
        {
            var sProject = new Project_v4
            {
                ArchitectureName = "testArch",
                PlatformName     = "testOS",
                Inputs           =
                {
                    new DecompilerInput_v4
                    {
                        Filename = "foo.exe",
                        User     = new UserData_v4
                        {
                            LoadAddress = "00123400"
                        }
                    },
                    new MetadataFile_v3 {
                        Filename = "meta1.xml",
                    },
                    new MetadataFile_v3 {
                        Filename = "meta2.xml",
                    },
                }
            };

            var types1 = new Dictionary <string, DataType>()
            {
                { "USRTYPE1", PrimitiveType.Word16 }
            };
            var types2 = new Dictionary <string, DataType>()
            {
                { "USRTYPE2", PrimitiveType.Word32 }
            };

            var ldr = mockFactory.CreateLoader();

            Given_TestArch();
            Given_TestOS();
            arch.Stub(a => a.TryParseAddress(
                          Arg <string> .Is.Equal("00123400"),
                          out Arg <Address> .Out(Address.Ptr32(0x00123400)).Dummy))
            .Return(true);
            mockFactory.CreateLoadMetadataStub(
                OsPath.Absolute("meta1.xml"),
                this.platform,
                new TypeLibrary(
                    types1, new Dictionary <string, FunctionType>(), new Dictionary <string, DataType>()
                    )
                );
            mockFactory.CreateLoadMetadataStub(
                OsPath.Absolute("meta2.xml"),
                this.platform,
                new TypeLibrary(
                    types2, new Dictionary <string, FunctionType>(), new Dictionary <string, DataType>()
                    )
                );
            mr.ReplayAll();

            var prld    = new ProjectLoader(sc, ldr, listener);
            var project = prld.LoadProject(OsPath.Absolute("foo.project"), sProject);

            Assert.AreEqual(2, project.Programs[0].EnvironmentMetadata.Types.Count);
            Assert.AreEqual(
                "word16",
                project.Programs[0].EnvironmentMetadata.Types["USRTYPE1"].ToString()
                );
            Assert.AreEqual(
                "word32",
                project.Programs[0].EnvironmentMetadata.Types["USRTYPE2"].ToString()
                );
            Assert.AreEqual(
                Address.Ptr32(0x00123400),
                project.Programs[0].User.LoadAddress);
        }