Skip to content
Merged
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
37 changes: 37 additions & 0 deletions src/ida_pro_mcp/mcp-plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,43 @@ def list_globals(
"""List all globals in the database (paginated)"""
return list_globals_filter(offset, count, "")

class Import(TypedDict):
address: str
name: str
library: str

@jsonrpc
@idaread
def list_imports(
offset: Annotated[int, "Offset to start listing from (start at 0)"],
count: Annotated[int, "Number of imports to list (100 is a good default, 0 means remainder)"],
) -> Page[Import]:
""" List all imported symbols with their name and module (paginated) """
nimps = ida_nalt.get_import_module_qty()

rv = []
for i in range(nimps):
module_name = ida_nalt.get_import_module_name(i)
if not module_name:
module_name = "<unnamed>"

def imp_cb(ea, symbol_name, ordinal, acc):
if not symbol_name:
symbol_name = f"#{ordinal}"

acc += [{
"module": module_name,
"imported_name": symbol_name,
"address": hex(ea),
}]

return True

imp_cb_w_context = lambda ea, symbol_name, ordinal: imp_cb(ea, symbol_name, ordinal, rv)
ida_nalt.enum_import_names(i, imp_cb_w_context)

return paginate(rv, offset, count)

class String(TypedDict):
address: str
length: int
Expand Down