#
AssemblyRef
The AssemblyRef
table contains various information about other referenced external assemblies.
#
Get referenced assemblies
AssemblyRef.get_assemblyref_names(deduplicate: bool) -> List[str]
Get a list of referenced assembly names.
Parameters:
- deduplicate De-duplicate names.
Return value:
A list with referenced assembly names
Example:
# Import class DotNetPE from module dotnetfile
from dotnetfile import DotNetPE
# Create an instance of DotNetPE with the file path as a parameter
dotnet_file = DotNetPE('/Users/<username>/my_dotnet_assembly.exe')
# Check if the "AssemblyRef" table exists
if dotnet_file.metadata_table_exists('AssemblyRef'):
# Get referenced assemblies
assemblyref_names = dotnet_file.AssemblyRef.get_assemblyref_names()
# Print out the list of referenced assemblies
for assemblyref_name in assemblyref_names:
print(f'{assemblyref_name}')
#
Get referenced assemblies with their versions
AssemblyRef.get_assemblyref_names_with_versions(deduplicate: bool) -> Dict[str, Union[str, List[str]]]
Get a dictionary of referenced assembly names and their versions.
Parameters:
- deduplicate De-duplicate names.
Return value:
The resulting dictionaries have the following keys and values :
- Assembly str Version (can be a list)
Example:
# Import class DotNetPE from module dotnetfile
from dotnetfile import DotNetPE
from typing import List
# Create an instance of DotNetPE with the file path as a parameter
dotnet_file = DotNetPE('/Users/<username>/my_dotnet_assembly.exe')
# Check if the "AssemblyRef" table exists
if dotnet_file.metadata_table_exists('AssemblyRef'):
# Get referenced assemblies with their versions
assembly_names_with_versions = dotnet_file.AssemblyRef.get_assemblyref_names_with_versions(deduplicate=True)
# Print out assemblies with their versions
for assembly_name, assembly_version in assembly_names_with_versions.items():
if isinstance(assembly_version, List):
assembly_versions = ', '.join(assembly_version)
print(f'{assembly_name}: {assembly_versions}')
else:
print(f'{assembly_name}: {assembly_version}')
#
Get referenced cultures
AssemblyRef.get_assemblyref_cultures() -> List[str]
Get a list of referenced culture names.
Parameters:
-
Return value:
A list with referenced culture names
Example:
# Import class DotNetPE from module dotnetfile
from dotnetfile import DotNetPE
# Create an instance of DotNetPE with the file path as a parameter
dotnet_file = DotNetPE('/Users/<username>/my_dotnet_assembly.exe')
# Check if the "AssemblyRef" table exists
if dotnet_file.metadata_table_exists('AssemblyRef'):
# Get referenced cultures
culture_names = dotnet_file.AssemblyRef.get_assemblyref_cultures()
# Print out the list of referenced cultures
for culture_name in culture_names:
print(f'{culture_name}')