BinaryNinja::CorePlatform Class Reference

Public Member Functions

 CorePlatform (BNPlatform *plat)
 
virtual std::vector< uint32_t > GetGlobalRegisters () override
 Get the global register list for this Platform. More...
 
virtual Ref< TypeGetGlobalRegisterType (uint32_t reg) override
 Get the type of a global register. More...
 
virtual void AdjustTypeParserInput (Ref< class TypeParser > parser, std::vector< std::string > &arguments, std::vector< std::pair< std::string, std::string > > &sourceFiles) override
 Modify the input passed to the Type Parser with Platform-specific features. More...
 
- Public Member Functions inherited from BinaryNinja::Platform
 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...
 
virtual void BinaryViewInit (BinaryView *view)
 Callback that will be called when the platform of a binaryview is set. More...
 
virtual std::vector< uint32_t > GetGlobalRegisters ()
 Get the global register list for this Platform. More...
 
virtual Ref< TypeGetGlobalRegisterType (uint32_t reg)
 Get the type of a global register. More...
 
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. More...
 
virtual bool GetFallbackEnabled ()
 Provide an option for platforms to decide whether to use the fallback type library. 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 ()
 

Additional Inherited Members

- Static Public Member Functions inherited from BinaryNinja::Platform
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)
 
- Public Attributes inherited from BinaryNinja::CoreRefCountObject< BNPlatform, BNNewPlatformReference, BNFreePlatform >
std::atomic< int > m_refs
 
bool m_registeredRef
 
BNPlatformm_object
 
- Protected Member Functions inherited from BinaryNinja::Platform
 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 inherited from BinaryNinja::Platform
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 BNTypeGetGlobalRegisterTypeCallback (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)
 

Constructor & Destructor Documentation

◆ CorePlatform()

CorePlatform::CorePlatform ( BNPlatform plat)

Member Function Documentation

◆ GetGlobalRegisters()

std::vector< uint32_t > CorePlatform::GetGlobalRegisters ( )
overridevirtual

Get the global register list for this Platform.

Allows the Platform to override the global register list used by analysis.

Reimplemented from BinaryNinja::Platform.

◆ GetGlobalRegisterType()

Ref< Type > CorePlatform::GetGlobalRegisterType ( uint32_t  reg)
overridevirtual

Get the type of a global register.

Called by analysis when the incoming register value of a global register is observed.

Parameters
regThe register being queried for type information.

Reimplemented from BinaryNinja::Platform.

◆ AdjustTypeParserInput()

void CorePlatform::AdjustTypeParserInput ( Ref< class TypeParser parser,
std::vector< std::string > &  arguments,
std::vector< std::pair< std::string, std::string > > &  sourceFiles 
)
overridevirtual

Modify the input passed to the Type Parser with Platform-specific features.

Parameters
[in]parserType Parser instance
[in,out]argumentsArguments to the type parser
[in,out]sourceFilesSource file names and contents

Reimplemented from BinaryNinja::Platform.