Skip to content

Commit

Permalink
Merge pull request #3 from Workshell/develop
Browse files Browse the repository at this point in the history
#2: Fixed issue with default directory type handler
  • Loading branch information
lkinsella authored Nov 28, 2019
2 parents d9c692c + 4949fd4 commit 49a5638
Showing 1 changed file with 6 additions and 47 deletions.
53 changes: 6 additions & 47 deletions Src/Workshell.PE/DataDirectory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ public DataContent GetContent()

public async Task<DataContent> GetContentAsync()
{
if (VirtualAddress == 0)
if (VirtualAddress == 0 || Size == 0)
{
return null;
}

switch (DirectoryType)
{
Expand Down Expand Up @@ -137,56 +139,13 @@ public async Task<DataContent> GetContentAsync()
default:
{
var calc = _image.GetCalculator();
var fileOffset = calc.VAToOffset(VirtualAddress);
var location = new Location(_image, fileOffset, calc.OffsetToRVA(fileOffset), VirtualAddress, Size, Size);
var fileOffset = calc.RVAToOffset(VirtualAddress);
var va = _imageBase + VirtualAddress;
var location = new Location(_image, fileOffset, VirtualAddress, va, Size, Size);

return new DataContent(_image, this, location);
}
}

/*
if (data_dir.VirtualAddress == 0) // No content so no point...
return null;
if (dir_content == null)
{
switch (dir_type)
{
case DataDirectoryType.ExportTable:
dir_content = new ExportTableContent(this,image_base);
break;
case DataDirectoryType.ImportTable:
dir_content = new ImportTableContent(this,image_base);
break;
case DataDirectoryType.Debug:
dir_content = new DebugContent(this,image_base);
break;
case DataDirectoryType.LoadConfigTable:
dir_content = new LoadConfigTableContent(this,image_base);
break;
case DataDirectoryType.TLSTable:
dir_content = new TLSTableContent(this,image_base);
break;
case DataDirectoryType.BaseRelocationTable:
dir_content = new RelocationTableContent(this,image_base);
break;
case DataDirectoryType.CLRRuntimeHeader:
dir_content = new CLRContent(this,image_base);
break;
case DataDirectoryType.ResourceTable:
dir_content = new ResourceTableContent(this,image_base);
break;
case DataDirectoryType.CertificateTable:
dir_content = new CertificateTableContent(this,image_base);
break;
default:
dir_content = null;
break;
}
}
return dir_content;
*/
}

public string GetSectionName()
Expand Down

0 comments on commit 49a5638

Please sign in to comment.