diff options
| author | Ryan Snyder <ryan@vector35.com> | 2021-08-04 11:17:40 -0400 |
|---|---|---|
| committer | Ryan Snyder <ryan@vector35.com> | 2021-08-20 04:34:14 -0400 |
| commit | cc1e85a4a8b2001f9fd6cf91b93fb39abef3a0e2 (patch) | |
| tree | 45fdf52d2bdb8e09f57fc76079a3a91b6528f4a1 /binaryninjacore.h | |
| parent | c1e526ea39d97c4c374de4cf8c211dc39ebbb538 (diff) | |
platforms: specify platform types and add bvt platform callbacks
Diffstat (limited to 'binaryninjacore.h')
| -rw-r--r-- | binaryninjacore.h | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/binaryninjacore.h b/binaryninjacore.h index 08f2f483..6eb5dfae 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -3109,15 +3109,48 @@ __attribute__ ((format (printf, 1, 2))) BNCustomBinaryViewType* type); BINARYNINJACOREAPI void BNRegisterArchitectureForViewType(BNBinaryViewType* type, uint32_t id, - BNEndianness endian, BNArchitecture* arch); + BNEndianness endian, BNArchitecture* arch); // Deprecated, use BNRegisterPlatformRecognizerForViewType BINARYNINJACOREAPI BNArchitecture* BNGetArchitectureForViewType(BNBinaryViewType* type, uint32_t id, - BNEndianness endian); + BNEndianness endian); // Deprecated, use BNRecognizePlatformForViewType + + BINARYNINJACOREAPI void BNRegisterPlatformForViewType(BNBinaryViewType* type, uint32_t id, + BNArchitecture* arch, BNPlatform* platform); // Deprecated, use BNRegisterPlatformRecognizerForViewType + BINARYNINJACOREAPI BNPlatform* BNGetPlatformForViewType(BNBinaryViewType* type, + uint32_t id, BNArchitecture* arch); // Deprecated, use BNRecognizePlatformForViewType - BINARYNINJACOREAPI void BNRegisterPlatformForViewType(BNBinaryViewType* type, uint32_t id, BNArchitecture* arch, - BNPlatform* platform); BINARYNINJACOREAPI void BNRegisterDefaultPlatformForViewType(BNBinaryViewType* type, BNArchitecture* arch, BNPlatform* platform); - BINARYNINJACOREAPI BNPlatform* BNGetPlatformForViewType(BNBinaryViewType* type, uint32_t id, BNArchitecture* arch); + + // Expanded identification of Platform for BinaryViewTypes. Supersedes BNRegisterArchitectureForViewType + // and BNRegisterPlatformForViewType, as these have certain edge cases (overloaded elf families, for example) + // that can't be represented. + // + // The callback returns a Platform object or null (failure), and most recently added callbacks are called first + // to allow plugins to override any default behaviors. When a callback returns a platform, architecture will be + // derived from the identified platform. + // + // The BinaryView pointer is the *parent* view (usually 'Raw') that the BinaryView is being created for. This + // means that generally speaking the callbacks need to be aware of the underlying file format, however the + // BinaryView implementation may have created datavars in the 'Raw' view by the time the callback is invoked. + // Behavior regarding when this callback is invoked and what has been made available in the BinaryView passed as an + // argument to the callback is up to the discretion of the BinaryView implementation. + // + // The 'id' ind 'endian' arguments are used as a filter to determine which registered Platform recognizer callbacks + // are invoked. + // + // Support for this API tentatively requires explicit support in the BinaryView implementation. + BINARYNINJACOREAPI void BNRegisterPlatformRecognizerForViewType(BNBinaryViewType* type, uint64_t id, BNEndianness endian, + BNPlatform* (*callback)(void* ctx, BNBinaryView* view, BNMetadata* metadata), void* ctx); + + // BinaryView* passed in here should be the parent view (not the partially constructed object!), and this function should + // be called from the BNCustomBinaryView::init implementation. + // + // 'id' and 'endianness' are used to determine which registered callbacks are actually invoked to eliminate some common sources + // of boilerplate that all callbacks would have to implement otherwise. If these aren't applicable to your binaryviewtype just + // use constants here and document them so that people registering Platform recognizers for your view type know what to use. + BINARYNINJACOREAPI BNPlatform* BNRecognizePlatformForViewType(BNBinaryViewType* type, uint64_t id, BNEndianness endian, + BNBinaryView* view, BNMetadata* metadata); + BINARYNINJACOREAPI void BNRegisterBinaryViewEvent(BNBinaryViewEventType type, void (*callback)(void* ctx, BNBinaryView* view), void* ctx); @@ -4966,6 +4999,8 @@ __attribute__ ((format (printf, 1, 2))) // Platforms BINARYNINJACOREAPI BNPlatform* BNCreatePlatform(BNArchitecture* arch, const char* name); + BINARYNINJACOREAPI BNPlatform* BNCreatePlatformWithTypes(BNArchitecture* arch, const char* name, + const char* typeFile, const char** includeDirs, size_t includeDirCount); BINARYNINJACOREAPI void BNRegisterPlatform(const char* os, BNPlatform* platform); BINARYNINJACOREAPI BNPlatform* BNNewPlatformReference(BNPlatform* platform); BINARYNINJACOREAPI void BNFreePlatform(BNPlatform* platform); |
