public static void PyCode_NewEmpty(DkmThread thread, ulong frameBase, ulong vframe, ulong returnAddress) { var process = thread.Process; CppExpressionEvaluator cppEval = new CppExpressionEvaluator(thread, frameBase, vframe); ulong filenamePtr = cppEval.EvaluateUInt64("filename"); if (filenamePtr == 0) { return; } string filename = new CStringProxy(process, filenamePtr).ReadUnicode(); if (process.GetPythonRuntimeInstance().GetModuleInstances().Any(mi => mi.FullName == filename)) { return; } new RemoteComponent.CreateModuleRequest { ModuleId = Guid.NewGuid(), FileName = filename }.SendLower(process); }
private IEnumerable <PythonEvaluationResult> GetDebugChildrenFromSlots() { var tp_members = ob_type.Read().tp_members; if (tp_members.IsNull) { yield break; } var langVer = Process.GetPythonRuntimeInfo().LanguageVersion; var memberDefs = tp_members.Read().TakeWhile(md => !md.name.IsNull); foreach (PyMemberDef memberDef in memberDefs) { var offset = memberDef.offset.Read(); IValueStore value; switch (memberDef.type.Read()) { case PyMemberDefType.T_OBJECT: case PyMemberDefType.T_OBJECT_EX: { var objProxy = GetFieldProxy(new StructField <PointerProxy <PyObject> > { Process = Process, Offset = offset }); if (!objProxy.IsNull) { value = objProxy; } else { value = new ValueStore <PyObject>(None(Process)); } } break; case PyMemberDefType.T_STRING: { var ptr = GetFieldProxy(new StructField <PointerProxy> { Process = Process, Offset = offset }).Read(); if (ptr != 0) { var proxy = new CStringProxy(Process, ptr); if (langVer <= PythonLanguageVersion.V27) { value = new ValueStore <AsciiString>(proxy.ReadAscii()); } else { value = new ValueStore <string>(proxy.ReadUnicode()); } } else { value = new ValueStore <PyObject>(None(Process)); } } break; case PyMemberDefType.T_STRING_INPLACE: { var proxy = new CStringProxy(Process, Address.OffsetBy(offset)); if (langVer <= PythonLanguageVersion.V27) { value = new ValueStore <AsciiString>(proxy.ReadAscii()); } else { value = new ValueStore <string>(proxy.ReadUnicode()); } } break; case PyMemberDefType.T_BYTE: value = GetFieldProxy(new StructField <SByteProxy> { Process = Process, Offset = offset }); break; case PyMemberDefType.T_UBYTE: value = GetFieldProxy(new StructField <ByteProxy> { Process = Process, Offset = offset }); break; case PyMemberDefType.T_SHORT: value = GetFieldProxy(new StructField <Int16Proxy> { Process = Process, Offset = offset }); break; case PyMemberDefType.T_USHORT: value = GetFieldProxy(new StructField <UInt16Proxy> { Process = Process, Offset = offset }); break; case PyMemberDefType.T_INT: case PyMemberDefType.T_LONG: value = GetFieldProxy(new StructField <Int32Proxy> { Process = Process, Offset = offset }); break; case PyMemberDefType.T_UINT: case PyMemberDefType.T_ULONG: value = GetFieldProxy(new StructField <UInt32Proxy> { Process = Process, Offset = offset }); break; case PyMemberDefType.T_LONGLONG: value = GetFieldProxy(new StructField <Int64Proxy> { Process = Process, Offset = offset }); break; case PyMemberDefType.T_ULONGLONG: value = GetFieldProxy(new StructField <UInt64Proxy> { Process = Process, Offset = offset }); break; case PyMemberDefType.T_PYSSIZET: value = GetFieldProxy(new StructField <SSizeTProxy> { Process = Process, Offset = offset }); break; case PyMemberDefType.T_FLOAT: value = GetFieldProxy(new StructField <SingleProxy> { Process = Process, Offset = offset }); break; case PyMemberDefType.T_DOUBLE: value = GetFieldProxy(new StructField <DoubleProxy> { Process = Process, Offset = offset }); break; case PyMemberDefType.T_BOOL: value = GetFieldProxy(new StructField <BoolProxy> { Process = Process, Offset = offset }); break; case PyMemberDefType.T_CHAR: value = GetFieldProxy(new StructField <CharProxy> { Process = Process, Offset = offset }); break; case PyMemberDefType.T_NONE: value = new ValueStore <PyObject>(None(Process)); break; default: continue; } yield return(new PythonEvaluationResult(value, memberDef.name.Read().ReadUnicode())); } }