Ejemplo n.º 1
0
 public DummyHolder(DkmProcess process) {
     var pyrtInfo = process.GetPythonRuntimeInfo();
     Dummy = 
         pyrtInfo.LanguageVersion >= PythonLanguageVersion.V34 ? 
         pyrtInfo.DLLs.Python.GetStaticVariable<PointerProxy<PyObject>>("_PySet_Dummy") :
         pyrtInfo.DLLs.Python.GetStaticVariable<PointerProxy<PyObject>>("dummy", "setobject.obj");
 }
Ejemplo n.º 2
0
        public ModuleManager(DkmProcess process) {
            _process = process;
            _pyrtInfo = process.GetPythonRuntimeInfo();

            LoadInitialPythonModules();
            LocalComponent.CreateRuntimeDllFunctionBreakpoint(_pyrtInfo.DLLs.Python, "PyCode_New", PythonDllBreakpointHandlers.PyCode_New, enable: true, debugStart: true);
            LocalComponent.CreateRuntimeDllFunctionBreakpoint(_pyrtInfo.DLLs.Python, "PyCode_NewEmpty", PythonDllBreakpointHandlers.PyCode_NewEmpty, enable: true, debugStart: true);
        }
Ejemplo n.º 3
0
 public PyFrameObject(DkmProcess process, ulong address)
     : base(process, address) {
     var pythonInfo = process.GetPythonRuntimeInfo();
     if (pythonInfo.LanguageVersion <= PythonLanguageVersion.V35) {
         Fields_27_35 fields;
         InitializeStruct(this, out fields);
         _fields = fields;
     } else {
         Fields_36 fields;
         InitializeStruct(this, out fields);
         _fields = fields;
     }
     CheckPyType<PyFrameObject>();
 }
Ejemplo n.º 4
0
        public ExpressionEvaluator(DkmProcess process) {
            _process = process;
            var pyrtInfo = process.GetPythonRuntimeInfo();

            _evalLoopThreadId = pyrtInfo.DLLs.DebuggerHelper.GetExportedStaticVariable<UInt64Proxy>("evalLoopThreadId");
            _evalLoopFrame = pyrtInfo.DLLs.DebuggerHelper.GetExportedStaticVariable<UInt64Proxy>("evalLoopFrame");
            _evalLoopResult = pyrtInfo.DLLs.DebuggerHelper.GetExportedStaticVariable<UInt64Proxy>("evalLoopResult");
            _evalLoopExcType = pyrtInfo.DLLs.DebuggerHelper.GetExportedStaticVariable<UInt64Proxy>("evalLoopExcType");
            _evalLoopExcValue = pyrtInfo.DLLs.DebuggerHelper.GetExportedStaticVariable<UInt64Proxy>("evalLoopExcValue");
            _evalLoopExcStr = pyrtInfo.DLLs.DebuggerHelper.GetExportedStaticVariable<UInt64Proxy>("evalLoopExcStr");
            _evalLoopSEHCode = pyrtInfo.DLLs.DebuggerHelper.GetExportedStaticVariable<UInt32Proxy>("evalLoopSEHCode");
            _evalLoopInput = pyrtInfo.DLLs.DebuggerHelper.GetExportedStaticVariable<CStringProxy>("evalLoopInput");

            LocalComponent.CreateRuntimeDllExportedFunctionBreakpoint(pyrtInfo.DLLs.DebuggerHelper, "OnEvalComplete", OnEvalComplete, enable: true);
        }
Ejemplo n.º 5
0
 public PyFrameObject_FieldOffsets(DkmProcess process) {
     if (process.GetPythonRuntimeInfo().LanguageVersion <= PythonLanguageVersion.V35) {
         var fields = StructProxy.GetStructFields<PyFrameObject, PyFrameObject.Fields_27_35>(process);
         f_back = -1;
         f_code = fields.f_code.Offset;
         f_globals = fields.f_globals.Offset;
         f_locals = fields.f_locals.Offset;
         f_lineno = fields.f_lineno.Offset;
     } else {
         var fields = StructProxy.GetStructFields<PyFrameObject, PyFrameObject.Fields_36>(process);
         f_back = fields.f_back.Offset;
         f_code = fields.f_code.Offset;
         f_globals = fields.f_globals.Offset;
         f_locals = fields.f_locals.Offset;
         f_lineno = fields.f_lineno.Offset;
     }
 }
Ejemplo n.º 6
0
 public InterpHeadHolder(DkmProcess process) {
     Proxy = process.GetPythonRuntimeInfo().DLLs.Python.GetStaticVariable<PointerProxy<PyInterpreterState>>("interp_head");
 }
Ejemplo n.º 7
0
        public unsafe TraceManagerLocalHelper(DkmProcess process, Kind kind) {
            _process = process;
            _pyrtInfo = process.GetPythonRuntimeInfo();

            _traceFunc = _pyrtInfo.DLLs.DebuggerHelper.GetExportedFunctionAddress("TraceFunc");
            _isTracing = _pyrtInfo.DLLs.DebuggerHelper.GetExportedStaticVariable<ByteProxy>("isTracing");
            _pyTracingPossible = _pyrtInfo.DLLs.Python.GetStaticVariable<UInt32Proxy>("_Py_TracingPossible");

            if (kind == Kind.StepIn) {
                var fieldOffsets = _pyrtInfo.DLLs.DebuggerHelper.GetExportedStaticVariable<CliStructProxy<FieldOffsets>>("fieldOffsets");
                fieldOffsets.Write(new FieldOffsets(process, _pyrtInfo));

                var types = _pyrtInfo.DLLs.DebuggerHelper.GetExportedStaticVariable<CliStructProxy<Types>>("types");
                types.Write(new Types(process, _pyrtInfo));

                var functionPointers = _pyrtInfo.DLLs.DebuggerHelper.GetExportedStaticVariable<CliStructProxy<FunctionPointers>>("functionPointers");
                functionPointers.Write(new FunctionPointers(process, _pyrtInfo));

                var stringEquals = _pyrtInfo.DLLs.DebuggerHelper.GetExportedStaticVariable<PointerProxy>("stringEquals");
                if (_pyrtInfo.LanguageVersion <= PythonLanguageVersion.V27) {
                    stringEquals.Write(_pyrtInfo.DLLs.DebuggerHelper.GetExportedFunctionAddress("StringEquals27").GetPointer());
                } else {
                    stringEquals.Write(_pyrtInfo.DLLs.DebuggerHelper.GetExportedFunctionAddress("StringEquals33").GetPointer());
                }

                foreach (var interp in PyInterpreterState.GetInterpreterStates(process)) {
                    foreach (var tstate in interp.GetThreadStates()) {
                        RegisterTracing(tstate);
                    }
                }

                _handlers = new PythonDllBreakpointHandlers(this);
                LocalComponent.CreateRuntimeDllFunctionExitBreakpoints(_pyrtInfo.DLLs.Python, "new_threadstate", _handlers.new_threadstate, enable: true);

                foreach (var methodInfo in _handlers.GetType().GetMethods()) {
                    var stepInAttr = (StepInGateAttribute)Attribute.GetCustomAttribute(methodInfo, typeof(StepInGateAttribute));
                    if (stepInAttr != null &&
                        (stepInAttr.MinVersion == PythonLanguageVersion.None || _pyrtInfo.LanguageVersion >= stepInAttr.MinVersion) &&
                        (stepInAttr.MaxVersion == PythonLanguageVersion.None || _pyrtInfo.LanguageVersion <= stepInAttr.MaxVersion)) {

                        var handler = (StepInGateHandler)Delegate.CreateDelegate(typeof(StepInGateHandler), _handlers, methodInfo);
                        AddStepInGate(handler, _pyrtInfo.DLLs.Python, methodInfo.Name, stepInAttr.HasMultipleExitPoints);
                    }
                }

                if (_pyrtInfo.DLLs.CTypes != null) {
                    OnCTypesLoaded(_pyrtInfo.DLLs.CTypes);
                }
            }
        }
Ejemplo n.º 8
0
 public DummyHolder(DkmProcess process) {
     Dummy = process.GetPythonRuntimeInfo().DLLs.Python.GetStaticVariable<PointerProxy<PyObject>>("dummy", "dictobject.obj");
 }
Ejemplo n.º 9
0
 public unsafe static PyTypeObject FromNativeGlobalVariable(DkmProcess process, string name) {
     var addr = process.GetPythonRuntimeInfo().DLLs.Python.GetStaticVariableAddress(name);
     return new PyTypeObject(process, addr);
 }
Ejemplo n.º 10
0
 public CallStackFilter(DkmProcess process) {
     _process = process;
     _pyrtInfo = process.GetPythonRuntimeInfo();
 }
Ejemplo n.º 11
0
            public ValuesHolder(DkmProcess process) {
                var pythonDll = process.GetPythonRuntimeInfo().DLLs.Python;

                False = pythonDll.GetStaticVariable<PyBoolObject33>("_Py_FalseStruct");
                True = pythonDll.GetStaticVariable<PyBoolObject33>("_Py_TrueStruct");
            }