Skip to content

Commit

Permalink
Added index property to Export and also a ReadBytes method to Utils.
Browse files Browse the repository at this point in the history
  • Loading branch information
lkinsella committed Jan 9, 2016
1 parent 6993d2d commit c1bc2b0
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 71 deletions.
68 changes: 0 additions & 68 deletions Src/Workshell.PE/Exports/ExportAddressTable.cs

This file was deleted.

11 changes: 9 additions & 2 deletions Src/Workshell.PE/Exports/ExportContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ public DataDirectoryType DirectoryType
public class Export
{

public Export(uint entryPoint, string name, int ord, string forwardName)
internal Export(int index, uint entryPoint, string name, int ord, string forwardName)
{
Index = index;
EntryPoint = entryPoint;
Name = name;
Ordinal = ord;
Expand All @@ -65,6 +66,12 @@ public override string ToString()

#region Properties

public int Index
{
get;
private set;
}

public uint EntryPoint
{
get;
Expand Down Expand Up @@ -227,7 +234,7 @@ private void LoadExports(Stream stream)
fwd_name = GetString(stream,fwd_offset);
}

Export export = new Export(function_address,name,Convert.ToInt32(ord + directory.Base),fwd_name);
Export export = new Export(i,function_address,name,Convert.ToInt32(ord + directory.Base),fwd_name);

exports.Add(export);
}
Expand Down
6 changes: 6 additions & 0 deletions Src/Workshell.PE/Exports/ExportTable.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand Down Expand Up @@ -33,6 +34,11 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
return GetEnumerator();
}

public byte[] GetBytes()
{
return Utils.ReadBytes(content.Section.Sections.Reader.Stream,location.Offset,location.Size);
}

#endregion

#region Properties
Expand Down
10 changes: 10 additions & 0 deletions Src/Workshell.PE/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ public static string ReadString(Stream stream)
return builder.ToString();
}

public static byte[] ReadBytes(Stream stream, long offset, long size)
{
byte[] buffer = new byte[size];

stream.Seek(offset,SeekOrigin.Begin);
stream.Read(buffer,0,buffer.Length);

return buffer;
}

public static void Write<T>(T structure, byte[] buffer, int startIndex, int count) where T : struct
{
IntPtr ptr = Marshal.AllocHGlobal(count);
Expand Down
1 change: 0 additions & 1 deletion Src/Workshell.PE/Workshell.PE.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
<Compile Include="DataDirectory.cs" />
<Compile Include="DOSHeader.cs" />
<Compile Include="DOSStub.cs" />
<Compile Include="Exports\ExportAddressTable.cs" />
<Compile Include="Exports\ExportDirectory.cs" />
<Compile Include="Exports\ExportContent.cs" />
<Compile Include="Exports\ExportTable.cs" />
Expand Down

0 comments on commit c1bc2b0

Please sign in to comment.