/// <summary>
        /// Loads a file and displays the hex in the text editor
        /// </summary>
        /// <param name="pathToFile">The full path to the file to load</param>
        private async Task LoadFileAndDisplayHex(string pathToFile)
        {
            HexViewer.Clear();

            byte[] fileBytes = await new FileLoader().LoadFile(pathToFile);
            HexViewer.AppendText(new HexBuilder().BuildHex(fileBytes));
        }
Beispiel #2
0
        public MDTablesStreamView()
        {
            var split = new SplitContainer {
                Orientation = Orientation.Horizontal,
                Dock        = DockStyle.Fill
            };

            Controls.Add(split);

            gridView = new GridView();
            gridView.AddColumn(new GridView.Column("Field", true, 120));
            gridView.AddColumn(new GridView.Column("Offset", true));
            gridView.AddColumn(new GridView.Column("Value", false, 150));
            split.Panel1.Controls.Add(gridView);

            hexView = new HexViewer();
            split.Panel2.Controls.Add(hexView);

            PerformLayout();

            hexView.ContextMenuStrip.Items.Add(new ToolStripSeparator());
            var nav = new ToolStripMenuItem("Show in Raw Data");

            nav.Click += OnShowData;
            hexView.ContextMenuStrip.Items.Add(nav);
        }
Beispiel #3
0
        public static void AddHighLights(this HexViewer hexView, List <Tuple <uint, uint> > ranges, Color colorA, Color colorB)
        {
            var currentColor = Color.Empty;

            foreach (var range in ranges)
            {
                currentColor = (currentColor == colorA ? colorB : colorA);
                hexView.AddHighLight(new HexViewer.HighLight(currentColor, range.Item1, range.Item2));
            }
        }
        private void AddPost(HexViewer control, int index, int length, int sourceIndex, bool isPrimary)
        {
            control.AddRange(new HexViewer.ByteGroup
            {
                Start     = index,
                Length    = 1,
                BackColor = isPrimary ? Color.DarkBlue : Color.Gray,
                ForeColor = Color.White,
                Type      = "Row",
                Pointer   = sourceIndex
            }); // row

            control.AddRange(new HexViewer.ByteGroup
            {
                Start     = index + 1,
                Length    = 1,
                BackColor = Color.MediumBlue,
                ForeColor = Color.White,
                Type      = "Length",
                Pointer   = index
            }); // length

            if (length != 255)
            {
                control.AddRange(new HexViewer.ByteGroup
                {
                    Start     = index + 2,
                    Length    = 1,
                    BackColor = Color.Black,
                    ForeColor = Color.White,
                    Type      = "Unused",
                    Pointer   = index
                }); // dead pixel?

                control.AddRange(new HexViewer.ByteGroup
                {
                    Start     = index + 3,
                    Length    = length,
                    BackColor = Color.LightSkyBlue,
                    ForeColor = Color.Black,
                    Type      = "Palette Index",
                    Pointer   = index
                }); // pixels

                control.AddRange(new HexViewer.ByteGroup
                {
                    Start     = index + 4 + length - 1,
                    Length    = 1,
                    BackColor = Color.Black,
                    ForeColor = Color.White,
                    Type      = "Unused",
                    Pointer   = index
                }); // dead pixel?
            }
        }
Beispiel #5
0
        public MDStreamView()
        {
            viewer = new HexViewer();
            Controls.Add(viewer);

            viewer.ContextMenuStrip.Items.Add(new ToolStripSeparator());
            var nav = new ToolStripMenuItem("Show in Raw Data");

            nav.Click += OnShowData;
            viewer.ContextMenuStrip.Items.Add(nav);
        }
Beispiel #6
0
        private static void Main(string[] args)
        {
            var rand  = new Random();
            var bytes = new byte[rand.Next(50, 100)];

            rand.NextBytes(bytes);
            Console.WriteLine(HexViewer.GetHexStringFormatted(bytes, 16));
            Console.WriteLine("{0}{0}", Environment.NewLine);
            HexViewer.View(bytes, 0, bytes.Length, false);
            Console.ReadLine();
        }
 private void AddColumnEndMarker(HexViewer control, int start, int source)
 {
     control.AddRange(new HexViewer.ByteGroup
     {
         Start     = start,
         Length    = 1,
         BackColor = Color.OrangeRed,
         ForeColor = Color.White,
         Type      = "End Of Column",
         Pointer   = source
     }); // end of column
 }
        public MDTableHeapView()
        {
            var split1 = new SplitContainer {
                Orientation = Orientation.Vertical,
                Dock        = DockStyle.Fill
            };

            Controls.Add(split1);

            // Since App property isn't initialized in this moment,
            // a callback is setup to initialize treeview later.
            initTreeView = () => {
                treeView = new TreeViewX(App)
                {
                    Dock = DockStyle.Fill
                };
                treeView.AfterSelect     += OnNodeSelected;
                treeView.ContextMenuStrip = GetContextMenu();
                split1.Panel1.Controls.Add(treeView);
            };

            var split2 = new SplitContainer {
                Orientation = Orientation.Horizontal,
                Dock        = DockStyle.Fill
            };

            split1.Panel2.Controls.Add(split2);

            gridView = new GridView();
            gridView.AddColumn(new GridView.Column("Field", true, 120));
            gridView.AddColumn(new GridView.Column("Type", true, 130));
            gridView.AddColumn(new GridView.Column("Offset", true));
            gridView.AddColumn(new GridView.Column("Value", false));
            gridView.AddColumn(new GridView.Column("Description", false, 200));
            split2.Panel1.Controls.Add(gridView);

            hexView = new HexViewer();
            split2.Panel2.Controls.Add(hexView);

            PerformLayout();

            hls = new Dictionary <Table, HexViewer.HighLight[]>();

            hexView.ContextMenuStrip.Items.Add(new ToolStripSeparator());
            var nav = new ToolStripMenuItem("Show in Raw Data");

            nav.Click += OnShowData;
            hexView.ContextMenuStrip.Items.Add(nav);

            followInHex = false;
        }
Beispiel #9
0
        // Load Main MDI form
        private void MainForm_Load(object sender, System.EventArgs e)
        {
            // Create new machine
            machine  = new Machine();
            mBuilder = new MachineBuilder(machine);
            mBuilder.LoadMachine("machine.xml");

            // Create hex viewer form
            hexview = new HexViewer(machine.mem)
            {
                MdiParent = this
            };

            // Create memory viewer form
            memview = new MemViewer(machine.mem)
            {
                MdiParent = this
            };

            // Create disassembly viewer form
            dasmview = new DisasmViewer(machine.mem, machine.cpu)
            {
                MdiParent = this
            };

            // Create line assembler form
            lineasm = new LineAsm(machine.mem, machine.cpu)
            {
                MdiParent = this
            };

            // Create cpu register viewer form
            cpuview = new CPUViewer(machine.cpu)
            {
                MdiParent = this
            };
            cpuview.Unlock();

            // Setup run timer
            runmode  = RunModes.stopped;
            rundelay = new Timer
            {
                Enabled  = false,
                Interval = runspeeds[6]
            };
            rundelay.Tick += new EventHandler(rundelay_Tick);

            RestoreFormPositions();
            this.Show();
        }
Beispiel #10
0
        public FormMain(SCIPackage package, SCIPackage translate)
        {
            _package   = package;
            _translate = translate;

            InitializeComponent();

            Text = package.GameDirectory;

            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);

            sc.Panel2.Controls.Add(hexViewer  = new HexViewer());
            sc.Panel2.Controls.Add(textViewer = new TextViewer());
            sc.Panel2.Controls.Add(fontView   = new FontView());
            sc.Panel2.Controls.Add(scriptView = new ScriptView());
            sc.Panel2.Controls.Add(vocabView  = new VocabView());
            sc.Panel2.Controls.Add(msgView    = new MsgView());
            sc.Panel2.Controls.Add(picView    = new PicView());

            foreach (ResType resType in Enum.GetValues(typeof(ResType)))
            {
                var resources = package.GetResources(resType);
                if (!resources.Any())
                {
                    continue;
                }

                TreeNode tnRes = tv.Nodes.Add(ResTypeName(resType));
                tnRes.ImageKey         = "folder";
                tnRes.SelectedImageKey = tnRes.ImageKey;

                foreach (var res in resources)
                {
                    TreeNode tnRec = tnRes.Nodes.Add(res.ToString());
                    tnRec.ImageKey         = ResTypeKey(resType);
                    tnRec.SelectedImageKey = tnRec.ImageKey;
                    tnRec.Tag = res;
                }
            }

            if (_translate == null)
            {
                tsbTranslated.Checked = false;
                tsbTranslated.Visible = false;
                tsbSave.Visible       = false;
            }
        }
Beispiel #11
0
        public MetaDataView()
        {
            var split1 = new SplitContainer {
                Orientation = Orientation.Horizontal,
                Dock        = DockStyle.Fill
            };

            Controls.Add(split1);

            var split2 = new SplitContainer {
                Orientation = Orientation.Vertical,
                Dock        = DockStyle.Fill
            };

            split1.Panel1.Controls.Add(split2);

            hdrGridView = new GridView();
            hdrGridView.AddColumn(new GridView.Column("Field", true, 120));
            hdrGridView.AddColumn(new GridView.Column("Offset", true));
            hdrGridView.AddColumn(new GridView.Column("Value", false));
            split2.Panel1.Controls.Add(hdrGridView);

            strGridView = new GridView();
            strGridView.AddColumn(new GridView.Column("Offset", false));
            strGridView.AddColumn(new GridView.Column("Size", false));
            strGridView.AddColumn(new GridView.Column("Name", false));
            strGridView.SelectionChanged += OnStreamSelectionChanged;
            split2.Panel2.Controls.Add(strGridView);

            hexView = new HexViewer();
            split1.Panel2.Controls.Add(hexView);

            PerformLayout();

            split2.SplitterDistance = split2.Width / 2;

            hexView.ContextMenuStrip.Items.Add(new ToolStripSeparator());
            var nav = new ToolStripMenuItem("Show in Raw Data");

            nav.Click += OnShowData;
            hexView.ContextMenuStrip.Items.Add(nav);
        }
Beispiel #12
0
        private void StartHexViewer()
        {
            if (m_currentfile != "")
            {
                dockManager1.BeginUpdate();
                try
                {
                    DockPanel dockPanel;
                    //= dockManager1.AddPanel(DevExpress.XtraBars.Docking.DockingStyle.Right);
                    if (!m_appSettings.NewPanelsFloating)
                    {
                        dockPanel = dockManager1.AddPanel(DockingStyle.Right);
                    }
                    else
                    {
                        System.Drawing.Point floatpoint = this.PointToClient(new System.Drawing.Point(dockSymbols.Location.X + dockSymbols.Width + 30, dockSymbols.Location.Y + 10));
                        dockPanel = dockManager1.AddPanel(floatpoint);
                    }

                    dockPanel.Text = "Hexviewer: " + Path.GetFileName(m_currentfile);
                    HexViewer hv = new HexViewer();
                    hv.Issramviewer = false;
                    hv.Dock = DockStyle.Fill;
                    dockPanel.Width = 580;
                    hv.LoadDataFromFile(m_currentfile, m_symbols);
                    dockPanel.ClosedPanel += new DockPanelEventHandler(dockPanel_ClosedPanel);
                    dockPanel.Controls.Add(hv);
                }
                catch (Exception E)
                {
                    logger.Debug(E.Message);
                }
                dockManager1.EndUpdate();
            }
        }
 /// <summary>
 /// Initializes a new instance of BuildInContextMenu class.
 /// </summary>
 /// <param name="hexBox">the HexBox control</param>
 internal BuiltInContextMenu(HexBox hexBox, HexViewer viewer)
 {
     _hexBox    = hexBox;
     _hexViewer = viewer;
     _hexBox.ByteProviderChanged += new EventHandler(HexBox_ByteProviderChanged);
 }
Beispiel #14
0
 public HexViewerViewModel(IContainerExtension container) : base(container)
 {
     Model = new EmptyModel();
     View  = new HexViewer();
 }
Beispiel #15
0
 public string ToHexString()
 {
     return(HexViewer.GetHexString(Data));
 }
        public void AddRanges(HexViewer control, byte[] buffer)
        {
            control.Clear();

            if (buffer.Length > 8)
            {
                int[] pointer;
                short width;
                short height;

                width  = WordHelpers.GetInt16Le(buffer, 0);
                height = WordHelpers.GetInt16Le(buffer, 2);

                // do some basic sanity checking
                if (width > 0 && width <= 320 && height > 0 && height <= 200)
                {
                    control.AddRange(0, 2, Color.MediumSeaGreen, Color.White, "Width"); // width
                    control.AddRange(2, 2, Color.SeaGreen, Color.White, "Height");      // height
                    control.AddRange(4, 2, Color.DeepPink, Color.White, "X-Offset");    // x offset
                    control.AddRange(6, 2, Color.HotPink, Color.White, "Y-Offset");     // y offset

                    pointer = new int[width];

                    for (int i = 0; i < width; i++)
                    {
                        int index;

                        index      = 8 + (i * 4);
                        pointer[i] = WordHelpers.GetInt32Le(buffer, index);

                        control.AddRange(new HexViewer.ByteGroup
                        {
                            Start     = index,
                            Length    = 4,
                            ForeColor = Color.White,
                            BackColor = Color.Orange,
                            Pointer   = pointer[i],
                            Type      = "Pointer #" + i.ToString()
                        }); // column pointer
                    }

                    for (int i = 0; i < width; i++)
                    {
                        int  index;
                        byte length;
                        int  sourceIndex;

                        index       = pointer[i];
                        length      = buffer[index + 1];
                        sourceIndex = 8 + (i * 4);

                        // post
                        if (_showPrimaryPosts)
                        {
                            this.AddPost(control, index, length, sourceIndex, true);
                        }

                        if (length != 255)
                        {
                            index = this.IncrementColumn(buffer, index + 3, length);
                            //index += length + 4; // row, length, 2xunused, pixel data

                            if (buffer[index] == 255)
                            {
                                this.AddColumnEndMarker(control, index, pointer[i]);
                            }
                            else
                            {
                                while (true)
                                {
                                    length = buffer[index + 1];

                                    if (length == 255 || index + length + 4 > buffer.Length)
                                    {
                                        break;
                                    }
                                    else if (_showSecondaryPosts)
                                    {
                                        this.AddPost(control, index, length, sourceIndex, false);
                                    }

                                    index = this.IncrementColumn(buffer, index + 3, length);
                                    //  index += length + 4;

                                    if (buffer[index] == 255)
                                    {
                                        this.AddColumnEndMarker(control, index, pointer[i]);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            control.Invalidate();
        }
Beispiel #17
0
 public RawDataView()
 {
     viewer = new HexViewer();
     Controls.Add(viewer);
 }