diff options
| author | Brian Potchik <brian@vector35.com> | 2026-01-30 14:04:22 -0500 |
|---|---|---|
| committer | Brian Potchik <brian@vector35.com> | 2026-01-30 14:04:22 -0500 |
| commit | c674599c102adee1882ccb6778e9c819dfccd305 (patch) | |
| tree | e4aaa5f07378f6e20c57be22ddd20580ce7788f7 | |
| parent | 3c8ce87f45512006f6f2d6818235e1531ac92ab5 (diff) | |
Improve filename handling for container files.
| -rw-r--r-- | binaryninjaapi.h | 2 | ||||
| -rw-r--r-- | binaryninjacore.h | 6 | ||||
| -rw-r--r-- | python/filemetadata.py | 8 | ||||
| -rw-r--r-- | python/transform.py | 5 | ||||
| -rw-r--r-- | transformcontext.cpp | 4 | ||||
| -rw-r--r-- | view/kernelcache/core/transformers/KernelCacheTransforms.cpp | 2 |
6 files changed, 17 insertions, 10 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 481e4102..64753e55 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -9277,7 +9277,7 @@ namespace BinaryNinja { size_t GetChildCount() const; std::vector<Ref<TransformContext>> GetChildren() const; Ref<TransformContext> GetChild(const std::string& filename = "") const; - Ref<TransformContext> SetChild(const DataBuffer& data, const std::string& filename = "", BNTransformResult result = TransformSuccess, const std::string& message = ""); + Ref<TransformContext> SetChild(const DataBuffer& data, const std::string& filename = "", BNTransformResult result = TransformSuccess, const std::string& message = "", bool filenameIsDescriptor = false); bool IsLeaf() const; bool IsRoot() const; std::vector<std::string> GetAvailableFiles() const; diff --git a/binaryninjacore.h b/binaryninjacore.h index 51cc63c1..228b1745 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -37,14 +37,14 @@ // Current ABI version for linking to the core. This is incremented any time // there are changes to the API that affect linking, including new functions, // new types, or modifications to existing functions or types. -#define BN_CURRENT_CORE_ABI_VERSION 154 +#define BN_CURRENT_CORE_ABI_VERSION 155 // Minimum ABI version that is supported for loading of plugins. Plugins that // are linked to an ABI version less than this will not be able to load and // will require rebuilding. The minimum version is increased when there are // incompatible changes that break binary compatibility, such as changes to // existing types or functions. -#define BN_MINIMUM_CORE_ABI_VERSION 154 +#define BN_MINIMUM_CORE_ABI_VERSION 155 #ifdef __GNUC__ #ifdef BINARYNINJACORE_LIBRARY @@ -4875,7 +4875,7 @@ extern "C" BINARYNINJACOREAPI BNTransformContext** BNTransformContextGetChildren(BNTransformContext* context, size_t* count); BINARYNINJACOREAPI void BNFreeTransformContextList(BNTransformContext** contexts, size_t count); BINARYNINJACOREAPI BNTransformContext* BNTransformContextGetChild(BNTransformContext* context, const char* filename); - BINARYNINJACOREAPI BNTransformContext* BNTransformContextSetChild(BNTransformContext* context, BNDataBuffer* data, const char* filename, BNTransformResult result, const char* message); + BINARYNINJACOREAPI BNTransformContext* BNTransformContextSetChild(BNTransformContext* context, BNDataBuffer* data, const char* filename, BNTransformResult result, const char* message, bool filenameIsDescriptor); BINARYNINJACOREAPI bool BNTransformContextIsLeaf(BNTransformContext* context); BINARYNINJACOREAPI bool BNTransformContextIsRoot(BNTransformContext* context); BINARYNINJACOREAPI char** BNTransformContextGetAvailableFiles(BNTransformContext* context, size_t* count); diff --git a/python/filemetadata.py b/python/filemetadata.py index 48ac9065..810d4d17 100644 --- a/python/filemetadata.py +++ b/python/filemetadata.py @@ -210,7 +210,13 @@ class FileMetadata: @property def virtual_path(self) -> str: - """The virtual path of the file including container and internal path (e.g., 'archive.zip:folder/file.bin') (read/write)""" + """ + ``virtual_path`` is a logical (non-filesystem) path that describes how this file was derived from container transform system. + + This path records provenance for files extracted from the transform system. It may include a sequence of transform steps and selection names. + + .. note:: An empty `virtual_path` indicates the file has not yet been processed by the transform system. If `virtual_path` matches `filename`, the file is not the result of an extraction or transform. + """ return core.BNGetVirtualPath(self.handle) @virtual_path.setter diff --git a/python/transform.py b/python/transform.py index d7f4202f..74279bce 100644 --- a/python/transform.py +++ b/python/transform.py @@ -681,15 +681,16 @@ class TransformContext: return None return TransformContext(child) - def create_child(self, data: databuffer.DataBuffer, filename: str = "", result: TransformResult = TransformResult.TransformSuccess, message: str = "") -> 'TransformContext': + def create_child(self, data: databuffer.DataBuffer, filename: str = "", result: TransformResult = TransformResult.TransformSuccess, message: str = "", filename_is_descriptor: bool = False) -> 'TransformContext': """Create a new child context with the given data, filename, result status, and message :param data: The data for the child context :param filename: The filename for the child context (default: "") :param result: Transform result for the child (default: TransformResult.TransformSuccess) :param message: Extraction message for the child (default: "") + :param filename_is_descriptor: Whether the filename is a descriptor that should be combined with parent (default: False) """ - child = core.BNTransformContextSetChild(self.handle, data.handle, filename, result, message) + child = core.BNTransformContextSetChild(self.handle, data.handle, filename, result, message, filename_is_descriptor) if child is None: raise RuntimeError("Failed to create child context") return TransformContext(child) diff --git a/transformcontext.cpp b/transformcontext.cpp index 06e70244..2cdb2a2c 100644 --- a/transformcontext.cpp +++ b/transformcontext.cpp @@ -173,9 +173,9 @@ Ref<TransformContext> TransformContext::GetChild(const string& filename) const } -Ref<TransformContext> TransformContext::SetChild(const DataBuffer& data, const string& filename, BNTransformResult result, const std::string& message) +Ref<TransformContext> TransformContext::SetChild(const DataBuffer& data, const string& filename, BNTransformResult result, const std::string& message, bool filenameIsDescriptor) { - BNTransformContext* child = BNTransformContextSetChild(m_object, data.GetBufferObject(), filename.c_str(), result, message.c_str()); + BNTransformContext* child = BNTransformContextSetChild(m_object, data.GetBufferObject(), filename.c_str(), result, message.c_str(), filenameIsDescriptor); if (!child) return nullptr; return new TransformContext(child); diff --git a/view/kernelcache/core/transformers/KernelCacheTransforms.cpp b/view/kernelcache/core/transformers/KernelCacheTransforms.cpp index d15169c1..753581e5 100644 --- a/view/kernelcache/core/transformers/KernelCacheTransforms.cpp +++ b/view/kernelcache/core/transformers/KernelCacheTransforms.cpp @@ -71,7 +71,7 @@ public: LogWarn("IMG4 payload contains keybag, which is not currently supported."); } - context->SetChild(DataBuffer(payload.payload.data, payload.payload.length), filename); + context->SetChild(DataBuffer(payload.payload.data, payload.payload.length), filename, TransformSuccess, "", true); return true; } |
