diff --git a/getnetguids.py b/getnetguids.py index 790df69..d91b4cc 100644 --- a/getnetguids.py +++ b/getnetguids.py @@ -122,6 +122,39 @@ def get_assembly_guids(assembly_path): guid_heap_index_length = 2 if ord(tilde[6:7]) & 0x02 == 0x00 else 4 blob_heap_index_length = 2 if ord(tilde[6:7]) & 0x04 == 0x00 else 4 + # print "Reserved 0x01: {0}".format([tilde[7:8]]) + # print "Table list: {0}".format([tilde[8:16]]) + + tables_present = [x == "1" for x in bin(struct.unpack("= 2**(16 - 5) for x in has_custom_attribute_tables]) + big_custom_attribute_type = any([row_counts[x] >= 2**(16 - 3) for x in custom_attribute_type_tables]) + big_resolution_scope = any([row_counts[x] >= 2**(16 - 2) for x in resolution_scope_tables]) + big_type_def_or_ref = any([row_counts[x] >= 2**(16 - 2) for x in type_def_or_ref_tables]) + big_member_ref_parent = any([row_counts[x] >= 2**(16 - 3) for x in member_ref_tables]) + # Build row length for each type up to CustomAttr row_type_widths = [ # 0x00 Module = Generation (2 bytes) + Name (String heap index) + Mvid (Guid heap index) + @@ -130,11 +163,11 @@ def get_assembly_guids(assembly_path): # 0x01 TypeRef = ResolutionScope (ResolutionScope index) + TypeName (String heap) + # TypeNamespace (String heap) - 2 + (strings_heap_index_length * 2), + (4 if big_resolution_scope else 2) + (strings_heap_index_length * 2), # 0x02 TypeDef = Flags(2 bytes) + TypeName(String heap index) +TypeNamespace(String heap index)+ # Extends (TypeDefOrRef index) + FieldList (index into field table) + # MethodList (index into MethodDef table) + ? - 10 + (strings_heap_index_length * 2), + 8 + (4 if big_type_def_or_ref else 2) + (strings_heap_index_length * 2), 0, # 0x03 None # 0x04 Field = Flags (2 bytes) + Name (String heap index) + Signature (Blob heap index) 2 + strings_heap_index_length + blob_heap_index_length, @@ -146,48 +179,60 @@ def get_assembly_guids(assembly_path): # 0x08 Param = Flags (2 bytes) + Sequence (2 bytes) + Name (String heap index) 4 + strings_heap_index_length, # 0x09 InterfaceImpl = Class (TypeDef index) + Interface (TypeDefOrRef index) - 4, + 2 + (4 if big_type_def_or_ref else 2), # 0x0a MemberRef = Class(MemberRefParent) + Name(String heap index) + Signature(Blob heap index) - 2 + strings_heap_index_length + blob_heap_index_length, + (4 if big_member_ref_parent else 2) + strings_heap_index_length + blob_heap_index_length, # 0x0b Constant = Type (?) + Parent + Value (Blob heap index) 4 + blob_heap_index_length, # 0x0c CustomAttr = Parent + Type (CustomAttributeType) + Value (Blob heap index) - 4 + blob_heap_index_length, + (4 if big_has_custom_attribute else 2) + (4 if big_custom_attribute_type else 2) + blob_heap_index_length, # Don't care about the rest ] - # print "Reserved 0x01: {0}".format([tilde[7:8]]) - # print "Table list: {0}".format([tilde[8:16]]) - - tables_present = [x == "1" for x in bin(struct.unpack("