From 3c88b11e5df33116580ac008e36092775df66135 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Fri, 13 Mar 2026 12:24:18 -0700 Subject: [WARP] Improved UX and API - Exposes WARP type objects directly - Adds processor API (for generating warp files directly) - Adds file and chunk API - Misc cleanup - Simplified the amount of commands - Replaced the "Create" commands with a purpose built processor dialog - Added a native QT viewer for WARP files - Simplified committing to a remote with a purpose built commit dialog --- plugins/warp/api/warp.h | 92 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 81 insertions(+), 11 deletions(-) (limited to 'plugins/warp/api/warp.h') diff --git a/plugins/warp/api/warp.h b/plugins/warp/api/warp.h index ccb4da97..42e8ac70 100644 --- a/plugins/warp/api/warp.h +++ b/plugins/warp/api/warp.h @@ -276,9 +276,23 @@ namespace Warp { static Ref FromPlatform(const BinaryNinja::Platform &platform); }; + class Type : public WarpRefCountObject + { + public: + explicit Type(BNWARPType *type); + + [[nodiscard]] static Ref FromAnalysisType(const BinaryNinja::Type &type, uint8_t confidence); + + std::optional GetName() const; + uint8_t GetConfidence() const; + + [[nodiscard]] BinaryNinja::Ref GetAnalysisType(BinaryNinja::Architecture* arch = nullptr) const; + }; + struct Constraint { - ConstraintGUID guid; + ConstraintGUID guid {}; std::optional offset; Constraint(ConstraintGUID guid, std::optional offset); @@ -312,7 +326,7 @@ namespace Warp { BinaryNinja::Ref GetSymbol(const BinaryNinja::Function &function) const; - BinaryNinja::Ref GetType(const BinaryNinja::Function &function) const; + Ref GetType() const; std::vector GetConstraints() const; @@ -354,7 +368,7 @@ namespace Warp { Source GetSource() const; - BinaryNinja::Ref GetType(const BinaryNinja::Ref &arch) const; + Ref GetType() const; std::string GetName() const; @@ -363,7 +377,7 @@ namespace Warp { struct ContainerSearchResponse { - std::vector > items; + std::vector> items; size_t offset; size_t total; @@ -379,7 +393,7 @@ namespace Warp { explicit Container(BNWARPContainer *container); /// Retrieve all available containers. - static std::vector > All(); + static std::vector> All(); /// Add a new container with the given name. static Ref Add(const std::string &name); @@ -399,13 +413,12 @@ namespace Warp { std::optional SourcePath(const Source &source) const; bool AddFunctions(const Target &target, const Source &source, - const std::vector > &functions) const; + const std::vector> &functions) const; - bool AddTypes(const BinaryNinja::BinaryView &view, const Source &source, - const std::vector > &types) const; + bool AddTypes(const Source &source, const std::vector> &types) const; bool RemoveFunctions(const Target &target, const Source &source, - const std::vector > &functions) const; + const std::vector> &functions) const; bool RemoveTypes(const Source &source, const std::vector &guids) const; @@ -418,14 +431,71 @@ namespace Warp { std::vector > GetFunctionsWithGUID(const Target &target, const Source &source, const FunctionGUID &guid) const; - BinaryNinja::Ref GetTypeWithGUID(const BinaryNinja::Architecture &arch, const Source &source, - const TypeGUID &guid) const; + Ref GetTypeWithGUID(const Source &source, const TypeGUID &guid) const; std::vector GetTypeGUIDsWithName(const Source &source, const std::string &name) const; std::optional Search(const ContainerSearchQuery &query) const; }; + class Chunk : public WarpRefCountObject + { + friend class File; + + public: + explicit Chunk(BNWARPChunk *chunk); + + Ref GetTarget() const; + + [[nodiscard]] std::vector> GetFunctions() const; + [[nodiscard]] std::vector> GetTypes() const; + }; + + class File : public WarpRefCountObject + { + public: + explicit File(BNWARPFile *file); + + static Ref FromPath(const std::string &path); + + [[nodiscard]] std::vector> GetChunks() const; + [[nodiscard]] BinaryNinja::DataBuffer ToDataBuffer() const; + }; + + class ProcessorState + { + public: + std::vector analyzingFiles; + std::vector processingFiles; + bool cancelled; + size_t unprocessedFilesCount; + size_t processedFilesCount; + + ProcessorState() = default; + + static ProcessorState FromAPIObject(BNWARPProcessorState *state); + }; + + class Processor + { + BNWARPProcessor* m_object; + public: + explicit Processor(BNWARPProcessorIncludedData includedData, + BNWARPProcessorIncludedFunctions includedFunctions, size_t workerCount); + + ~Processor(); + + void AddPath(const std::string &path) const; + void AddProject(const BinaryNinja::Project &project) const; + void AddProjectFile(const BinaryNinja::ProjectFile &projectFile) const; + void AddBinaryView(const BinaryNinja::BinaryView &view) const; + + Ref Start() const; + void Cancel() const; + + ProcessorState GetState() const; + }; + void RunMatcher(const BinaryNinja::BinaryView &view); bool IsInstructionVariant(const BinaryNinja::LowLevelILFunction &function, BinaryNinja::ExprId idx); -- cgit v1.3.1