summaryrefslogtreecommitdiff
path: root/plugins/warp/api/warp.h
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2026-03-13 12:24:18 -0700
committerMason Reed <35282038+emesare@users.noreply.github.com>2026-03-24 18:46:48 -0700
commit3c88b11e5df33116580ac008e36092775df66135 (patch)
treecd64fbe149f05683ddabcccd0db7b87356f1f8cf /plugins/warp/api/warp.h
parentf325aa7b6026a1daef84931baeb1f50d7da10c10 (diff)
[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
Diffstat (limited to 'plugins/warp/api/warp.h')
-rw-r--r--plugins/warp/api/warp.h92
1 files changed, 81 insertions, 11 deletions
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<Target> FromPlatform(const BinaryNinja::Platform &platform);
};
+ class Type : public WarpRefCountObject<BNWARPType, BNWARPNewTypeReference,
+ BNWARPFreeTypeReference>
+ {
+ public:
+ explicit Type(BNWARPType *type);
+
+ [[nodiscard]] static Ref<Type> FromAnalysisType(const BinaryNinja::Type &type, uint8_t confidence);
+
+ std::optional<std::string> GetName() const;
+ uint8_t GetConfidence() const;
+
+ [[nodiscard]] BinaryNinja::Ref<BinaryNinja::Type> GetAnalysisType(BinaryNinja::Architecture* arch = nullptr) const;
+ };
+
struct Constraint
{
- ConstraintGUID guid;
+ ConstraintGUID guid {};
std::optional<int64_t> offset;
Constraint(ConstraintGUID guid, std::optional<int64_t> offset);
@@ -312,7 +326,7 @@ namespace Warp {
BinaryNinja::Ref<BinaryNinja::Symbol> GetSymbol(const BinaryNinja::Function &function) const;
- BinaryNinja::Ref<BinaryNinja::Type> GetType(const BinaryNinja::Function &function) const;
+ Ref<Type> GetType() const;
std::vector<Constraint> GetConstraints() const;
@@ -354,7 +368,7 @@ namespace Warp {
Source GetSource() const;
- BinaryNinja::Ref<BinaryNinja::Type> GetType(const BinaryNinja::Ref<BinaryNinja::Architecture> &arch) const;
+ Ref<Type> GetType() const;
std::string GetName() const;
@@ -363,7 +377,7 @@ namespace Warp {
struct ContainerSearchResponse
{
- std::vector<Ref<ContainerSearchItem> > items;
+ std::vector<Ref<ContainerSearchItem>> items;
size_t offset;
size_t total;
@@ -379,7 +393,7 @@ namespace Warp {
explicit Container(BNWARPContainer *container);
/// Retrieve all available containers.
- static std::vector<Ref<Container> > All();
+ static std::vector<Ref<Container>> All();
/// Add a new container with the given name.
static Ref<Container> Add(const std::string &name);
@@ -399,13 +413,12 @@ namespace Warp {
std::optional<std::string> SourcePath(const Source &source) const;
bool AddFunctions(const Target &target, const Source &source,
- const std::vector<Ref<Function> > &functions) const;
+ const std::vector<Ref<Function>> &functions) const;
- bool AddTypes(const BinaryNinja::BinaryView &view, const Source &source,
- const std::vector<BinaryNinja::Ref<BinaryNinja::Type> > &types) const;
+ bool AddTypes(const Source &source, const std::vector<Ref<Type>> &types) const;
bool RemoveFunctions(const Target &target, const Source &source,
- const std::vector<Ref<Function> > &functions) const;
+ const std::vector<Ref<Function>> &functions) const;
bool RemoveTypes(const Source &source, const std::vector<TypeGUID> &guids) const;
@@ -418,14 +431,71 @@ namespace Warp {
std::vector<Ref<Function> > GetFunctionsWithGUID(const Target &target, const Source &source,
const FunctionGUID &guid) const;
- BinaryNinja::Ref<BinaryNinja::Type> GetTypeWithGUID(const BinaryNinja::Architecture &arch, const Source &source,
- const TypeGUID &guid) const;
+ Ref<Type> GetTypeWithGUID(const Source &source, const TypeGUID &guid) const;
std::vector<TypeGUID> GetTypeGUIDsWithName(const Source &source, const std::string &name) const;
std::optional<ContainerSearchResponse> Search(const ContainerSearchQuery &query) const;
};
+ class Chunk : public WarpRefCountObject<BNWARPChunk, BNWARPNewChunkReference, BNWARPFreeChunkReference>
+ {
+ friend class File;
+
+ public:
+ explicit Chunk(BNWARPChunk *chunk);
+
+ Ref<Target> GetTarget() const;
+
+ [[nodiscard]] std::vector<Ref<Function>> GetFunctions() const;
+ [[nodiscard]] std::vector<Ref<Type>> GetTypes() const;
+ };
+
+ class File : public WarpRefCountObject<BNWARPFile, BNWARPNewFileReference, BNWARPFreeFileReference>
+ {
+ public:
+ explicit File(BNWARPFile *file);
+
+ static Ref<File> FromPath(const std::string &path);
+
+ [[nodiscard]] std::vector<Ref<Chunk>> GetChunks() const;
+ [[nodiscard]] BinaryNinja::DataBuffer ToDataBuffer() const;
+ };
+
+ class ProcessorState
+ {
+ public:
+ std::vector<std::string> analyzingFiles;
+ std::vector<std::string> 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<File> Start() const;
+ void Cancel() const;
+
+ ProcessorState GetState() const;
+ };
+
void RunMatcher(const BinaryNinja::BinaryView &view);
bool IsInstructionVariant(const BinaryNinja::LowLevelILFunction &function, BinaryNinja::ExprId idx);