Architectures

Classes related to interacting with, hooking, and implementing Architectures. More...

Detailed Description

Classes related to interacting with, hooking, and implementing Architectures.

Classes

class  BinaryNinja::Architecture
 The Architecture class is the base class for all CPU architectures. More...
 
class  BinaryNinja::CoreArchitecture
 
class  BinaryNinja::ArchitectureExtension
 
class  BinaryNinja::ArchitectureHook
 

Class Documentation

◆ BinaryNinja::Architecture

class BinaryNinja::Architecture

The Architecture class is the base class for all CPU architectures.

This provides disassembly, assembly, patching, and IL translation lifting for a given architecture.

Public Member Functions

 Architecture (const std::string &name)
 
std::string GetName () const
 Get the name of this architecture. More...
 
virtual BNEndianness GetEndianness () const =0
 Get the default endianness for this architecture. More...
 
virtual size_t GetAddressSize () const =0
 Get the address size for this architecture. More...
 
virtual size_t GetDefaultIntegerSize () const
 Get the default integer size for this architecture. More...
 
virtual size_t GetInstructionAlignment () const
 
virtual size_t GetMaxInstructionLength () const
 Get the maximum instruction length. More...
 
virtual size_t GetOpcodeDisplayLength () const
 
virtual Ref< ArchitectureGetAssociatedArchitectureByAddress (uint64_t &addr)
 
virtual bool GetInstructionInfo (const uint8_t *data, uint64_t addr, size_t maxLen, InstructionInfo &result)=0
 Retrieves an InstructionInfo struct for the instruction at the given virtual address. More...
 
virtual bool GetInstructionText (const uint8_t *data, uint64_t addr, size_t &len, std::vector< InstructionTextToken > &result)=0
 Retrieves a list of InstructionTextTokens. More...
 
virtual bool GetInstructionLowLevelIL (const uint8_t *data, uint64_t addr, size_t &len, LowLevelILFunction &il)
 Translates an instruction at addr and appends it onto the LowLevelILFunction& il. More...
 
virtual std::string GetRegisterName (uint32_t reg)
 Gets a register name from a register index. More...
 
virtual std::string GetFlagName (uint32_t flag)
 Gets a flag name from a flag index. More...
 
virtual std::string GetFlagWriteTypeName (uint32_t flags)
 Gets the flag write type name for the given flag. More...
 
virtual std::string GetSemanticFlagClassName (uint32_t semClass)
 Gets the name of a semantic flag class from the index. More...
 
virtual std::string GetSemanticFlagGroupName (uint32_t semGroup)
 Gets the name of a semantic flag group from the index. More...
 
virtual std::vector< uint32_t > GetFullWidthRegisters ()
 Get the list of full width register indices. More...
 
virtual std::vector< uint32_t > GetAllRegisters ()
 Get the list of all register indices. More...
 
virtual std::vector< uint32_t > GetAllFlags ()
 Get the list of all flag indices. More...
 
virtual std::vector< uint32_t > GetAllFlagWriteTypes ()
 Get the list of all flag write type indices. More...
 
virtual std::vector< uint32_t > GetAllSemanticFlagClasses ()
 Get the list of all semantic flag class indices. More...
 
virtual std::vector< uint32_t > GetAllSemanticFlagGroups ()
 Get the list of all semantic flag group indices. More...
 
virtual BNFlagRole GetFlagRole (uint32_t flag, uint32_t semClass=0)
 Get the role of a given flag. More...
 
virtual std::vector< uint32_t > GetFlagsRequiredForFlagCondition (BNLowLevelILFlagCondition cond, uint32_t semClass=0)
 
virtual std::vector< uint32_t > GetFlagsRequiredForSemanticFlagGroup (uint32_t semGroup)
 
virtual std::map< uint32_t, BNLowLevelILFlagConditionGetFlagConditionsForSemanticFlagGroup (uint32_t semGroup)
 
virtual std::vector< uint32_t > GetFlagsWrittenByFlagWriteType (uint32_t writeType)
 
virtual uint32_t GetSemanticClassForFlagWriteType (uint32_t writeType)
 
virtual ExprId GetFlagWriteLowLevelIL (BNLowLevelILOperation op, size_t size, uint32_t flagWriteType, uint32_t flag, BNRegisterOrConstant *operands, size_t operandCount, LowLevelILFunction &il)
 
ExprId GetDefaultFlagWriteLowLevelIL (BNLowLevelILOperation op, size_t size, BNFlagRole role, BNRegisterOrConstant *operands, size_t operandCount, LowLevelILFunction &il)
 
virtual ExprId GetFlagConditionLowLevelIL (BNLowLevelILFlagCondition cond, uint32_t semClass, LowLevelILFunction &il)
 
ExprId GetDefaultFlagConditionLowLevelIL (BNLowLevelILFlagCondition cond, uint32_t semClass, LowLevelILFunction &il)
 
virtual ExprId GetSemanticFlagGroupLowLevelIL (uint32_t semGroup, LowLevelILFunction &il)
 
virtual BNRegisterInfo GetRegisterInfo (uint32_t reg)
 Get the register info for a given register index. More...
 
virtual uint32_t GetStackPointerRegister ()
 Get the register index corresponding to the stack pointer (SP) More...
 
virtual uint32_t GetLinkRegister ()
 Get the register index corresponding to the link register (LR) More...
 
virtual std::vector< uint32_t > GetGlobalRegisters ()
 
bool IsGlobalRegister (uint32_t reg)
 
virtual std::vector< uint32_t > GetSystemRegisters ()
 Get the list of system register indices. More...
 
bool IsSystemRegister (uint32_t reg)
 Check whether a register is a system register. More...
 
std::vector< uint32_t > GetModifiedRegistersOnWrite (uint32_t reg)
 Returns a list of register indices that are modified when reg is written to. More...
 
uint32_t GetRegisterByName (const std::string &name)
 Get a register index by its name. More...
 
virtual std::string GetRegisterStackName (uint32_t regStack)
 Get a register stack name from a register stack number. More...
 
virtual std::vector< uint32_t > GetAllRegisterStacks ()
 
virtual BNRegisterStackInfo GetRegisterStackInfo (uint32_t regStack)
 
uint32_t GetRegisterStackForRegister (uint32_t reg)
 
virtual std::string GetIntrinsicName (uint32_t intrinsic)
 Gets an intrinsic name from an intrinsic number. More...
 
virtual std::vector< uint32_t > GetAllIntrinsics ()
 
virtual std::vector< NameAndTypeGetIntrinsicInputs (uint32_t intrinsic)
 
virtual std::vector< Confidence< Ref< Type > > > GetIntrinsicOutputs (uint32_t intrinsic)
 
virtual bool CanAssemble ()
 Check whether this architecture can assemble instructions. More...
 
virtual bool Assemble (const std::string &code, uint64_t addr, DataBuffer &result, std::string &errors)
 Converts the string of assembly instructions code loaded at virtual address addr to the byte representation of those instructions. More...
 
virtual bool IsNeverBranchPatchAvailable (const uint8_t *data, uint64_t addr, size_t len)
 Returns true if the instruction at addr can be patched to never branch. More...
 
virtual bool IsAlwaysBranchPatchAvailable (const uint8_t *data, uint64_t addr, size_t len)
 Returns true if the instruction at addr can be patched to always branch. More...
 
virtual bool IsInvertBranchPatchAvailable (const uint8_t *data, uint64_t addr, size_t len)
 Returns true if the instruction at addr can be patched to invert the branch. More...
 
virtual bool IsSkipAndReturnZeroPatchAvailable (const uint8_t *data, uint64_t addr, size_t len)
 Checks if the instruction at addr is a call that can be patched to return zero. More...
 
virtual bool IsSkipAndReturnValuePatchAvailable (const uint8_t *data, uint64_t addr, size_t len)
 Checks if the instruction at addr is a call that can be patched to return a value. More...
 
virtual bool ConvertToNop (uint8_t *data, uint64_t addr, size_t len)
 Converts the instruction at addr to a no-operation instruction. More...
 
virtual bool AlwaysBranch (uint8_t *data, uint64_t addr, size_t len)
 Converts the conditional branch instruction at addr to an unconditional branch. More...
 
virtual bool InvertBranch (uint8_t *data, uint64_t addr, size_t len)
 InvertBranch converts the conditional branch instruction at addr to its invert. More...
 
virtual bool SkipAndReturnValue (uint8_t *data, uint64_t addr, size_t len, uint64_t value)
 SkipAndReturnValue converts the call instruction at addr to an instruction that simulates that call returning a value. More...
 
void RegisterFunctionRecognizer (FunctionRecognizer *recog)
 
void RegisterRelocationHandler (const std::string &viewName, RelocationHandler *handler)
 
Ref< RelocationHandlerGetRelocationHandler (const std::string &viewName)
 
bool IsBinaryViewTypeConstantDefined (const std::string &type, const std::string &name)
 
uint64_t GetBinaryViewTypeConstant (const std::string &type, const std::string &name, uint64_t defaultValue=0)
 
void SetBinaryViewTypeConstant (const std::string &type, const std::string &name, uint64_t value)
 
void RegisterCallingConvention (CallingConvention *cc)
 Register a calling convention with this architecture. More...
 
std::vector< Ref< CallingConvention > > GetCallingConventions ()
 List of registered calling conventions. More...
 
Ref< CallingConventionGetCallingConventionByName (const std::string &name)
 Get a calling convention by name. More...
 
void SetDefaultCallingConvention (CallingConvention *cc)
 Set the default calling convention. More...
 
void SetCdeclCallingConvention (CallingConvention *cc)
 Set the cdecl calling convention. More...
 
void SetStdcallCallingConvention (CallingConvention *cc)
 Set the stdcall calling convention. More...
 
void SetFastcallCallingConvention (CallingConvention *cc)
 Set the fastcall calling convention. More...
 
Ref< CallingConventionGetDefaultCallingConvention ()
 Get the default calling convention. More...
 
Ref< CallingConventionGetCdeclCallingConvention ()
 Get the cdecl calling convention. More...
 
Ref< CallingConventionGetStdcallCallingConvention ()
 Get the stdcall calling convention. More...
 
Ref< CallingConventionGetFastcallCallingConvention ()
 Get the fastcall calling convention. More...
 
Ref< PlatformGetStandalonePlatform ()
 Get the Architecture standalone platform. More...
 
std::vector< Ref< TypeLibrary > > GetTypeLibraries ()
 
void AddArchitectureRedirection (Architecture *from, Architecture *to)
 
- Public Member Functions inherited from BinaryNinja::StaticCoreRefCountObject< BNArchitecture >
 StaticCoreRefCountObject ()
 
virtual ~StaticCoreRefCountObject ()
 
BNArchitectureGetObject () const
 
void AddRef ()
 
void Release ()
 
void AddRefForRegistration ()
 
void AddRefForCallback ()
 
void ReleaseForCallback ()
 

Static Public Member Functions

static void Register (Architecture *arch)
 Register an architecture. More...
 
static Ref< ArchitectureGetByName (const std::string &name)
 Get an Architecture by name. More...
 
static std::vector< Ref< Architecture > > GetList ()
 Get the list of registered Architectures. More...
 
- Static Public Member Functions inherited from BinaryNinja::StaticCoreRefCountObject< BNArchitecture >
static BNArchitectureGetObject (StaticCoreRefCountObject *obj)
 

Protected Member Functions

 Architecture (BNArchitecture *arch)
 
virtual void Register (BNCustomArchitecture *callbacks)
 

Static Protected Member Functions

static void InitCallback (void *ctxt, BNArchitecture *obj)
 
static BNEndianness GetEndiannessCallback (void *ctxt)
 
static size_t GetAddressSizeCallback (void *ctxt)
 
static size_t GetDefaultIntegerSizeCallback (void *ctxt)
 
static size_t GetInstructionAlignmentCallback (void *ctxt)
 
static size_t GetMaxInstructionLengthCallback (void *ctxt)
 
static size_t GetOpcodeDisplayLengthCallback (void *ctxt)
 
static BNArchitectureGetAssociatedArchitectureByAddressCallback (void *ctxt, uint64_t *addr)
 
static bool GetInstructionInfoCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t maxLen, BNInstructionInfo *result)
 
static bool GetInstructionTextCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t *len, BNInstructionTextToken **result, size_t *count)
 
static void FreeInstructionTextCallback (BNInstructionTextToken *tokens, size_t count)
 
static bool GetInstructionLowLevelILCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t *len, BNLowLevelILFunction *il)
 
static char * GetRegisterNameCallback (void *ctxt, uint32_t reg)
 
static char * GetFlagNameCallback (void *ctxt, uint32_t flag)
 
static char * GetFlagWriteTypeNameCallback (void *ctxt, uint32_t flags)
 
static char * GetSemanticFlagClassNameCallback (void *ctxt, uint32_t semClass)
 
static char * GetSemanticFlagGroupNameCallback (void *ctxt, uint32_t semGroup)
 
static uint32_t * GetFullWidthRegistersCallback (void *ctxt, size_t *count)
 
static uint32_t * GetAllRegistersCallback (void *ctxt, size_t *count)
 
static uint32_t * GetAllFlagsCallback (void *ctxt, size_t *count)
 
static uint32_t * GetAllFlagWriteTypesCallback (void *ctxt, size_t *count)
 
static uint32_t * GetAllSemanticFlagClassesCallback (void *ctxt, size_t *count)
 
static uint32_t * GetAllSemanticFlagGroupsCallback (void *ctxt, size_t *count)
 
static BNFlagRole GetFlagRoleCallback (void *ctxt, uint32_t flag, uint32_t semClass)
 
static uint32_t * GetFlagsRequiredForFlagConditionCallback (void *ctxt, BNLowLevelILFlagCondition cond, uint32_t semClass, size_t *count)
 
static uint32_t * GetFlagsRequiredForSemanticFlagGroupCallback (void *ctxt, uint32_t semGroup, size_t *count)
 
static BNFlagConditionForSemanticClassGetFlagConditionsForSemanticFlagGroupCallback (void *ctxt, uint32_t semGroup, size_t *count)
 
static void FreeFlagConditionsForSemanticFlagGroupCallback (void *ctxt, BNFlagConditionForSemanticClass *conditions)
 
static uint32_t * GetFlagsWrittenByFlagWriteTypeCallback (void *ctxt, uint32_t writeType, size_t *count)
 
static uint32_t GetSemanticClassForFlagWriteTypeCallback (void *ctxt, uint32_t writeType)
 
static size_t GetFlagWriteLowLevelILCallback (void *ctxt, BNLowLevelILOperation op, size_t size, uint32_t flagWriteType, uint32_t flag, BNRegisterOrConstant *operands, size_t operandCount, BNLowLevelILFunction *il)
 
static size_t GetFlagConditionLowLevelILCallback (void *ctxt, BNLowLevelILFlagCondition cond, uint32_t semClass, BNLowLevelILFunction *il)
 
static size_t GetSemanticFlagGroupLowLevelILCallback (void *ctxt, uint32_t semGroup, BNLowLevelILFunction *il)
 
static void FreeRegisterListCallback (void *ctxt, uint32_t *regs)
 
static void GetRegisterInfoCallback (void *ctxt, uint32_t reg, BNRegisterInfo *result)
 
static uint32_t GetStackPointerRegisterCallback (void *ctxt)
 
static uint32_t GetLinkRegisterCallback (void *ctxt)
 
static uint32_t * GetGlobalRegistersCallback (void *ctxt, size_t *count)
 
static uint32_t * GetSystemRegistersCallback (void *ctxt, size_t *count)
 
static char * GetRegisterStackNameCallback (void *ctxt, uint32_t regStack)
 
static uint32_t * GetAllRegisterStacksCallback (void *ctxt, size_t *count)
 
static void GetRegisterStackInfoCallback (void *ctxt, uint32_t regStack, BNRegisterStackInfo *result)
 
static char * GetIntrinsicNameCallback (void *ctxt, uint32_t intrinsic)
 
static uint32_t * GetAllIntrinsicsCallback (void *ctxt, size_t *count)
 
static BNNameAndTypeGetIntrinsicInputsCallback (void *ctxt, uint32_t intrinsic, size_t *count)
 
static void FreeNameAndTypeListCallback (void *ctxt, BNNameAndType *nt, size_t count)
 
static BNTypeWithConfidenceGetIntrinsicOutputsCallback (void *ctxt, uint32_t intrinsic, size_t *count)
 
static void FreeTypeListCallback (void *ctxt, BNTypeWithConfidence *types, size_t count)
 
static bool CanAssembleCallback (void *ctxt)
 
static bool AssembleCallback (void *ctxt, const char *code, uint64_t addr, BNDataBuffer *result, char **errors)
 
static bool IsNeverBranchPatchAvailableCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t len)
 
static bool IsAlwaysBranchPatchAvailableCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t len)
 
static bool IsInvertBranchPatchAvailableCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t len)
 
static bool IsSkipAndReturnZeroPatchAvailableCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t len)
 
static bool IsSkipAndReturnValuePatchAvailableCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t len)
 
static bool ConvertToNopCallback (void *ctxt, uint8_t *data, uint64_t addr, size_t len)
 
static bool AlwaysBranchCallback (void *ctxt, uint8_t *data, uint64_t addr, size_t len)
 
static bool InvertBranchCallback (void *ctxt, uint8_t *data, uint64_t addr, size_t len)
 
static bool SkipAndReturnValueCallback (void *ctxt, uint8_t *data, uint64_t addr, size_t len, uint64_t value)
 

Protected Attributes

std::string m_nameForRegister
 

Additional Inherited Members

- Public Attributes inherited from BinaryNinja::StaticCoreRefCountObject< BNArchitecture >
std::atomic< int > m_refs
 
BNArchitecturem_object
 

Constructor & Destructor Documentation

◆ Architecture() [1/2]

Architecture::Architecture ( BNArchitecture arch)
protected

◆ Architecture() [2/2]

BinaryNinja::Architecture::Architecture ( const std::string &  name)

Member Function Documentation

◆ InitCallback()

void Architecture::InitCallback ( void *  ctxt,
BNArchitecture obj 
)
staticprotected

◆ GetEndiannessCallback()

BNEndianness Architecture::GetEndiannessCallback ( void *  ctxt)
staticprotected

◆ GetAddressSizeCallback()

size_t Architecture::GetAddressSizeCallback ( void *  ctxt)
staticprotected

◆ GetDefaultIntegerSizeCallback()

size_t Architecture::GetDefaultIntegerSizeCallback ( void *  ctxt)
staticprotected

◆ GetInstructionAlignmentCallback()

size_t Architecture::GetInstructionAlignmentCallback ( void *  ctxt)
staticprotected

◆ GetMaxInstructionLengthCallback()

size_t Architecture::GetMaxInstructionLengthCallback ( void *  ctxt)
staticprotected

◆ GetOpcodeDisplayLengthCallback()

size_t Architecture::GetOpcodeDisplayLengthCallback ( void *  ctxt)
staticprotected

◆ GetAssociatedArchitectureByAddressCallback()

BNArchitecture * Architecture::GetAssociatedArchitectureByAddressCallback ( void *  ctxt,
uint64_t *  addr 
)
staticprotected

◆ GetInstructionInfoCallback()

bool Architecture::GetInstructionInfoCallback ( void *  ctxt,
const uint8_t *  data,
uint64_t  addr,
size_t  maxLen,
BNInstructionInfo result 
)
staticprotected

◆ GetInstructionTextCallback()

bool Architecture::GetInstructionTextCallback ( void *  ctxt,
const uint8_t *  data,
uint64_t  addr,
size_t *  len,
BNInstructionTextToken **  result,
size_t *  count 
)
staticprotected

◆ FreeInstructionTextCallback()

void Architecture::FreeInstructionTextCallback ( BNInstructionTextToken tokens,
size_t  count 
)
staticprotected

◆ GetInstructionLowLevelILCallback()

bool Architecture::GetInstructionLowLevelILCallback ( void *  ctxt,
const uint8_t *  data,
uint64_t  addr,
size_t *  len,
BNLowLevelILFunction il 
)
staticprotected

◆ GetRegisterNameCallback()

char * Architecture::GetRegisterNameCallback ( void *  ctxt,
uint32_t  reg 
)
staticprotected

◆ GetFlagNameCallback()

char * Architecture::GetFlagNameCallback ( void *  ctxt,
uint32_t  flag 
)
staticprotected

◆ GetFlagWriteTypeNameCallback()

char * Architecture::GetFlagWriteTypeNameCallback ( void *  ctxt,
uint32_t  flags 
)
staticprotected

◆ GetSemanticFlagClassNameCallback()

char * Architecture::GetSemanticFlagClassNameCallback ( void *  ctxt,
uint32_t  semClass 
)
staticprotected

◆ GetSemanticFlagGroupNameCallback()

char * Architecture::GetSemanticFlagGroupNameCallback ( void *  ctxt,
uint32_t  semGroup 
)
staticprotected

◆ GetFullWidthRegistersCallback()

uint32_t * Architecture::GetFullWidthRegistersCallback ( void *  ctxt,
size_t *  count 
)
staticprotected

◆ GetAllRegistersCallback()

uint32_t * Architecture::GetAllRegistersCallback ( void *  ctxt,
size_t *  count 
)
staticprotected

◆ GetAllFlagsCallback()

uint32_t * Architecture::GetAllFlagsCallback ( void *  ctxt,
size_t *  count 
)
staticprotected

◆ GetAllFlagWriteTypesCallback()

uint32_t * Architecture::GetAllFlagWriteTypesCallback ( void *  ctxt,
size_t *  count 
)
staticprotected

◆ GetAllSemanticFlagClassesCallback()

uint32_t * Architecture::GetAllSemanticFlagClassesCallback ( void *  ctxt,
size_t *  count 
)
staticprotected

◆ GetAllSemanticFlagGroupsCallback()

uint32_t * Architecture::GetAllSemanticFlagGroupsCallback ( void *  ctxt,
size_t *  count 
)
staticprotected

◆ GetFlagRoleCallback()

BNFlagRole Architecture::GetFlagRoleCallback ( void *  ctxt,
uint32_t  flag,
uint32_t  semClass 
)
staticprotected

◆ GetFlagsRequiredForFlagConditionCallback()

uint32_t * Architecture::GetFlagsRequiredForFlagConditionCallback ( void *  ctxt,
BNLowLevelILFlagCondition  cond,
uint32_t  semClass,
size_t *  count 
)
staticprotected

◆ GetFlagsRequiredForSemanticFlagGroupCallback()

uint32_t * Architecture::GetFlagsRequiredForSemanticFlagGroupCallback ( void *  ctxt,
uint32_t  semGroup,
size_t *  count 
)
staticprotected

◆ GetFlagConditionsForSemanticFlagGroupCallback()

BNFlagConditionForSemanticClass * Architecture::GetFlagConditionsForSemanticFlagGroupCallback ( void *  ctxt,
uint32_t  semGroup,
size_t *  count 
)
staticprotected

◆ FreeFlagConditionsForSemanticFlagGroupCallback()

void Architecture::FreeFlagConditionsForSemanticFlagGroupCallback ( void *  ctxt,
BNFlagConditionForSemanticClass conditions 
)
staticprotected

◆ GetFlagsWrittenByFlagWriteTypeCallback()

uint32_t * Architecture::GetFlagsWrittenByFlagWriteTypeCallback ( void *  ctxt,
uint32_t  writeType,
size_t *  count 
)
staticprotected

◆ GetSemanticClassForFlagWriteTypeCallback()

uint32_t Architecture::GetSemanticClassForFlagWriteTypeCallback ( void *  ctxt,
uint32_t  writeType 
)
staticprotected

◆ GetFlagWriteLowLevelILCallback()

size_t Architecture::GetFlagWriteLowLevelILCallback ( void *  ctxt,
BNLowLevelILOperation  op,
size_t  size,
uint32_t  flagWriteType,
uint32_t  flag,
BNRegisterOrConstant operands,
size_t  operandCount,
BNLowLevelILFunction il 
)
staticprotected

◆ GetFlagConditionLowLevelILCallback()

size_t Architecture::GetFlagConditionLowLevelILCallback ( void *  ctxt,
BNLowLevelILFlagCondition  cond,
uint32_t  semClass,
BNLowLevelILFunction il 
)
staticprotected

◆ GetSemanticFlagGroupLowLevelILCallback()

size_t Architecture::GetSemanticFlagGroupLowLevelILCallback ( void *  ctxt,
uint32_t  semGroup,
BNLowLevelILFunction il 
)
staticprotected

◆ FreeRegisterListCallback()

void Architecture::FreeRegisterListCallback ( void *  ctxt,
uint32_t *  regs 
)
staticprotected

◆ GetRegisterInfoCallback()

void Architecture::GetRegisterInfoCallback ( void *  ctxt,
uint32_t  reg,
BNRegisterInfo result 
)
staticprotected

◆ GetStackPointerRegisterCallback()

uint32_t Architecture::GetStackPointerRegisterCallback ( void *  ctxt)
staticprotected

◆ GetLinkRegisterCallback()

uint32_t Architecture::GetLinkRegisterCallback ( void *  ctxt)
staticprotected

◆ GetGlobalRegistersCallback()

uint32_t * Architecture::GetGlobalRegistersCallback ( void *  ctxt,
size_t *  count 
)
staticprotected

◆ GetSystemRegistersCallback()

uint32_t * Architecture::GetSystemRegistersCallback ( void *  ctxt,
size_t *  count 
)
staticprotected

◆ GetRegisterStackNameCallback()

char * Architecture::GetRegisterStackNameCallback ( void *  ctxt,
uint32_t  regStack 
)
staticprotected

◆ GetAllRegisterStacksCallback()

uint32_t * Architecture::GetAllRegisterStacksCallback ( void *  ctxt,
size_t *  count 
)
staticprotected

◆ GetRegisterStackInfoCallback()

void Architecture::GetRegisterStackInfoCallback ( void *  ctxt,
uint32_t  regStack,
BNRegisterStackInfo result 
)
staticprotected

◆ GetIntrinsicNameCallback()

char * Architecture::GetIntrinsicNameCallback ( void *  ctxt,
uint32_t  intrinsic 
)
staticprotected

◆ GetAllIntrinsicsCallback()

uint32_t * Architecture::GetAllIntrinsicsCallback ( void *  ctxt,
size_t *  count 
)
staticprotected

◆ GetIntrinsicInputsCallback()

BNNameAndType * Architecture::GetIntrinsicInputsCallback ( void *  ctxt,
uint32_t  intrinsic,
size_t *  count 
)
staticprotected

◆ FreeNameAndTypeListCallback()

void Architecture::FreeNameAndTypeListCallback ( void *  ctxt,
BNNameAndType nt,
size_t  count 
)
staticprotected

◆ GetIntrinsicOutputsCallback()

BNTypeWithConfidence * Architecture::GetIntrinsicOutputsCallback ( void *  ctxt,
uint32_t  intrinsic,
size_t *  count 
)
staticprotected

◆ FreeTypeListCallback()

void Architecture::FreeTypeListCallback ( void *  ctxt,
BNTypeWithConfidence types,
size_t  count 
)
staticprotected

◆ CanAssembleCallback()

bool Architecture::CanAssembleCallback ( void *  ctxt)
staticprotected

◆ AssembleCallback()

bool Architecture::AssembleCallback ( void *  ctxt,
const char *  code,
uint64_t  addr,
BNDataBuffer result,
char **  errors 
)
staticprotected

◆ IsNeverBranchPatchAvailableCallback()

bool Architecture::IsNeverBranchPatchAvailableCallback ( void *  ctxt,
const uint8_t *  data,
uint64_t  addr,
size_t  len 
)
staticprotected

◆ IsAlwaysBranchPatchAvailableCallback()

bool Architecture::IsAlwaysBranchPatchAvailableCallback ( void *  ctxt,
const uint8_t *  data,
uint64_t  addr,
size_t  len 
)
staticprotected

◆ IsInvertBranchPatchAvailableCallback()

bool Architecture::IsInvertBranchPatchAvailableCallback ( void *  ctxt,
const uint8_t *  data,
uint64_t  addr,
size_t  len 
)
staticprotected

◆ IsSkipAndReturnZeroPatchAvailableCallback()

bool Architecture::IsSkipAndReturnZeroPatchAvailableCallback ( void *  ctxt,
const uint8_t *  data,
uint64_t  addr,
size_t  len 
)
staticprotected

◆ IsSkipAndReturnValuePatchAvailableCallback()

bool Architecture::IsSkipAndReturnValuePatchAvailableCallback ( void *  ctxt,
const uint8_t *  data,
uint64_t  addr,
size_t  len 
)
staticprotected

◆ ConvertToNopCallback()

bool Architecture::ConvertToNopCallback ( void *  ctxt,
uint8_t *  data,
uint64_t  addr,
size_t  len 
)
staticprotected

◆ AlwaysBranchCallback()

bool Architecture::AlwaysBranchCallback ( void *  ctxt,
uint8_t *  data,
uint64_t  addr,
size_t  len 
)
staticprotected

◆ InvertBranchCallback()

bool Architecture::InvertBranchCallback ( void *  ctxt,
uint8_t *  data,
uint64_t  addr,
size_t  len 
)
staticprotected

◆ SkipAndReturnValueCallback()

bool Architecture::SkipAndReturnValueCallback ( void *  ctxt,
uint8_t *  data,
uint64_t  addr,
size_t  len,
uint64_t  value 
)
staticprotected

◆ Register() [1/2]

void Architecture::Register ( BNCustomArchitecture callbacks)
protectedvirtual

◆ Register() [2/2]

void Architecture::Register ( Architecture arch)
static

Register an architecture.

Parameters
archArchitecture to register

◆ GetByName()

Ref< Architecture > Architecture::GetByName ( const std::string &  name)
static

Get an Architecture by name.

Parameters
nameName of the architecture
Returns
The architecture, if it was found.

◆ GetList()

vector< Ref< Architecture > > Architecture::GetList ( )
static

Get the list of registered Architectures.

Returns
The list of registered architectures

◆ GetName()

string Architecture::GetName ( ) const

Get the name of this architecture.

Returns
The name of this architecture

◆ GetEndianness()

virtual BNEndianness BinaryNinja::Architecture::GetEndianness ( ) const
pure virtual

Get the default endianness for this architecture.

Returns
The default endianness for this architecture

Implemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ GetAddressSize()

virtual size_t BinaryNinja::Architecture::GetAddressSize ( ) const
pure virtual

Get the address size for this architecture.

Returns
The address size for this architecture

Implemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ GetDefaultIntegerSize()

size_t Architecture::GetDefaultIntegerSize ( ) const
virtual

Get the default integer size for this architecture.

Returns
The default integer size for this architecture

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ GetInstructionAlignment()

size_t Architecture::GetInstructionAlignment ( ) const
virtual

◆ GetMaxInstructionLength()

size_t Architecture::GetMaxInstructionLength ( ) const
virtual

Get the maximum instruction length.

Returns
The maximum instruction length

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ GetOpcodeDisplayLength()

size_t Architecture::GetOpcodeDisplayLength ( ) const
virtual

◆ GetAssociatedArchitectureByAddress()

Ref< Architecture > Architecture::GetAssociatedArchitectureByAddress ( uint64_t &  addr)
virtual

◆ GetInstructionInfo()

virtual bool BinaryNinja::Architecture::GetInstructionInfo ( const uint8_t *  data,
uint64_t  addr,
size_t  maxLen,
InstructionInfo result 
)
pure virtual

Retrieves an InstructionInfo struct for the instruction at the given virtual address.

Note
Architecture subclasses should implement this method.
The instruction info object should always set the InstructionInfo.length to the instruction length, \ and the branches of the proper types should be added if the instruction is a branch.

If the instruction is a branch instruction architecture plugins should add a branch of the proper type:

===================== =================================================== BNBranchType Description ===================== =================================================== UnconditionalBranch Branch will always be taken FalseBranch False branch condition TrueBranch True branch condition CallDestination Branch is a call instruction (Branch with Link) FunctionReturn Branch returns from a function SystemCall System call instruction IndirectBranch Branch destination is a memory address or register UnresolvedBranch Branch destination is an unknown address ===================== ===================================================

Parameters
[in]datapointer to the instruction data to retrieve info for
[in]addraddress of the instruction data to retrieve info for
[in]maxLenMaximum length of the instruction data to read
[out]resultRetrieved instruction info
Returns
Whether instruction info was successfully retrieved.

Implemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ GetInstructionText()

virtual bool BinaryNinja::Architecture::GetInstructionText ( const uint8_t *  data,
uint64_t  addr,
size_t &  len,
std::vector< InstructionTextToken > &  result 
)
pure virtual

Retrieves a list of InstructionTextTokens.

Parameters
[in]datapointer to the instruction data to retrieve text for
[in]addraddress of the instruction data to retrieve text for
[out]lenwill be written to with the length of the instruction data which was translated
[out]result
Returns
Whether instruction info was successfully retrieved.

Implemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ GetInstructionLowLevelIL()

bool Architecture::GetInstructionLowLevelIL ( const uint8_t *  data,
uint64_t  addr,
size_t &  len,
LowLevelILFunction il 
)
virtual

Translates an instruction at addr and appends it onto the LowLevelILFunction& il.

Note
Architecture subclasses should implement this method.
Parameters
[in]datapointer to the instruction data to be translated
[in]addraddress of the instruction data to be translated
[out]lenwill be written to with the length of the instruction data which was translated
[in,out]ilthe LowLevelILFunction to appended to.

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ GetRegisterName()

string Architecture::GetRegisterName ( uint32_t  reg)
virtual

Gets a register name from a register index.

Parameters
regRegister index
Returns
The register name

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ GetFlagName()

string Architecture::GetFlagName ( uint32_t  flag)
virtual

Gets a flag name from a flag index.

Parameters
flagFlag index
Returns
Flag name

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ GetFlagWriteTypeName()

string Architecture::GetFlagWriteTypeName ( uint32_t  flags)
virtual

Gets the flag write type name for the given flag.

Parameters
flagsflag
Returns
Flag name

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ GetSemanticFlagClassName()

string Architecture::GetSemanticFlagClassName ( uint32_t  semClass)
virtual

Gets the name of a semantic flag class from the index.

Parameters
semClassSemantic class index
Returns
The name of the semantic flag class

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ GetSemanticFlagGroupName()

string Architecture::GetSemanticFlagGroupName ( uint32_t  semGroup)
virtual

Gets the name of a semantic flag group from the index.

Parameters
semGroupSemantic flag group index
Returns
Semantic flag group name

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ GetFullWidthRegisters()

vector< uint32_t > Architecture::GetFullWidthRegisters ( )
virtual

Get the list of full width register indices.

Returns
The list of full width register indices

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ GetAllRegisters()

vector< uint32_t > Architecture::GetAllRegisters ( )
virtual

Get the list of all register indices.

Returns
The list of all register indices

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ GetAllFlags()

vector< uint32_t > Architecture::GetAllFlags ( )
virtual

Get the list of all flag indices.

Returns
The list of all flag indices

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ GetAllFlagWriteTypes()

vector< uint32_t > Architecture::GetAllFlagWriteTypes ( )
virtual

Get the list of all flag write type indices.

Returns
The list of all flag write type indices

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ GetAllSemanticFlagClasses()

vector< uint32_t > Architecture::GetAllSemanticFlagClasses ( )
virtual

Get the list of all semantic flag class indices.

Returns
The list of all semantic flag class indices

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ GetAllSemanticFlagGroups()

vector< uint32_t > Architecture::GetAllSemanticFlagGroups ( )
virtual

Get the list of all semantic flag group indices.

Returns
The list of all semantic flag group indices

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ GetFlagRole()

BNFlagRole Architecture::GetFlagRole ( uint32_t  flag,
uint32_t  semClass = 0 
)
virtual

Get the role of a given flag.

Parameters
flagFlag index
semClassOptional semantic flag class
Returns
Flag role

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ GetFlagsRequiredForFlagCondition()

vector< uint32_t > Architecture::GetFlagsRequiredForFlagCondition ( BNLowLevelILFlagCondition  cond,
uint32_t  semClass = 0 
)
virtual

◆ GetFlagsRequiredForSemanticFlagGroup()

vector< uint32_t > Architecture::GetFlagsRequiredForSemanticFlagGroup ( uint32_t  semGroup)
virtual

◆ GetFlagConditionsForSemanticFlagGroup()

map< uint32_t, BNLowLevelILFlagCondition > Architecture::GetFlagConditionsForSemanticFlagGroup ( uint32_t  semGroup)
virtual

◆ GetFlagsWrittenByFlagWriteType()

vector< uint32_t > Architecture::GetFlagsWrittenByFlagWriteType ( uint32_t  writeType)
virtual

◆ GetSemanticClassForFlagWriteType()

uint32_t Architecture::GetSemanticClassForFlagWriteType ( uint32_t  writeType)
virtual

◆ GetFlagWriteLowLevelIL()

size_t Architecture::GetFlagWriteLowLevelIL ( BNLowLevelILOperation  op,
size_t  size,
uint32_t  flagWriteType,
uint32_t  flag,
BNRegisterOrConstant operands,
size_t  operandCount,
LowLevelILFunction il 
)
virtual

◆ GetDefaultFlagWriteLowLevelIL()

size_t Architecture::GetDefaultFlagWriteLowLevelIL ( BNLowLevelILOperation  op,
size_t  size,
BNFlagRole  role,
BNRegisterOrConstant operands,
size_t  operandCount,
LowLevelILFunction il 
)

◆ GetFlagConditionLowLevelIL()

ExprId Architecture::GetFlagConditionLowLevelIL ( BNLowLevelILFlagCondition  cond,
uint32_t  semClass,
LowLevelILFunction il 
)
virtual

◆ GetDefaultFlagConditionLowLevelIL()

ExprId Architecture::GetDefaultFlagConditionLowLevelIL ( BNLowLevelILFlagCondition  cond,
uint32_t  semClass,
LowLevelILFunction il 
)

◆ GetSemanticFlagGroupLowLevelIL()

ExprId Architecture::GetSemanticFlagGroupLowLevelIL ( uint32_t  semGroup,
LowLevelILFunction il 
)
virtual

◆ GetRegisterInfo()

BNRegisterInfo Architecture::GetRegisterInfo ( uint32_t  reg)
virtual

Get the register info for a given register index.

Parameters
regRegister index
Returns
Register info

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ GetStackPointerRegister()

uint32_t Architecture::GetStackPointerRegister ( )
virtual

Get the register index corresponding to the stack pointer (SP)

Returns
The register index corresponding to the stack pointer

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ GetLinkRegister()

uint32_t Architecture::GetLinkRegister ( )
virtual

Get the register index corresponding to the link register (LR)

Returns
The register index corresponding to the link register

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ GetGlobalRegisters()

vector< uint32_t > Architecture::GetGlobalRegisters ( )
virtual

◆ IsGlobalRegister()

bool Architecture::IsGlobalRegister ( uint32_t  reg)

◆ GetSystemRegisters()

vector< uint32_t > Architecture::GetSystemRegisters ( )
virtual

Get the list of system register indices.

Returns
The list of system register indices

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ IsSystemRegister()

bool Architecture::IsSystemRegister ( uint32_t  reg)

Check whether a register is a system register.

Parameters
regRegister index
Returns
Whether a register is a system register

◆ GetModifiedRegistersOnWrite()

vector< uint32_t > Architecture::GetModifiedRegistersOnWrite ( uint32_t  reg)

Returns a list of register indices that are modified when reg is written to.

Parameters
regRegister index
Returns
List of register indices modified on write.

◆ GetRegisterByName()

uint32_t Architecture::GetRegisterByName ( const std::string &  name)

Get a register index by its name.

Parameters
nameName of the register
Returns
Index of the register

◆ GetRegisterStackName()

string Architecture::GetRegisterStackName ( uint32_t  regStack)
virtual

Get a register stack name from a register stack number.

Parameters
regStackRegister stack number
Returns
The corresponding register string

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ GetAllRegisterStacks()

vector< uint32_t > Architecture::GetAllRegisterStacks ( )
virtual

◆ GetRegisterStackInfo()

BNRegisterStackInfo Architecture::GetRegisterStackInfo ( uint32_t  regStack)
virtual

◆ GetRegisterStackForRegister()

uint32_t Architecture::GetRegisterStackForRegister ( uint32_t  reg)

◆ GetIntrinsicName()

string Architecture::GetIntrinsicName ( uint32_t  intrinsic)
virtual

Gets an intrinsic name from an intrinsic number.

Parameters
intrinsicIntrinsic number
Returns
The corresponding intrinsic string

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ GetAllIntrinsics()

vector< uint32_t > Architecture::GetAllIntrinsics ( )
virtual

◆ GetIntrinsicInputs()

vector< NameAndType > Architecture::GetIntrinsicInputs ( uint32_t  intrinsic)
virtual

◆ GetIntrinsicOutputs()

vector< Confidence< Ref< Type > > > Architecture::GetIntrinsicOutputs ( uint32_t  intrinsic)
virtual

◆ CanAssemble()

bool Architecture::CanAssemble ( )
virtual

Check whether this architecture can assemble instructions.

Returns
Whether this architecture can assemble instructions

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ Assemble()

bool Architecture::Assemble ( const std::string &  code,
uint64_t  addr,
DataBuffer result,
std::string &  errors 
)
virtual

Converts the string of assembly instructions code loaded at virtual address addr to the byte representation of those instructions.

Parameters
[in]codeString representation of the instructions to be assembled
[in]addrAddress of the instructions
[out]resultDataBuffer containing the compiled bytes
[out]errorsAny errors that occurred during assembly
Returns
Whether assembly was successful

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ IsNeverBranchPatchAvailable()

bool Architecture::IsNeverBranchPatchAvailable ( const uint8_t *  data,
uint64_t  addr,
size_t  len 
)
virtual

Returns true if the instruction at addr can be patched to never branch.

Note
This is used in the UI to determine if "never branch" should be displayed in the right-click context menu when right-clicking on an instruction.
Parameters
dataBuffer of bytes to check
addrthe virtual address of the bytes, to be used when assembling
lenamount of bytes to be checked
Returns
If the never branch patch is available

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ IsAlwaysBranchPatchAvailable()

bool Architecture::IsAlwaysBranchPatchAvailable ( const uint8_t *  data,
uint64_t  addr,
size_t  len 
)
virtual

Returns true if the instruction at addr can be patched to always branch.

Note
This is used in the UI to determine if "always branch" should be displayed in the right-click context menu when right-clicking on an instruction.
Parameters
dataBuffer of bytes to check
addrthe address of the instruction in question
lenamount of bytes to be checked
Returns
If the always branch patch is available

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ IsInvertBranchPatchAvailable()

bool Architecture::IsInvertBranchPatchAvailable ( const uint8_t *  data,
uint64_t  addr,
size_t  len 
)
virtual

Returns true if the instruction at addr can be patched to invert the branch.

Note
This is used in the UI to determine if "invert branch" should be displayed in the right-click context menu when right-clicking on an instruction.
Parameters
dataBuffer of bytes to check
addrthe address of the instruction in question
lenamount of bytes to be checked
Returns
If the invert branch patch is available

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ IsSkipAndReturnZeroPatchAvailable()

bool Architecture::IsSkipAndReturnZeroPatchAvailable ( const uint8_t *  data,
uint64_t  addr,
size_t  len 
)
virtual

Checks if the instruction at addr is a call that can be patched to return zero.

Note
This is used in the UI to determine if "skip and return zero" should be displayed in the right-click context menu when right-clicking on an instruction.
Parameters
dataBuffer of bytes to check
addrthe address of the instruction in question
lenamount of bytes to be checked
Returns
If the skip and return zero patch is available

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ IsSkipAndReturnValuePatchAvailable()

bool Architecture::IsSkipAndReturnValuePatchAvailable ( const uint8_t *  data,
uint64_t  addr,
size_t  len 
)
virtual

Checks if the instruction at addr is a call that can be patched to return a value.

Note
This is used in the UI to determine if "skip and return value" should be displayed in the right-click context menu when right-clicking on an instruction.
Parameters
dataBuffer of bytes to check
addrthe address of the instruction in question
lenamount of bytes to be checked
Returns
If the skip and return value patch is available

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ ConvertToNop()

bool Architecture::ConvertToNop ( uint8_t *  data,
uint64_t  addr,
size_t  len 
)
virtual

Converts the instruction at addr to a no-operation instruction.

Parameters
[in,out]dataBuffer of bytes to convert
[in]addrthe address of the instruction to be converted
[in]lenLength of the bytes to be converted
Returns
Whether the conversion was successful

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ AlwaysBranch()

bool Architecture::AlwaysBranch ( uint8_t *  data,
uint64_t  addr,
size_t  len 
)
virtual

Converts the conditional branch instruction at addr to an unconditional branch.

Note
This is called when the right-click context menu item "always branch" is selected in the UI.
Parameters
[in,out]dataBuffer of bytes to convert
[in]addrthe address of the instruction to be converted
[in]lenLength of the bytes to be converted
Returns
Whether the conversion was successful

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ InvertBranch()

bool Architecture::InvertBranch ( uint8_t *  data,
uint64_t  addr,
size_t  len 
)
virtual

InvertBranch converts the conditional branch instruction at addr to its invert.

Note
This is called when the right-click context menu item "invert branch" is selected in the UI.
Parameters
[in,out]dataBuffer of bytes to convert
[in]addrthe address of the instruction to be converted
[in]lenLength of the bytes to be converted
Returns
Whether the conversion was successful

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ SkipAndReturnValue()

bool Architecture::SkipAndReturnValue ( uint8_t *  data,
uint64_t  addr,
size_t  len,
uint64_t  value 
)
virtual

SkipAndReturnValue converts the call instruction at addr to an instruction that simulates that call returning a value.

Note
This is called when the right-click context menu item "skip and return value" is selected in the UI.
Parameters
[in,out]dataBuffer of bytes to convert
[in]addrthe address of the instruction to be converted
[in]lenLength of the bytes to be converted
[in]valueValue to be returned
Returns
Whether the conversion was successful

Reimplemented in BinaryNinja::CoreArchitecture, and BinaryNinja::ArchitectureExtension.

◆ RegisterFunctionRecognizer()

void Architecture::RegisterFunctionRecognizer ( FunctionRecognizer recog)

◆ RegisterRelocationHandler()

void Architecture::RegisterRelocationHandler ( const std::string &  viewName,
RelocationHandler handler 
)

◆ GetRelocationHandler()

Ref< RelocationHandler > Architecture::GetRelocationHandler ( const std::string &  viewName)

◆ IsBinaryViewTypeConstantDefined()

bool Architecture::IsBinaryViewTypeConstantDefined ( const std::string &  type,
const std::string &  name 
)
Deprecated:
This API has been deprecated. The implementation has been removed, and this function no longer has any effect

◆ GetBinaryViewTypeConstant()

uint64_t Architecture::GetBinaryViewTypeConstant ( const std::string &  type,
const std::string &  name,
uint64_t  defaultValue = 0 
)
Deprecated:
This API has been deprecated. The implementation has been removed, and this function no longer has any effect

◆ SetBinaryViewTypeConstant()

void Architecture::SetBinaryViewTypeConstant ( const std::string &  type,
const std::string &  name,
uint64_t  value 
)
Deprecated:
This API has been deprecated. The implementation has been removed, and this function no longer has any effect

◆ RegisterCallingConvention()

void Architecture::RegisterCallingConvention ( CallingConvention cc)

Register a calling convention with this architecture.

Parameters
cccalling convention to register

◆ GetCallingConventions()

vector< Ref< CallingConvention > > Architecture::GetCallingConventions ( )

List of registered calling conventions.

Returns
The list of registered calling conventions

◆ GetCallingConventionByName()

Ref< CallingConvention > Architecture::GetCallingConventionByName ( const std::string &  name)

Get a calling convention by name.

Parameters
nameName of the calling convention
Returns
The calling convention

◆ SetDefaultCallingConvention()

void Architecture::SetDefaultCallingConvention ( CallingConvention cc)

Set the default calling convention.

Parameters
ccThe default calling convention

◆ SetCdeclCallingConvention()

void Architecture::SetCdeclCallingConvention ( CallingConvention cc)

Set the cdecl calling convention.

Parameters
ccThe cdecl calling convention

◆ SetStdcallCallingConvention()

void Architecture::SetStdcallCallingConvention ( CallingConvention cc)

Set the stdcall calling convention.

Parameters
ccThe stdcall calling convention

◆ SetFastcallCallingConvention()

void Architecture::SetFastcallCallingConvention ( CallingConvention cc)

Set the fastcall calling convention.

Parameters
ccThe fastcall calling convention

◆ GetDefaultCallingConvention()

Ref< CallingConvention > Architecture::GetDefaultCallingConvention ( )

Get the default calling convention.

Returns
The default calling convention

◆ GetCdeclCallingConvention()

Ref< CallingConvention > Architecture::GetCdeclCallingConvention ( )

Get the cdecl calling convention.

Returns
The cdecl calling convention

◆ GetStdcallCallingConvention()

Ref< CallingConvention > Architecture::GetStdcallCallingConvention ( )

Get the stdcall calling convention.

Returns
The stdcall calling convention

◆ GetFastcallCallingConvention()

Ref< CallingConvention > Architecture::GetFastcallCallingConvention ( )

Get the fastcall calling convention.

Returns
The fastcall calling convention

◆ GetStandalonePlatform()

Ref< Platform > Architecture::GetStandalonePlatform ( )

Get the Architecture standalone platform.

Returns
Architecture standalone platform

◆ GetTypeLibraries()

vector< Ref< TypeLibrary > > Architecture::GetTypeLibraries ( )

◆ AddArchitectureRedirection()

void Architecture::AddArchitectureRedirection ( Architecture from,
Architecture to 
)

Member Data Documentation

◆ m_nameForRegister

std::string BinaryNinja::Architecture::m_nameForRegister
protected

◆ BinaryNinja::CoreArchitecture

class BinaryNinja::CoreArchitecture

Public Member Functions

 CoreArchitecture (BNArchitecture *arch)
 
virtual BNEndianness GetEndianness () const override
 Get the default endianness for this architecture. More...
 
virtual size_t GetAddressSize () const override
 Get the address size for this architecture. More...
 
virtual size_t GetDefaultIntegerSize () const override
 Get the default integer size for this architecture. More...
 
virtual size_t GetInstructionAlignment () const override
 
virtual size_t GetMaxInstructionLength () const override
 Get the maximum instruction length. More...
 
virtual size_t GetOpcodeDisplayLength () const override
 
virtual Ref< ArchitectureGetAssociatedArchitectureByAddress (uint64_t &addr) override
 
virtual bool GetInstructionInfo (const uint8_t *data, uint64_t addr, size_t maxLen, InstructionInfo &result) override
 Retrieves an InstructionInfo struct for the instruction at the given virtual address. More...
 
virtual bool GetInstructionText (const uint8_t *data, uint64_t addr, size_t &len, std::vector< InstructionTextToken > &result) override
 Retrieves a list of InstructionTextTokens. More...
 
virtual bool GetInstructionLowLevelIL (const uint8_t *data, uint64_t addr, size_t &len, LowLevelILFunction &il) override
 Translates an instruction at addr and appends it onto the LowLevelILFunction& il. More...
 
virtual std::string GetRegisterName (uint32_t reg) override
 Gets a register name from a register index. More...
 
virtual std::string GetFlagName (uint32_t flag) override
 Gets a flag name from a flag index. More...
 
virtual std::string GetFlagWriteTypeName (uint32_t flags) override
 Gets the flag write type name for the given flag. More...
 
virtual std::string GetSemanticFlagClassName (uint32_t semClass) override
 Gets the name of a semantic flag class from the index. More...
 
virtual std::string GetSemanticFlagGroupName (uint32_t semGroup) override
 Gets the name of a semantic flag group from the index. More...
 
virtual std::vector< uint32_t > GetFullWidthRegisters () override
 Get the list of full width register indices. More...
 
virtual std::vector< uint32_t > GetAllRegisters () override
 Get the list of all register indices. More...
 
virtual std::vector< uint32_t > GetAllFlags () override
 Get the list of all flag indices. More...
 
virtual std::vector< uint32_t > GetAllFlagWriteTypes () override
 Get the list of all flag write type indices. More...
 
virtual std::vector< uint32_t > GetAllSemanticFlagClasses () override
 Get the list of all semantic flag class indices. More...
 
virtual std::vector< uint32_t > GetAllSemanticFlagGroups () override
 Get the list of all semantic flag group indices. More...
 
virtual BNFlagRole GetFlagRole (uint32_t flag, uint32_t semClass=0) override
 Get the role of a given flag. More...
 
virtual std::vector< uint32_t > GetFlagsRequiredForFlagCondition (BNLowLevelILFlagCondition cond, uint32_t semClass=0) override
 
virtual std::vector< uint32_t > GetFlagsRequiredForSemanticFlagGroup (uint32_t semGroup) override
 
virtual std::map< uint32_t, BNLowLevelILFlagConditionGetFlagConditionsForSemanticFlagGroup (uint32_t semGroup) override
 
virtual std::vector< uint32_t > GetFlagsWrittenByFlagWriteType (uint32_t writeType) override
 
virtual uint32_t GetSemanticClassForFlagWriteType (uint32_t writeType) override
 
virtual ExprId GetFlagWriteLowLevelIL (BNLowLevelILOperation op, size_t size, uint32_t flagWriteType, uint32_t flag, BNRegisterOrConstant *operands, size_t operandCount, LowLevelILFunction &il) override
 
virtual ExprId GetFlagConditionLowLevelIL (BNLowLevelILFlagCondition cond, uint32_t semClass, LowLevelILFunction &il) override
 
virtual ExprId GetSemanticFlagGroupLowLevelIL (uint32_t semGroup, LowLevelILFunction &il) override
 
virtual BNRegisterInfo GetRegisterInfo (uint32_t reg) override
 Get the register info for a given register index. More...
 
virtual uint32_t GetStackPointerRegister () override
 Get the register index corresponding to the stack pointer (SP) More...
 
virtual uint32_t GetLinkRegister () override
 Get the register index corresponding to the link register (LR) More...
 
virtual std::vector< uint32_t > GetGlobalRegisters () override
 
virtual std::vector< uint32_t > GetSystemRegisters () override
 Get the list of system register indices. More...
 
virtual std::string GetRegisterStackName (uint32_t regStack) override
 Get a register stack name from a register stack number. More...
 
virtual std::vector< uint32_t > GetAllRegisterStacks () override
 
virtual BNRegisterStackInfo GetRegisterStackInfo (uint32_t regStack) override
 
virtual std::string GetIntrinsicName (uint32_t intrinsic) override
 Gets an intrinsic name from an intrinsic number. More...
 
virtual std::vector< uint32_t > GetAllIntrinsics () override
 
virtual std::vector< NameAndTypeGetIntrinsicInputs (uint32_t intrinsic) override
 
virtual std::vector< Confidence< Ref< Type > > > GetIntrinsicOutputs (uint32_t intrinsic) override
 
virtual bool CanAssemble () override
 Check whether this architecture can assemble instructions. More...
 
virtual bool Assemble (const std::string &code, uint64_t addr, DataBuffer &result, std::string &errors) override
 Converts the string of assembly instructions code loaded at virtual address addr to the byte representation of those instructions. More...
 
virtual bool IsNeverBranchPatchAvailable (const uint8_t *data, uint64_t addr, size_t len) override
 Returns true if the instruction at addr can be patched to never branch. More...
 
virtual bool IsAlwaysBranchPatchAvailable (const uint8_t *data, uint64_t addr, size_t len) override
 Returns true if the instruction at addr can be patched to always branch. More...
 
virtual bool IsInvertBranchPatchAvailable (const uint8_t *data, uint64_t addr, size_t len) override
 Returns true if the instruction at addr can be patched to invert the branch. More...
 
virtual bool IsSkipAndReturnZeroPatchAvailable (const uint8_t *data, uint64_t addr, size_t len) override
 Checks if the instruction at addr is a call that can be patched to return zero. More...
 
virtual bool IsSkipAndReturnValuePatchAvailable (const uint8_t *data, uint64_t addr, size_t len) override
 Checks if the instruction at addr is a call that can be patched to return a value. More...
 
virtual bool ConvertToNop (uint8_t *data, uint64_t addr, size_t len) override
 Converts the instruction at addr to a no-operation instruction. More...
 
virtual bool AlwaysBranch (uint8_t *data, uint64_t addr, size_t len) override
 Converts the conditional branch instruction at addr to an unconditional branch. More...
 
virtual bool InvertBranch (uint8_t *data, uint64_t addr, size_t len) override
 InvertBranch converts the conditional branch instruction at addr to its invert. More...
 
virtual bool SkipAndReturnValue (uint8_t *data, uint64_t addr, size_t len, uint64_t value) override
 SkipAndReturnValue converts the call instruction at addr to an instruction that simulates that call returning a value. More...
 
- Public Member Functions inherited from BinaryNinja::Architecture
 Architecture (const std::string &name)
 
std::string GetName () const
 Get the name of this architecture. More...
 
virtual BNEndianness GetEndianness () const =0
 Get the default endianness for this architecture. More...
 
virtual size_t GetAddressSize () const =0
 Get the address size for this architecture. More...
 
virtual size_t GetDefaultIntegerSize () const
 Get the default integer size for this architecture. More...
 
virtual size_t GetInstructionAlignment () const
 
virtual size_t GetMaxInstructionLength () const
 Get the maximum instruction length. More...
 
virtual size_t GetOpcodeDisplayLength () const
 
virtual Ref< ArchitectureGetAssociatedArchitectureByAddress (uint64_t &addr)
 
virtual bool GetInstructionInfo (const uint8_t *data, uint64_t addr, size_t maxLen, InstructionInfo &result)=0
 Retrieves an InstructionInfo struct for the instruction at the given virtual address. More...
 
virtual bool GetInstructionText (const uint8_t *data, uint64_t addr, size_t &len, std::vector< InstructionTextToken > &result)=0
 Retrieves a list of InstructionTextTokens. More...
 
virtual bool GetInstructionLowLevelIL (const uint8_t *data, uint64_t addr, size_t &len, LowLevelILFunction &il)
 Translates an instruction at addr and appends it onto the LowLevelILFunction& il. More...
 
virtual std::string GetRegisterName (uint32_t reg)
 Gets a register name from a register index. More...
 
virtual std::string GetFlagName (uint32_t flag)
 Gets a flag name from a flag index. More...
 
virtual std::string GetFlagWriteTypeName (uint32_t flags)
 Gets the flag write type name for the given flag. More...
 
virtual std::string GetSemanticFlagClassName (uint32_t semClass)
 Gets the name of a semantic flag class from the index. More...
 
virtual std::string GetSemanticFlagGroupName (uint32_t semGroup)
 Gets the name of a semantic flag group from the index. More...
 
virtual std::vector< uint32_t > GetFullWidthRegisters ()
 Get the list of full width register indices. More...
 
virtual std::vector< uint32_t > GetAllRegisters ()
 Get the list of all register indices. More...
 
virtual std::vector< uint32_t > GetAllFlags ()
 Get the list of all flag indices. More...
 
virtual std::vector< uint32_t > GetAllFlagWriteTypes ()
 Get the list of all flag write type indices. More...
 
virtual std::vector< uint32_t > GetAllSemanticFlagClasses ()
 Get the list of all semantic flag class indices. More...
 
virtual std::vector< uint32_t > GetAllSemanticFlagGroups ()
 Get the list of all semantic flag group indices. More...
 
virtual BNFlagRole GetFlagRole (uint32_t flag, uint32_t semClass=0)
 Get the role of a given flag. More...
 
virtual std::vector< uint32_t > GetFlagsRequiredForFlagCondition (BNLowLevelILFlagCondition cond, uint32_t semClass=0)
 
virtual std::vector< uint32_t > GetFlagsRequiredForSemanticFlagGroup (uint32_t semGroup)
 
virtual std::map< uint32_t, BNLowLevelILFlagConditionGetFlagConditionsForSemanticFlagGroup (uint32_t semGroup)
 
virtual std::vector< uint32_t > GetFlagsWrittenByFlagWriteType (uint32_t writeType)
 
virtual uint32_t GetSemanticClassForFlagWriteType (uint32_t writeType)
 
virtual ExprId GetFlagWriteLowLevelIL (BNLowLevelILOperation op, size_t size, uint32_t flagWriteType, uint32_t flag, BNRegisterOrConstant *operands, size_t operandCount, LowLevelILFunction &il)
 
ExprId GetDefaultFlagWriteLowLevelIL (BNLowLevelILOperation op, size_t size, BNFlagRole role, BNRegisterOrConstant *operands, size_t operandCount, LowLevelILFunction &il)
 
virtual ExprId GetFlagConditionLowLevelIL (BNLowLevelILFlagCondition cond, uint32_t semClass, LowLevelILFunction &il)
 
ExprId GetDefaultFlagConditionLowLevelIL (BNLowLevelILFlagCondition cond, uint32_t semClass, LowLevelILFunction &il)
 
virtual ExprId GetSemanticFlagGroupLowLevelIL (uint32_t semGroup, LowLevelILFunction &il)
 
virtual BNRegisterInfo GetRegisterInfo (uint32_t reg)
 Get the register info for a given register index. More...
 
virtual uint32_t GetStackPointerRegister ()
 Get the register index corresponding to the stack pointer (SP) More...
 
virtual uint32_t GetLinkRegister ()
 Get the register index corresponding to the link register (LR) More...
 
virtual std::vector< uint32_t > GetGlobalRegisters ()
 
bool IsGlobalRegister (uint32_t reg)
 
virtual std::vector< uint32_t > GetSystemRegisters ()
 Get the list of system register indices. More...
 
bool IsSystemRegister (uint32_t reg)
 Check whether a register is a system register. More...
 
std::vector< uint32_t > GetModifiedRegistersOnWrite (uint32_t reg)
 Returns a list of register indices that are modified when reg is written to. More...
 
uint32_t GetRegisterByName (const std::string &name)
 Get a register index by its name. More...
 
virtual std::string GetRegisterStackName (uint32_t regStack)
 Get a register stack name from a register stack number. More...
 
virtual std::vector< uint32_t > GetAllRegisterStacks ()
 
virtual BNRegisterStackInfo GetRegisterStackInfo (uint32_t regStack)
 
uint32_t GetRegisterStackForRegister (uint32_t reg)
 
virtual std::string GetIntrinsicName (uint32_t intrinsic)
 Gets an intrinsic name from an intrinsic number. More...
 
virtual std::vector< uint32_t > GetAllIntrinsics ()
 
virtual std::vector< NameAndTypeGetIntrinsicInputs (uint32_t intrinsic)
 
virtual std::vector< Confidence< Ref< Type > > > GetIntrinsicOutputs (uint32_t intrinsic)
 
virtual bool CanAssemble ()
 Check whether this architecture can assemble instructions. More...
 
virtual bool Assemble (const std::string &code, uint64_t addr, DataBuffer &result, std::string &errors)
 Converts the string of assembly instructions code loaded at virtual address addr to the byte representation of those instructions. More...
 
virtual bool IsNeverBranchPatchAvailable (const uint8_t *data, uint64_t addr, size_t len)
 Returns true if the instruction at addr can be patched to never branch. More...
 
virtual bool IsAlwaysBranchPatchAvailable (const uint8_t *data, uint64_t addr, size_t len)
 Returns true if the instruction at addr can be patched to always branch. More...
 
virtual bool IsInvertBranchPatchAvailable (const uint8_t *data, uint64_t addr, size_t len)
 Returns true if the instruction at addr can be patched to invert the branch. More...
 
virtual bool IsSkipAndReturnZeroPatchAvailable (const uint8_t *data, uint64_t addr, size_t len)
 Checks if the instruction at addr is a call that can be patched to return zero. More...
 
virtual bool IsSkipAndReturnValuePatchAvailable (const uint8_t *data, uint64_t addr, size_t len)
 Checks if the instruction at addr is a call that can be patched to return a value. More...
 
virtual bool ConvertToNop (uint8_t *data, uint64_t addr, size_t len)
 Converts the instruction at addr to a no-operation instruction. More...
 
virtual bool AlwaysBranch (uint8_t *data, uint64_t addr, size_t len)
 Converts the conditional branch instruction at addr to an unconditional branch. More...
 
virtual bool InvertBranch (uint8_t *data, uint64_t addr, size_t len)
 InvertBranch converts the conditional branch instruction at addr to its invert. More...
 
virtual bool SkipAndReturnValue (uint8_t *data, uint64_t addr, size_t len, uint64_t value)
 SkipAndReturnValue converts the call instruction at addr to an instruction that simulates that call returning a value. More...
 
void RegisterFunctionRecognizer (FunctionRecognizer *recog)
 
void RegisterRelocationHandler (const std::string &viewName, RelocationHandler *handler)
 
Ref< RelocationHandlerGetRelocationHandler (const std::string &viewName)
 
bool IsBinaryViewTypeConstantDefined (const std::string &type, const std::string &name)
 
uint64_t GetBinaryViewTypeConstant (const std::string &type, const std::string &name, uint64_t defaultValue=0)
 
void SetBinaryViewTypeConstant (const std::string &type, const std::string &name, uint64_t value)
 
void RegisterCallingConvention (CallingConvention *cc)
 Register a calling convention with this architecture. More...
 
std::vector< Ref< CallingConvention > > GetCallingConventions ()
 List of registered calling conventions. More...
 
Ref< CallingConventionGetCallingConventionByName (const std::string &name)
 Get a calling convention by name. More...
 
void SetDefaultCallingConvention (CallingConvention *cc)
 Set the default calling convention. More...
 
void SetCdeclCallingConvention (CallingConvention *cc)
 Set the cdecl calling convention. More...
 
void SetStdcallCallingConvention (CallingConvention *cc)
 Set the stdcall calling convention. More...
 
void SetFastcallCallingConvention (CallingConvention *cc)
 Set the fastcall calling convention. More...
 
Ref< CallingConventionGetDefaultCallingConvention ()
 Get the default calling convention. More...
 
Ref< CallingConventionGetCdeclCallingConvention ()
 Get the cdecl calling convention. More...
 
Ref< CallingConventionGetStdcallCallingConvention ()
 Get the stdcall calling convention. More...
 
Ref< CallingConventionGetFastcallCallingConvention ()
 Get the fastcall calling convention. More...
 
Ref< PlatformGetStandalonePlatform ()
 Get the Architecture standalone platform. More...
 
std::vector< Ref< TypeLibrary > > GetTypeLibraries ()
 
void AddArchitectureRedirection (Architecture *from, Architecture *to)
 
- Public Member Functions inherited from BinaryNinja::StaticCoreRefCountObject< BNArchitecture >
 StaticCoreRefCountObject ()
 
virtual ~StaticCoreRefCountObject ()
 
BNArchitectureGetObject () const
 
void AddRef ()
 
void Release ()
 
void AddRefForRegistration ()
 
void AddRefForCallback ()
 
void ReleaseForCallback ()
 

Additional Inherited Members

- Static Public Member Functions inherited from BinaryNinja::Architecture
static void Register (Architecture *arch)
 Register an architecture. More...
 
static Ref< ArchitectureGetByName (const std::string &name)
 Get an Architecture by name. More...
 
static std::vector< Ref< Architecture > > GetList ()
 Get the list of registered Architectures. More...
 
- Static Public Member Functions inherited from BinaryNinja::StaticCoreRefCountObject< BNArchitecture >
static BNArchitectureGetObject (StaticCoreRefCountObject *obj)
 
- Public Attributes inherited from BinaryNinja::StaticCoreRefCountObject< BNArchitecture >
std::atomic< int > m_refs
 
BNArchitecturem_object
 
- Protected Member Functions inherited from BinaryNinja::Architecture
 Architecture (BNArchitecture *arch)
 
virtual void Register (BNCustomArchitecture *callbacks)
 
- Static Protected Member Functions inherited from BinaryNinja::Architecture
static void InitCallback (void *ctxt, BNArchitecture *obj)
 
static BNEndianness GetEndiannessCallback (void *ctxt)
 
static size_t GetAddressSizeCallback (void *ctxt)
 
static size_t GetDefaultIntegerSizeCallback (void *ctxt)
 
static size_t GetInstructionAlignmentCallback (void *ctxt)
 
static size_t GetMaxInstructionLengthCallback (void *ctxt)
 
static size_t GetOpcodeDisplayLengthCallback (void *ctxt)
 
static BNArchitectureGetAssociatedArchitectureByAddressCallback (void *ctxt, uint64_t *addr)
 
static bool GetInstructionInfoCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t maxLen, BNInstructionInfo *result)
 
static bool GetInstructionTextCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t *len, BNInstructionTextToken **result, size_t *count)
 
static void FreeInstructionTextCallback (BNInstructionTextToken *tokens, size_t count)
 
static bool GetInstructionLowLevelILCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t *len, BNLowLevelILFunction *il)
 
static char * GetRegisterNameCallback (void *ctxt, uint32_t reg)
 
static char * GetFlagNameCallback (void *ctxt, uint32_t flag)
 
static char * GetFlagWriteTypeNameCallback (void *ctxt, uint32_t flags)
 
static char * GetSemanticFlagClassNameCallback (void *ctxt, uint32_t semClass)
 
static char * GetSemanticFlagGroupNameCallback (void *ctxt, uint32_t semGroup)
 
static uint32_t * GetFullWidthRegistersCallback (void *ctxt, size_t *count)
 
static uint32_t * GetAllRegistersCallback (void *ctxt, size_t *count)
 
static uint32_t * GetAllFlagsCallback (void *ctxt, size_t *count)
 
static uint32_t * GetAllFlagWriteTypesCallback (void *ctxt, size_t *count)
 
static uint32_t * GetAllSemanticFlagClassesCallback (void *ctxt, size_t *count)
 
static uint32_t * GetAllSemanticFlagGroupsCallback (void *ctxt, size_t *count)
 
static BNFlagRole GetFlagRoleCallback (void *ctxt, uint32_t flag, uint32_t semClass)
 
static uint32_t * GetFlagsRequiredForFlagConditionCallback (void *ctxt, BNLowLevelILFlagCondition cond, uint32_t semClass, size_t *count)
 
static uint32_t * GetFlagsRequiredForSemanticFlagGroupCallback (void *ctxt, uint32_t semGroup, size_t *count)
 
static BNFlagConditionForSemanticClassGetFlagConditionsForSemanticFlagGroupCallback (void *ctxt, uint32_t semGroup, size_t *count)
 
static void FreeFlagConditionsForSemanticFlagGroupCallback (void *ctxt, BNFlagConditionForSemanticClass *conditions)
 
static uint32_t * GetFlagsWrittenByFlagWriteTypeCallback (void *ctxt, uint32_t writeType, size_t *count)
 
static uint32_t GetSemanticClassForFlagWriteTypeCallback (void *ctxt, uint32_t writeType)
 
static size_t GetFlagWriteLowLevelILCallback (void *ctxt, BNLowLevelILOperation op, size_t size, uint32_t flagWriteType, uint32_t flag, BNRegisterOrConstant *operands, size_t operandCount, BNLowLevelILFunction *il)
 
static size_t GetFlagConditionLowLevelILCallback (void *ctxt, BNLowLevelILFlagCondition cond, uint32_t semClass, BNLowLevelILFunction *il)
 
static size_t GetSemanticFlagGroupLowLevelILCallback (void *ctxt, uint32_t semGroup, BNLowLevelILFunction *il)
 
static void FreeRegisterListCallback (void *ctxt, uint32_t *regs)
 
static void GetRegisterInfoCallback (void *ctxt, uint32_t reg, BNRegisterInfo *result)
 
static uint32_t GetStackPointerRegisterCallback (void *ctxt)
 
static uint32_t GetLinkRegisterCallback (void *ctxt)
 
static uint32_t * GetGlobalRegistersCallback (void *ctxt, size_t *count)
 
static uint32_t * GetSystemRegistersCallback (void *ctxt, size_t *count)
 
static char * GetRegisterStackNameCallback (void *ctxt, uint32_t regStack)
 
static uint32_t * GetAllRegisterStacksCallback (void *ctxt, size_t *count)
 
static void GetRegisterStackInfoCallback (void *ctxt, uint32_t regStack, BNRegisterStackInfo *result)
 
static char * GetIntrinsicNameCallback (void *ctxt, uint32_t intrinsic)
 
static uint32_t * GetAllIntrinsicsCallback (void *ctxt, size_t *count)
 
static BNNameAndTypeGetIntrinsicInputsCallback (void *ctxt, uint32_t intrinsic, size_t *count)
 
static void FreeNameAndTypeListCallback (void *ctxt, BNNameAndType *nt, size_t count)
 
static BNTypeWithConfidenceGetIntrinsicOutputsCallback (void *ctxt, uint32_t intrinsic, size_t *count)
 
static void FreeTypeListCallback (void *ctxt, BNTypeWithConfidence *types, size_t count)
 
static bool CanAssembleCallback (void *ctxt)
 
static bool AssembleCallback (void *ctxt, const char *code, uint64_t addr, BNDataBuffer *result, char **errors)
 
static bool IsNeverBranchPatchAvailableCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t len)
 
static bool IsAlwaysBranchPatchAvailableCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t len)
 
static bool IsInvertBranchPatchAvailableCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t len)
 
static bool IsSkipAndReturnZeroPatchAvailableCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t len)
 
static bool IsSkipAndReturnValuePatchAvailableCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t len)
 
static bool ConvertToNopCallback (void *ctxt, uint8_t *data, uint64_t addr, size_t len)
 
static bool AlwaysBranchCallback (void *ctxt, uint8_t *data, uint64_t addr, size_t len)
 
static bool InvertBranchCallback (void *ctxt, uint8_t *data, uint64_t addr, size_t len)
 
static bool SkipAndReturnValueCallback (void *ctxt, uint8_t *data, uint64_t addr, size_t len, uint64_t value)
 
- Protected Attributes inherited from BinaryNinja::Architecture
std::string m_nameForRegister
 

Constructor & Destructor Documentation

◆ CoreArchitecture()

CoreArchitecture::CoreArchitecture ( BNArchitecture arch)

Member Function Documentation

◆ GetEndianness()

BNEndianness CoreArchitecture::GetEndianness ( ) const
overridevirtual

Get the default endianness for this architecture.

Returns
The default endianness for this architecture

Implements BinaryNinja::Architecture.

◆ GetAddressSize()

size_t CoreArchitecture::GetAddressSize ( ) const
overridevirtual

Get the address size for this architecture.

Returns
The address size for this architecture

Implements BinaryNinja::Architecture.

◆ GetDefaultIntegerSize()

size_t CoreArchitecture::GetDefaultIntegerSize ( ) const
overridevirtual

Get the default integer size for this architecture.

Returns
The default integer size for this architecture

Reimplemented from BinaryNinja::Architecture.

◆ GetInstructionAlignment()

size_t CoreArchitecture::GetInstructionAlignment ( ) const
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetMaxInstructionLength()

size_t CoreArchitecture::GetMaxInstructionLength ( ) const
overridevirtual

Get the maximum instruction length.

Returns
The maximum instruction length

Reimplemented from BinaryNinja::Architecture.

◆ GetOpcodeDisplayLength()

size_t CoreArchitecture::GetOpcodeDisplayLength ( ) const
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetAssociatedArchitectureByAddress()

Ref< Architecture > CoreArchitecture::GetAssociatedArchitectureByAddress ( uint64_t &  addr)
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetInstructionInfo()

bool CoreArchitecture::GetInstructionInfo ( const uint8_t *  data,
uint64_t  addr,
size_t  maxLen,
InstructionInfo result 
)
overridevirtual

Retrieves an InstructionInfo struct for the instruction at the given virtual address.

Note
Architecture subclasses should implement this method.
The instruction info object should always set the InstructionInfo.length to the instruction length, \ and the branches of the proper types should be added if the instruction is a branch.

If the instruction is a branch instruction architecture plugins should add a branch of the proper type:

===================== =================================================== BNBranchType Description ===================== =================================================== UnconditionalBranch Branch will always be taken FalseBranch False branch condition TrueBranch True branch condition CallDestination Branch is a call instruction (Branch with Link) FunctionReturn Branch returns from a function SystemCall System call instruction IndirectBranch Branch destination is a memory address or register UnresolvedBranch Branch destination is an unknown address ===================== ===================================================

Parameters
[in]datapointer to the instruction data to retrieve info for
[in]addraddress of the instruction data to retrieve info for
[in]maxLenMaximum length of the instruction data to read
[out]resultRetrieved instruction info
Returns
Whether instruction info was successfully retrieved.

Implements BinaryNinja::Architecture.

◆ GetInstructionText()

bool CoreArchitecture::GetInstructionText ( const uint8_t *  data,
uint64_t  addr,
size_t &  len,
std::vector< InstructionTextToken > &  result 
)
overridevirtual

Retrieves a list of InstructionTextTokens.

Parameters
[in]datapointer to the instruction data to retrieve text for
[in]addraddress of the instruction data to retrieve text for
[out]lenwill be written to with the length of the instruction data which was translated
[out]result
Returns
Whether instruction info was successfully retrieved.

Implements BinaryNinja::Architecture.

◆ GetInstructionLowLevelIL()

bool CoreArchitecture::GetInstructionLowLevelIL ( const uint8_t *  data,
uint64_t  addr,
size_t &  len,
LowLevelILFunction il 
)
overridevirtual

Translates an instruction at addr and appends it onto the LowLevelILFunction& il.

Note
Architecture subclasses should implement this method.
Parameters
[in]datapointer to the instruction data to be translated
[in]addraddress of the instruction data to be translated
[out]lenwill be written to with the length of the instruction data which was translated
[in,out]ilthe LowLevelILFunction to appended to.

Reimplemented from BinaryNinja::Architecture.

◆ GetRegisterName()

string CoreArchitecture::GetRegisterName ( uint32_t  reg)
overridevirtual

Gets a register name from a register index.

Parameters
regRegister index
Returns
The register name

Reimplemented from BinaryNinja::Architecture.

◆ GetFlagName()

string CoreArchitecture::GetFlagName ( uint32_t  flag)
overridevirtual

Gets a flag name from a flag index.

Parameters
flagFlag index
Returns
Flag name

Reimplemented from BinaryNinja::Architecture.

◆ GetFlagWriteTypeName()

string CoreArchitecture::GetFlagWriteTypeName ( uint32_t  flags)
overridevirtual

Gets the flag write type name for the given flag.

Parameters
flagsflag
Returns
Flag name

Reimplemented from BinaryNinja::Architecture.

◆ GetSemanticFlagClassName()

string CoreArchitecture::GetSemanticFlagClassName ( uint32_t  semClass)
overridevirtual

Gets the name of a semantic flag class from the index.

Parameters
semClassSemantic class index
Returns
The name of the semantic flag class

Reimplemented from BinaryNinja::Architecture.

◆ GetSemanticFlagGroupName()

string CoreArchitecture::GetSemanticFlagGroupName ( uint32_t  semGroup)
overridevirtual

Gets the name of a semantic flag group from the index.

Parameters
semGroupSemantic flag group index
Returns
Semantic flag group name

Reimplemented from BinaryNinja::Architecture.

◆ GetFullWidthRegisters()

vector< uint32_t > CoreArchitecture::GetFullWidthRegisters ( )
overridevirtual

Get the list of full width register indices.

Returns
The list of full width register indices

Reimplemented from BinaryNinja::Architecture.

◆ GetAllRegisters()

vector< uint32_t > CoreArchitecture::GetAllRegisters ( )
overridevirtual

Get the list of all register indices.

Returns
The list of all register indices

Reimplemented from BinaryNinja::Architecture.

◆ GetAllFlags()

vector< uint32_t > CoreArchitecture::GetAllFlags ( )
overridevirtual

Get the list of all flag indices.

Returns
The list of all flag indices

Reimplemented from BinaryNinja::Architecture.

◆ GetAllFlagWriteTypes()

vector< uint32_t > CoreArchitecture::GetAllFlagWriteTypes ( )
overridevirtual

Get the list of all flag write type indices.

Returns
The list of all flag write type indices

Reimplemented from BinaryNinja::Architecture.

◆ GetAllSemanticFlagClasses()

vector< uint32_t > CoreArchitecture::GetAllSemanticFlagClasses ( )
overridevirtual

Get the list of all semantic flag class indices.

Returns
The list of all semantic flag class indices

Reimplemented from BinaryNinja::Architecture.

◆ GetAllSemanticFlagGroups()

vector< uint32_t > CoreArchitecture::GetAllSemanticFlagGroups ( )
overridevirtual

Get the list of all semantic flag group indices.

Returns
The list of all semantic flag group indices

Reimplemented from BinaryNinja::Architecture.

◆ GetFlagRole()

BNFlagRole CoreArchitecture::GetFlagRole ( uint32_t  flag,
uint32_t  semClass = 0 
)
overridevirtual

Get the role of a given flag.

Parameters
flagFlag index
semClassOptional semantic flag class
Returns
Flag role

Reimplemented from BinaryNinja::Architecture.

◆ GetFlagsRequiredForFlagCondition()

vector< uint32_t > CoreArchitecture::GetFlagsRequiredForFlagCondition ( BNLowLevelILFlagCondition  cond,
uint32_t  semClass = 0 
)
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetFlagsRequiredForSemanticFlagGroup()

vector< uint32_t > CoreArchitecture::GetFlagsRequiredForSemanticFlagGroup ( uint32_t  semGroup)
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetFlagConditionsForSemanticFlagGroup()

map< uint32_t, BNLowLevelILFlagCondition > CoreArchitecture::GetFlagConditionsForSemanticFlagGroup ( uint32_t  semGroup)
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetFlagsWrittenByFlagWriteType()

vector< uint32_t > CoreArchitecture::GetFlagsWrittenByFlagWriteType ( uint32_t  writeType)
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetSemanticClassForFlagWriteType()

uint32_t CoreArchitecture::GetSemanticClassForFlagWriteType ( uint32_t  writeType)
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetFlagWriteLowLevelIL()

size_t CoreArchitecture::GetFlagWriteLowLevelIL ( BNLowLevelILOperation  op,
size_t  size,
uint32_t  flagWriteType,
uint32_t  flag,
BNRegisterOrConstant operands,
size_t  operandCount,
LowLevelILFunction il 
)
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetFlagConditionLowLevelIL()

ExprId CoreArchitecture::GetFlagConditionLowLevelIL ( BNLowLevelILFlagCondition  cond,
uint32_t  semClass,
LowLevelILFunction il 
)
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetSemanticFlagGroupLowLevelIL()

ExprId CoreArchitecture::GetSemanticFlagGroupLowLevelIL ( uint32_t  semGroup,
LowLevelILFunction il 
)
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetRegisterInfo()

BNRegisterInfo CoreArchitecture::GetRegisterInfo ( uint32_t  reg)
overridevirtual

Get the register info for a given register index.

Parameters
regRegister index
Returns
Register info

Reimplemented from BinaryNinja::Architecture.

◆ GetStackPointerRegister()

uint32_t CoreArchitecture::GetStackPointerRegister ( )
overridevirtual

Get the register index corresponding to the stack pointer (SP)

Returns
The register index corresponding to the stack pointer

Reimplemented from BinaryNinja::Architecture.

◆ GetLinkRegister()

uint32_t CoreArchitecture::GetLinkRegister ( )
overridevirtual

Get the register index corresponding to the link register (LR)

Returns
The register index corresponding to the link register

Reimplemented from BinaryNinja::Architecture.

◆ GetGlobalRegisters()

vector< uint32_t > CoreArchitecture::GetGlobalRegisters ( )
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetSystemRegisters()

vector< uint32_t > CoreArchitecture::GetSystemRegisters ( )
overridevirtual

Get the list of system register indices.

Returns
The list of system register indices

Reimplemented from BinaryNinja::Architecture.

◆ GetRegisterStackName()

string CoreArchitecture::GetRegisterStackName ( uint32_t  regStack)
overridevirtual

Get a register stack name from a register stack number.

Parameters
regStackRegister stack number
Returns
The corresponding register string

Reimplemented from BinaryNinja::Architecture.

◆ GetAllRegisterStacks()

vector< uint32_t > CoreArchitecture::GetAllRegisterStacks ( )
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetRegisterStackInfo()

BNRegisterStackInfo CoreArchitecture::GetRegisterStackInfo ( uint32_t  regStack)
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetIntrinsicName()

string CoreArchitecture::GetIntrinsicName ( uint32_t  intrinsic)
overridevirtual

Gets an intrinsic name from an intrinsic number.

Parameters
intrinsicIntrinsic number
Returns
The corresponding intrinsic string

Reimplemented from BinaryNinja::Architecture.

◆ GetAllIntrinsics()

vector< uint32_t > CoreArchitecture::GetAllIntrinsics ( )
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetIntrinsicInputs()

vector< NameAndType > CoreArchitecture::GetIntrinsicInputs ( uint32_t  intrinsic)
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetIntrinsicOutputs()

vector< Confidence< Ref< Type > > > CoreArchitecture::GetIntrinsicOutputs ( uint32_t  intrinsic)
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ CanAssemble()

bool CoreArchitecture::CanAssemble ( )
overridevirtual

Check whether this architecture can assemble instructions.

Returns
Whether this architecture can assemble instructions

Reimplemented from BinaryNinja::Architecture.

◆ Assemble()

bool CoreArchitecture::Assemble ( const std::string &  code,
uint64_t  addr,
DataBuffer result,
std::string &  errors 
)
overridevirtual

Converts the string of assembly instructions code loaded at virtual address addr to the byte representation of those instructions.

Parameters
[in]codeString representation of the instructions to be assembled
[in]addrAddress of the instructions
[out]resultDataBuffer containing the compiled bytes
[out]errorsAny errors that occurred during assembly
Returns
Whether assembly was successful

Reimplemented from BinaryNinja::Architecture.

◆ IsNeverBranchPatchAvailable()

bool CoreArchitecture::IsNeverBranchPatchAvailable ( const uint8_t *  data,
uint64_t  addr,
size_t  len 
)
overridevirtual

Returns true if the instruction at addr can be patched to never branch.

Note
This is used in the UI to determine if "never branch" should be displayed in the right-click context menu when right-clicking on an instruction.
Parameters
dataBuffer of bytes to check
addrthe virtual address of the bytes, to be used when assembling
lenamount of bytes to be checked
Returns
If the never branch patch is available

Reimplemented from BinaryNinja::Architecture.

◆ IsAlwaysBranchPatchAvailable()

bool CoreArchitecture::IsAlwaysBranchPatchAvailable ( const uint8_t *  data,
uint64_t  addr,
size_t  len 
)
overridevirtual

Returns true if the instruction at addr can be patched to always branch.

Note
This is used in the UI to determine if "always branch" should be displayed in the right-click context menu when right-clicking on an instruction.
Parameters
dataBuffer of bytes to check
addrthe address of the instruction in question
lenamount of bytes to be checked
Returns
If the always branch patch is available

Reimplemented from BinaryNinja::Architecture.

◆ IsInvertBranchPatchAvailable()

bool CoreArchitecture::IsInvertBranchPatchAvailable ( const uint8_t *  data,
uint64_t  addr,
size_t  len 
)
overridevirtual

Returns true if the instruction at addr can be patched to invert the branch.

Note
This is used in the UI to determine if "invert branch" should be displayed in the right-click context menu when right-clicking on an instruction.
Parameters
dataBuffer of bytes to check
addrthe address of the instruction in question
lenamount of bytes to be checked
Returns
If the invert branch patch is available

Reimplemented from BinaryNinja::Architecture.

◆ IsSkipAndReturnZeroPatchAvailable()

bool CoreArchitecture::IsSkipAndReturnZeroPatchAvailable ( const uint8_t *  data,
uint64_t  addr,
size_t  len 
)
overridevirtual

Checks if the instruction at addr is a call that can be patched to return zero.

Note
This is used in the UI to determine if "skip and return zero" should be displayed in the right-click context menu when right-clicking on an instruction.
Parameters
dataBuffer of bytes to check
addrthe address of the instruction in question
lenamount of bytes to be checked
Returns
If the skip and return zero patch is available

Reimplemented from BinaryNinja::Architecture.

◆ IsSkipAndReturnValuePatchAvailable()

bool CoreArchitecture::IsSkipAndReturnValuePatchAvailable ( const uint8_t *  data,
uint64_t  addr,
size_t  len 
)
overridevirtual

Checks if the instruction at addr is a call that can be patched to return a value.

Note
This is used in the UI to determine if "skip and return value" should be displayed in the right-click context menu when right-clicking on an instruction.
Parameters
dataBuffer of bytes to check
addrthe address of the instruction in question
lenamount of bytes to be checked
Returns
If the skip and return value patch is available

Reimplemented from BinaryNinja::Architecture.

◆ ConvertToNop()

bool CoreArchitecture::ConvertToNop ( uint8_t *  data,
uint64_t  addr,
size_t  len 
)
overridevirtual

Converts the instruction at addr to a no-operation instruction.

Parameters
[in,out]dataBuffer of bytes to convert
[in]addrthe address of the instruction to be converted
[in]lenLength of the bytes to be converted
Returns
Whether the conversion was successful

Reimplemented from BinaryNinja::Architecture.

◆ AlwaysBranch()

bool CoreArchitecture::AlwaysBranch ( uint8_t *  data,
uint64_t  addr,
size_t  len 
)
overridevirtual

Converts the conditional branch instruction at addr to an unconditional branch.

Note
This is called when the right-click context menu item "always branch" is selected in the UI.
Parameters
[in,out]dataBuffer of bytes to convert
[in]addrthe address of the instruction to be converted
[in]lenLength of the bytes to be converted
Returns
Whether the conversion was successful

Reimplemented from BinaryNinja::Architecture.

◆ InvertBranch()

bool CoreArchitecture::InvertBranch ( uint8_t *  data,
uint64_t  addr,
size_t  len 
)
overridevirtual

InvertBranch converts the conditional branch instruction at addr to its invert.

Note
This is called when the right-click context menu item "invert branch" is selected in the UI.
Parameters
[in,out]dataBuffer of bytes to convert
[in]addrthe address of the instruction to be converted
[in]lenLength of the bytes to be converted
Returns
Whether the conversion was successful

Reimplemented from BinaryNinja::Architecture.

◆ SkipAndReturnValue()

bool CoreArchitecture::SkipAndReturnValue ( uint8_t *  data,
uint64_t  addr,
size_t  len,
uint64_t  value 
)
overridevirtual

SkipAndReturnValue converts the call instruction at addr to an instruction that simulates that call returning a value.

Note
This is called when the right-click context menu item "skip and return value" is selected in the UI.
Parameters
[in,out]dataBuffer of bytes to convert
[in]addrthe address of the instruction to be converted
[in]lenLength of the bytes to be converted
[in]valueValue to be returned
Returns
Whether the conversion was successful

Reimplemented from BinaryNinja::Architecture.

◆ BinaryNinja::ArchitectureExtension

class BinaryNinja::ArchitectureExtension

Public Member Functions

 ArchitectureExtension (const std::string &name, Architecture *base)
 
Ref< ArchitectureGetBaseArchitecture () const
 
virtual BNEndianness GetEndianness () const override
 Get the default endianness for this architecture. More...
 
virtual size_t GetAddressSize () const override
 Get the address size for this architecture. More...
 
virtual size_t GetDefaultIntegerSize () const override
 Get the default integer size for this architecture. More...
 
virtual size_t GetInstructionAlignment () const override
 
virtual size_t GetMaxInstructionLength () const override
 Get the maximum instruction length. More...
 
virtual size_t GetOpcodeDisplayLength () const override
 
virtual Ref< ArchitectureGetAssociatedArchitectureByAddress (uint64_t &addr) override
 
virtual bool GetInstructionInfo (const uint8_t *data, uint64_t addr, size_t maxLen, InstructionInfo &result) override
 Retrieves an InstructionInfo struct for the instruction at the given virtual address. More...
 
virtual bool GetInstructionText (const uint8_t *data, uint64_t addr, size_t &len, std::vector< InstructionTextToken > &result) override
 Retrieves a list of InstructionTextTokens. More...
 
virtual bool GetInstructionLowLevelIL (const uint8_t *data, uint64_t addr, size_t &len, LowLevelILFunction &il) override
 Translates an instruction at addr and appends it onto the LowLevelILFunction& il. More...
 
virtual std::string GetRegisterName (uint32_t reg) override
 Gets a register name from a register index. More...
 
virtual std::string GetFlagName (uint32_t flag) override
 Gets a flag name from a flag index. More...
 
virtual std::string GetFlagWriteTypeName (uint32_t flags) override
 Gets the flag write type name for the given flag. More...
 
virtual std::string GetSemanticFlagClassName (uint32_t semClass) override
 Gets the name of a semantic flag class from the index. More...
 
virtual std::string GetSemanticFlagGroupName (uint32_t semGroup) override
 Gets the name of a semantic flag group from the index. More...
 
virtual std::vector< uint32_t > GetFullWidthRegisters () override
 Get the list of full width register indices. More...
 
virtual std::vector< uint32_t > GetAllRegisters () override
 Get the list of all register indices. More...
 
virtual std::vector< uint32_t > GetAllFlags () override
 Get the list of all flag indices. More...
 
virtual std::vector< uint32_t > GetAllFlagWriteTypes () override
 Get the list of all flag write type indices. More...
 
virtual std::vector< uint32_t > GetAllSemanticFlagClasses () override
 Get the list of all semantic flag class indices. More...
 
virtual std::vector< uint32_t > GetAllSemanticFlagGroups () override
 Get the list of all semantic flag group indices. More...
 
virtual BNFlagRole GetFlagRole (uint32_t flag, uint32_t semClass=0) override
 Get the role of a given flag. More...
 
virtual std::vector< uint32_t > GetFlagsRequiredForFlagCondition (BNLowLevelILFlagCondition cond, uint32_t semClass=0) override
 
virtual std::vector< uint32_t > GetFlagsRequiredForSemanticFlagGroup (uint32_t semGroup) override
 
virtual std::map< uint32_t, BNLowLevelILFlagConditionGetFlagConditionsForSemanticFlagGroup (uint32_t semGroup) override
 
virtual std::vector< uint32_t > GetFlagsWrittenByFlagWriteType (uint32_t writeType) override
 
virtual uint32_t GetSemanticClassForFlagWriteType (uint32_t writeType) override
 
virtual ExprId GetFlagWriteLowLevelIL (BNLowLevelILOperation op, size_t size, uint32_t flagWriteType, uint32_t flag, BNRegisterOrConstant *operands, size_t operandCount, LowLevelILFunction &il) override
 
virtual ExprId GetFlagConditionLowLevelIL (BNLowLevelILFlagCondition cond, uint32_t semClass, LowLevelILFunction &il) override
 
virtual ExprId GetSemanticFlagGroupLowLevelIL (uint32_t semGroup, LowLevelILFunction &il) override
 
virtual BNRegisterInfo GetRegisterInfo (uint32_t reg) override
 Get the register info for a given register index. More...
 
virtual uint32_t GetStackPointerRegister () override
 Get the register index corresponding to the stack pointer (SP) More...
 
virtual uint32_t GetLinkRegister () override
 Get the register index corresponding to the link register (LR) More...
 
virtual std::vector< uint32_t > GetGlobalRegisters () override
 
virtual std::vector< uint32_t > GetSystemRegisters () override
 Get the list of system register indices. More...
 
virtual std::string GetRegisterStackName (uint32_t regStack) override
 Get a register stack name from a register stack number. More...
 
virtual std::vector< uint32_t > GetAllRegisterStacks () override
 
virtual BNRegisterStackInfo GetRegisterStackInfo (uint32_t regStack) override
 
virtual std::string GetIntrinsicName (uint32_t intrinsic) override
 Gets an intrinsic name from an intrinsic number. More...
 
virtual std::vector< uint32_t > GetAllIntrinsics () override
 
virtual std::vector< NameAndTypeGetIntrinsicInputs (uint32_t intrinsic) override
 
virtual std::vector< Confidence< Ref< Type > > > GetIntrinsicOutputs (uint32_t intrinsic) override
 
virtual bool CanAssemble () override
 Check whether this architecture can assemble instructions. More...
 
virtual bool Assemble (const std::string &code, uint64_t addr, DataBuffer &result, std::string &errors) override
 Converts the string of assembly instructions code loaded at virtual address addr to the byte representation of those instructions. More...
 
virtual bool IsNeverBranchPatchAvailable (const uint8_t *data, uint64_t addr, size_t len) override
 Returns true if the instruction at addr can be patched to never branch. More...
 
virtual bool IsAlwaysBranchPatchAvailable (const uint8_t *data, uint64_t addr, size_t len) override
 Returns true if the instruction at addr can be patched to always branch. More...
 
virtual bool IsInvertBranchPatchAvailable (const uint8_t *data, uint64_t addr, size_t len) override
 Returns true if the instruction at addr can be patched to invert the branch. More...
 
virtual bool IsSkipAndReturnZeroPatchAvailable (const uint8_t *data, uint64_t addr, size_t len) override
 Checks if the instruction at addr is a call that can be patched to return zero. More...
 
virtual bool IsSkipAndReturnValuePatchAvailable (const uint8_t *data, uint64_t addr, size_t len) override
 Checks if the instruction at addr is a call that can be patched to return a value. More...
 
virtual bool ConvertToNop (uint8_t *data, uint64_t addr, size_t len) override
 Converts the instruction at addr to a no-operation instruction. More...
 
virtual bool AlwaysBranch (uint8_t *data, uint64_t addr, size_t len) override
 Converts the conditional branch instruction at addr to an unconditional branch. More...
 
virtual bool InvertBranch (uint8_t *data, uint64_t addr, size_t len) override
 InvertBranch converts the conditional branch instruction at addr to its invert. More...
 
virtual bool SkipAndReturnValue (uint8_t *data, uint64_t addr, size_t len, uint64_t value) override
 SkipAndReturnValue converts the call instruction at addr to an instruction that simulates that call returning a value. More...
 
- Public Member Functions inherited from BinaryNinja::Architecture
 Architecture (const std::string &name)
 
std::string GetName () const
 Get the name of this architecture. More...
 
virtual BNEndianness GetEndianness () const =0
 Get the default endianness for this architecture. More...
 
virtual size_t GetAddressSize () const =0
 Get the address size for this architecture. More...
 
virtual size_t GetDefaultIntegerSize () const
 Get the default integer size for this architecture. More...
 
virtual size_t GetInstructionAlignment () const
 
virtual size_t GetMaxInstructionLength () const
 Get the maximum instruction length. More...
 
virtual size_t GetOpcodeDisplayLength () const
 
virtual Ref< ArchitectureGetAssociatedArchitectureByAddress (uint64_t &addr)
 
virtual bool GetInstructionInfo (const uint8_t *data, uint64_t addr, size_t maxLen, InstructionInfo &result)=0
 Retrieves an InstructionInfo struct for the instruction at the given virtual address. More...
 
virtual bool GetInstructionText (const uint8_t *data, uint64_t addr, size_t &len, std::vector< InstructionTextToken > &result)=0
 Retrieves a list of InstructionTextTokens. More...
 
virtual bool GetInstructionLowLevelIL (const uint8_t *data, uint64_t addr, size_t &len, LowLevelILFunction &il)
 Translates an instruction at addr and appends it onto the LowLevelILFunction& il. More...
 
virtual std::string GetRegisterName (uint32_t reg)
 Gets a register name from a register index. More...
 
virtual std::string GetFlagName (uint32_t flag)
 Gets a flag name from a flag index. More...
 
virtual std::string GetFlagWriteTypeName (uint32_t flags)
 Gets the flag write type name for the given flag. More...
 
virtual std::string GetSemanticFlagClassName (uint32_t semClass)
 Gets the name of a semantic flag class from the index. More...
 
virtual std::string GetSemanticFlagGroupName (uint32_t semGroup)
 Gets the name of a semantic flag group from the index. More...
 
virtual std::vector< uint32_t > GetFullWidthRegisters ()
 Get the list of full width register indices. More...
 
virtual std::vector< uint32_t > GetAllRegisters ()
 Get the list of all register indices. More...
 
virtual std::vector< uint32_t > GetAllFlags ()
 Get the list of all flag indices. More...
 
virtual std::vector< uint32_t > GetAllFlagWriteTypes ()
 Get the list of all flag write type indices. More...
 
virtual std::vector< uint32_t > GetAllSemanticFlagClasses ()
 Get the list of all semantic flag class indices. More...
 
virtual std::vector< uint32_t > GetAllSemanticFlagGroups ()
 Get the list of all semantic flag group indices. More...
 
virtual BNFlagRole GetFlagRole (uint32_t flag, uint32_t semClass=0)
 Get the role of a given flag. More...
 
virtual std::vector< uint32_t > GetFlagsRequiredForFlagCondition (BNLowLevelILFlagCondition cond, uint32_t semClass=0)
 
virtual std::vector< uint32_t > GetFlagsRequiredForSemanticFlagGroup (uint32_t semGroup)
 
virtual std::map< uint32_t, BNLowLevelILFlagConditionGetFlagConditionsForSemanticFlagGroup (uint32_t semGroup)
 
virtual std::vector< uint32_t > GetFlagsWrittenByFlagWriteType (uint32_t writeType)
 
virtual uint32_t GetSemanticClassForFlagWriteType (uint32_t writeType)
 
virtual ExprId GetFlagWriteLowLevelIL (BNLowLevelILOperation op, size_t size, uint32_t flagWriteType, uint32_t flag, BNRegisterOrConstant *operands, size_t operandCount, LowLevelILFunction &il)
 
ExprId GetDefaultFlagWriteLowLevelIL (BNLowLevelILOperation op, size_t size, BNFlagRole role, BNRegisterOrConstant *operands, size_t operandCount, LowLevelILFunction &il)
 
virtual ExprId GetFlagConditionLowLevelIL (BNLowLevelILFlagCondition cond, uint32_t semClass, LowLevelILFunction &il)
 
ExprId GetDefaultFlagConditionLowLevelIL (BNLowLevelILFlagCondition cond, uint32_t semClass, LowLevelILFunction &il)
 
virtual ExprId GetSemanticFlagGroupLowLevelIL (uint32_t semGroup, LowLevelILFunction &il)
 
virtual BNRegisterInfo GetRegisterInfo (uint32_t reg)
 Get the register info for a given register index. More...
 
virtual uint32_t GetStackPointerRegister ()
 Get the register index corresponding to the stack pointer (SP) More...
 
virtual uint32_t GetLinkRegister ()
 Get the register index corresponding to the link register (LR) More...
 
virtual std::vector< uint32_t > GetGlobalRegisters ()
 
bool IsGlobalRegister (uint32_t reg)
 
virtual std::vector< uint32_t > GetSystemRegisters ()
 Get the list of system register indices. More...
 
bool IsSystemRegister (uint32_t reg)
 Check whether a register is a system register. More...
 
std::vector< uint32_t > GetModifiedRegistersOnWrite (uint32_t reg)
 Returns a list of register indices that are modified when reg is written to. More...
 
uint32_t GetRegisterByName (const std::string &name)
 Get a register index by its name. More...
 
virtual std::string GetRegisterStackName (uint32_t regStack)
 Get a register stack name from a register stack number. More...
 
virtual std::vector< uint32_t > GetAllRegisterStacks ()
 
virtual BNRegisterStackInfo GetRegisterStackInfo (uint32_t regStack)
 
uint32_t GetRegisterStackForRegister (uint32_t reg)
 
virtual std::string GetIntrinsicName (uint32_t intrinsic)
 Gets an intrinsic name from an intrinsic number. More...
 
virtual std::vector< uint32_t > GetAllIntrinsics ()
 
virtual std::vector< NameAndTypeGetIntrinsicInputs (uint32_t intrinsic)
 
virtual std::vector< Confidence< Ref< Type > > > GetIntrinsicOutputs (uint32_t intrinsic)
 
virtual bool CanAssemble ()
 Check whether this architecture can assemble instructions. More...
 
virtual bool Assemble (const std::string &code, uint64_t addr, DataBuffer &result, std::string &errors)
 Converts the string of assembly instructions code loaded at virtual address addr to the byte representation of those instructions. More...
 
virtual bool IsNeverBranchPatchAvailable (const uint8_t *data, uint64_t addr, size_t len)
 Returns true if the instruction at addr can be patched to never branch. More...
 
virtual bool IsAlwaysBranchPatchAvailable (const uint8_t *data, uint64_t addr, size_t len)
 Returns true if the instruction at addr can be patched to always branch. More...
 
virtual bool IsInvertBranchPatchAvailable (const uint8_t *data, uint64_t addr, size_t len)
 Returns true if the instruction at addr can be patched to invert the branch. More...
 
virtual bool IsSkipAndReturnZeroPatchAvailable (const uint8_t *data, uint64_t addr, size_t len)
 Checks if the instruction at addr is a call that can be patched to return zero. More...
 
virtual bool IsSkipAndReturnValuePatchAvailable (const uint8_t *data, uint64_t addr, size_t len)
 Checks if the instruction at addr is a call that can be patched to return a value. More...
 
virtual bool ConvertToNop (uint8_t *data, uint64_t addr, size_t len)
 Converts the instruction at addr to a no-operation instruction. More...
 
virtual bool AlwaysBranch (uint8_t *data, uint64_t addr, size_t len)
 Converts the conditional branch instruction at addr to an unconditional branch. More...
 
virtual bool InvertBranch (uint8_t *data, uint64_t addr, size_t len)
 InvertBranch converts the conditional branch instruction at addr to its invert. More...
 
virtual bool SkipAndReturnValue (uint8_t *data, uint64_t addr, size_t len, uint64_t value)
 SkipAndReturnValue converts the call instruction at addr to an instruction that simulates that call returning a value. More...
 
void RegisterFunctionRecognizer (FunctionRecognizer *recog)
 
void RegisterRelocationHandler (const std::string &viewName, RelocationHandler *handler)
 
Ref< RelocationHandlerGetRelocationHandler (const std::string &viewName)
 
bool IsBinaryViewTypeConstantDefined (const std::string &type, const std::string &name)
 
uint64_t GetBinaryViewTypeConstant (const std::string &type, const std::string &name, uint64_t defaultValue=0)
 
void SetBinaryViewTypeConstant (const std::string &type, const std::string &name, uint64_t value)
 
void RegisterCallingConvention (CallingConvention *cc)
 Register a calling convention with this architecture. More...
 
std::vector< Ref< CallingConvention > > GetCallingConventions ()
 List of registered calling conventions. More...
 
Ref< CallingConventionGetCallingConventionByName (const std::string &name)
 Get a calling convention by name. More...
 
void SetDefaultCallingConvention (CallingConvention *cc)
 Set the default calling convention. More...
 
void SetCdeclCallingConvention (CallingConvention *cc)
 Set the cdecl calling convention. More...
 
void SetStdcallCallingConvention (CallingConvention *cc)
 Set the stdcall calling convention. More...
 
void SetFastcallCallingConvention (CallingConvention *cc)
 Set the fastcall calling convention. More...
 
Ref< CallingConventionGetDefaultCallingConvention ()
 Get the default calling convention. More...
 
Ref< CallingConventionGetCdeclCallingConvention ()
 Get the cdecl calling convention. More...
 
Ref< CallingConventionGetStdcallCallingConvention ()
 Get the stdcall calling convention. More...
 
Ref< CallingConventionGetFastcallCallingConvention ()
 Get the fastcall calling convention. More...
 
Ref< PlatformGetStandalonePlatform ()
 Get the Architecture standalone platform. More...
 
std::vector< Ref< TypeLibrary > > GetTypeLibraries ()
 
void AddArchitectureRedirection (Architecture *from, Architecture *to)
 
- Public Member Functions inherited from BinaryNinja::StaticCoreRefCountObject< BNArchitecture >
 StaticCoreRefCountObject ()
 
virtual ~StaticCoreRefCountObject ()
 
BNArchitectureGetObject () const
 
void AddRef ()
 
void Release ()
 
void AddRefForRegistration ()
 
void AddRefForCallback ()
 
void ReleaseForCallback ()
 

Protected Member Functions

virtual void Register (BNCustomArchitecture *callbacks) override
 
- Protected Member Functions inherited from BinaryNinja::Architecture
 Architecture (BNArchitecture *arch)
 
virtual void Register (BNCustomArchitecture *callbacks)
 

Protected Attributes

Ref< Architecturem_base
 
- Protected Attributes inherited from BinaryNinja::Architecture
std::string m_nameForRegister
 

Additional Inherited Members

- Static Public Member Functions inherited from BinaryNinja::Architecture
static void Register (Architecture *arch)
 Register an architecture. More...
 
static Ref< ArchitectureGetByName (const std::string &name)
 Get an Architecture by name. More...
 
static std::vector< Ref< Architecture > > GetList ()
 Get the list of registered Architectures. More...
 
- Static Public Member Functions inherited from BinaryNinja::StaticCoreRefCountObject< BNArchitecture >
static BNArchitectureGetObject (StaticCoreRefCountObject *obj)
 
- Public Attributes inherited from BinaryNinja::StaticCoreRefCountObject< BNArchitecture >
std::atomic< int > m_refs
 
BNArchitecturem_object
 
- Static Protected Member Functions inherited from BinaryNinja::Architecture
static void InitCallback (void *ctxt, BNArchitecture *obj)
 
static BNEndianness GetEndiannessCallback (void *ctxt)
 
static size_t GetAddressSizeCallback (void *ctxt)
 
static size_t GetDefaultIntegerSizeCallback (void *ctxt)
 
static size_t GetInstructionAlignmentCallback (void *ctxt)
 
static size_t GetMaxInstructionLengthCallback (void *ctxt)
 
static size_t GetOpcodeDisplayLengthCallback (void *ctxt)
 
static BNArchitectureGetAssociatedArchitectureByAddressCallback (void *ctxt, uint64_t *addr)
 
static bool GetInstructionInfoCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t maxLen, BNInstructionInfo *result)
 
static bool GetInstructionTextCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t *len, BNInstructionTextToken **result, size_t *count)
 
static void FreeInstructionTextCallback (BNInstructionTextToken *tokens, size_t count)
 
static bool GetInstructionLowLevelILCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t *len, BNLowLevelILFunction *il)
 
static char * GetRegisterNameCallback (void *ctxt, uint32_t reg)
 
static char * GetFlagNameCallback (void *ctxt, uint32_t flag)
 
static char * GetFlagWriteTypeNameCallback (void *ctxt, uint32_t flags)
 
static char * GetSemanticFlagClassNameCallback (void *ctxt, uint32_t semClass)
 
static char * GetSemanticFlagGroupNameCallback (void *ctxt, uint32_t semGroup)
 
static uint32_t * GetFullWidthRegistersCallback (void *ctxt, size_t *count)
 
static uint32_t * GetAllRegistersCallback (void *ctxt, size_t *count)
 
static uint32_t * GetAllFlagsCallback (void *ctxt, size_t *count)
 
static uint32_t * GetAllFlagWriteTypesCallback (void *ctxt, size_t *count)
 
static uint32_t * GetAllSemanticFlagClassesCallback (void *ctxt, size_t *count)
 
static uint32_t * GetAllSemanticFlagGroupsCallback (void *ctxt, size_t *count)
 
static BNFlagRole GetFlagRoleCallback (void *ctxt, uint32_t flag, uint32_t semClass)
 
static uint32_t * GetFlagsRequiredForFlagConditionCallback (void *ctxt, BNLowLevelILFlagCondition cond, uint32_t semClass, size_t *count)
 
static uint32_t * GetFlagsRequiredForSemanticFlagGroupCallback (void *ctxt, uint32_t semGroup, size_t *count)
 
static BNFlagConditionForSemanticClassGetFlagConditionsForSemanticFlagGroupCallback (void *ctxt, uint32_t semGroup, size_t *count)
 
static void FreeFlagConditionsForSemanticFlagGroupCallback (void *ctxt, BNFlagConditionForSemanticClass *conditions)
 
static uint32_t * GetFlagsWrittenByFlagWriteTypeCallback (void *ctxt, uint32_t writeType, size_t *count)
 
static uint32_t GetSemanticClassForFlagWriteTypeCallback (void *ctxt, uint32_t writeType)
 
static size_t GetFlagWriteLowLevelILCallback (void *ctxt, BNLowLevelILOperation op, size_t size, uint32_t flagWriteType, uint32_t flag, BNRegisterOrConstant *operands, size_t operandCount, BNLowLevelILFunction *il)
 
static size_t GetFlagConditionLowLevelILCallback (void *ctxt, BNLowLevelILFlagCondition cond, uint32_t semClass, BNLowLevelILFunction *il)
 
static size_t GetSemanticFlagGroupLowLevelILCallback (void *ctxt, uint32_t semGroup, BNLowLevelILFunction *il)
 
static void FreeRegisterListCallback (void *ctxt, uint32_t *regs)
 
static void GetRegisterInfoCallback (void *ctxt, uint32_t reg, BNRegisterInfo *result)
 
static uint32_t GetStackPointerRegisterCallback (void *ctxt)
 
static uint32_t GetLinkRegisterCallback (void *ctxt)
 
static uint32_t * GetGlobalRegistersCallback (void *ctxt, size_t *count)
 
static uint32_t * GetSystemRegistersCallback (void *ctxt, size_t *count)
 
static char * GetRegisterStackNameCallback (void *ctxt, uint32_t regStack)
 
static uint32_t * GetAllRegisterStacksCallback (void *ctxt, size_t *count)
 
static void GetRegisterStackInfoCallback (void *ctxt, uint32_t regStack, BNRegisterStackInfo *result)
 
static char * GetIntrinsicNameCallback (void *ctxt, uint32_t intrinsic)
 
static uint32_t * GetAllIntrinsicsCallback (void *ctxt, size_t *count)
 
static BNNameAndTypeGetIntrinsicInputsCallback (void *ctxt, uint32_t intrinsic, size_t *count)
 
static void FreeNameAndTypeListCallback (void *ctxt, BNNameAndType *nt, size_t count)
 
static BNTypeWithConfidenceGetIntrinsicOutputsCallback (void *ctxt, uint32_t intrinsic, size_t *count)
 
static void FreeTypeListCallback (void *ctxt, BNTypeWithConfidence *types, size_t count)
 
static bool CanAssembleCallback (void *ctxt)
 
static bool AssembleCallback (void *ctxt, const char *code, uint64_t addr, BNDataBuffer *result, char **errors)
 
static bool IsNeverBranchPatchAvailableCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t len)
 
static bool IsAlwaysBranchPatchAvailableCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t len)
 
static bool IsInvertBranchPatchAvailableCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t len)
 
static bool IsSkipAndReturnZeroPatchAvailableCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t len)
 
static bool IsSkipAndReturnValuePatchAvailableCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t len)
 
static bool ConvertToNopCallback (void *ctxt, uint8_t *data, uint64_t addr, size_t len)
 
static bool AlwaysBranchCallback (void *ctxt, uint8_t *data, uint64_t addr, size_t len)
 
static bool InvertBranchCallback (void *ctxt, uint8_t *data, uint64_t addr, size_t len)
 
static bool SkipAndReturnValueCallback (void *ctxt, uint8_t *data, uint64_t addr, size_t len, uint64_t value)
 

Constructor & Destructor Documentation

◆ ArchitectureExtension()

ArchitectureExtension::ArchitectureExtension ( const std::string &  name,
Architecture base 
)

Member Function Documentation

◆ Register()

void ArchitectureExtension::Register ( BNCustomArchitecture callbacks)
overrideprotectedvirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetBaseArchitecture()

Ref< Architecture > BinaryNinja::ArchitectureExtension::GetBaseArchitecture ( ) const
inline

◆ GetEndianness()

BNEndianness ArchitectureExtension::GetEndianness ( ) const
overridevirtual

Get the default endianness for this architecture.

Returns
The default endianness for this architecture

Implements BinaryNinja::Architecture.

◆ GetAddressSize()

size_t ArchitectureExtension::GetAddressSize ( ) const
overridevirtual

Get the address size for this architecture.

Returns
The address size for this architecture

Implements BinaryNinja::Architecture.

◆ GetDefaultIntegerSize()

size_t ArchitectureExtension::GetDefaultIntegerSize ( ) const
overridevirtual

Get the default integer size for this architecture.

Returns
The default integer size for this architecture

Reimplemented from BinaryNinja::Architecture.

◆ GetInstructionAlignment()

size_t ArchitectureExtension::GetInstructionAlignment ( ) const
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetMaxInstructionLength()

size_t ArchitectureExtension::GetMaxInstructionLength ( ) const
overridevirtual

Get the maximum instruction length.

Returns
The maximum instruction length

Reimplemented from BinaryNinja::Architecture.

◆ GetOpcodeDisplayLength()

size_t ArchitectureExtension::GetOpcodeDisplayLength ( ) const
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetAssociatedArchitectureByAddress()

Ref< Architecture > ArchitectureExtension::GetAssociatedArchitectureByAddress ( uint64_t &  addr)
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetInstructionInfo()

bool ArchitectureExtension::GetInstructionInfo ( const uint8_t *  data,
uint64_t  addr,
size_t  maxLen,
InstructionInfo result 
)
overridevirtual

Retrieves an InstructionInfo struct for the instruction at the given virtual address.

Note
Architecture subclasses should implement this method.
The instruction info object should always set the InstructionInfo.length to the instruction length, \ and the branches of the proper types should be added if the instruction is a branch.

If the instruction is a branch instruction architecture plugins should add a branch of the proper type:

===================== =================================================== BNBranchType Description ===================== =================================================== UnconditionalBranch Branch will always be taken FalseBranch False branch condition TrueBranch True branch condition CallDestination Branch is a call instruction (Branch with Link) FunctionReturn Branch returns from a function SystemCall System call instruction IndirectBranch Branch destination is a memory address or register UnresolvedBranch Branch destination is an unknown address ===================== ===================================================

Parameters
[in]datapointer to the instruction data to retrieve info for
[in]addraddress of the instruction data to retrieve info for
[in]maxLenMaximum length of the instruction data to read
[out]resultRetrieved instruction info
Returns
Whether instruction info was successfully retrieved.

Implements BinaryNinja::Architecture.

◆ GetInstructionText()

bool ArchitectureExtension::GetInstructionText ( const uint8_t *  data,
uint64_t  addr,
size_t &  len,
std::vector< InstructionTextToken > &  result 
)
overridevirtual

Retrieves a list of InstructionTextTokens.

Parameters
[in]datapointer to the instruction data to retrieve text for
[in]addraddress of the instruction data to retrieve text for
[out]lenwill be written to with the length of the instruction data which was translated
[out]result
Returns
Whether instruction info was successfully retrieved.

Implements BinaryNinja::Architecture.

◆ GetInstructionLowLevelIL()

bool ArchitectureExtension::GetInstructionLowLevelIL ( const uint8_t *  data,
uint64_t  addr,
size_t &  len,
LowLevelILFunction il 
)
overridevirtual

Translates an instruction at addr and appends it onto the LowLevelILFunction& il.

Note
Architecture subclasses should implement this method.
Parameters
[in]datapointer to the instruction data to be translated
[in]addraddress of the instruction data to be translated
[out]lenwill be written to with the length of the instruction data which was translated
[in,out]ilthe LowLevelILFunction to appended to.

Reimplemented from BinaryNinja::Architecture.

◆ GetRegisterName()

string ArchitectureExtension::GetRegisterName ( uint32_t  reg)
overridevirtual

Gets a register name from a register index.

Parameters
regRegister index
Returns
The register name

Reimplemented from BinaryNinja::Architecture.

◆ GetFlagName()

string ArchitectureExtension::GetFlagName ( uint32_t  flag)
overridevirtual

Gets a flag name from a flag index.

Parameters
flagFlag index
Returns
Flag name

Reimplemented from BinaryNinja::Architecture.

◆ GetFlagWriteTypeName()

string ArchitectureExtension::GetFlagWriteTypeName ( uint32_t  flags)
overridevirtual

Gets the flag write type name for the given flag.

Parameters
flagsflag
Returns
Flag name

Reimplemented from BinaryNinja::Architecture.

◆ GetSemanticFlagClassName()

string ArchitectureExtension::GetSemanticFlagClassName ( uint32_t  semClass)
overridevirtual

Gets the name of a semantic flag class from the index.

Parameters
semClassSemantic class index
Returns
The name of the semantic flag class

Reimplemented from BinaryNinja::Architecture.

◆ GetSemanticFlagGroupName()

string ArchitectureExtension::GetSemanticFlagGroupName ( uint32_t  semGroup)
overridevirtual

Gets the name of a semantic flag group from the index.

Parameters
semGroupSemantic flag group index
Returns
Semantic flag group name

Reimplemented from BinaryNinja::Architecture.

◆ GetFullWidthRegisters()

vector< uint32_t > ArchitectureExtension::GetFullWidthRegisters ( )
overridevirtual

Get the list of full width register indices.

Returns
The list of full width register indices

Reimplemented from BinaryNinja::Architecture.

◆ GetAllRegisters()

vector< uint32_t > ArchitectureExtension::GetAllRegisters ( )
overridevirtual

Get the list of all register indices.

Returns
The list of all register indices

Reimplemented from BinaryNinja::Architecture.

◆ GetAllFlags()

vector< uint32_t > ArchitectureExtension::GetAllFlags ( )
overridevirtual

Get the list of all flag indices.

Returns
The list of all flag indices

Reimplemented from BinaryNinja::Architecture.

◆ GetAllFlagWriteTypes()

vector< uint32_t > ArchitectureExtension::GetAllFlagWriteTypes ( )
overridevirtual

Get the list of all flag write type indices.

Returns
The list of all flag write type indices

Reimplemented from BinaryNinja::Architecture.

◆ GetAllSemanticFlagClasses()

vector< uint32_t > ArchitectureExtension::GetAllSemanticFlagClasses ( )
overridevirtual

Get the list of all semantic flag class indices.

Returns
The list of all semantic flag class indices

Reimplemented from BinaryNinja::Architecture.

◆ GetAllSemanticFlagGroups()

vector< uint32_t > ArchitectureExtension::GetAllSemanticFlagGroups ( )
overridevirtual

Get the list of all semantic flag group indices.

Returns
The list of all semantic flag group indices

Reimplemented from BinaryNinja::Architecture.

◆ GetFlagRole()

BNFlagRole ArchitectureExtension::GetFlagRole ( uint32_t  flag,
uint32_t  semClass = 0 
)
overridevirtual

Get the role of a given flag.

Parameters
flagFlag index
semClassOptional semantic flag class
Returns
Flag role

Reimplemented from BinaryNinja::Architecture.

◆ GetFlagsRequiredForFlagCondition()

vector< uint32_t > ArchitectureExtension::GetFlagsRequiredForFlagCondition ( BNLowLevelILFlagCondition  cond,
uint32_t  semClass = 0 
)
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetFlagsRequiredForSemanticFlagGroup()

vector< uint32_t > ArchitectureExtension::GetFlagsRequiredForSemanticFlagGroup ( uint32_t  semGroup)
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetFlagConditionsForSemanticFlagGroup()

map< uint32_t, BNLowLevelILFlagCondition > ArchitectureExtension::GetFlagConditionsForSemanticFlagGroup ( uint32_t  semGroup)
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetFlagsWrittenByFlagWriteType()

vector< uint32_t > ArchitectureExtension::GetFlagsWrittenByFlagWriteType ( uint32_t  writeType)
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetSemanticClassForFlagWriteType()

uint32_t ArchitectureExtension::GetSemanticClassForFlagWriteType ( uint32_t  writeType)
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetFlagWriteLowLevelIL()

ExprId ArchitectureExtension::GetFlagWriteLowLevelIL ( BNLowLevelILOperation  op,
size_t  size,
uint32_t  flagWriteType,
uint32_t  flag,
BNRegisterOrConstant operands,
size_t  operandCount,
LowLevelILFunction il 
)
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetFlagConditionLowLevelIL()

ExprId ArchitectureExtension::GetFlagConditionLowLevelIL ( BNLowLevelILFlagCondition  cond,
uint32_t  semClass,
LowLevelILFunction il 
)
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetSemanticFlagGroupLowLevelIL()

ExprId ArchitectureExtension::GetSemanticFlagGroupLowLevelIL ( uint32_t  semGroup,
LowLevelILFunction il 
)
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetRegisterInfo()

BNRegisterInfo ArchitectureExtension::GetRegisterInfo ( uint32_t  reg)
overridevirtual

Get the register info for a given register index.

Parameters
regRegister index
Returns
Register info

Reimplemented from BinaryNinja::Architecture.

◆ GetStackPointerRegister()

uint32_t ArchitectureExtension::GetStackPointerRegister ( )
overridevirtual

Get the register index corresponding to the stack pointer (SP)

Returns
The register index corresponding to the stack pointer

Reimplemented from BinaryNinja::Architecture.

◆ GetLinkRegister()

uint32_t ArchitectureExtension::GetLinkRegister ( )
overridevirtual

Get the register index corresponding to the link register (LR)

Returns
The register index corresponding to the link register

Reimplemented from BinaryNinja::Architecture.

◆ GetGlobalRegisters()

vector< uint32_t > ArchitectureExtension::GetGlobalRegisters ( )
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetSystemRegisters()

vector< uint32_t > ArchitectureExtension::GetSystemRegisters ( )
overridevirtual

Get the list of system register indices.

Returns
The list of system register indices

Reimplemented from BinaryNinja::Architecture.

◆ GetRegisterStackName()

string ArchitectureExtension::GetRegisterStackName ( uint32_t  regStack)
overridevirtual

Get a register stack name from a register stack number.

Parameters
regStackRegister stack number
Returns
The corresponding register string

Reimplemented from BinaryNinja::Architecture.

◆ GetAllRegisterStacks()

vector< uint32_t > ArchitectureExtension::GetAllRegisterStacks ( )
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetRegisterStackInfo()

BNRegisterStackInfo ArchitectureExtension::GetRegisterStackInfo ( uint32_t  regStack)
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetIntrinsicName()

string ArchitectureExtension::GetIntrinsicName ( uint32_t  intrinsic)
overridevirtual

Gets an intrinsic name from an intrinsic number.

Parameters
intrinsicIntrinsic number
Returns
The corresponding intrinsic string

Reimplemented from BinaryNinja::Architecture.

◆ GetAllIntrinsics()

vector< uint32_t > ArchitectureExtension::GetAllIntrinsics ( )
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetIntrinsicInputs()

vector< NameAndType > ArchitectureExtension::GetIntrinsicInputs ( uint32_t  intrinsic)
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ GetIntrinsicOutputs()

vector< Confidence< Ref< Type > > > ArchitectureExtension::GetIntrinsicOutputs ( uint32_t  intrinsic)
overridevirtual

Reimplemented from BinaryNinja::Architecture.

◆ CanAssemble()

bool ArchitectureExtension::CanAssemble ( )
overridevirtual

Check whether this architecture can assemble instructions.

Returns
Whether this architecture can assemble instructions

Reimplemented from BinaryNinja::Architecture.

◆ Assemble()

bool ArchitectureExtension::Assemble ( const std::string &  code,
uint64_t  addr,
DataBuffer result,
std::string &  errors 
)
overridevirtual

Converts the string of assembly instructions code loaded at virtual address addr to the byte representation of those instructions.

Parameters
[in]codeString representation of the instructions to be assembled
[in]addrAddress of the instructions
[out]resultDataBuffer containing the compiled bytes
[out]errorsAny errors that occurred during assembly
Returns
Whether assembly was successful

Reimplemented from BinaryNinja::Architecture.

◆ IsNeverBranchPatchAvailable()

bool ArchitectureExtension::IsNeverBranchPatchAvailable ( const uint8_t *  data,
uint64_t  addr,
size_t  len 
)
overridevirtual

Returns true if the instruction at addr can be patched to never branch.

Note
This is used in the UI to determine if "never branch" should be displayed in the right-click context menu when right-clicking on an instruction.
Parameters
dataBuffer of bytes to check
addrthe virtual address of the bytes, to be used when assembling
lenamount of bytes to be checked
Returns
If the never branch patch is available

Reimplemented from BinaryNinja::Architecture.

◆ IsAlwaysBranchPatchAvailable()

bool ArchitectureExtension::IsAlwaysBranchPatchAvailable ( const uint8_t *  data,
uint64_t  addr,
size_t  len 
)
overridevirtual

Returns true if the instruction at addr can be patched to always branch.

Note
This is used in the UI to determine if "always branch" should be displayed in the right-click context menu when right-clicking on an instruction.
Parameters
dataBuffer of bytes to check
addrthe address of the instruction in question
lenamount of bytes to be checked
Returns
If the always branch patch is available

Reimplemented from BinaryNinja::Architecture.

◆ IsInvertBranchPatchAvailable()

bool ArchitectureExtension::IsInvertBranchPatchAvailable ( const uint8_t *  data,
uint64_t  addr,
size_t  len 
)
overridevirtual

Returns true if the instruction at addr can be patched to invert the branch.

Note
This is used in the UI to determine if "invert branch" should be displayed in the right-click context menu when right-clicking on an instruction.
Parameters
dataBuffer of bytes to check
addrthe address of the instruction in question
lenamount of bytes to be checked
Returns
If the invert branch patch is available

Reimplemented from BinaryNinja::Architecture.

◆ IsSkipAndReturnZeroPatchAvailable()

bool ArchitectureExtension::IsSkipAndReturnZeroPatchAvailable ( const uint8_t *  data,
uint64_t  addr,
size_t  len 
)
overridevirtual

Checks if the instruction at addr is a call that can be patched to return zero.

Note
This is used in the UI to determine if "skip and return zero" should be displayed in the right-click context menu when right-clicking on an instruction.
Parameters
dataBuffer of bytes to check
addrthe address of the instruction in question
lenamount of bytes to be checked
Returns
If the skip and return zero patch is available

Reimplemented from BinaryNinja::Architecture.

◆ IsSkipAndReturnValuePatchAvailable()

bool ArchitectureExtension::IsSkipAndReturnValuePatchAvailable ( const uint8_t *  data,
uint64_t  addr,
size_t  len 
)
overridevirtual

Checks if the instruction at addr is a call that can be patched to return a value.

Note
This is used in the UI to determine if "skip and return value" should be displayed in the right-click context menu when right-clicking on an instruction.
Parameters
dataBuffer of bytes to check
addrthe address of the instruction in question
lenamount of bytes to be checked
Returns
If the skip and return value patch is available

Reimplemented from BinaryNinja::Architecture.

◆ ConvertToNop()

bool ArchitectureExtension::ConvertToNop ( uint8_t *  data,
uint64_t  addr,
size_t  len 
)
overridevirtual

Converts the instruction at addr to a no-operation instruction.

Parameters
[in,out]dataBuffer of bytes to convert
[in]addrthe address of the instruction to be converted
[in]lenLength of the bytes to be converted
Returns
Whether the conversion was successful

Reimplemented from BinaryNinja::Architecture.

◆ AlwaysBranch()

bool ArchitectureExtension::AlwaysBranch ( uint8_t *  data,
uint64_t  addr,
size_t  len 
)
overridevirtual

Converts the conditional branch instruction at addr to an unconditional branch.

Note
This is called when the right-click context menu item "always branch" is selected in the UI.
Parameters
[in,out]dataBuffer of bytes to convert
[in]addrthe address of the instruction to be converted
[in]lenLength of the bytes to be converted
Returns
Whether the conversion was successful

Reimplemented from BinaryNinja::Architecture.

◆ InvertBranch()

bool ArchitectureExtension::InvertBranch ( uint8_t *  data,
uint64_t  addr,
size_t  len 
)
overridevirtual

InvertBranch converts the conditional branch instruction at addr to its invert.

Note
This is called when the right-click context menu item "invert branch" is selected in the UI.
Parameters
[in,out]dataBuffer of bytes to convert
[in]addrthe address of the instruction to be converted
[in]lenLength of the bytes to be converted
Returns
Whether the conversion was successful

Reimplemented from BinaryNinja::Architecture.

◆ SkipAndReturnValue()

bool ArchitectureExtension::SkipAndReturnValue ( uint8_t *  data,
uint64_t  addr,
size_t  len,
uint64_t  value 
)
overridevirtual

SkipAndReturnValue converts the call instruction at addr to an instruction that simulates that call returning a value.

Note
This is called when the right-click context menu item "skip and return value" is selected in the UI.
Parameters
[in,out]dataBuffer of bytes to convert
[in]addrthe address of the instruction to be converted
[in]lenLength of the bytes to be converted
[in]valueValue to be returned
Returns
Whether the conversion was successful

Reimplemented from BinaryNinja::Architecture.

Member Data Documentation

◆ m_base

Ref<Architecture> BinaryNinja::ArchitectureExtension::m_base
protected

◆ BinaryNinja::ArchitectureHook

class BinaryNinja::ArchitectureHook

Public Member Functions

 ArchitectureHook (Architecture *base)
 
- Public Member Functions inherited from BinaryNinja::CoreArchitecture
 CoreArchitecture (BNArchitecture *arch)
 
virtual BNEndianness GetEndianness () const override
 Get the default endianness for this architecture. More...
 
virtual size_t GetAddressSize () const override
 Get the address size for this architecture. More...
 
virtual size_t GetDefaultIntegerSize () const override
 Get the default integer size for this architecture. More...
 
virtual size_t GetInstructionAlignment () const override
 
virtual size_t GetMaxInstructionLength () const override
 Get the maximum instruction length. More...
 
virtual size_t GetOpcodeDisplayLength () const override
 
virtual Ref< ArchitectureGetAssociatedArchitectureByAddress (uint64_t &addr) override
 
virtual bool GetInstructionInfo (const uint8_t *data, uint64_t addr, size_t maxLen, InstructionInfo &result) override
 Retrieves an InstructionInfo struct for the instruction at the given virtual address. More...
 
virtual bool GetInstructionText (const uint8_t *data, uint64_t addr, size_t &len, std::vector< InstructionTextToken > &result) override
 Retrieves a list of InstructionTextTokens. More...
 
virtual bool GetInstructionLowLevelIL (const uint8_t *data, uint64_t addr, size_t &len, LowLevelILFunction &il) override
 Translates an instruction at addr and appends it onto the LowLevelILFunction& il. More...
 
virtual std::string GetRegisterName (uint32_t reg) override
 Gets a register name from a register index. More...
 
virtual std::string GetFlagName (uint32_t flag) override
 Gets a flag name from a flag index. More...
 
virtual std::string GetFlagWriteTypeName (uint32_t flags) override
 Gets the flag write type name for the given flag. More...
 
virtual std::string GetSemanticFlagClassName (uint32_t semClass) override
 Gets the name of a semantic flag class from the index. More...
 
virtual std::string GetSemanticFlagGroupName (uint32_t semGroup) override
 Gets the name of a semantic flag group from the index. More...
 
virtual std::vector< uint32_t > GetFullWidthRegisters () override
 Get the list of full width register indices. More...
 
virtual std::vector< uint32_t > GetAllRegisters () override
 Get the list of all register indices. More...
 
virtual std::vector< uint32_t > GetAllFlags () override
 Get the list of all flag indices. More...
 
virtual std::vector< uint32_t > GetAllFlagWriteTypes () override
 Get the list of all flag write type indices. More...
 
virtual std::vector< uint32_t > GetAllSemanticFlagClasses () override
 Get the list of all semantic flag class indices. More...
 
virtual std::vector< uint32_t > GetAllSemanticFlagGroups () override
 Get the list of all semantic flag group indices. More...
 
virtual BNFlagRole GetFlagRole (uint32_t flag, uint32_t semClass=0) override
 Get the role of a given flag. More...
 
virtual std::vector< uint32_t > GetFlagsRequiredForFlagCondition (BNLowLevelILFlagCondition cond, uint32_t semClass=0) override
 
virtual std::vector< uint32_t > GetFlagsRequiredForSemanticFlagGroup (uint32_t semGroup) override
 
virtual std::map< uint32_t, BNLowLevelILFlagConditionGetFlagConditionsForSemanticFlagGroup (uint32_t semGroup) override
 
virtual std::vector< uint32_t > GetFlagsWrittenByFlagWriteType (uint32_t writeType) override
 
virtual uint32_t GetSemanticClassForFlagWriteType (uint32_t writeType) override
 
virtual ExprId GetFlagWriteLowLevelIL (BNLowLevelILOperation op, size_t size, uint32_t flagWriteType, uint32_t flag, BNRegisterOrConstant *operands, size_t operandCount, LowLevelILFunction &il) override
 
virtual ExprId GetFlagConditionLowLevelIL (BNLowLevelILFlagCondition cond, uint32_t semClass, LowLevelILFunction &il) override
 
virtual ExprId GetSemanticFlagGroupLowLevelIL (uint32_t semGroup, LowLevelILFunction &il) override
 
virtual BNRegisterInfo GetRegisterInfo (uint32_t reg) override
 Get the register info for a given register index. More...
 
virtual uint32_t GetStackPointerRegister () override
 Get the register index corresponding to the stack pointer (SP) More...
 
virtual uint32_t GetLinkRegister () override
 Get the register index corresponding to the link register (LR) More...
 
virtual std::vector< uint32_t > GetGlobalRegisters () override
 
virtual std::vector< uint32_t > GetSystemRegisters () override
 Get the list of system register indices. More...
 
virtual std::string GetRegisterStackName (uint32_t regStack) override
 Get a register stack name from a register stack number. More...
 
virtual std::vector< uint32_t > GetAllRegisterStacks () override
 
virtual BNRegisterStackInfo GetRegisterStackInfo (uint32_t regStack) override
 
virtual std::string GetIntrinsicName (uint32_t intrinsic) override
 Gets an intrinsic name from an intrinsic number. More...
 
virtual std::vector< uint32_t > GetAllIntrinsics () override
 
virtual std::vector< NameAndTypeGetIntrinsicInputs (uint32_t intrinsic) override
 
virtual std::vector< Confidence< Ref< Type > > > GetIntrinsicOutputs (uint32_t intrinsic) override
 
virtual bool CanAssemble () override
 Check whether this architecture can assemble instructions. More...
 
virtual bool Assemble (const std::string &code, uint64_t addr, DataBuffer &result, std::string &errors) override
 Converts the string of assembly instructions code loaded at virtual address addr to the byte representation of those instructions. More...
 
virtual bool IsNeverBranchPatchAvailable (const uint8_t *data, uint64_t addr, size_t len) override
 Returns true if the instruction at addr can be patched to never branch. More...
 
virtual bool IsAlwaysBranchPatchAvailable (const uint8_t *data, uint64_t addr, size_t len) override
 Returns true if the instruction at addr can be patched to always branch. More...
 
virtual bool IsInvertBranchPatchAvailable (const uint8_t *data, uint64_t addr, size_t len) override
 Returns true if the instruction at addr can be patched to invert the branch. More...
 
virtual bool IsSkipAndReturnZeroPatchAvailable (const uint8_t *data, uint64_t addr, size_t len) override
 Checks if the instruction at addr is a call that can be patched to return zero. More...
 
virtual bool IsSkipAndReturnValuePatchAvailable (const uint8_t *data, uint64_t addr, size_t len) override
 Checks if the instruction at addr is a call that can be patched to return a value. More...
 
virtual bool ConvertToNop (uint8_t *data, uint64_t addr, size_t len) override
 Converts the instruction at addr to a no-operation instruction. More...
 
virtual bool AlwaysBranch (uint8_t *data, uint64_t addr, size_t len) override
 Converts the conditional branch instruction at addr to an unconditional branch. More...
 
virtual bool InvertBranch (uint8_t *data, uint64_t addr, size_t len) override
 InvertBranch converts the conditional branch instruction at addr to its invert. More...
 
virtual bool SkipAndReturnValue (uint8_t *data, uint64_t addr, size_t len, uint64_t value) override
 SkipAndReturnValue converts the call instruction at addr to an instruction that simulates that call returning a value. More...
 
- Public Member Functions inherited from BinaryNinja::Architecture
 Architecture (const std::string &name)
 
std::string GetName () const
 Get the name of this architecture. More...
 
virtual BNEndianness GetEndianness () const =0
 Get the default endianness for this architecture. More...
 
virtual size_t GetAddressSize () const =0
 Get the address size for this architecture. More...
 
virtual size_t GetDefaultIntegerSize () const
 Get the default integer size for this architecture. More...
 
virtual size_t GetInstructionAlignment () const
 
virtual size_t GetMaxInstructionLength () const
 Get the maximum instruction length. More...
 
virtual size_t GetOpcodeDisplayLength () const
 
virtual Ref< ArchitectureGetAssociatedArchitectureByAddress (uint64_t &addr)
 
virtual bool GetInstructionInfo (const uint8_t *data, uint64_t addr, size_t maxLen, InstructionInfo &result)=0
 Retrieves an InstructionInfo struct for the instruction at the given virtual address. More...
 
virtual bool GetInstructionText (const uint8_t *data, uint64_t addr, size_t &len, std::vector< InstructionTextToken > &result)=0
 Retrieves a list of InstructionTextTokens. More...
 
virtual bool GetInstructionLowLevelIL (const uint8_t *data, uint64_t addr, size_t &len, LowLevelILFunction &il)
 Translates an instruction at addr and appends it onto the LowLevelILFunction& il. More...
 
virtual std::string GetRegisterName (uint32_t reg)
 Gets a register name from a register index. More...
 
virtual std::string GetFlagName (uint32_t flag)
 Gets a flag name from a flag index. More...
 
virtual std::string GetFlagWriteTypeName (uint32_t flags)
 Gets the flag write type name for the given flag. More...
 
virtual std::string GetSemanticFlagClassName (uint32_t semClass)
 Gets the name of a semantic flag class from the index. More...
 
virtual std::string GetSemanticFlagGroupName (uint32_t semGroup)
 Gets the name of a semantic flag group from the index. More...
 
virtual std::vector< uint32_t > GetFullWidthRegisters ()
 Get the list of full width register indices. More...
 
virtual std::vector< uint32_t > GetAllRegisters ()
 Get the list of all register indices. More...
 
virtual std::vector< uint32_t > GetAllFlags ()
 Get the list of all flag indices. More...
 
virtual std::vector< uint32_t > GetAllFlagWriteTypes ()
 Get the list of all flag write type indices. More...
 
virtual std::vector< uint32_t > GetAllSemanticFlagClasses ()
 Get the list of all semantic flag class indices. More...
 
virtual std::vector< uint32_t > GetAllSemanticFlagGroups ()
 Get the list of all semantic flag group indices. More...
 
virtual BNFlagRole GetFlagRole (uint32_t flag, uint32_t semClass=0)
 Get the role of a given flag. More...
 
virtual std::vector< uint32_t > GetFlagsRequiredForFlagCondition (BNLowLevelILFlagCondition cond, uint32_t semClass=0)
 
virtual std::vector< uint32_t > GetFlagsRequiredForSemanticFlagGroup (uint32_t semGroup)
 
virtual std::map< uint32_t, BNLowLevelILFlagConditionGetFlagConditionsForSemanticFlagGroup (uint32_t semGroup)
 
virtual std::vector< uint32_t > GetFlagsWrittenByFlagWriteType (uint32_t writeType)
 
virtual uint32_t GetSemanticClassForFlagWriteType (uint32_t writeType)
 
virtual ExprId GetFlagWriteLowLevelIL (BNLowLevelILOperation op, size_t size, uint32_t flagWriteType, uint32_t flag, BNRegisterOrConstant *operands, size_t operandCount, LowLevelILFunction &il)
 
ExprId GetDefaultFlagWriteLowLevelIL (BNLowLevelILOperation op, size_t size, BNFlagRole role, BNRegisterOrConstant *operands, size_t operandCount, LowLevelILFunction &il)
 
virtual ExprId GetFlagConditionLowLevelIL (BNLowLevelILFlagCondition cond, uint32_t semClass, LowLevelILFunction &il)
 
ExprId GetDefaultFlagConditionLowLevelIL (BNLowLevelILFlagCondition cond, uint32_t semClass, LowLevelILFunction &il)
 
virtual ExprId GetSemanticFlagGroupLowLevelIL (uint32_t semGroup, LowLevelILFunction &il)
 
virtual BNRegisterInfo GetRegisterInfo (uint32_t reg)
 Get the register info for a given register index. More...
 
virtual uint32_t GetStackPointerRegister ()
 Get the register index corresponding to the stack pointer (SP) More...
 
virtual uint32_t GetLinkRegister ()
 Get the register index corresponding to the link register (LR) More...
 
virtual std::vector< uint32_t > GetGlobalRegisters ()
 
bool IsGlobalRegister (uint32_t reg)
 
virtual std::vector< uint32_t > GetSystemRegisters ()
 Get the list of system register indices. More...
 
bool IsSystemRegister (uint32_t reg)
 Check whether a register is a system register. More...
 
std::vector< uint32_t > GetModifiedRegistersOnWrite (uint32_t reg)
 Returns a list of register indices that are modified when reg is written to. More...
 
uint32_t GetRegisterByName (const std::string &name)
 Get a register index by its name. More...
 
virtual std::string GetRegisterStackName (uint32_t regStack)
 Get a register stack name from a register stack number. More...
 
virtual std::vector< uint32_t > GetAllRegisterStacks ()
 
virtual BNRegisterStackInfo GetRegisterStackInfo (uint32_t regStack)
 
uint32_t GetRegisterStackForRegister (uint32_t reg)
 
virtual std::string GetIntrinsicName (uint32_t intrinsic)
 Gets an intrinsic name from an intrinsic number. More...
 
virtual std::vector< uint32_t > GetAllIntrinsics ()
 
virtual std::vector< NameAndTypeGetIntrinsicInputs (uint32_t intrinsic)
 
virtual std::vector< Confidence< Ref< Type > > > GetIntrinsicOutputs (uint32_t intrinsic)
 
virtual bool CanAssemble ()
 Check whether this architecture can assemble instructions. More...
 
virtual bool Assemble (const std::string &code, uint64_t addr, DataBuffer &result, std::string &errors)
 Converts the string of assembly instructions code loaded at virtual address addr to the byte representation of those instructions. More...
 
virtual bool IsNeverBranchPatchAvailable (const uint8_t *data, uint64_t addr, size_t len)
 Returns true if the instruction at addr can be patched to never branch. More...
 
virtual bool IsAlwaysBranchPatchAvailable (const uint8_t *data, uint64_t addr, size_t len)
 Returns true if the instruction at addr can be patched to always branch. More...
 
virtual bool IsInvertBranchPatchAvailable (const uint8_t *data, uint64_t addr, size_t len)
 Returns true if the instruction at addr can be patched to invert the branch. More...
 
virtual bool IsSkipAndReturnZeroPatchAvailable (const uint8_t *data, uint64_t addr, size_t len)
 Checks if the instruction at addr is a call that can be patched to return zero. More...
 
virtual bool IsSkipAndReturnValuePatchAvailable (const uint8_t *data, uint64_t addr, size_t len)
 Checks if the instruction at addr is a call that can be patched to return a value. More...
 
virtual bool ConvertToNop (uint8_t *data, uint64_t addr, size_t len)
 Converts the instruction at addr to a no-operation instruction. More...
 
virtual bool AlwaysBranch (uint8_t *data, uint64_t addr, size_t len)
 Converts the conditional branch instruction at addr to an unconditional branch. More...
 
virtual bool InvertBranch (uint8_t *data, uint64_t addr, size_t len)
 InvertBranch converts the conditional branch instruction at addr to its invert. More...
 
virtual bool SkipAndReturnValue (uint8_t *data, uint64_t addr, size_t len, uint64_t value)
 SkipAndReturnValue converts the call instruction at addr to an instruction that simulates that call returning a value. More...
 
void RegisterFunctionRecognizer (FunctionRecognizer *recog)
 
void RegisterRelocationHandler (const std::string &viewName, RelocationHandler *handler)
 
Ref< RelocationHandlerGetRelocationHandler (const std::string &viewName)
 
bool IsBinaryViewTypeConstantDefined (const std::string &type, const std::string &name)
 
uint64_t GetBinaryViewTypeConstant (const std::string &type, const std::string &name, uint64_t defaultValue=0)
 
void SetBinaryViewTypeConstant (const std::string &type, const std::string &name, uint64_t value)
 
void RegisterCallingConvention (CallingConvention *cc)
 Register a calling convention with this architecture. More...
 
std::vector< Ref< CallingConvention > > GetCallingConventions ()
 List of registered calling conventions. More...
 
Ref< CallingConventionGetCallingConventionByName (const std::string &name)
 Get a calling convention by name. More...
 
void SetDefaultCallingConvention (CallingConvention *cc)
 Set the default calling convention. More...
 
void SetCdeclCallingConvention (CallingConvention *cc)
 Set the cdecl calling convention. More...
 
void SetStdcallCallingConvention (CallingConvention *cc)
 Set the stdcall calling convention. More...
 
void SetFastcallCallingConvention (CallingConvention *cc)
 Set the fastcall calling convention. More...
 
Ref< CallingConventionGetDefaultCallingConvention ()
 Get the default calling convention. More...
 
Ref< CallingConventionGetCdeclCallingConvention ()
 Get the cdecl calling convention. More...
 
Ref< CallingConventionGetStdcallCallingConvention ()
 Get the stdcall calling convention. More...
 
Ref< CallingConventionGetFastcallCallingConvention ()
 Get the fastcall calling convention. More...
 
Ref< PlatformGetStandalonePlatform ()
 Get the Architecture standalone platform. More...
 
std::vector< Ref< TypeLibrary > > GetTypeLibraries ()
 
void AddArchitectureRedirection (Architecture *from, Architecture *to)
 
- Public Member Functions inherited from BinaryNinja::StaticCoreRefCountObject< BNArchitecture >
 StaticCoreRefCountObject ()
 
virtual ~StaticCoreRefCountObject ()
 
BNArchitectureGetObject () const
 
void AddRef ()
 
void Release ()
 
void AddRefForRegistration ()
 
void AddRefForCallback ()
 
void ReleaseForCallback ()
 

Protected Member Functions

virtual void Register (BNCustomArchitecture *callbacks) override
 
- Protected Member Functions inherited from BinaryNinja::Architecture
 Architecture (BNArchitecture *arch)
 
virtual void Register (BNCustomArchitecture *callbacks)
 

Protected Attributes

Ref< Architecturem_base
 
- Protected Attributes inherited from BinaryNinja::Architecture
std::string m_nameForRegister
 

Additional Inherited Members

- Static Public Member Functions inherited from BinaryNinja::Architecture
static void Register (Architecture *arch)
 Register an architecture. More...
 
static Ref< ArchitectureGetByName (const std::string &name)
 Get an Architecture by name. More...
 
static std::vector< Ref< Architecture > > GetList ()
 Get the list of registered Architectures. More...
 
- Static Public Member Functions inherited from BinaryNinja::StaticCoreRefCountObject< BNArchitecture >
static BNArchitectureGetObject (StaticCoreRefCountObject *obj)
 
- Public Attributes inherited from BinaryNinja::StaticCoreRefCountObject< BNArchitecture >
std::atomic< int > m_refs
 
BNArchitecturem_object
 
- Static Protected Member Functions inherited from BinaryNinja::Architecture
static void InitCallback (void *ctxt, BNArchitecture *obj)
 
static BNEndianness GetEndiannessCallback (void *ctxt)
 
static size_t GetAddressSizeCallback (void *ctxt)
 
static size_t GetDefaultIntegerSizeCallback (void *ctxt)
 
static size_t GetInstructionAlignmentCallback (void *ctxt)
 
static size_t GetMaxInstructionLengthCallback (void *ctxt)
 
static size_t GetOpcodeDisplayLengthCallback (void *ctxt)
 
static BNArchitectureGetAssociatedArchitectureByAddressCallback (void *ctxt, uint64_t *addr)
 
static bool GetInstructionInfoCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t maxLen, BNInstructionInfo *result)
 
static bool GetInstructionTextCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t *len, BNInstructionTextToken **result, size_t *count)
 
static void FreeInstructionTextCallback (BNInstructionTextToken *tokens, size_t count)
 
static bool GetInstructionLowLevelILCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t *len, BNLowLevelILFunction *il)
 
static char * GetRegisterNameCallback (void *ctxt, uint32_t reg)
 
static char * GetFlagNameCallback (void *ctxt, uint32_t flag)
 
static char * GetFlagWriteTypeNameCallback (void *ctxt, uint32_t flags)
 
static char * GetSemanticFlagClassNameCallback (void *ctxt, uint32_t semClass)
 
static char * GetSemanticFlagGroupNameCallback (void *ctxt, uint32_t semGroup)
 
static uint32_t * GetFullWidthRegistersCallback (void *ctxt, size_t *count)
 
static uint32_t * GetAllRegistersCallback (void *ctxt, size_t *count)
 
static uint32_t * GetAllFlagsCallback (void *ctxt, size_t *count)
 
static uint32_t * GetAllFlagWriteTypesCallback (void *ctxt, size_t *count)
 
static uint32_t * GetAllSemanticFlagClassesCallback (void *ctxt, size_t *count)
 
static uint32_t * GetAllSemanticFlagGroupsCallback (void *ctxt, size_t *count)
 
static BNFlagRole GetFlagRoleCallback (void *ctxt, uint32_t flag, uint32_t semClass)
 
static uint32_t * GetFlagsRequiredForFlagConditionCallback (void *ctxt, BNLowLevelILFlagCondition cond, uint32_t semClass, size_t *count)
 
static uint32_t * GetFlagsRequiredForSemanticFlagGroupCallback (void *ctxt, uint32_t semGroup, size_t *count)
 
static BNFlagConditionForSemanticClassGetFlagConditionsForSemanticFlagGroupCallback (void *ctxt, uint32_t semGroup, size_t *count)
 
static void FreeFlagConditionsForSemanticFlagGroupCallback (void *ctxt, BNFlagConditionForSemanticClass *conditions)
 
static uint32_t * GetFlagsWrittenByFlagWriteTypeCallback (void *ctxt, uint32_t writeType, size_t *count)
 
static uint32_t GetSemanticClassForFlagWriteTypeCallback (void *ctxt, uint32_t writeType)
 
static size_t GetFlagWriteLowLevelILCallback (void *ctxt, BNLowLevelILOperation op, size_t size, uint32_t flagWriteType, uint32_t flag, BNRegisterOrConstant *operands, size_t operandCount, BNLowLevelILFunction *il)
 
static size_t GetFlagConditionLowLevelILCallback (void *ctxt, BNLowLevelILFlagCondition cond, uint32_t semClass, BNLowLevelILFunction *il)
 
static size_t GetSemanticFlagGroupLowLevelILCallback (void *ctxt, uint32_t semGroup, BNLowLevelILFunction *il)
 
static void FreeRegisterListCallback (void *ctxt, uint32_t *regs)
 
static void GetRegisterInfoCallback (void *ctxt, uint32_t reg, BNRegisterInfo *result)
 
static uint32_t GetStackPointerRegisterCallback (void *ctxt)
 
static uint32_t GetLinkRegisterCallback (void *ctxt)
 
static uint32_t * GetGlobalRegistersCallback (void *ctxt, size_t *count)
 
static uint32_t * GetSystemRegistersCallback (void *ctxt, size_t *count)
 
static char * GetRegisterStackNameCallback (void *ctxt, uint32_t regStack)
 
static uint32_t * GetAllRegisterStacksCallback (void *ctxt, size_t *count)
 
static void GetRegisterStackInfoCallback (void *ctxt, uint32_t regStack, BNRegisterStackInfo *result)
 
static char * GetIntrinsicNameCallback (void *ctxt, uint32_t intrinsic)
 
static uint32_t * GetAllIntrinsicsCallback (void *ctxt, size_t *count)
 
static BNNameAndTypeGetIntrinsicInputsCallback (void *ctxt, uint32_t intrinsic, size_t *count)
 
static void FreeNameAndTypeListCallback (void *ctxt, BNNameAndType *nt, size_t count)
 
static BNTypeWithConfidenceGetIntrinsicOutputsCallback (void *ctxt, uint32_t intrinsic, size_t *count)
 
static void FreeTypeListCallback (void *ctxt, BNTypeWithConfidence *types, size_t count)
 
static bool CanAssembleCallback (void *ctxt)
 
static bool AssembleCallback (void *ctxt, const char *code, uint64_t addr, BNDataBuffer *result, char **errors)
 
static bool IsNeverBranchPatchAvailableCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t len)
 
static bool IsAlwaysBranchPatchAvailableCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t len)
 
static bool IsInvertBranchPatchAvailableCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t len)
 
static bool IsSkipAndReturnZeroPatchAvailableCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t len)
 
static bool IsSkipAndReturnValuePatchAvailableCallback (void *ctxt, const uint8_t *data, uint64_t addr, size_t len)
 
static bool ConvertToNopCallback (void *ctxt, uint8_t *data, uint64_t addr, size_t len)
 
static bool AlwaysBranchCallback (void *ctxt, uint8_t *data, uint64_t addr, size_t len)
 
static bool InvertBranchCallback (void *ctxt, uint8_t *data, uint64_t addr, size_t len)
 
static bool SkipAndReturnValueCallback (void *ctxt, uint8_t *data, uint64_t addr, size_t len, uint64_t value)
 

Constructor & Destructor Documentation

◆ ArchitectureHook()

ArchitectureHook::ArchitectureHook ( Architecture base)

Member Function Documentation

◆ Register()

void ArchitectureHook::Register ( BNCustomArchitecture callbacks)
overrideprotectedvirtual

Reimplemented from BinaryNinja::Architecture.

Member Data Documentation

◆ m_base

Ref<Architecture> BinaryNinja::ArchitectureHook::m_base
protected