Reputation: 15
I am trying to make my extension for WinDbg and I need to make a "clickable" command in WinDbg.
For example: https://i.sstatic.net/H85XT.png
This is my code:
#define KDEXT_64BIT
#include "EPBreaker.hpp"
#include "PEInformation.hpp"
#include "PEReader.hpp"
#include <wdbgexts.h>
#include <dbgeng.h>
#include <cstdio>
#include <string>
#include <filesystem>
#define EXTENSION_VERSION_MAJOR 1
#define EXTENSION_VERSION_MINOR 0
extern "C" __declspec(dllexport) HRESULT CALLBACK EPBreaker(IDebugClient4* Client, std::string* Args)
{
IDebugControl* ptrIDebugControl = 0;
IDebugSymbols4* ptrIDebugSymbols = 0;
IDebugBreakpoint* ptrIDebugBreakpoint = 0;
if (Client->QueryInterface(__uuidof(IDebugControl), (PVOID*)&ptrIDebugControl)
!= S_OK) {
ptrIDebugControl->Output(DEBUG_OUTCTL_ALL_CLIENTS, "ERROR ON IDebugControl QueryInterface");
return S_FALSE;
}
if (Client->QueryInterface(__uuidof(IDebugSymbols4), (PVOID*)&ptrIDebugSymbols)
!= S_OK) {
ptrIDebugControl->Output(DEBUG_OUTCTL_ALL_CLIENTS, "ERROR ON IDebugSymbols QueryInterface\n");
return S_FALSE;
}
std::filesystem::path PathToCurrentDebugging;
{
std::string ModuleName; ModuleName.resize(MAX_PATH);
ptrIDebugSymbols->GetModuleNameString(DEBUG_MODNAME_SYMBOL_FILE, 0, DEBUG_ANY_ID, ModuleName.data(), ModuleName.size(), NULL);
PathToCurrentDebugging = ModuleName;
}
PEInformation PEInformation;
PeReader PeReader;
ptrIDebugControl->Output(DEBUG_OUTCTL_ALL_CLIENTS, "PeReader: %s\n", PathToCurrentDebugging.string().c_str());
PEInformation = PeReader.Pe(PathToCurrentDebugging, ptrIDebugControl, PEInformation);
uint64_t EP = PEInformation.pImageNTHeader64->OptionalHeader.AddressOfEntryPoint + PEInformation.pImageNTHeader64->OptionalHeader.ImageBase;
ptrIDebugControl->Output(DEBUG_OUTCTL_ALL_CLIENTS, "EP: %p\n", EP);
return S_OK;
}
extern "C" __declspec(dllexport) HRESULT CALLBACK DebugExtensionInitialize(PULONG Version, PULONG Flag)
{
*Version = DEBUG_EXTENSION_VERSION(EXTENSION_VERSION_MAJOR, EXTENSION_VERSION_MINOR);
*Flag = 0;
return S_OK;
}
Through which windbg API can I make similar "clickable" commands(text(In fact, I do not know what to call it)) as above?
Upvotes: 0
Views: 91
Reputation: 301
What you want is to output DML (debugger markup language). Documentation on DML, the APIs in the debugger which support it, and the tags that are available can be found at:
Upvotes: 1