File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -27,9 +27,11 @@ def __repr__(self):
2727 return f"StringSlice(address={ self .address :#x} , length={ self .length :#x} , data={ self .data !r} )"
2828
2929 @classmethod
30- def create_binary_ninja_type (
31- cls , bv : BinaryView
32- ): # TODO: check for existence of type
30+ def check_binary_ninja_type_exists (cls , bv : BinaryView ) -> bool :
31+ return bv .get_type_by_name ("RustStringSlice" ) is not None
32+
33+ @classmethod
34+ def create_binary_ninja_type (cls , bv : BinaryView ):
3335 if bv .arch is not None :
3436 rust_string_slice_bn_type_obj = StructureBuilder .create (packed = True )
3537 rust_string_slice_bn_type_obj .append (
@@ -337,10 +339,12 @@ def run(self):
337339
338340
339341def action_recover_string_slices_from_code (bv : BinaryView ):
340- RustStringSlice .create_binary_ninja_type (bv )
342+ if not RustStringSlice .check_binary_ninja_type_exists (bv ):
343+ RustStringSlice .create_binary_ninja_type (bv )
341344 RecoverStringFromCodeTask (bv = bv ).start ()
342345
343346
344347def action_recover_string_slices_from_readonly_data (bv : BinaryView ):
345- RustStringSlice .create_binary_ninja_type (bv )
348+ if not RustStringSlice .check_binary_ninja_type_exists (bv ):
349+ RustStringSlice .create_binary_ninja_type (bv )
346350 RecoverStringFromReadOnlyDataTask (bv = bv ).start ()
You can’t perform that action at this time.
0 commit comments