[0.3.x] added : disasm::opcode method ( returm current disassembled instruction )

[0.3.x] added : disasm::opmnemo method ( return mnemocode of the instruction )

git-svn-id: https://pykd.svn.codeplex.com/svn@89568 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\ussrhero_cp 2015-01-04 23:13:57 +00:00 committed by Mikhail I. Izmestev
parent c89fc1f823
commit 8d92470b1d
4 changed files with 75 additions and 13 deletions

View File

@ -3,6 +3,7 @@
#include "kdlib/disasm.h"
#include "pythreadstate.h"
#include "stladaptor.h"
namespace pykd {
@ -65,6 +66,24 @@ public:
return disasm.instruction();
}
static python::list opcode(kdlib::Disasm& disasm)
{
std::vector<unsigned char> lst;
do {
AutoRestorePyState pystate;
lst = disasm.opcode();
} while (false);
return vectorToList(lst);
}
static std::wstring opmnemo(kdlib::Disasm& disasm)
{
AutoRestorePyState pystate;
return disasm.opmnemo();
}
static kdlib::MEMOFFSET_64 begin( kdlib::Disasm& disasm )
{
AutoRestorePyState pystate;

View File

@ -126,7 +126,7 @@
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<PostBuildEvent>
<Command>copy $(ProjectDir)..\Debug\targetapp.exe $(OutDir)targetapp.exe</Command>
<Command>copy $(ProjectDir)..\x64\Debug\targetapp.exe $(OutDir)targetapp.exe</Command>
</PostBuildEvent>
<CustomBuildStep>
<Command>

View File

@ -212,6 +212,33 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\boost_thread.tss_null.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\boost_system.error_code.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\gregorian\boost_date_time.gregorian.date_generators.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\gregorian\boost_date_time.gregorian.gregorian_types.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\gregorian\boost_date_time.gregorian.greg_month.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\gregorian\boost_date_time.gregorian.greg_weekday.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\posix_time\boost_date_time.posix_time.posix_time_types.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\boost_chrono.chrono.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\boost_chrono.process_cpu_clocks.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\boost_chrono.thread_clock.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="pykd.def">

View File

@ -809,18 +809,34 @@ BOOST_PYTHON_MODULE( pykd )
python::class_<kdlib::Disasm>("disasm", "Class disassemble a processor instructions",python::no_init)
.def( "__init__", python::make_constructor(pykd::loadDisasm ) )
.def( "__init__", python::make_constructor(pykd::loadDisasmWithOffset ) )
.def( "disasm", DisasmAdapter::disassemble, "Disassemble next instruction" )
.def( "disasm", DisasmAdapter::jump, "Disassemble from the specified offset" )
.def( "asm", DisasmAdapter::assembly, "Insert assemblied instuction to current offset" )
.def( "begin", DisasmAdapter::begin, "Return begin offset" )
.def( "current", DisasmAdapter::current, "Return current offset" )
.def( "length", DisasmAdapter::length, "Return current instruction length" )
.def( "instruction", DisasmAdapter::instruction, "Returm current disassembled instruction" )
.def( "ea", DisasmAdapter::ea, "Return effective address for last disassembled instruction or 0" )
.def( "reset", DisasmAdapter::reset, "Reset current offset to begin" )
.def( "findOffset", DisasmAdapter::getNearInstruction, "Return the location of a processor instruction relative to a given location" )
.def( "jump",DisasmAdapter::jump, "Change the current instruction" )
.def( "jumprel", DisasmAdapter::jumprel, "Change the current instruction" )
.def( "disasm", DisasmAdapter::disassemble,
"Disassemble next instruction" )
.def( "disasm", DisasmAdapter::jump,
"Disassemble from the specified offset" )
.def( "asm", DisasmAdapter::assembly,
"Insert assemblied instuction to current offset" )
.def( "begin", DisasmAdapter::begin,
"Return begin offset" )
.def( "current", DisasmAdapter::current,
"Return current offset" )
.def( "length", DisasmAdapter::length,
"Return current instruction length" )
.def( "instruction", DisasmAdapter::instruction,
"Returm current disassembled instruction" )
.def("opcode", DisasmAdapter::opcode,
"Return list of bytes of the instruction opcode" )
.def("opmnemo", DisasmAdapter::opmnemo,
"Return mnemocode of the instruction")
.def( "ea", DisasmAdapter::ea,
"Return effective address for last disassembled instruction or 0" )
.def( "reset", DisasmAdapter::reset,
"Reset current offset to begin" )
.def( "findOffset", DisasmAdapter::getNearInstruction,
"Return the location of a processor instruction relative to a given location" )
.def( "jump",DisasmAdapter::jump,
"Change the current instruction" )
.def( "jumprel", DisasmAdapter::jumprel,
"Change the current instruction" )
.def( "__str__", DisasmAdapter::instruction );