Skip to content

Can't parse resources in a resource-only PE files #465

@justanotheranonymoususer

Description

Sample file:
shell32.zip

Sample script:

import sys
import pefile

def list_resource_types(dll_path):
    try:
        pe = pefile.PE(dll_path)
        
        if hasattr(pe, 'DIRECTORY_ENTRY_RESOURCE'):
            resource_types = []
            for entry in pe.DIRECTORY_ENTRY_RESOURCE.entries:
                if entry.name is not None:
                    resource_types.append(entry.name)
                else:
                    resource_types.append(f"Type {entry.id}")
            
            print(f"Resource types in {dll_path}:")
            for rt in resource_types:
                print(f"  - {rt}")
        else:
            print(f"No resources found in {dll_path}")
            
    except Exception as e:
        print(f"Error: {e}")

dll_path = sys.argv[1]
list_resource_types(dll_path)

Execution:

> .\list.py ".\shell32.dll"
No resources found in .\shell32.dll

> .\list.py C:\Windows\System32\shell32.dll
Resource types in C:\Windows\System32\shell32.dll:
  - MUI
  - TYPELIB
  - Type 16
  - Type 24

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions