From 7acfe6f01fc669bf08cd301631601a24486bee74 Mon Sep 17 00:00:00 2001 From: Josh Ferrell Date: Mon, 1 Mar 2021 14:03:17 -0500 Subject: Add methods for creating wide char types --- binaryninjaapi.h | 2 ++ binaryninjacore.h | 2 ++ python/types.py | 12 +++++++++++- type.cpp | 12 ++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/binaryninjaapi.h b/binaryninjaapi.h index eac2f6b8..cd52dc44 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -2618,6 +2618,7 @@ __attribute__ ((format (printf, 1, 2))) static Ref BoolType(); static Ref IntegerType(size_t width, const Confidence& sign, const std::string& altName = ""); static Ref FloatType(size_t width, const std::string& typeName = ""); + static Ref WideCharType(size_t width, const std::string& typeName = ""); static Ref StructureType(Structure* strct); static Ref NamedType(NamedTypeReference* ref, size_t width = 0, size_t align = 1); static Ref NamedType(const QualifiedName& name, Type* type); @@ -2738,6 +2739,7 @@ __attribute__ ((format (printf, 1, 2))) static TypeBuilder BoolType(); static TypeBuilder IntegerType(size_t width, const Confidence& sign, const std::string& altName = ""); static TypeBuilder FloatType(size_t width, const std::string& typeName = ""); + static TypeBuilder WideCharType(size_t width, const std::string& typeName = ""); static TypeBuilder StructureType(Structure* strct); static TypeBuilder NamedType(NamedTypeReference* ref, size_t width = 0, size_t align = 1); static TypeBuilder NamedType(const QualifiedName& name, Type* type); diff --git a/binaryninjacore.h b/binaryninjacore.h index b6cefa1d..425a8d3c 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -4254,6 +4254,7 @@ __attribute__ ((format (printf, 1, 2))) BINARYNINJACOREAPI BNType* BNCreateBoolType(void); BINARYNINJACOREAPI BNType* BNCreateIntegerType(size_t width, BNBoolWithConfidence* sign, const char* altName); BINARYNINJACOREAPI BNType* BNCreateFloatType(size_t width, const char* altName); + BINARYNINJACOREAPI BNType* BNCreateWideCharType(size_t width, const char* altName); BINARYNINJACOREAPI BNType* BNCreateStructureType(BNStructure* s); BINARYNINJACOREAPI BNType* BNCreateEnumerationType(BNArchitecture* arch, BNEnumeration* e, size_t width, bool isSigned); BINARYNINJACOREAPI BNType* BNCreatePointerType(BNArchitecture* arch, BNTypeWithConfidence* type, @@ -4274,6 +4275,7 @@ __attribute__ ((format (printf, 1, 2))) BINARYNINJACOREAPI BNTypeBuilder* BNCreateBoolTypeBuilder(void); BINARYNINJACOREAPI BNTypeBuilder* BNCreateIntegerTypeBuilder(size_t width, BNBoolWithConfidence* sign, const char* altName); BINARYNINJACOREAPI BNTypeBuilder* BNCreateFloatTypeBuilder(size_t width, const char* altName); + BINARYNINJACOREAPI BNTypeBuilder* BNCreateWideCharTypeBuilder(size_t width, const char* altName); BINARYNINJACOREAPI BNTypeBuilder* BNCreateStructureTypeBuilder(BNStructure* s); BINARYNINJACOREAPI BNTypeBuilder* BNCreateEnumerationTypeBuilder(BNArchitecture* arch, BNEnumeration* e, size_t width, bool isSigned); BINARYNINJACOREAPI BNTypeBuilder* BNCreatePointerTypeBuilder(BNArchitecture* arch, BNTypeWithConfidence* type, diff --git a/python/types.py b/python/types.py index e6ab5c2b..76f8c7f0 100644 --- a/python/types.py +++ b/python/types.py @@ -811,13 +811,23 @@ class Type(object): @classmethod def float(self, width, altname=""): """ - ``float`` class method for creating an floating point Types. + ``float`` class method for creating floating point Types. :param int width: width of the floating point number in bytes :param str altname: alternate name for type """ return Type(core.BNCreateFloatTypeBuilder(width, altname)) + @classmethod + def wide_char(self, width, altname=""): + """ + ``wide_char`` class method for creating wide char Types. + + :param int width: width of the wide character in bytes + :param str altname: alternate name for type + """ + return Type(core.BNCreateWideCharTypeBuilder(width, altname)) + @classmethod def structure_type(self, structure_type): return Type(core.BNCreateStructureTypeBuilder(structure_type.handle)) diff --git a/type.cpp b/type.cpp index ead27768..08597f1a 100644 --- a/type.cpp +++ b/type.cpp @@ -708,6 +708,12 @@ Ref Type::FloatType(size_t width, const string& altName) } +Ref Type::WideCharType(size_t width, const string& altName) +{ + return new Type(BNCreateWideCharType(width, altName.c_str())); +} + + Ref Type::StructureType(Structure* strct) { return new Type(BNCreateStructureType(strct->GetObject())); @@ -1340,6 +1346,12 @@ TypeBuilder TypeBuilder::FloatType(size_t width, const string& altName) } +TypeBuilder TypeBuilder::WideCharType(size_t width, const string& altName) +{ + return TypeBuilder(BNCreateWideCharTypeBuilder(width, altName.c_str())); +} + + TypeBuilder TypeBuilder::StructureType(Structure* strct) { return TypeBuilder(BNCreateStructureTypeBuilder(strct->GetObject())); -- cgit v1.3.1