Beispiel #1
0
        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);
                }
            }
        }
Beispiel #2
0
        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();
        }
Beispiel #3
0
 private void renderDebugLines(TreeNode root, SmxDebugLinesTable lines)
 {
     root.Tag = new NodeData(delegate()
     {
         renderSectionHeaderDetail(lines.SectionHeader);
         foreach (var line in lines.Entries)
         {
             addDetailLine("line {0} @ address 0x{1:x}", line.Line, line.Address);
         }
         endDetailUpdate();
     }, null);
 }
Beispiel #4
0
        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();
        }