From c85d93f505f53f921dd2d7b2d774ff75979261f7 Mon Sep 17 00:00:00 2001 From: plafosse Date: Thu, 7 Jul 2016 21:44:20 -0400 Subject: Adding DemangleMS API and extending types for C++ --- python/__init__.py | 20 ++++++++++++++++++++ python/generator.cpp | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'python') diff --git a/python/__init__.py b/python/__init__.py index 0c983fe2..fbe6fa61 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -5646,6 +5646,26 @@ def get_time_since_last_update_check(): def updates_checked(): core.BNUpdatesChecked() +def get_qualified_name(names): + out = "" + for i,a in enumerate(names): + if i == 0: + out += a + else: + out += "::" + a + return out + +def demangle_ms(arch, mangledName): + handle = ctypes.POINTER(core.BNType)() + outName = ctypes.POINTER(ctypes.c_char_p)() + outSize = ctypes.c_ulonglong() + names = [] + if core.BNDemangleMS(arch.handle, mangledName, ctypes.byref(handle), ctypes.byref(outName), ctypes.byref(outSize)): + for i in xrange(outSize.value): + names.append(outName[i]) + return (Type(handle), names) + return (None, mangledName) + bundled_plugin_path = core.BNGetBundledPluginDirectory() user_plugin_path = core.BNGetUserPluginDirectory() diff --git a/python/generator.cpp b/python/generator.cpp index f9790619..08485315 100644 --- a/python/generator.cpp +++ b/python/generator.cpp @@ -98,10 +98,10 @@ void OutputType(FILE* out, Type* type, bool isReturnType = false, bool isCallbac fprintf(out, "ctypes.c_double"); break; case StructureTypeClass: - fprintf(out, "%s", type->GetStructure()->GetName().c_str()); + fprintf(out, "%s", type->GetQualifiedName(type->GetStructure()->GetName()).c_str()); break; case EnumerationTypeClass: - fprintf(out, "%s", type->GetEnumeration()->GetName().c_str()); + fprintf(out, "%s", type->GetQualifiedName(type->GetEnumeration()->GetName()).c_str()); break; case PointerTypeClass: if (isCallback || (type->GetChildType()->GetClass() == VoidTypeClass)) -- cgit v1.3.1 From b6b76645f0a5e7e631363c4b4ae6383993669abf Mon Sep 17 00:00:00 2001 From: Jordan Wiens Date: Sat, 9 Jul 2016 02:32:21 -0400 Subject: few small typos and add convenience getter/setter for function.name --- python/__init__.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'python') diff --git a/python/__init__.py b/python/__init__.py index fbe6fa61..98b16b95 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -192,7 +192,7 @@ class FileMetadata(object): @property def filename(self): - """Backing filename""" + """Backing filename (read-only)""" return core.BNGetFilename(self.handle) @filename.setter @@ -201,7 +201,7 @@ class FileMetadata(object): @property def modified(self): - """Boolean result of whether the file is modified""" + """Boolean result of whether the file is modified (read-only)""" return core.BNIsFileModified(self.handle) @modified.setter @@ -218,7 +218,7 @@ class FileMetadata(object): @property def has_database(self): - """Whether the FileMetadata is backed by a database""" + """Whether the FileMetadata is backed by a database (read-only)""" return core.BNIsBackedByDatabase(self.handle) @property @@ -231,7 +231,7 @@ class FileMetadata(object): @property def offset(self): - """Current offset into the file""" + """Current offset into the file (read-only)""" return core.BNGetCurrentOffset(self.handle) @offset.setter @@ -247,7 +247,7 @@ class FileMetadata(object): @property def saved(self): - """Set to mark file as saved""" + """Boolean returns if the file has changed since last save. Set to mark whether the file is saved.""" return not core.BNIsFileModified(self.handle) @saved.setter @@ -2208,6 +2208,20 @@ class Function(object): def __del__(self): core.BNFreeFunction(self.handle) + @property + def name(self): + """Symbol name for the function""" + return self.symbol.name + + @name.setter + def name(self,value): + if value is None: + if self.symbol is not None: + self.view.undefine_user_symbol(self.symbol) + else: + symbol = Symbol(FunctionSymbol,self.start,value) + self.view.define_user_symbol(symbol) + @property def view(self): """Function view (read-only)""" @@ -2886,7 +2900,7 @@ class FunctionGraph(object): @property def function(self): - """Function for a function graph(read-only)""" + """Function for a function graph (read-only)""" func = core.BNGetFunctionForFunctionGraph(self.handle) if func is None: return None -- cgit v1.3.1