Example #1
0
 public override bool MatchJump(EndianImageReader rdr, uint opcode, out uint target)
 {
     if (opcode == 0xE9 // JMP NEAR
         &&
         rdr.IsValidOffset(rdr.Offset + 5u))
     {
         int callOffset = rdr.PeekLeInt32(1);
         target = (uint)(callOffset + (int)rdr.Address.ToLinear() + 5);
         return(true);
     }
     if (0x70 <= opcode && opcode <= 0x7F &&       // short branch.
         rdr.IsValidOffset(rdr.Offset + 1u))
     {
         sbyte callOffset = rdr.PeekSByte(1);
         target = (uint)((int)rdr.Address.ToLinear() + callOffset + 2);
         return(true);
     }
     if (opcode == 0x0F && rdr.IsValidOffset(rdr.Offset + 5u))
     {
         opcode = rdr.PeekByte(1);
         int  callOffset = rdr.PeekLeInt32(2);
         uint linAddr    = (uint)rdr.Address.ToLinear();
         if (0x80 <= opcode && opcode <= 0x8F)   // long branch
         {
             target = (uint)(callOffset + linAddr + 6);
             return(true);
         }
     }
     target = 0;
     return(false);
 }