WpfHexEditorControl

Wpf Hexeditor is a powerful and fully customisable user control for editing file or stream as hexadecimal, decimal and binary. Can be used in Wpf or WinForm application

View project on GitHub

NuGet NetFramework NetFramework NetFramework License

๐Ÿ“‘ Quick Navigation

Section Description
๐Ÿ–ผ Screenshots Visual examples and use cases
๐Ÿ›’ Features Complete feature list
๐Ÿ‘ How to Use Quick start guide
โšก Performance Performance optimizations (v2.2+)
๐Ÿ—๏ธ Architecture Service-based design
๐Ÿ“š Documentation Complete documentation index
๐Ÿงช Testing Unit tests and quality
๐Ÿ”ง Frameworks .NET support

Wpf Hexeditor is a powerful and fully customisable user control for editing file or stream as hexadecimal, decimal and binary.

You can use it very easily in Wpf or WinForm application. Download the code and test the Wpf (C#, VB.NET) and WinForm (C#) samples.

The control are localized in English, French, Russian, Polish, Portuguese and Chinese

โญ You want to say thank or just like project ?

Hexeditor control is totaly free and can be used in all project you want like open source and commercial applications. I make it in my free time and a few colaborators help me when they canโ€ฆ Please hit the โญ๏ธ button or fork and I will be very happy ;) I accept help contributionโ€ฆ

๐Ÿ–ผ Screenshots

๐Ÿ“ Standard ASCII View
Clean interface with hex/ASCII side-by-side

Standard ASCII view
๐ŸŽฎ Custom TBL (Final Fantasy II)
Game ROM editing with custom character tables

Custom TBL
๐Ÿ” Find & Replace
Advanced search with pattern matching

Find/Replace
๐Ÿ“Š BarChart View โญ
Visual data representation for analysis

BarChart
๐Ÿ”ง Advanced Features - Click to see more screenshots
โš™๏ธ ByteShift + Fixed Table Editing
Advanced table editing with byte shifting

ByteShift
๐Ÿ–ฅ๏ธ AvalonDock Integration โญ
Dockable panels for complex workflows

AvalonDock
๐ŸŽจ Custom Background Blocks
Visual diff and data highlighting

CustomBackgroundBlock

๐Ÿงพ What is TBL (custom character table)

The TBL are small plaintext .tbl files that link every hexadecimal value with a character, which proves most useful when reading and changing text data. Wpf HexEditor support .tbl and you can define your custom character table as you want.

Unicode TBL are supported. For use put value at the right of equal (=) like this (0401=ๅกž่ฅฟๅฐ”) or (42=ะ”) in you plaintext .tbl file.

example

๐Ÿ›’ Complete Feature List

โญ = New in v2.2+ ๐Ÿš€ = Performance feature

๐Ÿ“ Core Editing

  • Multi-format editing: Hexadecimal, Decimal, Binary display modes
  • Multi-byte support: 8-bit, 16-bit, 32-bit editing
  • Endianness: LoHi (Little Endian) or HiLo (Big Endian)
  • Insert/Delete bytes: Full support with automatic length adjustments
  • Append bytes: Add bytes at end of file
  • Fill selection: Fill with specific byte value
  • Unlimited Undo/Redo: Full history with memory optimization
  • Read-only mode: View-only mode for safe browsing

๐Ÿ” Search & Navigation

  • Advanced search: FindFirst, FindNext, FindPrevious, FindLast, FindAll
  • Pattern search: Search for byte patterns (byte[] or string)
  • Replace operations: ReplaceFirst, ReplaceNext, ReplaceAll
  • ๐Ÿš€ Search caching: 100-1000x faster repeated searches
  • Highlight results: Auto-highlight search matches
  • Bookmarks: Mark important positions with descriptions
  • Go to offset: Jump directly to byte position
  • Selection highlighting: Visual selection feedback

๐Ÿ“‹ Copy/Paste & Export

  • Standard clipboard: CTRL+C, CTRL+V, CTRL+X support
  • Copy as code: Export as C#, VB.NET, C, Java, F#, Python code
  • Multiple formats: HexString, ASCIIString, Binary, Decimal
  • Copy to stream: Export selection to Stream or file
  • Custom copy modes: Configurable default export format

๐ŸŽจ Display & Visualization

  • โญ BarChart view: Visual data representation
  • โญ AvalonDock support: Dockable hex editor panels
  • Byte grouping: Group bytes in blocks of 2, 4, 6, 8, 16 bytes
  • ๐Ÿ†• Multiple encodings: ASCII, UTF-8, UTF-16 (LE/BE), UTF-32, Latin-1, and custom encodings via Encoding.GetEncoding()
  • Custom TBL support: Use .tbl character tables (game ROMs, translation hacking)
  • Unicode TBL: Support for Unicode character mapping in TBL files
  • Zoom: 50% to 200% content scaling
  • Show deleted bytes: Option to visualize deleted data
  • Line addressing: Show/hide byte addresses
  • Offset modes: Decimal or hexadecimal addressing
  • Scrollbar markers: Visual markers for search results, bookmarks, changes

โšก Performance & Optimization

  • ๐Ÿš€ UI Virtualization: Handle GB-sized files (80-90% memory reduction)
  • ๐Ÿš€ Render caching: 5-10x faster UI rendering
  • ๐Ÿš€ Width calculation cache: 10-100x faster cell width calculations
  • ๐Ÿš€ Search result caching: 460x speedup for repeated searches
  • ๐Ÿš€ Span<T> APIs: Zero-allocation operations (.NET 5.0+)
  • ๐Ÿš€ SIMD search: Hardware-accelerated search (AVX2/SSE2)
  • ๐Ÿš€ Async operations: Non-blocking I/O for large files
  • ๐Ÿš€ Memory-mapped files: Support files larger than RAM

๐ŸŽจ Customization & Theming

  • Color customization: Bytes, TBL, backgrounds, headers, selection
  • Custom backgrounds: Highlight byte ranges with colors and descriptions
  • Font customization: Choose any font family and size
  • Border styles: Customize visual appearance
  • Status bar: Configurable position, selection, file info display
  • Context menus: Fully customizable right-click menus

๐Ÿ—๏ธ Architecture & Services

  • Service-based design: 10 specialized services for clean separation
  • ByteProvider: Efficient data access layer
  • Stream support: Work with any Stream (MemoryStream, FileStream, custom)
  • Event system: DataCopied, SelectionChanged, ByteModified, etc.
  • Change tracking: Track all modifications with position info

๐Ÿงช Developer Features

  • HexBox control: Standalone hex input control with spinner
  • Dependency properties: Full WPF binding support
  • MVVM compatible: Works with MVVM pattern
  • Sample applications: 7+ working samples (C#, VB.NET, WinForms)
  • Unit tests: 275+ tests with 100% service coverage
  • Benchmarks: BenchmarkDotNet suite for performance testing
  • Localization: English, French, Russian, Polish, Portuguese, Chinese

๐Ÿ“Š File Format Support

  • Any binary file: No format restrictions
  • Large files: Tested with multi-GB files
  • Partial loading: Load only visible portions (AllowVisualByteAddress)
  • Stream editing: Edit without loading entire file into memory
  • Custom formats: Use TBL files for custom character encoding

โŒจ๏ธ Keyboard Shortcuts

  • CTRL+C / CTRL+V / CTRL+X: Copy/Paste/Cut
  • CTRL+Z / CTRL+Y: Undo/Redo
  • CTRL+A: Select All
  • CTRL+F: Find dialog
  • CTRL+H: Replace dialog
  • CTRL+G: Go to offset
  • CTRL+B: Toggle bookmark
  • ESC: Clear selection
  • Delete / Backspace: Delete selected bytes
  • Arrow keys: Navigation
  • Page Up/Down: Fast scrolling

๐Ÿ“– See Performance Guide for detailed optimization documentation

โšก Performance Optimizations (v2.2+)

๐Ÿ“– For detailed performance documentation, benchmarking results, and best practices, see the Performance Guide

Advanced Backend Optimizations:

  • ๐Ÿš€ LRU Cache for Search Results (Option 4)
    • 10-100x faster for repeated searches
    • Intelligent caching with automatic eviction of least recently used results
    • Thread-safe with O(1) lookup performance
    • Configurable capacity (default: 20 cached searches)
  • โšก Parallel Multi-Core Search (Option 5)
    • 2-4x faster for large files (> 100MB)
    • Automatic threshold detection (uses all CPU cores for large files)
    • Zero overhead for small files (automatic fallback to standard search)
    • Thread-safe with overlap handling for patterns spanning chunk boundaries
  • ๐ŸŽฏ Profile-Guided Optimization (PGO) (Option 6)
    • 10-30% performance boost for CPU-intensive operations (.NET 8.0+)
    • Dynamic runtime optimization with tiered compilation
    • 30-50% faster startup with ReadyToRun (AOT compilation)
    • Automatic in Release builds
  • ๐Ÿ” SIMD Vectorization (net5.0+)
    • 4-8x faster single-byte searches with AVX2/SSE2
    • Processes 32 bytes at once with AVX2 (16 with SSE2)
    • Automatic hardware detection and fallback
  • **๐Ÿ“ฆ Span + ArrayPool**
    • 2-5x faster with 90% less memory allocation
    • Zero-allocation memory operations
    • Buffer pooling for efficient resource usage
  • โฑ๏ธ Async/Await Support
    • 100% UI responsiveness during long operations
    • Progress reporting (0-100%) with IProgress
    • Cancellation support with CancellationToken

Combined Results:

  • 10-100x faster operations (depending on optimization tier)
  • 95% less memory allocation
  • 100% backward compatible - no breaking changes
  • Automatic selection - optimizations activate based on file size/hardware

UI Rendering Optimizations (NEW!):

  • ๐ŸŽจ Cached Typeface & FormattedText (BaseByte.cs)
    • 2-3x faster rendering by reusing expensive WPF objects
    • Intelligent cache invalidation (only when text/font changes)
    • Eliminates allocations on every OnRender() call
  • ๐Ÿ“ Cached Width Calculations (HexByte.cs)
    • 10-100x faster width lookups with static Dictionary cache
    • O(1) lookups instead of repeated calculations
    • Thread-safe with lock protection
  • โšก Batch Visual Updates (BaseByte.cs)
    • 2-5x faster for multiple property changes
    • BeginUpdate/EndUpdate pattern prevents redundant updates
    • Single UpdateVisual() call instead of multiple
  • ๐Ÿ’พ Optimized StringByte Rendering
    • 2-3x faster by caching width calculations
    • No re-computation on every render unless text changes
    • Optimized for both TBL and ASCII modes

UI Performance Gains:

  • 5-10x faster UI operations overall
  • 50-80% reduction in rendering allocations
  • 100% backward compatible - no API changes
  • Automatic - optimizations always active

Data Structure Optimizations (NEW v2.2+):

  • โœจ HighlightService HashSet Migration
    • 2-3x faster highlight operations with HashSet vs Dictionary
    • 50% less memory usage (single long vs key-value pair)
    • Single lookup operations (no redundant ContainsKey checks)
  • ๐Ÿ“ฆ Batching Support for Bulk Operations
    • 10-100x faster when highlighting thousands of search results
    • BeginBatch/EndBatch pattern prevents UI updates during operations
    • Real-world: 1000 highlights in ~100ฮผs instead of 1.2ms
  • ๐Ÿš€ Bulk APIs
    • AddHighLightRanges() - 14x faster than loops (5-10x typical)
    • AddHighLightPositions() - 27x faster for scattered positions
    • Auto-batching when not already in batch mode

Highlight Performance Gains:

  • 10-100x faster bulk highlighting (with batching)
  • 2-3x faster single operations
  • 50% less memory for highlight tracking
  • 100% backward compatible - same API, better performance

See PERFORMANCE_GUIDE.md for comprehensive documentation.

๐Ÿ‘ How to use

Add a reference to WPFHexaEditor.dll from your project, then add the following namespace to your XAML:

xmlns:control="clr-namespace:WpfHexaEditor;assembly=WPFHexaEditor"

Insert the control like this in your XAMLโ€ฆ:

<control:HexEditor/>
<control:HexEditor Width="NaN" Height="NaN"/>
<control:HexEditor Width="Auto" Height="Auto"/>
<control:HexEditor FileName="{Binding FileNamePath}" Width="Auto" Height="Auto"/>

๐Ÿ—๏ธ Architecture

WPF HexEditor now uses a modern service-based architecture for improved maintainability and testability.

Service Layer (10 Services)

The control is powered by specialized services that handle different aspects of functionality:

Core Services

  • ๐Ÿ“‹ ClipboardService - Manages copy/paste/cut operations
  • ๐Ÿ” FindReplaceService - Search and replace with LRU cache + parallel search (10-100x faster)
  • โ†ฉ๏ธ UndoRedoService - Undo/redo history management
  • ๐ŸŽฏ SelectionService - Selection validation and manipulation
  • โœจ HighlightService - Manages byte highlighting with HashSet + batching (10-100x faster bulk operations)
  • ๐Ÿ”ง ByteModificationService - Handles insert, delete, and modify operations

Additional Services

  • ๐Ÿ”– BookmarkService - Bookmark management and navigation
  • ๐Ÿ“š TblService - Custom character table (TBL) operations
  • ๐Ÿ“ PositionService - Position calculations and conversions
  • ๐ŸŽจ CustomBackgroundService - Custom background color blocks

Benefits:

  • โœ… Separation of concerns - Each service has a single responsibility
  • โœ… Unit testable components - Services can be tested in isolation
  • โœ… Reusable across projects - Services are decoupled from HexEditor
  • โœ… Easier to maintain and extend - Clear APIs and focused logic
  • โœ… No breaking changes - Public API preserved during refactoring

Statistics:

  • 10 services total (6 stateless, 4 stateful)
  • ~150+ public methods
  • ~2500+ lines of business logic extracted

See Services Documentation for details.

๐Ÿ“š Documentation

๐Ÿ“– Table of Contents


๐ŸŽฏ Main Control API

WPFHexaEditor Control - Complete documentation for the main HexEditor control

  • Control architecture with 10 services
  • Property reference and customization
  • Usage examples (basic and advanced)
  • Performance optimization tips
  • Multi-targeting support (.NET 4.8 / .NET 8.0)
  • Internationalization (6 languages)

๐Ÿ“ Architecture & Design

Architecture Diagrams - Visual architecture documentation

  • Service layer architecture (Mermaid diagrams)
  • Data flow diagrams
  • Component relationships
  • Design patterns used

Services Layer - Business logic architecture

  • Complete API reference for all 10 services
  • Service usage examples and patterns
  • Stateless vs stateful services
  • Integration guidelines

๐ŸŽจ Sample Applications

Samples Overview - All sample applications

Individual Samples:

๐Ÿงฉ Core Components

Core Overview - Core infrastructure documentation

Detailed Component Documentation:

  • Bytes/ - ByteProvider and byte manipulation
    • File/stream I/O with modification tracking
    • Insert/delete/modify operations
    • Undo/redo support
    • Conversion utilities
  • CharacterTable/ - TBL file support
    • Custom character encoding for game hacking
    • Multi-byte character support (DTE)
    • Bidirectional byte โ†” character mapping
  • Converters/ - WPF value converters
    • Hex/decimal conversions
    • Visibility converters
    • Path/filename converters
  • EventArguments/ - Custom event args
    • ByteEventArgs for modifications
    • ByteDifferenceEventArgs for comparisons
    • CustomBackgroundBlockEventArgs for highlighting
  • Interfaces/ - Core interfaces
    • IByte - Byte control contract
    • IByteControl - Manipulation interface
    • IByteModified - Change tracking contract
  • MethodExtention/ - Extension methods
    • Byte array extensions
    • String parsing helpers
    • Double formatting
    • Application helpers
  • Native/ - Windows API P/Invoke
    • High-performance file I/O
    • Memory-mapped files
    • Native window operations
  • Dialog/ - UI dialogs
    • Find window
    • Find/Replace window
    • Byte input dialogs

๐Ÿงช Testing & Quality

Unit Tests - Test suite documentation

  • 80+ unit tests with xUnit
  • Service layer test coverage
  • Test patterns and best practices
  • Running tests and CI/CD integration

๐Ÿ”ง Development Tools

ByteProviderBench - Performance benchmarking tool

  • Read/write performance testing
  • Memory usage profiling
  • Search algorithm benchmarks

๐Ÿ“‚ Project Structure

Sources Overview - Complete source code structure

  • Directory organization
  • Build instructions
  • Multi-targeting configuration

๐Ÿ”ง Supported Frameworks

  • โœ… .NET Framework 4.8
  • โœ… .NET 8.0-windows

๐Ÿงช Unit Testing

The project includes comprehensive unit tests for all service layer components:

  • Test Framework: xUnit with .NET 8.0-windows
  • Test Project: WPFHexaEditor.Tests
  • Coverage: 80+ tests across 3 test suites
    • SelectionServiceTests - 35 tests for selection operations
    • FindReplaceServiceTests - 35 tests for search/replace with caching
    • HighlightServiceTests - 10+ tests for highlight management

Running tests:

cd Sources/WPFHexaEditor.Tests
dotnet test

The service-based architecture makes unit testing straightforward - services can be tested in isolation without UI dependencies.

๐Ÿ› Recent Bug Fixes

Critical Fix (2026):

  • Fixed search cache not being invalidated after data modifications
  • Users now receive accurate search results after editing
  • Cache properly cleared at all 11 modification points

๐Ÿ—บ๏ธ Complete Documentation Map

Every major folder in the project contains comprehensive README documentation:

๐Ÿ“ฆ WpfHexEditorControl/
โ”‚
โ”œโ”€โ”€ ๐Ÿ“„ README.md (this file) ..................... Main project overview
โ”œโ”€โ”€ ๐Ÿ“„ ARCHITECTURE.md .......................... Architecture diagrams
โ”‚
โ”œโ”€โ”€ ๐Ÿ“‚ Sources/
โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ README.md ............................ Source code overview
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ WPFHexaEditor/
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ README.md ........................ Main control documentation
โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ Services/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ๐Ÿ“„ README.md .................... 10 services API reference
โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ Core/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ README.md .................... Core components overview
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ Bytes/README.md .............. ByteProvider & data layer
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ CharacterTable/README.md ..... TBL file support
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ Converters/README.md ......... WPF value converters
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ EventArguments/README.md ..... Custom event args
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ Interfaces/README.md ......... Core interfaces
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ MethodExtention/README.md .... Extension methods
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ๐Ÿ“‚ Native/README.md ............. Windows API P/Invoke
โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ””โ”€โ”€ ๐Ÿ“‚ Dialog/
โ”‚   โ”‚       โ””โ”€โ”€ ๐Ÿ“„ README.md .................... Find/Replace dialogs
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ WPFHexaEditor.Tests/
โ”‚   โ”‚   โ””โ”€โ”€ ๐Ÿ“„ README.md ........................ 80+ unit tests
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ Samples/
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ README.md ........................ Samples overview
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ WPFHexEditor.Sample.CSharp/README.md
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ WpfHexEditor.Sample.VB/README.md
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ WpfHexEditor.Sample.Winform/README.md
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ WpfHexEditor.Sample.AvalonDock/README.md
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ WpfHexEditor.Sample.BarChart/README.md
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ WpfHexEditor.Sample.BinaryFilesDifference/README.md
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ WpfHexEditor.Sample.InsertByteAnywhere/README.md
โ”‚   โ”‚   โ””โ”€โ”€ ๐Ÿ“‚ WpfHexEditor.Sample.ServiceUsage/README.md
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ ๐Ÿ“‚ Tools/
โ”‚       โ””โ”€โ”€ ๐Ÿ“‚ ByteProviderBench/
โ”‚           โ””โ”€โ”€ ๐Ÿ“„ README.md .................... Performance benchmarking

Total Documentation: 19 comprehensive README files covering every aspect of the project! ๐Ÿ“š

๐Ÿ’ก Learning Path

Beginner: Start here

  1. Read How to Use for basic integration
  2. Explore C# Sample for practical examples
  3. Review Main Control API for available properties

Intermediate: Dive deeper

  1. Understand Architecture and service layer design
  2. Study Services Documentation for advanced features
  3. Try specialized samples (BarChart, Binary Diff)

Advanced: Master the internals

  1. Explore Core Components architecture
  2. Review ByteProvider for data layer understanding
  3. Study Unit Tests for testing patterns
  4. Build custom tools with Service Usage Sample

๐Ÿค Contributing

We welcome contributions! The comprehensive documentation makes it easy to understand the codebase:

  • All services are documented with API references
  • Unit tests provide usage examples
  • Architecture diagrams show component relationships
  • Each folder has detailed README with examples

โœจ WPF HexEditor - A powerful, well-documented hex editor control for .NET

Created by Derek Tremblay (derektremblay666@gmail.com) Contributors: ehsan69h, Janus Tida, Claude Sonnet 4.5

Coded with โค๏ธ for the community! ๐Ÿ˜Š๐ŸคŸ