diff --git a/include/vmlifters.hpp b/include/vmlifters.hpp index feedcdf..6da70cc 100644 --- a/include/vmlifters.hpp +++ b/include/vmlifters.hpp @@ -19,7 +19,9 @@ namespace vm::lifters extern vm::lifters::lifter_t lregq, lregdw; extern vm::lifters::lifter_t addq, adddw, addw; extern vm::lifters::lifter_t sregq, sregdw, sregw; - extern vm::lifters::lifter_t lconstq, lconstdw, lconstw; + extern vm::lifters::lifter_t lconstq, lconstdw, lconstw, lconstbzxw, lconstbsxdw, lconstbsxq, lconstdwsxq, + lconstwsxq, lconstwsxdw; + extern vm::lifters::lifter_t nandq, nanddw, nandw; extern vm::lifters::lifter_t vmexit; inline std::map< vm::handler::mnemonic_t, lifter_callback_t > all = { @@ -33,7 +35,10 @@ namespace vm::lifters sregq, sregdw, sregw, // lconst lifters... - lconstq, lconstdw, lconstw, + lconstq, lconstdw, lconstw, lconstbzxw, lconstbsxdw, lconstbsxq, lconstdwsxq, lconstwsxq, lconstwsxdw, + + // nand lifters... + nandq, nanddw, nandw, // vmexit lifter... vmexit }; diff --git a/src/vmlifters/lconst.cpp b/src/vmlifters/lconst.cpp index a9e54c8..2b246e3 100644 --- a/src/vmlifters/lconst.cpp +++ b/src/vmlifters/lconst.cpp @@ -19,4 +19,40 @@ namespace vm::lifters vm::handler::LCONSTW, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) { blk->push( vtil::operand( vinstr->operand.imm.u, 16 ) ); } }; + + vm::lifters::lifter_t lconstbzxw = { + // push imm + vm::handler::LCONSTBZXW, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) { + blk->push( vtil::operand( vinstr->operand.imm.u, 16 ) ); + } }; + + vm::lifters::lifter_t lconstbsxdw = { + // push imm + vm::handler::LCONSTBSXDW, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) { + blk->push( vtil::operand( vinstr->operand.imm.u, 32 ) ); + } }; + + vm::lifters::lifter_t lconstbsxq = { + // push imm + vm::handler::LCONSTBSXQ, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) { + blk->push( vtil::operand( vinstr->operand.imm.u, 64 ) ); + } }; + + vm::lifters::lifter_t lconstdwsxq = { + // push imm + vm::handler::LCONSTDWSXQ, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) { + blk->push( vtil::operand( vinstr->operand.imm.u, 64 ) ); + } }; + + vm::lifters::lifter_t lconstwsxq = { + // push imm + vm::handler::LCONSTWSXQ, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) { + blk->push( vtil::operand( vinstr->operand.imm.u, 64 ) ); + } }; + + vm::lifters::lifter_t lconstwsxdw = { + // push imm + vm::handler::LCONSTWSXDW, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) { + blk->push( vtil::operand( vinstr->operand.imm.u, 32 ) ); + } }; } // namespace vm::lifters \ No newline at end of file diff --git a/src/vmlifters/nand.cpp b/src/vmlifters/nand.cpp new file mode 100644 index 0000000..141c8f4 --- /dev/null +++ b/src/vmlifters/nand.cpp @@ -0,0 +1,67 @@ +#include + +namespace vm::lifters +{ + vm::lifters::lifter_t nandq = { + // pop vregX + // pop vregY + // not vregX + // not vregY + // and vregX, vregY + // push vregX + // pushf + vm::handler::NANDQ, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) { + auto [ t1, t2 ] = blk->tmp( 64, 64 ); + blk->pop( t1 ); + blk->pop( t2 ); + + blk->bnot( t1 ); + blk->bnot( t2 ); + + blk->band( t1, t2 ); + blk->push( t1 ); + blk->pushf(); + } }; + + vm::lifters::lifter_t nanddw = { + // pop vregX + // pop vregY + // not vregX + // not vregY + // and vregX, vregY + // push vregX + // pushf + vm::handler::NANDDW, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) { + auto [ t1, t2 ] = blk->tmp( 32, 32 ); + blk->pop( t1 ); + blk->pop( t2 ); + + blk->bnot( t1 ); + blk->bnot( t2 ); + + blk->band( t1, t2 ); + blk->push( t1 ); + blk->pushf(); + } }; + + vm::lifters::lifter_t nandw = { + // pop vregX + // pop vregY + // not vregX + // not vregY + // and vregX, vregY + // push vregX + // pushf + vm::handler::NANDW, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) { + auto [ t1, t2 ] = blk->tmp( 16, 16 ); + blk->pop( t1 ); + blk->pop( t2 ); + + blk->bnot( t1 ); + blk->bnot( t2 ); + + blk->band( t1, t2 ); + blk->push( t1 ); + blk->pushf(); + } }; +} // namespace vm::lifters \ No newline at end of file diff --git a/vmprofiler.vcxproj b/vmprofiler.vcxproj index 510b98a..9cacdad 100644 --- a/vmprofiler.vcxproj +++ b/vmprofiler.vcxproj @@ -170,6 +170,7 @@ + diff --git a/vmprofiler.vcxproj.filters b/vmprofiler.vcxproj.filters index 7c4ef1d..49e7c3a 100644 --- a/vmprofiler.vcxproj.filters +++ b/vmprofiler.vcxproj.filters @@ -273,5 +273,8 @@ Source Files\vmlifters + + Source Files\vmlifters + \ No newline at end of file