Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion api/debuggerapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,5 @@ namespace BinaryNinjaDebuggerAPI {
bool IsWinDbgInstalled(const std::string& installPath = "");
std::string GetWinDbgInstallerPath();
std::string GetWinDbgInstalledVersion(const std::string& installPath = "");
std::string GetWinDbgLatestVersion();

}; // namespace BinaryNinjaDebuggerAPI
1 change: 0 additions & 1 deletion api/ffi.h
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,6 @@ extern "C"
DEBUGGER_FFI_API bool BNDebuggerIsWinDbgInstalled(const char* installPath);
DEBUGGER_FFI_API char* BNDebuggerGetWinDbgInstallerPath(void);
DEBUGGER_FFI_API char* BNDebuggerGetWinDbgInstalledVersion(const char* installPath);
DEBUGGER_FFI_API char* BNDebuggerGetWinDbgLatestVersion(void);

#ifdef __cplusplus
}
Expand Down
9 changes: 0 additions & 9 deletions api/windbginstaller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,3 @@ std::string BinaryNinjaDebuggerAPI::GetWinDbgInstalledVersion(const std::string&
BNDebuggerFreeString(version);
return result;
}


std::string BinaryNinjaDebuggerAPI::GetWinDbgLatestVersion()
{
char* version = BNDebuggerGetWinDbgLatestVersion();
std::string result = version ? version : "";
BNDebuggerFreeString(version);
return result;
}
9 changes: 9 additions & 0 deletions core/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ limitations under the License.
#include "adapters/localwindowskerneladapter.h"
#include "adapters/windowsdumpfile.h"
#include "adapters/windowsnativeadapter.h"
#include "../installer/windbg_version.h"
#endif

using namespace BinaryNinja;
Expand Down Expand Up @@ -116,6 +117,14 @@ static void RegisterSettings()
"description" : "Attempt to unload the already loaded DLL if they are from a wrong path. You may turn this on if the DbgEng DLLs, e.g., dbghelp.dll, is loaded from a wrong path, but it happens early than the debugger initialization",
"ignore" : ["SettingsProjectScope", "SettingsResourceScope"]
})");
settings->RegisterSetting("debugger.windbgVersion",
R"({
"title" : "WinDbg/TTD Version",
"type" : "string",
"default" : ")" + std::string(WinDbgInstaller::kDefaultVersion) + R"(",
"description" : "The WinDbg version that 'Install WinDbg/TTD' downloads, e.g., 1.2603.20001.0. The default is a version validated against the debugger, since new WinDbg releases occasionally break the DbgEng/TTD adapter. Change it to install a different released version.",
"ignore" : ["SettingsProjectScope", "SettingsResourceScope"]
})");
settings->RegisterSetting("debugger.defaultWindowsAdapter",
R"({
"title" : "Default Windows Debug Adapter",
Expand Down
13 changes: 0 additions & 13 deletions core/ffi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2231,13 +2231,6 @@ char* BNDebuggerGetWinDbgInstalledVersion(const char* installPath)
return BNAllocString(version.c_str());
}


char* BNDebuggerGetWinDbgLatestVersion(void)
{
std::string version = GetLatestVersion();
return BNAllocString(version.c_str());
}

#else // !WIN32

// Stub implementations for non-Windows platforms
Expand Down Expand Up @@ -2280,10 +2273,4 @@ char* BNDebuggerGetWinDbgInstalledVersion(const char* installPath)
return BNAllocString("");
}


char* BNDebuggerGetWinDbgLatestVersion(void)
{
return BNAllocString("");
}

#endif // WIN32
96 changes: 5 additions & 91 deletions core/windbginstaller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ InstallResult InstallWinDbg(const std::string& installPath, bool isUpdate) {
if (!installPath.empty()) {
cmdLine += " --path \"" + installPath + "\"";
}
/* Install the version the user has configured, rather than the installer's built-in default */
std::string version = Settings::Instance()->Get<std::string>("debugger.windbgVersion");
if (!version.empty()) {
cmdLine += " --windbg-version \"" + version + "\"";
}

LogInfo("Running: %s", cmdLine.c_str());

Expand Down Expand Up @@ -160,92 +165,6 @@ InstallResult InstallWinDbg(const std::string& installPath, bool isUpdate) {
}
}

/* Helper function to run installer CLI and capture JSON output */
static std::string RunInstallerCommand(const std::string& command, const std::string& extraArgs = "") {
std::string installerPath = GetInstallerPath();
if (installerPath.empty()) {
return "";
}

std::string cmdLine = "\"" + installerPath + "\" " + command + " --json";
if (!extraArgs.empty()) {
cmdLine += " " + extraArgs;
}

/* Create pipes for stdout */
SECURITY_ATTRIBUTES sa = {};
sa.nLength = sizeof(sa);
sa.bInheritHandle = TRUE;

HANDLE hReadPipe, hWritePipe;
if (!CreatePipe(&hReadPipe, &hWritePipe, &sa, 0)) {
return "";
}

/* Ensure read handle is not inherited */
SetHandleInformation(hReadPipe, HANDLE_FLAG_INHERIT, 0);

STARTUPINFOA si = {};
si.cb = sizeof(si);
si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
si.hStdOutput = hWritePipe;
si.hStdError = hWritePipe;
si.wShowWindow = SW_HIDE;

PROCESS_INFORMATION pi = {};

if (!CreateProcessA(
nullptr,
const_cast<char*>(cmdLine.c_str()),
nullptr,
nullptr,
TRUE, /* Inherit handles */
CREATE_NO_WINDOW,
nullptr,
nullptr,
&si,
&pi)) {
CloseHandle(hReadPipe);
CloseHandle(hWritePipe);
return "";
}

/* Close write end in parent */
CloseHandle(hWritePipe);

/* Read output */
std::string output;
char buffer[4096];
DWORD bytesRead;
while (ReadFile(hReadPipe, buffer, sizeof(buffer) - 1, &bytesRead, nullptr) && bytesRead > 0) {
buffer[bytesRead] = '\0';
output += buffer;
}

CloseHandle(hReadPipe);

WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);

return output;
}

/* Simple JSON value extractor - finds "key":"value" pattern */
static std::string ExtractJsonValue(const std::string& json, const std::string& key) {
std::string searchKey = "\"" + key + "\":\"";
size_t pos = json.find(searchKey);
if (pos == std::string::npos) {
return "";
}
pos += searchKey.length();
size_t endPos = json.find("\"", pos);
if (endPos == std::string::npos) {
return "";
}
return json.substr(pos, endPos - pos);
}

std::string GetInstalledVersion(const std::string& installPath) {
/* Read version directly from marker file (fast, no CLI call needed) */
std::string path = installPath;
Expand Down Expand Up @@ -278,11 +197,6 @@ std::string GetInstalledVersion(const std::string& installPath) {
return "";
}

std::string GetLatestVersion() {
std::string output = RunInstallerCommand("check-update");
return ExtractJsonValue(output, "latest");
}

} // namespace BinaryNinjaDebugger

#endif // WIN32
7 changes: 0 additions & 7 deletions core/windbginstaller.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,6 @@ std::string GetInstallerPath();
*/
std::string GetInstalledVersion(const std::string& installPath = "");

/*
* Get the latest available WinDbg version from Microsoft
*
* @return Version string, or empty on error
*/
std::string GetLatestVersion();

} // namespace BinaryNinjaDebugger

#endif // WIN32
30 changes: 23 additions & 7 deletions docs/guide/dbgeng-ttd.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The WinDbg installation only needs to be done once.
- Open Binary Ninja
- Click `Debugger` -> `Install WinDbg/TTD` from the menu
- A dialog will appear showing the installation progress:
- The installer automatically downloads the latest WinDbg from Microsoft
- The installer downloads a specific WinDbg version from Microsoft
- It extracts the necessary files (DbgEng DLLs and TTD components)
- WinDbg will be installed to `%APPDATA%\Binary Ninja\windbg`
- Progress and status are displayed in real-time
Expand All @@ -32,17 +32,33 @@ The WinDbg installation only needs to be done once.

The automatic installer handles all the complexity of downloading and extracting the WinDbg MSIX bundle.

### Update WinDbg/TTD
By default, the installer installs a WinDbg version that has been validated against the debugger, rather than the newest release.
New WinDbg releases occasionally ship regressions that break the DbgEng/TTD adapter, so the default version is bumped only after the new release has been tested.

If you already have WinDbg/TTD installed and want to check for updates:
#### Select the WinDbg Version to Install

The version that the installer downloads is controlled by the `debugger.windbgVersion` setting:

- In Binary Ninja, open the Settings view via the menu `Edit` -> `Settings`, or use the shortcut (Ctrl+,)
- Search for `debugger.windbgVersion`
- Set it to the version you wish to install, e.g., `1.2603.20001.0`
- Any released WinDbg version can be used, as long as Microsoft still hosts its MSIX bundle at
`https://windbg.download.prss.microsoft.com/dbazure/prod/<version-with-dashes>/windbg.msixbundle`
- Leave it at its default value unless you have a reason to use a different version
- Click `Debugger` -> `Install WinDbg/TTD` to install the version you have set

### Reinstall WinDbg/TTD

If you already have WinDbg/TTD installed:

- Click `Debugger` -> `Install WinDbg/TTD` from the menu
- A dialog will appear showing:
- The currently installed version
- The latest available version from Microsoft
- If a newer version is available, click "Update" to download and install it
- If you are already on the latest version, the dialog will indicate that no update is needed
- Restart Binary Ninja after updating
- The version that will be installed, i.e., the value of `debugger.windbgVersion`
- If the two match, you can click "Reinstall" to install it again, e.g. if the installation was damaged
- If they differ, click "Install" to replace the installed version with the configured one.
Note this can be a downgrade: if you installed a newer WinDbg yourself, this replaces it with the configured version
- Restart Binary Ninja afterwards

<img src="../../img/debugger/ttd_update_windbg.png" width="600px">

Expand Down
Binary file modified docs/img/debugger/ttd_update_windbg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions installer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ set(INSTALLER_LIB_HEADERS
http_downloader.h
zip_extractor.h
windbg_installer.h
windbg_version.h
signature_verifier.h
)

Expand Down
Loading