Commit c36dafa3 authored by ussrhero's avatar ussrhero
Browse files

Merge branch 'm417z/pykd-patch-1' into 0.3.2

parents d8f99d73 cccc1103
#include "stdafx.h"
#include <boost/bind.hpp>
#include "pykdver.h"
#include "variant.h"
#include "dbgexcept.h"
#include "windbgext.h"
#include "pydbgeng.h"
#include "pydbgio.h"
#include "pydisasm.h"
#include "pyevents.h"
#include "pyeventhandler.h"
#include "pymemaccess.h"
#include "pymodule.h"
#include "pysymengine.h"
#include "pytypedvar.h"
#include "pytypeinfo.h"
#include "pycpucontext.h"
#include "pyprocess.h"
#include "pytagged.h"
using namespace pykd;
///////////////////////////////////////////////////////////////////////////////
static const std::string pykdVersion = PYKD_VERSION_BUILD_STR
#ifdef _DEBUG
" <DBG>"
#endif // _DEBUG
;
///////////////////////////////////////////////////////////////////////////////
BOOST_PYTHON_FUNCTION_OVERLOADS( startProcess_, pykd::startProcess, 1, 2 );
BOOST_PYTHON_FUNCTION_OVERLOADS( attachProcess_, pykd::attachProcess, 1, 2);
BOOST_PYTHON_FUNCTION_OVERLOADS( detachProcess_, pykd::detachProcess, 0, 1 );
BOOST_PYTHON_FUNCTION_OVERLOADS( terminateProcess_, pykd::terminateProcess, 0, 1 );
BOOST_PYTHON_FUNCTION_OVERLOADS(closeDump_, pykd::closeDump, 0, 1);
BOOST_PYTHON_FUNCTION_OVERLOADS( attachKernel_, pykd::attachKernel, 0, 1 );
BOOST_PYTHON_FUNCTION_OVERLOADS( evaluate_, pykd::evaluate, 1, 2 );
BOOST_PYTHON_FUNCTION_OVERLOADS( debugCommand_, pykd::debugCommand, 1, 2 );
BOOST_PYTHON_FUNCTION_OVERLOADS( dprint_, pykd::dprint, 1, 2 );
BOOST_PYTHON_FUNCTION_OVERLOADS( dprintln_, pykd::dprintln, 1, 2 );
//BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS( Module_findSymbol, Module::getSymbolNameByVa, 1, 2 );
BOOST_PYTHON_FUNCTION_OVERLOADS( loadChars_, pykd::loadChars, 2, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( loadWChars_, pykd::loadWChars, 2, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( loadBytes_, pykd::loadBytes, 2, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( loadWords_, pykd::loadWords, 2, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( loadDWords_, pykd::loadDWords, 2, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( loadQWords_, pykd::loadQWords, 2, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( loadSignBytes_, pykd::loadSignBytes, 2, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( loadSignWords_, pykd::loadSignWords, 2, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( loadSignDWords_, pykd::loadSignDWords, 2, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( loadSignQWords_, pykd::loadSignQWords, 2, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( loadFloats_, pykd::loadFloats, 2, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( loadDoubles_, pykd::loadDoubles, 2, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( compareMemory_, pykd::compareMemory, 3, 4 );
BOOST_PYTHON_FUNCTION_OVERLOADS( writeBytes_, pykd::writeBytes, 2, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( writeWords_, pykd::writeWords, 2, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( writeDWords_, pykd::writeDWords, 2, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( writeQWords_, pykd::writeQWords, 2, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( writeSignBytes_, pykd::writeSignBytes, 2, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( writeSignWords_, pykd::writeSignWords, 2, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( writeSignDWords_, pykd::writeSignDWords, 2, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( writeSignQWords_, pykd::writeSignQWords, 2, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( writeFloats_, pykd::writeFloats, 2, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( writeDoubles_, pykd::writeDoubles, 2, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( getSourceFile_, pykd::getSourceFile, 0, 1 );
BOOST_PYTHON_FUNCTION_OVERLOADS( getSourceFileFromSrcSrv_, pykd::getSourceFileFromSrcSrv, 0, 1 );
BOOST_PYTHON_FUNCTION_OVERLOADS( getSourceLine_, pykd::getSourceLine, 0, 1 );
BOOST_PYTHON_FUNCTION_OVERLOADS( findSymbol_, pykd::findSymbol, 1, 2 );
BOOST_PYTHON_FUNCTION_OVERLOADS( getStack_, pykd::getStack, 0, 1);
BOOST_PYTHON_FUNCTION_OVERLOADS( getProcessOffset_, pykd::getProcessOffset, 0, 1);
BOOST_PYTHON_FUNCTION_OVERLOADS( getProcessSystemId_, pykd::getProcessSystemId, 0, 1);
BOOST_PYTHON_FUNCTION_OVERLOADS( getProcessExecutableName_, pykd::getProcessExecutableName, 0, 1);
BOOST_PYTHON_FUNCTION_OVERLOADS( getThreadOffset_, pykd::getThreadOffset, 0, 1);
BOOST_PYTHON_FUNCTION_OVERLOADS( getThreadSystemId_, pykd::getThreadSystemId, 0, 1);
BOOST_PYTHON_FUNCTION_OVERLOADS( getThreadIdBySystemId_, pykd::getThreadIdBySystemId, 0, 1);
BOOST_PYTHON_FUNCTION_OVERLOADS( createStruct_, pykd::defineStruct, 1, 2 );
BOOST_PYTHON_FUNCTION_OVERLOADS( createUnion_, pykd::defineUnion, 1, 2 );
BOOST_PYTHON_FUNCTION_OVERLOADS( defineFunction_, pykd::defineFunction, 1, 2 );
BOOST_PYTHON_FUNCTION_OVERLOADS( setSoftwareBreakpoint_, Breakpoint::setSoftwareBreakpoint, 1, 2 );
BOOST_PYTHON_FUNCTION_OVERLOADS( setHardwareBreakpoint_, Breakpoint::setHardwareBreakpoint, 3, 4 );
BOOST_PYTHON_FUNCTION_OVERLOADS( TargetHeap_getEntries, TargetHeapAdapter::getEntries, 1, 4);
BOOST_PYTHON_FUNCTION_OVERLOADS( Module_enumSymbols, ModuleAdapter::enumSymbols, 1, 2 );
BOOST_PYTHON_FUNCTION_OVERLOADS( Module_findSymbol, ModuleAdapter::findSymbol, 2, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( Module_enumTypes, ModuleAdapter::enumTypes, 1, 2 );
BOOST_PYTHON_FUNCTION_OVERLOADS( TypeInfo_ptrTo, TypeInfoAdapter::ptrTo, 1, 2 );
BOOST_PYTHON_FUNCTION_OVERLOADS( getTypeFromSource_, pykd::getTypeFromSource, 2, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( getTypeInfoProviderFromPdb_, pykd::getTypeInfoProviderFromPdb, 1, 2 );
BOOST_PYTHON_FUNCTION_OVERLOADS( getTypeInfoProviderFromSource_, pykd::getTypeInfoProviderFromSource, 1, 2);
BOOST_PYTHON_FUNCTION_OVERLOADS( getSymbolProviderFromSource_, pykd::getSymbolProviderFromSource, 1, 2);
BOOST_PYTHON_FUNCTION_OVERLOADS(evalExpr_, pykd::evalExpr, 1, 3);
BOOST_PYTHON_FUNCTION_OVERLOADS( addSyntheticModule_, pykd::addSyntheticModule, 3, 4 );
namespace pykd {
void initialize()
{
AutoRestorePyState pystate;
kdlib::initialize();
}
void remote_initialize( const std::wstring& remoteOptions )
{
AutoRestorePyState pystate;
kdlib::remote_initialize(remoteOptions);
}
void uninitialize()
{
AutoRestorePyState pystate;
kdlib::uninitialize();
}
}
void pykd_init()
{
python::scope().attr("__version__") = pykdVersion;
python::scope().attr("version") = pykdVersion;
python::def( "initialize", pykd::initialize,
"Initialize local debug engine, only for console mode" );
python::def( "remoteConnect",pykd::remote_initialize,
"Initialize debug engine for remoting, only for console mode" );
python::def( "deinitialize", pykd::uninitialize,
"Deintialize debug engine, only for console mode" );
// DbgEng services
python::def( "setSymSrvDir", pykd::setSymSrvDir,
"Set directory of SYMSRV.dll library.\nUsually this is a directory of WinDbg");
python::def( "getExtensionSearchPath", pykd::getExtensionSearchPath,
"Return the extension DLL search path" );
python::def( "loadExt", pykd::loadExtension,
"Load a WinDBG extension. Return handle of the loaded extension" );
python::def( "removeExt", (void(*)(kdlib::EXTENSION_ID))&pykd::removeExtension,
"Unload a WinDBG extension. Parameter: handle returned by loadExt" );
python::def( "removeExt", (void (*)(const std::wstring& ))&pykd::removeExtension,
"Unload a WinDBG extension. Parameter: extension path" );
python::def( "callExt", pykd::callExtension,
"Call a WinDBG extension's routine. Parameters: handle returned by loadExt; string command line" );
// Manage debug target
python::def( "startProcess", pykd::startProcess, startProcess_( boost::python::args( "commandline", "debugOptions"),
"Start process for debugging" ) );
python::def("attachProcess", pykd::attachProcess, attachProcess_(boost::python::args("pid", "debugOptions"),
"Attach debugger to a exsisting process"));
python::def( "detachProcess", pykd::detachProcess, detachProcess_( boost::python::args( "id" ),
"Stop process debugging") );
python::def( "detachAllProcesses", pykd::detachAllProcesses,
"Detach from all process and resume all their threads" );
python::def( "killProcess", pykd::terminateProcess, terminateProcess_( boost::python::args( "id" ),
"Stop debugging and terminate current process" ) );
python::def( "killAllProcesses", pykd::terminateAllProcesses,
"Detach from all process then terminate them");
python::def( "loadDump", pykd::loadDump,
"Load crash dump");
python::def("closeDump", pykd::closeDump, closeDump_(boost::python::args("id"),
"Close crash dump"));
python::def( "isLocalKernelDebuggerEnabled", pykd::isLocalKernelDebuggerEnabled,
"Check whether kernel debugging is enabled for the local kernel");
python::def( "attachKernel", pykd::attachKernel, attachKernel_( boost::python::args( "connectOptions" ),
"Connect the debugger engine to a kernel target.\n"
"If connectOptions is not specified - attach to the local kernel") );
python::def( "isDumpAnalyzing", pykd::isDumpAnalyzing,
"Check if it is a dump analyzing ( not living debuggee )" );
python::def( "isKernelDebugging", pykd::isKernelDebugging,
"Check if kernel dubugging is running" );
python::def( "isWindbgExt", pykd::isWindbgExt,
"Check if script works in windbg context" );
python::def( "writeDump", pykd::writeDump,
"Create memory dump file" );
python::def( "getLocalProcesses", pykd::getLocalProcesses,
"Return list of runnng processes on the host system" );
python::def("getHostProcessPath", pykd::getHostProcessPath,
"Return image path of the process running python interpreter with a pykd");
python::def( "getDebugOptions", pykd::getDebugOptions,
"Return debug options" );
python::def( "changeDebugOptions", pykd::changeDebugOptions,
"Change debug options" );
python::def("getOutputMask", pykd::getOutputMask,
"Get output mask");
python::def("setOutputMask", pykd::setOutputMask,
"Set output mask");
python::def( "breakin", pykd::targetBreak,
"Break into debugger" );
python::def( "expr", pykd::evaluate, evaluate_( python::args( "expression", "cplusplus" ),
"Evaluate windbg expression" ) );
python::def( "dbgCommand", &pykd::debugCommand,
debugCommand_( python::args( "command", "suppressOutput"), "Run a debugger's command and return it's result as a string" ) );
python::def( "go", pykd::targetGo,
"Go debugging" );
python::def( "step", pykd::targetStep,
"The target is executing a single instruction or--if that instruction is a subroutine call--subroutine" );
python::def( "trace", pykd::targetStepIn,
"The target is executing a single instruction" );
python::def("stepout", pykd::targetStepOut,
"The traget is executing while not returned from the current subroutine");
python::def("sourceStep", pykd::sourceStep,
"The target is executing a single source line");
python::def("sourceStepOver", pykd::sourceStepOver,
"The target is executing a single source line");
python::def( "getExecutionStatus", pykd::targetExecutionStatus,
"Return current execution status" );
// Debug output
python::def( "dprint", &pykd::dprint, dprint_( python::args( "str", "dml" ),
"Print out string. If dml = True string is printed with dml highlighting ( only for windbg )" ) );
python::def( "dprintln", &pykd::dprintln, dprintln_( python::args( "str", "dml" ),
"Print out string and insert end of line symbol. If dml = True string is printed with dml highlighting ( only for windbg )" ) );
python::def("dinput", &pykd::dinput,
"Provide input for debugger");
python::def("setStatusMessage", &pykd::setStatusMessage,
"Set message at a windbg status bar");
// Python debug output console helper classes
python::class_<DbgOut>( "dout", "dout", python::no_init )
.def( "write", &DbgOut::write )
.def( "writedml", &DbgOut::writedml )
.def( "flush", &DbgOut::flush )
.def( "isatty", &DbgOut::isatty )
.add_property( "encoding", &DbgOut::encoding )
.add_property( "closed", &DbgOut::closed );
python::class_<DbgIn>( "din", "din", python::no_init )
.def( "readline", &DbgIn::readline )
.add_property( "encoding", &DbgIn::encoding )
.add_property("closed", &DbgIn::closed );
// system properties
python::def( "ptrSize", pykd::ptrSize,
"Return effective pointer size" );
python::def( "is64bitSystem", pykd::is64bitSystem,
"Check if target system has 64 address space" );
python::def( "pageSize", pykd::getPageSize,
"Get the page size for the currently executing processor context" );
python::def( "systemUptime", pykd::getSystemUptime,
"Return the number of seconds the computer has been running" );
python::def( "currentTime", pykd::getCurrentTime,
"Return the number of seconds since the beginning of 1970" );
python::def("getSystemVersion", pykd::getSystemVersion,
"Return systemVersion");
python::def( "bugCheckData", pykd::getBugCheckData,
"Function reads the kernel bug check code and related parameters\n"
"And return tuple: (code, arg1, arg2, arg3, arg4)" );
// Manage target memory access
python::def( "addr64", pykd::addr64,
"Extend address to 64 bits formats" );
python::def( "isValid", pykd::isVaValid,
"Check if the virtual address is valid" );
python::def("isVaRegionValid", pykd::isVaRegionValid,
"Check if the virtaul addresses region is valid");
python::def( "compareMemory", pykd::compareMemory, compareMemory_( python::args( "offset1", "offset2", "length", "phyAddr" ),
"Compare two memory buffers by virtual or physical addresses" ) );
python::def( "searchMemory", pykd::searchMemoryLst,
"Search in virtual memory" );
python::def( "searchMemory", pykd::searchMemoryStr,
"Search in virtual memory" );
python::def( "findMemoryRegion", pykd::findMemoryRegion,
"Return address of begining valid memory region nearest to offset" );
python::def( "getVaProtect", pykd::getVaProtect,
"Return memory protect" );
python::def( "getVaType", pykd::getVaType,
"Return memory type");
python::def( "getVaState", pykd::getVaProtect,
"Return memory state");
python::def("getVaAttributes", pykd::getVaAttributes,
"Return memory attributes");
python::def( "ptrByte", pykd::ptrByte,
"Read an unsigned 1-byte integer from the target memory" );
python::def( "ptrWord", pykd::ptrWord,
"Read an unsigned 2-byte integer from the target memory" );
python::def( "ptrDWord", pykd::ptrDWord,
"Read an unsigned 4-byte integer from the target memory" );
python::def( "ptrQWord", pykd::ptrQWord,
"Read an unsigned 8-byte integer from the target memory" );
python::def( "ptrMWord", pykd::ptrMWord,
"Read an unsigned mashine's word wide integer from the target memory" );
python::def( "ptrSignByte", pykd::ptrSignByte,
"Read an signed 1-byte integer from the target memory" );
python::def( "ptrSignWord", pykd::ptrSignWord,
"Read an signed 2-byte integer from the target memory" );
python::def( "ptrSignDWord", pykd::ptrSignDWord,
"Read an signed 4-byte integer from the target memory" );
python::def( "ptrSignQWord", pykd::ptrSignQWord,
"Read an signed 8-byte integer from the target memory" );
python::def( "ptrSignMWord", pykd::ptrSignMWord,
"Read an signed mashine's word wide integer from the target memory" );
python::def( "ptrFloat", pykd::ptrSingleFloat,
"Read a float with single precision from the target memory" );
python::def( "ptrDouble", pykd::ptrDoubleFloat,
"Read a float with single precision from the target memory" );
python::def( "setByte", pykd::setByte,
"Write an unsigned 1-byte integer to the target memory" );
python::def( "setWord", pykd::setWord,
"Write an unsigned 2-byte integer to the target memory" );
python::def( "setDWord", pykd::setDWord,
"Write an unsigned 4-byte integer to the target memory" );
python::def( "setQWord", pykd::setQWord,
"Write an unsigned 8-byte integer to the target memory" );
python::def( "setSignByte", pykd::setSignByte,
"Write an signed 1-byte integer to the target memory" );
python::def( "setSignWord", pykd::setSignWord,
"Write an signed 2-byte integer to the target memory" );
python::def( "setSignDWord", pykd::setSignDWord,
"Write an signed 4-byte integer to the target memory" );
python::def( "setSignQWord", pykd::setSignQWord,
"Write an signed 8-byte integer to the target memory" );
python::def( "setFloat", pykd::setSingleFloat,
"Write a float with single precision to the target memory" );
python::def( "setDouble", pykd::setDoubleFloat,
"Write a float with single precision to the target memory" );
python::def( "loadBytes", pykd::loadBytes, loadBytes_( python::args( "offset", "count", "phyAddr" ),
"Read the block of the target's memory and return it as list of unsigned bytes" ) );
python::def( "loadWords", pykd::loadWords, loadWords_( python::args( "offset", "count", "phyAddr" ),
"Read the block of the target's memory and return it as list of unsigned shorts" ) );
python::def( "loadDWords", pykd::loadDWords, loadDWords_( python::args( "offset", "count", "phyAddr" ),
"Read the block of the target's memory and return it as list of unsigned long ( double word )" ) );
python::def( "loadQWords", pykd::loadQWords, loadQWords_( python::args( "offset", "count", "phyAddr" ),
"Read the block of the target's memory and return it as list of unsigned long long ( quad word )" ) );
python::def( "loadSignBytes", pykd::loadSignBytes, loadSignBytes_( python::args( "offset", "count", "phyAddr" ),
"Read the block of the target's memory and return it as list of signed bytes" ) );
python::def( "loadSignWords", pykd::loadSignWords, loadSignWords_( python::args( "offset", "count", "phyAddr" ),
"Read the block of the target's memory and return it as list of signed words" ) );
python::def( "loadSignDWords", pykd::loadSignDWords, loadSignDWords_( python::args( "offset", "count", "phyAddr" ),
"Read the block of the target's memory and return it as list of signed longs" ) );
python::def( "loadSignQWords", pykd::loadSignQWords, loadSignQWords_( python::args( "offset", "count", "phyAddr" ),
"Read the block of the target's memory and return it as list of signed long longs" ) );
python::def( "loadChars", pykd::loadChars, loadChars_( python::args( "address", "count", "phyAddr" ),
"Load string from target memory" ) );
python::def( "loadWChars", pykd::loadWChars, loadWChars_( python::args( "address", "count", "phyAddr" ),
"Load string from target memory" ) );
python::def( "loadCStr", pykd::loadCStr,
"Load string from the target buffer containing 0-terminated ansi-string" );
python::def( "loadWStr", pykd::loadWStr,
"Load string from the target buffer containing 0-terminated unicode-string" );
python::def( "loadUnicodeString", pykd::loadUnicodeStr,
"Return string represention of windows UNICODE_STRING type" );
python::def( "loadAnsiString", pykd::loadAnsiStr,
"Return string represention of windows ANSI_STRING type" );
python::def( "loadFloats", pykd::loadFloats, loadFloats_( python::args( "offset", "count", "phyAddr" ),
"Read the block of the target's memory and return it as list of floats" ) );
python::def( "loadDoubles", pykd::loadDoubles, loadDoubles_( python::args( "offset", "count", "phyAddr" ),
"Read the block of the target's memory and return it as list of doubles" ) );
python::def( "writeBytes", pykd::writeBytes, writeBytes_( python::args( "offset", "values", "phyAddr" ),
"Writing a list of unsigned bytes to the target's memory" ) );
python::def( "writeWords", pykd::writeWords, writeWords_( python::args( "offset", "values", "phyAddr" ),
"Writing a list of unsigned shorts to the target's memory" ) );
python::def( "writeDWords", pykd::writeDWords, writeDWords_( python::args( "offset", "values", "phyAddr" ),
"Writing a list of unsigned long ( double word ) to the target's memory" ) );
python::def( "writeQWords", pykd::writeQWords, writeQWords_( python::args( "offset", "values", "phyAddr" ),
"Writing a list of unsigned long long ( quad word ) to the target's memory" ) );
python::def( "writeSignBytes", pykd::writeSignBytes, writeSignBytes_( python::args( "offset", "values", "phyAddr" ),
"Writing a list of signed bytes to the target's memory" ) );
python::def( "writeSignWords", pykd::writeSignWords, writeSignWords_( python::args( "offset", "count", "phyAddr" ),
"Writing a list of signed words to the target's memory" ) );
python::def( "writeSignDWords", pykd::writeSignDWords, writeSignDWords_( python::args( "offset", "values", "phyAddr" ),
"Writing a list of signed longs to the target's memory" ) );
python::def( "writeSignQWords", pykd::writeSignQWords, writeSignQWords_( python::args( "offset", "values", "phyAddr" ),
"Writing a list of signed long longs to the target's memory" ) );
python::def( "writeFloats", pykd::writeFloats, writeFloats_( python::args( "offset", "values", "phyAddr" ),
"Writing a list of floats to the target's memory" ) );
python::def( "writeDoubles", pykd::writeDoubles, writeDoubles_( python::args( "offset", "values", "phyAddr" ),
"Writing a list of doubles to the target's memory" ) );
python::def( "writeCStr", pykd::writeCStr,
"Write string as a 0 terminated ansi string to the buffer");
python::def( "writeWStr", pykd::writeWStr,
"Write string as a 0 terminated unicode string to the buffer");
python::def( "ptrPtr", pykd::ptrPtr,
"Read an pointer value from the target memory" );
python::def( "loadPtrList", pykd::loadPtrList,
"Return list of pointers, each points to next" );
python::def( "loadPtrs", pykd::loadPtrArray,
"Read the block of the target's memory and return it as a list of pointers" );
python::def( "setPtr", pykd::setPtr,
"Write an pointer value to the target memory" );
// types and vaiables
python::def( "getSourceFile", pykd::getSourceFile, getSourceFile_( python::args( "offset"),
"Return source file by the specified offset" ) );
python::def("getSourceFileFromSrcSrv", pykd::getSourceFileFromSrcSrv, getSourceFileFromSrcSrv_(python::args("offset"),
"Load and return source file from source server by the specified offset") );
python::def( "getSourceLine", pykd::getSourceLine, getSourceLine_( python::args( "offset"),
"Return source file name, line and displacement by the specified offset" ) );
python::def( "getOffset", pykd::getSymbolOffset,
"Return traget virtual address for specified symbol" );
python::def( "findSymbol", pykd::findSymbol, findSymbol_( python::args( "offset", "showDisplacement"),
"Find symbol by the target virtual memory offset" ) );
python::def("findSymbolAndDisp", pykd::findSymbolAndDisp,
"Return tuple (module_name, symbol_name, displacement) by virtual address" );
python::def( "sizeof", pykd::getSymbolSize,
"Return a size of the type or variable" );
python::def("typedVarList", pykd::getTypedVarListByTypeName,
"Return a list of the typedVar class instances. Each item represents an item of the linked list in the target memory" );
python::def("typedVarList", pykd::getTypedVarListByType,
"Return a list of the typedVar class instances. Each item represents an item of the linked list in the target memory" );
python::def("typedVarArray", pykd::getTypedVarArrayByTypeName,
"Return a list of the typedVar class instances. Each item represents an item of the counted array in the target memory" );
python::def("typedVarArray", pykd::getTypedVarArrayByType,
"Return a list of the typedVar class instances. Each item represents an item of the counted array in the target memory" );
python::def("containingRecord", pykd::containingRecordByName,
"Return instance of the typedVar class. It's value are loaded from the target memory."
"The start address is calculated by the same method as the standard macro CONTAINING_RECORD does" );
python::def("containingRecord", pykd::containingRecordByType,
"Return instance of the typedVar class. It's value are loaded from the target memory."
"The start address is calculated by the same method as the standard macro CONTAINING_RECORD does" );
python::def( "createStruct", &pykd::defineStruct, createStruct_( python::args( "name", "align" ),
"Create custom struct" ) );
python::def( "createUnion", &pykd::defineUnion, createUnion_( python::args( "name", "align" ),
"Create custom union" ) );
python::def( "defineFunction", &pykd::defineFunction, defineFunction_( python::args("returnType", "callconv"),
"Define custom function prototype" ) );
python::def( "callFunctionByPtr", python::raw_function(pykd::callFunctionByVar, 1) );
python::def( "callFunctionByAddr", python::raw_function(pykd::callFunctionByOffset, 2) );
python::def( "callFunctionRaw", python::raw_function(pykd::callFunctionRaw, 1) );
python::def( "getTypeFromSource", &pykd::getTypeFromSource, getTypeFromSource_( python::args("sourceCode", "typeName", "compileOptions"),
"Create typeInfo class from C/C++ source code") );
python::def( "getTypeInfoProviderFromSource", &pykd::getTypeInfoProviderFromSource, getTypeInfoProviderFromSource_( python::args("sourceCode", "compileOptions"),
"Create typeInfo provider from C/C++ source code") );
python::def( "getTypeInfoProviderFromPdb", &pykd::getTypeInfoProviderFromPdb, getTypeInfoProviderFromPdb_( python::args("filePath", "baseOffset"),
"Create typeInfo provider from pdb file") );
python::def("getSymbolProviderFromSource", &pykd::getSymbolProviderFromSource, getSymbolProviderFromSource_(python::args("sourceCode", "compileOptions"),
"Create symbol provider for source code"));
python::def("evalExpr", &pykd::evalExpr, evalExpr_(python::args("expression", "scope", "typeProvider"),
"Evaluate C++ expression with typed information"));
// CPU registers
python::def( "reg", pykd::getRegisterByName,
"Return a CPU regsiter value by the register's name" );
python::def( "reg", pykd::getRegisterByIndex,
"Return a CPU register value by the register's number");
python::def( "setReg", pykd::setRegisterByName,
"Set a CPU register value by its name" );
python::def( "setReg", pykd::setRegisterByIndex,
"Set a CPU register value by its index" );
python::def( "getNumberRegisters", pykd::getNumberRegisters,
"Return a number of CPU registers");
python::def( "getRegisterName", pykd::getRegisterName,
"Return register name by its index");
python::def("getIP", pykd::getIP,
"Return instruction pointer");
python::def("getSP", pykd::getSP,
"Return stack pointer");
python::def("getFP", pykd::getFP,
"Return frame pointer");
python::def("setIP", pykd::setIP,
"Change instruction pointer");
python::def("setSP", pykd::setSP,
"Change stack pointer");
python::def("setFP", pykd::setFP,
"Change frame pointer");
python::def ( "rdmsr", pykd::loadMSR,
"Return MSR value" );
python::def( "wrmsr", pykd::setMSR,
"Set MSR value" );
python::def( "getCPUMode", pykd::getProcessorMode,
"Return current processor mode: CPUType" );
python::def( "getCPUType", pykd::getProcessorType,
"Return type of physical processor: CPUType" );
python::def( "setCPUMode",pykd::setProcessorMode,
"Set current processor mode (CPUType)" );
python::def( "switchCPUMode", pykd::switchProcessorMode,
"Switch processor mode ( X86 <-> X64 )" );
// stack and local variables
python::def( "getStack", pykd::getStack, getStack_(python::args("inlineFrames"),
"Return a current stack as a list of stackFrame objects" ) );
python::def( "getFrame", pykd::getCurrentFrame,
"Return a current stack frame" );
python::def("getFrameNumber", pykd::getCurrentFrameNumber,
"Return current frame number");
python::def( "setFrame", pykd::setCurrentFrame,
"Change current local scope" );
python::def( "setFrame", pykd::setCurrentFrameByIndex,
"Change current local scope" );
python::def( "resetFrame", pykd::resetCurrentFrame,
"Resets the current local scope to the default scope of the current thread" );
python::def( "getLocals", pykd::getLocals,
"Get list of local variables" );
python::def( "getLocal", pykd::getLocal,
"Get the fucntion's local variable by name" );
python::def( "getParams", pykd::getParams,
"Get list of function arguments as list of tuple (name, value ) " );
python::def( "getParam", pykd::getParam,
"Get the function argument by name" );
python::def( "stackAlloc", pykd::stackAlloc,
"Allocate bytes of space in the stack in the target process" );
python::def( "stackFree", pykd::stackFree,
"Free space in the stack previously allocated by stackAlloc" );
python::def( "pushStack", pykd::pushStack,
"Push a value into a stack" );
python::def( "popStack", pykd::popStack,
"Pop a value from a stack" );
// breakpoints
python::def( "setBp", &Breakpoint::setSoftwareBreakpoint,
setSoftwareBreakpoint_( python::args( "offset", "callback" ),"Set software breakpoint on executiont" )[python::return_value_policy<python::manage_new_object>()]);
python::def( "setBp", &Breakpoint::setHardwareBreakpoint,
setHardwareBreakpoint_( python::args( "offset", "size", "accsessType", "callback" ),"Set hardware breakpoint")[python::return_value_policy<python::manage_new_object>()]);
python::def("getNumberBreakpoints", &Breakpoint::getNumberBreakpoints,
"Return number of breakpoints in the current process" );
python::def( "getBp", &Breakpoint::getBreakpointByIndex, python::return_value_policy<python::manage_new_object>(),
"Return breakpoint object by index");
python::def("removeBp", &Breakpoint::removeBreakpointByIndex,
"Remove breakpoint by index");
python::def("removeAllBp", &Breakpoint::removeAllBreakpoints,
"Remove all breakpoints");
// processes and threads
python::def ( "getNumberProcesses", pykd::getNumberProcesses,
"Return number of processes on the target system" );
python::def( "getProcessId", pykd::getProcessIdByIndex,
"Return process ID by index" );
python::def( "getProcessOffset", pykd::getProcessOffset, getProcessOffset_( python::args( "Id" ),
"Return the location in the target's memory of the process structure ( PEB )" ) );
python::def( "getProcessSystemID", pykd::getProcessSystemId, getProcessSystemId_( python::args( "Id" ),
"Return system process ID ( PID )" ) );
python::def("getProcessExeName", pykd::getProcessExecutableName, getProcessExecutableName_(python::args("Id"),
"Return name of executable file of the process"));
python::def( "getProcessIdBySystemID", pykd::getProcessIdBySystemId,
"Return process ID by the system's process ID ( PID )" );
python::def( "getCurrentProcess", pykd::getCurrentProcess,
"Return current offset" );
python::def( "getCurrentProcessId", pykd::getCurrentProcessId,
"Return current process ID" );
python::def( "setCurrentProcess", pykd::setCurrentProcess,
"Set current process" );
python::def( "setCurrentProcessId", pykd::setCurrentProcessId,
"Set current process by debug ID" );
python::def( "getImplicitProcess", pykd::getImplicitProcessOffset,
"Return implicit process" );
python::def( "setImplicitProcess", pykd::setImplicitProcess,
"Set implicit process" );
python::def( "getProcessThreads", pykd::getProcessThreads,
"Get all process's threads " );
python::def( "getTargetProcesses", pykd::getTargetProcesses,
"Get all target processes " );
python::def ( "getNumberThreads", pykd::getNumberThreads,
"Return number of threads on the current system" );
python::def( "getThreadId", pykd::getThreadIdByIndex,
"Return thread id by index");
python::def( "getThreadOffset", pykd::getThreadOffset, getThreadOffset_( python::args("Id"),
"Return the location in the target's memory of the thread structure ( TEB )" ) );
python::def( "getThreadSystemID", pykd::getThreadSystemId, getThreadSystemId_( python::args("Id"),
"Return system thread ID ( TID )" ) );
python::def( "getThreadIdByOffset", pykd::getThreadIdByOffset,
"Return thread ID by the location in the targ et's memory of the thread structure" );
</