Binary Ninja API C++: BinaryNinja::Platform Class Reference
Platform base class.
This should be subclassed when creating a new platform
Public Member Functions | |
| Platform (BNPlatform *platform) | |
| Ref< Architecture > | GetArchitecture () const |
| Get the Architecture for this platform. | |
| std::string | GetName () const |
| Get the name of this platform. | |
| Ref< CallingConvention > | GetDefaultCallingConvention () const |
| Get the default calling convention for this platform. | |
| Ref< CallingConvention > | GetCdeclCallingConvention () const |
| Get the cdecl CallingConvention. | |
| Ref< CallingConvention > | GetStdcallCallingConvention () const |
| Get the stdcall CallingConvention. | |
| Ref< CallingConvention > | GetFastcallCallingConvention () const |
| Get the fastcall CallingConvention. | |
| std::vector< Ref< CallingConvention > > | GetCallingConventions () const |
| Get the list of registered calling conventions. | |
| Ref< CallingConvention > | GetSystemCallConvention () const |
| Get the syscall calling convention. | |
| void | RegisterCallingConvention (CallingConvention *cc) |
| Register a Calling Convention. | |
| void | RegisterDefaultCallingConvention (CallingConvention *cc) |
| Set the default calling convention. | |
| void | RegisterCdeclCallingConvention (CallingConvention *cc) |
| Set the cdecl calling convention. | |
| void | RegisterStdcallCallingConvention (CallingConvention *cc) |
| Set the stdcall calling convention. | |
| void | RegisterFastcallCallingConvention (CallingConvention *cc) |
| Set the fastcall calling convention. | |
| void | SetSystemCallConvention (CallingConvention *cc) |
| Set the syscall calling convention. | |
| virtual void | BinaryViewInit (BinaryView *view) |
| Callback that will be called when the platform of a binaryview is set. | |
| virtual std::vector< uint32_t > | GetGlobalRegisters () |
| Get the global register list for this Platform. | |
| virtual Ref< Type > | GetGlobalRegisterType (uint32_t reg) |
| Get the type of a global register. | |
| virtual size_t | GetAddressSize () const |
| Get the address size for this platform. | |
| virtual void | AdjustTypeParserInput (Ref< class TypeParser > parser, std::vector< std::string > &arguments, std::vector< std::pair< std::string, std::string > > &sourceFiles) |
| Modify the input passed to the Type Parser with Platform-specific features. | |
| virtual bool | GetFallbackEnabled () |
| Provide an option for platforms to decide whether to use the fallback type library. | |
| Ref< Platform > | GetRelatedPlatform (Architecture *arch) |
| void | AddRelatedPlatform (Architecture *arch, Platform *platform) |
| std::vector< Ref< Platform > > | GetRelatedPlatforms () |
| Get the list of related platforms for this platform. | |
| Ref< Platform > | GetAssociatedPlatformByAddress (uint64_t &addr) |
| std::map< QualifiedName, Ref< Type > > | GetTypes () |
| Get the list of platform-specific types. | |
| std::map< QualifiedName, Ref< Type > > | GetVariables () |
| Get the list of platform-specific variable definitions. | |
| std::map< QualifiedName, Ref< Type > > | GetFunctions () |
| Get the list of platform-specific function definitions. | |
| std::map< uint32_t, QualifiedNameAndType > | GetSystemCalls () |
| System calls for this platform. | |
| std::vector< Ref< TypeLibrary > > | GetTypeLibraries () |
| std::vector< Ref< TypeLibrary > > | GetTypeLibrariesByName (const std::string &name) |
| TypeContainer | GetTypeContainer () |
| Type Container for all registered types in the Platform. | |
| Ref< Type > | GetTypeByName (const QualifiedName &name) |
| Ref< Type > | GetVariableByName (const QualifiedName &name) |
| Ref< Type > | GetFunctionByName (const QualifiedName &name, bool exactMatch=false) |
| std::string | GetSystemCallName (uint32_t n) |
| Ref< Type > | GetSystemCallType (uint32_t n) |
| std::string | GenerateAutoPlatformTypeId (const QualifiedName &name) |
| Ref< NamedTypeReference > | GenerateAutoPlatformTypeReference (BNNamedTypeReferenceClass cls, const QualifiedName &name) |
| std::string | GetAutoPlatformTypeIdSource () |
| bool | ParseTypesFromSource (const std::string &source, const std::string &fileName, std::map< QualifiedName, Ref< Type > > &types, std::map< QualifiedName, Ref< Type > > &variables, std::map< QualifiedName, Ref< Type > > &functions, std::string &errors, const std::vector< std::string > &includeDirs=std::vector< std::string >(), const std::string &autoTypeSource="") |
| Parses the source string and any needed headers searching for them in the optional list of directories provided in ``includeDirs``. | |
| bool | ParseTypesFromSourceFile (const std::string &fileName, std::map< QualifiedName, Ref< Type > > &types, std::map< QualifiedName, Ref< Type > > &variables, std::map< QualifiedName, Ref< Type > > &functions, std::string &errors, const std::vector< std::string > &includeDirs=std::vector< std::string >(), const std::string &autoTypeSource="") |
| Parses the source string and any needed headers searching for them in the optional list of directories provided in ``includeDirs``. | |
| Public Member Functions inherited from BinaryNinja::CoreRefCountObject< BNPlatform, BNNewPlatformReference, BNFreePlatform > | |
| CoreRefCountObject () | |
| virtual | ~CoreRefCountObject () |
| BNPlatform * | GetObject () const |
| void | AddRef () |
| void | Release () |
| void | AddRefForRegistration () |
| void | ReleaseForRegistration () |
| void | AddRefForCallback () |
| void | ReleaseForCallback () |
Static Public Member Functions | |
| static void | Register (const std::string &os, Platform *platform) |
| Register a Platform. | |
| static Ref< Platform > | GetByName (const std::string &name) |
| Get a platform by name. | |
| static std::vector< Ref< Platform > > | GetList () |
| Get the list of registered platforms. | |
| static std::vector< Ref< Platform > > | GetList (Architecture *arch) |
| Get the list of registered platforms by Architecture. | |
| static std::vector< Ref< Platform > > | GetList (const std::string &os) |
| Get the list of registered platforms by os. | |
| static std::vector< Ref< Platform > > | GetList (const std::string &os, Architecture *arch) |
| Get the list of registered platforms by OS and Architecture. | |
| static std::vector< std::string > | GetOSList () |
| Get the list of operating systems. | |
Protected Member Functions | |
| Platform (Architecture *arch, const std::string &name) | |
| Platform (Architecture *arch, const std::string &name, const std::string &typeFile, const std::vector< std::string > &includeDirs=std::vector< std::string >()) | |
Static Protected Member Functions | |
| static void | InitCallback (void *ctxt, BNPlatform *) |
| static void | InitViewCallback (void *ctxt, BNBinaryView *view) |
| static uint32_t * | GetGlobalRegistersCallback (void *ctxt, size_t *count) |
| static void | FreeRegisterListCallback (void *ctxt, uint32_t *regs, size_t count) |
| static size_t | GetAddressSizeCallback (void *ctxt) |
| static BNType * | GetGlobalRegisterTypeCallback (void *ctxt, uint32_t reg) |
| static void | AdjustTypeParserInputCallback (void *ctxt, BNTypeParser *parser, const char *const *argumentsIn, size_t argumentsLenIn, const char *const *sourceFileNamesIn, const char *const *sourceFileValuesIn, size_t sourceFilesLenIn, char ***argumentsOut, size_t *argumentsLenOut, char ***sourceFileNamesOut, char ***sourceFileValuesOut, size_t *sourceFilesLenOut) |
| static void | FreeTypeParserInputCallback (void *ctxt, char **arguments, size_t argumentsLen, char **sourceFileNames, char **sourceFileValues, size_t sourceFilesLen) |
| static bool | GetFallbackEnabledCallback (void *ctxt) |
◆ Platform() [1/3]
|
protected |
◆ Platform() [2/3]
|
protected |
◆ Platform() [3/3]
◆ InitCallback()
|
staticprotected |
◆ InitViewCallback()
|
staticprotected |
◆ GetGlobalRegistersCallback()
|
staticprotected |
◆ FreeRegisterListCallback()
|
staticprotected |
◆ GetAddressSizeCallback()
|
staticprotected |
◆ GetGlobalRegisterTypeCallback()
|
staticprotected |
◆ AdjustTypeParserInputCallback()
|
staticprotected |
◆ FreeTypeParserInputCallback()
|
staticprotected |
◆ GetFallbackEnabledCallback()
|
staticprotected |
◆ GetArchitecture()
Get the Architecture for this platform.
- Returns
- The platform architecture
◆ GetName()
| string Platform::GetName | ( | ) | const |
Get the name of this platform.
- Returns
- The platform namee
◆ Register()
|
static |
◆ GetByName()
Get a platform by name.
- Parameters
-
name Name of the platform to retrieve
- Returns
- The Platform, if it exists
◆ GetList() [1/4]
Get the list of registered platforms.
- Returns
- The list of registered platforms
◆ GetList() [2/4]
Get the list of registered platforms by Architecture.
- Parameters
- Returns
- The list of registered platforms by Architecture
◆ GetList() [3/4]
Get the list of registered platforms by os.
- Parameters
-
os OS to get the registered platforms for
- Returns
- The list of registered platforms by Architecture
◆ GetList() [4/4]
|
static |
Get the list of registered platforms by OS and Architecture.
- Parameters
-
os OS to get the registered platforms for arch Architecture to get the registered platforms for
- Returns
- The list of registered platforms
◆ GetOSList()
|
static |
Get the list of operating systems.
- Returns
- The list of operating systems
◆ GetDefaultCallingConvention()
Get the default calling convention for this platform.
- Returns
- The default calling convention
◆ GetCdeclCallingConvention()
◆ GetStdcallCallingConvention()
◆ GetFastcallCallingConvention()
◆ GetCallingConventions()
Get the list of registered calling conventions.
- Returns
- The list of registered calling conventions
◆ GetSystemCallConvention()
◆ RegisterCallingConvention()
Register a Calling Convention.
- Parameters
-
cc Calling Convention to register
◆ RegisterDefaultCallingConvention()
Set the default calling convention.
- Parameters
◆ RegisterCdeclCallingConvention()
Set the cdecl calling convention.
- Parameters
◆ RegisterStdcallCallingConvention()
Set the stdcall calling convention.
- Parameters
◆ RegisterFastcallCallingConvention()
Set the fastcall calling convention.
- Parameters
-
cc The new fastcall calling convention
◆ SetSystemCallConvention()
Set the syscall calling convention.
- Parameters
-
cc The new syscall calling convention
◆ BinaryViewInit()
|
virtual |
Callback that will be called when the platform of a binaryview is set.
Allows for the Platform to to do platform-specific processing of views just after finalization.
- Parameters
◆ GetGlobalRegisters()
|
virtual |
◆ GetGlobalRegisterType()
Get the type of a global register.
Called by analysis when the incoming register value of a global register is observed.
- Parameters
-
reg The register being queried for type information.
Reimplemented in BinaryNinja::CorePlatform.
◆ GetAddressSize()
|
virtual |
Get the address size for this platform.
- Returns
- The address size for this platform
Reimplemented in BinaryNinja::CorePlatform.
◆ AdjustTypeParserInput()
|
virtual |
Modify the input passed to the Type Parser with Platform-specific features.
- Parameters
-
[in] parser Type Parser instance [in,out] arguments Arguments to the type parser [in,out] sourceFiles Source file names and contents
Reimplemented in BinaryNinja::CorePlatform.
◆ GetFallbackEnabled()
|
virtual |
Provide an option for platforms to decide whether to use the fallback type library.
Allows the Platform to override it to false.
◆ GetRelatedPlatform()
◆ AddRelatedPlatform()
| void Platform::AddRelatedPlatform | ( | Architecture * | arch, |
| Platform * | platform ) |
◆ GetRelatedPlatforms()
Get the list of related platforms for this platform.
- Returns
- A vector of Ref<Platform>s
◆ GetAssociatedPlatformByAddress()
◆ GetTypes()
◆ GetVariables()
◆ GetFunctions()
◆ GetSystemCalls()
System calls for this platform.
- Returns
- A list of system calls for this platform
◆ GetTypeLibraries()
◆ GetTypeLibrariesByName()
| vector< Ref< TypeLibrary > > Platform::GetTypeLibrariesByName | ( | const std::string & | name | ) |
◆ GetTypeContainer()
◆ GetTypeByName()
◆ GetVariableByName()
◆ GetFunctionByName()
◆ GetSystemCallName()
| string Platform::GetSystemCallName | ( | uint32_t | n | ) |
◆ GetSystemCallType()
◆ GenerateAutoPlatformTypeId()
| string Platform::GenerateAutoPlatformTypeId | ( | const QualifiedName & | name | ) |
◆ GenerateAutoPlatformTypeReference()
◆ GetAutoPlatformTypeIdSource()
| string Platform::GetAutoPlatformTypeIdSource | ( | ) |
◆ ParseTypesFromSource()
| bool Platform::ParseTypesFromSource | ( | const std::string & | source, |
| const std::string & | fileName, | ||
| std::map< QualifiedName, Ref< Type > > & | types, | ||
| std::map< QualifiedName, Ref< Type > > & | variables, | ||
| std::map< QualifiedName, Ref< Type > > & | functions, | ||
| std::string & | errors, | ||
| const std::vector< std::string > & | includeDirs = std::vector<std::string>(), | ||
| const std::string & | autoTypeSource = "" ) |
Parses the source string and any needed headers searching for them in the optional list of directories provided in ``includeDirs``.
- Note
- This API does not allow the source to rely on existing types that only exist in a specific view. Use BinaryView->ParseTypeString instead.
- Parameters
-
source Source string to be parsed fileName Source Filename types map reference that Types will be copied into variables map reference that variables will be copied into functions map reference that functions will be copied into errors string reference that any errors will be copied into includeDirs optional list of directories to include for header searches autoTypeSource optional source of types if used for automatically generated types
- Returns
- true on success, false otherwise
◆ ParseTypesFromSourceFile()
| bool Platform::ParseTypesFromSourceFile | ( | const std::string & | fileName, |
| std::map< QualifiedName, Ref< Type > > & | types, | ||
| std::map< QualifiedName, Ref< Type > > & | variables, | ||
| std::map< QualifiedName, Ref< Type > > & | functions, | ||
| std::string & | errors, | ||
| const std::vector< std::string > & | includeDirs = std::vector<std::string>(), | ||
| const std::string & | autoTypeSource = "" ) |
Parses the source string and any needed headers searching for them in the optional list of directories provided in ``includeDirs``.
- Note
- This API does not allow the source to rely on existing types that only exist in a specific view. Use BinaryView->ParseTypeString instead.
- Parameters
-
fileName Source Filename types map reference that Types will be copied into variables map reference that variables will be copied into functions map reference that functions will be copied into errors string reference that any errors will be copied into includeDirs optional list of directories to include for header searches autoTypeSource optional source of types if used for automatically generated types
- Returns
- true on success, false otherwise