$ show TalAloni/HardDiskValidator
HardDiskValidator is a Windows Forms application for testing hard drives for bad sectors and verifying disk integrity. It provides multiple test modes: read-only scan, read + wipe damaged sectors + read, read + write + verify + restore (non-destructive), and write + verify (destructive). The application uses the DiskAccessLibrary.Win32 NuGet package for low-level physical disk access, requiring administrator privileges. It features a visual block map showing test progress and results, with logging and speed display. The code is well-structured with clear separation between disk I/O (DiskReader, DiskTester) and UI (MainForm, UIHelper). It targets multiple .NET frameworks (2.0, 4.0, Core 3.1) and includes ILMerge for single-file deployment. The repository is a single-project solution with no tests, but the core disk testing logic is robust and handles I/O errors gracefully.
The LLM identified 2 files worth highlighting for reuse:
Provides methods for reading disk sectors with robust error handling. Implements chunked reads to respect MaximumDirectTransferSizeLBA, and a ReadEverySector method that falls back to sector-by-sector reads on bulk read failure to maximize data recovery. Uses events for status and log updates, making it decoupled from the UI. This pattern is reusable for any application needing reliable disk reading with progress feedback.
Extends DiskReader to implement various disk test strategies (read, write+verify, read+wipe+read, etc.). Handles large transfers by splitting into chunks and forcing garbage collection to manage memory. Generates test patterns based on sector index for verification. Demonstrates a clean strategy pattern for different test types and includes write operations with proper error handling. The pattern generation and verification logic could be extracted for other disk testing tools.