BinaryNinja::Platform Class Reference

Platform base class. More...

Detailed Description

Platform base class.

This should be subclassed when creating a new platform

Public Member Functions

 Platform (BNPlatform *platform)
 
Ref< ArchitectureGetArchitecture () const
 Get the Architecture for this platform. More...
 
std::string GetName () const
 Get the name of this platform. More...
 
Ref< CallingConventionGetDefaultCallingConvention () const
 Get the default calling convention for this platform. More...
 
Ref< CallingConventionGetCdeclCallingConvention () const
 Get the cdecl CallingConvention. More...
 
Ref< CallingConventionGetStdcallCallingConvention () const
 Get the stdcall CallingConvention. More...
 
Ref< CallingConventionGetFastcallCallingConvention () const
 Get the fastcall CallingConvention. More...
 
std::vector< Ref< CallingConvention > > GetCallingConventions () const
 Get the list of registered calling conventions. More...
 
Ref< CallingConventionGetSystemCallConvention () const
 Get the syscall calling convention. More...
 
void RegisterCallingConvention (CallingConvention *cc)
 Register a Calling Convention. More...
 
void RegisterDefaultCallingConvention (CallingConvention *cc)
 Set the default calling convention. More...
 
void RegisterCdeclCallingConvention (CallingConvention *cc)
 Set the cdecl calling convention. More...
 
void RegisterStdcallCallingConvention (CallingConvention *cc)
 Set the stdcall calling convention. More...
 
void RegisterFastcallCallingConvention (CallingConvention *cc)
 Set the fastcall calling convention. More...
 
void SetSystemCallConvention (CallingConvention *cc)
 Set the syscall calling convention. More...
 
Ref< PlatformGetRelatedPlatform (Architecture *arch)
 
void AddRelatedPlatform (Architecture *arch, Platform *platform)
 
Ref< PlatformGetAssociatedPlatformByAddress (uint64_t &addr)
 
std::map< QualifiedName, Ref< Type > > GetTypes ()
 Get the list of platform-specific types. More...
 
std::map< QualifiedName, Ref< Type > > GetVariables ()
 Get the list of platform-specific variable definitions. More...
 
std::map< QualifiedName, Ref< Type > > GetFunctions ()
 Get the list of platform-specific function definitions. More...
 
std::map< uint32_t, QualifiedNameAndTypeGetSystemCalls ()
 System calls for this platform. More...
 
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. More...
 
Ref< TypeGetTypeByName (const QualifiedName &name)
 
Ref< TypeGetVariableByName (const QualifiedName &name)
 
Ref< TypeGetFunctionByName (const QualifiedName &name, bool exactMatch=false)
 
std::string GetSystemCallName (uint32_t n)
 
Ref< TypeGetSystemCallType (uint32_t n)
 
std::string GenerateAutoPlatformTypeId (const QualifiedName &name)
 
Ref< NamedTypeReferenceGenerateAutoPlatformTypeReference (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``. More...
 
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``. More...
 
- Public Member Functions inherited from BinaryNinja::CoreRefCountObject< BNPlatform, BNNewPlatformReference, BNFreePlatform >
 CoreRefCountObject ()
 
virtual ~CoreRefCountObject ()
 
BNPlatformGetObject () 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. More...
 
static Ref< PlatformGetByName (const std::string &name)
 Get a platform by name. More...
 
static std::vector< Ref< Platform > > GetList ()
 Get the list of registered platforms. More...
 
static std::vector< Ref< Platform > > GetList (Architecture *arch)
 Get the list of registered platforms by Architecture. More...
 
static std::vector< Ref< Platform > > GetList (const std::string &os)
 Get the list of registered platforms by os. More...
 
static std::vector< Ref< Platform > > GetList (const std::string &os, Architecture *arch)
 Get the list of registered platforms by OS and Architecture. More...
 
static std::vector< std::string > GetOSList ()
 Get the list of operating systems. More...
 
- Static Public Member Functions inherited from BinaryNinja::CoreRefCountObject< BNPlatform, BNNewPlatformReference, BNFreePlatform >
static BNPlatformGetObject (CoreRefCountObject *obj)
 
static BNPlatformGetObject (const CoreRefCountObject *obj)
 

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 >())
 

Additional Inherited Members

- Public Attributes inherited from BinaryNinja::CoreRefCountObject< BNPlatform, BNNewPlatformReference, BNFreePlatform >
std::atomic< int > m_refs
 
bool m_registeredRef
 
BNPlatformm_object
 

Constructor & Destructor Documentation

◆ Platform() [1/3]

BinaryNinja::Platform::Platform ( Architecture arch,
const std::string &  name 
)
protected

◆ Platform() [2/3]

BinaryNinja::Platform::Platform ( Architecture arch,
const std::string &  name,
const std::string &  typeFile,
const std::vector< std::string > &  includeDirs = std::vector< std::string >() 
)
protected

◆ Platform() [3/3]

Platform::Platform ( BNPlatform platform)

Member Function Documentation

◆ GetArchitecture()

Ref< Architecture > Platform::GetArchitecture ( ) const

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()

void Platform::Register ( const std::string &  os,
Platform platform 
)
static

Register a Platform.

Parameters
osOS for the platform to register
platformPlatform to register

◆ GetByName()

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

Get a platform by name.

Parameters
nameName of the platform to retrieve
Returns
The Platform, if it exists

◆ GetList() [1/4]

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

Get the list of registered platforms.

Returns
The list of registered platforms

◆ GetList() [2/4]

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

Get the list of registered platforms by Architecture.

Parameters
archArchitecture to get the registered platforms for
Returns
The list of registered platforms by Architecture

◆ GetList() [3/4]

static std::vector< Ref< Platform > > BinaryNinja::Platform::GetList ( const std::string &  os)
static

Get the list of registered platforms by os.

Parameters
osOS to get the registered platforms for
Returns
The list of registered platforms by Architecture

◆ GetList() [4/4]

static std::vector< Ref< Platform > > BinaryNinja::Platform::GetList ( const std::string &  os,
Architecture arch 
)
static

Get the list of registered platforms by OS and Architecture.

Parameters
osOS to get the registered platforms for
archArchitecture to get the registered platforms for
Returns
The list of registered platforms

◆ GetOSList()

vector< std::string > Platform::GetOSList ( )
static

Get the list of operating systems.

Returns
The list of operating systems

◆ GetDefaultCallingConvention()

Ref< CallingConvention > Platform::GetDefaultCallingConvention ( ) const

Get the default calling convention for this platform.

Returns
The default calling convention

◆ GetCdeclCallingConvention()

Ref< CallingConvention > Platform::GetCdeclCallingConvention ( ) const

Get the cdecl CallingConvention.

Returns
The cdecl CallingConvention

◆ GetStdcallCallingConvention()

Ref< CallingConvention > Platform::GetStdcallCallingConvention ( ) const

Get the stdcall CallingConvention.

Returns
The stdcall CallingConvention

◆ GetFastcallCallingConvention()

Ref< CallingConvention > Platform::GetFastcallCallingConvention ( ) const

Get the fastcall CallingConvention.

Returns
The fastcall Calling Convention

◆ GetCallingConventions()

vector< Ref< CallingConvention > > Platform::GetCallingConventions ( ) const

Get the list of registered calling conventions.

Returns
The list of registered calling conventions

◆ GetSystemCallConvention()

Ref< CallingConvention > Platform::GetSystemCallConvention ( ) const

Get the syscall calling convention.

Returns
The syscall CallingConvention

◆ RegisterCallingConvention()

void Platform::RegisterCallingConvention ( CallingConvention cc)

Register a Calling Convention.

Parameters
ccCalling Convention to register

◆ RegisterDefaultCallingConvention()

void Platform::RegisterDefaultCallingConvention ( CallingConvention cc)

Set the default calling convention.

Parameters
ccThe new default CallingConvention

◆ RegisterCdeclCallingConvention()

void Platform::RegisterCdeclCallingConvention ( CallingConvention cc)

Set the cdecl calling convention.

Parameters
ccThe new cdecl CallingConvention

◆ RegisterStdcallCallingConvention()

void Platform::RegisterStdcallCallingConvention ( CallingConvention cc)

Set the stdcall calling convention.

Parameters
ccThe new stdcall CallingConvention

◆ RegisterFastcallCallingConvention()

void Platform::RegisterFastcallCallingConvention ( CallingConvention cc)

Set the fastcall calling convention.

Parameters
ccThe new fastcall calling convention

◆ SetSystemCallConvention()

void Platform::SetSystemCallConvention ( CallingConvention cc)

Set the syscall calling convention.

Parameters
ccThe new syscall calling convention

◆ GetRelatedPlatform()

Ref< Platform > Platform::GetRelatedPlatform ( Architecture arch)

◆ AddRelatedPlatform()

void Platform::AddRelatedPlatform ( Architecture arch,
Platform platform 
)

◆ GetAssociatedPlatformByAddress()

Ref< Platform > Platform::GetAssociatedPlatformByAddress ( uint64_t &  addr)

◆ GetTypes()

map< QualifiedName, Ref< Type > > Platform::GetTypes ( )

Get the list of platform-specific types.

Returns
A map of Platform Type QualifiedNames and Ref<Type>s

◆ GetVariables()

map< QualifiedName, Ref< Type > > Platform::GetVariables ( )

Get the list of platform-specific variable definitions.

Returns
A map of Platform Variable QualifiedNames and Ref<Type>s

◆ GetFunctions()

map< QualifiedName, Ref< Type > > Platform::GetFunctions ( )

Get the list of platform-specific function definitions.

Returns
A map of Platform Function QualifiedNames and Ref<Type>s

◆ GetSystemCalls()

map< uint32_t, QualifiedNameAndType > Platform::GetSystemCalls ( )

System calls for this platform.

Returns
A list of system calls for this platform

◆ GetTypeLibraries()

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

◆ GetTypeLibrariesByName()

vector< Ref< TypeLibrary > > Platform::GetTypeLibrariesByName ( const std::string &  name)

◆ GetTypeContainer()

TypeContainer Platform::GetTypeContainer ( )

Type Container for all registered types in the Platform.

Returns
Platform types Type Container

◆ GetTypeByName()

Ref< Type > Platform::GetTypeByName ( const QualifiedName name)

◆ GetVariableByName()

Ref< Type > Platform::GetVariableByName ( const QualifiedName name)

◆ GetFunctionByName()

Ref< Type > Platform::GetFunctionByName ( const QualifiedName name,
bool  exactMatch = false 
)

◆ GetSystemCallName()

string Platform::GetSystemCallName ( uint32_t  n)

◆ GetSystemCallType()

Ref< Type > Platform::GetSystemCallType ( uint32_t  n)

◆ GenerateAutoPlatformTypeId()

string Platform::GenerateAutoPlatformTypeId ( const QualifiedName name)

◆ GenerateAutoPlatformTypeReference()

Ref< NamedTypeReference > Platform::GenerateAutoPlatformTypeReference ( BNNamedTypeReferenceClass  cls,
const QualifiedName name 
)

◆ 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
sourceSource string to be parsed
fileNameSource Filename
typesmap reference that Types will be copied into
variablesmap reference that variables will be copied into
functionsmap reference that functions will be copied into
errorsstring reference that any errors will be copied into
includeDirsoptional list of directories to include for header searches
autoTypeSourceoptional 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
fileNameSource Filename
typesmap reference that Types will be copied into
variablesmap reference that variables will be copied into
functionsmap reference that functions will be copied into
errorsstring reference that any errors will be copied into
includeDirsoptional list of directories to include for header searches
autoTypeSourceoptional source of types if used for automatically generated types
Returns
true on success, false otherwise