예제 #1
0
        public void ElfLoaderConstructorTest()
        {
            var injectContext = new InjectContext();

            injectContext.SetInstanceType <PspMemory, LazyPspMemory>();
            var memory          = injectContext.GetInstance <PspMemory>();
            var memoryStream    = new PspMemoryStream(memory);
            var memoryPartition = new MemoryPartition(injectContext, PspMemory.MainOffset,
                                                      PspMemory.MainOffset + PspMemory.MainSize);

            var elfLoader = new ElfLoader();

            elfLoader.Load(File.OpenRead("../../../TestInput/minifire.elf"), "minifire.elf");
            elfLoader.AllocateAndWrite(memoryStream, memoryPartition);
            Assert.Equal(1, elfLoader.ProgramHeaders.Length);
            Assert.Equal(3, elfLoader.SectionHeaders.Length);

            Assert.Equal(
                "['','.rodata.sceModuleInfo']".Replace('\'', '"'),
                elfLoader.SectionHeadersByName.Keys.ToJson()
                );

            //ElfLoader.LoadAllocateMemory(MemoryPartition);
            //ElfLoader.LoadWriteToMemory(MemoryStream);

            //var ModuleInfo = ElfLoader.ModuleInfo;

            var pc = elfLoader.Header.EntryPoint;

            //var GP = ModuleInfo.GP;

            Assert.Equal(0x08900008, (int)pc);
            //Assert.Equal(0x00004821, (int)GP);
        }
예제 #2
0
        public void ElfLoaderConstructorTest()
        {
            var PspConfig          = new PspConfig();
            var PspEmulatorContext = new PspEmulatorContext(PspConfig);

            PspEmulatorContext.SetInstanceType <PspMemory, LazyPspMemory>();
            var Memory          = PspEmulatorContext.GetInstance <PspMemory>();
            var MemoryStream    = new PspMemoryStream(Memory);
            var MemoryPartition = new MemoryPartition(PspMemory.MainOffset, PspMemory.MainOffset + PspMemory.MainSize);

            var ElfLoader = new ElfLoader();

            ElfLoader.Load(File.OpenRead("../../../TestInput/minifire.elf"));
            ElfLoader.AllocateAndWrite(MemoryStream, MemoryPartition);
            Assert.AreEqual(1, ElfLoader.ProgramHeaders.Length);
            Assert.AreEqual(3, ElfLoader.SectionHeaders.Length);

            Assert.AreEqual(
                "['','.rodata.sceModuleInfo']".Replace('\'', '"'),
                ElfLoader.SectionHeadersByName.Keys.ToJson()
                );

            //ElfLoader.LoadAllocateMemory(MemoryPartition);
            //ElfLoader.LoadWriteToMemory(MemoryStream);

            //var ModuleInfo = ElfLoader.ModuleInfo;

            var PC = ElfLoader.Header.EntryPoint;

            //var GP = ModuleInfo.GP;

            Assert.AreEqual(0x08900008, (int)PC);
            //Assert.AreEqual(0x00004821, (int)GP);
        }