diff --git a/include/vmlifters.hpp b/include/vmlifters.hpp index 6da70cc..029f4f5 100644 --- a/include/vmlifters.hpp +++ b/include/vmlifters.hpp @@ -22,7 +22,10 @@ namespace vm::lifters 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 readq, readdw, readw; + extern vm::lifters::lifter_t shrq, shrw; extern vm::lifters::lifter_t vmexit; + extern vm::lifters::lifter_t pushvsp; inline std::map< vm::handler::mnemonic_t, lifter_callback_t > all = { // lreg lifters... @@ -40,6 +43,15 @@ namespace vm::lifters // nand lifters... nandq, nanddw, nandw, + // read lifters.... + readq, readdw, readw, + + // shr lifters... + shrq, shrw, + + // pushvsp lifter... + pushvsp, + // vmexit lifter... vmexit }; } // namespace vm::lifters \ No newline at end of file diff --git a/src/vmlifters/pushvsp.cpp b/src/vmlifters/pushvsp.cpp new file mode 100644 index 0000000..566a430 --- /dev/null +++ b/src/vmlifters/pushvsp.cpp @@ -0,0 +1,9 @@ +#include + +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 ); } }; +} \ No newline at end of file diff --git a/src/vmlifters/read.cpp b/src/vmlifters/read.cpp new file mode 100644 index 0000000..db3420e --- /dev/null +++ b/src/vmlifters/read.cpp @@ -0,0 +1,37 @@ +#include + +namespace vm::lifters +{ + vm::lifters::lifter_t readq = { + // pop vregX + // ldd vregX, vregX, 0 + // push vregX + vm::handler::READQ, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) { + auto t0 = blk->tmp( 64 ); + blk->pop( t0 ); + blk->ldd( t0, t0, 0 ); + blk->push( t0 ); + } }; + + vm::lifters::lifter_t readdw = { + // pop vregX + // ldd vregX, vregX, 0 + // push vregX + vm::handler::READDW, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) { + auto t0 = blk->tmp( 32 ); + blk->pop( t0 ); + blk->ldd( t0, t0, 0 ); + blk->push( t0 ); + } }; + + vm::lifters::lifter_t readw = { + // pop vregX + // ldd vregX, vregX, 0 + // push vregX + vm::handler::READW, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) { + auto t0 = blk->tmp( 16 ); + blk->pop( t0 ); + blk->ldd( t0, t0, 0 ); + blk->push( t0 ); + } }; +} // namespace vm::lifters \ No newline at end of file diff --git a/src/vmlifters/shr.cpp b/src/vmlifters/shr.cpp new file mode 100644 index 0000000..8e88e17 --- /dev/null +++ b/src/vmlifters/shr.cpp @@ -0,0 +1,34 @@ +#include + +namespace vm::lifters +{ + vm::lifters::lifter_t shrq = { + // pop vregX + // pop vregY + // shr vregX, vregY + // push vregX + // pushf + vm::handler::SHRQ, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) { + auto [ t0, t1 ] = blk->tmp( 64, 8 ); + blk->pop( t0 ); + blk->pop( t1 ); + blk->bshr( t0, t1 ); + blk->push( t0 ); + blk->pushf(); + } }; + + vm::lifters::lifter_t shrw = { + // pop vregX + // pop vregY + // shr vregX, vregY + // push vregX + // pushf + vm::handler::SHRW, []( vtil::basic_block *blk, vm::instrs::virt_instr_t *vinstr ) { + auto [ t0, t1 ] = blk->tmp( 16, 8 ); + blk->pop( t0 ); + blk->pop( t1 ); + blk->bshr( t0, t1 ); + blk->push( t0 ); + blk->pushf(); + } }; +} // namespace vm::lifters \ No newline at end of file diff --git a/vmprofiler.vcxproj b/vmprofiler.vcxproj index 9cacdad..dd0c3c4 100644 --- a/vmprofiler.vcxproj +++ b/vmprofiler.vcxproj @@ -171,6 +171,9 @@ + + + diff --git a/vmprofiler.vcxproj.filters b/vmprofiler.vcxproj.filters index 49e7c3a..242966a 100644 --- a/vmprofiler.vcxproj.filters +++ b/vmprofiler.vcxproj.filters @@ -276,5 +276,14 @@ Source Files\vmlifters + + Source Files\vmlifters + + + Source Files\vmlifters + + + Source Files\vmlifters + \ No newline at end of file