From 28d5961606f74157c14a50f939d9a6d656617b5d Mon Sep 17 00:00:00 2001 From: Lloyd Kinsella Date: Tue, 7 Aug 2018 16:27:00 +0100 Subject: [PATCH] Tweaks around naming conventions. --- Src/Workshell.PE/Content/CLR/CLR.cs | 13 +++++++--- Src/Workshell.PE/Content/CLR/CLRHeader.cs | 2 +- Src/Workshell.PE/Content/CLR/CLRMetaData.cs | 2 +- Src/Workshell.PE/DataDirectory.cs | 18 +++++++------ src/Workshell.PE/Content/Certificate.cs | 9 +++++-- .../Content/Debug/DebugDirectory.cs | 9 +++++-- .../Content/Exports/ExportDirectory.cs | 25 +++++++++++-------- .../Content/Exports/ExportTable.cs | 6 ++--- src/Workshell.PE/Content/Exports/Exports.cs | 2 +- .../Imports/DelayedImportAddressTables.cs | 2 +- .../Content/Imports/DelayedImportDirectory.cs | 9 +++++-- .../Imports/DelayedImportHintNameTable.cs | 2 +- .../Content/Imports/DelayedImports.cs | 2 +- .../Content/Imports/ImportAddressTables.cs | 2 +- .../Content/Imports/ImportDirectory.cs | 9 +++++-- .../Content/Imports/ImportHintNameTable.cs | 2 +- src/Workshell.PE/Content/Imports/Imports.cs | 2 +- .../Content/LoadConfigurationDirectory.cs | 9 +++++-- .../Content/Relocation/RelocationTable.cs | 9 +++++-- src/Workshell.PE/Content/TLSDirectory.cs | 11 +++++--- 20 files changed, 96 insertions(+), 49 deletions(-) diff --git a/Src/Workshell.PE/Content/CLR/CLR.cs b/Src/Workshell.PE/Content/CLR/CLR.cs index fbda28e..35cfe84 100644 --- a/Src/Workshell.PE/Content/CLR/CLR.cs +++ b/Src/Workshell.PE/Content/CLR/CLR.cs @@ -7,7 +7,7 @@ namespace Workshell.PE.Content { public sealed class CLR : DataContent { - internal CLR(PortableExecutableImage image, DataDirectory directory, Location location, CLRHeader header, CLRMetaData metaData) : base(image, directory, location) + private CLR(PortableExecutableImage image, DataDirectory directory, Location location, CLRHeader header, CLRMetaData metaData) : base(image, directory, location) { Header = header; MetaData = metaData; @@ -15,7 +15,12 @@ internal CLR(PortableExecutableImage image, DataDirectory directory, Location lo #region Static Methods - internal static async Task LoadAsync(PortableExecutableImage image) + public static CLR Get(PortableExecutableImage image) + { + return GetAsync(image).GetAwaiter().GetResult(); + } + + public static async Task GetAsync(PortableExecutableImage image) { if (!image.NTHeaders.DataDirectories.Exists(DataDirectoryType.CLRRuntimeHeader)) return null; @@ -30,8 +35,8 @@ internal static async Task LoadAsync(PortableExecutableImage image) var fileOffset = calc.RVAToOffset(section, dataDirectory.VirtualAddress); var imageBase = image.NTHeaders.OptionalHeader.ImageBase; var location = new Location(fileOffset, dataDirectory.VirtualAddress, imageBase + dataDirectory.VirtualAddress, dataDirectory.Size, dataDirectory.Size, section); - var header = await CLRHeader.LoadAsync(image, location).ConfigureAwait(false); - var metaData = await CLRMetaData.LoadAsync(image, header).ConfigureAwait(false); + var header = await CLRHeader.GetAsync(image, location).ConfigureAwait(false); + var metaData = await CLRMetaData.GetAsync(image, header).ConfigureAwait(false); return new CLR(image, dataDirectory, location, header, metaData); } diff --git a/Src/Workshell.PE/Content/CLR/CLRHeader.cs b/Src/Workshell.PE/Content/CLR/CLRHeader.cs index 7040e3e..7be3338 100644 --- a/Src/Workshell.PE/Content/CLR/CLRHeader.cs +++ b/Src/Workshell.PE/Content/CLR/CLRHeader.cs @@ -75,7 +75,7 @@ internal CLRHeader(Location location, IMAGE_COR20_HEADER header) #region Static Methods - internal static async Task LoadAsync(PortableExecutableImage image, Location clrLocation) + internal static async Task GetAsync(PortableExecutableImage image, Location clrLocation) { var size = Marshal.SizeOf(); var location = new Location(clrLocation.FileOffset, clrLocation.RelativeVirtualAddress, clrLocation.VirtualAddress, size.ToUInt32(), size.ToUInt32(), clrLocation.Section); diff --git a/Src/Workshell.PE/Content/CLR/CLRMetaData.cs b/Src/Workshell.PE/Content/CLR/CLRMetaData.cs index 79e89ac..e53cc46 100644 --- a/Src/Workshell.PE/Content/CLR/CLRMetaData.cs +++ b/Src/Workshell.PE/Content/CLR/CLRMetaData.cs @@ -23,7 +23,7 @@ internal CLRMetaData(PortableExecutableImage image, Location location, CLRMetaDa #region Static Methods - internal static async Task LoadAsync(PortableExecutableImage image, CLRHeader header) + internal static async Task GetAsync(PortableExecutableImage image, CLRHeader header) { var calc = image.GetCalculator(); var imageBase = image.NTHeaders.OptionalHeader.ImageBase; diff --git a/Src/Workshell.PE/DataDirectory.cs b/Src/Workshell.PE/DataDirectory.cs index f2b74b8..bfebb28 100644 --- a/Src/Workshell.PE/DataDirectory.cs +++ b/Src/Workshell.PE/DataDirectory.cs @@ -92,21 +92,23 @@ public async Task GetContentAsync() case DataDirectoryType.LoadConfigTable: return await LoadConfigurationDirectory.GetAsync(_image).ConfigureAwait(false); case DataDirectoryType.TLSTable: - return await TLSDirectory.LoadAsync(_image).ConfigureAwait(false); + return await TLSDirectory.GetAsync(_image).ConfigureAwait(false); case DataDirectoryType.CertificateTable: - return await Certificate.LoadAsync(_image).ConfigureAwait(false); + return await Certificate.GetAsync(_image).ConfigureAwait(false); case DataDirectoryType.CLRRuntimeHeader: - return await CLR.LoadAsync(_image).ConfigureAwait(false); + return await CLR.GetAsync(_image).ConfigureAwait(false); case DataDirectoryType.Debug: - return await DebugDirectory.LoadAsync(_image).ConfigureAwait(false); + return await DebugDirectory.GetAsync(_image).ConfigureAwait(false); case DataDirectoryType.BaseRelocationTable: - return await RelocationTable.LoadAsync(_image).ConfigureAwait(false); + return await RelocationTable.GetAsync(_image).ConfigureAwait(false); case DataDirectoryType.ExportTable: - return await ExportDirectory.LoadAsync(_image).ConfigureAwait(false); + return await ExportDirectory.GetAsync(_image).ConfigureAwait(false); case DataDirectoryType.ImportTable: - return await ImportDirectory.LoadAsync(_image).ConfigureAwait(false); + return await ImportDirectory.GetAsync(_image).ConfigureAwait(false); case DataDirectoryType.DelayImportDescriptor: - return await DelayedImportDirectory.LoadAsync(_image).ConfigureAwait(false); + return await DelayedImportDirectory.GetAsync(_image).ConfigureAwait(false); + case DataDirectoryType.ExceptionTable: + return await ExceptionTable.GetAsync(_image).ConfigureAwait(false); default: { var calc = _image.GetCalculator(); diff --git a/src/Workshell.PE/Content/Certificate.cs b/src/Workshell.PE/Content/Certificate.cs index f7890be..28678c9 100644 --- a/src/Workshell.PE/Content/Certificate.cs +++ b/src/Workshell.PE/Content/Certificate.cs @@ -20,7 +20,7 @@ public enum CertificateType : ushort public sealed class Certificate : DataContent { - internal Certificate(PortableExecutableImage image, DataDirectory directory, Location location, WIN_CERTIFICATE cert) : base(image, directory, location) + private Certificate(PortableExecutableImage image, DataDirectory directory, Location location, WIN_CERTIFICATE cert) : base(image, directory, location) { Length = cert.dwLength; Revision = cert.wRevision; @@ -29,7 +29,12 @@ internal Certificate(PortableExecutableImage image, DataDirectory directory, Loc #region Static Methods - public static async Task LoadAsync(PortableExecutableImage image) + public static Certificate Get(PortableExecutableImage image) + { + return GetAsync(image).GetAwaiter().GetResult(); + } + + public static async Task GetAsync(PortableExecutableImage image) { if (!image.NTHeaders.DataDirectories.Exists(DataDirectoryType.CertificateTable)) return null; diff --git a/src/Workshell.PE/Content/Debug/DebugDirectory.cs b/src/Workshell.PE/Content/Debug/DebugDirectory.cs index 4dd691b..b227e9a 100644 --- a/src/Workshell.PE/Content/Debug/DebugDirectory.cs +++ b/src/Workshell.PE/Content/Debug/DebugDirectory.cs @@ -15,7 +15,7 @@ public sealed class DebugDirectory : DataContent, IEnumerable LoadAsync(PortableExecutableImage image) + public DebugDirectory Get(PortableExecutableImage image) + { + return GetAsync(image).GetAwaiter().GetResult(); + } + + public static async Task GetAsync(PortableExecutableImage image) { if (!image.NTHeaders.DataDirectories.Exists(DataDirectoryType.Debug)) return null; diff --git a/src/Workshell.PE/Content/Exports/ExportDirectory.cs b/src/Workshell.PE/Content/Exports/ExportDirectory.cs index adaca32..2b7e8ef 100644 --- a/src/Workshell.PE/Content/Exports/ExportDirectory.cs +++ b/src/Workshell.PE/Content/Exports/ExportDirectory.cs @@ -17,7 +17,7 @@ public sealed class ExportDirectory : DataContent private readonly uint[] _functionNameAddresses; private readonly ushort[] _functionOrdinals; - internal ExportDirectory(PortableExecutableImage image, DataDirectory dataDirectory, Location location, IMAGE_EXPORT_DIRECTORY directory, + private ExportDirectory(PortableExecutableImage image, DataDirectory dataDirectory, Location location, IMAGE_EXPORT_DIRECTORY directory, string name, uint[] functionAddresses, uint[] functionNameAddresses, ushort[] functionOrdinals) : base(image, dataDirectory, location) { _name = name; @@ -40,7 +40,12 @@ internal ExportDirectory(PortableExecutableImage image, DataDirectory dataDirect #region Static Methods - internal static async Task LoadAsync(PortableExecutableImage image) + public static ExportDirectory Get(PortableExecutableImage image) + { + return GetAsync(image).GetAwaiter().GetResult(); + } + + public static async Task GetAsync(PortableExecutableImage image) { if (!image.NTHeaders.DataDirectories.Exists(DataDirectoryType.ExportTable)) return null; @@ -65,10 +70,10 @@ internal static async Task LoadAsync(PortableExecutableImage im stream.Seek(offset.ToInt64(), SeekOrigin.Begin); var exportDirectory = await stream.ReadStructAsync(size).ConfigureAwait(false); - var name = await LoadNameAsync(calc, stream, exportDirectory).ConfigureAwait(false); - var functionAddresses = await LoadFunctionAddressesAsync(calc, stream, exportDirectory).ConfigureAwait(false); - var functionNameAddresses = await LoadFunctionNameAddressesAsync(calc, stream, exportDirectory).ConfigureAwait(false); - var functionOrdinals = await LoadFunctionOrdinalsAsync(calc, stream, exportDirectory).ConfigureAwait(false); + var name = await BuildNameAsync(calc, stream, exportDirectory).ConfigureAwait(false); + var functionAddresses = await BuildFunctionAddressesAsync(calc, stream, exportDirectory).ConfigureAwait(false); + var functionNameAddresses = await BuildFunctionNameAddressesAsync(calc, stream, exportDirectory).ConfigureAwait(false); + var functionOrdinals = await BuildFunctionOrdinalsAsync(calc, stream, exportDirectory).ConfigureAwait(false); return new ExportDirectory(image, dataDirectory, location, exportDirectory, name, functionAddresses, functionNameAddresses, functionOrdinals); } @@ -78,7 +83,7 @@ internal static async Task LoadAsync(PortableExecutableImage im } } - private static async Task LoadNameAsync(LocationCalculator calc, Stream stream, IMAGE_EXPORT_DIRECTORY directory) + private static async Task BuildNameAsync(LocationCalculator calc, Stream stream, IMAGE_EXPORT_DIRECTORY directory) { var builder = new StringBuilder(256); var offset = calc.RVAToOffset(directory.Name).ToInt64(); @@ -100,7 +105,7 @@ private static async Task LoadNameAsync(LocationCalculator calc, Stream return builder.ToString(); } - private static async Task LoadFunctionAddressesAsync(LocationCalculator calc, Stream stream, IMAGE_EXPORT_DIRECTORY directory) + private static async Task BuildFunctionAddressesAsync(LocationCalculator calc, Stream stream, IMAGE_EXPORT_DIRECTORY directory) { var offset = calc.RVAToOffset(directory.AddressOfFunctions).ToInt64(); @@ -114,7 +119,7 @@ private static async Task LoadFunctionAddressesAsync(LocationCalculator return results; } - private static async Task LoadFunctionNameAddressesAsync(LocationCalculator calc, Stream stream, IMAGE_EXPORT_DIRECTORY directory) + private static async Task BuildFunctionNameAddressesAsync(LocationCalculator calc, Stream stream, IMAGE_EXPORT_DIRECTORY directory) { var offset = calc.RVAToOffset(directory.AddressOfNames).ToInt64(); @@ -128,7 +133,7 @@ private static async Task LoadFunctionNameAddressesAsync(LocationCalcula return results; } - private static async Task LoadFunctionOrdinalsAsync(LocationCalculator calc, Stream stream, IMAGE_EXPORT_DIRECTORY directory) + private static async Task BuildFunctionOrdinalsAsync(LocationCalculator calc, Stream stream, IMAGE_EXPORT_DIRECTORY directory) { var offset = calc.RVAToOffset(directory.AddressOfNameOrdinals).ToInt64(); diff --git a/src/Workshell.PE/Content/Exports/ExportTable.cs b/src/Workshell.PE/Content/Exports/ExportTable.cs index 3ff616d..983ff40 100644 --- a/src/Workshell.PE/Content/Exports/ExportTable.cs +++ b/src/Workshell.PE/Content/Exports/ExportTable.cs @@ -19,7 +19,7 @@ protected ExportTable(PortableExecutableImage image, DataDirectory directory, Lo public static async Task> GetFunctionAddressTableAsync(PortableExecutableImage image, ExportDirectory directory = null) { if (directory == null) - directory = await ExportDirectory.LoadAsync(image).ConfigureAwait(false); + directory = await ExportDirectory.GetAsync(image).ConfigureAwait(false); var calc = image.GetCalculator(); var section = calc.RVAToSection(directory.AddressOfFunctions); @@ -53,7 +53,7 @@ public static async Task> GetFunctionAddressTableAsync(Portabl public static async Task> GetNameAddressTableAsync(PortableExecutableImage image, ExportDirectory directory = null) { if (directory == null) - directory = await ExportDirectory.LoadAsync(image).ConfigureAwait(false); + directory = await ExportDirectory.GetAsync(image).ConfigureAwait(false); var calc = image.GetCalculator(); var section = calc.RVAToSection(directory.AddressOfNames); @@ -87,7 +87,7 @@ public static async Task> GetNameAddressTableAsync(PortableExe public static async Task> GetOrdinalTableAsync(PortableExecutableImage image, ExportDirectory directory = null) { if (directory == null) - directory = await ExportDirectory.LoadAsync(image).ConfigureAwait(false); + directory = await ExportDirectory.GetAsync(image).ConfigureAwait(false); var calc = image.GetCalculator(); var section = calc.RVAToSection(directory.AddressOfNameOrdinals); diff --git a/src/Workshell.PE/Content/Exports/Exports.cs b/src/Workshell.PE/Content/Exports/Exports.cs index c36e95f..b0a9b98 100644 --- a/src/Workshell.PE/Content/Exports/Exports.cs +++ b/src/Workshell.PE/Content/Exports/Exports.cs @@ -25,7 +25,7 @@ internal Exports(Export[] exports) public static async Task GetAsync(PortableExecutableImage image) { - var directory = await ExportDirectory.LoadAsync(image).ConfigureAwait(false); + var directory = await ExportDirectory.GetAsync(image).ConfigureAwait(false); if (directory == null) return null; diff --git a/src/Workshell.PE/Content/Imports/DelayedImportAddressTables.cs b/src/Workshell.PE/Content/Imports/DelayedImportAddressTables.cs index 692fc3c..5fe0103 100644 --- a/src/Workshell.PE/Content/Imports/DelayedImportAddressTables.cs +++ b/src/Workshell.PE/Content/Imports/DelayedImportAddressTables.cs @@ -29,7 +29,7 @@ public static async Task GetAddressTableAsync(Portab private static async Task GetTableAsync(PortableExecutableImage image, DelayedImportDirectory directory, Func thunkHandler) { if (directory == null) - directory = await DelayedImportDirectory.LoadAsync(image).ConfigureAwait(false); + directory = await DelayedImportDirectory.GetAsync(image).ConfigureAwait(false); var calc = image.GetCalculator(); var stream = image.GetStream(); diff --git a/src/Workshell.PE/Content/Imports/DelayedImportDirectory.cs b/src/Workshell.PE/Content/Imports/DelayedImportDirectory.cs index b790f39..1c5a22d 100644 --- a/src/Workshell.PE/Content/Imports/DelayedImportDirectory.cs +++ b/src/Workshell.PE/Content/Imports/DelayedImportDirectory.cs @@ -12,13 +12,18 @@ namespace Workshell.PE.Content { public sealed class DelayedImportDirectory : ImportDirectoryBase { - internal DelayedImportDirectory(PortableExecutableImage image, DataDirectory directory, Location location, DelayedImportDirectoryEntry[] entries) : base(image, directory, location, entries) + private DelayedImportDirectory(PortableExecutableImage image, DataDirectory directory, Location location, DelayedImportDirectoryEntry[] entries) : base(image, directory, location, entries) { } #region Static Methods - internal static async Task LoadAsync(PortableExecutableImage image) + public static DelayedImportDirectory Get(PortableExecutableImage image) + { + return GetAsync(image).GetAwaiter().GetResult(); + } + + public static async Task GetAsync(PortableExecutableImage image) { if (!image.NTHeaders.DataDirectories.Exists(DataDirectoryType.DelayImportDescriptor)) return null; diff --git a/src/Workshell.PE/Content/Imports/DelayedImportHintNameTable.cs b/src/Workshell.PE/Content/Imports/DelayedImportHintNameTable.cs index d2084a7..a7b9dab 100644 --- a/src/Workshell.PE/Content/Imports/DelayedImportHintNameTable.cs +++ b/src/Workshell.PE/Content/Imports/DelayedImportHintNameTable.cs @@ -19,7 +19,7 @@ internal DelayedImportHintNameTable(PortableExecutableImage image, DataDirectory public static async Task GetAsync(PortableExecutableImage image, DelayedImportDirectory directory = null) { if (directory == null) - directory = await DelayedImportDirectory.LoadAsync(image).ConfigureAwait(false); + directory = await DelayedImportDirectory.GetAsync(image).ConfigureAwait(false); var entries = new Dictionary>(); var ilt = await DelayedImportAddressTables.GetLookupTableAsync(image, directory).ConfigureAwait(false); diff --git a/src/Workshell.PE/Content/Imports/DelayedImports.cs b/src/Workshell.PE/Content/Imports/DelayedImports.cs index 2577f1e..4a845e1 100644 --- a/src/Workshell.PE/Content/Imports/DelayedImports.cs +++ b/src/Workshell.PE/Content/Imports/DelayedImports.cs @@ -19,7 +19,7 @@ internal DelayedImports(DelayedImportLibrary[] libraries) : base(libraries) public static async Task GetAsync(PortableExecutableImage image) { - var directory = await DelayedImportDirectory.LoadAsync(image).ConfigureAwait(false); + var directory = await DelayedImportDirectory.GetAsync(image).ConfigureAwait(false); if (directory == null) return null; diff --git a/src/Workshell.PE/Content/Imports/ImportAddressTables.cs b/src/Workshell.PE/Content/Imports/ImportAddressTables.cs index d656c5d..4adcf94 100644 --- a/src/Workshell.PE/Content/Imports/ImportAddressTables.cs +++ b/src/Workshell.PE/Content/Imports/ImportAddressTables.cs @@ -29,7 +29,7 @@ public static async Task GetAddressTableAsync(PortableExecu private static async Task GetTableAsync(PortableExecutableImage image, ImportDirectory directory, Func thunkHandler) { if (directory == null) - directory = await ImportDirectory.LoadAsync(image).ConfigureAwait(false); + directory = await ImportDirectory.GetAsync(image).ConfigureAwait(false); var calc = image.GetCalculator(); var stream = image.GetStream(); diff --git a/src/Workshell.PE/Content/Imports/ImportDirectory.cs b/src/Workshell.PE/Content/Imports/ImportDirectory.cs index fe6ffd6..5989a42 100644 --- a/src/Workshell.PE/Content/Imports/ImportDirectory.cs +++ b/src/Workshell.PE/Content/Imports/ImportDirectory.cs @@ -12,13 +12,18 @@ namespace Workshell.PE.Content { public sealed class ImportDirectory : ImportDirectoryBase { - internal ImportDirectory(PortableExecutableImage image, DataDirectory directory, Location location, ImportDirectoryEntry[] entries) : base(image, directory, location, entries) + private ImportDirectory(PortableExecutableImage image, DataDirectory directory, Location location, ImportDirectoryEntry[] entries) : base(image, directory, location, entries) { } #region Static Methods - internal static async Task LoadAsync(PortableExecutableImage image) + public static ImportDirectory Get(PortableExecutableImage image) + { + return GetAsync(image).GetAwaiter().GetResult(); + } + + public static async Task GetAsync(PortableExecutableImage image) { if (!image.NTHeaders.DataDirectories.Exists(DataDirectoryType.ImportTable)) return null; diff --git a/src/Workshell.PE/Content/Imports/ImportHintNameTable.cs b/src/Workshell.PE/Content/Imports/ImportHintNameTable.cs index f7c25ee..490feea 100644 --- a/src/Workshell.PE/Content/Imports/ImportHintNameTable.cs +++ b/src/Workshell.PE/Content/Imports/ImportHintNameTable.cs @@ -19,7 +19,7 @@ internal ImportHintNameTable(PortableExecutableImage image, DataDirectory direct public static async Task GetAsync(PortableExecutableImage image, ImportDirectory directory = null) { if (directory == null) - directory = await ImportDirectory.LoadAsync(image).ConfigureAwait(false); + directory = await ImportDirectory.GetAsync(image).ConfigureAwait(false); var entries = new Dictionary>(); var ilt = await ImportAddressTables.GetLookupTableAsync(image, directory).ConfigureAwait(false); diff --git a/src/Workshell.PE/Content/Imports/Imports.cs b/src/Workshell.PE/Content/Imports/Imports.cs index cb18091..5d9eb63 100644 --- a/src/Workshell.PE/Content/Imports/Imports.cs +++ b/src/Workshell.PE/Content/Imports/Imports.cs @@ -19,7 +19,7 @@ internal Imports(ImportLibrary[] libraries) : base(libraries) public static async Task GetAsync(PortableExecutableImage image) { - var directory = await ImportDirectory.LoadAsync(image).ConfigureAwait(false); + var directory = await ImportDirectory.GetAsync(image).ConfigureAwait(false); if (directory == null) return null; diff --git a/src/Workshell.PE/Content/LoadConfigurationDirectory.cs b/src/Workshell.PE/Content/LoadConfigurationDirectory.cs index 5b9f8fb..2da8dfe 100644 --- a/src/Workshell.PE/Content/LoadConfigurationDirectory.cs +++ b/src/Workshell.PE/Content/LoadConfigurationDirectory.cs @@ -12,7 +12,7 @@ namespace Workshell.PE.Content { public sealed class LoadConfigurationDirectory : DataContent { - internal LoadConfigurationDirectory(PortableExecutableImage image, DataDirectory dataDirectory, Location location, IMAGE_LOAD_CONFIG_DIRECTORY32 directory) : base(image, dataDirectory, location) + private LoadConfigurationDirectory(PortableExecutableImage image, DataDirectory dataDirectory, Location location, IMAGE_LOAD_CONFIG_DIRECTORY32 directory) : base(image, dataDirectory, location) { Size = directory.Size; TimeDateStamp = directory.TimeDateStamp; @@ -39,7 +39,7 @@ internal LoadConfigurationDirectory(PortableExecutableImage image, DataDirectory GuardFlags = directory.GuardFlags; } - internal LoadConfigurationDirectory(PortableExecutableImage image, DataDirectory dataDirectory, Location location, IMAGE_LOAD_CONFIG_DIRECTORY64 directory) : base(image, dataDirectory, location) + private LoadConfigurationDirectory(PortableExecutableImage image, DataDirectory dataDirectory, Location location, IMAGE_LOAD_CONFIG_DIRECTORY64 directory) : base(image, dataDirectory, location) { Size = directory.Size; TimeDateStamp = directory.TimeDateStamp; @@ -68,6 +68,11 @@ internal LoadConfigurationDirectory(PortableExecutableImage image, DataDirectory #region Static Methods + public static LoadConfigurationDirectory Get(PortableExecutableImage image) + { + return GetAsync(image).GetAwaiter().GetResult(); + } + public static async Task GetAsync(PortableExecutableImage image) { if (!image.NTHeaders.DataDirectories.Exists(DataDirectoryType.LoadConfigTable)) diff --git a/src/Workshell.PE/Content/Relocation/RelocationTable.cs b/src/Workshell.PE/Content/Relocation/RelocationTable.cs index ca4724d..cb3a03c 100644 --- a/src/Workshell.PE/Content/Relocation/RelocationTable.cs +++ b/src/Workshell.PE/Content/Relocation/RelocationTable.cs @@ -13,7 +13,7 @@ public sealed class RelocationTable : DataContent, IEnumerable { private readonly RelocationBlock[] _blocks; - internal RelocationTable(PortableExecutableImage image, DataDirectory directory, Location location, RelocationBlock[] blocks) : base(image, directory, location) + private RelocationTable(PortableExecutableImage image, DataDirectory directory, Location location, RelocationBlock[] blocks) : base(image, directory, location) { _blocks = blocks; @@ -22,7 +22,12 @@ internal RelocationTable(PortableExecutableImage image, DataDirectory directory, #region Static Methods - internal static async Task LoadAsync(PortableExecutableImage image) + public static RelocationTable Get(PortableExecutableImage image) + { + return GetAsync(image).GetAwaiter().GetResult(); + } + + public static async Task GetAsync(PortableExecutableImage image) { if (!image.NTHeaders.DataDirectories.Exists(DataDirectoryType.BaseRelocationTable)) return null; diff --git a/src/Workshell.PE/Content/TLSDirectory.cs b/src/Workshell.PE/Content/TLSDirectory.cs index c3867f2..ed59961 100644 --- a/src/Workshell.PE/Content/TLSDirectory.cs +++ b/src/Workshell.PE/Content/TLSDirectory.cs @@ -11,7 +11,7 @@ namespace Workshell.PE.Content { public sealed class TLSDirectory : DataContent { - internal TLSDirectory(PortableExecutableImage image, DataDirectory dataDirectory, Location location, IMAGE_TLS_DIRECTORY32 directory) : base(image, dataDirectory, location) + private TLSDirectory(PortableExecutableImage image, DataDirectory dataDirectory, Location location, IMAGE_TLS_DIRECTORY32 directory) : base(image, dataDirectory, location) { StartAddress = directory.StartAddress; EndAddress = directory.EndAddress; @@ -21,7 +21,7 @@ internal TLSDirectory(PortableExecutableImage image, DataDirectory dataDirectory Characteristics = directory.Characteristics; } - internal TLSDirectory(PortableExecutableImage image, DataDirectory dataDirectory, Location location, IMAGE_TLS_DIRECTORY64 directory) : base(image, dataDirectory, location) + private TLSDirectory(PortableExecutableImage image, DataDirectory dataDirectory, Location location, IMAGE_TLS_DIRECTORY64 directory) : base(image, dataDirectory, location) { StartAddress = directory.StartAddress; EndAddress = directory.EndAddress; @@ -33,7 +33,12 @@ internal TLSDirectory(PortableExecutableImage image, DataDirectory dataDirectory #region Static Methods - public static async Task LoadAsync(PortableExecutableImage image) + public static TLSDirectory Get(PortableExecutableImage image) + { + return GetAsync(image).GetAwaiter().GetResult(); + } + + public static async Task GetAsync(PortableExecutableImage image) { if (!image.NTHeaders.DataDirectories.Exists(DataDirectoryType.TLSTable)) return null;