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
ResourceTypeThe type.
ResourceDirectory(string)
Creates a new named resource directory.
public ResourceDirectory(string name)
Parameters
name
stringThe name of the directory.
ResourceDirectory(uint)
Creates a new resource directory defined by a numeric identifier.
public ResourceDirectory(uint id)
Parameters
id
uintThe identifier.
Properties
Characteristics
Gets or sets the flags of the directory.
public uint Characteristics { get; set; }
Property Value
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
Id
Gets or sets the ID of the entry.
public uint Id { get; set; }
Property Value
MajorVersion
Gets or sets the major version number of the directory.
public ushort MajorVersion { get; set; }
Property Value
MinorVersion
Gets or sets the minor version number of the directory.
public ushort MinorVersion { get; set; }
Property Value
Name
Gets or sets the name of the entry.
public string? Name { get; set; }
Property Value
ParentDirectory
Gets the parent directory the entry is stored in.
public ResourceDirectory? ParentDirectory { get; }
Property Value
TimeDateStamp
Gets or sets the time that the resource data was created by the compiler.
public uint TimeDateStamp { get; set; }
Property Value
Type
Gets the type of resources stored in the directory.
public ResourceType Type { get; set; }
Property Value
Methods
GetData(uint)
Looks up a data entry in the directory by its unique identifier.
public ResourceData GetData(uint id)
Parameters
id
uintThe 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
ResourceTypeThe 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
uintThe 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
uintThe 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
IResourceEntryThe 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
ResourceTypeThe 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
uintThe 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
uintThe identifier of the data entry to lookup.
data
ResourceDataThe 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
ResourceTypeThe type of resources to lookup.
directory
ResourceDirectoryThe 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
uintThe identifier of the directory to lookup.
directory
ResourceDirectoryThe 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
uintThe identifier of the entry to lookup.
entry
IResourceEntryThe found entry, or
null
if none was found.
Returns
- bool
true
if the entry was found,false
otherwise.