public ProcedureBase GetTrampolineDestination(ImageReader rdr, IRewriterHost host) { var dasm = new PowerPcDisassembler(this, rdr, WordWidth); return GetTrampolineDestination(dasm, host); }
public override ProcedureBase GetTrampolineDestination(ImageReader rdr, IRewriterHost host) { var dasm = new PowerPcDisassembler( (PowerPcArchitecture64) Architecture, rdr, PrimitiveType.Word64); PowerPcInstruction instr; ImmediateOperand immOp; MemoryOperand memOp; //addi r12,r0,0000 instr = dasm.DisassembleInstruction(); if (instr.Opcode != Opcode.addi) return null; //oris r12,r12,0006 instr = dasm.DisassembleInstruction(); if (instr.Opcode != Opcode.oris) return null; immOp = (ImmediateOperand) instr.op3; uint aFuncDesc = immOp.Value.ToUInt32() << 16; //lwz r12,nnnn(r12) instr = dasm.DisassembleInstruction(); if (instr.Opcode != Opcode.lwz) return null; memOp = (MemoryOperand)instr.op2; int offset = memOp.Offset.ToInt32(); aFuncDesc = (uint)(aFuncDesc + offset); //std r2,40(r1) instr = dasm.DisassembleInstruction(); if (instr.Opcode != Opcode.std) return null; //lwz r0,0(r12) // Have a pointer to a trampoline instr = dasm.DisassembleInstruction(); if (instr.Opcode != Opcode.lwz) return null; //lwz r2,4(r12) instr = dasm.DisassembleInstruction(); if (instr.Opcode != Opcode.lwz) return null; // mtctr r0 instr = dasm.DisassembleInstruction(); if (instr.Opcode != Opcode.mtctr) return null; // bcctr 14,00 instr = dasm.DisassembleInstruction(); if (instr.Opcode != Opcode.bcctr) return null; // Read the function pointer from the function descriptor. offset = (int)aFuncDesc - (int)rdr.Address.ToUInt32(); rdr.Offset = rdr.Offset + offset; var aFn = rdr.ReadUInt32(); return null; }
public override ProcedureBase GetTrampolineDestination(ImageReader rdr, IRewriterHost host) { var dasm = new PowerPcDisassembler( (PowerPcArchitecture64)Architecture, rdr, PrimitiveType.Word64); PowerPcInstruction instr; ImmediateOperand immOp; MemoryOperand memOp; //addi r12,r0,0000 instr = dasm.DisassembleInstruction(); if (instr.Opcode != Opcode.addi) { return(null); } //oris r12,r12,0006 instr = dasm.DisassembleInstruction(); if (instr.Opcode != Opcode.oris) { return(null); } immOp = (ImmediateOperand)instr.op3; uint aFuncDesc = immOp.Value.ToUInt32() << 16; //lwz r12,nnnn(r12) instr = dasm.DisassembleInstruction(); if (instr.Opcode != Opcode.lwz) { return(null); } memOp = (MemoryOperand)instr.op2; int offset = memOp.Offset.ToInt32(); aFuncDesc = (uint)(aFuncDesc + offset); //std r2,40(r1) instr = dasm.DisassembleInstruction(); if (instr.Opcode != Opcode.std) { return(null); } //lwz r0,0(r12) // Have a pointer to a trampoline instr = dasm.DisassembleInstruction(); if (instr.Opcode != Opcode.lwz) { return(null); } //lwz r2,4(r12) instr = dasm.DisassembleInstruction(); if (instr.Opcode != Opcode.lwz) { return(null); } // mtctr r0 instr = dasm.DisassembleInstruction(); if (instr.Opcode != Opcode.mtctr) { return(null); } // bcctr 14,00 instr = dasm.DisassembleInstruction(); if (instr.Opcode != Opcode.bcctr) { return(null); } // Read the function pointer from the function descriptor. offset = (int)aFuncDesc - (int)rdr.Address.ToUInt32(); rdr.Offset = (ulong)(((long)rdr.Offset) + offset); var aFn = rdr.ReadUInt32(); return(null); }