Example #1
0
 public function testSetOpcode()
 {
     $instr = new Instruction();
     $instr->setOpcode('90');
     $this->assertEquals('90', $instr->getOpcode());
     $this->assertEquals('90', $instr->assemble());
 }
Example #2
0
 public function testAssembleX8664Offset()
 {
     $nopInstr1 = new X8664Nop();
     $nopInstr2 = new X8664Nop();
     $bInstr1 = new BaseInstruction();
     $retInstr = new X8664Ret();
     $bInstr1->setOpcode('909090');
     $bInstr1->setLen(3);
     $asm = new Assembly();
     $asm->addInstruction($nopInstr1);
     $asm->addInstruction($nopInstr2);
     $asm->addInstruction($bInstr1);
     $asm->addInstruction($retInstr);
     $this->assertEquals(0, $nopInstr1->getOffset());
     $this->assertEquals(1, $nopInstr2->getOffset());
     $this->assertEquals(2, $bInstr1->getOffset());
     $this->assertEquals(5, $retInstr->getOffset());
     $bInstr1->setOpcode('90');
     $bInstr1->setLen(1);
     $this->assertEquals(0, $nopInstr1->getOffset());
     $this->assertEquals(1, $nopInstr2->getOffset());
     $this->assertEquals(2, $bInstr1->getOffset());
     $this->assertEquals(3, $retInstr->getOffset());
     $bInstr1->setOpcode('90909090');
     $bInstr1->setLen(4);
     $this->assertEquals(0, $nopInstr1->getOffset());
     $this->assertEquals(1, $nopInstr2->getOffset());
     $this->assertEquals(2, $bInstr1->getOffset());
     $this->assertEquals(6, $retInstr->getOffset());
 }
Example #3
0
 /**
  * @dataProvider x8664ObjectProvider
  */
 public function test8664Object($offsetJmp, $offsetInstr, $expected)
 {
     $instr1 = new Instruction();
     $instr1->setOffset($offsetInstr);
     $jmp1 = new X8664Jmp($instr1);
     $jmp1->setOffset($offsetJmp);
     $opcode = unpack('H*', $jmp1->assemble());
     $opcode = $opcode[1];
     $this->assertEquals($expected, $opcode);
 }