-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
1,127 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using Workshell.PE.Native; | ||
|
||
namespace Workshell.PE | ||
{ | ||
|
||
public sealed class CLRContent : DataDirectoryContent | ||
{ | ||
|
||
private CLRHeader header; | ||
private CLRMetaData meta_data; | ||
|
||
internal CLRContent(DataDirectory dataDirectory, ulong imageBase) : base(dataDirectory, imageBase) | ||
{ | ||
LocationCalculator calc = DataDirectory.Directories.Reader.GetCalculator(); | ||
Stream stream = DataDirectory.Directories.Reader.GetStream(); | ||
|
||
LoadHeader(calc, stream, imageBase); | ||
LoadMetaData(calc, stream, imageBase); | ||
} | ||
|
||
#region Methods | ||
|
||
private void LoadHeader(LocationCalculator calc, Stream stream, ulong imageBase) | ||
{ | ||
ulong offset = calc.RVAToOffset(DataDirectory.VirtualAddress); | ||
uint size = Convert.ToUInt32(Utils.SizeOf<IMAGE_COR20_HEADER>()); | ||
Location location = new Location(offset,DataDirectory.VirtualAddress,imageBase + DataDirectory.VirtualAddress,size,size); | ||
Section section = calc.RVAToSection(DataDirectory.VirtualAddress); | ||
|
||
stream.Seek(Convert.ToInt64(offset),SeekOrigin.Begin); | ||
|
||
IMAGE_COR20_HEADER clr_header = Utils.Read<IMAGE_COR20_HEADER>(stream,Convert.ToInt32(size)); | ||
|
||
header = new CLRHeader(this,clr_header,location,section); | ||
} | ||
|
||
private void LoadMetaData(LocationCalculator calc, Stream stream, ulong imageBase) | ||
{ | ||
meta_data = new CLRMetaData(this,imageBase); | ||
} | ||
|
||
#endregion | ||
|
||
#region Properties | ||
|
||
public CLRHeader Header | ||
{ | ||
get | ||
{ | ||
return header; | ||
} | ||
} | ||
|
||
public CLRMetaData MetaData | ||
{ | ||
get | ||
{ | ||
return meta_data; | ||
} | ||
} | ||
|
||
#endregion | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using Workshell.PE.Native; | ||
|
||
namespace Workshell.PE | ||
{ | ||
|
||
public sealed class CLRDataDirectory | ||
{ | ||
|
||
private IMAGE_DATA_DIRECTORY data_dir; | ||
|
||
internal CLRDataDirectory(IMAGE_DATA_DIRECTORY dataDirectory) | ||
{ | ||
data_dir = dataDirectory; | ||
} | ||
|
||
#region Static Methods | ||
|
||
public static bool IsNullOrEmpty(DataDirectory dataDirectory) | ||
{ | ||
if (dataDirectory == null) | ||
return true; | ||
|
||
if (dataDirectory.VirtualAddress == 0) | ||
return true; | ||
|
||
if (dataDirectory.Size == 0) | ||
return true; | ||
|
||
return false; | ||
} | ||
|
||
#endregion | ||
|
||
#region Methods | ||
|
||
public override string ToString() | ||
{ | ||
return String.Format("0x{0:X8}+{1}",data_dir.VirtualAddress,data_dir.Size); | ||
} | ||
|
||
#endregion | ||
|
||
#region Properties | ||
|
||
public uint VirtualAddress | ||
{ | ||
get | ||
{ | ||
return data_dir.VirtualAddress; | ||
} | ||
} | ||
|
||
public uint Size | ||
{ | ||
get | ||
{ | ||
return data_dir.Size; | ||
} | ||
} | ||
|
||
#endregion | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.