コード例 #1
0
        public frmEditRelocation(uint oldAddress, Relocations.BASE_RELOCATION_TYPE oldType)
        {
            InitializeComponent();

            this.oldAddress = oldAddress;

            txtAddress.Text = oldAddress.ToString("X8");
            cboType.SelectedIndex = (int)oldType - 1;
        }
コード例 #2
0
        private void mnuMainFileOpen_Click(object sender, EventArgs e)
        {
            string path = "";

            if (!string.IsNullOrEmpty(argPath))
            {
                path = argPath;
                argPath = "";
            }
            else
            {
                dlgOpen.Title = "Select an executable file";
                dlgOpen.Filter = "Executable (*.exe)|*.exe" +
                      "|Dynamic Link Library (*.dll)|*.dll" +
                      "|Drivers (*.sys)|*.sys" +
                      "|Windows Visual Style (*.msstyles)|*.msstyles" +
                      "|Configuration Panel Widget (*.cpl)|*.cpl" +
                      "|ActiveX Library (*.ocx)|*.ocx" +
                      "|ActiveX Cache Library (*.oca)|*.oca" +
                      "|Multi User Interface (*.mui)|*.mui" +
                      "|Codecs (*.acm, *.ax)|*.acm;*.ax" +
                      "|Borland / Delphi Library (*.bpl, *.dpl)|*.bpl;*.dpl" +
                      "|Screensaver (*.scr)|*.scr" +
                      "|All Executables (*.exe, *.dll, *.sys, *.msstyles, *.cpl, *.ocx, *.oca, *.mui, *.acm, *.ax, *.bpl, *.dpl, *.scr)|*.exe;*.dll;*.sys;*.msstyles;*.cpl;*.ocx;*.oca;*.mui;*.acm;*.ax;*.bpl;*.dpl;*.scr" +
                      "|All Files (*.*)|*.*";

                if (dlgOpen.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                    return;

                path = dlgOpen.FileName;
            }

            try
            {
                rel = new Relocations(path);

                this.Text = "Relocation Section Editor - " + rel.GetPath();

                RefreshData();

                cmnuPages.Enabled = true;
                cmnuRelocations.Enabled = true;
                mnuMainFileSaveAs.Enabled = true;
                mnuMainFileSave.Enabled = true;
            }
            catch (FileNotFoundException)
            {
                MessageBox.Show("File not found");
            }
            catch (InvalidOperationException ex)
            {
                switch (ex.Message)
                {
                    case "MZ":
                        MessageBox.Show("MZ Header not found");
                        break;
                    case "PE":
                        MessageBox.Show("PE Header not found");
                        break;
                    case "X86":
                        MessageBox.Show("Is not a 32bits executable");
                        break;
                    case "RAW":
                        MessageBox.Show("No relocation table in this file");
                        break;
                    default:
                        MessageBox.Show("Unknown error");
                        break;
                }
            }
        }
コード例 #3
0
        private void mnuMainFileOpen_Click(object sender, EventArgs e)
        {
            string path = "";

            if (!string.IsNullOrEmpty(argPath))
            {
                path    = argPath;
                argPath = "";
            }
            else
            {
                dlgOpen.Title  = "Select an executable file";
                dlgOpen.Filter = "Executable (*.exe)|*.exe" +
                                 "|Dynamic Link Library (*.dll)|*.dll" +
                                 "|Drivers (*.sys)|*.sys" +
                                 "|Windows Visual Style (*.msstyles)|*.msstyles" +
                                 "|Configuration Panel Widget (*.cpl)|*.cpl" +
                                 "|ActiveX Library (*.ocx)|*.ocx" +
                                 "|ActiveX Cache Library (*.oca)|*.oca" +
                                 "|Multi User Interface (*.mui)|*.mui" +
                                 "|Codecs (*.acm, *.ax)|*.acm;*.ax" +
                                 "|Borland / Delphi Library (*.bpl, *.dpl)|*.bpl;*.dpl" +
                                 "|Screensaver (*.scr)|*.scr" +
                                 "|All Executables (*.exe, *.dll, *.sys, *.msstyles, *.cpl, *.ocx, *.oca, *.mui, *.acm, *.ax, *.bpl, *.dpl, *.scr)|*.exe;*.dll;*.sys;*.msstyles;*.cpl;*.ocx;*.oca;*.mui;*.acm;*.ax;*.bpl;*.dpl;*.scr" +
                                 "|All Files (*.*)|*.*";

                if (dlgOpen.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }

                path = dlgOpen.FileName;
            }

            try
            {
                rel = new Relocations(path);

                this.Text = "Relocation Section Editor - " + rel.GetPath();

                RefreshData();

                cmnuPages.Enabled         = true;
                cmnuRelocations.Enabled   = true;
                mnuMainFileSaveAs.Enabled = true;
                mnuMainFileSave.Enabled   = true;
            }
            catch (FileNotFoundException)
            {
                MessageBox.Show("File not found");
            }
            catch (InvalidOperationException ex)
            {
                switch (ex.Message)
                {
                case "MZ":
                    MessageBox.Show("MZ Header not found");
                    break;

                case "PE":
                    MessageBox.Show("PE Header not found");
                    break;

                case "X86":
                    MessageBox.Show("Is not a 32bits executable");
                    break;

                case "RAW":
                    MessageBox.Show("No relocation table in this file");
                    break;

                default:
                    MessageBox.Show("Unknown error");
                    break;
                }
            }
        }