mirror of
https://github.com/claunia/libexeinfo.git
synced 2025-12-16 19:14:24 +00:00
Handle OpenVMS ELF notes, as the only ones found using 64-bit fields.
This commit is contained in:
@@ -382,8 +382,10 @@ namespace libexeinfo
|
|||||||
buffer = new byte[sections[i].sh_size];
|
buffer = new byte[sections[i].sh_size];
|
||||||
BaseStream.Read(buffer, 0, buffer.Length);
|
BaseStream.Read(buffer, 0, buffer.Length);
|
||||||
|
|
||||||
if(sectionNames[i] == ".interp" || sectionNames[i] == ".dynstr" || sectionNames[i] == ".comment" ||
|
if(sectionNames[i] == ".interp" || sectionNames[i] == ".dynstr" ||
|
||||||
sectionNames[i] == ".strtab" || sectionNames[i] == ".stab.indexstr")
|
sectionNames[i] == ".comment" ||
|
||||||
|
sectionNames[i] == ".strtab" || sectionNames[i] == ".stab.indexstr" ||
|
||||||
|
sectionNames[i] == ".debug_str")
|
||||||
{
|
{
|
||||||
strStart = 0;
|
strStart = 0;
|
||||||
len = 0;
|
len = 0;
|
||||||
@@ -426,12 +428,31 @@ namespace libexeinfo
|
|||||||
else if(sectionNames[i].StartsWith(".note") && buffer.Length > 12)
|
else if(sectionNames[i].StartsWith(".note") && buffer.Length > 12)
|
||||||
{
|
{
|
||||||
pos = 0;
|
pos = 0;
|
||||||
|
string noteAsString = Encoding.ASCII.GetString(buffer);
|
||||||
|
|
||||||
|
// Only IA-64 OpenVMS ELF uses 64-bit fields inside the note!
|
||||||
|
bool openVms = noteAsString.Contains("IPF/VMS");
|
||||||
|
|
||||||
while(pos < buffer.Length)
|
while(pos < buffer.Length)
|
||||||
{
|
{
|
||||||
uint namesz = BitConverter.ToUInt32(buffer, pos);
|
uint namesz;
|
||||||
uint descsz = BitConverter.ToUInt32(buffer, pos + 4);
|
uint descsz;
|
||||||
uint notetype = BitConverter.ToUInt32(buffer, pos + 8);
|
uint notetype;
|
||||||
pos += 12;
|
|
||||||
|
if(openVms)
|
||||||
|
{
|
||||||
|
namesz = (uint)BitConverter.ToUInt64(buffer, pos);
|
||||||
|
descsz = (uint)BitConverter.ToUInt64(buffer, pos + 8);
|
||||||
|
notetype = (uint)BitConverter.ToUInt64(buffer, pos + 16);
|
||||||
|
pos += 24;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
namesz = BitConverter.ToUInt32(buffer, pos);
|
||||||
|
descsz = BitConverter.ToUInt32(buffer, pos + 4);
|
||||||
|
notetype = BitConverter.ToUInt32(buffer, pos + 8);
|
||||||
|
pos += 12;
|
||||||
|
}
|
||||||
|
|
||||||
if(IsBigEndian)
|
if(IsBigEndian)
|
||||||
{
|
{
|
||||||
@@ -449,15 +470,14 @@ namespace libexeinfo
|
|||||||
|
|
||||||
pos += (int)namesz;
|
pos += (int)namesz;
|
||||||
|
|
||||||
pos += pos % 4 != 0 ? 4 - pos % 4 : 0;
|
pos += pos % (openVms ? 8 : 4) != 0 ? (openVms ? 8 : 4) - pos % (openVms ? 8 : 4) : 0;
|
||||||
|
|
||||||
Array.Copy(buffer, pos, note.contents, 0, descsz);
|
Array.Copy(buffer, pos, note.contents, 0, descsz);
|
||||||
pos += (int)descsz;
|
pos += (int)descsz;
|
||||||
pos += pos % 4 != 0 ? 4 - pos % 4 : 0;
|
pos += pos % (openVms ? 8 : 4) != 0 ? (openVms ? 8 : 4) - pos % (openVms ? 8 : 4) : 0;
|
||||||
|
|
||||||
string notename = note.type != 1 ? $"{sectionNames[i]}.{note.type}" : sectionNames[i];
|
string notename = note.type != 1 ? $"{sectionNames[i]}.{note.type}" : sectionNames[i];
|
||||||
if(!notes.ContainsKey(notename))
|
if(!notes.ContainsKey(notename)) notes.Add(notename, note);
|
||||||
notes.Add(notename, note);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user