CSPspEmu.Hle.Loader.ElfLoader.AllocateAndWrite C# (CSharp) Method

AllocateAndWrite() public method

public AllocateAndWrite ( Stream MemoryStream, MemoryPartition MemoryPartition, uint BaseAddress ) : void
MemoryStream Stream
MemoryPartition MemoryPartition
BaseAddress uint
return void
        public void AllocateAndWrite(Stream MemoryStream, MemoryPartition MemoryPartition, uint BaseAddress = 0)
        {
            this.MemoryStream = MemoryStream;
            this.MemoryPartition = MemoryPartition;
            this.BaseAddress = BaseAddress;

            AllocateMemory();
            WriteToMemory();

            //((PspMemoryStream)MemoryStream).Memory.Dump("after_allocate_and_write_dump.bin");
        }

Usage Example

Example #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.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);
        }
All Usage Examples Of CSPspEmu.Hle.Loader.ElfLoader::AllocateAndWrite