diff --git a/pykd/pymod.cpp b/pykd/pymod.cpp index 7185908..d3fcac1 100644 --- a/pykd/pymod.cpp +++ b/pykd/pymod.cpp @@ -575,6 +575,8 @@ BOOST_PYTHON_MODULE( pykd ) "Return process by index") .def("getProcessById", TargetSystemAdapter::getProcessById, "Return process by id") + .def("getProcessBySystemId", TargetSystemAdapter::getProcessBySystemId, + "Return process by PID") .def("currentProcess", TargetSystemAdapter::getCurrentProcess, "Return current process") .def("processes", TargetSystemAdapter::getProcessesList, @@ -607,6 +609,8 @@ BOOST_PYTHON_MODULE( pykd ) "Return thread by its index" ) .def("getThreadById", TargetProcessAdapter::getThreadById, "Return thread by its index") + .def("getThreadBySystemId", TargetProcessAdapter::getThreadBySystemId, + "Return thread by tid") .def("currentThread", TargetProcessAdapter::getCurrentThread, "Return current thread" ) .def("getNumberBreakpoints", TargetProcessAdapter::getNumberBreakpoints, diff --git a/pykd/pyprocess.h b/pykd/pyprocess.h index 8473315..d11a660 100644 --- a/pykd/pyprocess.h +++ b/pykd/pyprocess.h @@ -81,6 +81,12 @@ struct TargetSystemAdapter { return system.getProcessById(id); } + static kdlib::TargetProcessPtr getProcessBySystemId(kdlib::TargetSystem& system, kdlib::PROCESS_ID pid) + { + AutoRestorePyState pystate; + return system.getProcessBySystemId(pid); + } + static kdlib::TargetProcessPtr getCurrentProcess(kdlib::TargetSystem& system) { AutoRestorePyState pystate; @@ -167,6 +173,12 @@ struct TargetProcessAdapter { return process.getThreadById(id); } + static kdlib::TargetThreadPtr getThreadBySystemId(kdlib::TargetProcess& process, kdlib::THREAD_ID tid) + { + AutoRestorePyState pystate; + return process.getThreadBySystemId(tid); + } + static kdlib::TargetThreadPtr getCurrentThread(kdlib::TargetProcess& process) { AutoRestorePyState pystate; diff --git a/snippets/wfp.py b/snippets/wfp.py index d1b4d3a..a73cfdf 100644 --- a/snippets/wfp.py +++ b/snippets/wfp.py @@ -4,9 +4,9 @@ import re from pykd import * -fwpsLayer = typeInfo( "FWPS_BUILTIN_LAYERS_" ).asMap() -fwpsDataType = typeInfo( "FWP_DATA_TYPE_" ).asMap() -fwpDirection = typeInfo( "FWP_DIRECTION_" ).asMap() +fwpsLayer = dict( [ (long(val), key) for key, val in typeInfo( "FWPS_BUILTIN_LAYERS_" ).fields() ] ) +fwpsDataType = dict( [ (long(val), key) for key, val in typeInfo( "FWP_DATA_TYPE_" ).fields() ] ) +fwpDirection = dict( [ (long(val), key) for key, val in typeInfo( "FWP_DIRECTION_" ).fields() ] ) def printBlob( blob ): bb = loadBytes( blob.data, blob.size ) @@ -47,7 +47,7 @@ def wfpFixedValues( addr ): dprintln( "FWPS_INCOMING_VALUES0:" ) inFixedValue = typedVar( "FWPS_INCOMING_VALUES0_", addr ) - + dprintln( " Layer: " + fwpsLayer[ inFixedValue.layerId ] ) dprintln( " Value: %d" % inFixedValue.valueCount ) @@ -59,10 +59,10 @@ def wfpFixedValues( addr ): layerName = discardRe.sub( '', layerName, 1 ) layerRe = re.compile( 'LAYER' ) - fwpsFields = typeInfo( layerRe.sub( 'FIELDS', layerName, 1 ) + '_' ).asMap() + fwpsFields = typeInfo( layerRe.sub( 'FIELDS', layerName, 1 ) + '_' ).fields() - for i in range( 0, len(values) ): - dprintln( " " + fwpsFields[ i ] ) + for i in xrange( min(len(fwpsFields),len(values)) ): + dprintln( " " + fwpsFields[i][0] ) dprintln( " Type: " + fwpsDataType[ values[i].field("type") ] ) dprintln( " Value: " + printFwpsValue( values[i] ) )