mirror of
https://github.com/claunia/libexeinfo.git
synced 2025-12-16 19:14:24 +00:00
Add GUI for BeOS resources.
This commit is contained in:
15
exeinfogui/BeOS/TabBeResources.xeto
Normal file
15
exeinfogui/BeOS/TabBeResources.xeto
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<TabPage Text="BeOS Resources" xmlns="http://schema.picoe.ca/eto.forms" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<StackLayout Orientation="Vertical">
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Expand="True">
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Expand="True">
|
||||
<TreeGridView ID="treeResources"/>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Expand="True">
|
||||
<Panel ID="pnlResource"/>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</TabPage>
|
||||
111
exeinfogui/BeOS/TabBeResources.xeto.cs
Normal file
111
exeinfogui/BeOS/TabBeResources.xeto.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
//
|
||||
// TabBeResources.xeto.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.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Eto.Forms;
|
||||
using Eto.Serialization.Xaml;
|
||||
using libexeinfo.BeOS;
|
||||
|
||||
namespace exeinfogui.BeOS
|
||||
{
|
||||
public class TabBeResources : TabPage
|
||||
{
|
||||
PanelHexDump panelHexDump;
|
||||
PanelText panelText;
|
||||
Panel pnlResource;
|
||||
TreeGridView treeResources;
|
||||
|
||||
public TabBeResources()
|
||||
{
|
||||
XamlReader.Load(this);
|
||||
|
||||
treeResources.Columns.Add(new GridColumn {HeaderText = "Name", DataCell = new TextBoxCell(0)});
|
||||
treeResources.Columns.Add(new GridColumn {HeaderText = "ID", DataCell = new TextBoxCell(1)});
|
||||
treeResources.Columns.Add(new GridColumn {HeaderText = "Size", DataCell = new TextBoxCell(2)});
|
||||
|
||||
treeResources.AllowMultipleSelection = false;
|
||||
treeResources.SelectionChanged += TreeResourcesOnSelectionChanged;
|
||||
|
||||
panelHexDump = new PanelHexDump();
|
||||
panelText = new PanelText();
|
||||
}
|
||||
|
||||
public void Update(IEnumerable<ResourceTypeBlock> resources)
|
||||
{
|
||||
TreeGridItemCollection treeData = new TreeGridItemCollection();
|
||||
|
||||
foreach(ResourceTypeBlock type in resources.OrderBy(r => r.type))
|
||||
{
|
||||
TreeGridItem root = new TreeGridItem {Values = new object[] {$"{type.type}", null, null, null, null}};
|
||||
|
||||
foreach(Resource resource in type.resources.OrderBy(r => r.name).ThenBy(r => r.id).ThenBy(r => r.index))
|
||||
{
|
||||
TreeGridItem child = new TreeGridItem
|
||||
{
|
||||
Values = new object[]
|
||||
{
|
||||
$"{resource.name}", $"{resource.id}",
|
||||
resource.data == null ? null : $"{resource.data.Length}", $"{type.type}", resource.data
|
||||
}
|
||||
};
|
||||
|
||||
root.Children.Add(child);
|
||||
}
|
||||
|
||||
treeData.Add(root);
|
||||
}
|
||||
|
||||
treeResources.DataStore = treeData;
|
||||
}
|
||||
|
||||
void TreeResourcesOnSelectionChanged(object sender, EventArgs eventArgs)
|
||||
{
|
||||
if(((TreeGridItem)treeResources.SelectedItem)?.Values[4] == null)
|
||||
{
|
||||
pnlResource.Content = null;
|
||||
return;
|
||||
}
|
||||
|
||||
byte[] data = ((TreeGridItem)treeResources.SelectedItem)?.Values[4] as byte[];
|
||||
string type = ((TreeGridItem)treeResources.SelectedItem)?.Values[3] as string;
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case Consts.B_MIME_STRING_TYPE:
|
||||
pnlResource.Content = panelText;
|
||||
panelText.Update(data, Encoding.UTF8);
|
||||
break;
|
||||
default:
|
||||
pnlResource.Content = panelHexDump;
|
||||
panelHexDump.Update(data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using exeinfogui.BeOS;
|
||||
using exeinfogui.GEM;
|
||||
using exeinfogui.LE;
|
||||
using exeinfogui.LX;
|
||||
@@ -41,6 +42,7 @@ namespace exeinfogui
|
||||
{
|
||||
ComboBox cmbArch;
|
||||
Label lblSubsystem;
|
||||
TabBeResources tabBeResources;
|
||||
TabGemResources tabGemResources;
|
||||
TabLeVxdVersion tabLeVxdVersion;
|
||||
TabLxResources tabLxResources;
|
||||
@@ -66,6 +68,7 @@ namespace exeinfogui
|
||||
tabLeVxdVersion = new TabLeVxdVersion {Visible = false};
|
||||
tabLxResources = new TabLxResources {Visible = false};
|
||||
tabPeResources = new TabPeResources {Visible = false};
|
||||
tabBeResources = new TabBeResources {Visible = false};
|
||||
tabMain.Pages.Add(tabSegments);
|
||||
tabMain.Pages.Add(tabStrings);
|
||||
tabMain.Pages.Add(tabGemResources);
|
||||
@@ -73,6 +76,7 @@ namespace exeinfogui
|
||||
tabMain.Pages.Add(tabLeVxdVersion);
|
||||
tabMain.Pages.Add(tabLxResources);
|
||||
tabMain.Pages.Add(tabPeResources);
|
||||
tabMain.Pages.Add(tabBeResources);
|
||||
}
|
||||
|
||||
protected void OnBtnLoadClick(object sender, EventArgs e)
|
||||
@@ -90,6 +94,7 @@ namespace exeinfogui
|
||||
tabLeVxdVersion.Visible = false;
|
||||
tabLxResources.Visible = false;
|
||||
tabPeResources.Visible = false;
|
||||
tabBeResources.Visible = false;
|
||||
|
||||
OpenFileDialog dlgOpen = new OpenFileDialog {Title = "Choose executable file", MultiSelect = false};
|
||||
|
||||
@@ -149,12 +154,17 @@ namespace exeinfogui
|
||||
else if(peExe.Recognized)
|
||||
{
|
||||
recognizedExe = peExe;
|
||||
if(((libexeinfo.PE)peExe).WindowsResourcesRoot != null &&
|
||||
((libexeinfo.PE)peExe).WindowsResourcesRoot.children != null)
|
||||
if(((libexeinfo.PE)peExe).WindowsResourcesRoot?.children != null)
|
||||
{
|
||||
tabPeResources.Update(((libexeinfo.PE)peExe).WindowsResourcesRoot);
|
||||
tabPeResources.Visible = true;
|
||||
}
|
||||
|
||||
if(((libexeinfo.PE)peExe).BeosResources != null)
|
||||
{
|
||||
tabBeResources.Update(((libexeinfo.PE)peExe).BeosResources);
|
||||
tabBeResources.Visible = true;
|
||||
}
|
||||
}
|
||||
else if(stExe.Recognized)
|
||||
{
|
||||
|
||||
@@ -28,5 +28,6 @@
|
||||
<Folder Include="LE\" />
|
||||
<Folder Include="LX\" />
|
||||
<Folder Include="PE\" />
|
||||
<Folder Include="BeOS\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user