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
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,16 @@ endif()

add_subdirectory(core)
add_subdirectory(api)

if(NOT HEADLESS)
add_subdirectory(ui)
endif()

if (NOT DEMO)
add_subdirectory(cli)
endif()

# WinDbg installer CLI (standalone, spawned by debuggercore API)
if(WIN32)
add_subdirectory(installer)
endif()
19 changes: 19 additions & 0 deletions api/debuggerapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ limitations under the License.
#include "ffi.h"
#include "../vendor/intx/intx.hpp"
#include <optional>
#include <functional>

using namespace BinaryNinja;

Expand Down Expand Up @@ -842,4 +843,22 @@ namespace BinaryNinjaDebuggerAPI {
bool CanConnect(Ref<BinaryView> data);
static std::vector<std::string> GetAvailableAdapters(Ref<BinaryView> data);
};


// WinDbg Installer API (Windows only, stubs on other platforms)
struct InstallResult
{
bool success;
std::string errorMessage; // Empty if success, otherwise describes the error

InstallResult() : success(false) {}
InstallResult(bool s, const std::string& err = "") : success(s), errorMessage(err) {}
};

InstallResult InstallWinDbg(const std::string& installPath = "", bool isUpdate = false);
bool IsWinDbgInstalled(const std::string& installPath = "");
std::string GetWinDbgInstallerPath();
std::string GetWinDbgInstalledVersion(const std::string& installPath = "");
std::string GetWinDbgLatestVersion();

}; // namespace BinaryNinjaDebuggerAPI
14 changes: 14 additions & 0 deletions api/ffi.h
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,20 @@ extern "C"

DEBUGGER_FFI_API bool BNDebuggerFunctionExistsInOldView(BNDebuggerController* controller, uint64_t address);

// WinDbg Installer (Windows only)
typedef struct BNDebuggerInstallResult
{
bool success;
char* errorMessage; // NULL if success, otherwise error description (caller must free)
} BNDebuggerInstallResult;

DEBUGGER_FFI_API BNDebuggerInstallResult BNDebuggerInstallWinDbg(const char* installPath, bool isUpdate);
DEBUGGER_FFI_API void BNDebuggerFreeInstallResult(BNDebuggerInstallResult* result);
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
}
#endif
68 changes: 68 additions & 0 deletions api/windbginstaller.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
Copyright 2020-2026 Vector 35 Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#include "debuggerapi.h"

using namespace BinaryNinjaDebuggerAPI;


InstallResult BinaryNinjaDebuggerAPI::InstallWinDbg(const std::string& installPath, bool isUpdate)
{
BNDebuggerInstallResult ffiResult = BNDebuggerInstallWinDbg(installPath.empty() ? nullptr : installPath.c_str(), isUpdate);

InstallResult result;
result.success = ffiResult.success;
if (ffiResult.errorMessage)
{
result.errorMessage = ffiResult.errorMessage;
}

BNDebuggerFreeInstallResult(&ffiResult);
return result;
}


bool BinaryNinjaDebuggerAPI::IsWinDbgInstalled(const std::string& installPath)
{
return BNDebuggerIsWinDbgInstalled(installPath.empty() ? nullptr : installPath.c_str());
}


std::string BinaryNinjaDebuggerAPI::GetWinDbgInstallerPath()
{
char* path = BNDebuggerGetWinDbgInstallerPath();
std::string result = path ? path : "";
BNDebuggerFreeString(path);
return result;
}


std::string BinaryNinjaDebuggerAPI::GetWinDbgInstalledVersion(const std::string& installPath)
{
char* version = BNDebuggerGetWinDbgInstalledVersion(installPath.empty() ? nullptr : installPath.c_str());
std::string result = version ? version : "";
BNDebuggerFreeString(version);
return result;
}


std::string BinaryNinjaDebuggerAPI::GetWinDbgLatestVersion()
{
char* version = BNDebuggerGetWinDbgLatestVersion();
std::string result = version ? version : "";
BNDebuggerFreeString(version);
return result;
}
111 changes: 111 additions & 0 deletions core/ffi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1690,3 +1690,114 @@ bool BNDebuggerFunctionExistsInOldView(BNDebuggerController* controller, uint64_
{
return controller->object->FunctionExistsInOldView(address);
}


// WinDbg Installer FFI implementations (Windows only)
#ifdef WIN32
#include "windbginstaller.h"

BNDebuggerInstallResult BNDebuggerInstallWinDbg(const char* installPath, bool isUpdate)
{
std::string path = installPath ? installPath : "";
BinaryNinjaDebugger::InstallResult result = InstallWinDbg(path, isUpdate);

BNDebuggerInstallResult ffiResult;
ffiResult.success = result.success;
if (!result.errorMessage.empty())
{
ffiResult.errorMessage = BNAllocString(result.errorMessage.c_str());
}
else
{
ffiResult.errorMessage = nullptr;
}
return ffiResult;
}

void BNDebuggerFreeInstallResult(BNDebuggerInstallResult* result)
{
if (result && result->errorMessage)
{
BNFreeString(result->errorMessage);
result->errorMessage = nullptr;
}
}


bool BNDebuggerIsWinDbgInstalled(const char* installPath)
{
std::string path = installPath ? installPath : "";
return IsWinDbgInstalled(path);
}


char* BNDebuggerGetWinDbgInstallerPath(void)
{
std::string path = GetInstallerPath();
return BNAllocString(path.c_str());
}


char* BNDebuggerGetWinDbgInstalledVersion(const char* installPath)
{
std::string path = installPath ? installPath : "";
std::string version = GetInstalledVersion(path);
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
BNDebuggerInstallResult BNDebuggerInstallWinDbg(const char* installPath, bool isUpdate)
{
(void)installPath;
(void)isUpdate;
BNDebuggerInstallResult result;
result.success = false;
result.errorMessage = BNAllocString("WinDbg installation is only supported on Windows");
return result;
}

void BNDebuggerFreeInstallResult(BNDebuggerInstallResult* result)
{
if (result && result->errorMessage)
{
BNFreeString(result->errorMessage);
result->errorMessage = nullptr;
}
}


bool BNDebuggerIsWinDbgInstalled(const char* installPath)
{
(void)installPath;
return false;
}


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


char* BNDebuggerGetWinDbgInstalledVersion(const char* installPath)
{
(void)installPath;
return BNAllocString("");
}


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

#endif // WIN32
Loading