mirror of
https://github.com/claunia/libexeinfo.git
synced 2025-12-16 19:14:24 +00:00
Add decoding for BeOS version resource.
This commit is contained in:
61
exeinfogui/BeOS/PanelBeVersion.xeto
Normal file
61
exeinfogui/BeOS/PanelBeVersion.xeto
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Panel xmlns="http://schema.picoe.ca/eto.forms" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
<StackLayout Orientation="Vertical" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Top">
|
||||||
|
<StackLayout Orientation="Horizontal">
|
||||||
|
<StackLayoutItem>
|
||||||
|
<Label ID="lblMajorVersion">Major version</Label>
|
||||||
|
</StackLayoutItem>
|
||||||
|
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch">
|
||||||
|
<TextBox ID="txtMajorVersion" ReadOnly="True"/>
|
||||||
|
</StackLayoutItem>
|
||||||
|
</StackLayout>
|
||||||
|
<StackLayout Orientation="Horizontal">
|
||||||
|
<StackLayoutItem>
|
||||||
|
<Label ID="lblMiddleVersion">Middle version</Label>
|
||||||
|
</StackLayoutItem>
|
||||||
|
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch">
|
||||||
|
<TextBox ID="txtMiddleVersion" ReadOnly="True"/>
|
||||||
|
</StackLayoutItem>
|
||||||
|
</StackLayout>
|
||||||
|
<StackLayout Orientation="Horizontal">
|
||||||
|
<StackLayoutItem>
|
||||||
|
<Label ID="lblMinorVersion">Minor version</Label>
|
||||||
|
</StackLayoutItem>
|
||||||
|
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch">
|
||||||
|
<TextBox ID="txtMinorVersion" ReadOnly="True"/>
|
||||||
|
</StackLayoutItem>
|
||||||
|
</StackLayout>
|
||||||
|
<StackLayout Orientation="Horizontal">
|
||||||
|
<StackLayoutItem>
|
||||||
|
<Label ID="lblVariety">Variety</Label>
|
||||||
|
</StackLayoutItem>
|
||||||
|
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch">
|
||||||
|
<TextBox ID="txtVariety" ReadOnly="True"/>
|
||||||
|
</StackLayoutItem>
|
||||||
|
</StackLayout>
|
||||||
|
<StackLayout Orientation="Horizontal">
|
||||||
|
<StackLayoutItem>
|
||||||
|
<Label ID="lblInternal">Internal</Label>
|
||||||
|
</StackLayoutItem>
|
||||||
|
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch">
|
||||||
|
<TextBox ID="txtInternal" ReadOnly="True"/>
|
||||||
|
</StackLayoutItem>
|
||||||
|
</StackLayout>
|
||||||
|
<StackLayout Orientation="Horizontal">
|
||||||
|
<StackLayoutItem>
|
||||||
|
<Label ID="lblShortInfo">Short information</Label>
|
||||||
|
</StackLayoutItem>
|
||||||
|
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch">
|
||||||
|
<TextBox ID="txtShortInfo" ReadOnly="True"/>
|
||||||
|
</StackLayoutItem>
|
||||||
|
</StackLayout>
|
||||||
|
<StackLayout Orientation="Horizontal">
|
||||||
|
<StackLayoutItem>
|
||||||
|
<Label ID="lblLongInfo">Long information</Label>
|
||||||
|
</StackLayoutItem>
|
||||||
|
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch">
|
||||||
|
<TextArea ID="txtLongInfo" ReadOnly="True"/>
|
||||||
|
</StackLayoutItem>
|
||||||
|
</StackLayout>
|
||||||
|
</StackLayout>
|
||||||
|
</Panel>
|
||||||
39
exeinfogui/BeOS/PanelBeVersion.xeto.cs
Normal file
39
exeinfogui/BeOS/PanelBeVersion.xeto.cs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
using System.Text;
|
||||||
|
using Eto.Forms;
|
||||||
|
using Eto.Serialization.Xaml;
|
||||||
|
using libexeinfo;
|
||||||
|
using libexeinfo.BeOS;
|
||||||
|
|
||||||
|
namespace exeinfogui.BeOS
|
||||||
|
{
|
||||||
|
public class PanelBeVersion : Panel
|
||||||
|
{
|
||||||
|
TextBox txtInternal;
|
||||||
|
TextArea txtLongInfo;
|
||||||
|
TextBox txtMajorVersion;
|
||||||
|
TextBox txtMiddleVersion;
|
||||||
|
TextBox txtMinorVersion;
|
||||||
|
TextBox txtShortInfo;
|
||||||
|
TextBox txtVariety;
|
||||||
|
|
||||||
|
public PanelBeVersion()
|
||||||
|
{
|
||||||
|
XamlReader.Load(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(byte[] data, bool bigEndian)
|
||||||
|
{
|
||||||
|
VersionInfo versionInfo = bigEndian
|
||||||
|
? BigEndianMarshal.ByteArrayToStructureBigEndian<VersionInfo>(data)
|
||||||
|
: BigEndianMarshal.ByteArrayToStructureLittleEndian<VersionInfo>(data);
|
||||||
|
|
||||||
|
txtMajorVersion.Text = $"{versionInfo.major}";
|
||||||
|
txtMiddleVersion.Text = $"{versionInfo.middle}";
|
||||||
|
txtMinorVersion.Text = $"{versionInfo.minor}";
|
||||||
|
txtVariety.Text = $"{versionInfo.variety}";
|
||||||
|
txtInternal.Text = $"{versionInfo.interna1}";
|
||||||
|
txtShortInfo.Text = StringHandlers.CToString(versionInfo.short_info, Encoding.UTF8);
|
||||||
|
txtLongInfo.Text = StringHandlers.CToString(versionInfo.long_info, Encoding.UTF8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -36,11 +36,13 @@ namespace exeinfogui.BeOS
|
|||||||
{
|
{
|
||||||
public class TabBeResources : TabPage
|
public class TabBeResources : TabPage
|
||||||
{
|
{
|
||||||
|
bool bigEndian;
|
||||||
|
PanelBeIcon panelBeIcon;
|
||||||
|
PanelBeVersion panelBeVersion;
|
||||||
PanelHexDump panelHexDump;
|
PanelHexDump panelHexDump;
|
||||||
PanelText panelText;
|
PanelText panelText;
|
||||||
Panel pnlResource;
|
Panel pnlResource;
|
||||||
TreeGridView treeResources;
|
TreeGridView treeResources;
|
||||||
PanelBeIcon panelBeIcon;
|
|
||||||
|
|
||||||
public TabBeResources()
|
public TabBeResources()
|
||||||
{
|
{
|
||||||
@@ -56,9 +58,10 @@ namespace exeinfogui.BeOS
|
|||||||
panelHexDump = new PanelHexDump();
|
panelHexDump = new PanelHexDump();
|
||||||
panelText = new PanelText();
|
panelText = new PanelText();
|
||||||
panelBeIcon = new PanelBeIcon();
|
panelBeIcon = new PanelBeIcon();
|
||||||
|
panelBeVersion = new PanelBeVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(IEnumerable<ResourceTypeBlock> resources)
|
public void Update(IEnumerable<ResourceTypeBlock> resources, bool bigEndian)
|
||||||
{
|
{
|
||||||
TreeGridItemCollection treeData = new TreeGridItemCollection();
|
TreeGridItemCollection treeData = new TreeGridItemCollection();
|
||||||
|
|
||||||
@@ -84,6 +87,7 @@ namespace exeinfogui.BeOS
|
|||||||
}
|
}
|
||||||
|
|
||||||
treeResources.DataStore = treeData;
|
treeResources.DataStore = treeData;
|
||||||
|
this.bigEndian = bigEndian;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TreeResourcesOnSelectionChanged(object sender, EventArgs eventArgs)
|
void TreeResourcesOnSelectionChanged(object sender, EventArgs eventArgs)
|
||||||
@@ -108,6 +112,10 @@ namespace exeinfogui.BeOS
|
|||||||
pnlResource.Content = panelBeIcon;
|
pnlResource.Content = panelBeIcon;
|
||||||
panelBeIcon.Update(data, type);
|
panelBeIcon.Update(data, type);
|
||||||
break;
|
break;
|
||||||
|
case Consts.B_VERSION_INFO_TYPE:
|
||||||
|
pnlResource.Content = panelBeVersion;
|
||||||
|
panelBeVersion.Update(data, bigEndian);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
pnlResource.Content = panelHexDump;
|
pnlResource.Content = panelHexDump;
|
||||||
panelHexDump.Update(data);
|
panelHexDump.Update(data);
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ namespace exeinfogui
|
|||||||
|
|
||||||
if(((libexeinfo.PE)peExe).BeosResources != null)
|
if(((libexeinfo.PE)peExe).BeosResources != null)
|
||||||
{
|
{
|
||||||
tabBeResources.Update(((libexeinfo.PE)peExe).BeosResources);
|
tabBeResources.Update(((libexeinfo.PE)peExe).BeosResources, peExe.IsBigEndian);
|
||||||
tabBeResources.Visible = true;
|
tabBeResources.Visible = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
namespace libexeinfo.BeOS
|
namespace libexeinfo.BeOS
|
||||||
{
|
{
|
||||||
|
// TODO: Find examples of 'CSTR', 'TEXT', and 'MMSG' with data
|
||||||
public static class Consts
|
public static class Consts
|
||||||
{
|
{
|
||||||
internal const int RESOURCES_HEADER_MAGIC = 0x444F1000;
|
internal const int RESOURCES_HEADER_MAGIC = 0x444F1000;
|
||||||
|
|||||||
38
libexeinfo/BeOS/Enums.cs
Normal file
38
libexeinfo/BeOS/Enums.cs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
//
|
||||||
|
// Enums.cs
|
||||||
|
//
|
||||||
|
// Author:
|
||||||
|
// Natalia Portillo <claunia@claunia.com>
|
||||||
|
//
|
||||||
|
// Copyright (c) 2017-2018 Copyright © Claunia.com
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
namespace libexeinfo.BeOS
|
||||||
|
{
|
||||||
|
public enum InfoVariety : uint
|
||||||
|
{
|
||||||
|
B_DEVELOPMENT_VERSION = 0,
|
||||||
|
B_ALPHA_VERSION,
|
||||||
|
B_BETA_VERSION,
|
||||||
|
B_GAMMA_VERSION,
|
||||||
|
B_GOLDEN_MASTER_VERSION,
|
||||||
|
B_FINAL_VERSION
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -202,4 +202,18 @@ namespace libexeinfo.BeOS
|
|||||||
public int index;
|
public int index;
|
||||||
public string name;
|
public string name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct VersionInfo
|
||||||
|
{
|
||||||
|
public uint major;
|
||||||
|
public uint middle;
|
||||||
|
public uint minor;
|
||||||
|
public InfoVariety variety;
|
||||||
|
public uint interna1;
|
||||||
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
|
||||||
|
public byte[] short_info;
|
||||||
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
|
||||||
|
public byte[] long_info;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using libexeinfo.Windows;
|
using libexeinfo.BeOS;
|
||||||
|
|
||||||
namespace libexeinfo
|
namespace libexeinfo
|
||||||
{
|
{
|
||||||
@@ -41,6 +41,7 @@ namespace libexeinfo
|
|||||||
public partial class PE : IExecutable
|
public partial class PE : IExecutable
|
||||||
{
|
{
|
||||||
MZ baseExecutable;
|
MZ baseExecutable;
|
||||||
|
public ResourceTypeBlock[] BeosResources;
|
||||||
DebugDirectory debugDirectory;
|
DebugDirectory debugDirectory;
|
||||||
ImageDataDirectory[] directoryEntries;
|
ImageDataDirectory[] directoryEntries;
|
||||||
string[] exportedNames;
|
string[] exportedNames;
|
||||||
@@ -54,7 +55,6 @@ namespace libexeinfo
|
|||||||
public Version[] Versions;
|
public Version[] Versions;
|
||||||
public ResourceNode WindowsResourcesRoot;
|
public ResourceNode WindowsResourcesRoot;
|
||||||
WindowsHeader64 winHeader;
|
WindowsHeader64 winHeader;
|
||||||
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,15 @@ 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 = Resources.Decode(buffer);
|
||||||
|
|
||||||
|
strings.AddRange(from type in BeosResources
|
||||||
|
where type.type == Consts.B_VERSION_INFO_TYPE
|
||||||
|
from resource in type.resources
|
||||||
|
select BigEndianMarshal
|
||||||
|
.ByteArrayToStructureLittleEndian<VersionInfo>(resource.data)
|
||||||
|
into versionInfo
|
||||||
|
select StringHandlers.CToString(versionInfo.long_info));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -427,7 +435,7 @@ namespace libexeinfo
|
|||||||
ResourceNode thisNode = new ResourceNode {name = name, id = id, level = level};
|
ResourceNode thisNode = new ResourceNode {name = name, id = id, level = level};
|
||||||
|
|
||||||
if(thisNode.name == null)
|
if(thisNode.name == null)
|
||||||
thisNode.name = level == 1 ? Resources.IdToName((ushort)thisNode.id) : $"{thisNode.id}";
|
thisNode.name = level == 1 ? Windows.Resources.IdToName((ushort)thisNode.id) : $"{thisNode.id}";
|
||||||
|
|
||||||
stream.Position = position;
|
stream.Position = position;
|
||||||
byte[] buffer = new byte[Marshal.SizeOf(typeof(ResourceDirectoryTable))];
|
byte[] buffer = new byte[Marshal.SizeOf(typeof(ResourceDirectoryTable))];
|
||||||
|
|||||||
@@ -51,6 +51,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="AtariST\Enums.cs" />
|
<Compile Include="AtariST\Enums.cs" />
|
||||||
<Compile Include="BeOS\Consts.cs" />
|
<Compile Include="BeOS\Consts.cs" />
|
||||||
|
<Compile Include="BeOS\Enums.cs" />
|
||||||
<Compile Include="BeOS\Resources.cs" />
|
<Compile Include="BeOS\Resources.cs" />
|
||||||
<Compile Include="BeOS\Structs.cs" />
|
<Compile Include="BeOS\Structs.cs" />
|
||||||
<Compile Include="Enums.cs" />
|
<Compile Include="Enums.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user