示例#1
0
        static void Main(string[] args)
        {
            HexEditor editor = new HexEditor();
            var       bytes  = editor.GetPathBytes(@"C:\Users\hakop\OneDrive\Documents\Visual Studio 2019\Projects\HelloWorld\HelloWorld\Program.fs");
            var       hex    = editor.ConvertToHex(bytes);
            var       chars  = editor.GetLettersFromHex(hex);

            int length = hex.Length;

            for (int i = 0; i < Math.Ceiling((double)(length) / 16); i++)
            {
                var listH = hex.Take(16).ToList();
                var listC = chars.Take(16).ToList();
                hex   = hex.Skip(16).ToArray();
                chars = chars.Skip(16).ToArray();
                foreach (var h in listH)
                {
                    Console.Write($"{h} ");
                }
                Console.SetCursorPosition(60, Console.CursorTop);
                foreach (var c in listC)
                {
                    if (!char.IsControl(c))
                    {
                        Console.Write($"{c} ");
                    }
                    else
                    {
                        Console.Write(". ");
                    }
                }
                Console.WriteLine();
            }
        }
示例#2
0
            public override void OnClick(TreeView treeview)
            {
                string filePath = GetFilePath();

                if (!romfs.FileDict.ContainsKey($"/{filePath}"))
                {
                    return;
                }

                var file = romfs.FileDict[$"/{filePath}"];



                HexEditor editor = (HexEditor)LibraryGUI.GetActiveContent(typeof(HexEditor));

                if (editor == null)
                {
                    editor = new HexEditor();
                    LibraryGUI.LoadEditor(editor);
                }
                editor.Text = Text;
                editor.Dock = DockStyle.Fill;

                using (var stream = romfs.OpenFile(file).AsStream())
                {
                    var mem = new MemoryStream();
                    stream.CopyTo(mem);

                    editor.LoadData(mem.ToArray());
                }
            }
示例#3
0
        public StringByte(HexEditor parent) : base(parent)
        {
            //Default properties
            Width = 10;

            #region Binding tooltip

            LoadDictionary("/WPFHexaEditor;component/Resources/Dictionary/ToolTipDictionary.xaml");
            var txtBinding = new Binding
            {
                Source = FindResource("ByteToolTip"),
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                Mode = BindingMode.OneWay
            };

            // Load ressources dictionnary
            void LoadDictionary(string url)
            {
                var ttRes = new ResourceDictionary {
                    Source = new Uri(url, UriKind.Relative)
                };

                Resources.MergedDictionaries.Add(ttRes);
            }

            SetBinding(ToolTipProperty, txtBinding);

            #endregion
        }
示例#4
0
        private void OnGUI()
        {
            prototypeHex = (HexEditor)EditorGUILayout.ObjectField("Hex Prototype ", prototypeHex, typeof(HexEditor), true);

            GUI.enabled = false;
            hexContainer = (Transform)EditorGUILayout.ObjectField("Hex Container ", hexContainer, typeof(Transform), true);
            GUI.enabled = true;

            genType = (MapGenType)EditorGUILayout.EnumPopup("Generation Type", genType);

            switch (genType)
            {
                case MapGenType.Circle:
                    circleCount = EditorGUILayout.IntSlider("Circle count ", circleCount, 2, 20);
                    break;
            }

            if (GUILayout.Button("Generate")) Generate();

            if (GUILayout.Button("DestroyAll")) Destroy();

            if (!prototypeHex)
            {
                prototypeHex = Resources.Load<HexEditor>("Prefabs/Editor/Hex");
            }

            if (!hexContainer)
            {
                var go = GameObject.Find("Hex Container");
                if (go)
                {
                    hexContainer = go.transform;
                }
            }
        }
        protected BaseByte(HexEditor parent)
        {
            //Parent hexeditor
            _parent = parent ?? throw new ArgumentNullException(nameof(parent));

            #region Binding tooltip

            LoadDictionary("/WPFHexaEditor;component/Resources/Dictionary/ToolTipDictionary.xaml");
            var txtBinding = new Binding
            {
                Source = FindResource("ByteToolTip"),
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                Mode = BindingMode.OneWay
            };

            // Load ressources dictionnary
            void LoadDictionary(string url)
            {
                var ttRes = new ResourceDictionary {
                    Source = new Uri(url, UriKind.Relative)
                };

                Resources.MergedDictionaries.Add(ttRes);
            }

            SetBinding(ToolTipProperty, txtBinding);

            #endregion

            //Default properties
            DataContext = this;
            Focusable   = true;
        }
示例#6
0
        public void Goto(uint Offset)
        {
            //HexEditor.SetPosition(Offset, 0);
            for (int i = 0; i < Info.Length; i++)
            {
                Map_Info Current_Info = Info[i];
                uint     End          = Current_Info.Offset + Current_Info.Size;

                if (Offset >= Current_Info.Offset && Offset <= End)
                {
                    var Old_Stream = HexEditor.Stream;

                    Selected_Index        = i;
                    currentlyEditing.Text = @"Currently Editing: [" + Current_Info.Section_Name + "] - " + Current_Info.Parent_Name + @"/" + Current_Info.File_Name
                                            + " - File Offset: 0x" + Current_Info.Offset.ToString("X");
                    if (Current_Info.Data == null)
                    {
                        Current_Info.Data = File_Buffer.Skip((int)Current_Info.Offset).Take((int)Current_Info.Size).ToArray();
                    }

                    HexEditor.Stream = new MemoryStream(Current_Info.Data); // "new MemoryStream(Data)" is probably a memory leak
                    HexEditor.SetPosition(Offset - Current_Info.Offset, 0);
                    Display_Content();

                    if (Old_Stream != null)
                    {
                        Old_Stream.Dispose();
                    }
                    return;
                }
            }
        }
        public FastTextLine(HexEditor parent)
        {
            //Parent hexeditor
            _parent = parent ?? throw new ArgumentNullException(nameof(parent));

            //Default properties
            DataContext = this;

            #region Binding tooltip

            //LoadDictionary("/WPFHexaEditor;component/Resources/Dictionary/ToolTipDictionary.xaml");
            //var txtBinding = new Binding
            //{
            //    Source = FindResource("ByteToolTip"),
            //    UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
            //    Mode = BindingMode.OneWay
            //};

            //// Load ressources dictionnary
            //void LoadDictionary(string url)
            //{
            //    var ttRes = new ResourceDictionary { Source = new Uri(url, UriKind.Relative) };
            //    Resources.MergedDictionaries.Add(ttRes);
            //}

            //SetBinding(ToolTipProperty, txtBinding);

            #endregion
        }
        public FastTextLine(HexEditor parent)
        {
            //Parent hexeditor
            _parent = parent ?? throw new ArgumentNullException(nameof(parent));

            //Default properties
            DataContext = this;
        }
		internal void InternalHandleKeypress (HexEditor editor, Gdk.Key key, uint unicodeChar, Gdk.ModifierType modifier)
		{
			this.Editor = editor; 
			
			HandleKeypress (key, unicodeChar, modifier);
			
			//make sure that nothing funny goes on when the mode should have finished
			this.Editor = null;
		}
示例#10
0
        public FindWindow(HexEditor parent)
        {
            InitializeComponent();

            //Parent hexeditor for "binding" search
            _parent = parent;

            InitializeMStream();
        }
示例#11
0
 public MarginMouseEventArgs(HexEditor editor, int button, int x, int y, Gdk.EventType type, Gdk.ModifierType modifierState)
 {
     this.Editor        = editor;
     this.Button        = button;
     this.X             = x;
     this.Y             = y;
     this.Type          = type;
     this.ModifierState = modifierState;
 }
示例#12
0
        protected BaseByte(HexEditor parent)
        {
            //Parent hexeditor
            _parent = parent ?? throw new ArgumentNullException(nameof(parent));

            //Default properties
            DataContext = this;
            Focusable   = true;
        }
示例#13
0
        internal void InternalHandleKeypress(HexEditor editor, Gdk.Key key, uint unicodeChar, Gdk.ModifierType modifier)
        {
            this.Editor = editor;

            HandleKeypress(key, unicodeChar, modifier);

            //make sure that nothing funny goes on when the mode should have finished
            this.Editor = null;
        }
        public FindWindow(HexEditor parent, byte[] findData = null)
        {
            InitializeComponent();

            //Parent hexeditor for "binding" search
            _parent = parent;

            InitializeMStream(findData);
        }
示例#15
0
        private HexEditor CreateHexEditor(byte[] data, EventHandler <byte[]> saveHandler)
        {
            var editor = new HexEditor();

            editor.Width = 700;
            editor.LoadData(data);
            editor.SaveData += saveHandler;

            return(editor);
        }
示例#16
0
        private void StructListView_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (StructListView.Items.Count == 0)
            {
                return;
            }

            var item = (StructListItem)StructListView.Items[StructListView.SelectedIndex];

            HexEditor.Select(item.offset, item.typeLength);
        }
示例#17
0
        public MapGenerator(HexEditor prototype, int circleCount)
        {
            this.prototype = prototype;
            this.container = new GameObject("Hex Container").transform;
            this.circleCount = circleCount;

            r = HexInfo.R;
            a = HexInfo.A;

            hexMap = new Dictionary<int, HexEditor>();
        }
        /// <summary>
        /// Initialize stream and hexeditor
        /// </summary>
        private void InitializeMStream(HexEditor hexeditor, byte[] findData = null)
        {
            hexeditor.CloseProvider();

            var ms = new MemoryStream(1);

            if (findData is not null && findData.Length > 0)
            {
                foreach (byte b in findData)
                {
                    ms.WriteByte(b);
                }
            }
示例#19
0
        public override void AddRedraw(HexEditor editor)
        {
            Margin margin = editor.Margins.FirstOrDefault(m => m.GetType() == MarginType);

            if (margin != null)
            {
                editor.RepaintMarginArea(margin,
                                         margin.XOffset,
                                         (int)(Line * editor.LineHeight - editor.HexEditorData.VAdjustment.Value),
                                         margin.Width,
                                         editor.LineHeight);
            }
        }
示例#20
0
            private void ShowHexView()
            {
                HexEditor editor = (HexEditor)LibraryGUI.GetActiveContent(typeof(HexEditor));

                if (editor == null)
                {
                    editor = new HexEditor();
                    LibraryGUI.LoadEditor(editor);
                }
                editor.Text = Text;
                editor.Dock = DockStyle.Fill;
                editor.LoadData(Data);
            }
示例#21
0
        private void StructListView_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (StructListView.Items.Count == 0)
            {
                return;
            }

            var item = (StructListItem)StructListView.Items[StructListView.SelectedIndex];

            HexEditor.SetPosition(item.offset);
            HexEditor.SelectionStart = item.offset;
            HexEditor.SelectionStop  = item.offset + item.typeLength;
        }
示例#22
0
        private List<HexEditor> BuildAround(HexEditor hex)
        {
            List<HexEditor> hexes = new List<HexEditor>();

            foreach (var index in HexInfo.GetCircumIndices(hex.Index))
                if (!hexMap.ContainsKey(index))
                {
                    var builtHex = CreateHex(index);
                    hexes.Add(builtHex);
                }

            return hexes;
        }
示例#23
0
            public override void OnClick(TreeView treeView)
            {
                HexEditor editor = (HexEditor)LibraryGUI.Instance.GetActiveContent(typeof(HexEditor));

                if (editor == null)
                {
                    editor = new HexEditor();
                    LibraryGUI.Instance.LoadEditor(editor);
                }
                editor.Text = Text;
                editor.Dock = DockStyle.Fill;
                editor.LoadData(DecompressBlock());
            }
示例#24
0
        private void UpdateEditor()
        {
            HexEditor editor = (HexEditor)LibraryGUI.Instance.GetActiveContent(typeof(HexEditor));

            if (editor == null)
            {
                editor      = new HexEditor();
                editor.Dock = DockStyle.Fill;
                LibraryGUI.Instance.LoadEditor(editor);
            }
            editor.Text = Text;
            editor.LoadData(Data);
        }
示例#25
0
        public override void OnClick(TreeView treeview)
        {
            HexEditor editor = (HexEditor)LibraryGUI.GetActiveContent(typeof(HexEditor));

            if (editor == null)
            {
                editor = new HexEditor();
                LibraryGUI.LoadEditor(editor);
            }
            editor.Text = Text;
            editor.Dock = DockStyle.Fill;
            editor.LoadData(DecryptedTable);
        }
        /// <summary>
        /// Test of adding somes byte
        ///
        /// IN DEVELOPMENT, NOT WORKING PROPRELY :)
        /// </summary>
        private void AddByteButton_Click(object sender, RoutedEventArgs e) =>
        HexEditor.With(c =>
        {
            c.InsertByte(255, 15);
            c.InsertByte(255, 16);
            c.InsertByte(255, 17);
            c.InsertByte(255, 18);
            c.InsertByte(255, 19);
            c.InsertByte(255, 20);
            c.InsertByte(255, 21);

            //Actually the visual not show the result. I'm working on this :)
            c.RefreshView();
        });
示例#27
0
 public override void OnClick(TreeView treeview)
 {
     if (UnknownData != null && UnknownData.Length > 0)
     {
         HexEditor editor = (HexEditor)LibraryGUI.GetActiveContent(typeof(HexEditor));
         if (editor == null)
         {
             editor = new HexEditor();
             LibraryGUI.LoadEditor(editor);
         }
         editor.Text = Text;
         editor.Dock = DockStyle.Fill;
         editor.LoadData(UnknownData);
         editor.SaveData += (object sender, byte[] data) => this.UnknownData = data;
     }
 }
示例#28
0
        private void RelView_Item_Clicked(int Index)
        {
            Selected_Index = Index;
            Map_Info This_Info = Info[Index];

            currentlyEditing.Text = @"Currently Editing: [" + This_Info.Section_Name + "] - " + This_Info.Parent_Name + @"/" + This_Info.File_Name
                                    + " - File Offset: 0x" + This_Info.Offset.ToString("X");
            if (This_Info.Data == null)
            {
                This_Info.Data = File_Buffer.Skip((int)This_Info.Offset).Take((int)This_Info.Size).ToArray();
            }

            HexEditor.Stream = new MemoryStream(This_Info.Data); // "new MemoryStream(Data)" is probably a memory leak
            HexEditor.SetPosition(0, 0);
            Display_Content();
        }
示例#29
0
        private void AddTab(EFTB.NodeBase node)
        {
            var tab = new TabPage(node.Signature);

            if (node is EFTB.CADP)
            {
                tab.Controls.Add(CreateCADPEditor((EFTB.CADP)node));
            }
            else if (node.UnknownData != null && node.UnknownData.Length > 0)
            {
                var hexEditor = new HexEditor();
                hexEditor.Dock = DockStyle.Fill;
                hexEditor.LoadData(node.UnknownData);
                tab.Controls.Add(hexEditor);
            }
            stTabControl1.TabPages.Add(tab);
        }
示例#30
0
        internal static void ShowHexEditor(Form1 form)
        {
            CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(form.pagesTabControl.SelectedTabPage);

            if (String.IsNullOrEmpty(pageTextBox.Text))
            {
                ShowInfoBox(form, LanguageUtil.GetCurrentLanguageString("TextEmpty", className));
                return;
            }

            HexEditor hexEditor = new HexEditor {
                Owner = form
            };

            hexEditor.InitializeForm();
            hexEditor.Show(form);
        }
        private void OpenFile(HexEditor hexEditor)
        {
            ClearUI();

            #region Create file dialog
            var fileDialog = new OpenFileDialog
            {
                Multiselect     = true,
                CheckFileExists = true
            };

            if (fileDialog.ShowDialog() == null || !File.Exists(fileDialog.FileName))
            {
                return;
            }
            #endregion

            hexEditor.FileName = fileDialog.FileName;
        }
示例#32
0
        private Control CreateCADPEditor(EFTB.CADP cadp)
        {
            var panel = new FlowLayoutPanel();

            panel.Dock          = DockStyle.Fill;
            panel.FlowDirection = FlowDirection.TopDown;
            var label = new Label();

            label.Text = "Shape";
            panel.Controls.Add(label);
            foreach (EFTB.CADP.Shape flag in Enum.GetValues(typeof(EFTB.CADP.Shape)))
            {
                var checkbox = new CheckBox();
                checkbox.Text            = Enum.GetName(typeof(EFTB.CADP.Shape), flag);
                checkbox.Checked         = cadp.ShapeFlag.HasFlag(flag);
                checkbox.CheckedChanged += (object sender, EventArgs e) =>
                {
                    if (checkbox.Checked)
                    {
                        cadp.ShapeFlag |= flag;
                    }
                    else
                    {
                        cadp.ShapeFlag &= ~flag;
                    }
                };
                panel.Controls.Add(checkbox);
            }
            var hexEditor = new HexEditor();

            hexEditor.Width = 700;
            // hexEditor.Dock = DockStyle.Fill;
            hexEditor.LoadData(cadp.UnknownData);
            hexEditor.SaveData += (object sender, byte[] data) => cadp.UnknownData = data;
            panel.Controls.Add(hexEditor);

            return(panel);
        }
        private void DisplayInformation(ManifestChunk chunk)
        {
            ByteStartOffsetBox.Text = chunk.Offset.ToString();
            ByteEndOffsetBox.Text   = chunk.EndOffset.ToString();
            ByteSizeBox.Text        = chunk.Size.ToString();
            AnonByteBox.Text        = chunk.Extra.ToString();
            NameLabel.Text          = chunk.Name;
            ColorDisplay.Background = FileMapBorders[chunk].Background;
            OpenChunk = chunk;
            var path = System.IO.Path.Combine(DestinationBox.Text, chunk.Name);

            if (File.Exists(path))
            {
                OpenFileButton.IsEnabled = true;
                HexEditor.FileName       = path;
            }
            else
            {
                OpenFileButton.IsEnabled = false;
                HexEditor.CloseProvider();
            }
            Title = $"MV - Viewing {chunk.Name}";
        }
		public DashedLineMargin (HexEditor hexEditor) : base (hexEditor)
		{
		}
		public GutterMargin (HexEditor hexEditor) : base (hexEditor)
		{
		}
示例#36
0
		public TextEditorMargin (HexEditor hexEditor) : base (hexEditor)
		{
		}
示例#37
0
		public MarginMouseEventArgs (HexEditor editor, Margin margin, ButtonEventArgs args)
		{
			this.Editor = editor;
			this.margin = margin;
			this.Args = args;
		}
示例#38
0
		/*
		protected Gdk.Cursor cursor = null;
		
		public Gdk.Cursor MarginCursor {
			get {
				return cursor;
			}
		}*/
		
		protected Margin (HexEditor hexEditor)
		{
			this.Editor = hexEditor;
			IsVisible = true;
		}
示例#39
0
		public MarginMouseMovedEventArgs (HexEditor editor, Margin margin, MouseMovedEventArgs args)
		{
			this.margin = margin;
			this.Editor = editor;
			this.Args = args;
		}
示例#40
0
		public EmptySpaceMargin (HexEditor hexEditor) : base (hexEditor)
		{
		}
示例#41
0
		public IconMargin  (HexEditor hexEditor) : base (hexEditor)
		{
		}
示例#42
0
 public EmptySpaceMargin(HexEditor hexEditor) : base(hexEditor)
 {
 }
		public MarginMouseEventArgs (HexEditor editor, int button, int x, int y, Gdk.EventType type, Gdk.ModifierType modifierState)
		{
			this.Editor = editor;
			this.Button = button;
			this.X = x;
			this.Y = y;
			this.Type = type;
			this.ModifierState = modifierState;
		}