IaitoCore¶
-
class IaitoCore : public QObject¶
Public Types
Public Functions
-
explicit IaitoCore(QObject *parent = nullptr)¶
-
~IaitoCore()¶
-
void initialize(bool loadPlugins = true)¶
-
void loadIaitoRC()¶
-
void loadDefaultIaitoRC()¶
-
QDir getIaitoRCDefaultDirectory() const¶
-
inline AsyncTaskManager *getAsyncTaskManager()¶
-
inline RVA getOffset() const¶
-
QString cmd(const char *str)¶
send a command to radare2
Note
if you want to seek to an address, you should use IaitoCore::seek.
- Parameters
str – the command you want to execute
- Returns
command output
-
inline QString cmd(const QString &str)¶
send a command to radare2 asynchronously
Note
connect to the &R2Task::finished signal to add your own logic once the command is finished. Use task->getResult()/getResultJson() for the return value. Once you have setup connections you can start the task with task->startTask() If you want to seek to an address, you should use IaitoCore::seek.
- Parameters
str – the command you want to execute
task – a shared pointer that will be returned with the R2 command task
-
QString cmdRaw(const char *cmd)¶
Execute a radare2 command cmd. By nature, the API is executing raw commands, and thus ignores multiple commands and overcome command injections.
- Parameters
cmd – - a raw command to execute. Passing multiple commands (e.g “px 5; pd 7 && pdf”) will result in them treated as arguments to first command.
- Returns
the output of the command
-
inline QString cmdRaw(const QString &cmd)¶
a wrapper around cmdRaw(const char *cmd,).
-
QString cmdRawAt(const char *cmd, RVA address)¶
Execute a radare2 command cmd at address. The function will preform a silent seek to the address without triggering the seekChanged event nor adding new entries to the seek history. By nature, the API is executing a single command without going through radare2 shell, and thus ignores multiple commands and tries to overcome command injections.
- Parameters
cmd – - a raw command to execute. If multiple commands will be passed (e.g “px 5; pd 7 && pdf”) then only the first command will be executed.
address – - an address to which Iaito will temporarily seek.
- Returns
the output of the command
-
inline QString cmdRawAt(const QString &str, RVA address)¶
a wrapper around cmdRawAt(const char *cmd, RVA address).
-
QJsonDocument cmdj(const char *str)¶
-
inline QJsonDocument cmdj(const QString &str)¶
-
QJsonDocument cmdjAt(const char *str, RVA address)¶
-
inline QStringList cmdList(const char *str)¶
-
inline QStringList cmdList(const QString &str)¶
-
QString cmdTask(const QString &str)¶
-
QJsonDocument cmdjTask(const QString &str)¶
-
void cmdEsil(const char *command)¶
send a command to radare2 and check for ESIL errors
Note
If you want to seek to an address, you should use IaitoCore::seek.
- Parameters
command – the command you want to execute
-
inline void cmdEsil(const QString &command)¶
send a command to radare2 and check for ESIL errors
Note
connect to the &R2Task::finished signal to add your own logic once the command is finished. Use task->getResult()/getResultJson() for the return value. Once you have setup connections you can start the task with task->startTask() If you want to seek to an address, you should use IaitoCore::seek.
- Parameters
command – the command you want to execute
task – a shared pointer that will be returned with the R2 command task
-
QString getVersionInformation()¶
-
QJsonDocument parseJson(const char *res, const char *cmd = nullptr)¶
-
inline QJsonDocument parseJson(const char *res, const QString &cmd = QString())¶
-
QStringList autocomplete(const QString &cmd, RLinePromptType promptType, size_t limit = 4096)¶
-
void renameFunction(const RVA offset, const QString &newName)¶
-
void delFunction(RVA addr)¶
-
void renameFlag(QString old_name, QString new_name)¶
-
void renameFunctionVariable(QString newName, QString oldName, RVA functionAddress)¶
Renames the specified local variable in the function specified by the address given.
- Parameters
newName – Specifies the name to which the current name of the variable should be renamed.
oldName – Specifies the current name of the function variable.
functionAddress – Specifies the exact address of the function.
-
RAnalFunction *functionIn(ut64 addr)¶
- Parameters
addr –
- Returns
a function that contains addr or nullptr
-
RAnalFunction *functionAt(ut64 addr)¶
- Parameters
addr –
- Returns
the function that has its entrypoint at addr or nullptr
-
RVA getFunctionStart(RVA addr)¶
finds the start address of a function in a given address
- Parameters
addr – - an address which belongs to a function
- Returns
if function exists, return its start address. Otherwise return RVA_INVALID
-
RVA getFunctionEnd(RVA addr)¶
finds the end address of a function in a given address
- Parameters
addr – - an address which belongs to a function
- Returns
if function exists, return its end address. Otherwise return RVA_INVALID
-
RVA getLastFunctionInstruction(RVA addr)¶
finds the last instruction of a function in a given address
- Parameters
addr – - an address which belongs to a function
- Returns
if function exists, return the address of its last instruction. Otherwise return RVA_INVALID
-
QString cmdFunctionAt(QString addr)¶
-
QString cmdFunctionAt(RVA addr)¶
-
QString createFunctionAt(RVA addr)¶
-
QString createFunctionAt(RVA addr, QString name)¶
-
QStringList getDisassemblyPreview(RVA address, int num_of_lines)¶
get a compact disassembly preview for tooltips
- Parameters
address – - the address from which to print the disassembly
num_of_lines – - number of instructions to print
-
void delFlag(RVA addr)¶
-
void delFlag(const QString &name)¶
-
void addFlag(RVA offset, QString name, RVA size, QString color = "", QString comment = "")¶
-
QString listFlagsAsStringAt(RVA addr)¶
Gets all the flags present at a specific address.
- Parameters
addr – The address to be checked
- Returns
String containing all the flags which are comma-separated
-
QString nearestFlag(RVA offset, RVA *flagOffsetOut)¶
Get nearest flag at or before offset.
- Parameters
offset – search position
flagOffsetOut – address of returned flag
- Returns
flag name
-
void triggerFlagsChanged()¶
-
QString getInstructionBytes(RVA addr)¶
-
QString getInstructionOpcode(RVA addr)¶
-
void editInstruction(RVA addr, const QString &inst)¶
-
void nopInstruction(RVA addr)¶
-
void jmpReverse(RVA addr)¶
-
void editBytes(RVA addr, const QString &inst)¶
-
void editBytesEndian(RVA addr, const QString &bytes)¶
-
void setToCode(RVA addr)¶
-
void setAsString(RVA addr, int size = 0, StringTypeFormats type = StringTypeFormats::None)¶
Adds string at address That function calls the ‘Cs’ command.
- Parameters
addr – The address of the array where the string will be applied
size – The size of string
type – The type of string
-
void removeString(RVA addr)¶
Removes string at address That function calls the ‘Cs-‘ command.
- Parameters
addr – The address of the array where the string will be applied
-
QString getString(RVA addr)¶
Gets string at address That function calls the ‘ps’ command.
- Parameters
addr – The address of the first byte of the array
- Returns
string at requested address
-
void setToData(RVA addr, int size, int repeat = 1)¶
-
int sizeofDataMeta(RVA addr)¶
-
void setComment(RVA addr, const QString &cmt)¶
-
void delComment(RVA addr)¶
-
QString getCommentAt(RVA addr)¶
Gets the comment present at a specific address.
- Parameters
addr – The address to be checked
- Returns
String containing comment
-
void setImmediateBase(const QString &r2BaseName, RVA offset = RVA_INVALID)¶
-
void setCurrentBits(int bits, RVA offset = RVA_INVALID)¶
-
void applyStructureOffset(const QString &structureOffset, RVA offset = RVA_INVALID)¶
Changes immediate displacement to structure offset This function makes use of the “aht” command of r2 to apply structure offset to the immediate displacement used in the given instruction.
- Parameters
structureOffset – The name of struct which will be applied
offset – The address of the instruction where the struct will be applied
-
QList<QString> getAllAnalClasses(bool sorted)¶
-
QList<AnalMethodDescription> getAnalClassMethods(const QString &cls)¶
-
QList<AnalBaseClassDescription> getAnalClassBaseClasses(const QString &cls)¶
-
QList<AnalVTableDescription> getAnalClassVTables(const QString &cls)¶
-
void createNewClass(const QString &cls)¶
-
void renameClass(const QString &oldName, const QString &newName)¶
-
void deleteClass(const QString &cls)¶
-
bool getAnalMethod(const QString &cls, const QString &meth, AnalMethodDescription *desc)¶
-
void renameAnalMethod(const QString &className, const QString &oldMethodName, const QString &newMethodName)¶
-
void setAnalMethod(const QString &cls, const AnalMethodDescription &meth)¶
-
bool loadFile(QString path, ut64 baddr = 0LL, ut64 mapaddr = 0LL, int perms = R_PERM_R, int va = 0, bool bincache = false, bool loadbin = false, const QString &forceBinPlugin = QString())¶
IaitoCore::loadFile Load initial file. TODO Maybe use the “o” commands?
- Parameters
path – File path
baddr – Base (RBin) address
mapaddr – Map address
perms –
va –
loadbin – Load RBin information
forceBinPlugin –
- Returns
-
bool tryFile(QString path, bool rw)¶
-
bool mapFile(QString path, RVA mapaddr)¶
Maps a file using r2 API.
- Parameters
path – Path to file
mapaddr – Map Address
- Returns
bool
-
void loadScript(const QString &scriptname)¶
-
QJsonArray getOpenedFiles()¶
-
void seek(QString thing)¶
-
void seek(ut64 offset)¶
-
void seekSilent(ut64 offset)¶
-
inline void seekSilent(QString thing)¶
-
void seekPrev()¶
-
void seekNext()¶
-
void updateSeek()¶
-
void showMemoryWidget()¶
Raise a memory widget showing current offset, prefer last active memory widget.
-
void seekAndShow(ut64 offset)¶
Seek to
offset
and raise a memory widget showing it.- Parameters
offset –
-
void seekAndShow(QString thing)¶
- See
IaitoCore::show(ut64)
- Parameters
thing – - addressable expression
-
RVA getOffset()¶
-
RVA prevOpAddr(RVA startAddr, int count)¶
-
RVA nextOpAddr(RVA startAddr, int count)¶
-
ut64 math(const QString &expr)¶
-
ut64 num(const QString &expr)¶
-
QString itoa(ut64 num, int rdx = 16)¶
-
void setConfig(const char *k, const char *v)¶
-
void setConfig(const QString &k, const char *v)¶
-
void setConfig(const char *k, const QString &v)¶
-
inline void setConfig(const QString &k, const QString &v)¶
-
void setConfig(const char *k, int v)¶
-
inline void setConfig(const QString &k, int v)¶
-
void setConfig(const char *k, bool v)¶
-
inline void setConfig(const QString &k, bool v)¶
-
void setConfig(const char *k, const QVariant &v)¶
-
inline void setConfig(const QString &k, const QVariant &v)¶
-
int getConfigi(const char *k)¶
-
inline int getConfigi(const QString &k)¶
-
ut64 getConfigut64(const char *k)¶
-
inline ut64 getConfigut64(const QString &k)¶
-
bool getConfigb(const char *k)¶
-
inline bool getConfigb(const QString &k)¶
-
QString getConfig(const char *k)¶
-
inline QString getConfig(const QString &k)¶
-
QString getConfigDescription(const char *k)¶
-
QList<QString> getColorThemes()¶
-
QByteArray assemble(const QString &code)¶
-
QString disassemble(const QByteArray &data)¶
-
QString disassembleSingleInstruction(RVA addr)¶
-
QList<DisassemblyLine> disassembleLines(RVA offset, int lines)¶
-
QString hexdump(RVA offset, int size, HexdumpFormats format)¶
return hexdump of <size> from an <offset> by a given formats
- Parameters
address – - the address from which to print the hexdump
size – - number of bytes to print
format – - the type of hexdump (qwords, words. decimal, etc)
-
QString getHexdumpPreview(RVA offset, int size)¶
get a compact hexdump preview for tooltips
- Parameters
address – - the address from which to print the hexdump
size – - number of bytes to print
-
void setCPU(QString arch, QString cpu, int bits)¶
-
void setEndianness(bool big)¶
-
QList<QString> sdbList(QString path)¶
-
QList<QString> sdbListKeys(QString path)¶
-
QString sdbGet(QString path, QString key)¶
-
bool sdbSet(QString path, QString key, QString val)¶
-
QJsonDocument getRegistersInfo()¶
-
QJsonDocument getRegisterValues()¶
-
QString getRegisterName(QString registerRole)¶
-
RVA getProgramCounterValue()¶
-
void setRegister(QString regName, QString regValue)¶
-
void setCurrentDebugThread(int tid)¶
-
void setCurrentDebugProcess(int pid)¶
Attach to a given pid from a debug session.
-
QList<QJsonObject> getStack(int size = 0x100, int depth = 6)¶
Returns a list of stack address and their telescoped references.
- Parameters
size – number of bytes to scan
depth – telescoping depth
-
QJsonObject getAddrRefs(RVA addr, int depth)¶
Recursively dereferences pointers starting at the specified address up to a given depth.
- Parameters
addr – telescoping addr
depth – telescoping depth
-
RefDescription formatRefDesc(QJsonObject ref)¶
return a RefDescription with a formatted ref string and configured colors
- Parameters
ref – the “ref” JSON node from getAddrRefs
-
QJsonDocument getProcessThreads(int pid)¶
Get a list of a given process’s threads.
- Parameters
pid – The pid of the process, -1 for the currently debugged process
- Returns
JSON object result of dptj
-
QJsonDocument getChildProcesses(int pid)¶
Get a list of a given process’s child processes.
- Parameters
pid – The pid of the process, -1 for the currently debugged process
- Returns
JSON object result of dptj
-
QJsonDocument getBacktrace()¶
-
void startDebug()¶
-
void startEmulation()¶
-
void attachRemote(const QString &uri)¶
attach to a remote debugger
Note
attachedRemote(bool) signals the result
- Parameters
uri – remote debugger uri
-
void attachDebug(int pid)¶
-
void stopDebug()¶
-
void suspendDebug()¶
-
void syncAndSeekProgramCounter()¶
-
void continueDebug()¶
-
void continueUntilCall()¶
-
void continueUntilSyscall()¶
-
void continueUntilDebug(QString offset)¶
-
void stepDebug()¶
-
void stepOverDebug()¶
-
void stepOutDebug()¶
-
void addBreakpoint(const BreakpointDescription &config)¶
-
void updateBreakpoint(int index, const BreakpointDescription &config)¶
-
void toggleBreakpoint(RVA addr)¶
-
void delBreakpoint(RVA addr)¶
-
void delAllBreakpoints()¶
-
void enableBreakpoint(RVA addr)¶
-
void disableBreakpoint(RVA addr)¶
-
void setBreakpointTrace(int index, bool enabled)¶
Enable or disable breakpoint tracing.
- Parameters
index – - breakpoint index to modify
enabled – - true if tracing should be enabled
-
int breakpointIndexAt(RVA addr)¶
-
BreakpointDescription getBreakpointAt(RVA addr)¶
-
bool isBreakpoint(const QList<RVA> &breakpoints, RVA addr)¶
-
QList<RVA> getBreakpointsAddresses()¶
-
QList<RVA> getBreakpointsInFunction(RVA funcAddr)¶
Get all breakpoinst that are belong to a functions at this address.
-
QString getActiveDebugPlugin()¶
-
QStringList getDebugPlugins()¶
-
void setDebugPlugin(QString plugin)¶
-
bool isDebugTaskInProgress()¶
-
bool isRedirectableDebugee()¶
Check if we can use output/input redirection with the currently debugged process.
-
QList<Decompiler*> getDecompilers()¶
-
Decompiler *getDecompilerById(const QString &id)¶
-
bool registerDecompiler(Decompiler *decompiler)¶
Register a new decompiler
The decompiler must have a unique id, otherwise this method will fail. The decompiler’s parent will be set to this IaitoCore instance, so it will automatically be freed later.
- Returns
whether the decompiler was registered successfully
-
RVA getOffsetJump(RVA addr)¶
-
QJsonDocument getFileInfo()¶
-
QJsonDocument getSignatureInfo()¶
-
QJsonDocument getFileVersionInfo()¶
-
QStringList getStats()¶
-
void setGraphEmpty(bool empty)¶
-
bool isGraphEmpty()¶
-
void getOpcodes()¶
-
void setSettings()¶
-
void loadPDB(const QString &file)¶
-
QByteArray ioRead(RVA addr, int len)¶
-
QList<RVA> getSeekHistory()¶
-
QStringList getAsmPluginNames()¶
-
QStringList getAnalPluginNames()¶
-
QStringList getProjectNames()¶
-
void openProject(const QString &name)¶
-
void saveProject(const QString &name)¶
-
void deleteProject(const QString &name)¶
-
QList<RBinPluginDescription> getRBinPluginDescriptions(const QString &type = QString())¶
-
QList<RIOPluginDescription> getRIOPluginDescriptions()¶
-
QList<RCorePluginDescription> getRCorePluginDescriptions()¶
-
QList<RAsmPluginDescription> getRAsmPluginDescriptions()¶
-
QList<FunctionDescription> getAllFunctions()¶
-
QList<ImportDescription> getAllImports()¶
-
QList<ExportDescription> getAllExports()¶
-
QList<SymbolDescription> getAllSymbols()¶
-
QList<HeaderDescription> getAllHeaders()¶
-
QList<ZignatureDescription> getAllZignatures()¶
-
QList<CommentDescription> getAllComments(const QString &filterType)¶
-
QList<RelocDescription> getAllRelocs()¶
-
QList<StringDescription> getAllStrings()¶
-
QList<FlagspaceDescription> getAllFlagspaces()¶
-
QList<FlagDescription> getAllFlags(QString flagspace = QString())¶
-
QList<SectionDescription> getAllSections()¶
-
QList<SegmentDescription> getAllSegments()¶
-
QList<EntrypointDescription> getAllEntrypoint()¶
-
QList<BinClassDescription> getAllClassesFromBin()¶
-
QList<BinClassDescription> getAllClassesFromFlags()¶
-
QList<ResourcesDescription> getAllResources()¶
-
QList<VTableDescription> getAllVTables()¶
-
QList<TypeDescription> getAllTypes()¶
- Returns
all loaded types
-
QList<TypeDescription> getAllPrimitiveTypes()¶
- Returns
all loaded primitive types
-
QList<TypeDescription> getAllUnions()¶
- Returns
all loaded unions
-
QList<TypeDescription> getAllStructs()¶
- Returns
all loaded structs
-
QList<TypeDescription> getAllEnums()¶
- Returns
all loaded enums
-
QList<TypeDescription> getAllTypedefs()¶
- Returns
all loaded typedefs
-
QString getTypeAsC(QString name, QString category)¶
Fetching the C representation of a given Type.
- Parameters
name – - the name or the type of the given Type / Struct
category – - the category of the given Type (Struct, Union, Enum, …)
- Returns
The type decleration as C output
-
QString addTypes(const char *str)¶
Adds new types It first uses the r_parse_c_string() function from radare2 API to parse the supplied C file (in the form of a string). If there were errors, they are displayed. If there were no errors, it uses sdb_query_lines() function from radare2 API to save the parsed types returned by r_parse_c_string()
- Parameters
str – Contains the definition of the data types
- Returns
returns an empty QString if there was no error, else returns the error
-
inline QString addTypes(const QString &str)¶
-
bool isAddressMapped(RVA addr)¶
Checks if the given address is mapped to a region.
- Parameters
addr – The address to be checked
- Returns
true if addr is mapped, false otherwise
-
QList<MemoryMapDescription> getMemoryMap()¶
-
QList<SearchDescription> getAllSearch(QString search_for, QString space)¶
-
BlockStatistics getBlockStatistics(unsigned int blocksCount)¶
-
QList<BreakpointDescription> getBreakpoints()¶
-
QList<ProcessDescription> getAllProcesses()¶
-
QList<QJsonObject> getRegisterRefs(int depth = 6)¶
returns a list of reg values and their telescoped references
- Parameters
depth – telescoping depth
-
QVector<RegisterRefValueDescription> getRegisterRefValues()¶
-
QList<VariableDescription> getVariables(RVA at)¶
-
QList<XrefDescription> getXRefsForVariable(QString variableName, bool findWrites, RVA offset)¶
Fetches all the writes or reads to the specified local variable ‘variableName’ in the function in which the specified offset is a part of.
- Parameters
variableName – Name of the local variable.
findWrites – If this is true, then locations at which modification happen to the specified local variable is fetched. Else, the locations at which the local is variable is read is fetched.
offset – An offset in the function in which the specified local variable exist.
- Returns
A list of XrefDescriptions that contains details of all the writes or reads that happen to the variable ‘variableName’.
-
QList<XrefDescription> getXRefs(RVA addr, bool to, bool whole_function, const QString &filterType = QString())¶
-
QList<StringDescription> parseStringsJson(const QJsonDocument &doc)¶
-
void handleREvent(int type, void *data)¶
-
void triggerVarsChanged()¶
-
void triggerFunctionRenamed(const RVA offset, const QString &newName)¶
-
void triggerRefreshAll()¶
-
void triggerAsmOptionsChanged()¶
-
void triggerGraphOptionsChanged()¶
-
void message(const QString &msg, bool debug = false)¶
-
QStringList getSectionList()¶
-
RCoreLocked core()¶
-
BasicBlockHighlighter *getBBHighlighter()¶
-
BasicInstructionHighlighter *getBIHighlighter()¶
-
void setIOCache(bool enabled)¶
Enable or dsiable Cache mode. Cache mode is used to imagine writing to the opened file without committing the changes to the disk.
- Parameters
enabled –
-
bool isIOCacheEnabled() const¶
Check if Cache mode is enabled.
- Returns
true if Cache is enabled, otherwise return false.
-
void commitWriteCache()¶
Commit write cache to the file on disk.
-
void setWriteMode(bool enabled)¶
Enable or disable Write mode. When the file is opened in write mode, any changes to it will be immediately committed to the file on disk, thus modify the file. This function wrap radare2 function which re-open the file with the desired permissions.
- Parameters
enabled –
-
bool isWriteModeEnabled()¶
Check if the file is opened in write mode.
- Returns
true if write mode is enabled, otherwise return false.
Public Members
-
bool currentlyDebugging = false¶
-
bool currentlyEmulating = false¶
-
int currentlyAttachedToPID = -1¶
-
QString currentlyOpenFile¶
-
QList<QString> opcodes¶
-
QList<QString> regs¶
Signals
-
void refreshAll()¶
-
void functionRenamed(const RVA offset, const QString &new_name)¶
-
void varsChanged()¶
-
void functionsChanged()¶
-
void flagsChanged()¶
-
void commentsChanged(RVA addr)¶
-
void registersChanged()¶
-
void instructionChanged(RVA offset)¶
-
void breakpointsChanged(RVA offset)¶
-
void refreshCodeViews()¶
-
void stackChanged()¶
-
void codeRebased()¶
update all the widgets that are affected by rebasing in debug mode
-
void switchedThread()¶
-
void switchedProcess()¶
-
void classNew(const QString &cls)¶
-
void classDeleted(const QString &cls)¶
-
void classRenamed(const QString &oldName, const QString &newName)¶
-
void classAttrsChanged(const QString &cls)¶
-
void debugProcessFinished(int pid)¶
end of current debug event received
-
void attachedRemote(bool successfully)¶
-
void projectSaved(bool successfully, const QString &name)¶
-
void ioCacheChanged(bool newval)¶
-
void writeModeChanged(bool newval)¶
-
void ioModeChanged()¶
-
void debugTaskStateChanged()¶
emitted when debugTask started or finished running
-
void asmOptionsChanged()¶
emitted when config regarding disassembly display changes
-
void graphOptionsChanged()¶
emitted when config regarding graph display changes
-
void seekChanged(RVA offset)¶
seekChanged is emitted each time radare2 seek value is modified
- Parameters
offset –
-
void toggleDebugView()¶
-
void newMessage(const QString &msg)¶
-
void newDebugMessage(const QString &msg)¶
-
void showMemoryWidgetRequested()¶
-
explicit IaitoCore(QObject *parent = nullptr)¶