Fixed bug in executables with no imports/exports
I now check for the existance of imports/exports in the data directory.
This commit is contained in:
parent
65ebaea880
commit
f8a3a70291
|
|
@ -665,6 +665,11 @@ $code = @"
|
||||||
|
|
||||||
function Get-Exports()
|
function Get-Exports()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if ($NTHeader.OptionalHeader.DataDirectory[0].VirtualAddress -eq 0) {
|
||||||
|
Write-Verbose 'Module does not contain any exports'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
# List all function Rvas in the export table
|
# List all function Rvas in the export table
|
||||||
$ExportPointer = [IntPtr] ($PEBaseAddr.ToInt64() + $NtHeader.OptionalHeader.DataDirectory[0].VirtualAddress)
|
$ExportPointer = [IntPtr] ($PEBaseAddr.ToInt64() + $NtHeader.OptionalHeader.DataDirectory[0].VirtualAddress)
|
||||||
|
|
@ -759,6 +764,11 @@ $code = @"
|
||||||
|
|
||||||
function Get-Imports()
|
function Get-Imports()
|
||||||
{
|
{
|
||||||
|
if ($NTHeader.OptionalHeader.DataDirectory[1].VirtualAddress -eq 0) {
|
||||||
|
Write-Verbose 'Module does not contain any imports'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
$FirstImageImportDescriptorPtr = [IntPtr] ($PEBaseAddr.ToInt64() + $NtHeader.OptionalHeader.DataDirectory[1].VirtualAddress)
|
$FirstImageImportDescriptorPtr = [IntPtr] ($PEBaseAddr.ToInt64() + $NtHeader.OptionalHeader.DataDirectory[1].VirtualAddress)
|
||||||
if ($OnDisk) { $FirstImageImportDescriptorPtr = Convert-RVAToFileOffset $FirstImageImportDescriptorPtr }
|
if ($OnDisk) { $FirstImageImportDescriptorPtr = Convert-RVAToFileOffset $FirstImageImportDescriptorPtr }
|
||||||
$ImportDescriptorPtr = $FirstImageImportDescriptorPtr
|
$ImportDescriptorPtr = $FirstImageImportDescriptorPtr
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue