Add in utility function for recasting objects as array of pointers of objects.

This commit is contained in:
Mike Auty
2017-10-05 00:10:02 +01:00
parent 88fa13bbdd
commit 5fbc90e699
+6
View File
@@ -19,3 +19,9 @@ def pointer_to_string(pointer, count, errors = 'replace'):
raise ValueError("pointer_to_string requires a positive count")
char = pointer.dereference()
return char.cast("string", max_length = count, errors = errors)
def array_of_pointers(array, count, subtype = None):
"""Takes an object, and recasts it as an array of pointers to subtype"""
subtype_pointer = objects.templates.ObjectTemplate(objects.Pointer, type_name = 'pointer', subtype = subtype)
return array.cast("array", count = count, subtype = subtype_pointer)