Skip to content

Commit

Permalink
Added calls on Imports and Exports making it easier to get an instanc…
Browse files Browse the repository at this point in the history
…e from just an ExecutabeImage.
  • Loading branch information
lkinsella committed Jul 1, 2016
1 parent ac4eab1 commit d190b00
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Src/Workshell.PE/Content/Delayed Imports/DelayImports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,27 @@ internal DelayImports(Tuple<string,DelayImportAddressTable,DelayImportHintNameTa

#region Static Methods

public static DelayImports Get(ExecutableImage image)
{
DelayImportDirectory directory = DelayImportDirectory.Get(image);

if (directory == null)
return null;

DelayImportAddressTables ilt = DelayImportAddressTables.GetLookupTable(directory);

if (ilt == null)
return null;

DelayImportHintNameTable hnt = DelayImportHintNameTable.Get(directory);

if (hnt == null)
return null;

return Get(ilt, hnt);
}


public static DelayImports Get(DelayImportAddressTables ilt, DelayImportHintNameTable hnTable)
{
List<Tuple<string, DelayImportAddressTable, DelayImportHintNameTable>> libraries = new List<Tuple<string, DelayImportAddressTable, DelayImportHintNameTable>>();
Expand Down
25 changes: 25 additions & 0 deletions Src/Workshell.PE/Content/Exports/Exports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,31 @@ internal Exports(Export[] exports)

#region Static Methods

public static Exports Get(ExecutableImage image)
{
ExportDirectory directory = ExportDirectory.Get(image);

if (directory == null)
return null;

ExportTable<uint> function_addresses = ExportTable<uint>.GetFunctionAddressTable(directory);

if (function_addresses == null)
return null;

ExportTable<uint> name_addresses = ExportTable<uint>.GetNameAddressTable(directory);

if (name_addresses == null)
return null;

ExportTable<ushort> ordinals = ExportTable<short>.GetOrdinalTable(directory);

if (ordinals == null)
return null;

return Get(directory, function_addresses, name_addresses, ordinals);
}

public static Exports Get(ExportDirectory directory, ExportTable<uint> functionAddresses, ExportTable<uint> nameAddresses, ExportTable<ushort> ordinals)
{
LocationCalculator calc = directory.DataDirectory.Directories.Image.GetCalculator();
Expand Down
20 changes: 20 additions & 0 deletions Src/Workshell.PE/Content/Imports/Imports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@ internal Imports(Tuple<string,ImportAddressTable,ImportHintNameTable>[] importLi

#region Static Methods

public static Imports Get(ExecutableImage image)
{
ImportDirectory directory = ImportDirectory.Get(image);

if (directory == null)
return null;

ImportAddressTables ilt = ImportAddressTables.GetLookupTable(directory);

if (ilt == null)
return null;

ImportHintNameTable hnt = ImportHintNameTable.Get(directory);

if (hnt == null)
return null;

return Get(ilt, hnt);
}

public static Imports Get(ImportAddressTables ilt, ImportHintNameTable hnTable)
{
List<Tuple<string, ImportAddressTable, ImportHintNameTable>> libraries = new List<Tuple<string, ImportAddressTable, ImportHintNameTable>>();
Expand Down

0 comments on commit d190b00

Please sign in to comment.