mirror of
https://github.com/claunia/libexeinfo.git
synced 2025-12-16 19:14:24 +00:00
Correct handling of BeOS resource index.
This commit is contained in:
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
namespace libexeinfo.BeOS
|
namespace libexeinfo.BeOS
|
||||||
{
|
{
|
||||||
static class Consts
|
public static class Consts
|
||||||
{
|
{
|
||||||
internal const int RESOURCES_HEADER_MAGIC = 0x444F1000;
|
internal const int RESOURCES_HEADER_MAGIC = 0x444F1000;
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ namespace libexeinfo.BeOS
|
|||||||
|
|
||||||
if(header.magic != Consts.RESOURCES_HEADER_MAGIC) return null;
|
if(header.magic != Consts.RESOURCES_HEADER_MAGIC) return null;
|
||||||
|
|
||||||
ResourceIndexEntry[] indexes = new ResourceIndexEntry[header.resource_count];
|
|
||||||
pos = header.index_section_offset;
|
pos = header.index_section_offset;
|
||||||
buffer = new byte[Marshal.SizeOf(typeof(ResourceIndexSectionHeader))];
|
buffer = new byte[Marshal.SizeOf(typeof(ResourceIndexSectionHeader))];
|
||||||
if(pos + buffer.Length > data.Length) return null;
|
if(pos + buffer.Length > data.Length) return null;
|
||||||
@@ -33,7 +32,11 @@ namespace libexeinfo.BeOS
|
|||||||
BigEndianMarshal.ByteArrayToStructureLittleEndian<ResourceIndexSectionHeader>(buffer);
|
BigEndianMarshal.ByteArrayToStructureLittleEndian<ResourceIndexSectionHeader>(buffer);
|
||||||
pos += (uint)buffer.Length;
|
pos += (uint)buffer.Length;
|
||||||
|
|
||||||
for(int i = 0; i < header.resource_count; i++)
|
ResourceIndexEntry[] indexes =
|
||||||
|
new ResourceIndexEntry[(indexHeader.index_section_size -
|
||||||
|
Marshal.SizeOf(typeof(ResourceIndexSectionHeader))) /
|
||||||
|
Marshal.SizeOf(typeof(ResourceIndexEntry))];
|
||||||
|
for(int i = 0; i < indexes.Length; i++)
|
||||||
{
|
{
|
||||||
buffer = new byte[Marshal.SizeOf(typeof(ResourceIndexEntry))];
|
buffer = new byte[Marshal.SizeOf(typeof(ResourceIndexEntry))];
|
||||||
Array.Copy(data, pos, buffer, 0, buffer.Length);
|
Array.Copy(data, pos, buffer, 0, buffer.Length);
|
||||||
@@ -88,10 +91,10 @@ namespace libexeinfo.BeOS
|
|||||||
id = infos[i].id,
|
id = infos[i].id,
|
||||||
index = infos[i].index,
|
index = infos[i].index,
|
||||||
name = names[i],
|
name = names[i],
|
||||||
data = new byte[indexes[i].size]
|
data = new byte[indexes[infos[i].index - 1].size]
|
||||||
};
|
};
|
||||||
|
|
||||||
Array.Copy(data, indexes[i].offset, rez.data, 0, rez.data.Length);
|
Array.Copy(data, indexes[infos[i].index - 1].offset, rez.data, 0, rez.data.Length);
|
||||||
|
|
||||||
thisRezzes.Add(rez);
|
thisRezzes.Add(rez);
|
||||||
rezzes.Remove(types[i]);
|
rezzes.Remove(types[i]);
|
||||||
@@ -118,7 +121,6 @@ namespace libexeinfo.BeOS
|
|||||||
|
|
||||||
if(header.magic != Consts.RESOURCES_HEADER_MAGIC) return null;
|
if(header.magic != Consts.RESOURCES_HEADER_MAGIC) return null;
|
||||||
|
|
||||||
ResourceIndexEntry[] indexes = new ResourceIndexEntry[header.resource_count];
|
|
||||||
pos = header.index_section_offset;
|
pos = header.index_section_offset;
|
||||||
buffer = new byte[Marshal.SizeOf(typeof(ResourceIndexSectionHeader))];
|
buffer = new byte[Marshal.SizeOf(typeof(ResourceIndexSectionHeader))];
|
||||||
if(pos + buffer.Length > data.Length) return null;
|
if(pos + buffer.Length > data.Length) return null;
|
||||||
@@ -128,7 +130,11 @@ namespace libexeinfo.BeOS
|
|||||||
BigEndianMarshal.ByteArrayToStructureBigEndian<ResourceIndexSectionHeader>(buffer);
|
BigEndianMarshal.ByteArrayToStructureBigEndian<ResourceIndexSectionHeader>(buffer);
|
||||||
pos += (uint)buffer.Length;
|
pos += (uint)buffer.Length;
|
||||||
|
|
||||||
for(int i = 0; i < header.resource_count; i++)
|
ResourceIndexEntry[] indexes =
|
||||||
|
new ResourceIndexEntry[(indexHeader.index_section_size -
|
||||||
|
Marshal.SizeOf(typeof(ResourceIndexSectionHeader))) /
|
||||||
|
Marshal.SizeOf(typeof(ResourceIndexEntry))];
|
||||||
|
for(int i = 0; i < indexes.Length; i++)
|
||||||
{
|
{
|
||||||
buffer = new byte[Marshal.SizeOf(typeof(ResourceIndexEntry))];
|
buffer = new byte[Marshal.SizeOf(typeof(ResourceIndexEntry))];
|
||||||
Array.Copy(data, pos, buffer, 0, buffer.Length);
|
Array.Copy(data, pos, buffer, 0, buffer.Length);
|
||||||
@@ -183,10 +189,10 @@ namespace libexeinfo.BeOS
|
|||||||
id = infos[i].id,
|
id = infos[i].id,
|
||||||
index = infos[i].index,
|
index = infos[i].index,
|
||||||
name = names[i],
|
name = names[i],
|
||||||
data = new byte[indexes[i].size]
|
data = new byte[indexes[infos[i].index - 1].size]
|
||||||
};
|
};
|
||||||
|
|
||||||
Array.Copy(data, indexes[i].offset, rez.data, 0, rez.data.Length);
|
Array.Copy(data, indexes[infos[i].index - 1].offset, rez.data, 0, rez.data.Length);
|
||||||
|
|
||||||
thisRezzes.Add(rez);
|
thisRezzes.Add(rez);
|
||||||
rezzes.Remove(types[i]);
|
rezzes.Remove(types[i]);
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ namespace libexeinfo
|
|||||||
public Version[] Versions;
|
public Version[] Versions;
|
||||||
public ResourceNode WindowsResourcesRoot;
|
public ResourceNode WindowsResourcesRoot;
|
||||||
WindowsHeader64 winHeader;
|
WindowsHeader64 winHeader;
|
||||||
public BeOS.ResourceTypeBlock[] beosResources;
|
public BeOS.ResourceTypeBlock[] BeosResources;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="T:libexeinfo.PE" /> class.
|
/// Initializes a new instance of the <see cref="T:libexeinfo.PE" /> class.
|
||||||
@@ -389,7 +389,7 @@ namespace libexeinfo
|
|||||||
buffer = new byte[rsrc.sizeOfRawData];
|
buffer = new byte[rsrc.sizeOfRawData];
|
||||||
BaseStream.Position = rsrc.pointerToRawData;
|
BaseStream.Position = rsrc.pointerToRawData;
|
||||||
BaseStream.Read(buffer, 0, buffer.Length);
|
BaseStream.Read(buffer, 0, buffer.Length);
|
||||||
beosResources = BeOS.Resources.Decode(buffer);
|
BeosResources = BeOS.Resources.Decode(buffer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user