コード例 #1
0
ファイル: MainFormInteractor.cs プロジェクト: mmyydd/reko
 public void EditFind()
 {
     using (ISearchDialog dlg = dlgFactory.CreateSearchDialog())
     {
         if (uiSvc.ShowModalDialog(dlg) == DialogResult.OK)
         {
             Func <int, Program, bool> filter = GetScannedFilter(dlg);
             var re = Scanning.Dfa.Automaton.CreateFromPattern(dlg.Patterns.Text);
             if (re == null)
             {
                 return;
             }
             var hits = this.decompilerSvc.Decompiler.Project.Programs
                        .SelectMany(program =>
                                    re.GetMatches(program.Image.Bytes, 0)
                                    .Where(o => filter(o, program))
                                    .Select(offset => new AddressSearchHit
             {
                 Program = program,
                 Address = program.Image.BaseAddress + offset
             }));
             srSvc.ShowSearchResults(new AddressSearchResult(
                                         this.sc,
                                         hits));
         }
     }
 }
コード例 #2
0
ファイル: LowLevelViewInteractor.cs プロジェクト: mmyydd/reko
        public bool ViewFindPattern()
        {
            AddressRange addrRange = control.MemoryView.GetAddressRange();

            if (!addrRange.IsValid || program == null)
            {
                return(true);
            }
            var dlgFactory = services.RequireService <IDialogFactory>();
            var uiSvc      = services.RequireService <IDecompilerShellUiService>();
            var srSvc      = services.RequireService <ISearchResultService>();

            using (ISearchDialog dlg = dlgFactory.CreateSearchDialog())
            {
                dlg.InitialPattern = SelectionToHex(addrRange);
                if (uiSvc.ShowModalDialog(dlg) == DialogResult.OK)
                {
                    var re   = Scanning.Dfa.Automaton.CreateFromPattern(dlg.Patterns.Text);
                    var hits =
                        re.GetMatches(program.Image.Bytes, 0)
                        .Select(offset => new AddressSearchHit
                    {
                        Program = program,
                        Address = program.Image.BaseAddress + offset
                    });
                    srSvc.ShowSearchResults(new AddressSearchResult(this.services, hits));
                }
            }
            return(true);
        }
コード例 #3
0
 public void EditFind()
 {
     using (ISearchDialog dlg = dlgFactory.CreateSearchDialog())
     {
         if (uiSvc.ShowModalDialog(dlg) == DialogResult.OK)
         {
             Func <int, Program, bool> filter = GetScannedFilter(dlg);
             var re = Scanning.Dfa.Automaton.CreateFromPattern(dlg.Patterns.Text);
             if (re == null)
             {
                 return;
             }
             var hits = this.decompilerSvc.Decompiler.Project.Programs
                        .SelectMany(program =>
                                    program.ImageMap.Segments.Values.SelectMany(seg =>
             {
                 var segOffset = (int)(seg.Address - program.Image.BaseAddress);
                 return(re.GetMatches(
                            program.Image.Bytes,
                            segOffset,
                            segOffset + (int)seg.Size)
                        .Where(o => filter(o, program))
                        .Select(offset => new ProgramAddress(
                                    program,
                                    program.ImageMap.MapLinearAddressToAddress(
                                        program.Image.BaseAddress.ToLinear() + (ulong)offset))));
             }));
             srSvc.ShowAddressSearchResults(hits, AddressSearchDetails.Code);
         }
     }
 }
コード例 #4
0
ファイル: LowLevelViewInteractor.cs プロジェクト: heruix/reko
        public bool ViewFindPattern()
        {
            AddressRange addrRange = control.MemoryView.GetAddressRange();

            if (!addrRange.IsValid || program == null)
            {
                return(true);
            }
            var dlgFactory = services.RequireService <IDialogFactory>();
            var uiSvc      = services.RequireService <IDecompilerShellUiService>();
            var srSvc      = services.RequireService <ISearchResultService>();

            using (ISearchDialog dlg = dlgFactory.CreateSearchDialog())
            {
                dlg.InitialPattern = SelectionToHex(addrRange);
                if (uiSvc.ShowModalDialog(dlg) == Gui.DialogResult.OK)
                {
                    var re   = Core.Dfa.Automaton.CreateFromPattern(dlg.Patterns.Text);
                    var hits =
                        //$BUG: wrong result
                        program.SegmentMap.Segments.Values
                        .SelectMany(s => re.GetMatches(s.MemoryArea.Bytes, 0))
                        .Select(offset => new AddressSearchHit
                    {
                        Program = program,
                        Address = program.ImageMap.BaseAddress + offset,
                        Length  = 1
                    });
                    srSvc.ShowAddressSearchResults(hits, new CodeSearchDetails());
                }
            }
            return(true);
        }
コード例 #5
0
 public void EditFind()
 {
     using (ISearchDialog dlg = dlgFactory.CreateSearchDialog())
     {
         if (uiSvc.ShowModalDialog(dlg) == DialogResult.OK)
         {
             Func <int, Program, bool> filter = GetScannedFilter(dlg);
             var re = Core.Dfa.Automaton.CreateFromPattern(dlg.Patterns.Text);
             if (re == null)
             {
                 return;
             }
             var hits = this.decompilerSvc.Decompiler.Project.Programs
                        .SelectMany(program =>
                                    program.SegmentMap.Segments.Values.SelectMany(seg =>
             {
                 var linBaseAddr = seg.MemoryArea.BaseAddress.ToLinear();
                 return(re.GetMatches(
                            seg.MemoryArea.Bytes,
                            0,
                            (int)seg.MemoryArea.Length)
                        .Where(o => filter(o, program))
                        .Select(offset => new AddressSearchHit
                 {
                     Program = program,
                     Address = program.SegmentMap.MapLinearAddressToAddress(
                         linBaseAddr + (ulong)offset)
                 }));
             }));
             srSvc.ShowAddressSearchResults(hits, new CodeSearchDetails());
         }
     }
 }
コード例 #6
0
 private void When_CreateDialog()
 {
     dlg = new SearchDialog()
     {
         Services = sc
     };
 }
コード例 #7
0
 public void TearDown()
 {
     if (dlg != null)
     {
         dlg.Dispose();
     }
     dlg = null;
 }
コード例 #8
0
 public void Attach(ISearchDialog dlg)
 {
     this.dlg = dlg;
     dlg.Load += dlg_Load;
     dlg.Closed += dlg_Closed;
     dlg.Patterns.TextChanged += delegate { EnableControls(); };
     dlg.ScannedMemory.CheckedChanged += delegate { EnableControls(); };
     dlg.UnscannedMemory.CheckedChanged += delegate { EnableControls(); };
     dlg.SearchButton.Click += SearchButton_Click;
 }
コード例 #9
0
ファイル: SearchDialogInteractor.cs プロジェクト: Klanly/reko
 public void Attach(ISearchDialog dlg)
 {
     this.dlg    = dlg;
     dlg.Load   += dlg_Load;
     dlg.Closed += dlg_Closed;
     dlg.Patterns.TextChanged           += delegate { EnableControls(); };
     dlg.ScannedMemory.CheckedChanged   += delegate { EnableControls(); };
     dlg.UnscannedMemory.CheckedChanged += delegate { EnableControls(); };
     dlg.SearchButton.Click             += SearchButton_Click;
 }
コード例 #10
0
 public Data(IWidgetModified widgetModified,
             ISearchDialog searchDialog,
             String descriptionQuery,
             String descriptionParameter,
             Enum descriptionColumn)
 {
     m_widgetModified       = widgetModified;
     m_searchDialog         = searchDialog;
     m_descriptionQuery     = descriptionQuery;
     m_descriptionParameter = descriptionParameter;
     m_descriptionColumn    = descriptionColumn;
 }
コード例 #11
0
        private TableIO initializeItemManufacturing(ISearchDialog itemSearchDialog)
        {
            Net7_Tools.Gui.frmManufacturing manufacturingDlg  = new Net7_Tools.Gui.frmManufacturing();
            ItemManufacturingRecordManager  itemRecordManager = new ItemManufacturingRecordManager(manufacturingDlg, this);
            TableIO tableIO = new TableIO(this, itemRecordManager);

            manufacturingDlg.setTableIO(tableIO);
            DataBinding dataBinding;

            dataBinding = tableIO.bind(manufacturingDlg.manufacturingCboDifficulty, Net7.Table_item_manufacture._difficulty, "Difficulty Level");
            dataBinding.addValidation(new ValidateNumericInsideRange(1, 9));

            //dataBinding.addValidation(new ValidateInTable(Net7_db.Tables.item_base.ToString(), DB.getQueryItem(itemId));
            dataBinding = tableIO.bind(manufacturingDlg.manufacturingTxtComponent1, Net7.Table_item_manufacture._comp_1, "Component 1", false);
            dataBinding = tableIO.bind(manufacturingDlg.manufacturingTxtComponent2, Net7.Table_item_manufacture._comp_2, "Component 2", false);
            dataBinding = tableIO.bind(manufacturingDlg.manufacturingTxtComponent3, Net7.Table_item_manufacture._comp_3, "Component 3", false);
            dataBinding = tableIO.bind(manufacturingDlg.manufacturingTxtComponent4, Net7.Table_item_manufacture._comp_4, "Component 4", false);
            dataBinding = tableIO.bind(manufacturingDlg.manufacturingTxtComponent5, Net7.Table_item_manufacture._comp_5, "Component 5", false);
            dataBinding = tableIO.bind(manufacturingDlg.manufacturingTxtComponent6, Net7.Table_item_manufacture._comp_6, "Component 6", false);

            // Initialize the manufacturing difficulty levels
            manufacturingDlg.manufacturingCboDifficulty.Items.Clear();
            manufacturingDlg.manufacturingCboDifficulty.Items.AddRange(Database.Database.getItemManufacturingLevels());

            // Configure the 6 component fields, search buttons, and descriptions
            FieldSearchDescription.Data fieldSearchDescriptionData
                = new FieldSearchDescription.Data(
                      itemRecordManager,
                      itemSearchDialog,
                      Database.Database.getQueryItem_param(),
                      DB.QueryParameterCharacter + ColumnData.GetName(Net7.Table_item_base._id),
                      Net7.Table_item_base._name);
            itemRecordManager.setFieldSearchDescriptionData(fieldSearchDescriptionData);
            itemRecordManager.addComponentFields(new FieldSearchDescription.Fields(manufacturingDlg.manufacturingTxtComponent1, manufacturingDlg.manufacturingBtnComponent1, manufacturingDlg.manufacturingTxtComponentDesc1));
            itemRecordManager.addComponentFields(new FieldSearchDescription.Fields(manufacturingDlg.manufacturingTxtComponent2, manufacturingDlg.manufacturingBtnComponent2, manufacturingDlg.manufacturingTxtComponentDesc2));
            itemRecordManager.addComponentFields(new FieldSearchDescription.Fields(manufacturingDlg.manufacturingTxtComponent3, manufacturingDlg.manufacturingBtnComponent3, manufacturingDlg.manufacturingTxtComponentDesc3));
            itemRecordManager.addComponentFields(new FieldSearchDescription.Fields(manufacturingDlg.manufacturingTxtComponent4, manufacturingDlg.manufacturingBtnComponent4, manufacturingDlg.manufacturingTxtComponentDesc4));
            itemRecordManager.addComponentFields(new FieldSearchDescription.Fields(manufacturingDlg.manufacturingTxtComponent5, manufacturingDlg.manufacturingBtnComponent5, manufacturingDlg.manufacturingTxtComponentDesc5));
            itemRecordManager.addComponentFields(new FieldSearchDescription.Fields(manufacturingDlg.manufacturingTxtComponent6, manufacturingDlg.manufacturingBtnComponent6, manufacturingDlg.manufacturingTxtComponentDesc6));

            tableIO.initialize(Net7.Tables.item_manufacture.ToString(), Net7.Table_item_manufacture._item_id, Database.Database.getQueryManufacturing());

            return(tableIO);
        }
コード例 #12
0
 public void EditFind()
 {
     using (ISearchDialog dlg = dlgFactory.CreateSearchDialog())
     {
         if (uiSvc.ShowModalDialog(dlg) == DialogResult.OK)
         {
             Func <int, Program, bool> filter = GetScannedFilter(dlg);
             var re = Core.Dfa.Automaton.CreateFromPattern(dlg.Patterns.Text);
             if (re == null)
             {
                 return;
             }
             var hits = this.decompilerSvc.Decompiler.Project.Programs
                        .SelectMany(program =>
                                    program.SegmentMap.Segments.Values.SelectMany(seg =>
             {
                 return(ReMatches(program, seg, filter, re));
             }));
             srSvc.ShowAddressSearchResults(hits, new CodeSearchDetails());
         }
     }
 }
コード例 #13
0
 private Func <int, Program, bool> GetScannedFilter(ISearchDialog dlg)
 {
     if (dlg.ScannedMemory.Checked)
     {
         if (dlg.UnscannedMemory.Checked)
         {
             return((o, map) => true);
         }
         else
         {
             return (o, program) =>
                    {
                        var addr = program.SegmentMap.MapLinearAddressToAddress(
                            (ulong)
                            ((long)program.SegmentMap.BaseAddress.ToLinear() + o));
                        ImageMapItem item;
                        return program.ImageMap.TryFindItem(addr, out item) &&
                               item.DataType != null &&
                               !(item.DataType is UnknownType);
                    }
         };
     }
     else if (dlg.UnscannedMemory.Checked)
     {
         return((o, program) =>
         {
             var addr = program.SegmentMap.MapLinearAddressToAddress(
                 (uint)((long)program.SegmentMap.BaseAddress.ToLinear() + o));
             ImageMapItem item;
             return program.ImageMap.TryFindItem(addr, out item) &&
             item.DataType == null ||
             item.DataType is UnknownType;
         });
     }
     else
     {
         throw new NotSupportedException();
     }
 }
コード例 #14
0
 public Data(IWidgetModified widgetModified,
             ISearchDialog searchDialog,
             String descriptionQuery,
             String descriptionParameter,
             Enum descriptionColumn)
 {
     m_widgetModified = widgetModified;
     m_searchDialog = searchDialog;
     m_descriptionQuery = descriptionQuery;
     m_descriptionParameter = descriptionParameter;
     m_descriptionColumn = descriptionColumn;
 }
コード例 #15
0
 private void When_CreateDialog()
 {
     dlg = new SearchDialog()
     {
         Services = sc
     };
 }
コード例 #16
0
        private TableIO initializeItemManufacturing(ISearchDialog itemSearchDialog)
        {
            Net7_Tools.Gui.frmManufacturing manufacturingDlg = new Net7_Tools.Gui.frmManufacturing();
            ItemManufacturingRecordManager itemRecordManager = new ItemManufacturingRecordManager(manufacturingDlg, this);
            TableIO tableIO = new TableIO(this, itemRecordManager);
            manufacturingDlg.setTableIO(tableIO);
            DataBinding dataBinding;

            dataBinding = tableIO.bind(manufacturingDlg.manufacturingCboDifficulty, Net7.Table_item_manufacture._difficulty, "Difficulty Level");
            dataBinding.addValidation(new ValidateNumericInsideRange(1, 9));

            //dataBinding.addValidation(new ValidateInTable(Net7_db.Tables.item_base.ToString(), DB.getQueryItem(itemId));
            dataBinding = tableIO.bind(manufacturingDlg.manufacturingTxtComponent1, Net7.Table_item_manufacture._comp_1, "Component 1", false);
            dataBinding = tableIO.bind(manufacturingDlg.manufacturingTxtComponent2, Net7.Table_item_manufacture._comp_2, "Component 2", false);
            dataBinding = tableIO.bind(manufacturingDlg.manufacturingTxtComponent3, Net7.Table_item_manufacture._comp_3, "Component 3", false);
            dataBinding = tableIO.bind(manufacturingDlg.manufacturingTxtComponent4, Net7.Table_item_manufacture._comp_4, "Component 4", false);
            dataBinding = tableIO.bind(manufacturingDlg.manufacturingTxtComponent5, Net7.Table_item_manufacture._comp_5, "Component 5", false);
            dataBinding = tableIO.bind(manufacturingDlg.manufacturingTxtComponent6, Net7.Table_item_manufacture._comp_6, "Component 6", false);

            // Initialize the manufacturing difficulty levels
            manufacturingDlg.manufacturingCboDifficulty.Items.Clear();
            manufacturingDlg.manufacturingCboDifficulty.Items.AddRange(Database.Database.getItemManufacturingLevels());

            // Configure the 6 component fields, search buttons, and descriptions
            FieldSearchDescription.Data fieldSearchDescriptionData
                    = new FieldSearchDescription.Data(
                            itemRecordManager,
                            itemSearchDialog,
                            Database.Database.getQueryItem_param(),
                            DB.QueryParameterCharacter + ColumnData.GetName(Net7.Table_item_base._id),
                            Net7.Table_item_base._name);
            itemRecordManager.setFieldSearchDescriptionData(fieldSearchDescriptionData);
            itemRecordManager.addComponentFields(new FieldSearchDescription.Fields(manufacturingDlg.manufacturingTxtComponent1, manufacturingDlg.manufacturingBtnComponent1, manufacturingDlg.manufacturingTxtComponentDesc1));
            itemRecordManager.addComponentFields(new FieldSearchDescription.Fields(manufacturingDlg.manufacturingTxtComponent2, manufacturingDlg.manufacturingBtnComponent2, manufacturingDlg.manufacturingTxtComponentDesc2));
            itemRecordManager.addComponentFields(new FieldSearchDescription.Fields(manufacturingDlg.manufacturingTxtComponent3, manufacturingDlg.manufacturingBtnComponent3, manufacturingDlg.manufacturingTxtComponentDesc3));
            itemRecordManager.addComponentFields(new FieldSearchDescription.Fields(manufacturingDlg.manufacturingTxtComponent4, manufacturingDlg.manufacturingBtnComponent4, manufacturingDlg.manufacturingTxtComponentDesc4));
            itemRecordManager.addComponentFields(new FieldSearchDescription.Fields(manufacturingDlg.manufacturingTxtComponent5, manufacturingDlg.manufacturingBtnComponent5, manufacturingDlg.manufacturingTxtComponentDesc5));
            itemRecordManager.addComponentFields(new FieldSearchDescription.Fields(manufacturingDlg.manufacturingTxtComponent6, manufacturingDlg.manufacturingBtnComponent6, manufacturingDlg.manufacturingTxtComponentDesc6));

            tableIO.initialize(Net7.Tables.item_manufacture.ToString(), Net7.Table_item_manufacture._item_id, Database.Database.getQueryManufacturing());

            return tableIO;
        }
コード例 #17
0
ファイル: MainFormInteractor.cs プロジェクト: nemerle/reko
 private Func<int, Program, bool> GetScannedFilter(ISearchDialog dlg)
 {
     if (dlg.ScannedMemory.Checked)
     {
         if (dlg.UnscannedMemory.Checked)
             return (o, map) => true;
         else
             return (o, program) =>
             {
                 var addr = program.ImageMap.MapLinearAddressToAddress(
                     (ulong)
                      ((long)program.Image.BaseAddress.ToLinear() + o));
                 ImageMapItem item;
                 return program.ImageMap.TryFindItem(addr, out item)
                     && item.DataType != null &&
                     !(item.DataType is UnknownType);
             };
     }
     else if (dlg.UnscannedMemory.Checked)
     {
         return (o, program) =>
             {
                 var addr = program.ImageMap.MapLinearAddressToAddress(
                       (uint)((long) program.Image.BaseAddress.ToLinear() + o));
                 ImageMapItem item;
                 return program.ImageMap.TryFindItem(addr, out item)
                     && item.DataType == null ||
                     item.DataType is UnknownType;
             };
     }
     else
         throw new NotSupportedException();
 }
コード例 #18
0
 // TODO: Most of this code is generic for any instance of IEditor
 /// <summary>
 ///   <para>Constructor</para>
 /// </summary>
 public ItemEditor(ISearchDialog itemSearchDialog)
 {
     m_itemSearchDialog = itemSearchDialog;
 }
コード例 #19
0
        // TODO: Most of this code is generic for any instance of IEditor

        /// <summary>
        ///   <para>Constructor</para>
        /// </summary>
        public ItemEditor(ISearchDialog itemSearchDialog)
        {
            m_itemSearchDialog = itemSearchDialog;
        }
コード例 #20
0
 public void TearDown()
 {
     if (dlg != null)
         dlg.Dispose();
     dlg = null;
 }