added a param to the lifter_callback_t...

merge-requests/11/head
_xeroxz 3 years ago
parent 87acc2837b
commit 44e412cffb

@ -4,7 +4,7 @@
namespace vm::lifters
{
using lifter_callback_t = std::function< void( vtil::basic_block *, vm::instrs::virt_instr_t * ) >;
using lifter_callback_t = std::function< void( vtil::basic_block *, vm::instrs::virt_instr_t *, vmp2::v3::code_block_t* ) >;
using lifter_t = std::pair< vm::handler::mnemonic_t, lifter_callback_t >;
// taken from

@ -4,7 +4,7 @@ namespace vm::lifters
{
vm::lifters::lifter_t addq = {
// vsp[0] = vsp[1] + vsp[0];
vm::handler::ADDQ, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) {
vm::handler::ADDQ, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr, vmp2::v3::code_block_t* code_blk ) {
auto [ t0, t1 ] = blk->tmp( 64, 64 );
blk->pop( t0 );
blk->pop( t1 );
@ -15,7 +15,7 @@ namespace vm::lifters
vm::lifters::lifter_t adddw = {
// vsp[0] = vsp[1] + vsp[0];
vm::handler::ADDDW, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) {
vm::handler::ADDDW, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr, vmp2::v3::code_block_t* code_blk ) {
auto [ t0, t1 ] = blk->tmp( 32, 32 );
blk->pop( t0 );
blk->pop( t1 );
@ -26,7 +26,7 @@ namespace vm::lifters
vm::lifters::lifter_t addw = {
// vsp[0] = vsp[1] + vsp[0];
vm::handler::ADDW, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) {
vm::handler::ADDW, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr, vmp2::v3::code_block_t* code_blk ) {
auto [ t0, t1 ] = blk->tmp( 16, 16 );
blk->pop( t0 );
blk->pop( t1 );

@ -4,7 +4,15 @@ namespace vm::lifters
{
vm::lifters::lifter_t jmp = {
// jmp
vm::handler::JMP, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) {
blk->jmp( vinstr->trace_data.vsp.qword[ 0 ] );
vm::handler::JMP,
[]( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr, vmp2::v3::code_block_t *code_blk ) {
if ( code_blk->jcc.has_jcc )
{
// TODO: figure out what bit the JCC is determined on...
blk->js( vtil::REG_FLAGS.select( 1, 11 ), code_blk->jcc.block_addr[ 0 ],
code_blk->jcc.block_addr[ 1 ] );
}
else
blk->jmp( vinstr->trace_data.vsp.qword[ 0 ] );
} };
}

@ -4,55 +4,64 @@ namespace vm::lifters
{
vm::lifters::lifter_t lconstq = {
// push imm<N>
vm::handler::LCONSTQ, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) {
vm::handler::LCONSTQ,
[]( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr, vmp2::v3::code_block_t *code_blk ) {
blk->push( vtil::operand( vinstr->operand.imm.u, 64 ) );
} };
vm::lifters::lifter_t lconstdw = {
// push imm<N>
vm::handler::LCONSTDW, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) {
vm::handler::LCONSTDW,
[]( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr, vmp2::v3::code_block_t *code_blk ) {
blk->push( vtil::operand( vinstr->operand.imm.u, 32 ) );
} };
vm::lifters::lifter_t lconstw = {
// push imm<N>
vm::handler::LCONSTW, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) {
vm::handler::LCONSTW,
[]( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr, vmp2::v3::code_block_t *code_blk ) {
blk->push( vtil::operand( vinstr->operand.imm.u, 16 ) );
} };
vm::lifters::lifter_t lconstbzxw = {
// push imm<N>
vm::handler::LCONSTBZXW, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) {
vm::handler::LCONSTBZXW,
[]( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr, vmp2::v3::code_block_t *code_blk ) {
blk->push( vtil::operand( vinstr->operand.imm.u, 16 ) );
} };
vm::lifters::lifter_t lconstbsxdw = {
// push imm<N>
vm::handler::LCONSTBSXDW, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) {
vm::handler::LCONSTBSXDW,
[]( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr, vmp2::v3::code_block_t *code_blk ) {
blk->push( vtil::operand( vinstr->operand.imm.u, 32 ) );
} };
vm::lifters::lifter_t lconstbsxq = {
// push imm<N>
vm::handler::LCONSTBSXQ, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) {
vm::handler::LCONSTBSXQ,
[]( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr, vmp2::v3::code_block_t *code_blk ) {
blk->push( vtil::operand( vinstr->operand.imm.u, 64 ) );
} };
vm::lifters::lifter_t lconstdwsxq = {
// push imm<N>
vm::handler::LCONSTDWSXQ, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) {
vm::handler::LCONSTDWSXQ,
[]( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr, vmp2::v3::code_block_t *code_blk ) {
blk->push( vtil::operand( vinstr->operand.imm.u, 64 ) );
} };
vm::lifters::lifter_t lconstwsxq = {
// push imm<N>
vm::handler::LCONSTWSXQ, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) {
vm::handler::LCONSTWSXQ,
[]( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr, vmp2::v3::code_block_t *code_blk ) {
blk->push( vtil::operand( vinstr->operand.imm.u, 64 ) );
} };
vm::lifters::lifter_t lconstwsxdw = {
// push imm<N>
vm::handler::LCONSTWSXDW, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) {
vm::handler::LCONSTWSXDW,
[]( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr, vmp2::v3::code_block_t *code_blk ) {
blk->push( vtil::operand( vinstr->operand.imm.u, 32 ) );
} };
} // namespace vm::lifters

@ -4,6 +4,6 @@ namespace vm::lifters
{
vm::lifters::lifter_t lrflags = {
// push flags
vm::handler::LRFLAGS,
[]( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) { blk->push( vtil::REG_FLAGS ); } };
vm::handler::LRFLAGS, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr,
vmp2::v3::code_block_t *code_blk ) { blk->push( vtil::REG_FLAGS ); } };
}

@ -4,13 +4,15 @@ namespace vm::lifters
{
vm::lifters::lifter_t lregq = {
// push vregX
vm::handler::LREGQ, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) {
vm::handler::LREGQ,
[]( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr, vmp2::v3::code_block_t *code_blk ) {
blk->push( make_virtual_register( vinstr->operand.imm.u, 8 ) );
} };
vm::lifters::lifter_t lregdw = {
// push vregX
vm::handler::LREGDW, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) {
vm::handler::LREGDW,
[]( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr, vmp2::v3::code_block_t *code_blk ) {
blk->push( make_virtual_register( vinstr->operand.imm.u, 4 ) );
} };
} // namespace vm::lifters

@ -4,6 +4,6 @@ namespace vm::lifters
{
vm::lifters::lifter_t lvsp = {
// vsp = vsp[0]
vm::handler::LVSP,
[]( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) { blk->pop( vtil::REG_SP ); } };
vm::handler::LVSP, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr,
vmp2::v3::code_block_t *code_blk ) { blk->pop( vtil::REG_SP ); } };
}

@ -10,7 +10,8 @@ namespace vm::lifters
// and vregX, vregY
// push vregX
// pushf
vm::handler::NANDQ, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) {
vm::handler::NANDQ,
[]( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr, vmp2::v3::code_block_t *code_blk ) {
auto [ t1, t2 ] = blk->tmp( 64, 64 );
blk->pop( t1 );
blk->pop( t2 );
@ -31,7 +32,8 @@ namespace vm::lifters
// and vregX, vregY
// push vregX
// pushf
vm::handler::NANDDW, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) {
vm::handler::NANDDW,
[]( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr, vmp2::v3::code_block_t *code_blk ) {
auto [ t1, t2 ] = blk->tmp( 32, 32 );
blk->pop( t1 );
blk->pop( t2 );
@ -52,7 +54,8 @@ namespace vm::lifters
// and vregX, vregY
// push vregX
// pushf
vm::handler::NANDW, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) {
vm::handler::NANDW,
[]( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr, vmp2::v3::code_block_t *code_blk ) {
auto [ t1, t2 ] = blk->tmp( 16, 16 );
blk->pop( t1 );
blk->pop( t2 );

@ -4,6 +4,6 @@ namespace vm::lifters
{
vm::lifters::lifter_t pushvsp = {
// push vsp
vm::handler::PUSHVSP,
[]( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) { blk->push( vtil::REG_SP ); } };
vm::handler::PUSHVSP, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr,
vmp2::v3::code_block_t *code_blk ) { blk->push( vtil::REG_SP ); } };
}

@ -6,7 +6,8 @@ namespace vm::lifters
// pop vregX
// ldd vregX, vregX, 0
// push vregX
vm::handler::READQ, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) {
vm::handler::READQ,
[]( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr, vmp2::v3::code_block_t *code_blk ) {
auto [ t0, t1 ] = blk->tmp( 64, 64 );
blk->pop( t0 );
blk->ldd( t1, t0, vtil::make_imm( 0ull ) );
@ -17,7 +18,8 @@ namespace vm::lifters
// pop vregX
// ldd vregX, vregX, 0
// push vregX
vm::handler::READDW, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) {
vm::handler::READDW,
[]( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr, vmp2::v3::code_block_t *code_blk ) {
auto [ t0, t1 ] = blk->tmp( 64, 32 );
blk->pop( t0 );
blk->ldd( t1, t0, vtil::make_imm( 0ull ) );
@ -28,7 +30,8 @@ namespace vm::lifters
// pop vregX
// ldd vregX, vregX, 0
// push vregX
vm::handler::READW, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) {
vm::handler::READW,
[]( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr, vmp2::v3::code_block_t *code_blk ) {
auto [ t0, t1 ] = blk->tmp( 64, 16 );
blk->pop( t0 );
blk->ldd( t1, t0, vtil::make_imm( 0ull ) );

@ -8,7 +8,8 @@ namespace vm::lifters
// shr vregX, vregY
// push vregX
// pushf
vm::handler::SHRQ, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) {
vm::handler::SHRQ,
[]( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr, vmp2::v3::code_block_t *code_blk ) {
auto [ t0, t1 ] = blk->tmp( 64, 8 );
blk->pop( t0 );
blk->pop( t1 );
@ -23,7 +24,8 @@ namespace vm::lifters
// shr vregX, vregY
// push vregX
// pushf
vm::handler::SHRW, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) {
vm::handler::SHRW,
[]( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr, vmp2::v3::code_block_t *code_blk ) {
auto [ t0, t1 ] = blk->tmp( 16, 8 );
blk->pop( t0 );
blk->pop( t1 );

@ -4,19 +4,22 @@ namespace vm::lifters
{
vm::lifters::lifter_t sregq = {
// pop vregX
vm::handler::SREGQ, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) {
vm::handler::SREGQ,
[]( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr, vmp2::v3::code_block_t *code_blk ) {
blk->pop( make_virtual_register( vinstr->operand.imm.u, 8 ) );
} };
vm::lifters::lifter_t sregdw = {
// pop vregX
vm::handler::SREGDW, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) {
vm::handler::SREGDW,
[]( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr, vmp2::v3::code_block_t *code_blk ) {
blk->pop( make_virtual_register( vinstr->operand.imm.u, 4 ) );
} };
vm::lifters::lifter_t sregw = {
// pop vregX
vm::handler::SREGW, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) {
vm::handler::SREGW,
[]( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr, vmp2::v3::code_block_t *code_blk ) {
blk->pop( make_virtual_register( vinstr->operand.imm.u, 2 ) );
} };
} // namespace vm::lifters

@ -4,7 +4,8 @@ namespace vm::lifters
{
vm::lifters::lifter_t vmexit = {
// ret
vm::handler::VMEXIT, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) {
vm::handler::VMEXIT,
[]( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr, vmp2::v3::code_block_t *code_blk ) {
blk->vexit( vtil::make_imm( vinstr->trace_data.vsp.qword[ 0x13 ] - vinstr->trace_data.regs.r13 ) );
} };
}
Loading…
Cancel
Save