Skip to content

Commit c2b742a

Browse files
Copilotxusheng6
authored andcommitted
Rewrite Windbg/TTD installation in C++. Fix #794
1 parent c40b2e6 commit c2b742a

File tree

6 files changed

+721
-32
lines changed

6 files changed

+721
-32
lines changed

core/adapters/dbgeng/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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.

docs/guide/dbgeng-ttd.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,14 @@ There are two ways to install and configure WinDbg to be used by Binary Ninja de
1414
We recommend you to try the first method first.
1515
If it does not work, for example if your machine cannot connect to the Internet, you can follow the second method to set it up manually.
1616

17-
The free version currently does not support installing WinDbg automatically. It needs to be installed manually.
18-
1917
The WinDbg installation only needs to be done once.
2018

2119
### Install WinDbg Automatically
2220

2321
- Open Binary Ninja
2422
- Click Menu -> "Debugger" -> "Install WinDbg/TTD"
25-
- Wait for the script to finish
26-
- Behind the scenes, this runs the Python [script](https://github.com/Vector35/debugger/blob/dev/core/adapters/dbgeng/install_windbg.py) to download and configure WinDbg
23+
- Wait for the installation to finish
24+
- Behind the scenes, this runs a C++ installer that downloads and configures WinDbg
2725
- The WinDbg will be installed to `%APPDATA%\Binary Ninja\windbg`
2826
- Restart Binary Ninja
2927

ui/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,7 @@ set_target_properties(debuggerui PROPERTIES
4141
)
4242

4343
target_link_libraries(debuggerui debuggerapi binaryninjaui Qt6::Core Qt6::Gui Qt6::Widgets)
44+
45+
if(WIN32)
46+
target_link_libraries(debuggerui urlmon.lib shell32.lib ole32.lib)
47+
endif()

0 commit comments

Comments
 (0)