コード例 #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);
                }
            }
        }
コード例 #2
0
ファイル: MainWindow.cs プロジェクト: peace-maker/smxtools
 private void renderDebugNatives(TreeNode root, SmxDebugNativesTable natives)
 {
     foreach (var native_ in natives.Entries)
     {
         var native = native_;
         var node = root.Nodes.Add(native.Name);
         node.Tag = new NodeData(delegate()
         {
             renderDebugNative(native);
         }, null);
     }
 }
コード例 #3
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();
        }
コード例 #4
0
ファイル: DASMElement.xaml.cs プロジェクト: not1ce111/Spedit
 private void renderDebugNatives(TreeViewItem root, SmxDebugNativesTable natives)
 {
     foreach (var native_ in natives.Entries)
     {
         var native = native_;
         var node = new TreeViewItem() { Header = native.Name };
         root.Items.Add(node);
         node.Tag = new NodeData(delegate()
         {
             renderDebugNative(native);
         }, null);
     }
 }
コード例 #5
0
ファイル: File.cs プロジェクト: peace-maker/smxtools
        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();
        }