public SmxFile(BinaryReader br) { Header = FileHeader.From(br); // Parse precursor sections. foreach (var section in Header.Sections) { if (section.Name == ".names") { Names = new SmxNameTable(Header, section); } else if (section.Name == ".dbg.strings") { DebugNames = new SmxNameTable(Header, section); } else if (section.Name == ".dbg.info") { DebugInfo = new SmxDebugInfoSection(Header, section); } } CalledFunctions = new SmxCalledFunctionsTable(); // .dbg.names was removed when RTTI was added. if (DebugNames == null) { DebugNames = Names; } // Parse out other sections. var unknown = new List <SectionEntry>(); foreach (var section in Header.Sections) { try { switch (section.Name) { case ".names": case ".dbg.strings": case ".dbg.info": break; case ".natives": Natives = new SmxNativeTable(Header, section, Names); break; case ".publics": Publics = new SmxPublicTable(Header, section, Names); break; case ".pubvars": Pubvars = new SmxPubvarTable(Header, section, Names); break; case ".tags": Tags = new SmxTagTable(Header, section, Names); break; case ".data": Data = new SmxDataSection(Header, section); break; case ".code": CodeV1 = new SmxCodeV1Section(Header, section); break; case ".dbg.files": DebugFiles = new SmxDebugFilesTable(Header, section, DebugNames); break; case ".dbg.lines": DebugLines = new SmxDebugLinesTable(Header, section); break; case ".dbg.natives": DebugNatives = new SmxDebugNativesTable(Header, section, DebugNames); break; case ".dbg.symbols": DebugSymbols = new SmxDebugSymbolsTable(Header, section, DebugInfo, DebugNames); break; case ".dbg.methods": DebugMethods = new SmxDebugMethods(Header, section, Names); break; case ".dbg.globals": DebugGlobals = new SmxDebugGlobals(Header, section, Names); break; case ".dbg.locals": DebugLocals = new SmxDebugLocals(this, Header, section, Names); break; case "rtti.data": RttiData = new SmxRttiData(this, Header, section); break; case "rtti.classdefs": RttiClassDefs = new SmxRttiClassDefTable(Header, section, Names); break; case "rtti.fields": RttiFields = new SmxRttiFieldTable(Header, section, Names); break; case "rtti.methods": RttiMethods = new SmxRttiMethodTable(Header, section, Names); break; case "rtti.natives": RttiNatives = new SmxRttiNativeTable(Header, section, Names); break; case "rtti.enums": RttiEnums = new SmxRttiEnumTable(Header, section, Names); break; case "rtti.typedefs": RttiTypedefs = new SmxRttiTypedefTable(Header, section, Names); break; case "rtti.typesets": RttiTypesets = new SmxRttiTypesetTable(Header, section, Names); break; default: unknown.Add(section); break; } } catch { // Set a breakpoint here to see why the section failed to be parsed. unknown.Add(section); } } UnknownSections = unknown.ToArray(); // Disassemble all functions right away to find all called functions. if (DebugSymbols != null) { foreach (var entry in DebugSymbols.Entries) { if (entry.Ident != SymKind.Function) { continue; } V1Disassembler.TryDisassemble(this, CodeV1, entry.Address); } } if (Publics != null) { foreach (var pubfun in Publics.Entries) { V1Disassembler.TryDisassemble(this, CodeV1, (int)pubfun.Address); } } if (CalledFunctions != null) { foreach (var fun in CalledFunctions.Entries) { V1Disassembler.TryDisassemble(this, CodeV1, (int)fun.Address); } } }
private void renderPublicsList(TreeNode root, SmxPublicTable publics) { for (var i = 0; i < publics.Length; i++) { var index = i; var pubfun = publics[i]; var node = root.Nodes.Add(i + ": " + pubfun.Name); node.Tag = new NodeData(delegate() { startDetail("; public entry {0}", index); addDetailLine("nameoffs = 0x{0:x} ; {1}", pubfun.nameoffs, pubfun.Name); addDetailLine("address = 0x{0:x}", pubfun.Address); endDetailUpdate(); }, null); } }
public SmxFile(BinaryReader br) { Header = FileHeader.From(br); // Parse precursor sections. foreach (var section in Header.Sections) { if (section.Name == ".names") { Names = new SmxNameTable(Header, section); } else if (section.Name == ".dbg.strings") { DebugNames = new SmxNameTable(Header, section); } else if (section.Name == ".dbg.info") { DebugInfo = new SmxDebugInfoSection(Header, section); } } // Parse out other sections. var unknown = new List <SectionEntry>(); foreach (var section in Header.Sections) { switch (section.Name) { case ".names": case ".dbg.strings": case ".dbg.info": break; case ".natives": Natives = new SmxNativeTable(Header, section, Names); break; case ".publics": Publics = new SmxPublicTable(Header, section, Names); break; case ".pubvars": Pubvars = new SmxPubvarTable(Header, section, Names); break; case ".tags": Tags = new SmxTagTable(Header, section, Names); break; case ".data": Data = new SmxDataSection(Header, section); break; case ".code": CodeV1 = new SmxCodeV1Section(Header, section); break; case ".dbg.files": DebugFiles = new SmxDebugFilesTable(Header, section, DebugNames); break; case ".dbg.lines": DebugLines = new SmxDebugLinesTable(Header, section); break; case ".dbg.natives": DebugNatives = new SmxDebugNativesTable(Header, section, DebugNames); break; case ".dbg.symbols": DebugSymbols = new SmxDebugSymbolsTable(Header, section, DebugInfo, DebugNames); break; default: unknown.Add(section); break; } } UnknownSections = unknown.ToArray(); }
private void renderPublicsList(TreeViewItem root, SmxPublicTable publics) { for (int i = 0; i < publics.Length; i++) { var index = i; var pubfun = publics[i]; var node = new TreeViewItem() { Header = (i.ToString() + ": " + pubfun.Name) }; root.Items.Add(node); node.Tag = new NodeData(delegate() { startDetail("; public entry {0}", index); addDetailLine("nameoffs = 0x{0:x} ; {1}", pubfun.nameoffs, pubfun.Name); addDetailLine("address = 0x{0:x}", pubfun.Address); endDetailUpdate(); }, null); } }
public SmxFile(BinaryReader br) { Header = FileHeader.From(br); // Parse precursor sections. foreach (var section in Header.Sections) { if (section.Name == ".names") Names = new SmxNameTable(Header, section); else if (section.Name == ".dbg.strings") DebugNames = new SmxNameTable(Header, section); else if (section.Name == ".dbg.info") DebugInfo = new SmxDebugInfoSection(Header, section); } // Parse out other sections. var unknown = new List<SectionEntry>(); foreach (var section in Header.Sections) { switch (section.Name) { case ".names": case ".dbg.strings": case ".dbg.info": break; case ".natives": Natives = new SmxNativeTable(Header, section, Names); break; case ".publics": Publics = new SmxPublicTable(Header, section, Names); break; case ".pubvars": Pubvars = new SmxPubvarTable(Header, section, Names); break; case ".tags": Tags = new SmxTagTable(Header, section, Names); break; case ".data": Data = new SmxDataSection(Header, section); break; case ".code": CodeV1 = new SmxCodeV1Section(Header, section); break; case ".dbg.files": DebugFiles = new SmxDebugFilesTable(Header, section, DebugNames); break; case ".dbg.lines": DebugLines = new SmxDebugLinesTable(Header, section); break; case ".dbg.natives": DebugNatives = new SmxDebugNativesTable(Header, section, DebugNames); break; case ".dbg.symbols": DebugSymbols = new SmxDebugSymbolsTable(Header, section, DebugInfo, DebugNames); break; default: unknown.Add(section); break; } } UnknownSections = unknown.ToArray(); }