Binary Ninja API C++: Plugin
The PluginCommand class is used for registering "commands" for Plugins, corresponding to code in those plugins to be executed.
The proper way to use this class is via one of the "Register*" static methods.
Public Member Functions | |
| PluginCommand (const BNPluginCommand &cmd) | |
| PluginCommand (const PluginCommand &cmd) | |
| ~PluginCommand () | |
| PluginCommand & | operator= (const PluginCommand &cmd) |
| std::string | GetName () const |
| Get the name for the registered PluginCommand. | |
| std::string | GetDescription () const |
| Get the description for the registered PluginCommand. | |
| BNPluginCommandType | GetType () const |
| Get the type of the registered PluginCommand. | |
| const BNPluginCommand * | GetObject () const |
| bool | IsValid (const PluginCommandContext &ctxt) const |
| void | Execute (const PluginCommandContext &ctxt) const |
Static Public Member Functions | |
| static void | Register (const std::string &name, const std::string &description, const std::function< void(BinaryView *view)> &action) |
| Register a command for a given BinaryView. | |
| static void | Register (const std::string &name, const std::string &description, const std::function< void(BinaryView *view)> &action, const std::function< bool(BinaryView *view)> &isValid) |
| Register a command for a given BinaryView, with a validity check. | |
| static void | RegisterForAddress (const std::string &name, const std::string &description, const std::function< void(BinaryView *view, uint64_t addr)> &action) |
| Register a command for a given BinaryView, when an address is selected. | |
| static void | RegisterForAddress (const std::string &name, const std::string &description, const std::function< void(BinaryView *view, uint64_t addr)> &action, const std::function< bool(BinaryView *view, uint64_t addr)> &isValid) |
| Register a command for a given BinaryView and an address, with a validity check. | |
| static void | RegisterForRange (const std::string &name, const std::string &description, const std::function< void(BinaryView *view, uint64_t addr, uint64_t len)> &action) |
| Register a command for a given BinaryView, when a range of address is selected. | |
| static void | RegisterForRange (const std::string &name, const std::string &description, const std::function< void(BinaryView *view, uint64_t addr, uint64_t len)> &action, const std::function< bool(BinaryView *view, uint64_t addr, uint64_t len)> &isValid) |
| Register a command for a given BinaryView and a range, with a validity check. | |
| static void | RegisterForFunction (const std::string &name, const std::string &description, const std::function< void(BinaryView *view, Function *func)> &action) |
| Register a command for a given BinaryView within a function. | |
| static void | RegisterForFunction (const std::string &name, const std::string &description, const std::function< void(BinaryView *view, Function *func)> &action, const std::function< bool(BinaryView *view, Function *func)> &isValid) |
| Register a command for a given BinaryView and a function, with a validity check. | |
| static void | RegisterForLowLevelILFunction (const std::string &name, const std::string &description, const std::function< void(BinaryView *view, LowLevelILFunction *func)> &action) |
| Register a command for a given BinaryView within a LowLevelILFunction. | |
| static void | RegisterForLowLevelILFunction (const std::string &name, const std::string &description, const std::function< void(BinaryView *view, LowLevelILFunction *func)> &action, const std::function< bool(BinaryView *view, LowLevelILFunction *func)> &isValid) |
| Register a command for a given BinaryView and a Low Level IL function, with a validity check. | |
| static void | RegisterForLowLevelILInstruction (const std::string &name, const std::string &description, const std::function< void(BinaryView *view, const LowLevelILInstruction &instr)> &action) |
| Register a command for a given BinaryView with a given LowLevelILInstruction. | |
| static void | RegisterForLowLevelILInstruction (const std::string &name, const std::string &description, const std::function< void(BinaryView *view, const LowLevelILInstruction &instr)> &action, const std::function< bool(BinaryView *view, const LowLevelILInstruction &instr)> &isValid) |
| Register a command for a given BinaryView and a LowLevelILInstruction, with a validity check. | |
| static void | RegisterForMediumLevelILFunction (const std::string &name, const std::string &description, const std::function< void(BinaryView *view, MediumLevelILFunction *func)> &action) |
| Register a command for a given BinaryView within a MediumLevelILFunction. | |
| static void | RegisterForMediumLevelILFunction (const std::string &name, const std::string &description, const std::function< void(BinaryView *view, MediumLevelILFunction *func)> &action, const std::function< bool(BinaryView *view, MediumLevelILFunction *func)> &isValid) |
| Register a command for a given BinaryView and a Medium Level IL function, with a validity check. | |
| static void | RegisterForMediumLevelILInstruction (const std::string &name, const std::string &description, const std::function< void(BinaryView *view, const MediumLevelILInstruction &instr)> &action) |
| Register a command for a given BinaryView with a given MediumLevelILInstruction. | |
| static void | RegisterForMediumLevelILInstruction (const std::string &name, const std::string &description, const std::function< void(BinaryView *view, const MediumLevelILInstruction &instr)> &action, const std::function< bool(BinaryView *view, const MediumLevelILInstruction &instr)> &isValid) |
| Register a command for a given BinaryView and a MediumLevelILInstruction, with a validity check. | |
| static void | RegisterForHighLevelILFunction (const std::string &name, const std::string &description, const std::function< void(BinaryView *view, HighLevelILFunction *func)> &action) |
| Register a command for a given BinaryView within a HighLevelILFunction. | |
| static void | RegisterForHighLevelILFunction (const std::string &name, const std::string &description, const std::function< void(BinaryView *view, HighLevelILFunction *func)> &action, const std::function< bool(BinaryView *view, HighLevelILFunction *func)> &isValid) |
| Register a command for a given BinaryView and a High Level IL function, with a validity check. | |
| static void | RegisterForHighLevelILInstruction (const std::string &name, const std::string &description, const std::function< void(BinaryView *view, const HighLevelILInstruction &instr)> &action) |
| Register a command for a given BinaryView with a given HighLevelILInstruction. | |
| static void | RegisterForHighLevelILInstruction (const std::string &name, const std::string &description, const std::function< void(BinaryView *view, const HighLevelILInstruction &instr)> &action, const std::function< bool(BinaryView *view, const HighLevelILInstruction &instr)> &isValid) |
| Register a command for a given BinaryView and a HighLevelILInstruction, with a validity check. | |
| static void | RegisterForProject (const std::string &name, const std::string &description, const std::function< void(Project *project)> &action) |
| static void | RegisterForProject (const std::string &name, const std::string &description, const std::function< void(Project *project)> &action, const std::function< bool(Project *project)> &isValid) |
| static std::vector< PluginCommand > | GetList () |
| Get the list of registered PluginCommands. | |
| static std::vector< PluginCommand > | GetValidList (const PluginCommandContext &ctxt) |
| Get the list of valid PluginCommands for a given context. | |
◆ PluginCommand() [1/2]
◆ PluginCommand() [2/2]
| PluginCommand::PluginCommand | ( | const PluginCommand & | cmd | ) |
◆ ~PluginCommand()
| PluginCommand::~PluginCommand | ( | ) |
◆ operator=()
| PluginCommand & PluginCommand::operator= | ( | const PluginCommand & | cmd | ) |
◆ Register() [1/2]
|
static |
Register a command for a given BinaryView.
This will appear in the top menu and the right-click context menu.
PluginCommand::Register("MyPlugin\\MyAction", "Perform an action",
{
});
void MyPlugin::MyCommand(BinaryView* view)
{
}
PluginCommand::Register("MyPlugin\\MySecondAction", "Perform an action", MyPlugin::MyCommand);
- Parameters
-
name Name of the command to register. This will appear in the top menu and the context menu.
You can register submenus to an item by separating names with a
"\\". The base (farthest right) name will be the item which upon being clicked will perform the action.description Description of the command action Action to perform
◆ Register() [2/2]
|
static |
Register a command for a given BinaryView, with a validity check.
This will appear in the top menu and the right-click context menu.
PluginCommand::Register("MyPlugin\\MyAction", "Perform an action",
{
},
{
});
void MyPlugin::MyCommand(BinaryView* view)
{
}
PluginCommand::Register("MyPlugin\\MySecondAction", "Perform an action", MyPlugin::MyCommand,
[](BinaryView *view){ return view->HasSymbols(); });
- Parameters
-
name Name of the command to register. This will appear in the top menu and the context menu.
You can register submenus to an item by separating names with a
"\\". The base (farthest right) name will be the item which upon being clicked will perform the action.description Description of the command action Action to perform isValid Function that returns whether the command is allowed to be performed.
◆ RegisterForAddress() [1/2]
|
static |
Register a command for a given BinaryView, when an address is selected.
This will appear in the top menu and the right-click context menu.
PluginCommand::RegisterForAddress("MyPlugin\\MyAddressAction", "Perform an action on an address",
{
});
void MyPlugin::MyCommand(BinaryView* view, uint64_t addr)
{
}
PluginCommand::RegisterForAddress("MyPlugin\\MySecondAddressAction", "Perform an action", MyPlugin::MyCommand);
- Parameters
-
name Name of the command to register. This will appear in the top menu and the context menu.
You can register submenus to an item by separating names with a
"\\". The base (farthest right) name will be the item which upon being clicked will perform the action.description Description of the command action Action to perform
◆ RegisterForAddress() [2/2]
|
static |
Register a command for a given BinaryView and an address, with a validity check.
This will appear in the top menu and the right-click context menu.
PluginCommand::RegisterForAddress("MyPlugin\\MyAddressAction", "Perform an action",
{
},
{
});
void MyPlugin::MyCommand(BinaryView* view, uint64_t addr)
{
}
PluginCommand::RegisterForAddress("MyPlugin\\MySecondAddressAction", "Perform an action", MyPlugin::MyCommand,
[](BinaryView *view, uint64_t addr){ return view->HasSymbols(); });
- Parameters
-
name Name of the command to register. This will appear in the top menu and the context menu.
You can register submenus to an item by separating names with a
"\\". The base (farthest right) name will be the item which upon being clicked will perform the action.description Description of the command action Action to perform isValid Expression that returns whether the command is allowed to be performed.
◆ RegisterForRange() [1/2]
|
static |
Register a command for a given BinaryView, when a range of address is selected.
This will appear in the top menu and the right-click context menu.
PluginCommand::RegisterForRange("MyPlugin\\MyRangeAction", "Perform an action on a range",
[](BinaryView* view, uint64_t addr, uint64_t len)
{
});
void MyPlugin::MyCommand(BinaryView* view, uint64_t addr, uint64_t len)
{
}
PluginCommand::RegisterForRange("MyPlugin\\MySecondRangeAction", "Perform an action", MyPlugin::MyCommand);
- Parameters
-
name Name of the command to register. This will appear in the top menu and the context menu.
You can register submenus to an item by separating names with a
"\\". The base (farthest right) name will be the item which upon being clicked will perform the action.description Description of the command action Action to perform
◆ RegisterForRange() [2/2]
|
static |
Register a command for a given BinaryView and a range, with a validity check.
This will appear in the top menu and the right-click context menu.
PluginCommand::RegisterForRange("MyPlugin\\MyRangeAction", "Perform an action",
[](BinaryView* view, uint64_t addr, uint64_t len)
{
},
[](BinaryView* view, uint64_t addr, uint64_t len)
{
});
void MyPlugin::MyCommand(BinaryView* view, uint64_t addr, uint64_t len)
{
}
PluginCommand::RegisterForRange("MyPlugin\\MySecondRangeAction", "Perform an action", MyPlugin::MyCommand,
[](BinaryView *view, uint64_t addr, uint64_t len){ return view->HasSymbols(); });
- Parameters
-
name Name of the command to register. This will appear in the top menu and the context menu.
You can register submenus to an item by separating names with a
"\\". The base (farthest right) name will be the item which upon being clicked will perform the action.description Description of the command action Action to perform isValid Expression that returns whether the command is allowed to be performed.
◆ RegisterForFunction() [1/2]
|
static |
Register a command for a given BinaryView within a function.
This will appear in the top menu and the right-click context menu.
PluginCommand::RegisterForFunction("MyPlugin\\MyFunctionAction", "Perform an action on a function",
{
});
{
}
PluginCommand::RegisterForFunction("MyPlugin\\MySecondFunctionAction", "Perform an action", MyPlugin::MyCommand);
- Parameters
-
name Name of the command to register. This will appear in the top menu and the context menu.
You can register submenus to an item by separating names with a
"\\". The base (farthest right) name will be the item which upon being clicked will perform the action.description Description of the command action Action to perform
◆ RegisterForFunction() [2/2]
|
static |
Register a command for a given BinaryView and a function, with a validity check.
This will appear in the top menu and the right-click context menu.
PluginCommand::RegisterForFunction("MyPlugin\\MyFunctionAction", "Perform an action",
{
},
{
});
void MyPlugin::MyCommand(BinaryView* view, Function* func)
{
}
PluginCommand::RegisterForFunction("MyPlugin\\MySecondFunctionAction", "Perform an action", MyPlugin::MyCommand,
[](BinaryView *view, Function* func){ return view->HasSymbols(); });
- Parameters
-
name Name of the command to register. This will appear in the top menu and the context menu.
You can register submenus to an item by separating names with a
"\\". The base (farthest right) name will be the item which upon being clicked will perform the action.description Description of the command action Action to perform isValid Expression that returns whether the command is allowed to be performed.
◆ RegisterForLowLevelILFunction() [1/2]
|
static |
Register a command for a given BinaryView within a LowLevelILFunction.
This will appear in the top menu and the right-click context menu.
PluginCommand::RegisterForLowLevelILFunction("MyPlugin\\MyLLILFunctionAction", "Perform an action on a llil function",
{
});
{
}
PluginCommand::RegisterForLowLevelILFunction("MyPlugin\\MySecondLLILAction", "Perform an action", MyPlugin::MyCommand);
- Parameters
-
name Name of the command to register. This will appear in the top menu and the context menu.
You can register submenus to an item by separating names with a
"\\". The base (farthest right) name will be the item which upon being clicked will perform the action.description Description of the command action Action to perform
◆ RegisterForLowLevelILFunction() [2/2]
|
static |
Register a command for a given BinaryView and a Low Level IL function, with a validity check.
This will appear in the top menu and the right-click context menu.
PluginCommand::RegisterForLowLevelILFunction("MyPlugin\\MyLLILFunctionAction", "Perform an action",
{
},
{
});
void MyPlugin::MyCommand(BinaryView* view, LowLevelILFunction* func)
{
}
PluginCommand::RegisterForLowLevelILFunction("MyPlugin\\MySecondLLILAction", "Perform an action", MyPlugin::MyCommand,
[](BinaryView *view, LowLevelILFunction* func){ return view->HasSymbols(); });
- Parameters
-
name Name of the command to register. This will appear in the top menu and the context menu.
You can register submenus to an item by separating names with a
"\\". The base (farthest right) name will be the item which upon being clicked will perform the action.description Description of the command action Action to perform isValid Expression that returns whether the command is allowed to be performed.
◆ RegisterForLowLevelILInstruction() [1/2]
|
static |
Register a command for a given BinaryView with a given LowLevelILInstruction.
This will appear in the top menu and the right-click context menu.
PluginCommand::RegisterForRegisterForLowLevelILInstruction("MyPlugin\\MyLLILInstructionAction",
"Perform an action on an instruction",
{
});
{
}
PluginCommand::RegisterForLowLevelILInstruction("MyPlugin\\MySecondLLILAction", "Perform an action", MyPlugin::MyCommand);
- Parameters
-
name Name of the command to register. This will appear in the top menu and the context menu.
You can register submenus to an item by separating names with a
"\\". The base (farthest right) name will be the item which upon being clicked will perform the action.description Description of the command action Action to perform
◆ RegisterForLowLevelILInstruction() [2/2]
|
static |
Register a command for a given BinaryView and a LowLevelILInstruction, with a validity check.
This will appear in the top menu and the right-click context menu.
PluginCommand::RegisterForLowLevelILInstruction("MyPlugin\\MyLLILInstructionAction", "Perform an action",
{
},
{
});
void MyPlugin::MyCommand(BinaryView* view, LowLevelILInstruction* instr)
{
}
PluginCommand::RegisterForLowLevelILInstruction("MyPlugin\\MySecondLLILAction",
"Perform an action", MyPlugin::MyCommand,
[](BinaryView *view, LowLevelILInstruction* instr){ return view->HasSymbols(); });
- Parameters
-
name Name of the command to register. This will appear in the top menu and the context menu.
You can register submenus to an item by separating names with a
"\\". The base (farthest right) name will be the item which upon being clicked will perform the action.description Description of the command action Action to perform isValid Expression that returns whether the command is allowed to be performed.
◆ RegisterForMediumLevelILFunction() [1/2]
|
static |
Register a command for a given BinaryView within a MediumLevelILFunction.
This will appear in the top menu and the right-click context menu.
PluginCommand::RegisterForMediumLevelILFunction("MyPlugin\\MyMLILFunctionAction", "Perform an action on a mlil function",
{
});
{
}
PluginCommand::RegisterForMediumLevelILFunction("MyPlugin\\MySecondMLILAction", "Perform an action", MyPlugin::MyCommand);
- Parameters
-
name Name of the command to register. This will appear in the top menu and the context menu.
You can register submenus to an item by separating names with a
"\\". The base (farthest right) name will be the item which upon being clicked will perform the action.description Description of the command action Action to perform
◆ RegisterForMediumLevelILFunction() [2/2]
Register a command for a given BinaryView and a Medium Level IL function, with a validity check.
This will appear in the top menu and the right-click context menu.
PluginCommand::RegisterForMediumLevelILFunction("MyPlugin\\MyMLILFunctionAction", "Perform an action",
{
},
{
});
void MyPlugin::MyCommand(BinaryView* view, MediumLevelILFunction* func)
{
}
PluginCommand::RegisterForMediumLevelILFunction("MyPlugin\\MySecondMLILAction", "Perform an action", MyPlugin::MyCommand,
[](BinaryView *view, MediumLevelILFunction* func){ return view->HasSymbols(); });
- Parameters
-
name Name of the command to register. This will appear in the top menu and the context menu.
You can register submenus to an item by separating names with a
"\\". The base (farthest right) name will be the item which upon being clicked will perform the action.description Description of the command action Action to perform isValid Expression that returns whether the command is allowed to be performed.
◆ RegisterForMediumLevelILInstruction() [1/2]
|
static |
Register a command for a given BinaryView with a given MediumLevelILInstruction.
This will appear in the top menu and the right-click context menu.
PluginCommand::RegisterForRegisterForMediumLevelILInstruction("MyPlugin\\MyMLILInstructionAction",
"Perform an action on an instruction",
{
});
{
}
PluginCommand::RegisterForMediumLevelILInstruction("MyPlugin\\MySecondMLILAction", "Perform an action", MyPlugin::MyCommand);
- Parameters
-
name Name of the command to register. This will appear in the top menu and the context menu.
You can register submenus to an item by separating names with a
"\\". The base (farthest right) name will be the item which upon being clicked will perform the action.description Description of the command action Action to perform
◆ RegisterForMediumLevelILInstruction() [2/2]
Register a command for a given BinaryView and a MediumLevelILInstruction, with a validity check.
This will appear in the top menu and the right-click context menu.
PluginCommand::RegisterForMediumLevelILInstruction("MyPlugin\\MyMLILInstructionAction", "Perform an action",
{
},
{
});
void MyPlugin::MyCommand(BinaryView* view, MediumLevelILInstruction* instr)
{
}
PluginCommand::RegisterForMediumLevelILInstruction("MyPlugin\\MySecondMLILAction",
"Perform an action", MyPlugin::MyCommand,
[](BinaryView *view, MediumLevelILInstruction* instr){ return view->HasSymbols(); });
- Parameters
-
name Name of the command to register. This will appear in the top menu and the context menu.
You can register submenus to an item by separating names with a
"\\". The base (farthest right) name will be the item which upon being clicked will perform the action.description Description of the command action Action to perform isValid Expression that returns whether the command is allowed to be performed.
◆ RegisterForHighLevelILFunction() [1/2]
|
static |
Register a command for a given BinaryView within a HighLevelILFunction.
This will appear in the top menu and the right-click context menu.
PluginCommand::RegisterForHighLevelILFunction("MyPlugin\\MyHLILFunctionAction", "Perform an action on a hlil function",
{
});
{
}
PluginCommand::RegisterForMediumLevelILFunction("MyPlugin\\MySecondHLILAction", "Perform an action", MyPlugin::MyCommand);
- Parameters
-
name Name of the command to register. This will appear in the top menu and the context menu.
You can register submenus to an item by separating names with a
"\\". The base (farthest right) name will be the item which upon being clicked will perform the action.description Description of the command action Action to perform
◆ RegisterForHighLevelILFunction() [2/2]
|
static |
Register a command for a given BinaryView and a High Level IL function, with a validity check.
This will appear in the top menu and the right-click context menu.
PluginCommand::RegisterForHighLevelILFunction("MyPlugin\\MyHLILFunctionAction", "Perform an action",
{
},
{
});
void MyPlugin::MyCommand(BinaryView* view, HighLevelILFunction* func)
{
}
PluginCommand::RegisterForHighLevelILFunction("MyPlugin\\MySecondHLILAction", "Perform an action", MyPlugin::MyCommand,
[](BinaryView *view, HighLevelILFunction* func){ return view->HasSymbols(); });
- Parameters
-
name Name of the command to register. This will appear in the top menu and the context menu.
You can register submenus to an item by separating names with a
"\\". The base (farthest right) name will be the item which upon being clicked will perform the action.description Description of the command action Action to perform isValid Expression that returns whether the command is allowed to be performed.
◆ RegisterForHighLevelILInstruction() [1/2]
|
static |
Register a command for a given BinaryView with a given HighLevelILInstruction.
This will appear in the top menu and the right-click context menu.
PluginCommand::RegisterForRegisterForHighLevelILInstruction("MyPlugin\\MyHLILInstructionAction",
"Perform an action on an instruction",
{
});
{
}
PluginCommand::RegisterForHighLevelILInstruction("MyPlugin\\MySecondHLILAction", "Perform an action", MyPlugin::MyCommand);
- Parameters
-
name Name of the command to register. This will appear in the top menu and the context menu.
You can register submenus to an item by separating names with a
"\\". The base (farthest right) name will be the item which upon being clicked will perform the action.description Description of the command action Action to perform
◆ RegisterForHighLevelILInstruction() [2/2]
|
static |
Register a command for a given BinaryView and a HighLevelILInstruction, with a validity check.
This will appear in the top menu and the right-click context menu.
PluginCommand::RegisterForHighLevelILInstruction("MyPlugin\\MyHLILInstructionAction", "Perform an action",
{
},
{
});
void MyPlugin::MyCommand(BinaryView* view, HighLevelILInstruction* instr)
{
}
PluginCommand::RegisterForHighLevelILInstruction("MyPlugin\\MySecondHLILAction",
"Perform an action", MyPlugin::MyCommand,
[](BinaryView *view, HighLevelILInstruction* instr){ return view->HasSymbols(); });
- Parameters
-
name Name of the command to register. This will appear in the top menu and the context menu.
You can register submenus to an item by separating names with a
"\\". The base (farthest right) name will be the item which upon being clicked will perform the action.description Description of the command action Action to perform isValid Expression that returns whether the command is allowed to be performed.
◆ RegisterForProject() [1/2]
|
static |
◆ RegisterForProject() [2/2]
|
static |
◆ GetList()
|
static |
Get the list of registered PluginCommands.
- Returns
- The list of registered PluginCommands
◆ GetValidList()
|
static |
Get the list of valid PluginCommands for a given context.
- Parameters
-
ctxt The context to be used for the checks
- Returns
- The list of valid plugin commands.
◆ GetName()
|
inline |
Get the name for the registered PluginCommand.
- Returns
- The name for the registered PluginCommand
◆ GetDescription()
|
inline |
Get the description for the registered PluginCommand.
- Returns
- The description for the registered PluginCommand
◆ GetType()
Get the type of the registered PluginCommand.
- Returns
- The type of the registered PluginCommand
◆ GetObject()
|
inline |
◆ IsValid()
| bool PluginCommand::IsValid | ( | const PluginCommandContext & | ctxt | ) | const |
◆ Execute()
| void PluginCommand::Execute | ( | const PluginCommandContext & | ctxt | ) | const |