Table of Contents

Class ResourceDirectory

Namespace
AsmResolver.PE.Win32Resources
Assembly
AsmResolver.PE.dll

Represents a single directory containing Win32 resources of a PE image.

public class ResourceDirectory : IResourceEntry, IOwnedCollectionElement<ResourceDirectory>
Inheritance
ResourceDirectory
Implements
Derived
Inherited Members

Constructors

ResourceDirectory()

Initializes a new resource directory entry.

protected ResourceDirectory()

ResourceDirectory(ResourceType)

Creates a new resource directory defined by its resource type.

public ResourceDirectory(ResourceType type)

Parameters

type ResourceType

The type.

ResourceDirectory(string)

Creates a new named resource directory.

public ResourceDirectory(string name)

Parameters

name string

The name of the directory.

ResourceDirectory(uint)

Creates a new resource directory defined by a numeric identifier.

public ResourceDirectory(uint id)

Parameters

id uint

The identifier.

Properties

Characteristics

Gets or sets the flags of the directory.

public uint Characteristics { get; set; }

Property Value

uint

Remarks

This field is reserved and is usually set to zero.

Entries

Gets a collection of entries that are stored in the directory.

public IList<IResourceEntry> Entries { get; }

Property Value

IList<IResourceEntry>

Id

Gets or sets the ID of the entry.

public uint Id { get; set; }

Property Value

uint

MajorVersion

Gets or sets the major version number of the directory.

public ushort MajorVersion { get; set; }

Property Value

ushort

MinorVersion

Gets or sets the minor version number of the directory.

public ushort MinorVersion { get; set; }

Property Value

ushort

Name

Gets or sets the name of the entry.

public string? Name { get; set; }

Property Value

string

ParentDirectory

Gets the parent directory the entry is stored in.

public ResourceDirectory? ParentDirectory { get; }

Property Value

ResourceDirectory

TimeDateStamp

Gets or sets the time that the resource data was created by the compiler.

public uint TimeDateStamp { get; set; }

Property Value

uint

Type

Gets the type of resources stored in the directory.

public ResourceType Type { get; set; }

Property Value

ResourceType

Methods

GetData(uint)

Looks up a data entry in the directory by its unique identifier.

public ResourceData GetData(uint id)

Parameters

id uint

The id of the data entry to lookup.

Returns

ResourceData

The data entry.

Exceptions

KeyNotFoundException

Occurs when no data entry with the provided identifier was found.

GetDirectory(ResourceType)

Looks up an directory by its resource type.

public ResourceDirectory GetDirectory(ResourceType type)

Parameters

type ResourceType

The type of resources to lookup.

Returns

ResourceDirectory

The directory.

Exceptions

KeyNotFoundException

Occurs when no directory with the provided identifier was found.

GetDirectory(uint)

Looks up an directory by its unique identifier.

public ResourceDirectory GetDirectory(uint id)

Parameters

id uint

The identifier of the directory to lookup.

Returns

ResourceDirectory

The directory.

Exceptions

KeyNotFoundException

Occurs when no directory with the provided identifier was found.

GetEntries()

Obtains the list of entries in the directory.

protected virtual IList<IResourceEntry> GetEntries()

Returns

IList<IResourceEntry>

The list of entries.

Remarks

This method is called upon initialization of the Entries property.

GetEntry(uint)

Looks up an entry in the directory by its unique identifier.

public IResourceEntry GetEntry(uint id)

Parameters

id uint

The identifier of the entry to lookup.

Returns

IResourceEntry

The entry.

Exceptions

KeyNotFoundException

Occurs when no entry with the provided identifier was found.

InsertOrReplaceEntry(IResourceEntry)

Replaces an existing entry with the same ID with the provided entry, or inserts the new entry into the directory.

public void InsertOrReplaceEntry(IResourceEntry entry)

Parameters

entry IResourceEntry

The entry to store in the directory.

RemoveEntry(ResourceType)

Removes a directory in the directory by its resource type.

public bool RemoveEntry(ResourceType type)

Parameters

type ResourceType

The type of resources to remove.

Returns

bool

true if the directory was found and removed, false otherwise.

RemoveEntry(uint)

Removes an entry in the directory by its unique identifier.

public bool RemoveEntry(uint id)

Parameters

id uint

The identifier of the entry to remove.

Returns

bool

true if the data entry was found and removed, false otherwise.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

TryGetData(uint, out ResourceData?)

Attempts to looks up a data entry in the directory by its unique identifier.

public bool TryGetData(uint id, out ResourceData? data)

Parameters

id uint

The identifier of the data entry to lookup.

data ResourceData

The found data entry, or null if none was found.

Returns

bool

true if the data entry was found, false otherwise.

TryGetDirectory(ResourceType, out ResourceDirectory?)

Attempts to looks up a directory by its resource type.

public bool TryGetDirectory(ResourceType type, out ResourceDirectory? directory)

Parameters

type ResourceType

The type of resources to lookup.

directory ResourceDirectory

The found directory, or null if none was found.

Returns

bool

true if the directory was found, false otherwise.

TryGetDirectory(uint, out ResourceDirectory?)

Attempts to looks up a directory by its unique identifier.

public bool TryGetDirectory(uint id, out ResourceDirectory? directory)

Parameters

id uint

The identifier of the directory to lookup.

directory ResourceDirectory

The found directory, or null if none was found.

Returns

bool

true if the directory was found, false otherwise.

TryGetEntry(uint, out IResourceEntry?)

Attempts to looks up an entry in the directory by its unique identifier.

public bool TryGetEntry(uint id, out IResourceEntry? entry)

Parameters

id uint

The identifier of the entry to lookup.

entry IResourceEntry

The found entry, or null if none was found.

Returns

bool

true if the entry was found, false otherwise.