|
1 | 1 |
|
2 | 2 | ########################################################################################
|
3 | 3 | ##
|
4 |
| -## This plugin is the client for the HashDB lookup service operated buy OALABS: |
| 4 | +## This plugin is the client for the HashDB lookup service operated by OALABS: |
5 | 5 | ##
|
6 | 6 | ## https://hashdb.openanalysis.net/
|
7 | 7 | ##
|
|
74 | 74 | ENUM_PREFIX = "hashdb_strings"
|
75 | 75 | NETNODE_NAME = "$hashdb"
|
76 | 76 |
|
| 77 | +ENUM_CREATED_SUCCESS = 1 |
| 78 | +SUFFIX_UPPER_LIMIT = 100 |
| 79 | + |
77 | 80 | #--------------------------------------------------------------------------
|
78 | 81 | # Setup Icon
|
79 | 82 | #--------------------------------------------------------------------------
|
@@ -654,11 +657,19 @@ def add_enums(enum_name, hash_list, enum_member_suffix = None, enum_size = 0):
|
654 | 657 | if not ida_enum.set_enum_width(enum_id, enum_size):
|
655 | 658 | return None
|
656 | 659 |
|
657 |
| - for member_name, value in hash_list: |
658 |
| - ida_enum.add_enum_member(enum_id, member_name if enum_member_suffix is None else member_name + '_' + enum_member_suffix, value) |
| 660 | + for name, value in hash_list: |
| 661 | + suffix = 0 |
| 662 | + final_name = name |
| 663 | + while (ida_enum.add_enum_member(enum_id, name, value) != ENUM_CREATED_SUCCESS): |
| 664 | + if suffix > SUFFIX_UPPER_LIMIT: |
| 665 | + raise HashDBError("Exceeded the upper limit for number of suffixes for enum name " + name) |
| 666 | + else: |
| 667 | + final_name = name + "_" + str(suffix) #new name becomes: name_0, name_1, name_2 etc... |
| 668 | + suffix += 1 |
659 | 669 | return enum_id
|
660 | 670 |
|
661 | 671 |
|
| 672 | + |
662 | 673 | def generate_enum_name(prefix: str) -> str:
|
663 | 674 | """
|
664 | 675 | Generates an enum name from a prefix
|
|
0 commit comments