예제 #1
0
 static void Test1()
 {
     var Memory = new Xbox360MemoryNormal();
     var Xex = new Xex();
     var CpuThreadState = new CpuThreadState();
     Xex.LoadHeader(File.OpenRead("../../../TestInput/test.xex"));
     Xex.Pe.LoadSectionsTo(new Xbox360MemoryStream(Memory));
     CpuThreadState.pc = Xex.Pe.PeOptionalHeader.AddressOfEntryPoint + Xex.Pe.PeOptionalHeader.ImageBase;
     Console.WriteLine("{0:X}: {1:X}", CpuThreadState.pc, Memory.Read4(CpuThreadState.pc));
 }
 public void CreateDelegateTest()
 {
     var CpuThreadState = new CpuThreadState();
     var CompilerState = new CompilerState();
     CpuThreadState.r1 = 1000000000000000000;
     CompilerState.SaveGpr(0, () =>
     {
         CompilerState.LoadGpr(1);
         CompilerState.LoadImm(999);
         CompilerState.Emit(OpCodes.Add);
     });
     CompilerState.Ret();
     CompilerState.CreateDelegate()(CpuThreadState);
     Assert.AreEqual(1000000000000000999, CpuThreadState.r0);
 }
예제 #3
0
        static void Test2()
        {
            //new DisassemblerTest().DissasembleTest();
            /*
            Console.WriteLine(Disassembler.DissasembleSimple(0x3D608202));
            Console.WriteLine(Disassembler.DissasembleSimple(0x7C7E1B78));
            Console.WriteLine(Disassembler.DissasembleSimple(0x7FA53214));
            Console.WriteLine(Disassembler.DissasembleSimple(0x7D8802A6));
            */

            Console.WriteLine(Disassembler.DissasembleSimple(0x4E800020));

            var CpuThreadState = new CpuThreadState();
            var CompilerState = new CompilerState();
            var Compiler = new Compiler(CompilerState);
            CompilerState.CurrentInstruction = 0x7D8802A6;
            Compiler.mflr();
            var Delegate = CompilerState.CreateDelegate();

            CpuThreadState.lr = 999;
            Delegate(CpuThreadState);

            Console.WriteLine("{0}, {1}", CpuThreadState.lr, CpuThreadState.r12);
        }