Luaexts is an extension for Windbg (and the other dbgeng-based debuggers) that provides access to the dbgeng COM API from Lua. It also implements a lightweight framework for writing extensions in Lua.
Within Windbg, run the following command:
To verify that the extension loaded correctly, run the following command:
The growing list of supported dbgeng API functions can be accessed through the global table dbgeng. The table is split up into sub-tables matching the organization of the dbgeng API itself. So the functions from the IDebugSymbols interface (as well as IDebugSymbols2, etc) can be found in the dbgeng.symbols table.
As an example, here’s how to call the IDebugSymbols::GetSymbolTypeId function, use the return values to call the IDebugSymbols::GetTypeName function, and then print the type name of a variable named foo that exists in the current scope:
!lua local module, typeid = dbgeng.symbols.get_symbol_type_id( 'foo' ) say( dbgeng.symbols.get_type_name( module, typeid ) )
or without the temporary variables:
!lua say( dbgeng.symbols.get_type_name( dbgeng.symbols.get_symbol_type_id( 'foo' ) ) )
Small side note: A global function called
say() is available that takes the place of Lua’s normal
print() function: it prints whatever is given to it and appends a newline. The
print() function has been overridden to output without a newline.
The luaexts API is divided into two categories: 1) the exposed dbgeng COM API; and 2) the additional
API that luaexts provides, sometimes as higher level constructs on top of the dbgeng API like
cppobj, and sometimes as Lua-extension scaffolding like register_extension().