|
| 1 | +# WinDbg/TTD Installer Implementation |
| 2 | + |
| 3 | +This directory contains the C++ implementation of the WinDbg/TTD automatic installer for Binary Ninja. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The installer was rewritten from Python to C++ to allow it to work with both paid and free versions of Binary Ninja. The original Python implementation (`install_windbg.py`) was restricted to only work with paid versions due to the `#ifdef DEMO_EDITION` check in the UI code. |
| 8 | + |
| 9 | +## Files |
| 10 | + |
| 11 | +- `install_windbg.h` - Header file with function declarations |
| 12 | +- `install_windbg.cpp` - Main implementation with Windows-specific code |
| 13 | + |
| 14 | +## Functionality |
| 15 | + |
| 16 | +The installer performs these steps: |
| 17 | + |
| 18 | +1. **Download AppInstaller**: Downloads the appinstaller XML file from Microsoft's WinDbg download URL |
| 19 | +2. **Parse XML**: Extracts the MSIX bundle URL from the appinstaller XML using pugixml |
| 20 | +3. **Download MSIX Bundle**: Downloads the MSIX bundle containing WinDbg |
| 21 | +4. **Extract Inner MSIX**: Extracts the `windbg_win-x64.msix` file from the bundle |
| 22 | +5. **Extract WinDbg**: Extracts the actual WinDbg files to the user directory |
| 23 | +6. **Validate Installation**: Checks that required files (dbgeng.dll, TTD.exe, etc.) are present |
| 24 | +7. **Update Settings**: Sets the `debugger.x64dbgEngPath` setting to point to the installation |
| 25 | + |
| 26 | +## Dependencies |
| 27 | + |
| 28 | +- **Windows APIs**: URLDownloadToFileA for HTTP downloads, CreateProcess for PowerShell execution |
| 29 | +- **pugixml**: For XML parsing (already included in the project) |
| 30 | +- **PowerShell**: Used for ZIP extraction via System.IO.Compression.FileSystem |
| 31 | +- **Standard C++20**: filesystem, string handling, etc. |
| 32 | + |
| 33 | +## Libraries Required |
| 34 | + |
| 35 | +- urlmon.lib - For URL downloading |
| 36 | +- shell32.lib - For shell operations |
| 37 | +- ole32.lib - For GUID generation |
| 38 | + |
| 39 | +## UI Integration |
| 40 | + |
| 41 | +The installer is called from `ui/ui.cpp` in the `GlobalDebuggerUI::installTTD()` function, which: |
| 42 | +- Shows a progress dialog |
| 43 | +- Runs the installer asynchronously using QTimer |
| 44 | +- Displays success/failure messages |
| 45 | + |
| 46 | +## Error Handling |
| 47 | + |
| 48 | +The implementation includes comprehensive error handling: |
| 49 | +- HTTP download failures |
| 50 | +- XML parsing errors |
| 51 | +- ZIP extraction failures |
| 52 | +- File system errors |
| 53 | +- Process execution errors |
| 54 | + |
| 55 | +All errors are logged using Binary Ninja's logging system and reported to the user via message boxes. |
| 56 | + |
| 57 | +## Testing |
| 58 | + |
| 59 | +Basic functionality can be tested by compiling the XML parsing component separately. The ZIP extraction relies on PowerShell and Windows APIs, so it requires a Windows environment for full testing. |
0 commit comments