mirror of
https://github.com/claunia/libexeinfo.git
synced 2025-12-16 19:14:24 +00:00
Add segments to interface.
This commit is contained in:
@@ -111,6 +111,7 @@ namespace libexeinfo
|
||||
public IEnumerable<Architecture> Architectures => new[] {Architecture.M68K};
|
||||
public OperatingSystem RequiredOperatingSystem { get; private set; }
|
||||
public IEnumerable<string> Strings { get; private set; }
|
||||
public IEnumerable<Segment> Segments { get; private set; }
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
@@ -144,6 +145,31 @@ namespace libexeinfo
|
||||
}
|
||||
}
|
||||
|
||||
Segments = new []
|
||||
{
|
||||
new Segment
|
||||
{
|
||||
Name = ".text",
|
||||
Flags = $"{(PrgFlags)(Header.flags & 0xFFCF)} {(PrgSharing)(Header.flags & PF_SHARE_MASK)}",
|
||||
Offset = 0x1C,
|
||||
Size = Header.text_len
|
||||
},
|
||||
new Segment
|
||||
{
|
||||
Name = ".data",
|
||||
Flags = "",
|
||||
Offset = 0x1C + Header.text_len,
|
||||
Size = Header.data_len
|
||||
},
|
||||
new Segment
|
||||
{
|
||||
Name = ".bss",
|
||||
Flags = "",
|
||||
Offset = 0,
|
||||
Size = Header.bss_len
|
||||
}
|
||||
};
|
||||
|
||||
RequiredOperatingSystem = new OperatingSystem {Name = Header.mint == MINT_SIGNATURE ? "MiNT" : "Atari TOS"};
|
||||
|
||||
if(ResourceStream == null) return;
|
||||
|
||||
@@ -78,6 +78,7 @@ namespace libexeinfo
|
||||
public OperatingSystem RequiredOperatingSystem =>
|
||||
new OperatingSystem {Name = "Unknown"}; // TODO: Know
|
||||
public IEnumerable<string> Strings { get; }
|
||||
public IEnumerable<Segment> Segments { get; }
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
|
||||
@@ -63,5 +63,9 @@ namespace libexeinfo
|
||||
/// List of all strings available in the executable resources, if any
|
||||
/// </summary>
|
||||
IEnumerable<string> Strings { get; }
|
||||
/// <summary>
|
||||
/// List of all file segments, if any
|
||||
/// </summary>
|
||||
IEnumerable<Segment> Segments { get; }
|
||||
}
|
||||
}
|
||||
@@ -83,6 +83,7 @@ namespace libexeinfo
|
||||
public IEnumerable<Architecture> Architectures => new[] {CpuToArchitecture(header.cpu_type)};
|
||||
public OperatingSystem RequiredOperatingSystem { get; private set; }
|
||||
public IEnumerable<string> Strings { get; }
|
||||
public IEnumerable<Segment> Segments { get; }
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
|
||||
@@ -116,6 +116,7 @@ namespace libexeinfo
|
||||
public IEnumerable<Architecture> Architectures => new[] {Architecture.I86};
|
||||
public OperatingSystem RequiredOperatingSystem { get; private set; }
|
||||
public IEnumerable<string> Strings { get; private set; }
|
||||
public IEnumerable<Segment> Segments { get; }
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
|
||||
@@ -97,6 +97,7 @@ namespace libexeinfo
|
||||
};
|
||||
public OperatingSystem RequiredOperatingSystem { get; private set; }
|
||||
public IEnumerable<string> Strings { get; }
|
||||
public IEnumerable<Segment> Segments { get; private set; }
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
@@ -388,6 +389,28 @@ namespace libexeinfo
|
||||
else NonResidentNames = null;
|
||||
}
|
||||
}
|
||||
|
||||
if(segments == null) return;
|
||||
|
||||
List<Segment> libsegs = new List<Segment>();
|
||||
foreach(SegmentEntry seg in segments)
|
||||
{
|
||||
Segment libseg = new Segment
|
||||
{
|
||||
Flags = $"{(SegmentFlags)(seg.dwFlags & SEGMENT_FLAGS_MASK)}",
|
||||
Name =
|
||||
((SegmentType)(seg.dwFlags & SEGMENT_TYPE_MASK)) == SegmentType.Code ? ".text" : ".data",
|
||||
Offset = seg.dwLogicalSectorOffset * 16,
|
||||
Size = seg.dwSegmentLength
|
||||
};
|
||||
|
||||
if(Header.target_os == TargetOS.OS2 && (seg.dwFlags & (int)SegmentFlags.Huge) == (int)SegmentFlags.Huge)
|
||||
libseg.Size *= 16;
|
||||
|
||||
libsegs.Add(libseg);
|
||||
}
|
||||
|
||||
Segments = libsegs.OrderBy(s => s.Offset).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -81,6 +81,7 @@ namespace libexeinfo
|
||||
new[] {COFF.MachineTypeToArchitecture(Header.coff.machine)};
|
||||
public OperatingSystem RequiredOperatingSystem { get; private set; }
|
||||
public IEnumerable<string> Strings { get; }
|
||||
public IEnumerable<Segment> Segments { get; }
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
|
||||
@@ -33,4 +33,24 @@ namespace libexeinfo
|
||||
public int MinorVersion;
|
||||
public string Subsystem;
|
||||
}
|
||||
|
||||
public struct Segment
|
||||
{
|
||||
/// <summary>
|
||||
/// Standardized segment type name: .text, .data, .rsrc, .bss, etc.
|
||||
/// </summary>
|
||||
public string Name;
|
||||
/// <summary>
|
||||
/// String containing the name of the flags that the executable set accordingly.
|
||||
/// </summary>
|
||||
public string Flags;
|
||||
/// <summary>
|
||||
/// Offset from start of file where the segment starts. 0 if segment is memory only
|
||||
/// </summary>
|
||||
public long Offset;
|
||||
/// <summary>
|
||||
/// Size in bytes of the segment.
|
||||
/// </summary>
|
||||
public long Size;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user