### Info command examples Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Tools/whfmt.Validate/README.md Examples for inspecting format metadata. ```bash # Show ZIP format metadata whfmt info zip # Show PE32 format in JSON (includes AI hints, forensic risk, technical details) whfmt info pe32 --json # Look up by extension whfmt info .docx ``` -------------------------------- ### Build, Package, and Install Plugin CLI Commands Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/wiki/Plugin-System.md Commands to build the plugin project, package it into a .whxplugin archive, and install it using the plugin installer. ```bash # Build the plugin dotnet build MyPlugin.csproj -c Release # Package into .whxplugin (ZIP archive with manifest + DLL) whxpack --input bin/Release/net8.0-windows --output MyPlugin.whxplugin # Install (silent mode for CI) WpfHexEditor.PluginInstaller.exe --file MyPlugin.whxplugin --silent ``` -------------------------------- ### Build, Package, and Install Commands Source: https://github.com/abbaye/wpfhexeditoride/wiki/Plugin-System CLI commands for building the project, packaging it into a .whxplugin file, and installing it silently. ```bash # Build dotnet build MyPlugin.csproj -c Release # Package → .whxplugin (ZIP with manifest + DLL) whxpack --input bin/Release/net8.0-windows --output MyPlugin.whxplugin # Install (silent for CI) WpfHexEditor.PluginInstaller.exe --file MyPlugin.whxplugin --silent ``` -------------------------------- ### List formats examples Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Tools/whfmt.Validate/README.md Examples for listing supported formats with filtering and JSON output. ```bash # List all supported formats grouped by category whfmt list # List all game formats whfmt list --category Game # Search for anything related to "zip" whfmt list --search zip # JSON output for scripting whfmt list --category Executables --json ``` -------------------------------- ### List command examples Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Tools/whfmt.CodeGen/whfmt-CodeGen-guide.md Examples of filtering the list of available binary formats. ```bash whfmt-codegen list # all binary formats whfmt-codegen list --category Archives whfmt-codegen list --search png ``` -------------------------------- ### Install and verify whfmt.CodeGen Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Tools/whfmt.CodeGen/whfmt-CodeGen-guide.md Install the tool globally using the .NET CLI and verify the installation by displaying the help menu. ```bash dotnet tool install --global whfmt.CodeGen --version 1.1.2 # verify whfmt-codegen --help ``` -------------------------------- ### LIFO Insertion Logic Example Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/architecture/HexEditorArchitecture.md Step-by-step example showing how multiple insertions at the same physical position are handled in LIFO order. ```text Step 1: Insert A at physical 100 _insertedBytes[100] = [InsertedByte(A, offset=0)] Step 2: Insert B at physical 100 Shift existing offsets: A.offset = 1 Prepend new byte: _insertedBytes[100] = [B(offset=0), A(offset=1)] Step 3: Insert C at physical 100 Shift: B.offset=1, A.offset=2 Prepend: [C(offset=0), B(offset=1), A(offset=2)] Result Array: Index: [0] [1] [2] Value: C B A VirtualOffset: 0 1 2 Order: newest oldest ``` -------------------------------- ### Bookmarks Example Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/ApiReference.md Demonstrates finding markers, setting bookmarks, and navigating between them. ```csharp var hexEditor = new HexEditor { AllowBookmark = true }; hexEditor.OpenFile(@"C:\data\log.bin"); // Find all "START" markers and bookmark them string marker = "START"; byte[] markerBytes = System.Text.Encoding.ASCII.GetBytes(marker); List positions = hexEditor.FindAll(markerBytes); foreach (long position in positions) { hexEditor.SetBookmark(position); } Console.WriteLine($"Set {positions.Count} bookmarks"); // Navigate through bookmarks while (hexEditor.NavigateToNextBookmark()) { Console.WriteLine($"Bookmark at 0x{hexEditor.SelectionStart:X}"); } ``` -------------------------------- ### Generate command examples Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Tools/whfmt.CodeGen/whfmt-CodeGen-guide.md Various usage examples for generating parsers with different configurations and languages. ```bash # Default C# parser to stdout whfmt-codegen generate PNG # C# parser to file, with validation + async whfmt-codegen generate PNG -n MyApp.Parsers -c PngReader \ --validate --async -o PngReader.cs # Zero-alloc Span parser whfmt-codegen generate ZIP --lang span -o ZipParser.cs # F# discriminated unions whfmt-codegen generate BMP --lang fsharp -o Bmp.fs # Rust struct whfmt-codegen generate GIF --lang rust -o gif.rs # VB.NET class whfmt-codegen generate DDS --lang vb -o DdsParser.vb # Full multi-file C# project whfmt-codegen generate PNG --project ./PngLib --validate --async # Generate from a local .whfmt instead of the catalog whfmt-codegen generate ./Custom.whfmt -n Custom -c CustomParser ``` -------------------------------- ### Run Rider/SimpleExample Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Samples/README.md Command to execute the minimal JetBrains Rider-focused example from the terminal. ```bash cd Sources/Samples/Rider/SimpleExample dotnet run ``` -------------------------------- ### Enable Scope Guides Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Editors/WpfHexEditor.Editor.CodeEditor/WpfCodeEditor-guide.md Configuration for displaying scope guides, rainbow coloring, and bracket pair colorization. ```csharp Editor.PrimaryEditor.ShowScopeGuides = true; Editor.PrimaryEditor.RainbowScopeGuidesEnabled = true; // depth-colored guides Editor.PrimaryEditor.BracketPairColorizationEnabled = true; ``` -------------------------------- ### Install whfmt.Validate globally Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Tools/whfmt.Validate/README.md Install the tool globally using the .NET CLI. ```bash dotnet tool install -g whfmt.Validate ``` -------------------------------- ### Dump command examples Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Tools/whfmt.CodeGen/whfmt-CodeGen-guide.md Examples of inspecting binary files using the dump command. ```bash whfmt-codegen dump golden.png whfmt-codegen dump -f BMP unknown.bin whfmt-codegen dump --verbose --hex tiny.dds ``` -------------------------------- ### Install whfmt.Validate global tool Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Tools/whfmt.Validate/whfmt-Validate-guide.md Installs the tool globally and verifies the installation by displaying the help menu. Note that the command is named whfmt. ```bash dotnet tool install --global whfmt.Validate --version 1.0.0 # command is named `whfmt` (not `whfmt-validate`) whfmt --help ``` -------------------------------- ### PhysicalToVirtual Example Layout Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/architecture/HexEditorArchitecture.md A concrete example showing how physical position 100 maps to virtual positions when 3 bytes are inserted. ```text Physical position 100 has 3 insertions: [C, B, A] Virtual layout: [A at 150, B at 151, C at 152, PhysicalByte at 153] PhysicalToVirtual(100) = 153 (position of physical byte, AFTER 3 insertions) Virtual positions: 150 → A (oldest, VirtualOffset = 2, array index = 2) 151 → B (middle, VirtualOffset = 1, array index = 1) 152 → C (newest, VirtualOffset = 0, array index = 0) 153 → Physical byte at position 100 ``` -------------------------------- ### Install whfmt.CodeGen global tool Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Tools/whfmt.CodeGen/README.md Install the whfmt.CodeGen tool globally using the .NET CLI. ```bash dotnet tool install -g whfmt.CodeGen ``` -------------------------------- ### Install via NuGet Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Controls/WpfHexEditor.ColorPicker/PACKAGE_README.md Use the .NET CLI to add the WpfColorPicker package to your project. ```bash dotnet add package WpfColorPicker ``` -------------------------------- ### Install via PackageReference Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Tools/whfmt.Analysis/whfmt-Analysis-guide.md Add the package dependency directly to your project file. ```xml ``` -------------------------------- ### Install and use whfmt.CodeGen CLI Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Tools/whfmt.CodeGen/README.md Commands to install the tool, generate a parser for a specific format, dump binary file structures, and list supported formats. ```bash dotnet tool install -g whfmt.CodeGen # Generate a PNG parser whfmt-codegen generate PNG --namespace My.Parsers --output PngParser.cs # Dump a binary file's structure whfmt-codegen dump myfile.png # List all 799 supported binary formats whfmt-codegen list ``` -------------------------------- ### Minimal v3 .whfmt Schema Example Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Core/WpfHexEditor.Core.Definitions/README.md A JSONC example demonstrating v3-specific features such as formatId, typed variables, executable functions, assertions, and diff/fuzz configuration blocks. ```jsonc { "formatName": "ZIP Archive", "formatId": "ZIP", // v3 — unique, machine-readable "version": "1.14", "category": "Archives", "extensions": [".zip", ".jar", ".apk"], "mimeTypes": ["application/zip"], "preferredEditor": "hex-editor", // Detection — supports negative offsets in v3 (offset-from-end) "detection": { "signatures": [ { "value": "504B0304", "offset": 0, "weight": 1.0, "label": "Local File Header" }, { "value": "504B0506", "offset": 0, "weight": 0.8, "label": "End of Central Directory" }, { "value": "55AA", "offset": -2, "weight": 0.5, "label": "Tail marker" } ], "matchMode": "best", "minimumScore": 0.5, "minFileSize": 22 }, // Typed variables (v3 preferred form) — feed WhfmtVariableStore "variables": [ { "name": "magic", "type": "ascii", "offset": 0, "length": 4 }, { "name": "compressionMethod", "type": "uint16", "offset": 8, "length": 2, "endian": "little" } ], // Executable functions (v3) — invokable from expressions "functions": { "isZipMagic": { "params": [], "returns": "bool", "body": "magic == 'PK'" }, "crc32": { "params": ["bytes"], "returns": "uint32", "builtIn": "crc32" } }, // Runtime assertions — evaluated by FormatAssertionEvaluator "assertions": [ { "name": "magic valid", "expression": "magic == 'PK'", "severity": "error", "message": "Missing ZIP magic bytes" }, { "name": "supported compression", "expression": "compressionMethod == 0 || compressionMethod == 8", "severity": "warning" } ], // Consumed by whfmt.Analysis (semantic diff) "diff": { "keyFields": ["centralDirectoryEntries"], "ignoreFields": ["timestamp"] }, // Consumed by whfmt.Fuzz (mutation engine) "fuzz": { "preserveChecksums": true, "strategies": [ { "field": "compressionMethod", "mutation": "enum_sweep", "weight": 1.0 }, { "field": "fileSize", "mutation": "boundary_values", "weight": 0.7 } ] } } ``` -------------------------------- ### Install whfmt.Analysis package Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Tools/whfmt.Analysis/README.md Use the .NET CLI to add the whfmt.Analysis package to your project. ```bash dotnet add package whfmt.Analysis ``` -------------------------------- ### Install via dotnet CLI Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Tools/whfmt.Analysis/whfmt-Analysis-guide.md Use the dotnet CLI to add the whfmt.Analysis package to your project. ```bash dotnet add package whfmt.Analysis --version 1.1.1 ``` -------------------------------- ### BookmarkService Usage Example Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/architecture/core-systems/service-layer.md Demonstrates adding bookmarks at specific positions and iterating through the collection to display them. ```csharp // Add bookmarks bookmarkService.AddBookmark(0x100, "File header start"); bookmarkService.AddBookmark(0x500, "Data section"); bookmarkService.AddBookmark(0x1000, "Footer"); // Navigate to bookmark var bookmarks = bookmarkService.GetBookmarks(); foreach (var bm in bookmarks) { Console.WriteLine($"{bm.Description} at 0x{bm.Position:X}"); } ``` -------------------------------- ### CompareService Usage Example Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/architecture/core-systems/service-layer.md Shows how to compare two binary files and iterate through the detected differences. ```csharp // Compare two files var result = compareService.Compare("original.bin", "modified.bin"); Console.WriteLine($"Files match: {result.AreEqual}"); Console.WriteLine($"Differences: {result.DifferenceCount}"); foreach (var diff in result.Differences) { Console.WriteLine($"Position 0x{diff.Position:X}: " + $"0x{diff.File1Byte:X2} vs 0x{diff.File2Byte:X2}"); } ``` -------------------------------- ### Add Bookmarks Example Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/api-reference/features/bookmarks.md Demonstrates how to add bookmarks at the current position or specific file offsets. ```csharp using WpfHexaEditor; // Add bookmark at current position hexEditor.AddBookmark(hexEditor.Position, "Current location"); // Add bookmark at specific positions hexEditor.AddBookmark(0x0000, "File Header"); hexEditor.AddBookmark(0x1000, "Data Section Start"); hexEditor.AddBookmark(0x5000, "String Table"); Console.WriteLine($"Total bookmarks: {hexEditor.BookmarkCount}"); ``` -------------------------------- ### Install whfmt.Fuzz package Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Tools/whfmt.Fuzz/README.md Use the .NET CLI to add the whfmt.Fuzz package to your project. ```bash dotnet add package whfmt.Fuzz ``` -------------------------------- ### Count From Position Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/api-reference/search/countoccurrences.md Example of counting occurrences starting from a specific offset in the file. ```csharp // Count occurrences after position 0x1000 var pattern = new byte[] { 0xAA, 0xBB }; int count = hexEditor.CountOccurrences(pattern, startPosition: 0x1000); ``` -------------------------------- ### Copying a Sample Application Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/wiki/Sample-Applications.md Use this command to copy an existing sample project to a new directory as a starting point for your application. ```bash # Copy sample cp -r Sources/Samples/WpfHexEditor.Sample.MVVM MyHexApp # Rename namespace # Update project references # Customize UI and features ``` -------------------------------- ### Install WpfHexEditor.Core.ByteProvider via NuGet Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Core/WpfHexEditor.Core.ByteProvider/WpfHexEditor-Core-ByteProvider-guide.md Use the dotnet CLI to add the WpfHexEditor.Core.ByteProvider package to your project. ```bash dotnet add package WpfHexEditor.Core.ByteProvider --version 1.1.1 ``` -------------------------------- ### Install WpfDocking via NuGet Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Docking/WpfHexEditor.Docking.Wpf/README.md Use the .NET CLI to add the WpfDocking package to your WPF project. ```bash dotnet add package WpfDocking ``` -------------------------------- ### Example .hxscript file content Source: https://github.com/abbaye/wpfhexeditoride/wiki/Terminal A sample script file containing sequential HxTerminal commands. ```text open C:\Data\firmware.bin search DE AD BE EF read-hex 0x1000 256 send-output Analysis complete ``` -------------------------------- ### Create a minimal plugin implementation Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/wiki/Plugin-System.md A complete example showing how to implement both plugin interfaces, register a dockable panel, and subscribe to IDE events. ```csharp using WpfHexEditor.SDK; public class MyPlugin : IWpfHexEditorPluginV2, IPluginWithOptions { private IIDEHostContext? _context; public string Id => "com.example.myplugin"; public string Name => "My Plugin"; public string Version => "1.0.0"; public string? Description => "Does something awesome"; public string OptionsPageTitle => "My Plugin"; public void Init(IIDEHostContext context) { _context = context; // Register a VS-style dockable panel context.UIRegistry.RegisterPanel( contentId: "my-panel", title: "My Panel", factory: () => new MyPanelView()); // Subscribe to events context.EventBus.Subscribe(OnFileOpened); } public void Activate() => _context?.UIRegistry.ShowDockablePanel("my-panel"); public void Deactivate() => _context?.UIRegistry.HideDockablePanel("my-panel"); public void Dispose() { /* cleanup */ } public FrameworkElement CreateOptionsPage() => new MyOptionsPage(); private void OnFileOpened(FileOpenedEvent e) => _context?.OutputService.WriteLine($"Opened: {e.FilePath}"); } ``` -------------------------------- ### SetSelection Method Example Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/ApiReference.md Sets a selection range based on a starting position and length. ```csharp // Select 256 bytes starting at 0x1000 hexEditor.SetSelection(0x1000, 256); ``` -------------------------------- ### Install whfmt.FileFormatCatalog via CLI Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Core/WpfHexEditor.Core.Definitions/README.md Use the dotnet CLI to add the package to your .NET 8 project. ```bash dotnet add package whfmt.FileFormatCatalog ``` -------------------------------- ### SelectAll Method Example Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/ApiReference.md Selects all bytes in the file and displays the selection length. ```csharp hexEditor.SelectAll(); Console.WriteLine($"Selected {hexEditor.SelectionLength} bytes"); ``` -------------------------------- ### Get Selection Information Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/wiki/Basic-Operations.md Retrieve the start position and length of the current selection to calculate the end position. ```csharp long selectionStart = hexEditor.SelectionStart; long selectionLength = hexEditor.SelectionLength; long selectionEnd = selectionStart + selectionLength; Console.WriteLine($"Selection: 0x{selectionStart:X} - 0x{selectionEnd:X}"); ``` -------------------------------- ### Custom Visual Theme Example Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/ApiReference.md Demonstrates customizing the appearance and layout of the hex editor. ```csharp var hexEditor = new HexEditor { // Custom colors SelectionFirstColor = Colors.DarkBlue, ByteModifiedColor = Colors.Gold, ByteAddedColor = Colors.LimeGreen, ByteDeletedColor = Colors.Crimson, // Layout BytesPerLine = 32, ZoomScale = 1.25, // Features ShowByteToolTip = true, ShowHeader = true, ShowStatusBar = true }; ``` -------------------------------- ### Delete Multiple Bytes Example Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/api-reference/byte-operations/deletebytes.md Demonstrates deleting a block of 16 bytes starting at a specific offset. ```csharp private void DeleteMultipleBytes() { long position = 0x1000; int count = 16; // Delete 16 bytes Console.WriteLine($"Before: Length = {hexEditor.Length}"); // Delete bytes hexEditor.DeleteBytes(position, count); Console.WriteLine($"After: Length = {hexEditor.Length}"); // -16 bytes Console.WriteLine($"Deleted {count} bytes at 0x{position:X}"); } ``` -------------------------------- ### ByteProvider Usage Example Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Core/WpfHexEditor.Core/Bytes/README.md Demonstrates how to initialize a ByteProvider, read bytes, perform modifications, manage undo/redo history, and save changes. ```csharp // Create a ByteProvider using var provider = new ByteProvider("file.bin"); // Read a byte (returns tuple) var (byteValue, success) = provider.GetByte(100); if (success) { Console.WriteLine($"Byte at 100: 0x{byteValue:X2}"); } // Modify bytes provider.AddByteModified(100, 0xFF, 0x00); // position, newByte, oldByte // Insert bytes provider.AddByteToStream(1000, new byte[] { 0x01, 0x02, 0x03 }); // Delete bytes provider.RemoveByte(500, 10); // position, count // Undo/Redo provider.Undo(); provider.Redo(); // Save changes provider.SubmitChanges(); ``` -------------------------------- ### SelectionStart and SelectionStop Properties Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/ApiReference.md Properties to get or set the start and end positions of the current selection in the editor. ```APIDOC ## Properties: SelectionStart / SelectionStop ### Description Gets or sets the selection start and stop positions (virtual). ### Type long ### Example ```csharp hexEditor.SelectionStart = 0x100; hexEditor.SelectionStop = 0x1FF; ``` ``` -------------------------------- ### Install WpfHexEditor.Core.BinaryAnalysis via NuGet Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Core/WpfHexEditor.Core.BinaryAnalysis/WpfHexEditor-Core-BinaryAnalysis-guide.md Use the dotnet CLI to add the package to your .NET 8.0 project. ```bash dotnet add package WpfHexEditor.Core.BinaryAnalysis --version 1.0.1 ``` -------------------------------- ### Add Bookmarks with Colors Example Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/api-reference/features/bookmarks.md Shows how to categorize bookmarks by assigning specific colors to them. ```csharp // Add bookmarks with different colors for categorization hexEditor.AddBookmark(0x0000, "PE Header", Colors.LightBlue); hexEditor.AddBookmark(0x0400, "Import Table", Colors.LightGreen); hexEditor.AddBookmark(0x1000, "Code Section", Colors.LightYellow); hexEditor.AddBookmark(0x5000, "Data Section", Colors.LightCoral); Console.WriteLine("Color-coded bookmarks added"); ``` -------------------------------- ### Build from Source Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/wiki/Installation.md Clone the repository, restore dependencies, build the project, and add a reference to your solution. ```bash # Clone repository git clone https://github.com/abbaye/WpfHexEditorIDE.git cd WpfHexEditorIDE # Restore dependencies dotnet restore # Build dotnet build Sources/WPFHexaEditor/WPFHexaEditor.csproj # Add project reference to your solution dotnet add reference ../WpfHexEditorControl/Sources/WPFHexaEditor/WPFHexaEditor.csproj ``` -------------------------------- ### Run Sample Project Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Samples/README.md Command to run a specific sample project after navigating to its directory. ```bash dotnet run ``` -------------------------------- ### Install WpfTerminal via NuGet Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Controls/WpfHexEditor.Terminal/PACKAGE_README.md Use the .NET CLI to add the WpfTerminal package to your project. ```bash dotnet add package WpfTerminal ``` -------------------------------- ### Build All Projects Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/README.md Command to build the entire solution in Release configuration. ```bash dotnet build WpfHexEditorControl.sln --configuration Release ``` -------------------------------- ### Install whfmt.Fuzz via PackageReference Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Tools/whfmt.Fuzz/whfmt-Fuzz-guide.md Add the whfmt.Fuzz package to your project file using a PackageReference. ```xml ``` -------------------------------- ### Commit Message Examples Source: https://github.com/abbaye/wpfhexeditoride/wiki/Contributing Examples of good and bad commit message styles. ```bash # Good commits git commit -m "Add support for 64-bit byte editing" git commit -m "Fix search cache invalidation bug" git commit -m "Improve FindReplaceService performance" # Bad commits git commit -m "Update code" git commit -m "Fix bug" git commit -m "Changes" ``` -------------------------------- ### Install whfmt.SourceGenerator NuGet package Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Tools/whfmt.SourceGenerator/README.md Add the package reference to your project file to enable the source generator. ```xml ``` -------------------------------- ### Create Plugin Class Library Source: https://github.com/abbaye/wpfhexeditoride/wiki/Getting-Started Initialize a new class library project targeting net8.0-windows. ```bash dotnet new classlib -n MyPlugin -f net8.0-windows ``` -------------------------------- ### Open and Manage Solutions with SolutionManager Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Core/WpfHexEditor.Core.ProjectSystem/README.md Demonstrates how to instantiate the SolutionManager, open a solution file asynchronously, iterate through projects, and save changes. ```csharp var manager = new SolutionManager(); await manager.OpenAsync(@"C:\Projects\MyApp\MyApp.whsln"); // Access the active solution ISolution solution = manager.CurrentSolution!; foreach (IProject project in solution.Projects) { /* ... */ } // Save changes await manager.SaveAsync(); ``` -------------------------------- ### Build and Run Project Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/wiki/Installation.md Compile and execute your project using the .NET CLI. ```bash dotnet build dotnet run ``` -------------------------------- ### Drop-in Binding Example Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Controls/WpfHexEditor.ColorPicker/WpfColorPicker-guide.md A complete example showing the ColorPicker bound to a ViewModel property. ```xml ``` ```csharp public class ViewModel : INotifyPropertyChanged { Color _highlightColor = Colors.LimeGreen; public Color HighlightColor { get => _highlightColor; set { _highlightColor = value; OnPropertyChanged(); } } // …PropertyChanged plumbing… } ``` -------------------------------- ### Basic Undo Implementation Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/api-reference/edit-operations/undo.md A simple example demonstrating how to perform an undo operation after checking if it is available. ```csharp using WpfHexaEditor; // Make an edit hexEditor.ModifyByte(0xFF, 0x100); // Undo it if (hexEditor.CanUndo) { hexEditor.Undo(); Console.WriteLine("Edit undone"); } ``` -------------------------------- ### Install WPFHexaEditor via NuGet Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/QuickStart.md Use the Package Manager Console to install the WPFHexaEditor package. ```powershell Install-Package WPFHexaEditor ``` -------------------------------- ### Clone and Build WpfHexEditorIDE Samples Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/wiki/Sample-Applications.md Commands to clone the repository and build the MVVM and Winform sample projects using the .NET CLI. ```bash # Clone repository git clone https://github.com/abbaye/WpfHexEditorIDE.git cd WpfHexEditorIDE # Build all samples dotnet build Sources/Samples/WpfHexEditor.Sample.MVVM dotnet build Sources/Samples/WpfHexEditor.Sample.Winform # Run MVVM sample cd Sources/Samples/WpfHexEditor.Sample.MVVM dotnet run ``` -------------------------------- ### Run WpfHexEditor.Sample.HexEditor Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Samples/README.md Command to execute the primary V2 sample application from the terminal. ```bash cd Sources/Samples/WpfHexEditor.Sample.HexEditor dotnet run ``` -------------------------------- ### Run WpfHexEditor.Sample.MVVM Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/wiki/Sample-Applications.md Command to run the MVVM sample application. ```bash cd Sources/Samples/WpfHexEditor.Sample.MVVM dotnet run ``` -------------------------------- ### Verify and Install WPFHexaEditor NuGet Package Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/wiki/Troubleshooting.md Use these commands to check for the presence of the WPFHexaEditor package and install it if it is missing. ```bash # Check if package exists dotnet list package # If missing, install dotnet add package WPFHexaEditor ``` -------------------------------- ### Run WpfHexEditor.Sample.Winform Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/wiki/Sample-Applications.md Command to run the WinForms integration sample application. ```bash cd Sources/Samples/WpfHexEditor.Sample.Winform dotnet run ``` -------------------------------- ### Check .NET SDK Version Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/wiki/Installation.md Verify that the .NET SDK is installed on your system before proceeding with the package installation in VS Code. ```bash # Check .NET is installed dotnet --version ``` -------------------------------- ### Build WPFHexaEditor from Source Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/QuickStart.md Clone the repository and build the project using the .NET CLI. ```bash git clone https://github.com/abbaye/WpfHexEditorIDE.git cd WpfHexEditorIDE/Sources/WPFHexaEditor dotnet build ``` -------------------------------- ### Install WPFHexaEditor via CLI Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/wiki/FAQ.md Commands to install the WPFHexaEditor package using the .NET CLI or the Package Manager Console. ```bash # .NET CLI dotnet add package WPFHexaEditor # Package Manager Console Install-Package WPFHexaEditor ``` -------------------------------- ### Basic HexEditor Initialization Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/ApiReference.md Demonstrates how to instantiate the HexEditor and open a file. ```csharp using WpfHexaEditor; // Basic usage var hexEditor = new HexEditor(); hexEditor.OpenFile("myfile.bin"); ``` -------------------------------- ### UI Virtualization Comparison Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/performance/Performance_Guide.md Demonstrates the memory and control count benefits of using UI virtualization for large file handling. ```csharp // File size: 100 MB = ~6.25M lines (at 16 bytes/line) // Viewport: ~30 visible lines // ❌ Without Virtualization: Controls created: 6,250,000 lines × 16 bytes × 2 (hex + string) = 200M controls Memory usage: ~100 GB (500 bytes per control) // ✅ With Virtualization: Controls created: 30 lines × 16 bytes × 2 = 960 controls Memory usage: ~480 KB Memory saved: 99.9995% 🎉 ``` -------------------------------- ### Example Service Implementation Source: https://github.com/abbaye/wpfhexeditoride/wiki/Contributing A template for creating a new service class following the project's architecture. ```csharp /// /// Service for managing operation X /// public class XService { /// /// Performs operation Y /// /// Byte provider /// Operation parameter /// Result tuple (value, success) public (int value, bool success) DoOperation(ByteProvider provider, int parameter) { // Validate inputs if (provider == null) return (0, false); if (parameter < 0) return (0, false); // Perform operation // ... return (result, true); } } ``` -------------------------------- ### Validate files examples Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Tools/whfmt.Validate/README.md Various examples for validating files, including format forcing, recursive validation, CI/CD usage, and JSON output piping. ```bash # Validate a ZIP file (auto-detect format) whfmt validate archive.zip # Validate a firmware blob, force PE32 format whfmt validate firmware.bin --format pe32 # Validate all files in a directory, output HTML report whfmt validate ./files --recursive --report html --output report.html # CI/CD: silent validation, fail on first error whfmt validate build/output.exe --quiet --fail-fast && echo "OK" || echo "INVALID" # JSON output for scripting whfmt validate image.png --report json | jq '.isValid' ``` -------------------------------- ### Standard Thingy TBL Format Example Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Core/WpfHexEditor.Core/CharacterTable/README.md Example of a TBL file structure including comments, multi-byte entries, special markers, and escape sequences. ```text # Full line comment 41=A 42=B # Inline comment # Multi-byte entries 8182=AB # DTE (2 bytes) 818283=ABC # MTE (3 bytes) # Special markers /00 # EndBlock *0A # EndLine # Bookmarks (1000h)Text start # Escape sequences 01=Hello\nWorld ``` -------------------------------- ### Annotated .whfmt Schema Example Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Core/WpfHexEditor.Core.Definitions/whfmt-FileFormatCatalog-guide.md A comprehensive example of a .whfmt file demonstrating root identification, file association, detection logic, variable definitions, and structural blocks. ```jsonc { // Root identification "formatName": "ZIP Archive", // Human-readable name "formatId": "ZIP", // Canonical PascalCase identifier (unique across the catalog) "version": "1.14", // Format spec version "category": "Archives", // Must match a FormatCategory enum value "description":"...", "author": "WPFHexaEditor Team", "preferredEditor": "hex-editor", // hex-editor | code-editor | structure-editor | image-viewer | audio-viewer "diffMode": "binary", // text | semantic | binary // File association "extensions": [".zip", ".jar", ".apk"], "mimeTypes": ["application/zip"], // Detection "detection": { "signatures": [ { "value": "504B0304", "offset": 0, "weight": 1.0, "label": "Local File Header" }, { "value": "504B0506", "offset": 0, "weight": 0.8, "label": "End of Central Directory" }, { "value": "55AA", "offset": -2, "weight": 0.5, "label": "Tail marker (negative offset)" } ], "matchMode": "best", // any | best (default) | all "minimumScore": 0.5, // discard scored matches below this threshold "minFileSize": 22, // skip when header shorter than this "strength": "Strong", // Strong | Medium | Weak — informational only "isTextFormat": false, "validation": { "minFileSize": 22, "maxSignatureOffset": 0, "discriminator": { // NEW in v3 — resolves magic collisions "offset": 4, "length": 2, "endian": "little", "values": { "0103": "ZIP", "0203": "ZIP_NESTED" } } } }, // Typed variables (v3 preferred form) — consumed by the runtime expression engine "variables": [ { "name": "fileSize", "type": "uint64", "offset": 0, "length": 8 }, { "name": "magic", "type": "ascii", "offset": 0, "length": 4 }, { "name": "compressionMethod", "type": "uint16", "offset": 8, "length": 2, "endian": "little" } ], // … or the dict form (still accepted): // "variables": { "fileSize": 0, "magic": "", "compressionMethod": 0 } // Named function registry — v3 executable form (or doc-string) "functions": { "crc32": { "params": ["bytes"], "returns": "uint32", "builtIn": "crc32" }, "validateMagic": { "params": [], "returns": "bool", "body": "magic == 'PK'" } }, // Block layout (signature/field/conditional/loop/repeating/pointer/bitfield/union) "blocks": [ { "type": "signature", "name": "magic", "offset": 0, "length": 4, "valueType": "ascii" }, { "type": "field", "name": "compressionMethod", "offset": 8, "length": 2, "valueType": "uint16", "endianness": "little", "valueMap": { "0": "Store", "8": "Deflate" } }, { "type": "conditional", "name": "encryptionHeader", "condition": "(flags & 1) != 0", // expression engine "trueLabel": "encrypted", "falseLabel":"plain" } ], // Runtime assertions — evaluated by FormatAssertionEvaluator "assertions": [ { "name": "magic valid", "expression": "magic == 'PK'", "severity": "error", "message": "Missing ZIP magic bytes" }, { "name": "compression OK", "expression": "compressionMethod == 0 || compressionMethod == 8", "severity": "warning" } ], // Quality "qualityMetrics": { "completenessScore": 92 }, // Forensic intelligence "forensic": { "category": "archive", "riskLevel": "low", // low | medium | high | critical "suspiciousPatterns": [ { "name": "Zip bomb", "description": "Nested archives with extreme ratio", "condition": "compressionRatio > 1000" } ] }, // AI hints "aiHints": { "analysisContext": "ZIP is a widely-used container format…", "suggestedInspections": [ "Check local file header counts", "Verify central directory offset" ] }, // Navigation "navigation": { "entryPoint": "Local File Header", "structure": [ "Local File Header[]", "Central Directory", "End of Central Directory" ], "bookmarks": [ { "name": "Local File Header", "offset": 0, "icon": "signature" }, { "name": "Central Directory", "offsetVar": "cdOffset", "icon": "directory" } ] } ``` -------------------------------- ### Create WPF Project via .NET CLI Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/wiki/Quick-Start.md Use the .NET CLI to scaffold a new WPF application named MyHexEditor. ```bash dotnet new wpf -n MyHexEditor cd MyHexEditor ``` -------------------------------- ### ClearSelection Method Example Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/ApiReference.md Clears the current selection. ```csharp hexEditor.ClearSelection(); ``` -------------------------------- ### SelectionLength Property Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/ApiReference.md Gets the length of the current selection. ```csharp public long SelectionLength { get; } ``` ```csharp if (hexEditor.SelectionLength > 0) { Console.WriteLine($"Selected {hexEditor.SelectionLength} bytes"); } ``` -------------------------------- ### OpenStream Method Example Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/ApiReference.md Opens a seekable stream for editing. ```csharp using var memoryStream = new MemoryStream(byteArray); hexEditor.OpenStream(memoryStream); ``` -------------------------------- ### Open a file and read bytes Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Core/WpfHexEditor.Core.ByteProvider/README.md Demonstrates initializing a ByteProvider, opening a file, and reading a specific range of bytes. ```csharp using WpfHexEditor.Core.Bytes; var provider = new ByteProvider(); provider.OpenFile("firmware.bin"); // Read 16 bytes at offset 0x100 byte[] data = provider.GetBytes(0x100, 16); Console.WriteLine($"File size: {provider.VirtualLength} bytes"); Console.WriteLine($"Is open: {provider.IsOpen}"); ``` -------------------------------- ### Bulk Color Palette Modification in C# Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/api-reference/replace-operations/replaceall.md This example defines a PaletteModifier class that wraps the HexEditor.ReplaceAll method to perform individual and batch color replacements. It includes a usage example for updating game sprite colors by mapping old RGB byte arrays to new ones. ```csharp // Replace colors in image palette public class PaletteModifier { private HexEditor _hexEditor; public PaletteModifier(HexEditor hexEditor) { _hexEditor = hexEditor; } // Replace RGB color values public int ReplaceColor(byte[] oldRGB, byte[] newRGB) { if (oldRGB.Length != 3 || newRGB.Length != 3) { throw new ArgumentException("RGB must be 3 bytes"); } return _hexEditor.ReplaceAll(oldRGB, newRGB); } // Batch color replacement public Dictionary ReplacePalette( Dictionary colors) { var results = new Dictionary(); _hexEditor.BeginBatch(); try { foreach (var (colorName, (oldRGB, newRGB)) in colors) { int count = _hexEditor.ReplaceAll(oldRGB, newRGB); results[colorName] = count; if (count > 0) { Console.WriteLine($"Replaced {colorName}: {count} pixels"); } } } finally { _hexEditor.EndBatch(); } return results; } } // Usage: Change game sprite colors var modifier = new PaletteModifier(hexEditor); var palette = new Dictionary { { "Red", (new byte[] { 0xFF, 0x00, 0x00 }, new byte[] { 0x00, 0xFF, 0x00 }) }, // Red -> Green { "Blue", (new byte[] { 0x00, 0x00, 0xFF }, new byte[] { 0xFF, 0xFF, 0x00 }) } // Blue -> Yellow }; var results = modifier.ReplacePalette(palette); int totalReplaced = results.Values.Sum(); Console.WriteLine($"Total pixels recolored: {totalReplaced}"); ``` -------------------------------- ### IDE startup workflow diagram Source: https://github.com/abbaye/wpfhexeditoride/wiki/Getting-Started A visual representation of the steps required to launch the IDE. ```mermaid flowchart LR Clone["git clone"] --> Open["Open .sln\nVisual Studio 2022"] Open --> Startup["Set WpfHexEditor.App\nas Startup Project"] Startup --> Run["F5 → IDE launches"] Run --> Welcome["Welcome Panel\nwith recent files and changelog"] ``` -------------------------------- ### Count Pattern Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/api-reference/search/countoccurrences.md Example of counting occurrences of a single byte pattern. ```csharp // Count how many times 0xFF appears var pattern = new byte[] { 0xFF }; int count = hexEditor.CountOccurrences(pattern); Console.WriteLine($"Found {count} occurrences of 0xFF"); ``` -------------------------------- ### Bind HexEditor in XAML Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/QuickStart.md Example of binding HexEditor properties to the ViewModel. ```xml ``` -------------------------------- ### Close Method Example Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/ApiReference.md Closes the currently open file or stream. ```csharp hexEditor.Close(); Console.WriteLine("File closed"); ``` -------------------------------- ### Build, Run, and Test Commands Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/ARCHITECTURE.md Commands to build the solution, launch the IDE, execute test suites, and package plugins using the .NET CLI. ```bash # Full solution dotnet build Sources/WpfHexEditorControl.sln --configuration Release # Run IDE dotnet run --project Sources/WpfHexEditor.App # Tests dotnet test Sources/WpfHexEditor.Tests/WpfHexEditor.Tests.csproj dotnet test Sources/WpfHexEditor.BinaryAnalysis.Tests/ # Package a plugin cd Sources/Tools/WpfHexEditor.PackagingTool dotnet run -- pack path/to/plugin.dll --output my.whxplugin ``` -------------------------------- ### SetSelection(long start, long length) Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/ApiReference.md Sets a selection range. ```APIDOC ## SetSelection(long start, long length) ### Description Sets a selection range. ### Parameters - **start** (long) - Starting position (virtual) - **length** (long) - Number of bytes to select ``` -------------------------------- ### Statistics Use Case Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/api-reference/search/countoccurrences.md Example of using CountOccurrences to analyze byte frequency. ```csharp // Analyze byte frequency int nullBytes = hexEditor.CountOccurrences(new byte[] { 0x00 }); int ffBytes = hexEditor.CountOccurrences(new byte[] { 0xFF }); Console.WriteLine($"File contains {nullBytes} null bytes and {ffBytes} FF bytes"); ``` -------------------------------- ### SelectionChanged Event Usage Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/ApiReference.md Example of updating a status label when the selection changes. ```csharp hexEditor.SelectionChanged += (sender, e) => { var editor = sender as HexEditor; statusLabel.Text = $"Selected: {editor.SelectionLength} bytes"; }; ``` -------------------------------- ### Combine FindReplace, Highlight, and Bookmark Services Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Samples/ServiceUsageExample.md Demonstrates searching for a byte pattern, highlighting the matches, and creating bookmarks for navigation. This workflow uses FindReplaceService, HighlightService, and BookmarkService sequentially. ```csharp // Real-world example: Search, highlight results, and add bookmarks var findService = new FindReplaceService(); var highlightService = new HighlightService(); var bookmarkService = new BookmarkService(); var provider = new ByteProvider("data.bin"); // Search for pattern byte[] pattern = new byte[] { 0xFF, 0xD8, 0xFF }; // JPEG header var results = findService.FindAllCached(provider, pattern); Console.WriteLine($"Found {results.Count()} JPEG headers"); // Highlight and bookmark each result int count = 1; foreach (var position in results) { // Highlight the match highlightService.AddHighLight(position, pattern.Length); // Add bookmark bookmarkService.AddBookmark(position, $"JPEG #{count}", ScrollMarker.SearchMatch); count++; } Console.WriteLine($"Highlighted {highlightService.GetHighlightCount()} positions"); Console.WriteLine($"Added {bookmarkService.GetBookmarkCount()} bookmarks"); // Navigate through results using bookmarks long currentPos = 0; while (true) { var nextMatch = bookmarkService.GetNextBookmark(currentPos, ScrollMarker.SearchMatch); if (nextMatch == null) break; Console.WriteLine($"Next match at: 0x{nextMatch.BytePositionInStream:X}"); currentPos = nextMatch.BytePositionInStream; } ``` -------------------------------- ### Manual .csproj Configuration and Restore Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/wiki/Installation.md Manually add the PackageReference to your project file and restore dependencies. ```xml net8.0-windows true ``` ```bash dotnet restore ``` -------------------------------- ### FillSelection Method Example Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/ApiReference.md Fills the current selection with a specific byte value. ```csharp // Fill selection with 0x00 hexEditor.FillSelection(0x00); ``` -------------------------------- ### DeleteSelection Method Example Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/ApiReference.md Deletes the currently selected bytes if a selection exists. ```csharp if (hexEditor.HasSelection) { hexEditor.DeleteSelection(); } ``` -------------------------------- ### PositionMapper Example Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/architecture/Overview.md Demonstrates how virtual and physical positions are calculated after inserting 3 bytes into a 10-byte file. ```text Original file: 10 bytes (positions 0-9) Insert 3 bytes at position 5 Virtual positions: 0 1 2 3 4 5 6 7 | 8 9 10 11 12 ↑ Insertions Physical positions: 0 1 2 3 4 | 5 6 7 8 9 VirtualToPhysical(8) = 5 // Skip 3 inserted bytes PhysicalToVirtual(5) = 8 // Account for 3 insertions ``` -------------------------------- ### ModifyByte Method Example Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/ApiReference.md Modifies a single byte at a specific virtual position. ```csharp // Change byte at position 0x100 to 0xFF hexEditor.ModifyByte(0xFF, 0x100); ``` -------------------------------- ### SaveAs Method Example Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/ApiReference.md Saves the current file to a new specified location. ```csharp hexEditor.SaveAs(@"C:\data\file_backup.bin"); ``` -------------------------------- ### MSBuild integration Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Tools/whfmt.CodeGen/README.md Example of how to integrate parser generation into an MSBuild project file. ```xml ``` -------------------------------- ### Basic Redo Implementation Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/api-reference/edit-operations/redo.md A simple example demonstrating how to check if a redo is possible before calling the Redo method. ```csharp using WpfHexaEditor; // Make an edit hexEditor.ModifyByte(0xFF, 0x100); // Undo it hexEditor.Undo(); // Redo it if (hexEditor.CanRedo) { hexEditor.Redo(); Console.WriteLine("Edit re-applied"); } ``` -------------------------------- ### Variable References in Expressions Source: https://github.com/abbaye/wpfhexeditoride/blob/master/Sources/Core/WpfHexEditor.Core.Definitions/FormatDefinitions/README.md Examples of referencing variables within arithmetic expressions. ```json "calc:currentOffset + recordSize" "calc:(width * height) / 8" ``` -------------------------------- ### Set Selection Source: https://github.com/abbaye/wpfhexeditoride/blob/master/docs/wiki/Basic-Operations.md Define a selection by setting the start position and length in bytes. ```csharp // Select 256 bytes at position 0x1000 hexEditor.SelectionStart = 0x1000; hexEditor.SelectionLength = 256; ```