mirror of
https://github.com/SabreTools/SabreTools.Printing.git
synced 2026-04-22 06:03:32 +00:00
Compare commits
53 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e69ee2ec58 | ||
|
|
2f11ecdfde | ||
|
|
f6b1a19aa2 | ||
|
|
ede807fc76 | ||
|
|
f2d43b2f18 | ||
|
|
047bbeedbc | ||
|
|
bac35b1ba6 | ||
|
|
77fefef1cb | ||
|
|
b7a8cac71e | ||
|
|
6b69a7bd27 | ||
|
|
f450da1621 | ||
|
|
d2c68eef4b | ||
|
|
65facd03d1 | ||
|
|
606d2268e7 | ||
|
|
c65bbe9fd6 | ||
|
|
e4a98f1e73 | ||
|
|
0cf4d46de0 | ||
|
|
913caddb10 | ||
|
|
df6b77812a | ||
|
|
a175ab0309 | ||
|
|
792e5042bd | ||
|
|
2d08b97910 | ||
|
|
d6a60070bb | ||
|
|
5956e15486 | ||
|
|
ead32b3422 | ||
|
|
b320fc8985 | ||
|
|
f4bd465866 | ||
|
|
3a2371b64f | ||
|
|
ca8f8a7838 | ||
|
|
b1866d9710 | ||
|
|
29af485574 | ||
|
|
17fefa2ab4 | ||
|
|
3ff29666ed | ||
|
|
e093e4e768 | ||
|
|
25b6c52327 | ||
|
|
dff654af5c | ||
|
|
6f6451ff40 | ||
|
|
b28f5011ac | ||
|
|
56d8077216 | ||
|
|
9fd534f539 | ||
|
|
19aefca0e1 | ||
|
|
4dce7a7fa4 | ||
|
|
ed2f53526c | ||
|
|
9b1040e912 | ||
|
|
abc4701f9d | ||
|
|
03c0bc1802 | ||
|
|
a6e38f6868 | ||
|
|
d900eeb2d2 | ||
|
|
bd49efa14a | ||
|
|
93cd267b00 | ||
|
|
668b4bada7 | ||
|
|
36ddb62def | ||
|
|
1de4cede1b |
43
.github/workflows/build_nupkg.yml
vendored
Normal file
43
.github/workflows/build_nupkg.yml
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
name: Nuget Pack
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: 8.0.x
|
||||
|
||||
- name: Restore dependencies
|
||||
run: dotnet restore
|
||||
|
||||
- name: Pack
|
||||
run: dotnet pack
|
||||
|
||||
- name: Upload build
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: 'Nuget Package'
|
||||
path: 'SabreTools.Printing/bin/Release/*.nupkg'
|
||||
|
||||
- name: Upload to rolling
|
||||
uses: ncipollo/release-action@v1.14.0
|
||||
with:
|
||||
allowUpdates: True
|
||||
artifacts: 'SabreTools.Printing/bin/Release/*.nupkg'
|
||||
body: 'Last built commit: ${{ github.sha }}'
|
||||
name: 'Rolling Release'
|
||||
prerelease: True
|
||||
replacesArtifacts: True
|
||||
tag: "rolling"
|
||||
updateOnlyUnreleased: True
|
||||
17
.github/workflows/check_pr.yml
vendored
Normal file
17
.github/workflows/check_pr.yml
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
name: Build PR
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: 8.0.x
|
||||
|
||||
- name: Build
|
||||
run: dotnet build
|
||||
@@ -1,3 +1,5 @@
|
||||
# SabreTools.Printing
|
||||
|
||||
This library comprises of code to output human-readable representations of various (usually binary) models. All of the classes here are `static` and utilize `StringBuilder`.
|
||||
This library comprises of code to output human-readable representations of various (usually binary) models. All of the classes here implement the `IPrinter` interface to associate them with a top-level model and utilize `StringBuilder` within `static` implementations.
|
||||
|
||||
Find the link to the Nuget package [here](https://www.nuget.org/packages/SabreTools.Printing).
|
||||
|
||||
@@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.0.31903.59
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SabreTools.Printing", "SabreTools.Printing.csproj", "{4274AA02-00A0-48F1-98C4-B3286E547246}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SabreTools.Printing", "SabreTools.Printing\SabreTools.Printing.csproj", "{4274AA02-00A0-48F1-98C4-B3286E547246}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{F7DE19C8-9E62-443D-BBD0-A846405E3903}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -18,5 +20,9 @@ Global
|
||||
{4274AA02-00A0-48F1-98C4-B3286E547246}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4274AA02-00A0-48F1-98C4-B3286E547246}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4274AA02-00A0-48F1-98C4-B3286E547246}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F7DE19C8-9E62-443D-BBD0-A846405E3903}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F7DE19C8-9E62-443D-BBD0-A846405E3903}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F7DE19C8-9E62-443D-BBD0-A846405E3903}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F7DE19C8-9E62-443D-BBD0-A846405E3903}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
18
SabreTools.Printing/Interfaces/IPrinter.cs
Normal file
18
SabreTools.Printing/Interfaces/IPrinter.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Text;
|
||||
|
||||
namespace SabreTools.Printing.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Marks a class as a printer associated with a model
|
||||
/// </summary>
|
||||
/// <typeparam name="TModel">Type of the top-level model</typeparam>
|
||||
public interface IPrinter<TModel>
|
||||
{
|
||||
/// <summary>
|
||||
/// Print information associated with a model
|
||||
/// </summary>
|
||||
/// <param name="builder">StringBuilder to append information to</param>
|
||||
/// <param name="model">Model to print</param>
|
||||
void PrintInformation(StringBuilder builder, TModel model);
|
||||
}
|
||||
}
|
||||
430
SabreTools.Printing/PrintExtensions.cs
Normal file
430
SabreTools.Printing/PrintExtensions.cs
Normal file
@@ -0,0 +1,430 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using SabreTools.Printing.Printers;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
using Wrapper = SabreTools.Serialization.Wrappers;
|
||||
|
||||
namespace SabreTools.Printing
|
||||
{
|
||||
/// <summary>
|
||||
/// Generic wrapper around printing methods
|
||||
/// </summary>
|
||||
public static class PrintExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Print the item information from a wrapper to console as
|
||||
/// pretty-printed text
|
||||
/// </summary>
|
||||
public static void PrintToConsole(this IWrapper wrapper)
|
||||
{
|
||||
var sb = wrapper.ExportStringBuilder();
|
||||
if (sb == null)
|
||||
{
|
||||
Console.WriteLine("No item information could be generated");
|
||||
return;
|
||||
}
|
||||
|
||||
Console.WriteLine(sb.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as a StringBuilder
|
||||
/// </summary>
|
||||
public static StringBuilder? ExportStringBuilder(this IWrapper wrapper)
|
||||
{
|
||||
return wrapper switch
|
||||
{
|
||||
Wrapper.AACSMediaKeyBlock item => item.PrettyPrint(),
|
||||
Wrapper.BDPlusSVM item => item.PrettyPrint(),
|
||||
Wrapper.BFPK item => item.PrettyPrint(),
|
||||
Wrapper.BSP item => item.PrettyPrint(),
|
||||
Wrapper.CFB item => item.PrettyPrint(),
|
||||
Wrapper.CIA item => item.PrettyPrint(),
|
||||
Wrapper.GCF item => item.PrettyPrint(),
|
||||
Wrapper.InstallShieldCabinet item => item.PrettyPrint(),
|
||||
Wrapper.IRD item => item.PrettyPrint(),
|
||||
Wrapper.LinearExecutable item => item.PrettyPrint(),
|
||||
Wrapper.MicrosoftCabinet item => item.PrettyPrint(),
|
||||
Wrapper.MoPaQ item => item.PrettyPrint(),
|
||||
Wrapper.MSDOS item => item.PrettyPrint(),
|
||||
Wrapper.N3DS item => item.PrettyPrint(),
|
||||
Wrapper.NCF item => item.PrettyPrint(),
|
||||
Wrapper.NewExecutable item => item.PrettyPrint(),
|
||||
Wrapper.Nitro item => item.PrettyPrint(),
|
||||
Wrapper.PAK item => item.PrettyPrint(),
|
||||
Wrapper.PFF item => item.PrettyPrint(),
|
||||
Wrapper.PIC item => item.PrettyPrint(),
|
||||
Wrapper.PlayJAudioFile item => item.PrettyPrint(),
|
||||
Wrapper.PlayJPlaylist item => item.PrettyPrint(),
|
||||
Wrapper.PortableExecutable item => item.PrettyPrint(),
|
||||
Wrapper.Quantum item => item.PrettyPrint(),
|
||||
Wrapper.SGA item => item.PrettyPrint(),
|
||||
Wrapper.VBSP item => item.PrettyPrint(),
|
||||
Wrapper.VPK item => item.PrettyPrint(),
|
||||
Wrapper.WAD item => item.PrettyPrint(),
|
||||
Wrapper.XeMID item => item.PrettyPrint(),
|
||||
Wrapper.XMID item => item.PrettyPrint(),
|
||||
Wrapper.XZP item => item.PrettyPrint(),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// Export the item information as JSON
|
||||
/// </summary>
|
||||
public static string ExportJSON(this IWrapper wrapper)
|
||||
{
|
||||
return wrapper switch
|
||||
{
|
||||
Wrapper.AACSMediaKeyBlock item => item.ExportJSON(),
|
||||
Wrapper.BDPlusSVM item => item.ExportJSON(),
|
||||
Wrapper.BFPK item => item.ExportJSON(),
|
||||
Wrapper.BSP item => item.ExportJSON(),
|
||||
Wrapper.CFB item => item.ExportJSON(),
|
||||
Wrapper.CIA item => item.ExportJSON(),
|
||||
Wrapper.GCF item => item.ExportJSON(),
|
||||
Wrapper.InstallShieldCabinet item => item.ExportJSON(),
|
||||
Wrapper.IRD item => item.ExportJSON(),
|
||||
Wrapper.LinearExecutable item => item.ExportJSON(),
|
||||
Wrapper.MicrosoftCabinet item => item.ExportJSON(),
|
||||
Wrapper.MoPaQ item => item.ExportJSON(),
|
||||
Wrapper.MSDOS item => item.ExportJSON(),
|
||||
Wrapper.N3DS item => item.ExportJSON(),
|
||||
Wrapper.NCF item => item.ExportJSON(),
|
||||
Wrapper.NewExecutable item => item.ExportJSON(),
|
||||
Wrapper.Nitro item => item.ExportJSON(),
|
||||
Wrapper.PAK item => item.ExportJSON(),
|
||||
Wrapper.PFF item => item.ExportJSON(),
|
||||
Wrapper.PIC item => item.ExportJSON(),
|
||||
Wrapper.PlayJAudioFile item => item.ExportJSON(),
|
||||
Wrapper.PlayJPlaylist item => item.ExportJSON(),
|
||||
Wrapper.PortableExecutable item => item.ExportJSON(),
|
||||
Wrapper.Quantum item => item.ExportJSON(),
|
||||
Wrapper.SGA item => item.ExportJSON(),
|
||||
Wrapper.VBSP item => item.ExportJSON(),
|
||||
Wrapper.VPK item => item.ExportJSON(),
|
||||
Wrapper.WAD item => item.ExportJSON(),
|
||||
Wrapper.XeMID item => item.ExportJSON(),
|
||||
Wrapper.XMID item => item.ExportJSON(),
|
||||
Wrapper.XZP item => item.ExportJSON(),
|
||||
_ => string.Empty,
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
#region Static Printing Implementations
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.AACSMediaKeyBlock item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
AACSMediaKeyBlock.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.BDPlusSVM item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
BDPlusSVM.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.BFPK item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
BFPK.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.BSP item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
BSP.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.CFB item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
CFB.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.CIA item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
CIA.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.GCF item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
GCF.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.InstallShieldCabinet item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
InstallShieldCabinet.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.IRD item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
IRD.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.LinearExecutable item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
LinearExecutable.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.MicrosoftCabinet item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
MicrosoftCabinet.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.MoPaQ item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
MoPaQ.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.MSDOS item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
MSDOS.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.N3DS item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
N3DS.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.NCF item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
NCF.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.NewExecutable item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
NewExecutable.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.Nitro item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
Nitro.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.PAK item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
PAK.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.PFF item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
PFF.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.PIC item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
PIC.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.PlayJAudioFile item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
PlayJAudioFile.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.PlayJPlaylist item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
PlayJPlaylist.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.PortableExecutable item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
PortableExecutable.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.Quantum item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
Quantum.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.SGA item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
SGA.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.VBSP item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
VBSP.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.VPK item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
VPK.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.WAD item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
WAD.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.XeMID item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
XeMID.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.XMID item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
XMID.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the item information as pretty-printed text
|
||||
/// </summary>
|
||||
private static StringBuilder PrettyPrint(this Wrapper.XZP item)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
XZP.Print(builder, item.Model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,15 @@
|
||||
using System.Text;
|
||||
using SabreTools.Models.AACS;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
|
||||
namespace SabreTools.Printing
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public static class AACSMediaKeyBlock
|
||||
public class AACSMediaKeyBlock : IPrinter<MediaKeyBlock>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, MediaKeyBlock model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, MediaKeyBlock mediaKeyBlock)
|
||||
{
|
||||
builder.AppendLine("AACS Media Key Block Information:");
|
||||
@@ -14,11 +19,7 @@ namespace SabreTools.Printing
|
||||
Print(builder, mediaKeyBlock.Records);
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Record[] records)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Record?[]? records)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Records Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -37,11 +38,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Record record, int index)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Record? record, int index)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine($" Record Entry {index}");
|
||||
if (record == null)
|
||||
@@ -85,11 +82,7 @@ namespace SabreTools.Printing
|
||||
}
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, EndOfMediaKeyBlockRecord record)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, EndOfMediaKeyBlockRecord record)
|
||||
#endif
|
||||
{
|
||||
if (record == null)
|
||||
return;
|
||||
@@ -97,11 +90,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine(record.SignatureData, " Signature data");
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ExplicitSubsetDifferenceRecord record)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ExplicitSubsetDifferenceRecord? record)
|
||||
#endif
|
||||
{
|
||||
if (record == null)
|
||||
return;
|
||||
@@ -130,11 +119,7 @@ namespace SabreTools.Printing
|
||||
}
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, MediaKeyDataRecord record)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, MediaKeyDataRecord? record)
|
||||
#endif
|
||||
{
|
||||
if (record == null)
|
||||
return;
|
||||
@@ -154,11 +139,7 @@ namespace SabreTools.Printing
|
||||
}
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, SubsetDifferenceIndexRecord record)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, SubsetDifferenceIndexRecord? record)
|
||||
#endif
|
||||
{
|
||||
if (record == null)
|
||||
return;
|
||||
@@ -179,11 +160,7 @@ namespace SabreTools.Printing
|
||||
}
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, TypeAndVersionRecord record)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, TypeAndVersionRecord? record)
|
||||
#endif
|
||||
{
|
||||
if (record == null)
|
||||
return;
|
||||
@@ -192,11 +169,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine(record.VersionNumber, " Version number");
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DriveRevocationListRecord record)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DriveRevocationListRecord? record)
|
||||
#endif
|
||||
{
|
||||
if (record == null)
|
||||
return;
|
||||
@@ -247,11 +220,7 @@ namespace SabreTools.Printing
|
||||
}
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, HostRevocationListRecord record)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, HostRevocationListRecord? record)
|
||||
#endif
|
||||
{
|
||||
if (record == null)
|
||||
return;
|
||||
@@ -302,11 +271,7 @@ namespace SabreTools.Printing
|
||||
}
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, VerifyMediaKeyRecord record)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, VerifyMediaKeyRecord? record)
|
||||
#endif
|
||||
{
|
||||
if (record == null)
|
||||
return;
|
||||
@@ -314,11 +279,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine(record.CiphertextValue, " Ciphertext value");
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, CopyrightRecord record)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, CopyrightRecord? record)
|
||||
#endif
|
||||
{
|
||||
if (record == null)
|
||||
return;
|
||||
@@ -1,10 +1,15 @@
|
||||
using System.Text;
|
||||
using SabreTools.Models.BDPlus;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
|
||||
namespace SabreTools.Printing
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public static class BDPlusSVM
|
||||
public class BDPlusSVM : IPrinter<SVM>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, SVM model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, SVM svm)
|
||||
{
|
||||
builder.AppendLine("BD+ SVM Information:");
|
||||
@@ -1,10 +1,15 @@
|
||||
using System.Text;
|
||||
using SabreTools.Models.BFPK;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
|
||||
namespace SabreTools.Printing
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public static class BFPK
|
||||
public class BFPK : IPrinter<Archive>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, Archive model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, Archive archive)
|
||||
{
|
||||
builder.AppendLine("BFPK Information:");
|
||||
@@ -15,11 +20,7 @@ namespace SabreTools.Printing
|
||||
Print(builder, archive.Files);
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Header header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Header? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -36,11 +37,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, FileEntry[] files)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, FileEntry?[]? files)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" File Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -1,11 +1,16 @@
|
||||
using System.Text;
|
||||
using SabreTools.Models.BSP;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
using static SabreTools.Models.BSP.Constants;
|
||||
|
||||
namespace SabreTools.Printing
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public static class BSP
|
||||
public class BSP : IPrinter<File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, File model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, File file)
|
||||
{
|
||||
builder.AppendLine("BSP Information:");
|
||||
@@ -18,11 +23,7 @@ namespace SabreTools.Printing
|
||||
Print(builder, file.Textures);
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Header header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Header? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -37,11 +38,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Lump[] lumps)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Lump?[]? lumps)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Lumps Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -79,11 +76,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, TextureHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, TextureHeader? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Texture Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -110,11 +103,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Texture[] textures)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Texture?[]? textures)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Textures Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -157,6 +146,5 @@ namespace SabreTools.Printing
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,16 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using SabreTools.Models.CFB;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
|
||||
namespace SabreTools.Printing
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public static class CFB
|
||||
public class CFB : IPrinter<Binary>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, Binary model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, Binary binary)
|
||||
{
|
||||
builder.AppendLine("Compound File Binary Information:");
|
||||
@@ -19,11 +24,7 @@ namespace SabreTools.Printing
|
||||
Print(builder, binary.DirectoryEntries);
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, FileHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, FileHeader? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" File Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -65,11 +66,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, SectorNumber[] sectorNumbers, string name)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, SectorNumber?[]? sectorNumbers, string name)
|
||||
#endif
|
||||
private static void Print(StringBuilder builder, SectorNumber[]? sectorNumbers, string name)
|
||||
{
|
||||
builder.AppendLine($" {name} Sectors Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -87,11 +84,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DirectoryEntry[] directoryEntries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DirectoryEntry?[]? directoryEntries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Directory Entries Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -128,6 +121,5 @@ namespace SabreTools.Printing
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,16 @@
|
||||
using System.Text;
|
||||
using SabreTools.Models.N3DS;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
|
||||
namespace SabreTools.Printing
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public static class CIA
|
||||
public class CIA : IPrinter<Models.N3DS.CIA>
|
||||
{
|
||||
public static void Print(StringBuilder builder, SabreTools.Models.N3DS.CIA cia)
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, Models.N3DS.CIA model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, Models.N3DS.CIA cia)
|
||||
{
|
||||
builder.AppendLine("CIA Archive Information:");
|
||||
builder.AppendLine("-------------------------");
|
||||
@@ -19,11 +24,7 @@ namespace SabreTools.Printing
|
||||
Print(builder, cia.MetaData);
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, CIAHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, CIAHeader? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" CIA Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -46,11 +47,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Certificate[] certificateChain)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Certificate?[]? certificateChain)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Certificate Chain Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -106,11 +103,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Ticket ticket)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Ticket? ticket)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Ticket Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -215,11 +208,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, TitleMetadata tmd)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, TitleMetadata? tmd)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Title Metadata Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -362,11 +351,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, NCCHHeader[] partitions)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, NCCHHeader?[]? partitions)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" NCCH Partition Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -446,11 +431,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, MetaData metaData)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, MetaData? metaData)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Meta Data Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -1,10 +1,16 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using SabreTools.Models.GCF;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
|
||||
namespace SabreTools.Printing
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public static class GCF
|
||||
public class GCF : IPrinter<File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, File model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, File file)
|
||||
{
|
||||
builder.AppendLine("GCF Information:");
|
||||
@@ -28,7 +34,7 @@ namespace SabreTools.Printing
|
||||
|
||||
// Directory and Directory Maps
|
||||
Print(builder, file.DirectoryHeader);
|
||||
Print(builder, file.DirectoryEntries);
|
||||
Print(builder, file.DirectoryEntries, file.DirectoryNames);
|
||||
// TODO: Should we print out the entire string table?
|
||||
Print(builder, file.DirectoryInfo1Entries);
|
||||
Print(builder, file.DirectoryInfo2Entries);
|
||||
@@ -47,11 +53,7 @@ namespace SabreTools.Printing
|
||||
Print(builder, file.DataBlockHeader);
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Header header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Header? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -76,11 +78,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, BlockEntryHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, BlockEntryHeader? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Block Entry Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -102,11 +100,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, BlockEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, BlockEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Block Entries Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -138,11 +132,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, FragmentationMapHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, FragmentationMapHeader? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Fragmentation Map Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -160,11 +150,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, FragmentationMap[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, FragmentationMap?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Fragmentation Maps Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -190,11 +176,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, BlockEntryMapHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, BlockEntryMapHeader? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Block Entry Map Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -213,11 +195,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, BlockEntryMap[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, BlockEntryMap?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Block Entry Maps Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -244,11 +222,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DirectoryHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DirectoryHeader? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Directory Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -276,11 +250,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DirectoryEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DirectoryEntry?[]? entries)
|
||||
#endif
|
||||
private static void Print(StringBuilder builder, DirectoryEntry?[]? entries, Dictionary<long, string?>? entryNames)
|
||||
{
|
||||
builder.AppendLine(" Directory Entries Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -302,7 +272,7 @@ namespace SabreTools.Printing
|
||||
}
|
||||
|
||||
builder.AppendLine(entry.NameOffset, " Name offset");
|
||||
builder.AppendLine(entry.Name, " Name");
|
||||
builder.AppendLine(entryNames![entry.NameOffset], " Name");
|
||||
builder.AppendLine(entry.ItemSize, " Item size");
|
||||
builder.AppendLine(entry.ChecksumIndex, " Checksum index");
|
||||
builder.AppendLine($" Directory flags: {entry.DirectoryFlags} (0x{entry.DirectoryFlags:X})");
|
||||
@@ -313,11 +283,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DirectoryInfo1Entry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DirectoryInfo1Entry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Directory Info 1 Entries Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -343,11 +309,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DirectoryInfo2Entry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DirectoryInfo2Entry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Directory Info 2 Entries Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -373,11 +335,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DirectoryCopyEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DirectoryCopyEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Directory Copy Entries Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -403,11 +361,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DirectoryLocalEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DirectoryLocalEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Directory Local Entries Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -433,11 +387,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DirectoryMapHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DirectoryMapHeader? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Directory Map Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -453,11 +403,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DirectoryMapEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DirectoryMapEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Directory Map Entries Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -483,11 +429,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ChecksumHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ChecksumHeader? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Checksum Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -503,11 +445,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ChecksumMapHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ChecksumMapHeader? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Checksum Map Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -525,11 +463,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ChecksumMapEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ChecksumMapEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Checksum Map Entries Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -556,11 +490,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ChecksumEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ChecksumEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Checksum Entries Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -586,11 +516,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DataBlockHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DataBlockHeader? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Data Block Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
55
SabreTools.Printing/Printers/IRD.cs
Normal file
55
SabreTools.Printing/Printers/IRD.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System.Text;
|
||||
using SabreTools.Models.IRD;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public class IRD : IPrinter<File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, File model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, File ird)
|
||||
{
|
||||
builder.AppendLine("IRD Information:");
|
||||
builder.AppendLine("-------------------------");
|
||||
builder.AppendLine(ird.Magic, "Magic", Encoding.ASCII);
|
||||
builder.AppendLine(ird.Version, "Version");
|
||||
builder.AppendLine(ird.TitleID, "Title ID");
|
||||
builder.AppendLine(ird.TitleLength, "Title length");
|
||||
builder.AppendLine(ird.Title, "Title");
|
||||
builder.AppendLine(ird.SystemVersion, "System version");
|
||||
builder.AppendLine(ird.GameVersion, "Game version");
|
||||
builder.AppendLine(ird.AppVersion, "App version");
|
||||
builder.AppendLine(ird.HeaderLength, "Header length");
|
||||
builder.AppendLine(ird.Header, "Header");
|
||||
builder.AppendLine(ird.FooterLength, "Footer length");
|
||||
builder.AppendLine(ird.Footer, "Footer");
|
||||
builder.AppendLine(ird.RegionCount, "Region count");
|
||||
if (ird.RegionCount != 0 && ird.RegionHashes != null && ird.RegionHashes.Length != 0)
|
||||
{
|
||||
for (int i = 0; i < ird.RegionCount; i++)
|
||||
{
|
||||
builder.AppendLine(ird.RegionHashes[i], $"Region {i} hash");
|
||||
}
|
||||
}
|
||||
builder.AppendLine(ird.FileCount, "File count");
|
||||
for (int i = 0; i < ird.FileCount; i++)
|
||||
{
|
||||
if (ird.FileKeys != null)
|
||||
builder.AppendLine(ird.FileKeys[i], $"File {i} key");
|
||||
if (ird.FileHashes != null)
|
||||
builder.AppendLine(ird.FileHashes[i], $"File {i} hash");
|
||||
}
|
||||
builder.AppendLine(ird.ExtraConfig, "Extra config");
|
||||
builder.AppendLine(ird.Attachments, "Attachments");
|
||||
builder.AppendLine(ird.Data1Key, "Data 1 key");
|
||||
builder.AppendLine(ird.Data2Key, "Data 2 key");
|
||||
builder.AppendLine(ird.PIC, "PIC");
|
||||
builder.AppendLine(ird.UID, "UID");
|
||||
builder.AppendLine(ird.CRC, "CRC");
|
||||
builder.AppendLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using SabreTools.Models.InstallShieldCabinet;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
|
||||
namespace SabreTools.Printing
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public static class InstallShieldCabinet
|
||||
public class InstallShieldCabinet : IPrinter<Cabinet>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, Cabinet model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, Cabinet cabinet)
|
||||
{
|
||||
builder.AppendLine("InstallShield Cabinet Information:");
|
||||
@@ -35,17 +39,9 @@ namespace SabreTools.Printing
|
||||
Print(builder, cabinet.Components);
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static int GetMajorVersion(CommonHeader header)
|
||||
#else
|
||||
private static int GetMajorVersion(CommonHeader? header)
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
uint majorVersion = header.Version;
|
||||
#else
|
||||
uint majorVersion = header?.Version ?? 0;
|
||||
#endif
|
||||
if (majorVersion >> 24 == 1)
|
||||
{
|
||||
majorVersion = (majorVersion >> 12) & 0x0F;
|
||||
@@ -60,11 +56,7 @@ namespace SabreTools.Printing
|
||||
return (int)majorVersion;
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, CommonHeader header, int majorVersion)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, CommonHeader? header, int majorVersion)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Common Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -83,11 +75,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, VolumeHeader header, int majorVersion)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, VolumeHeader? header, int majorVersion)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Volume Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -132,11 +120,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Descriptor descriptor)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Descriptor? descriptor)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Descriptor Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -203,11 +187,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, uint[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, uint[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" File Descriptor Offsets:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -225,11 +205,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, string[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, string?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Directory Names:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -247,11 +223,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, FileDescriptor[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, FileDescriptor?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" File Descriptors:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -288,11 +260,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Dictionary<long, OffsetList> entries, string name)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Dictionary<long, OffsetList?>? entries, string name)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine($" {name} Offsets:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -323,11 +291,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, FileGroup[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, FileGroup?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" File Groups:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -376,11 +340,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Component[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Component?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Components:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -1,10 +1,15 @@
|
||||
using System.Text;
|
||||
using SabreTools.Models.LinearExecutable;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
|
||||
namespace SabreTools.Printing
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public static class LinearExecutable
|
||||
public class LinearExecutable : IPrinter<Executable>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, Executable model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, Executable executable)
|
||||
{
|
||||
builder.AppendLine("New Executable Information:");
|
||||
@@ -36,11 +41,7 @@ namespace SabreTools.Printing
|
||||
Print(builder, executable.DebugInformation);
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, SabreTools.Models.MSDOS.ExecutableHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, SabreTools.Models.MSDOS.ExecutableHeader? header)
|
||||
#endif
|
||||
private static void Print(StringBuilder builder, Models.MSDOS.ExecutableHeader? header)
|
||||
{
|
||||
builder.AppendLine(" MS-DOS Stub Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -77,11 +78,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, InformationBlock block)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, InformationBlock? block)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Information Block Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -141,11 +138,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ObjectTableEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ObjectTableEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Object Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -176,11 +169,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ObjectPageMapEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ObjectPageMapEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Object Page Map Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -208,11 +197,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ResourceTableEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ResourceTableEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Resource Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -242,11 +227,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ResidentNamesTableEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ResidentNamesTableEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Resident Names Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -274,11 +255,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, EntryTableBundle[] bundles)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, EntryTableBundle?[]? bundles)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Entry Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -364,11 +341,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ModuleFormatDirectivesTableEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ModuleFormatDirectivesTableEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Module Format Directives Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -396,11 +369,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, VerifyRecordDirectiveTableEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, VerifyRecordDirectiveTableEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Verify Record Directive Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -432,11 +401,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, FixupPageTableEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, FixupPageTableEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Fix-up Page Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -462,11 +427,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, FixupRecordTableEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, FixupRecordTableEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Fix-up Record Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -491,25 +452,45 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine($" Target flags: {entry.TargetFlags} (0x{entry.TargetFlags:X})");
|
||||
|
||||
// Source list flag
|
||||
#if NET20 || NET35
|
||||
if ((entry.SourceType & FixupRecordSourceType.SourceListFlag) != 0)
|
||||
#else
|
||||
if (entry.SourceType.HasFlag(FixupRecordSourceType.SourceListFlag))
|
||||
#endif
|
||||
builder.AppendLine(entry.SourceOffsetListCount, " Source offset list count");
|
||||
else
|
||||
builder.AppendLine(entry.SourceOffset, " Source offset");
|
||||
|
||||
// OBJECT / TRGOFF
|
||||
#if NET20 || NET35
|
||||
if ((entry.TargetFlags & FixupRecordTargetFlags.InternalReference) != 0)
|
||||
#else
|
||||
if (entry.TargetFlags.HasFlag(FixupRecordTargetFlags.InternalReference))
|
||||
#endif
|
||||
{
|
||||
// 16-bit Object Number/Module Ordinal Flag
|
||||
#if NET20 || NET35
|
||||
if ((entry.TargetFlags & FixupRecordTargetFlags.SixteenBitObjectNumberModuleOrdinalFlag) != 0)
|
||||
#else
|
||||
if (entry.TargetFlags.HasFlag(FixupRecordTargetFlags.SixteenBitObjectNumberModuleOrdinalFlag))
|
||||
#endif
|
||||
builder.AppendLine(entry.TargetObjectNumberWORD, " Target object number");
|
||||
else
|
||||
builder.AppendLine(entry.TargetObjectNumberByte, " Target object number");
|
||||
|
||||
// 16-bit Selector fixup
|
||||
#if NET20 || NET35
|
||||
if ((entry.SourceType & FixupRecordSourceType.SixteenBitSelectorFixup) != 0)
|
||||
#else
|
||||
if (!entry.SourceType.HasFlag(FixupRecordSourceType.SixteenBitSelectorFixup))
|
||||
#endif
|
||||
{
|
||||
// 32-bit Target Offset Flag
|
||||
#if NET20 || NET35
|
||||
if ((entry.TargetFlags & FixupRecordTargetFlags.ThirtyTwoBitTargetOffsetFlag) != 0)
|
||||
#else
|
||||
if (entry.TargetFlags.HasFlag(FixupRecordTargetFlags.ThirtyTwoBitTargetOffsetFlag))
|
||||
#endif
|
||||
builder.AppendLine(entry.TargetOffsetDWORD, " Target offset");
|
||||
else
|
||||
builder.AppendLine(entry.TargetOffsetWORD, " Target offset");
|
||||
@@ -517,27 +498,51 @@ namespace SabreTools.Printing
|
||||
}
|
||||
|
||||
// MOD ORD# / IMPORT ORD / ADDITIVE
|
||||
#if NET20 || NET35
|
||||
else if ((entry.TargetFlags & FixupRecordTargetFlags.ImportedReferenceByOrdinal) != 0)
|
||||
#else
|
||||
else if (entry.TargetFlags.HasFlag(FixupRecordTargetFlags.ImportedReferenceByOrdinal))
|
||||
#endif
|
||||
{
|
||||
// 16-bit Object Number/Module Ordinal Flag
|
||||
if (entry.TargetFlags.HasFlag(FixupRecordTargetFlags.SixteenBitObjectNumberModuleOrdinalFlag))
|
||||
#if NET20 || NET35
|
||||
if ((entry.TargetFlags & FixupRecordTargetFlags.SixteenBitObjectNumberModuleOrdinalFlag) != 0)
|
||||
#else
|
||||
if (!entry.TargetFlags.HasFlag(FixupRecordTargetFlags.SixteenBitObjectNumberModuleOrdinalFlag))
|
||||
#endif
|
||||
builder.AppendLine(entry.OrdinalIndexImportModuleNameTableWORD, " Ordinal index import module name table");
|
||||
else
|
||||
builder.AppendLine(entry.OrdinalIndexImportModuleNameTableByte, " Ordinal index import module name table");
|
||||
|
||||
// 8-bit Ordinal Flag & 32-bit Target Offset Flag
|
||||
if (entry.TargetFlags.HasFlag(FixupRecordTargetFlags.EightBitOrdinalFlag))
|
||||
#if NET20 || NET35
|
||||
if ((entry.TargetFlags & FixupRecordTargetFlags.EightBitOrdinalFlag) != 0)
|
||||
#else
|
||||
if (!entry.TargetFlags.HasFlag(FixupRecordTargetFlags.EightBitOrdinalFlag))
|
||||
#endif
|
||||
builder.AppendLine(entry.ImportedOrdinalNumberByte, " Imported ordinal number");
|
||||
else if (entry.TargetFlags.HasFlag(FixupRecordTargetFlags.ThirtyTwoBitTargetOffsetFlag))
|
||||
#if NET20 || NET35
|
||||
else if ((entry.TargetFlags & FixupRecordTargetFlags.ThirtyTwoBitTargetOffsetFlag) != 0)
|
||||
#else
|
||||
else if (!entry.TargetFlags.HasFlag(FixupRecordTargetFlags.ThirtyTwoBitTargetOffsetFlag))
|
||||
#endif
|
||||
builder.AppendLine(entry.ImportedOrdinalNumberDWORD, " Imported ordinal number");
|
||||
else
|
||||
builder.AppendLine(entry.ImportedOrdinalNumberWORD, " Imported ordinal number");
|
||||
|
||||
// Additive Fixup Flag
|
||||
if (entry.TargetFlags.HasFlag(FixupRecordTargetFlags.AdditiveFixupFlag))
|
||||
#if NET20 || NET35
|
||||
if ((entry.TargetFlags & FixupRecordTargetFlags.AdditiveFixupFlag) != 0)
|
||||
#else
|
||||
if (!entry.TargetFlags.HasFlag(FixupRecordTargetFlags.AdditiveFixupFlag))
|
||||
#endif
|
||||
{
|
||||
// 32-bit Additive Flag
|
||||
if (entry.TargetFlags.HasFlag(FixupRecordTargetFlags.ThirtyTwoBitAdditiveFixupFlag))
|
||||
#if NET20 || NET35
|
||||
if ((entry.TargetFlags & FixupRecordTargetFlags.ThirtyTwoBitAdditiveFixupFlag) != 0)
|
||||
#else
|
||||
if (!entry.TargetFlags.HasFlag(FixupRecordTargetFlags.ThirtyTwoBitAdditiveFixupFlag))
|
||||
#endif
|
||||
builder.AppendLine(entry.AdditiveFixupValueDWORD, " Additive fixup value");
|
||||
else
|
||||
builder.AppendLine(entry.AdditiveFixupValueWORD, " Additive fixup value");
|
||||
@@ -545,25 +550,45 @@ namespace SabreTools.Printing
|
||||
}
|
||||
|
||||
// MOD ORD# / PROCEDURE NAME OFFSET / ADDITIVE
|
||||
#if NET20 || NET35
|
||||
else if ((entry.TargetFlags & FixupRecordTargetFlags.ImportedReferenceByName) != 0)
|
||||
#else
|
||||
else if (entry.TargetFlags.HasFlag(FixupRecordTargetFlags.ImportedReferenceByName))
|
||||
#endif
|
||||
{
|
||||
// 16-bit Object Number/Module Ordinal Flag
|
||||
if (entry.TargetFlags.HasFlag(FixupRecordTargetFlags.SixteenBitObjectNumberModuleOrdinalFlag))
|
||||
#if NET20 || NET35
|
||||
if ((entry.TargetFlags & FixupRecordTargetFlags.SixteenBitObjectNumberModuleOrdinalFlag) != 0)
|
||||
#else
|
||||
if (!entry.TargetFlags.HasFlag(FixupRecordTargetFlags.SixteenBitObjectNumberModuleOrdinalFlag))
|
||||
#endif
|
||||
builder.AppendLine(entry.OrdinalIndexImportModuleNameTableWORD, " Ordinal index import module name table");
|
||||
else
|
||||
builder.AppendLine(entry.OrdinalIndexImportModuleNameTableByte, " Ordinal index import module name table");
|
||||
|
||||
// 32-bit Target Offset Flag
|
||||
if (entry.TargetFlags.HasFlag(FixupRecordTargetFlags.ThirtyTwoBitTargetOffsetFlag))
|
||||
#if NET20 || NET35
|
||||
if ((entry.TargetFlags & FixupRecordTargetFlags.ThirtyTwoBitTargetOffsetFlag) != 0)
|
||||
#else
|
||||
if (!entry.TargetFlags.HasFlag(FixupRecordTargetFlags.ThirtyTwoBitTargetOffsetFlag))
|
||||
#endif
|
||||
builder.AppendLine(entry.OffsetImportProcedureNameTableDWORD, " Offset import procedure name table");
|
||||
else
|
||||
builder.AppendLine(entry.OffsetImportProcedureNameTableWORD, " Offset import procedure name table");
|
||||
|
||||
// Additive Fixup Flag
|
||||
if (entry.TargetFlags.HasFlag(FixupRecordTargetFlags.AdditiveFixupFlag))
|
||||
#if NET20 || NET35
|
||||
if ((entry.TargetFlags & FixupRecordTargetFlags.AdditiveFixupFlag) != 0)
|
||||
#else
|
||||
if (!entry.TargetFlags.HasFlag(FixupRecordTargetFlags.AdditiveFixupFlag))
|
||||
#endif
|
||||
{
|
||||
// 32-bit Additive Flag
|
||||
if (entry.TargetFlags.HasFlag(FixupRecordTargetFlags.ThirtyTwoBitAdditiveFixupFlag))
|
||||
#if NET20 || NET35
|
||||
if ((entry.TargetFlags & FixupRecordTargetFlags.ThirtyTwoBitAdditiveFixupFlag) != 0)
|
||||
#else
|
||||
if (!entry.TargetFlags.HasFlag(FixupRecordTargetFlags.ThirtyTwoBitAdditiveFixupFlag))
|
||||
#endif
|
||||
builder.AppendLine(entry.AdditiveFixupValueDWORD, " Additive fixup value");
|
||||
else
|
||||
builder.AppendLine(entry.AdditiveFixupValueWORD, " Additive fixup value");
|
||||
@@ -571,19 +596,35 @@ namespace SabreTools.Printing
|
||||
}
|
||||
|
||||
// ORD # / ADDITIVE
|
||||
#if NET20 || NET35
|
||||
else if ((entry.TargetFlags & FixupRecordTargetFlags.InternalReferenceViaEntryTable) != 0)
|
||||
#else
|
||||
else if (entry.TargetFlags.HasFlag(FixupRecordTargetFlags.InternalReferenceViaEntryTable))
|
||||
#endif
|
||||
{
|
||||
// 16-bit Object Number/Module Ordinal Flag
|
||||
if (entry.TargetFlags.HasFlag(FixupRecordTargetFlags.SixteenBitObjectNumberModuleOrdinalFlag))
|
||||
#if NET20 || NET35
|
||||
if ((entry.TargetFlags & FixupRecordTargetFlags.SixteenBitObjectNumberModuleOrdinalFlag) != 0)
|
||||
#else
|
||||
if (!entry.TargetFlags.HasFlag(FixupRecordTargetFlags.SixteenBitObjectNumberModuleOrdinalFlag))
|
||||
#endif
|
||||
builder.AppendLine(entry.TargetObjectNumberWORD, " Target object number");
|
||||
else
|
||||
builder.AppendLine(entry.TargetObjectNumberByte, " Target object number");
|
||||
|
||||
// Additive Fixup Flag
|
||||
if (entry.TargetFlags.HasFlag(FixupRecordTargetFlags.AdditiveFixupFlag))
|
||||
#if NET20 || NET35
|
||||
if ((entry.TargetFlags & FixupRecordTargetFlags.AdditiveFixupFlag) != 0)
|
||||
#else
|
||||
if (!entry.TargetFlags.HasFlag(FixupRecordTargetFlags.AdditiveFixupFlag))
|
||||
#endif
|
||||
{
|
||||
// 32-bit Additive Flag
|
||||
if (entry.TargetFlags.HasFlag(FixupRecordTargetFlags.ThirtyTwoBitAdditiveFixupFlag))
|
||||
#if NET20 || NET35
|
||||
if ((entry.TargetFlags & FixupRecordTargetFlags.ThirtyTwoBitAdditiveFixupFlag) != 0)
|
||||
#else
|
||||
if (!entry.TargetFlags.HasFlag(FixupRecordTargetFlags.ThirtyTwoBitAdditiveFixupFlag))
|
||||
#endif
|
||||
builder.AppendLine(entry.AdditiveFixupValueDWORD, " Additive fixup value");
|
||||
else
|
||||
builder.AppendLine(entry.AdditiveFixupValueWORD, " Additive fixup value");
|
||||
@@ -614,11 +655,7 @@ namespace SabreTools.Printing
|
||||
}
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ImportModuleNameTableEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ImportModuleNameTableEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Import Module Name Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -645,11 +682,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ImportModuleProcedureNameTableEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ImportModuleProcedureNameTableEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Import Module Procedure Name Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -676,11 +709,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, PerPageChecksumTableEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, PerPageChecksumTableEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Per-Page Checksum Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -706,11 +735,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, NonResidentNamesTableEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, NonResidentNamesTableEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Non-Resident Names Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -738,11 +763,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DebugInformation di)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DebugInformation? di)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Debug Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -1,10 +1,15 @@
|
||||
using System.Text;
|
||||
using SabreTools.Models.MSDOS;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
|
||||
namespace SabreTools.Printing
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public static class MSDOS
|
||||
public class MSDOS : IPrinter<Executable>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, Executable model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, Executable executable)
|
||||
{
|
||||
builder.AppendLine("MS-DOS Executable Information:");
|
||||
@@ -15,11 +20,7 @@ namespace SabreTools.Printing
|
||||
Print(builder, executable.RelocationTable);
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ExecutableHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ExecutableHeader? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -47,11 +48,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, RelocationEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, RelocationEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Relocation Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -1,11 +1,15 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using SabreTools.Models.MicrosoftCabinet;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
|
||||
namespace SabreTools.Printing
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public static class MicrosoftCabinet
|
||||
public class MicrosoftCabinet : IPrinter<Cabinet>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, Cabinet model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, Cabinet cabinet)
|
||||
{
|
||||
builder.AppendLine("Microsoft Cabinet Information:");
|
||||
@@ -17,11 +21,7 @@ namespace SabreTools.Printing
|
||||
Print(builder, cabinet.Files);
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, CFHEADER header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, CFHEADER? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -46,7 +46,11 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine(header.SetID, " Set ID");
|
||||
builder.AppendLine(header.CabinetIndex, " Cabinet index");
|
||||
|
||||
#if NET20 || NET35
|
||||
if ((header.Flags & HeaderFlags.RESERVE_PRESENT) != 0)
|
||||
#else
|
||||
if (header.Flags.HasFlag(HeaderFlags.RESERVE_PRESENT))
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(header.HeaderReservedSize, " Header reserved size");
|
||||
builder.AppendLine(header.FolderReservedSize, " Folder reserved size");
|
||||
@@ -54,13 +58,21 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine(header.ReservedData, " Reserved data");
|
||||
}
|
||||
|
||||
#if NET20 || NET35
|
||||
if ((header.Flags & HeaderFlags.PREV_CABINET) != 0)
|
||||
#else
|
||||
if (header.Flags.HasFlag(HeaderFlags.PREV_CABINET))
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(header.CabinetPrev, " Previous cabinet");
|
||||
builder.AppendLine(header.DiskPrev, " Previous disk");
|
||||
}
|
||||
|
||||
#if NET20 || NET35
|
||||
if ((header.Flags & HeaderFlags.NEXT_CABINET) != 0)
|
||||
#else
|
||||
if (header.Flags.HasFlag(HeaderFlags.NEXT_CABINET))
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(header.CabinetNext, " Next cabinet");
|
||||
builder.AppendLine(header.DiskNext, " Next disk");
|
||||
@@ -69,11 +81,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, CFFOLDER[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, CFFOLDER?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Folders:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -129,11 +137,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, CFFILE[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, CFFILE?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Files:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
243
SabreTools.Printing/Printers/MoPaQ.cs
Normal file
243
SabreTools.Printing/Printers/MoPaQ.cs
Normal file
@@ -0,0 +1,243 @@
|
||||
using System.Text;
|
||||
using SabreTools.Models.MoPaQ;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public class MoPaQ : IPrinter<Archive>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, Archive model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, Archive archive)
|
||||
{
|
||||
builder.AppendLine("MoPaQ Archive Information:");
|
||||
builder.AppendLine("-------------------------");
|
||||
builder.AppendLine();
|
||||
|
||||
Print(builder, archive.UserData);
|
||||
Print(builder, archive.ArchiveHeader);
|
||||
Print(builder, archive.HetTable);
|
||||
Print(builder, archive.BetTable);
|
||||
Print(builder, archive.HashTable);
|
||||
Print(builder, archive.BlockTable);
|
||||
Print(builder, archive.HiBlockTable);
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, UserData? userData)
|
||||
{
|
||||
builder.AppendLine(" User Data Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (userData == null)
|
||||
{
|
||||
builder.AppendLine(" No user data");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendLine(userData.Signature, " Signature");
|
||||
builder.AppendLine(userData.UserDataSize, " User data size");
|
||||
builder.AppendLine(userData.HeaderOffset, " Header offset");
|
||||
builder.AppendLine(userData.UserDataHeaderSize, " User data header size");
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, ArchiveHeader? header)
|
||||
{
|
||||
builder.AppendLine(" Archive Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (header == null)
|
||||
{
|
||||
builder.AppendLine(" No archive header");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendLine(header.Signature, " Signature");
|
||||
builder.AppendLine(header.HeaderSize, " Header size");
|
||||
builder.AppendLine(header.ArchiveSize, " Archive size");
|
||||
builder.AppendLine($" Format version: {header.FormatVersion} (0x{header.FormatVersion:X})");
|
||||
builder.AppendLine(header.BlockSize, " Block size");
|
||||
builder.AppendLine(header.HashTablePosition, " Hash table position");
|
||||
builder.AppendLine(header.BlockTablePosition, " Block table position");
|
||||
builder.AppendLine(header.HashTableSize, " Hash table size");
|
||||
builder.AppendLine(header.BlockTableSize, " Block table size");
|
||||
builder.AppendLine(header.HiBlockTablePosition, " Hi-block table position");
|
||||
builder.AppendLine(header.HashTablePositionHi, " Hash table position hi");
|
||||
builder.AppendLine(header.BlockTablePositionHi, " Block table position hi");
|
||||
builder.AppendLine(header.ArchiveSizeLong, " Archive size long");
|
||||
builder.AppendLine(header.BetTablePosition, " BET table position");
|
||||
builder.AppendLine(header.HetTablePosition, " HET table position");
|
||||
builder.AppendLine(header.HashTableSizeLong, " Hash table size long");
|
||||
builder.AppendLine(header.BlockTableSizeLong, " Block table size long");
|
||||
builder.AppendLine(header.HiBlockTableSize, " Hi-block table size");
|
||||
builder.AppendLine(header.HetTableSize, " HET table size");
|
||||
builder.AppendLine(header.BetTablesize, " BET table size"); // TODO: Fix casing
|
||||
builder.AppendLine(header.RawChunkSize, " Raw chunk size");
|
||||
builder.AppendLine(header.BlockTableMD5, " Block table MD5");
|
||||
builder.AppendLine(header.HashTableMD5, " Hash table MD5");
|
||||
builder.AppendLine(header.HiBlockTableMD5, " Hi-block table MD5");
|
||||
builder.AppendLine(header.BetTableMD5, " BET table MD5");
|
||||
builder.AppendLine(header.HetTableMD5, " HET table MD5");
|
||||
builder.AppendLine(header.MpqHeaderMD5, " MPQ header MD5");
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, HetTable? table)
|
||||
{
|
||||
builder.AppendLine(" HET Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (table == null)
|
||||
{
|
||||
builder.AppendLine(" No HET table");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendLine(table.Signature, " Signature");
|
||||
builder.AppendLine(table.Version, " Version");
|
||||
builder.AppendLine(table.DataSize, " Data size");
|
||||
builder.AppendLine(table.TableSize, " Table size");
|
||||
builder.AppendLine(table.MaxFileCount, " Max file count");
|
||||
builder.AppendLine(table.HashTableSize, " Hash table size");
|
||||
builder.AppendLine(table.HashEntrySize, " Hash entry size");
|
||||
builder.AppendLine(table.TotalIndexSize, " Total index size");
|
||||
builder.AppendLine(table.IndexSizeExtra, " Index size extra");
|
||||
builder.AppendLine(table.IndexSize, " Index size");
|
||||
builder.AppendLine(table.BlockTableSize, " Block table size");
|
||||
builder.AppendLine(table.HashTable, " Hash table");
|
||||
|
||||
builder.AppendLine(" File indexes:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (table.FileIndexes == null)
|
||||
{
|
||||
builder.AppendLine(" No file indexes ");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < table.FileIndexes.Length; i++)
|
||||
{
|
||||
builder.AppendLine(table.FileIndexes[i], $" File index {i}");
|
||||
}
|
||||
}
|
||||
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, BetTable? table)
|
||||
{
|
||||
builder.AppendLine(" BET Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (table == null)
|
||||
{
|
||||
builder.AppendLine(" No BET table");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendLine(table.Signature, " Signature");
|
||||
builder.AppendLine(table.Version, " Version");
|
||||
builder.AppendLine(table.DataSize, " Data size");
|
||||
builder.AppendLine(table.TableSize, " Table size");
|
||||
builder.AppendLine(table.FileCount, " File count");
|
||||
builder.AppendLine(table.Unknown, " Unknown");
|
||||
builder.AppendLine(table.TableEntrySize, " Table entry size");
|
||||
builder.AppendLine(table.FilePositionBitIndex, " File position bit index");
|
||||
builder.AppendLine(table.FileSizeBitIndex, " File size bit index");
|
||||
builder.AppendLine(table.CompressedSizeBitIndex, " Compressed size bit index");
|
||||
builder.AppendLine(table.FlagIndexBitIndex, " Flag index bit index");
|
||||
builder.AppendLine(table.UnknownBitIndex, " Unknown bit index");
|
||||
builder.AppendLine(table.FilePositionBitCount, " File position bit count");
|
||||
builder.AppendLine(table.FileSizeBitCount, " File size bit count");
|
||||
builder.AppendLine(table.CompressedSizeBitCount, " Compressed size bit count");
|
||||
builder.AppendLine(table.FlagIndexBitCount, " Flag index bit count");
|
||||
builder.AppendLine(table.UnknownBitCount, " Unknown bit count");
|
||||
builder.AppendLine(table.TotalBetHashSize, " Total BET hash size");
|
||||
builder.AppendLine(table.BetHashSizeExtra, " BET hash size extra");
|
||||
builder.AppendLine(table.BetHashSize, " BET hash size");
|
||||
builder.AppendLine(table.BetHashArraySize, " BET hash array size");
|
||||
builder.AppendLine(table.FlagCount, " Flag count");
|
||||
builder.AppendLine(table.FlagsArray, " Flags array");
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, HashEntry?[]? entries)
|
||||
{
|
||||
builder.AppendLine(" Hash Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (entries == null || entries.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No hash table items");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < entries.Length; i++)
|
||||
{
|
||||
var entry = entries[i];
|
||||
builder.AppendLine($" Hash Table Entry {i}");
|
||||
if (entry == null)
|
||||
{
|
||||
builder.AppendLine(" [NULL]");
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.AppendLine(entry.NameHashPartA, " Name hash, part A");
|
||||
builder.AppendLine(entry.NameHashPartB, " Name hash, part B");
|
||||
builder.AppendLine($" Locale: {entry.Locale} (0x{entry.Locale:X})");
|
||||
builder.AppendLine(entry.Platform, " Platform");
|
||||
builder.AppendLine(entry.BlockIndex, " BlockIndex");
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, BlockEntry?[]? entries)
|
||||
{
|
||||
builder.AppendLine(" Block Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (entries == null || entries.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No block table items");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < entries.Length; i++)
|
||||
{
|
||||
var entry = entries[i];
|
||||
builder.AppendLine($" Block Table Entry {i}");
|
||||
if (entry == null)
|
||||
{
|
||||
builder.AppendLine(" [NULL]");
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.AppendLine(entry.FilePosition, " File position");
|
||||
builder.AppendLine(entry.CompressedSize, " Compressed size");
|
||||
builder.AppendLine(entry.UncompressedSize, " Uncompressed size");
|
||||
builder.AppendLine($" Flags: {entry.Flags} (0x{entry.Flags:X})");
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, short[]? entries)
|
||||
{
|
||||
builder.AppendLine(" Hi-block Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (entries == null || entries.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No hi-block table items");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < entries.Length; i++)
|
||||
{
|
||||
var entry = entries[i];
|
||||
builder.AppendLine($" Hi-block Table Entry {i}: {entry}");
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,15 @@
|
||||
using System.Text;
|
||||
using SabreTools.Models.N3DS;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
|
||||
namespace SabreTools.Printing
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public static class N3DS
|
||||
public class N3DS : IPrinter<Cart>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, Cart model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, Cart cart)
|
||||
{
|
||||
builder.AppendLine("3DS Cart Information:");
|
||||
@@ -20,11 +25,7 @@ namespace SabreTools.Printing
|
||||
Print(builder, cart.RomFSHeaders);
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, NCSDHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, NCSDHeader? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" NCSD Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -107,11 +108,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, CardInfoHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, CardInfoHeader? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Card Info Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -136,11 +133,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DevelopmentCardInfoHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DevelopmentCardInfoHeader? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Development Card Info Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -234,11 +227,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, NCCHHeader[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, NCCHHeader?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" NCCH Partition Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -318,11 +307,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, NCCHExtendedHeader[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, NCCHExtendedHeader?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" NCCH Extended Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -546,11 +531,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ExeFSHeader[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ExeFSHeader?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" ExeFS Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -620,11 +601,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, RomFSHeader[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, RomFSHeader?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" RomFS Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -1,10 +1,16 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using SabreTools.Models.NCF;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
|
||||
namespace SabreTools.Printing
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public static class NCF
|
||||
public class NCF : IPrinter<File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, File model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, File file)
|
||||
{
|
||||
builder.AppendLine("NCF Information:");
|
||||
@@ -16,7 +22,7 @@ namespace SabreTools.Printing
|
||||
|
||||
// Directory and Directory Maps
|
||||
Print(builder, file.DirectoryHeader);
|
||||
Print(builder, file.DirectoryEntries);
|
||||
Print(builder, file.DirectoryEntries, file.DirectoryNames);
|
||||
// TODO: Should we print out the entire string table?
|
||||
Print(builder, file.DirectoryInfo1Entries);
|
||||
Print(builder, file.DirectoryInfo2Entries);
|
||||
@@ -32,11 +38,7 @@ namespace SabreTools.Printing
|
||||
Print(builder, file.ChecksumEntries);
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Header header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Header? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -61,11 +63,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DirectoryHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DirectoryHeader? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Directory Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -93,11 +91,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DirectoryEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DirectoryEntry?[]? entries)
|
||||
#endif
|
||||
private static void Print(StringBuilder builder, DirectoryEntry?[]? entries, Dictionary<long, string?>? entryNames)
|
||||
{
|
||||
builder.AppendLine(" Directory Entries Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -119,7 +113,7 @@ namespace SabreTools.Printing
|
||||
}
|
||||
|
||||
builder.AppendLine(entry.NameOffset, " Name offset");
|
||||
builder.AppendLine(entry.Name, " Name");
|
||||
builder.AppendLine(entryNames![entry.NameOffset], " Name");
|
||||
builder.AppendLine(entry.ItemSize, " Item size");
|
||||
builder.AppendLine(entry.ChecksumIndex, " Checksum index");
|
||||
builder.AppendLine($" Directory flags: {entry.DirectoryFlags} (0x{entry.DirectoryFlags:X})");
|
||||
@@ -130,11 +124,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DirectoryInfo1Entry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DirectoryInfo1Entry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Directory Info 1 Entries Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -160,11 +150,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DirectoryInfo2Entry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DirectoryInfo2Entry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Directory Info 2 Entries Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -190,11 +176,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DirectoryCopyEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DirectoryCopyEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Directory Copy Entries Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -220,11 +202,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DirectoryLocalEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DirectoryLocalEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Directory Local Entries Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -250,11 +228,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, UnknownHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, UnknownHeader? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Unknown Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -270,11 +244,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, UnknownEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, UnknownEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Unknown Entries Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -300,11 +270,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ChecksumHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ChecksumHeader? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Checksum Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -320,11 +286,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ChecksumMapHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ChecksumMapHeader? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Checksum Map Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -342,11 +304,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ChecksumMapEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ChecksumMapEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Checksum Map Entries Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -373,11 +331,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ChecksumEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ChecksumEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Checksum Entries Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -1,12 +1,17 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using SabreTools.Models.NewExecutable;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
using static SabreTools.Serialization.Extensions;
|
||||
|
||||
namespace SabreTools.Printing
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public static class NewExecutable
|
||||
public class NewExecutable : IPrinter<Executable>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, Executable model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, Executable executable)
|
||||
{
|
||||
builder.AppendLine("New Executable Information:");
|
||||
@@ -29,11 +34,7 @@ namespace SabreTools.Printing
|
||||
Print(builder, executable.NonResidentNameTable);
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, SabreTools.Models.MSDOS.ExecutableHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, SabreTools.Models.MSDOS.ExecutableHeader? header)
|
||||
#endif
|
||||
private static void Print(StringBuilder builder, Models.MSDOS.ExecutableHeader? header)
|
||||
{
|
||||
builder.AppendLine(" MS-DOS Stub Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -70,11 +71,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ExecutableHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ExecutableHeader? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -119,11 +116,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, SegmentTableEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, SegmentTableEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Segment Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -152,11 +145,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ResourceTable table)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ResourceTable? table)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Resource Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -225,13 +214,12 @@ namespace SabreTools.Printing
|
||||
foreach (var typeAndNameString in table.TypeAndNameStrings)
|
||||
{
|
||||
builder.AppendLine($" Resource Type/Name Offset {typeAndNameString.Key}");
|
||||
#if NET6_0_OR_GREATER
|
||||
if (typeAndNameString.Value == null)
|
||||
{
|
||||
builder.AppendLine(" [NULL]");
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
builder.AppendLine(typeAndNameString.Value.Length, " Length");
|
||||
builder.AppendLine(typeAndNameString.Value.Text, " Text", Encoding.ASCII);
|
||||
}
|
||||
@@ -239,11 +227,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ResidentNameTableEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ResidentNameTableEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Resident-Name Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -271,11 +255,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ModuleReferenceTableEntry[] entries, SabreTools.Models.MSDOS.ExecutableHeader stub, ExecutableHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ModuleReferenceTableEntry?[]? entries, SabreTools.Models.MSDOS.ExecutableHeader? stub, ExecutableHeader? header)
|
||||
#endif
|
||||
private static void Print(StringBuilder builder, ModuleReferenceTableEntry?[]? entries, Models.MSDOS.ExecutableHeader? stub, ExecutableHeader? header)
|
||||
{
|
||||
builder.AppendLine(" Module-Reference Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -297,20 +277,12 @@ namespace SabreTools.Printing
|
||||
continue;
|
||||
}
|
||||
|
||||
#if NET48
|
||||
builder.AppendLine($" Offset: {entry.Offset} (adjusted to be {entry.Offset + stub.NewExeHeaderAddr + header.ImportedNamesTableOffset})");
|
||||
#else
|
||||
builder.AppendLine($" Offset: {entry.Offset} (adjusted to be {entry.Offset + (stub?.NewExeHeaderAddr ?? 0) + (header?.ImportedNamesTableOffset ?? 0)})");
|
||||
#endif
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Dictionary<ushort, ImportedNameTableEntry> entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Dictionary<ushort, ImportedNameTableEntry?>? entries)
|
||||
#endif
|
||||
private static void Print(StringBuilder builder, Dictionary<ushort, ImportedNameTableEntry>? entries)
|
||||
{
|
||||
builder.AppendLine(" Imported-Name Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -324,24 +296,19 @@ namespace SabreTools.Printing
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
builder.AppendLine($" Imported-Name Table at Offset {entry.Key}");
|
||||
#if NET6_0_OR_GREATER
|
||||
if (entry.Value == null)
|
||||
{
|
||||
builder.AppendLine(" [NULL]");
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if (entry.Value == null)
|
||||
{
|
||||
builder.AppendLine(" [NULL]");
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.AppendLine(entry.Value.Length, " Length");
|
||||
builder.AppendLine(entry.Value.NameString, " Name string", Encoding.ASCII);
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, EntryTableBundle[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, EntryTableBundle?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Entry Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -381,11 +348,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, NonResidentNameTableEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, NonResidentNameTableEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Nonresident-Name Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -1,10 +1,15 @@
|
||||
using System.Text;
|
||||
using SabreTools.Models.Nitro;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
|
||||
namespace SabreTools.Printing
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public static class Nitro
|
||||
public class Nitro : IPrinter<Cart>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, Cart model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, Cart cart)
|
||||
{
|
||||
builder.AppendLine("NDS Cart Information:");
|
||||
@@ -18,11 +23,7 @@ namespace SabreTools.Printing
|
||||
Print(builder, cart.FileAllocationTable);
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, CommonHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, CommonHeader? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Common Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -76,11 +77,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ExtendedDSiHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ExtendedDSiHeader? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Extended DSi Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -142,11 +139,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, byte[] secureArea)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, byte[]? secureArea)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Secure Area Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -154,11 +147,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, NameTable table)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, NameTable? table)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Name Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -174,11 +163,7 @@ namespace SabreTools.Printing
|
||||
Print(builder, table.NameList);
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, FolderAllocationTableEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, FolderAllocationTableEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Folder Allocation Table:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -215,11 +200,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, NameListEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, NameListEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Name List:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -248,11 +229,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, FileAllocationTableEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, FileAllocationTableEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" File Allocation Table:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -1,10 +1,15 @@
|
||||
using System.Text;
|
||||
using SabreTools.Models.PAK;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
|
||||
namespace SabreTools.Printing
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public static class PAK
|
||||
public class PAK : IPrinter<File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, File model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, File file)
|
||||
{
|
||||
builder.AppendLine("PAK Information:");
|
||||
@@ -15,11 +20,7 @@ namespace SabreTools.Printing
|
||||
Print(builder, file.DirectoryItems);
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Header header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Header? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -36,11 +37,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DirectoryItem[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DirectoryItem?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Directory Items Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -1,10 +1,15 @@
|
||||
using System.Text;
|
||||
using SabreTools.Models.PFF;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
|
||||
namespace SabreTools.Printing
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public static class PFF
|
||||
public class PFF : IPrinter<Archive>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, Archive model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, Archive archive)
|
||||
{
|
||||
builder.AppendLine("PFF Information:");
|
||||
@@ -16,11 +21,7 @@ namespace SabreTools.Printing
|
||||
Print(builder, archive.Footer);
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Header header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Header? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -39,11 +40,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Segment[] segments)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Segment?[]? segments)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Segments Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -75,11 +72,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Footer footer)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Footer? footer)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Footer Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
87
SabreTools.Printing/Printers/PIC.cs
Normal file
87
SabreTools.Printing/Printers/PIC.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using System.Text;
|
||||
using SabreTools.Models.PIC;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public class PIC : IPrinter<DiscInformation>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, DiscInformation model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, DiscInformation di)
|
||||
{
|
||||
builder.AppendLine("PIC Information:");
|
||||
builder.AppendLine("-------------------------");
|
||||
builder.AppendLine(di.DataStructureLength, "Data structure length");
|
||||
builder.AppendLine(di.Reserved0, "Reserved");
|
||||
builder.AppendLine(di.Reserved1, "Reserved");
|
||||
builder.AppendLine();
|
||||
|
||||
Print(builder, di.Units);
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, DiscInformationUnit?[]? entries)
|
||||
{
|
||||
builder.AppendLine(" Disc Information Units:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (entries == null || entries.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No disc information units");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < entries.Length; i++)
|
||||
{
|
||||
var entry = entries[i];
|
||||
builder.AppendLine($" Disc Information Unit {i}");
|
||||
if (entry == null)
|
||||
{
|
||||
builder.AppendLine(" [NULL]");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (entry.Header == null)
|
||||
{
|
||||
builder.AppendLine(" No header");
|
||||
}
|
||||
else
|
||||
{
|
||||
var header = entry.Header;
|
||||
builder.AppendLine(header.DiscInformationIdentifier, " Disc information identifier");
|
||||
builder.AppendLine(header.DiscInformationFormat, " Disc information format");
|
||||
builder.AppendLine(header.Reserved0, " Reserved");
|
||||
builder.AppendLine(header.SequenceNumber, " Sequence number");
|
||||
builder.AppendLine(header.BytesInUse, " Bytes in use");
|
||||
builder.AppendLine(header.Reserved1, " Reserved");
|
||||
}
|
||||
if (entry.Body == null)
|
||||
{
|
||||
builder.AppendLine(" No body");
|
||||
}
|
||||
else
|
||||
{
|
||||
DiscInformationUnitBody body = entry.Body;
|
||||
builder.AppendLine(body.DiscTypeIdentifier, " Disc type identifer");
|
||||
builder.AppendLine(body.DiscSizeClassVersion, " Disc size class version");
|
||||
builder.AppendLine(body.FormatDependentContents, " Format-dependent contents");
|
||||
}
|
||||
if (entry.Trailer == null)
|
||||
{
|
||||
builder.AppendLine(" No trailer");
|
||||
}
|
||||
else
|
||||
{
|
||||
DiscInformationUnitTrailer trailer = entry.Trailer;
|
||||
builder.AppendLine(trailer.DiscManufacturerID, " Disc manufacturer ID");
|
||||
builder.AppendLine(trailer.MediaTypeID, " Media type ID");
|
||||
builder.AppendLine(trailer.TimeStamp, " Timestamp");
|
||||
builder.AppendLine(trailer.ProductRevisionNumber, " Product revision number");
|
||||
}
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,15 @@
|
||||
using System.Text;
|
||||
using SabreTools.Models.PlayJ;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
|
||||
namespace SabreTools.Printing
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public static class PlayJAudioFile
|
||||
public class PlayJAudioFile : IPrinter<AudioFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, AudioFile model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, AudioFile audio)
|
||||
{
|
||||
builder.AppendLine("PlayJ Audio File Information:");
|
||||
@@ -25,11 +30,7 @@ namespace SabreTools.Printing
|
||||
}
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, AudioHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, AudioHeader? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Audio Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -103,11 +104,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, UnknownBlock1 block)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, UnknownBlock1? block)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Unknown Block 1 Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -123,32 +120,22 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, uint value)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, uint? value)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Unknown Value 2 Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
#if NET6_0_OR_GREATER
|
||||
if (value == null)
|
||||
{
|
||||
builder.AppendLine(" No unknown block 1r");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
builder.AppendLine(value, " Value");
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, UnknownBlock3 block)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, UnknownBlock3? block)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Unknown Block 3 Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -163,11 +150,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, uint count, DataFile[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, uint count, DataFile?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Data Files Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
226
SabreTools.Printing/Printers/PlayJPlaylist.cs
Normal file
226
SabreTools.Printing/Printers/PlayJPlaylist.cs
Normal file
@@ -0,0 +1,226 @@
|
||||
using System.Text;
|
||||
using SabreTools.Models.PlayJ;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public class PlayJPlaylist : IPrinter<Playlist>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, Playlist model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, Playlist playlist)
|
||||
{
|
||||
builder.AppendLine("PlayJ Playlist Information:");
|
||||
builder.AppendLine("-------------------------");
|
||||
builder.AppendLine();
|
||||
|
||||
Print(builder, playlist.Header);
|
||||
Print(builder, playlist.AudioFiles);
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, PlaylistHeader? header)
|
||||
{
|
||||
builder.AppendLine(" Playlist Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (header == null)
|
||||
{
|
||||
builder.AppendLine(" No playlist header");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendLine(header.TrackCount, " Track count");
|
||||
builder.AppendLine(header.Data, " Data");
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, AudioFile?[]? entries)
|
||||
{
|
||||
builder.AppendLine(" Audio Files Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (entries == null || entries.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No audio files");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < entries.Length; i++)
|
||||
{
|
||||
var entry = entries[i];
|
||||
builder.AppendLine($" Audio File {i}:");
|
||||
if (entry == null)
|
||||
{
|
||||
builder.AppendLine(" [NULL]");
|
||||
continue;
|
||||
}
|
||||
|
||||
Print(builder, entry.Header);
|
||||
Print(builder, entry.UnknownBlock1);
|
||||
|
||||
if (entry.Header?.Version == 0x00000000)
|
||||
{
|
||||
Print(builder, entry.UnknownValue2);
|
||||
Print(builder, entry.UnknownBlock3);
|
||||
}
|
||||
else if (entry.Header?.Version == 0x0000000A)
|
||||
{
|
||||
Print(builder, entry.DataFilesCount, entry.DataFiles);
|
||||
}
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, AudioHeader? header)
|
||||
{
|
||||
builder.AppendLine(" Audio Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (header == null)
|
||||
{
|
||||
builder.AppendLine(" No audio header");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendLine(header.Signature, " Signature");
|
||||
builder.AppendLine(header.Version, " Version");
|
||||
if (header.Version == 0x00000000 && header is AudioHeaderV1 headerV1)
|
||||
{
|
||||
builder.AppendLine(headerV1.TrackID, " Track ID");
|
||||
builder.AppendLine(headerV1.UnknownOffset1, " Unknown offset 1");
|
||||
builder.AppendLine(headerV1.UnknownOffset2, " Unknown offset 2");
|
||||
builder.AppendLine(headerV1.UnknownOffset3, " Unknown offset 3");
|
||||
builder.AppendLine(headerV1.Unknown1, " Unknown 1");
|
||||
builder.AppendLine(headerV1.Unknown2, " Unknown 2");
|
||||
builder.AppendLine(headerV1.Year, " Year");
|
||||
builder.AppendLine(headerV1.TrackNumber, " Track number");
|
||||
builder.AppendLine($" Subgenre: {headerV1.Subgenre} (0x{headerV1.Subgenre:X})");
|
||||
builder.AppendLine(headerV1.Duration, " Duration in seconds");
|
||||
}
|
||||
else if (header.Version == 0x0000000A && header is AudioHeaderV2 headerV2)
|
||||
{
|
||||
builder.AppendLine(headerV2.Unknown1, " Unknown 1");
|
||||
builder.AppendLine(headerV2.Unknown2, " Unknown 2");
|
||||
builder.AppendLine(headerV2.Unknown3, " Unknown 3");
|
||||
builder.AppendLine(headerV2.Unknown4, " Unknown 4");
|
||||
builder.AppendLine(headerV2.Unknown5, " Unknown 5");
|
||||
builder.AppendLine(headerV2.Unknown6, " Unknown 6");
|
||||
builder.AppendLine(headerV2.UnknownOffset1, " Unknown Offset 1");
|
||||
builder.AppendLine(headerV2.Unknown7, " Unknown 7");
|
||||
builder.AppendLine(headerV2.Unknown8, " Unknown 8");
|
||||
builder.AppendLine(headerV2.Unknown9, " Unknown 9");
|
||||
builder.AppendLine(headerV2.UnknownOffset2, " Unknown Offset 2");
|
||||
builder.AppendLine(headerV2.Unknown10, " Unknown 10");
|
||||
builder.AppendLine(headerV2.Unknown11, " Unknown 11");
|
||||
builder.AppendLine(headerV2.Unknown12, " Unknown 12");
|
||||
builder.AppendLine(headerV2.Unknown13, " Unknown 13");
|
||||
builder.AppendLine(headerV2.Unknown14, " Unknown 14");
|
||||
builder.AppendLine(headerV2.Unknown15, " Unknown 15");
|
||||
builder.AppendLine(headerV2.Unknown16, " Unknown 16");
|
||||
builder.AppendLine(headerV2.Unknown17, " Unknown 17");
|
||||
builder.AppendLine(headerV2.TrackID, " Track ID");
|
||||
builder.AppendLine(headerV2.Year, " Year");
|
||||
builder.AppendLine(headerV2.TrackNumber, " Track number");
|
||||
builder.AppendLine(headerV2.Unknown18, " Unknown 18");
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.AppendLine(" Unrecognized version, not parsed...");
|
||||
}
|
||||
|
||||
builder.AppendLine(header.TrackLength, " Track length");
|
||||
builder.AppendLine(header.Track, " Track");
|
||||
builder.AppendLine(header.ArtistLength, " Artist length");
|
||||
builder.AppendLine(header.Artist, " Artist");
|
||||
builder.AppendLine(header.AlbumLength, " Album length");
|
||||
builder.AppendLine(header.Album, " Album");
|
||||
builder.AppendLine(header.WriterLength, " Writer length");
|
||||
builder.AppendLine(header.Writer, " Writer");
|
||||
builder.AppendLine(header.PublisherLength, " Publisher length");
|
||||
builder.AppendLine(header.Publisher, " Publisher");
|
||||
builder.AppendLine(header.LabelLength, " Label length");
|
||||
builder.AppendLine(header.Label, " Label");
|
||||
builder.AppendLine(header.CommentsLength, " Comments length");
|
||||
builder.AppendLine(header.Comments, " Comments");
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, UnknownBlock1? block)
|
||||
{
|
||||
builder.AppendLine(" Unknown Block 1 Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (block == null)
|
||||
{
|
||||
builder.AppendLine(" No unknown block 1r");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendLine(block.Length, " Length");
|
||||
builder.AppendLine(block.Data, " Data");
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, uint? value)
|
||||
{
|
||||
builder.AppendLine(" Unknown Value 2 Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (value == null)
|
||||
{
|
||||
builder.AppendLine(" No unknown block 1r");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendLine(value, " Value");
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, UnknownBlock3? block)
|
||||
{
|
||||
builder.AppendLine(" Unknown Block 3 Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (block == null)
|
||||
{
|
||||
builder.AppendLine(" No unknown block 1r");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendLine(block.Data, " Data");
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, uint count, DataFile?[]? entries)
|
||||
{
|
||||
builder.AppendLine(" Data Files Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
builder.AppendLine(count, " Data files count");
|
||||
if (count == 0 || entries == null || entries.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No data files");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < entries.Length; i++)
|
||||
{
|
||||
var entry = entries[i];
|
||||
builder.AppendLine($" Data File {i}:");
|
||||
if (entry == null)
|
||||
{
|
||||
builder.AppendLine(" [NULL]");
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.AppendLine(entry.FileNameLength, " File name length");
|
||||
builder.AppendLine(entry.FileName, " File name");
|
||||
builder.AppendLine(entry.DataLength, " Data length");
|
||||
builder.AppendLine(entry.Data, " Data");
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using SabreTools.ASN1;
|
||||
using SabreTools.IO;
|
||||
using SabreTools.IO.Extensions;
|
||||
using SabreTools.Models.PortableExecutable;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
using static SabreTools.Serialization.Extensions;
|
||||
|
||||
namespace SabreTools.Printing
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public static class PortableExecutable
|
||||
public class PortableExecutable : IPrinter<Executable>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, Executable model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, Executable executable)
|
||||
{
|
||||
builder.AppendLine("Portable Executable Information:");
|
||||
@@ -39,11 +45,7 @@ namespace SabreTools.Printing
|
||||
Print(builder, executable.ResourceDirectoryTable);
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, SabreTools.Models.MSDOS.ExecutableHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, SabreTools.Models.MSDOS.ExecutableHeader? header)
|
||||
#endif
|
||||
private static void Print(StringBuilder builder, Models.MSDOS.ExecutableHeader? header)
|
||||
{
|
||||
builder.AppendLine(" MS-DOS Stub Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -80,11 +82,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, string signature, COFFFileHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, string? signature, COFFFileHeader? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" COFF File Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -106,11 +104,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, OptionalHeader header, SectionHeader[] table)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, OptionalHeader? header, SectionHeader?[]? table)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Optional Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -171,49 +165,49 @@ namespace SabreTools.Printing
|
||||
{
|
||||
builder.AppendLine(" Export Table (1)");
|
||||
builder.AppendLine(header.ExportTable.VirtualAddress, " Virtual address");
|
||||
builder.AppendLine(header.ExportTable.VirtualAddress.ConvertVirtualAddress(table ?? Array.Empty<SectionHeader>()), " Physical address");
|
||||
builder.AppendLine(header.ExportTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.ExportTable.Size, " Size");
|
||||
}
|
||||
if (header.ImportTable != null)
|
||||
{
|
||||
builder.AppendLine(" Import Table (2)");
|
||||
builder.AppendLine(header.ImportTable.VirtualAddress, " Virtual address");
|
||||
builder.AppendLine(header.ImportTable.VirtualAddress.ConvertVirtualAddress(table ?? Array.Empty<SectionHeader>()), " Physical address");
|
||||
builder.AppendLine(header.ImportTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.ImportTable.Size, " Size");
|
||||
}
|
||||
if (header.ResourceTable != null)
|
||||
{
|
||||
builder.AppendLine(" Resource Table (3)");
|
||||
builder.AppendLine(header.ResourceTable.VirtualAddress, " Virtual address");
|
||||
builder.AppendLine(header.ResourceTable.VirtualAddress.ConvertVirtualAddress(table ?? Array.Empty<SectionHeader>()), " Physical address");
|
||||
builder.AppendLine(header.ResourceTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.ResourceTable.Size, " Size");
|
||||
}
|
||||
if (header.ExceptionTable != null)
|
||||
{
|
||||
builder.AppendLine(" Exception Table (4)");
|
||||
builder.AppendLine(header.ExceptionTable.VirtualAddress, " Virtual address");
|
||||
builder.AppendLine(header.ExceptionTable.VirtualAddress.ConvertVirtualAddress(table ?? Array.Empty<SectionHeader>()), " Physical address");
|
||||
builder.AppendLine(header.ExceptionTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.ExceptionTable.Size, " Size");
|
||||
}
|
||||
if (header.CertificateTable != null)
|
||||
{
|
||||
builder.AppendLine(" Certificate Table (5)");
|
||||
builder.AppendLine(header.CertificateTable.VirtualAddress, " Virtual address");
|
||||
builder.AppendLine(header.CertificateTable.VirtualAddress.ConvertVirtualAddress(table ?? Array.Empty<SectionHeader>()), " Physical address");
|
||||
builder.AppendLine(header.CertificateTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.CertificateTable.Size, " Size");
|
||||
}
|
||||
if (header.BaseRelocationTable != null)
|
||||
{
|
||||
builder.AppendLine(" Base Relocation Table (6)");
|
||||
builder.AppendLine(header.BaseRelocationTable.VirtualAddress, " Virtual address");
|
||||
builder.AppendLine(header.BaseRelocationTable.VirtualAddress.ConvertVirtualAddress(table ?? Array.Empty<SectionHeader>()), " Physical address");
|
||||
builder.AppendLine(header.BaseRelocationTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.BaseRelocationTable.Size, " Size");
|
||||
}
|
||||
if (header.Debug != null)
|
||||
{
|
||||
builder.AppendLine(" Debug Table (7)");
|
||||
builder.AppendLine(header.Debug.VirtualAddress, " Virtual address");
|
||||
builder.AppendLine(header.Debug.VirtualAddress.ConvertVirtualAddress(table ?? Array.Empty<SectionHeader>()), " Physical address");
|
||||
builder.AppendLine(header.Debug.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.Debug.Size, " Size");
|
||||
}
|
||||
if (header.NumberOfRvaAndSizes >= 8)
|
||||
@@ -227,49 +221,49 @@ namespace SabreTools.Printing
|
||||
{
|
||||
builder.AppendLine(" Global Pointer Register (9)");
|
||||
builder.AppendLine(header.GlobalPtr.VirtualAddress, " Virtual address");
|
||||
builder.AppendLine(header.GlobalPtr.VirtualAddress.ConvertVirtualAddress(table ?? Array.Empty<SectionHeader>()), " Physical address");
|
||||
builder.AppendLine(header.GlobalPtr.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.GlobalPtr.Size, " Size");
|
||||
}
|
||||
if (header.ThreadLocalStorageTable != null)
|
||||
{
|
||||
builder.AppendLine(" Thread Local Storage (TLS) Table (10)");
|
||||
builder.AppendLine(header.ThreadLocalStorageTable.VirtualAddress, " Virtual address");
|
||||
builder.AppendLine(header.ThreadLocalStorageTable.VirtualAddress.ConvertVirtualAddress(table ?? Array.Empty<SectionHeader>()), " Physical address");
|
||||
builder.AppendLine(header.ThreadLocalStorageTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.ThreadLocalStorageTable.Size, " Size");
|
||||
}
|
||||
if (header.LoadConfigTable != null)
|
||||
{
|
||||
builder.AppendLine(" Load Config Table (11)");
|
||||
builder.AppendLine(header.LoadConfigTable.VirtualAddress, " Virtual address");
|
||||
builder.AppendLine(header.LoadConfigTable.VirtualAddress.ConvertVirtualAddress(table ?? Array.Empty<SectionHeader>()), " Physical address");
|
||||
builder.AppendLine(header.LoadConfigTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.LoadConfigTable.Size, " Size");
|
||||
}
|
||||
if (header.BoundImport != null)
|
||||
{
|
||||
builder.AppendLine(" Bound Import Table (12)");
|
||||
builder.AppendLine(header.BoundImport.VirtualAddress, " Virtual address");
|
||||
builder.AppendLine(header.BoundImport.VirtualAddress.ConvertVirtualAddress(table ?? Array.Empty<SectionHeader>()), " Physical address");
|
||||
builder.AppendLine(header.BoundImport.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.BoundImport.Size, " Size");
|
||||
}
|
||||
if (header.ImportAddressTable != null)
|
||||
{
|
||||
builder.AppendLine(" Import Address Table (13)");
|
||||
builder.AppendLine(header.ImportAddressTable.VirtualAddress, " Virtual address");
|
||||
builder.AppendLine(header.ImportAddressTable.VirtualAddress.ConvertVirtualAddress(table ?? Array.Empty<SectionHeader>()), " Physical address");
|
||||
builder.AppendLine(header.ImportAddressTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.ImportAddressTable.Size, " Size");
|
||||
}
|
||||
if (header.DelayImportDescriptor != null)
|
||||
{
|
||||
builder.AppendLine(" Delay Import Descriptior (14)");
|
||||
builder.AppendLine(header.DelayImportDescriptor.VirtualAddress, " Virtual address");
|
||||
builder.AppendLine(header.DelayImportDescriptor.VirtualAddress.ConvertVirtualAddress(table ?? Array.Empty<SectionHeader>()), " Physical address");
|
||||
builder.AppendLine(header.DelayImportDescriptor.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.DelayImportDescriptor.Size, " Size");
|
||||
}
|
||||
if (header.CLRRuntimeHeader != null)
|
||||
{
|
||||
builder.AppendLine(" CLR Runtime Header (15)");
|
||||
builder.AppendLine(header.CLRRuntimeHeader.VirtualAddress, " Virtual address");
|
||||
builder.AppendLine(header.CLRRuntimeHeader.VirtualAddress.ConvertVirtualAddress(table ?? Array.Empty<SectionHeader>()), " Physical address");
|
||||
builder.AppendLine(header.CLRRuntimeHeader.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.CLRRuntimeHeader.Size, " Size");
|
||||
}
|
||||
if (header.NumberOfRvaAndSizes >= 16)
|
||||
@@ -282,11 +276,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, SectionHeader[] table)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, SectionHeader?[]? table)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Section Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -297,11 +287,7 @@ namespace SabreTools.Printing
|
||||
return;
|
||||
}
|
||||
|
||||
#if NET48
|
||||
for (int i = 0; i < table.Length; i++)
|
||||
#else
|
||||
for (int i = 0; i < table!.Length; i++)
|
||||
#endif
|
||||
for (int i = 0; i < table!.Length; i++)
|
||||
{
|
||||
var entry = table[i];
|
||||
builder.AppendLine($" Section Table Entry {i}");
|
||||
@@ -311,10 +297,10 @@ namespace SabreTools.Printing
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.AppendLine(entry.Name, " Name");
|
||||
builder.AppendLine(entry.Name, " Name", Encoding.ASCII);
|
||||
builder.AppendLine(entry.VirtualSize, " Virtual size");
|
||||
builder.AppendLine(entry.VirtualAddress, " Virtual address");
|
||||
builder.AppendLine(entry.VirtualAddress.ConvertVirtualAddress(table ?? Array.Empty<SectionHeader>()), " Physical address");
|
||||
builder.AppendLine(entry.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(entry.SizeOfRawData, " Size of raw data");
|
||||
builder.AppendLine(entry.PointerToRawData, " Pointer to raw data");
|
||||
builder.AppendLine(entry.PointerToRelocations, " Pointer to relocations");
|
||||
@@ -328,11 +314,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, COFFSymbolTableEntry[] symbolTable)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, COFFSymbolTableEntry?[]? symbolTable)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" COFF Symbol Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -360,7 +342,7 @@ namespace SabreTools.Printing
|
||||
{
|
||||
if (entry.ShortName != null)
|
||||
{
|
||||
builder.AppendLine(entry.ShortName, " Short name");
|
||||
builder.AppendLine(entry.ShortName, " Short name", Encoding.ASCII);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -438,7 +420,7 @@ namespace SabreTools.Printing
|
||||
}
|
||||
else if (currentSymbolType == 4)
|
||||
{
|
||||
builder.AppendLine(entry.AuxFormat4FileName, " File name");
|
||||
builder.AppendLine(entry.AuxFormat4FileName, " File name", Encoding.ASCII);
|
||||
auxSymbolsRemaining--;
|
||||
}
|
||||
else if (currentSymbolType == 5)
|
||||
@@ -468,11 +450,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, COFFStringTable stringTable)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, COFFStringTable? stringTable)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" COFF String Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -486,22 +464,14 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine(stringTable.TotalSize, " Total size");
|
||||
for (int i = 0; i < stringTable.Strings.Length; i++)
|
||||
{
|
||||
#if NET48
|
||||
string entry = stringTable.Strings[i];
|
||||
#else
|
||||
string? entry = stringTable.Strings[i];
|
||||
#endif
|
||||
builder.AppendLine($" COFF String Table Entry {i})");
|
||||
builder.AppendLine(entry, " Value");
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, AttributeCertificateTableEntry[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, AttributeCertificateTableEntry?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Attribute Certificate Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -570,11 +540,7 @@ namespace SabreTools.Printing
|
||||
}
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DelayLoadDirectoryTable table)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DelayLoadDirectoryTable? table)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Delay-Load Directory Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -596,11 +562,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, BaseRelocationBlock[] entries, SectionHeader[] table)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, BaseRelocationBlock?[]? entries, SectionHeader?[]? table)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Base Relocation Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -622,7 +584,7 @@ namespace SabreTools.Printing
|
||||
}
|
||||
|
||||
builder.AppendLine(baseRelocationTableEntry.PageRVA, " Page RVA");
|
||||
builder.AppendLine(baseRelocationTableEntry.PageRVA.ConvertVirtualAddress(table ?? Array.Empty<SectionHeader>()), " Page physical address");
|
||||
builder.AppendLine(baseRelocationTableEntry.PageRVA.ConvertVirtualAddress(table), " Page physical address");
|
||||
builder.AppendLine(baseRelocationTableEntry.BlockSize, " Block size");
|
||||
|
||||
builder.AppendLine($" Base Relocation Table {i} Type and Offset Information:");
|
||||
@@ -637,13 +599,12 @@ namespace SabreTools.Printing
|
||||
{
|
||||
var typeOffsetFieldEntry = baseRelocationTableEntry.TypeOffsetFieldEntries[j];
|
||||
builder.AppendLine($" Type and Offset Entry {j}");
|
||||
#if NET6_0_OR_GREATER
|
||||
if (typeOffsetFieldEntry == null)
|
||||
{
|
||||
builder.AppendLine(" [NULL]");
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if (typeOffsetFieldEntry == null)
|
||||
{
|
||||
builder.AppendLine(" [NULL]");
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.AppendLine($" Type: {typeOffsetFieldEntry.BaseRelocationType} (0x{typeOffsetFieldEntry.BaseRelocationType:X})");
|
||||
builder.AppendLine(typeOffsetFieldEntry.Offset, " Offset");
|
||||
}
|
||||
@@ -651,11 +612,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DebugTable table)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DebugTable? table)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Debug Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -689,11 +646,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ExportTable table)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ExportTable? table)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Export Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -802,11 +755,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ImportTable table, SectionHeader[] sectionTable)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ImportTable? table, SectionHeader?[]? sectionTable)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Import Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -837,13 +786,13 @@ namespace SabreTools.Printing
|
||||
}
|
||||
|
||||
builder.AppendLine(importDirectoryTableEntry.ImportLookupTableRVA, " Import lookup table RVA");
|
||||
builder.AppendLine(importDirectoryTableEntry.ImportLookupTableRVA.ConvertVirtualAddress(sectionTable ?? Array.Empty<SectionHeader>()), " Import lookup table Physical Address");
|
||||
builder.AppendLine(importDirectoryTableEntry.ImportLookupTableRVA.ConvertVirtualAddress(sectionTable), " Import lookup table Physical Address");
|
||||
builder.AppendLine(importDirectoryTableEntry.TimeDateStamp, " Time/Date stamp");
|
||||
builder.AppendLine(importDirectoryTableEntry.ForwarderChain, " Forwarder chain");
|
||||
builder.AppendLine(importDirectoryTableEntry.NameRVA, " Name RVA");
|
||||
builder.AppendLine(importDirectoryTableEntry.Name, " Name");
|
||||
builder.AppendLine(importDirectoryTableEntry.ImportAddressTableRVA, " Import address table RVA");
|
||||
builder.AppendLine(importDirectoryTableEntry.ImportAddressTableRVA.ConvertVirtualAddress(sectionTable ?? Array.Empty<SectionHeader>()), " Import address table Physical Address");
|
||||
builder.AppendLine(importDirectoryTableEntry.ImportAddressTableRVA.ConvertVirtualAddress(sectionTable), " Import address table Physical Address");
|
||||
}
|
||||
}
|
||||
builder.AppendLine();
|
||||
@@ -888,7 +837,7 @@ namespace SabreTools.Printing
|
||||
else
|
||||
{
|
||||
builder.AppendLine(importLookupTableEntry.HintNameTableRVA, " Hint/Name table RVA");
|
||||
builder.AppendLine(importLookupTableEntry.HintNameTableRVA.ConvertVirtualAddress(sectionTable ?? Array.Empty<SectionHeader>()), " Hint/Name table Physical Address");
|
||||
builder.AppendLine(importLookupTableEntry.HintNameTableRVA.ConvertVirtualAddress(sectionTable), " Hint/Name table Physical Address");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -935,7 +884,7 @@ namespace SabreTools.Printing
|
||||
else
|
||||
{
|
||||
builder.AppendLine(importAddressTableEntry.HintNameTableRVA, " Hint/Name table RVA");
|
||||
builder.AppendLine(importAddressTableEntry.HintNameTableRVA.ConvertVirtualAddress(sectionTable ?? Array.Empty<SectionHeader>()), " Hint/Name table Physical Address");
|
||||
builder.AppendLine(importAddressTableEntry.HintNameTableRVA.ConvertVirtualAddress(sectionTable), " Hint/Name table Physical Address");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -967,11 +916,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ResourceDirectoryTable table)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ResourceDirectoryTable? table)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Resource Directory Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -982,13 +927,13 @@ namespace SabreTools.Printing
|
||||
return;
|
||||
}
|
||||
|
||||
Print(table, level: 0, types: new List<object>(), builder);
|
||||
Print(table, level: 0, types: [], builder);
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(ResourceDirectoryTable table, int level, List<object> types, StringBuilder builder)
|
||||
{
|
||||
string padding = new string(' ', (level + 1) * 2);
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
|
||||
builder.AppendLine(level, $"{padding}Table level");
|
||||
builder.AppendLine(table.Characteristics, $"{padding}Characteristics");
|
||||
@@ -1017,7 +962,7 @@ namespace SabreTools.Printing
|
||||
if (entry == null)
|
||||
continue;
|
||||
|
||||
var newTypes = new List<object>(types ?? new List<object>());
|
||||
var newTypes = new List<object>(types ?? []);
|
||||
if (entry.Name?.UnicodeString != null)
|
||||
newTypes.Add(Encoding.UTF8.GetString(entry.Name.UnicodeString));
|
||||
else
|
||||
@@ -1030,13 +975,13 @@ namespace SabreTools.Printing
|
||||
|
||||
private static void PrintResourceDirectoryEntry(ResourceDirectoryEntry entry, int level, List<object> types, StringBuilder builder)
|
||||
{
|
||||
string padding = new string(' ', (level + 1) * 2);
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
|
||||
builder.AppendLine(level, $"{padding}Item level");
|
||||
if (entry.NameOffset != default)
|
||||
{
|
||||
builder.AppendLine(entry.NameOffset, $"{padding}Name offset");
|
||||
builder.AppendLine(entry.Name?.UnicodeString, $"{padding}Name ({entry.Name?.Length ?? 0})");
|
||||
builder.AppendLine(entry.Name?.UnicodeString, $"{padding}Name ({entry.Name?.Length ?? 0})", Encoding.Unicode);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1051,10 +996,10 @@ namespace SabreTools.Printing
|
||||
|
||||
private static void PrintResourceDataEntry(ResourceDataEntry entry, int level, List<object> types, StringBuilder builder)
|
||||
{
|
||||
string padding = new string(' ', (level + 1) * 2);
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
|
||||
// TODO: Use ordered list of base types to determine the shape of the data
|
||||
builder.AppendLine($"{padding}Base types: {string.Join(", ", types)}");
|
||||
builder.AppendLine($"{padding}Base types: {string.Join(", ", types.Select(t => t.ToString()).ToArray())}");
|
||||
|
||||
builder.AppendLine(level, $"{padding}Entry level");
|
||||
builder.AppendLine(entry.DataRVA, $"{padding}Data RVA");
|
||||
@@ -1145,31 +1090,27 @@ namespace SabreTools.Printing
|
||||
|
||||
private static void PrintResourceRT_CURSOR(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new string(' ', (level + 1) * 2);
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}Hardware-dependent cursor resource found, not parsed yet");
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_BITMAP(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new string(' ', (level + 1) * 2);
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}Bitmap resource found, not parsed yet");
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_ICON(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new string(' ', (level + 1) * 2);
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}Hardware-dependent icon resource found, not parsed yet");
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_MENU(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new string(' ', (level + 1) * 2);
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
|
||||
#if NET48
|
||||
MenuResource menu = null;
|
||||
#else
|
||||
MenuResource? menu = null;
|
||||
#endif
|
||||
try { menu = entry.AsMenu(); } catch { }
|
||||
if (menu == null)
|
||||
{
|
||||
@@ -1200,18 +1141,18 @@ namespace SabreTools.Printing
|
||||
continue;
|
||||
}
|
||||
|
||||
if (menuItem.NormalMenuText != null)
|
||||
if (menuItem is NormalMenuItem normalMenuItem)
|
||||
{
|
||||
builder.AppendLine($"{padding} Resource info: {menuItem.NormalResInfo} (0x{menuItem.NormalResInfo:X})");
|
||||
builder.AppendLine(menuItem.NormalMenuText, $"{padding} Menu text");
|
||||
builder.AppendLine($"{padding} Resource info: {normalMenuItem.NormalResInfo} (0x{normalMenuItem.NormalResInfo:X})");
|
||||
builder.AppendLine(normalMenuItem.NormalMenuText, $"{padding} Menu text");
|
||||
}
|
||||
else
|
||||
else if (menuItem is PopupMenuItem popupMenuItem)
|
||||
{
|
||||
builder.AppendLine($"{padding} Item type: {menuItem.PopupItemType} (0x{menuItem.PopupItemType:X})");
|
||||
builder.AppendLine($"{padding} State: {menuItem.PopupState} (0x{menuItem.PopupState:X})");
|
||||
builder.AppendLine(menuItem.PopupID, $"{padding} ID");
|
||||
builder.AppendLine($"{padding} Resource info: {menuItem.PopupResInfo} (0x{menuItem.PopupResInfo:X})");
|
||||
builder.AppendLine(menuItem.PopupMenuText, $"{padding} Menu text");
|
||||
builder.AppendLine($"{padding} Item type: {popupMenuItem.PopupItemType} (0x{popupMenuItem.PopupItemType:X})");
|
||||
builder.AppendLine($"{padding} State: {popupMenuItem.PopupState} (0x{popupMenuItem.PopupState:X})");
|
||||
builder.AppendLine(popupMenuItem.PopupID, $"{padding} ID");
|
||||
builder.AppendLine($"{padding} Resource info: {popupMenuItem.PopupResInfo} (0x{popupMenuItem.PopupResInfo:X})");
|
||||
builder.AppendLine(popupMenuItem.PopupMenuText, $"{padding} Menu text");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1257,13 +1198,9 @@ namespace SabreTools.Printing
|
||||
|
||||
private static void PrintResourceRT_DIALOG(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new string(' ', (level + 1) * 2);
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
|
||||
#if NET48
|
||||
DialogBoxResource dialogBox = null;
|
||||
#else
|
||||
DialogBoxResource? dialogBox = null;
|
||||
#endif
|
||||
try { dialogBox = entry.AsDialogBox(); } catch { }
|
||||
if (dialogBox == null)
|
||||
{
|
||||
@@ -1396,13 +1333,9 @@ namespace SabreTools.Printing
|
||||
|
||||
private static void PrintResourceRT_STRING(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new string(' ', (level + 1) * 2);
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
|
||||
#if NET48
|
||||
Dictionary<int, string> stringTable = null;
|
||||
#else
|
||||
Dictionary<int, string?>? stringTable = null;
|
||||
#endif
|
||||
try { stringTable = entry.AsStringTable(); } catch { }
|
||||
if (stringTable == null)
|
||||
{
|
||||
@@ -1413,36 +1346,28 @@ namespace SabreTools.Printing
|
||||
foreach (var kvp in stringTable)
|
||||
{
|
||||
int index = kvp.Key;
|
||||
#if NET48
|
||||
string stringValue = kvp.Value;
|
||||
#else
|
||||
string? stringValue = kvp.Value;
|
||||
#endif
|
||||
builder.AppendLine(stringValue, $"{padding}String entry {index}");
|
||||
}
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_FONTDIR(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new string(' ', (level + 1) * 2);
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}Font directory resource found, not parsed yet");
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_FONT(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new string(' ', (level + 1) * 2);
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}Font resource found, not parsed yet");
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_ACCELERATOR(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new string(' ', (level + 1) * 2);
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
|
||||
#if NET48
|
||||
AcceleratorTableEntry[] acceleratorTable = null;
|
||||
#else
|
||||
AcceleratorTableEntry[]? acceleratorTable = null;
|
||||
#endif
|
||||
try { acceleratorTable = entry.AsAcceleratorTableResource(); } catch { }
|
||||
if (acceleratorTable == null)
|
||||
{
|
||||
@@ -1463,7 +1388,7 @@ namespace SabreTools.Printing
|
||||
|
||||
private static void PrintResourceRT_RCDATA(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new string(' ', (level + 1) * 2);
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}Application-defined resource found, not parsed yet");
|
||||
|
||||
// Then print the data, if needed
|
||||
@@ -1474,11 +1399,7 @@ namespace SabreTools.Printing
|
||||
else
|
||||
{
|
||||
int offset = 0;
|
||||
#if NET48
|
||||
byte[] magic = entry.Data.ReadBytes(ref offset, Math.Min(entry.Data.Length, 16));
|
||||
#else
|
||||
byte[]? magic = entry.Data.ReadBytes(ref offset, Math.Min(entry.Data.Length, 16));
|
||||
#endif
|
||||
|
||||
if (magic == null)
|
||||
{
|
||||
@@ -1510,13 +1431,9 @@ namespace SabreTools.Printing
|
||||
|
||||
private static void PrintResourceRT_MESSAGETABLE(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new string(' ', (level + 1) * 2);
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
|
||||
#if NET48
|
||||
MessageResourceData messageTable = null;
|
||||
#else
|
||||
MessageResourceData? messageTable = null;
|
||||
#endif
|
||||
try { messageTable = entry.AsMessageResourceData(); } catch { }
|
||||
if (messageTable == null)
|
||||
{
|
||||
@@ -1581,25 +1498,21 @@ namespace SabreTools.Printing
|
||||
|
||||
private static void PrintResourceRT_GROUP_CURSOR(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new string(' ', (level + 1) * 2);
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}Hardware-independent cursor resource found, not parsed yet");
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_GROUP_ICON(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new string(' ', (level + 1) * 2);
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}Hardware-independent icon resource found, not parsed yet");
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_VERSION(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new string(' ', (level + 1) * 2);
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
|
||||
#if NET48
|
||||
VersionInfo versionInfo = null;
|
||||
#else
|
||||
VersionInfo? versionInfo = null;
|
||||
#endif
|
||||
try { versionInfo = entry.AsVersionInfo(); } catch { }
|
||||
if (versionInfo == null)
|
||||
{
|
||||
@@ -1718,37 +1631,37 @@ namespace SabreTools.Printing
|
||||
|
||||
private static void PrintResourceRT_DLGINCLUDE(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new string(' ', (level + 1) * 2);
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}External header resource found, not parsed yet");
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_PLUGPLAY(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new string(' ', (level + 1) * 2);
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}Plug and Play resource found, not parsed yet");
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_VXD(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new string(' ', (level + 1) * 2);
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}VXD found, not parsed yet");
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_ANICURSOR(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new string(' ', (level + 1) * 2);
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}Animated cursor found, not parsed yet");
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_ANIICON(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new string(' ', (level + 1) * 2);
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}Animated icon found, not parsed yet");
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_HTML(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new string(' ', (level + 1) * 2);
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}HTML resource found, not parsed yet");
|
||||
|
||||
//if (entry.Data != null)
|
||||
@@ -1761,13 +1674,9 @@ namespace SabreTools.Printing
|
||||
|
||||
private static void PrintResourceRT_MANIFEST(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new string(' ', (level + 1) * 2);
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
|
||||
#if NET48
|
||||
AssemblyManifest assemblyManifest = null;
|
||||
#else
|
||||
AssemblyManifest? assemblyManifest = null;
|
||||
#endif
|
||||
try { assemblyManifest = entry.AsAssemblyManifest(); } catch { }
|
||||
if (assemblyManifest == null)
|
||||
{
|
||||
@@ -1983,7 +1892,7 @@ namespace SabreTools.Printing
|
||||
|
||||
private static void PrintResourceUNKNOWN(ResourceDataEntry entry, int level, object resourceType, StringBuilder builder)
|
||||
{
|
||||
string padding = new string(' ', (level + 1) * 2);
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
|
||||
// Print the type first
|
||||
if (resourceType is uint numericType)
|
||||
@@ -2001,12 +1910,8 @@ namespace SabreTools.Printing
|
||||
else
|
||||
{
|
||||
int offset = 0;
|
||||
#if NET48
|
||||
byte[] magic = entry.Data.ReadBytes(ref offset, Math.Min(entry.Data.Length, 16));
|
||||
#else
|
||||
byte[]? magic = entry.Data.ReadBytes(ref offset, Math.Min(entry.Data.Length, 16));
|
||||
#endif
|
||||
|
||||
byte[]? magic = entry.Data.ReadBytes(ref offset, Math.Min(entry.Data.Length, 16));
|
||||
if (magic == null)
|
||||
{
|
||||
// No-op
|
||||
@@ -1,10 +1,15 @@
|
||||
using System.Text;
|
||||
using SabreTools.Models.Quantum;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
|
||||
namespace SabreTools.Printing
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public static class Quantum
|
||||
public class Quantum : IPrinter<Archive>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, Archive model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, Archive archive)
|
||||
{
|
||||
builder.AppendLine("Quantum Information:");
|
||||
@@ -17,11 +22,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Header header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Header? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -41,11 +42,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, FileDescriptor[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, FileDescriptor?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" File List Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -1,10 +1,15 @@
|
||||
using System.Text;
|
||||
using SabreTools.Models.SGA;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
|
||||
namespace SabreTools.Printing
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public static class SGA
|
||||
public class SGA : IPrinter<File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, File model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, File file)
|
||||
{
|
||||
builder.AppendLine("SGA Information:");
|
||||
@@ -19,11 +24,7 @@ namespace SabreTools.Printing
|
||||
// TODO: Should we print the string table?
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Header header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Header? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -58,11 +59,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Directory directory)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Directory? directory)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Directory Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -110,11 +107,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DirectoryHeader4 header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DirectoryHeader4? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Directory Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -136,11 +129,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DirectoryHeader5 header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DirectoryHeader5? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Directory Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -162,11 +151,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DirectoryHeader7 header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DirectoryHeader7? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Directory Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -190,11 +175,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Section4[] sections)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Section4?[]? sections)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Sections Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -226,11 +207,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Section5[] sections)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Section5?[]? sections)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Sections Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -262,11 +239,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Folder4[] folders)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Folder4?[]? folders)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Folders Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -297,11 +270,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Folder5[] folders)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Folder5?[]? folders)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Folders Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -332,11 +301,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, File4[] files)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, File4?[]? files)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Files Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -369,11 +334,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, File6[] files)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, File6?[]? files)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Files Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -407,11 +368,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, File7[] files)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, File7?[]? files)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Files Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -1,11 +1,16 @@
|
||||
using System.Text;
|
||||
using SabreTools.Models.VBSP;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
using static SabreTools.Models.VBSP.Constants;
|
||||
|
||||
namespace SabreTools.Printing
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public static class VBSP
|
||||
public class VBSP : IPrinter<File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, File model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, File file)
|
||||
{
|
||||
builder.AppendLine("VBSP Information:");
|
||||
@@ -15,11 +20,7 @@ namespace SabreTools.Printing
|
||||
Print(builder, file.Header);
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Header header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Header? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -38,11 +39,7 @@ namespace SabreTools.Printing
|
||||
Print(builder, header.Lumps);
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Lump[] lumps)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Lump?[]? lumps)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Lumps Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -1,10 +1,15 @@
|
||||
using System.Text;
|
||||
using SabreTools.Models.VPK;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
|
||||
namespace SabreTools.Printing
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public static class VPK
|
||||
public class VPK : IPrinter<File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, File model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, File file)
|
||||
{
|
||||
builder.AppendLine("VPK Information:");
|
||||
@@ -17,11 +22,7 @@ namespace SabreTools.Printing
|
||||
Print(builder, file.DirectoryItems);
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Header header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Header? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -38,11 +39,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ExtendedHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ExtendedHeader? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Extended Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -60,11 +57,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, ArchiveHash[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, ArchiveHash?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Archive Hashes Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -93,11 +86,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DirectoryItem[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DirectoryItem?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Directory Items Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -130,11 +119,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DirectoryEntry entry)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DirectoryEntry? entry)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Directory Entry:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -1,10 +1,15 @@
|
||||
using System.Text;
|
||||
using SabreTools.Models.WAD;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
|
||||
namespace SabreTools.Printing
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public static class WAD
|
||||
public class WAD : IPrinter<File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, File model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, File file)
|
||||
{
|
||||
builder.AppendLine("WAD Information:");
|
||||
@@ -16,11 +21,7 @@ namespace SabreTools.Printing
|
||||
Print(builder, file.LumpInfos);
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Header header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Header? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -37,11 +38,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Lump[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Lump?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Lumps Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -74,11 +71,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, LumpInfo[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, LumpInfo?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Lump Infos Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
28
SabreTools.Printing/Printers/XMID.cs
Normal file
28
SabreTools.Printing/Printers/XMID.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.Text;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
using static SabreTools.Models.Xbox.Constants;
|
||||
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public class XMID : IPrinter<Models.Xbox.XMID>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, Models.Xbox.XMID model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, Models.Xbox.XMID xmid)
|
||||
{
|
||||
builder.AppendLine("Xbox Media Identifier Information:");
|
||||
builder.AppendLine("-------------------------");
|
||||
builder.AppendLine(xmid.PublisherIdentifier, "Publisher identifier");
|
||||
if (!string.IsNullOrEmpty(xmid.PublisherIdentifier) && Publishers.ContainsKey(xmid.PublisherIdentifier ?? string.Empty))
|
||||
builder.AppendLine(Publishers[xmid.PublisherIdentifier ?? string.Empty], "Publisher");
|
||||
builder.AppendLine(xmid.GameID, "Game ID");
|
||||
builder.AppendLine(xmid.VersionNumber, "Version number");
|
||||
builder.AppendLine(xmid.RegionIdentifier, "Region identifier");
|
||||
if (Regions.ContainsKey(xmid.RegionIdentifier))
|
||||
builder.AppendLine(Regions[xmid.RegionIdentifier], "Region");
|
||||
builder.AppendLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,15 @@
|
||||
using System.Text;
|
||||
using SabreTools.Models.XZP;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
|
||||
namespace SabreTools.Printing
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public static class XZP
|
||||
public class XZP : IPrinter<File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, File model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, File file)
|
||||
{
|
||||
builder.AppendLine("XZP Information:");
|
||||
@@ -19,11 +24,7 @@ namespace SabreTools.Printing
|
||||
Print(builder, file.Footer);
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Header header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Header? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -46,11 +47,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DirectoryEntry[] entries, string prefix)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DirectoryEntry?[]? entries, string prefix)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine($" {prefix} Entries Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -78,11 +75,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DirectoryMapping[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DirectoryMapping?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Preload Directory Mappings Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -108,11 +101,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, DirectoryItem[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, DirectoryItem?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Directory Items Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -141,11 +130,7 @@ namespace SabreTools.Printing
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, Footer footer)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, Footer? footer)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Footer Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
35
SabreTools.Printing/Printers/XeMID.cs
Normal file
35
SabreTools.Printing/Printers/XeMID.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Text;
|
||||
using SabreTools.Printing.Interfaces;
|
||||
using static SabreTools.Models.Xbox.Constants;
|
||||
|
||||
namespace SabreTools.Printing.Printers
|
||||
{
|
||||
public class XeMID : IPrinter<Models.Xbox.XeMID>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void PrintInformation(StringBuilder builder, Models.Xbox.XeMID model)
|
||||
=> Print(builder, model);
|
||||
|
||||
public static void Print(StringBuilder builder, Models.Xbox.XeMID xemid)
|
||||
{
|
||||
builder.AppendLine("Xbox Media Identifier Information:");
|
||||
builder.AppendLine("-------------------------");
|
||||
builder.AppendLine(xemid.PublisherIdentifier, "Publisher identifier");
|
||||
if (!string.IsNullOrEmpty(xemid.PublisherIdentifier) && Publishers.ContainsKey(xemid.PublisherIdentifier ?? string.Empty))
|
||||
builder.AppendLine(Publishers[xemid.PublisherIdentifier ?? string.Empty], "Publisher");
|
||||
builder.AppendLine(xemid.PlatformIdentifier, "Platform identifier");
|
||||
builder.AppendLine(xemid.GameID, "Game ID");
|
||||
builder.AppendLine(xemid.SKU, "SKU");
|
||||
builder.AppendLine(xemid.RegionIdentifier, "Region identifier");
|
||||
if (Regions.ContainsKey(xemid.RegionIdentifier))
|
||||
builder.AppendLine(Regions[xemid.RegionIdentifier], "Region");
|
||||
builder.AppendLine(xemid.BaseVersion, "Base version");
|
||||
builder.AppendLine(xemid.MediaSubtypeIdentifier, "Media subtype identifier");
|
||||
if (MediaSubtypes.ContainsKey(xemid.MediaSubtypeIdentifier))
|
||||
builder.AppendLine(MediaSubtypes[xemid.MediaSubtypeIdentifier], "Media subtype");
|
||||
builder.AppendLine(xemid.DiscNumberIdentifier, "Disc number identifier");
|
||||
builder.AppendLine(xemid.CertificationSubmissionIdentifier, "Certification submission identifier");
|
||||
builder.AppendLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,17 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<!-- Assembly Properties -->
|
||||
<TargetFrameworks>net48;net6.0;net7.0;net8.0</TargetFrameworks>
|
||||
<RuntimeIdentifiers>win-x86;win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
|
||||
<Version>1.1.0</Version>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
|
||||
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<Version>1.3.9</Version>
|
||||
|
||||
<!-- Package Properties -->
|
||||
<Authors>Matt Nadareski</Authors>
|
||||
<Description>Pretty-printing library for various models</Description>
|
||||
<Copyright>Copyright (c) Matt Nadareski 2022-2023</Copyright>
|
||||
<Copyright>Copyright (c) Matt Nadareski 2022-2024</Copyright>
|
||||
<PackageProjectUrl>https://github.com/SabreTools/</PackageProjectUrl>
|
||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||
<RepositoryUrl>https://github.com/SabreTools/SabreTools.Printing</RepositoryUrl>
|
||||
@@ -19,19 +21,15 @@
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(TargetFramework)'!='net48'">
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="README.md" Pack="true" PackagePath=""/>
|
||||
<None Include="../README.md" Pack="true" PackagePath="" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SabreTools.ASN1" Version="1.1.0" />
|
||||
<PackageReference Include="SabreTools.IO" Version="1.1.1" />
|
||||
<PackageReference Include="SabreTools.Models" Version="1.1.2" />
|
||||
<PackageReference Include="SabreTools.Serialization" Version="1.1.5" />
|
||||
<PackageReference Include="SabreTools.ASN1" Version="1.3.1" />
|
||||
<PackageReference Include="SabreTools.IO" Version="1.4.0" />
|
||||
<PackageReference Include="SabreTools.Models" Version="1.4.5" />
|
||||
<PackageReference Include="SabreTools.Serialization" Version="1.5.6" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,58 +1,36 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace SabreTools.Printing
|
||||
{
|
||||
// TODO: Add extension for printing enums, if possible
|
||||
internal static class Extensions
|
||||
internal static class StringBuilderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Append a line containing a boolean to a StringBuilder
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, bool value, string prefixString)
|
||||
#else
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, bool? value, string prefixString)
|
||||
#endif
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
value ??= false;
|
||||
#endif
|
||||
|
||||
return sb.AppendLine($"{prefixString}: {value.ToString()}");
|
||||
return sb.AppendLine($"{prefixString}: {value}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append a line containing a Char to a StringBuilder
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, char value, string prefixString)
|
||||
#else
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, char? value, string prefixString)
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
string valueString = value.ToString();
|
||||
#else
|
||||
string valueString = (value == null ? "[NULL]" : value.Value.ToString());
|
||||
#endif
|
||||
|
||||
return sb.AppendLine($"{prefixString}: {valueString}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append a line containing a Int8 to a StringBuilder
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, sbyte value, string prefixString)
|
||||
#else
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, sbyte? value, string prefixString)
|
||||
#endif
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
value ??= 0;
|
||||
#endif
|
||||
|
||||
string valueString = $"{value} (0x{value:X})";
|
||||
return sb.AppendLine($"{prefixString}: {valueString}");
|
||||
}
|
||||
@@ -60,16 +38,9 @@ namespace SabreTools.Printing
|
||||
/// <summary>
|
||||
/// Append a line containing a UInt8 to a StringBuilder
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, byte value, string prefixString)
|
||||
#else
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, byte? value, string prefixString)
|
||||
#endif
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
value ??= 0;
|
||||
#endif
|
||||
|
||||
string valueString = $"{value} (0x{value:X})";
|
||||
return sb.AppendLine($"{prefixString}: {valueString}");
|
||||
}
|
||||
@@ -77,16 +48,9 @@ namespace SabreTools.Printing
|
||||
/// <summary>
|
||||
/// Append a line containing a Int16 to a StringBuilder
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, short value, string prefixString)
|
||||
#else
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, short? value, string prefixString)
|
||||
#endif
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
value ??= 0;
|
||||
#endif
|
||||
|
||||
string valueString = $"{value} (0x{value:X})";
|
||||
return sb.AppendLine($"{prefixString}: {valueString}");
|
||||
}
|
||||
@@ -94,16 +58,9 @@ namespace SabreTools.Printing
|
||||
/// <summary>
|
||||
/// Append a line containing a UInt16 to a StringBuilder
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, ushort value, string prefixString)
|
||||
#else
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, ushort? value, string prefixString)
|
||||
#endif
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
value ??= 0;
|
||||
#endif
|
||||
|
||||
string valueString = $"{value} (0x{value:X})";
|
||||
return sb.AppendLine($"{prefixString}: {valueString}");
|
||||
}
|
||||
@@ -111,16 +68,9 @@ namespace SabreTools.Printing
|
||||
/// <summary>
|
||||
/// Append a line containing a Int32 to a StringBuilder
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, int value, string prefixString)
|
||||
#else
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, int? value, string prefixString)
|
||||
#endif
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
value ??= 0;
|
||||
#endif
|
||||
|
||||
string valueString = $"{value} (0x{value:X})";
|
||||
return sb.AppendLine($"{prefixString}: {valueString}");
|
||||
}
|
||||
@@ -128,16 +78,9 @@ namespace SabreTools.Printing
|
||||
/// <summary>
|
||||
/// Append a line containing a UInt32 to a StringBuilder
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, uint value, string prefixString)
|
||||
#else
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, uint? value, string prefixString)
|
||||
#endif
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
value ??= 0;
|
||||
#endif
|
||||
|
||||
string valueString = $"{value} (0x{value:X})";
|
||||
return sb.AppendLine($"{prefixString}: {valueString}");
|
||||
}
|
||||
@@ -145,16 +88,9 @@ namespace SabreTools.Printing
|
||||
/// <summary>
|
||||
/// Append a line containing a Int64 to a StringBuilder
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, long value, string prefixString)
|
||||
#else
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, long? value, string prefixString)
|
||||
#endif
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
value ??= 0;
|
||||
#endif
|
||||
|
||||
string valueString = $"{value} (0x{value:X})";
|
||||
return sb.AppendLine($"{prefixString}: {valueString}");
|
||||
}
|
||||
@@ -162,16 +98,9 @@ namespace SabreTools.Printing
|
||||
/// <summary>
|
||||
/// Append a line containing a UInt64 to a StringBuilder
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, ulong value, string prefixString)
|
||||
#else
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, ulong? value, string prefixString)
|
||||
#endif
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
value ??= 0;
|
||||
#endif
|
||||
|
||||
string valueString = $"{value} (0x{value:X})";
|
||||
return sb.AppendLine($"{prefixString}: {valueString}");
|
||||
}
|
||||
@@ -179,16 +108,9 @@ namespace SabreTools.Printing
|
||||
/// <summary>
|
||||
/// Append a line containing a string to a StringBuilder
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, string value, string prefixString)
|
||||
#else
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, string? value, string prefixString)
|
||||
#endif
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
value ??= string.Empty;
|
||||
#endif
|
||||
|
||||
string valueString = value ?? "[NULL]";
|
||||
return sb.AppendLine($"{prefixString}: {valueString}");
|
||||
}
|
||||
@@ -196,30 +118,17 @@ namespace SabreTools.Printing
|
||||
/// <summary>
|
||||
/// Append a line containing a Guid to a StringBuilder
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, Guid value, string prefixString)
|
||||
#else
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, Guid? value, string prefixString)
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
string valueString = value.ToString();
|
||||
#else
|
||||
value ??= Guid.Empty;
|
||||
string valueString = value.Value.ToString();
|
||||
#endif
|
||||
|
||||
return sb.AppendLine($"{prefixString}: {value}");
|
||||
return sb.AppendLine($"{prefixString}: {valueString}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append a line containing a UInt8[] value to a StringBuilder
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, byte[] value, string prefixString)
|
||||
#else
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, byte[]? value, string prefixString)
|
||||
#endif
|
||||
{
|
||||
string valueString = (value == null ? "[NULL]" : BitConverter.ToString(value).Replace('-', ' '));
|
||||
return sb.AppendLine($"{prefixString}: {valueString}");
|
||||
@@ -228,11 +137,7 @@ namespace SabreTools.Printing
|
||||
/// <summary>
|
||||
/// Append a line containing a UInt8[] value as a string to a StringBuilder
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, byte[] value, string prefixString, Encoding encoding)
|
||||
#else
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, byte[]? value, string prefixString, Encoding encoding)
|
||||
#endif
|
||||
{
|
||||
string valueString = (value == null ? "[NULL]" : encoding.GetString(value).Replace("\0", string.Empty));
|
||||
return sb.AppendLine($"{prefixString}: {valueString}");
|
||||
@@ -241,91 +146,63 @@ namespace SabreTools.Printing
|
||||
/// <summary>
|
||||
/// Append a line containing a Char[] value to a StringBuilder
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, char[] value, string prefixString)
|
||||
#else
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, char[]? value, string prefixString)
|
||||
#endif
|
||||
{
|
||||
string valueString = (value == null ? "[NULL]" : string.Join(", ", value));
|
||||
string valueString = (value == null ? "[NULL]" : string.Join(", ", value.Select(c => c.ToString()).ToArray()));
|
||||
return sb.AppendLine($"{prefixString}: {valueString}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append a line containing a Int16[] value to a StringBuilder
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, short[] value, string prefixString)
|
||||
#else
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, short[]? value, string prefixString)
|
||||
#endif
|
||||
{
|
||||
string valueString = (value == null ? "[NULL]" : string.Join(", ", value));
|
||||
string valueString = (value == null ? "[NULL]" : string.Join(", ", value.Select(s => s.ToString()).ToArray()));
|
||||
return sb.AppendLine($"{prefixString}: {valueString}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append a line containing a UInt16[] value to a StringBuilder
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, ushort[] value, string prefixString)
|
||||
#else
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, ushort[]? value, string prefixString)
|
||||
#endif
|
||||
{
|
||||
string valueString = (value == null ? "[NULL]" : string.Join(", ", value));
|
||||
string valueString = (value == null ? "[NULL]" : string.Join(", ", value.Select(u => u.ToString()).ToArray()));
|
||||
return sb.AppendLine($"{prefixString}: {valueString}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append a line containing a Int32[] value to a StringBuilder
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, int[] value, string prefixString)
|
||||
#else
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, int[]? value, string prefixString)
|
||||
#endif
|
||||
{
|
||||
string valueString = (value == null ? "[NULL]" : string.Join(", ", value));
|
||||
string valueString = (value == null ? "[NULL]" : string.Join(", ", value.Select(i => i.ToString()).ToArray()));
|
||||
return sb.AppendLine($"{prefixString}: {valueString}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append a line containing a UInt32[] value to a StringBuilder
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, uint[] value, string prefixString)
|
||||
#else
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, uint[]? value, string prefixString)
|
||||
#endif
|
||||
{
|
||||
string valueString = (value == null ? "[NULL]" : string.Join(", ", value));
|
||||
string valueString = (value == null ? "[NULL]" : string.Join(", ", value.Select(u => u.ToString()).ToArray()));
|
||||
return sb.AppendLine($"{prefixString}: {valueString}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append a line containing a Int64[] value to a StringBuilder
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, long[] value, string prefixString)
|
||||
#else
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, long[]? value, string prefixString)
|
||||
#endif
|
||||
{
|
||||
string valueString = (value == null ? "[NULL]" : string.Join(", ", value));
|
||||
string valueString = (value == null ? "[NULL]" : string.Join(", ", value.Select(l => l.ToString()).ToArray()));
|
||||
return sb.AppendLine($"{prefixString}: {valueString}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append a line containing a UInt64[] value to a StringBuilder
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, ulong[] value, string prefixString)
|
||||
#else
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, ulong[]? value, string prefixString)
|
||||
#endif
|
||||
{
|
||||
string valueString = (value == null ? "[NULL]" : string.Join(", ", value));
|
||||
string valueString = (value == null ? "[NULL]" : string.Join(", ", value.Select(u => u.ToString()).ToArray()));
|
||||
return sb.AppendLine($"{prefixString}: {valueString}");
|
||||
}
|
||||
}
|
||||
812
Test/FileTypes.cs
Normal file
812
Test/FileTypes.cs
Normal file
@@ -0,0 +1,812 @@
|
||||
using System;
|
||||
using SabreTools.Matching;
|
||||
|
||||
namespace Test
|
||||
{
|
||||
internal static class FileTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the supported file type for a magic string
|
||||
/// </summary>
|
||||
/// <remarks>Recommend sending in 16 bytes to check</remarks>
|
||||
public static SupportedFileType GetFileType(byte[] magic)
|
||||
{
|
||||
// If we have an invalid magic byte array
|
||||
if (magic == null || magic.Length == 0)
|
||||
return SupportedFileType.UNKNOWN;
|
||||
|
||||
// TODO: For all modelled types, use the constants instead of hardcoded values here
|
||||
#region AACSMediaKeyBlock
|
||||
|
||||
// Block starting with verify media key record
|
||||
if (magic.StartsWith(new byte?[] { 0x81, 0x00, 0x00, 0x14 }))
|
||||
return SupportedFileType.AACSMediaKeyBlock;
|
||||
|
||||
// Block starting with type and version record
|
||||
if (magic.StartsWith(new byte?[] { 0x10, 0x00, 0x00, 0x0C }))
|
||||
return SupportedFileType.AACSMediaKeyBlock;
|
||||
|
||||
#endregion
|
||||
|
||||
#region BDPlusSVM
|
||||
|
||||
if (magic.StartsWith(new byte?[] { 0x42, 0x44, 0x53, 0x56, 0x4D, 0x5F, 0x43, 0x43 }))
|
||||
return SupportedFileType.BDPlusSVM;
|
||||
|
||||
#endregion
|
||||
|
||||
#region BFPK
|
||||
|
||||
if (magic.StartsWith(new byte?[] { 0x42, 0x46, 0x50, 0x4b }))
|
||||
return SupportedFileType.BFPK;
|
||||
|
||||
#endregion
|
||||
|
||||
#region BSP
|
||||
|
||||
if (magic.StartsWith(new byte?[] { 0x1e, 0x00, 0x00, 0x00 }))
|
||||
return SupportedFileType.BSP;
|
||||
|
||||
#endregion
|
||||
|
||||
#region BZip2
|
||||
|
||||
if (magic.StartsWith(new byte?[] { 0x42, 0x52, 0x68 }))
|
||||
return SupportedFileType.BZip2;
|
||||
|
||||
#endregion
|
||||
|
||||
#region CFB
|
||||
|
||||
if (magic.StartsWith(new byte?[] { 0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1 }))
|
||||
return SupportedFileType.CFB;
|
||||
|
||||
#endregion
|
||||
|
||||
#region CIA
|
||||
|
||||
// No magic checks for CIA
|
||||
|
||||
#endregion
|
||||
|
||||
#region Executable
|
||||
|
||||
// DOS MZ executable file format (and descendants)
|
||||
if (magic.StartsWith(new byte?[] { 0x4d, 0x5a }))
|
||||
return SupportedFileType.Executable;
|
||||
|
||||
/*
|
||||
// None of the following are supported in scans yet
|
||||
|
||||
// Executable and Linkable Format
|
||||
if (magic.StartsWith(new byte?[] { 0x7f, 0x45, 0x4c, 0x46 }))
|
||||
return FileTypes.Executable;
|
||||
|
||||
// Mach-O binary (32-bit)
|
||||
if (magic.StartsWith(new byte?[] { 0xfe, 0xed, 0xfa, 0xce }))
|
||||
return FileTypes.Executable;
|
||||
|
||||
// Mach-O binary (32-bit, reverse byte ordering scheme)
|
||||
if (magic.StartsWith(new byte?[] { 0xce, 0xfa, 0xed, 0xfe }))
|
||||
return FileTypes.Executable;
|
||||
|
||||
// Mach-O binary (64-bit)
|
||||
if (magic.StartsWith(new byte?[] { 0xfe, 0xed, 0xfa, 0xcf }))
|
||||
return FileTypes.Executable;
|
||||
|
||||
// Mach-O binary (64-bit, reverse byte ordering scheme)
|
||||
if (magic.StartsWith(new byte?[] { 0xcf, 0xfa, 0xed, 0xfe }))
|
||||
return FileTypes.Executable;
|
||||
|
||||
// Prefrred Executable File Format
|
||||
if (magic.StartsWith(new byte?[] { 0x4a, 0x6f, 0x79, 0x21, 0x70, 0x65, 0x66, 0x66 }))
|
||||
return FileTypes.Executable;
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
#region GCF
|
||||
|
||||
if (magic.StartsWith(new byte?[] { 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 }))
|
||||
return SupportedFileType.GCF;
|
||||
|
||||
#endregion
|
||||
|
||||
#region GZIP
|
||||
|
||||
if (magic.StartsWith(new byte?[] { 0x1f, 0x8b }))
|
||||
return SupportedFileType.GZIP;
|
||||
|
||||
#endregion
|
||||
|
||||
#region IniFile
|
||||
|
||||
// No magic checks for IniFile
|
||||
|
||||
#endregion
|
||||
|
||||
#region InstallShieldArchiveV3
|
||||
|
||||
if (magic.StartsWith(new byte?[] { 0x13, 0x5D, 0x65, 0x8C }))
|
||||
return SupportedFileType.InstallShieldArchiveV3;
|
||||
|
||||
#endregion
|
||||
|
||||
#region InstallShieldCAB
|
||||
|
||||
if (magic.StartsWith(new byte?[] { 0x49, 0x53, 0x63 }))
|
||||
return SupportedFileType.InstallShieldCAB;
|
||||
|
||||
#endregion
|
||||
|
||||
#region LDSCRYPT
|
||||
|
||||
if (magic.StartsWith(new byte?[] { 0x4C, 0x44, 0x53, 0x43, 0x52, 0x59, 0x50, 0x54 }))
|
||||
return SupportedFileType.LDSCRYPT;
|
||||
|
||||
#endregion
|
||||
|
||||
#region MicrosoftCAB
|
||||
|
||||
if (magic.StartsWith(new byte?[] { 0x4d, 0x53, 0x43, 0x46 }))
|
||||
return SupportedFileType.MicrosoftCAB;
|
||||
|
||||
#endregion
|
||||
|
||||
#region MicrosoftLZ
|
||||
|
||||
if (magic.StartsWith(new byte?[] { 0x53, 0x5a, 0x44, 0x44, 0x88, 0xf0, 0x27, 0x33 }))
|
||||
return SupportedFileType.MicrosoftLZ;
|
||||
|
||||
#endregion
|
||||
|
||||
#region MPQ
|
||||
|
||||
if (magic.StartsWith(new byte?[] { 0x4d, 0x50, 0x51, 0x1a }))
|
||||
return SupportedFileType.MPQ;
|
||||
|
||||
if (magic.StartsWith(new byte?[] { 0x4d, 0x50, 0x51, 0x1b }))
|
||||
return SupportedFileType.MPQ;
|
||||
|
||||
#endregion
|
||||
|
||||
#region N3DS
|
||||
|
||||
// No magic checks for N3DS
|
||||
|
||||
#endregion
|
||||
|
||||
#region NCF
|
||||
|
||||
if (magic.StartsWith(new byte?[] { 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00 }))
|
||||
return SupportedFileType.NCF;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Nitro
|
||||
|
||||
// No magic checks for Nitro
|
||||
|
||||
#endregion
|
||||
|
||||
#region PAK
|
||||
|
||||
if (magic.StartsWith(new byte?[] { 0x50, 0x41, 0x43, 0x4B }))
|
||||
return SupportedFileType.PAK;
|
||||
|
||||
#endregion
|
||||
|
||||
#region PFF
|
||||
|
||||
// Version 2
|
||||
if (magic.StartsWith(new byte?[] { 0x14, 0x00, 0x00, 0x00, 0x50, 0x46, 0x46, 0x32 }))
|
||||
return SupportedFileType.PFF;
|
||||
|
||||
// Version 3
|
||||
if (magic.StartsWith(new byte?[] { 0x14, 0x00, 0x00, 0x00, 0x50, 0x46, 0x46, 0x33 }))
|
||||
return SupportedFileType.PFF;
|
||||
|
||||
// Version 4
|
||||
if (magic.StartsWith(new byte?[] { 0x14, 0x00, 0x00, 0x00, 0x50, 0x46, 0x46, 0x34 }))
|
||||
return SupportedFileType.PFF;
|
||||
|
||||
#endregion
|
||||
|
||||
#region PKZIP
|
||||
|
||||
// PKZIP (Unknown)
|
||||
if (magic.StartsWith(new byte?[] { 0x50, 0x4b, 0x00, 0x00 }))
|
||||
return SupportedFileType.PKZIP;
|
||||
|
||||
// PKZIP
|
||||
if (magic.StartsWith(new byte?[] { 0x50, 0x4b, 0x03, 0x04 }))
|
||||
return SupportedFileType.PKZIP;
|
||||
|
||||
// PKZIP (Empty Archive)
|
||||
if (magic.StartsWith(new byte?[] { 0x50, 0x4b, 0x05, 0x06 }))
|
||||
return SupportedFileType.PKZIP;
|
||||
|
||||
// PKZIP (Spanned Archive)
|
||||
if (magic.StartsWith(new byte?[] { 0x50, 0x4b, 0x07, 0x08 }))
|
||||
return SupportedFileType.PKZIP;
|
||||
|
||||
#endregion
|
||||
|
||||
#region PLJ
|
||||
|
||||
// https://www.iana.org/assignments/media-types/audio/vnd.everad.plj
|
||||
if (magic.StartsWith(new byte?[] { 0xFF, 0x9D, 0x53, 0x4B }))
|
||||
return SupportedFileType.PLJ;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Quantum
|
||||
|
||||
if (magic.StartsWith(new byte?[] { 0x44, 0x53 }))
|
||||
return SupportedFileType.Quantum;
|
||||
|
||||
#endregion
|
||||
|
||||
#region RAR
|
||||
|
||||
// RAR archive version 1.50 onwards
|
||||
if (magic.StartsWith(new byte?[] { 0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00 }))
|
||||
return SupportedFileType.RAR;
|
||||
|
||||
// RAR archive version 5.0 onwards
|
||||
if (magic.StartsWith(new byte?[] { 0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x01, 0x00 }))
|
||||
return SupportedFileType.RAR;
|
||||
|
||||
#endregion
|
||||
|
||||
#region RealArcade
|
||||
|
||||
// RASGI2.0
|
||||
// Found in the ".rgs files in IA item "Nova_RealArcadeCD_USA".
|
||||
if (magic.StartsWith(new byte?[] { 0x52, 0x41, 0x53, 0x47, 0x49, 0x32, 0x2E, 0x30 }))
|
||||
return SupportedFileType.RealArcadeInstaller;
|
||||
|
||||
// XZip2.0
|
||||
// Found in the ".mez" files in IA item "Nova_RealArcadeCD_USA".
|
||||
if (magic.StartsWith(new byte?[] { 0x58, 0x5A, 0x69, 0x70, 0x32, 0x2E, 0x30 }))
|
||||
return SupportedFileType.RealArcadeMezzanine;
|
||||
|
||||
#endregion
|
||||
|
||||
#region SevenZip
|
||||
|
||||
if (magic.StartsWith(new byte?[] { 0x37, 0x7a, 0xbc, 0xaf, 0x27, 0x1c }))
|
||||
return SupportedFileType.SevenZip;
|
||||
|
||||
#endregion
|
||||
|
||||
#region SFFS
|
||||
|
||||
// Found in Redump entry 81756, confirmed to be "StarForce Filesystem" by PiD.
|
||||
if (magic.StartsWith(new byte?[] { 0x53, 0x46, 0x46, 0x53 }))
|
||||
return SupportedFileType.SFFS;
|
||||
|
||||
#endregion
|
||||
|
||||
#region SGA
|
||||
|
||||
if (magic.StartsWith(new byte?[] { 0x5F, 0x41, 0x52, 0x43, 0x48, 0x49, 0x56, 0x45 }))
|
||||
return SupportedFileType.SGA;
|
||||
|
||||
#endregion
|
||||
|
||||
#region TapeArchive
|
||||
|
||||
if (magic.StartsWith(new byte?[] { 0x75, 0x73, 0x74, 0x61, 0x72, 0x00, 0x30, 0x30 }))
|
||||
return SupportedFileType.TapeArchive;
|
||||
|
||||
if (magic.StartsWith(new byte?[] { 0x75, 0x73, 0x74, 0x61, 0x72, 0x20, 0x20, 0x00 }))
|
||||
return SupportedFileType.TapeArchive;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Textfile
|
||||
|
||||
// Not all textfiles can be determined through magic number
|
||||
|
||||
// HTML
|
||||
if (magic.StartsWith(new byte?[] { 0x3c, 0x68, 0x74, 0x6d, 0x6c }))
|
||||
return SupportedFileType.Textfile;
|
||||
|
||||
// HTML and XML
|
||||
if (magic.StartsWith(new byte?[] { 0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45 }))
|
||||
return SupportedFileType.Textfile;
|
||||
|
||||
// InstallShield Compiled Rules
|
||||
if (magic.StartsWith(new byte?[] { 0x61, 0x4C, 0x75, 0x5A }))
|
||||
return SupportedFileType.Textfile;
|
||||
|
||||
// Microsoft Office File (old)
|
||||
if (magic.StartsWith(new byte?[] { 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1 }))
|
||||
return SupportedFileType.Textfile;
|
||||
|
||||
// Rich Text File
|
||||
if (magic.StartsWith(new byte?[] { 0x7b, 0x5c, 0x72, 0x74, 0x66, 0x31 }))
|
||||
return SupportedFileType.Textfile;
|
||||
|
||||
// Windows Help File
|
||||
if (magic.StartsWith(new byte?[] { 0x3F, 0x5F, 0x03, 0x00 }))
|
||||
return SupportedFileType.Textfile;
|
||||
|
||||
// XML
|
||||
// "<?xml"
|
||||
if (magic.StartsWith(new byte?[] { 0x3C, 0x3F, 0x78, 0x6D, 0x6C }))
|
||||
return SupportedFileType.Textfile;
|
||||
|
||||
#endregion
|
||||
|
||||
#region VBSP
|
||||
|
||||
if (magic.StartsWith(new byte?[] { 0x56, 0x42, 0x53, 0x50 }))
|
||||
return SupportedFileType.VBSP;
|
||||
|
||||
#endregion
|
||||
|
||||
#region VPK
|
||||
|
||||
if (magic.StartsWith(new byte?[] { 0x34, 0x12, 0xaa, 0x55 }))
|
||||
return SupportedFileType.VPK;
|
||||
|
||||
#endregion
|
||||
|
||||
#region WAD
|
||||
|
||||
if (magic.StartsWith(new byte?[] { 0x57, 0x41, 0x44, 0x33 }))
|
||||
return SupportedFileType.WAD;
|
||||
|
||||
#endregion
|
||||
|
||||
#region XZ
|
||||
|
||||
if (magic.StartsWith(new byte?[] { 0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00 }))
|
||||
return SupportedFileType.XZ;
|
||||
|
||||
#endregion
|
||||
|
||||
#region XZP
|
||||
|
||||
if (magic.StartsWith(new byte?[] { 0x70, 0x69, 0x5A, 0x78 }))
|
||||
return SupportedFileType.XZP;
|
||||
|
||||
#endregion
|
||||
|
||||
// We couldn't find a supported match
|
||||
return SupportedFileType.UNKNOWN;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the supported file type for an extension
|
||||
/// </summary>
|
||||
/// <remarks>This is less accurate than a magic string match</remarks>
|
||||
public static SupportedFileType GetFileType(string extension)
|
||||
{
|
||||
// If we have an invalid extension
|
||||
if (string.IsNullOrEmpty(extension))
|
||||
return SupportedFileType.UNKNOWN;
|
||||
|
||||
// Normalize the extension
|
||||
extension = extension.TrimStart('.').Trim();
|
||||
|
||||
#region AACSMediaKeyBlock
|
||||
|
||||
// Shares an extension with INF setup information so it can't be used accurately
|
||||
// Blu-ray
|
||||
// if (extension.Equals("inf", StringComparison.OrdinalIgnoreCase))
|
||||
// return SupportedFileType.AACSMediaKeyBlock;
|
||||
|
||||
// HD-DVD
|
||||
if (extension.Equals("aacs", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.AACSMediaKeyBlock;
|
||||
|
||||
#endregion
|
||||
|
||||
#region BDPlusSVM
|
||||
|
||||
if (extension.Equals("svm", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.BDPlusSVM;
|
||||
|
||||
#endregion
|
||||
|
||||
#region BFPK
|
||||
|
||||
// No extensions registered for BFPK
|
||||
|
||||
#endregion
|
||||
|
||||
#region BSP
|
||||
|
||||
// Shares an extension with VBSP so it can't be used accurately
|
||||
// if (extension.Equals("bsp", StringComparison.OrdinalIgnoreCase))
|
||||
// return SupportedFileType.BSP;
|
||||
|
||||
#endregion
|
||||
|
||||
#region BZip2
|
||||
|
||||
if (extension.Equals("bz2", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.BZip2;
|
||||
|
||||
#endregion
|
||||
|
||||
#region CFB
|
||||
|
||||
// Installer package
|
||||
if (extension.Equals("msi", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.CFB;
|
||||
|
||||
// Merge module
|
||||
else if (extension.Equals("msm", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.CFB;
|
||||
|
||||
// Patch Package
|
||||
else if (extension.Equals("msp", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.CFB;
|
||||
|
||||
// Transform
|
||||
else if (extension.Equals("mst", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.CFB;
|
||||
|
||||
// Patch Creation Properties
|
||||
else if (extension.Equals("pcp", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.CFB;
|
||||
|
||||
#endregion
|
||||
|
||||
#region CIA
|
||||
|
||||
if (extension.Equals("cia", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.CIA;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Executable
|
||||
|
||||
// DOS MZ executable file format (and descendants)
|
||||
if (extension.Equals("exe", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.Executable;
|
||||
|
||||
// DOS MZ library file format (and descendants)
|
||||
if (extension.Equals("dll", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.Executable;
|
||||
|
||||
#endregion
|
||||
|
||||
#region GCF
|
||||
|
||||
if (extension.Equals("gcf", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.GCF;
|
||||
|
||||
#endregion
|
||||
|
||||
#region GZIP
|
||||
|
||||
if (extension.Equals("gz", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.GZIP;
|
||||
|
||||
#endregion
|
||||
|
||||
#region IniFile
|
||||
|
||||
if (extension.Equals("ini", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.IniFile;
|
||||
|
||||
#endregion
|
||||
|
||||
#region InstallShieldArchiveV3
|
||||
|
||||
if (extension.Equals("z", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.InstallShieldArchiveV3;
|
||||
|
||||
#endregion
|
||||
|
||||
#region InstallShieldCAB
|
||||
|
||||
// No extensions registered for InstallShieldCAB
|
||||
// Both InstallShieldCAB and MicrosoftCAB share the same extension
|
||||
|
||||
#endregion
|
||||
|
||||
#region MicrosoftCAB
|
||||
|
||||
// No extensions registered for InstallShieldCAB
|
||||
// Both InstallShieldCAB and MicrosoftCAB share the same extension
|
||||
|
||||
#endregion
|
||||
|
||||
#region MPQ
|
||||
|
||||
if (extension.Equals("mpq", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.MPQ;
|
||||
|
||||
#endregion
|
||||
|
||||
#region N3DS
|
||||
|
||||
// 3DS cart image
|
||||
if (extension.Equals("3ds", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.N3DS;
|
||||
|
||||
// CIA package -- Not currently supported
|
||||
// else if (extension.Equals("cia", StringComparison.OrdinalIgnoreCase))
|
||||
// return SupportedFileType.N3DS;
|
||||
|
||||
#endregion
|
||||
|
||||
#region NCF
|
||||
|
||||
if (extension.Equals("ncf", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.NCF;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Nitro
|
||||
|
||||
// DS cart image
|
||||
if (extension.Equals("nds", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.Nitro;
|
||||
|
||||
// DS development cart image
|
||||
else if (extension.Equals("srl", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.Nitro;
|
||||
|
||||
// DSi cart image
|
||||
else if (extension.Equals("dsi", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.Nitro;
|
||||
|
||||
// iQue DS cart image
|
||||
else if (extension.Equals("ids", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.Nitro;
|
||||
|
||||
#endregion
|
||||
|
||||
#region PAK
|
||||
|
||||
// No extensions registered for PAK
|
||||
// Both PAK and Quantum share one extension
|
||||
// if (extension.Equals("pak", StringComparison.OrdinalIgnoreCase))
|
||||
// return SupportedFileType.PAK;
|
||||
|
||||
#endregion
|
||||
|
||||
#region PFF
|
||||
|
||||
if (extension.Equals("pff", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.PFF;
|
||||
|
||||
#endregion
|
||||
|
||||
#region PKZIP
|
||||
|
||||
// PKZIP
|
||||
if (extension.Equals("zip", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.PKZIP;
|
||||
|
||||
// Android package
|
||||
if (extension.Equals("apk", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.PKZIP;
|
||||
|
||||
// Java archive
|
||||
if (extension.Equals("jar", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.PKZIP;
|
||||
|
||||
// Google Earth saved working session file
|
||||
if (extension.Equals("kmz", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.PKZIP;
|
||||
|
||||
// KWord document
|
||||
if (extension.Equals("kwd", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.PKZIP;
|
||||
|
||||
// Microsoft Office Open XML Format (OOXML) Document
|
||||
if (extension.Equals("docx", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.PKZIP;
|
||||
|
||||
// Microsoft Office Open XML Format (OOXML) Presentation
|
||||
if (extension.Equals("pptx", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.PKZIP;
|
||||
|
||||
// Microsoft Office Open XML Format (OOXML) Spreadsheet
|
||||
if (extension.Equals("xlsx", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.PKZIP;
|
||||
|
||||
// OpenDocument text document
|
||||
if (extension.Equals("odt", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.PKZIP;
|
||||
|
||||
// OpenDocument presentation
|
||||
if (extension.Equals("odp", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.PKZIP;
|
||||
|
||||
// OpenDocument text document template
|
||||
if (extension.Equals("ott", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.PKZIP;
|
||||
|
||||
// Microsoft Open XML paper specification file
|
||||
if (extension.Equals("oxps", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.PKZIP;
|
||||
|
||||
// OpenOffice spreadsheet
|
||||
if (extension.Equals("sxc", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.PKZIP;
|
||||
|
||||
// OpenOffice drawing
|
||||
if (extension.Equals("sxd", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.PKZIP;
|
||||
|
||||
// OpenOffice presentation
|
||||
if (extension.Equals("sxi", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.PKZIP;
|
||||
|
||||
// OpenOffice word processing
|
||||
if (extension.Equals("sxw", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.PKZIP;
|
||||
|
||||
// StarOffice spreadsheet
|
||||
if (extension.Equals("sxc", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.PKZIP;
|
||||
|
||||
// Windows Media compressed skin file
|
||||
if (extension.Equals("wmz", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.PKZIP;
|
||||
|
||||
// Mozilla Browser Archive
|
||||
if (extension.Equals("xpi", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.PKZIP;
|
||||
|
||||
// XML paper specification file
|
||||
if (extension.Equals("xps", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.PKZIP;
|
||||
|
||||
// eXact Packager Models
|
||||
if (extension.Equals("xpt", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.PKZIP;
|
||||
|
||||
#endregion
|
||||
|
||||
#region PLJ
|
||||
|
||||
// https://www.iana.org/assignments/media-types/audio/vnd.everad.plj
|
||||
if (extension.Equals("plj", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.PLJ;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Quantum
|
||||
|
||||
if (extension.Equals("q", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.Quantum;
|
||||
|
||||
// Both PAK and Quantum share one extension
|
||||
// if (extension.Equals("pak", StringComparison.OrdinalIgnoreCase))
|
||||
// return SupportedFileType.Quantum;
|
||||
|
||||
#endregion
|
||||
|
||||
#region RAR
|
||||
|
||||
if (extension.Equals("rar", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.RAR;
|
||||
|
||||
#endregion
|
||||
|
||||
#region SevenZip
|
||||
|
||||
if (extension.Equals("7z", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.SevenZip;
|
||||
|
||||
#endregion
|
||||
|
||||
#region SGA
|
||||
|
||||
if (extension.Equals("sga", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.SGA;
|
||||
|
||||
#endregion
|
||||
|
||||
#region TapeArchive
|
||||
|
||||
if (extension.Equals("tar", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.SevenZip;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Textfile
|
||||
|
||||
// "Description in Zip"
|
||||
if (extension.Equals("diz", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.Textfile;
|
||||
|
||||
// Generic textfile (no header)
|
||||
if (extension.Equals("txt", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.Textfile;
|
||||
|
||||
// HTML
|
||||
if (extension.Equals("htm", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.Textfile;
|
||||
if (extension.Equals("html", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.Textfile;
|
||||
|
||||
// InstallShield Script
|
||||
if (extension.Equals("ins", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.Textfile;
|
||||
|
||||
// Microsoft Office File (old)
|
||||
if (extension.Equals("doc", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.Textfile;
|
||||
|
||||
// Property list
|
||||
if (extension.Equals("plist", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.Textfile;
|
||||
|
||||
// Rich Text File
|
||||
if (extension.Equals("rtf", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.Textfile;
|
||||
|
||||
// Setup information
|
||||
if (extension.Equals("inf", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.Textfile;
|
||||
|
||||
// Windows Help File
|
||||
if (extension.Equals("hlp", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.Textfile;
|
||||
|
||||
// WZC
|
||||
if (extension.Equals("wzc", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.Textfile;
|
||||
|
||||
// XML
|
||||
if (extension.Equals("xml", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.Textfile;
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region VBSP
|
||||
|
||||
// Shares an extension with BSP so it can't be used accurately
|
||||
// if (extension.Equals("bsp", StringComparison.OrdinalIgnoreCase))
|
||||
// return SupportedFileType.VBSP;
|
||||
|
||||
#endregion
|
||||
|
||||
#region VPK
|
||||
|
||||
// Common extension so this cannot be used accurately
|
||||
// if (extension.Equals("vpk", StringComparison.OrdinalIgnoreCase))
|
||||
// return SupportedFileType.VPK;
|
||||
|
||||
#endregion
|
||||
|
||||
#region WAD
|
||||
|
||||
// Common extension so this cannot be used accurately
|
||||
// if (extension.Equals("wad", StringComparison.OrdinalIgnoreCase))
|
||||
// return SupportedFileType.WAD;
|
||||
|
||||
#endregion
|
||||
|
||||
#region XZ
|
||||
|
||||
if (extension.Equals("xz", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.XZ;
|
||||
|
||||
#endregion
|
||||
|
||||
#region XZP
|
||||
|
||||
if (extension.Equals("xzp", StringComparison.OrdinalIgnoreCase))
|
||||
return SupportedFileType.XZP;
|
||||
|
||||
#endregion
|
||||
|
||||
// We couldn't find a supported match
|
||||
return SupportedFileType.UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
119
Test/Options.cs
Normal file
119
Test/Options.cs
Normal file
@@ -0,0 +1,119 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Test
|
||||
{
|
||||
/// <summary>
|
||||
/// Set of options for the test executable
|
||||
/// </summary>
|
||||
internal sealed class Options
|
||||
{
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Enable debug output for relevant operations
|
||||
/// </summary>
|
||||
public bool Debug { get; private set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Set of input paths to use for operations
|
||||
/// </summary>
|
||||
public List<string> InputPaths { get; private set; } = [];
|
||||
|
||||
#if NETCOREAPP3_1_OR_GREATER
|
||||
/// <summary>
|
||||
/// Enable JSON output
|
||||
/// </summary>
|
||||
public bool Json { get; private set; } = false;
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Parse commandline arguments into an Options object
|
||||
/// </summary>
|
||||
public static Options? ParseOptions(string[] args)
|
||||
{
|
||||
// If we have invalid arguments
|
||||
if (args == null || args.Length == 0)
|
||||
return null;
|
||||
|
||||
// Create an Options object
|
||||
var options = new Options();
|
||||
|
||||
// Parse the features
|
||||
int index = 0;
|
||||
for (; index < args.Length; index++)
|
||||
{
|
||||
string arg = args[index];
|
||||
bool featureFound = false;
|
||||
switch (arg)
|
||||
{
|
||||
case "-?":
|
||||
case "-h":
|
||||
case "--help":
|
||||
return null;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// If the flag wasn't a feature
|
||||
if (!featureFound)
|
||||
break;
|
||||
}
|
||||
|
||||
// Parse the options and paths
|
||||
for (; index < args.Length; index++)
|
||||
{
|
||||
string arg = args[index];
|
||||
switch (arg)
|
||||
{
|
||||
case "-d":
|
||||
case "--debug":
|
||||
options.Debug = true;
|
||||
break;
|
||||
|
||||
case "-j":
|
||||
case "--json":
|
||||
#if NET6_0_OR_GREATER
|
||||
options.Json = true;
|
||||
#else
|
||||
Console.WriteLine("JSON output not available in .NET Framework");
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
options.InputPaths.Add(arg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Validate we have any input paths to work on
|
||||
if (options.InputPaths.Count == 0)
|
||||
{
|
||||
Console.WriteLine("At least one path is required!");
|
||||
return null;
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Display help text
|
||||
/// </summary>
|
||||
public static void DisplayHelp()
|
||||
{
|
||||
Console.WriteLine("SabreTools.Printing Test Program");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("test.exe <options> file|directory ...");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Options:");
|
||||
Console.WriteLine("-?, -h, --help Display this help text and quit");
|
||||
Console.WriteLine("-d, --debug Enable debug mode");
|
||||
#if NET6_0_OR_GREATER
|
||||
Console.WriteLine("-j, --json Print executable info as JSON");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
141
Test/Program.cs
Normal file
141
Test/Program.cs
Normal file
@@ -0,0 +1,141 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using SabreTools.IO.Extensions;
|
||||
using SabreTools.Printing;
|
||||
|
||||
namespace Test
|
||||
{
|
||||
public static class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
// Get the options from the arguments
|
||||
var options = Options.ParseOptions(args);
|
||||
|
||||
// If we have an invalid state
|
||||
if (options == null)
|
||||
{
|
||||
Options.DisplayHelp();
|
||||
Console.WriteLine("Press enter to close the program...");
|
||||
Console.ReadLine();
|
||||
return;
|
||||
}
|
||||
|
||||
// Loop through the input paths
|
||||
foreach (string inputPath in args)
|
||||
{
|
||||
#if NETFRAMEWORK
|
||||
PrintPathInfo(inputPath, false, options.Debug);
|
||||
#else
|
||||
PrintPathInfo(inputPath, options.Json, options.Debug);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wrapper to print information for a single path
|
||||
/// </summary>
|
||||
/// <param name="path">File or directory path</param>
|
||||
/// <param name="json">Enable JSON output, if supported</param>
|
||||
/// <param name="debug">Enable debug output</param>
|
||||
private static void PrintPathInfo(string path, bool json, bool debug)
|
||||
{
|
||||
Console.WriteLine($"Checking possible path: {path}");
|
||||
|
||||
// Check if the file or directory exists
|
||||
if (File.Exists(path))
|
||||
{
|
||||
PrintFileInfo(path, json, debug);
|
||||
}
|
||||
else if (Directory.Exists(path))
|
||||
{
|
||||
#if NET20 || NET35
|
||||
foreach (string file in Directory.GetFiles(path, "*", SearchOption.AllDirectories))
|
||||
#else
|
||||
foreach (string file in Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories))
|
||||
#endif
|
||||
{
|
||||
PrintFileInfo(file, json, debug);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"{path} does not exist, skipping...");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Print information for a single file, if possible
|
||||
/// </summary>
|
||||
private static void PrintFileInfo(string file, bool json, bool debug)
|
||||
{
|
||||
Console.WriteLine($"Attempting to print info for {file}");
|
||||
|
||||
try
|
||||
{
|
||||
using Stream stream = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
|
||||
// Read the first 8 bytes
|
||||
byte[]? magic = stream.ReadBytes(8);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
// Get the file type
|
||||
SupportedFileType ft = FileTypes.GetFileType(magic ?? []);
|
||||
if (ft == SupportedFileType.UNKNOWN)
|
||||
{
|
||||
string extension = Path.GetExtension(file).TrimStart('.');
|
||||
ft = FileTypes.GetFileType(extension);
|
||||
}
|
||||
|
||||
// Print out the file format
|
||||
Console.WriteLine($"File format found: {ft}");
|
||||
|
||||
// Setup the wrapper to print
|
||||
var wrapper = WrapperFactory.CreateWrapper(ft, stream);
|
||||
|
||||
// If we don't have a wrapper
|
||||
if (wrapper == null)
|
||||
{
|
||||
Console.WriteLine($"Either {ft} is not supported or something went wrong during parsing!");
|
||||
Console.WriteLine();
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the base info output name
|
||||
string filenameBase = $"info-{DateTime.Now:yyyy-MM-dd_HHmmss.ffff}";
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
// If we have the JSON flag
|
||||
if (json)
|
||||
{
|
||||
// Create the output data
|
||||
string serializedData = wrapper.ExportJSON();
|
||||
Console.WriteLine(serializedData);
|
||||
|
||||
// Write the output data
|
||||
using var jsw = new StreamWriter(File.OpenWrite($"{filenameBase}.json"));
|
||||
jsw.WriteLine(serializedData);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Create the output data
|
||||
var builder = wrapper.ExportStringBuilder();
|
||||
if (builder == null)
|
||||
{
|
||||
Console.WriteLine("No item information could be generated");
|
||||
return;
|
||||
}
|
||||
|
||||
// Write the output data
|
||||
Console.WriteLine(builder);
|
||||
using var sw = new StreamWriter(File.OpenWrite($"{filenameBase}.txt"));
|
||||
sw.WriteLine(builder.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(debug ? ex : "[Exception opening file, please try again]");
|
||||
Console.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
203
Test/SupportedFileType.cs
Normal file
203
Test/SupportedFileType.cs
Normal file
@@ -0,0 +1,203 @@
|
||||
namespace Test
|
||||
{
|
||||
/// <summary>
|
||||
/// Subset of file types that are supported by the library
|
||||
/// </summary>
|
||||
internal enum SupportedFileType
|
||||
{
|
||||
/// <summary>
|
||||
/// Unknown or unsupported
|
||||
/// </summary>
|
||||
UNKNOWN,
|
||||
|
||||
/// <summary>
|
||||
/// AACS media key block
|
||||
/// </summary>
|
||||
AACSMediaKeyBlock,
|
||||
|
||||
/// <summary>
|
||||
/// BD+ SVM
|
||||
/// </summary>
|
||||
BDPlusSVM,
|
||||
|
||||
/// <summary>
|
||||
/// BFPK custom archive
|
||||
/// </summary>
|
||||
BFPK,
|
||||
|
||||
/// <summary>
|
||||
/// Half-Life Level
|
||||
/// </summary>
|
||||
BSP,
|
||||
|
||||
/// <summary>
|
||||
/// bzip2 archive
|
||||
/// </summary>
|
||||
BZip2,
|
||||
|
||||
/// <summary>
|
||||
/// Compound File Binary
|
||||
/// </summary>
|
||||
CFB,
|
||||
|
||||
/// <summary>
|
||||
/// CTR Importable Archive
|
||||
/// </summary>
|
||||
CIA,
|
||||
|
||||
/// <summary>
|
||||
/// Executable or library
|
||||
/// </summary>
|
||||
Executable,
|
||||
|
||||
/// <summary>
|
||||
/// Half-Life Game Cache File
|
||||
/// </summary>
|
||||
GCF,
|
||||
|
||||
/// <summary>
|
||||
/// gzip archive
|
||||
/// </summary>
|
||||
GZIP,
|
||||
|
||||
/// <summary>
|
||||
/// Key-value pair INI file
|
||||
/// </summary>
|
||||
IniFile,
|
||||
|
||||
/// <summary>
|
||||
/// InstallShield archive v3
|
||||
/// </summary>
|
||||
InstallShieldArchiveV3,
|
||||
|
||||
/// <summary>
|
||||
/// InstallShield cabinet file
|
||||
/// </summary>
|
||||
InstallShieldCAB,
|
||||
|
||||
/// <summary>
|
||||
/// Link Data Security encrypted file
|
||||
/// </summary>
|
||||
LDSCRYPT,
|
||||
|
||||
/// <summary>
|
||||
/// Microsoft cabinet file
|
||||
/// </summary>
|
||||
MicrosoftCAB,
|
||||
|
||||
/// <summary>
|
||||
/// Microsoft LZ-compressed file
|
||||
/// </summary>
|
||||
MicrosoftLZ,
|
||||
|
||||
/// <summary>
|
||||
/// MPQ game data archive
|
||||
/// </summary>
|
||||
MPQ,
|
||||
|
||||
/// <summary>
|
||||
/// Nintendo 3DS cart image
|
||||
/// </summary>
|
||||
N3DS,
|
||||
|
||||
/// <summary>
|
||||
/// Half-Life No Cache File
|
||||
/// </summary>
|
||||
NCF,
|
||||
|
||||
/// <summary>
|
||||
/// Nintendo DS/DSi cart image
|
||||
/// </summary>
|
||||
Nitro,
|
||||
|
||||
/// <summary>
|
||||
/// Half-Life Package File
|
||||
/// </summary>
|
||||
PAK,
|
||||
|
||||
/// <summary>
|
||||
/// NovaLogic Game Archive Format
|
||||
/// </summary>
|
||||
PFF,
|
||||
|
||||
/// <summary>
|
||||
/// PKWARE ZIP archive and derivatives
|
||||
/// </summary>
|
||||
PKZIP,
|
||||
|
||||
/// <summary>
|
||||
/// PlayJ audio file
|
||||
/// </summary>
|
||||
PLJ,
|
||||
|
||||
/// <summary>
|
||||
/// Quantum archive
|
||||
/// </summary>
|
||||
Quantum,
|
||||
|
||||
/// <summary>
|
||||
/// RAR archive
|
||||
/// </summary>
|
||||
RAR,
|
||||
|
||||
/// <summary>
|
||||
/// RealArcade Installer
|
||||
/// </summary>
|
||||
RealArcadeInstaller,
|
||||
|
||||
/// <summary>
|
||||
/// RealArcade Mezzanine
|
||||
/// </summary>
|
||||
RealArcadeMezzanine,
|
||||
|
||||
/// <summary>
|
||||
/// 7-zip archive
|
||||
/// </summary>
|
||||
SevenZip,
|
||||
|
||||
/// <summary>
|
||||
/// StarForce FileSystem file
|
||||
/// </summary>
|
||||
SFFS,
|
||||
|
||||
/// <summary>
|
||||
/// SGA
|
||||
/// </summary>
|
||||
SGA,
|
||||
|
||||
/// <summary>
|
||||
/// Tape archive
|
||||
/// </summary>
|
||||
TapeArchive,
|
||||
|
||||
/// <summary>
|
||||
/// Various generic textfile formats
|
||||
/// </summary>
|
||||
Textfile,
|
||||
|
||||
/// <summary>
|
||||
/// Half-Life 2 Level
|
||||
/// </summary>
|
||||
VBSP,
|
||||
|
||||
/// <summary>
|
||||
/// Valve Package File
|
||||
/// </summary>
|
||||
VPK,
|
||||
|
||||
/// <summary>
|
||||
/// Half-Life Texture Package File
|
||||
/// </summary>
|
||||
WAD,
|
||||
|
||||
/// <summary>
|
||||
/// xz archive
|
||||
/// </summary>
|
||||
XZ,
|
||||
|
||||
/// <summary>
|
||||
/// Xbox Package File
|
||||
/// </summary>
|
||||
XZP,
|
||||
}
|
||||
}
|
||||
24
Test/Test.csproj
Normal file
24
Test/Test.csproj
Normal file
@@ -0,0 +1,24 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
|
||||
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64</RuntimeIdentifiers>
|
||||
<OutputType>Exe</OutputType>
|
||||
<CheckEolTargetFramework>false</CheckEolTargetFramework>
|
||||
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SabreTools.Printing\SabreTools.Printing.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SabreTools.IO" Version="1.4.0" />
|
||||
<PackageReference Include="SabreTools.Matching" Version="1.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
116
Test/WrapperFactory.cs
Normal file
116
Test/WrapperFactory.cs
Normal file
@@ -0,0 +1,116 @@
|
||||
using System.IO;
|
||||
using SabreTools.IO.Extensions;
|
||||
using SabreTools.Matching;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
using SabreTools.Serialization.Wrappers;
|
||||
|
||||
namespace Test
|
||||
{
|
||||
internal static class WrapperFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Create an instance of a wrapper based on file type
|
||||
/// </summary>
|
||||
public static IWrapper? CreateWrapper(SupportedFileType fileType, Stream? data)
|
||||
{
|
||||
switch (fileType)
|
||||
{
|
||||
case SupportedFileType.AACSMediaKeyBlock: return AACSMediaKeyBlock.Create(data);
|
||||
case SupportedFileType.BDPlusSVM: return BDPlusSVM.Create(data);
|
||||
case SupportedFileType.BFPK: return BFPK.Create(data);
|
||||
case SupportedFileType.BSP: return BSP.Create(data);
|
||||
//case SupportedFileType.BZip2: return BZip2.Create(data);
|
||||
case SupportedFileType.CFB: return CFB.Create(data);
|
||||
case SupportedFileType.CIA: return CIA.Create(data);
|
||||
case SupportedFileType.Executable: return CreateExecutableWrapper(data);
|
||||
case SupportedFileType.GCF: return GCF.Create(data);
|
||||
//case SupportedFileType.GZIP: return GZIP.Create(data);
|
||||
//case SupportedFileType.IniFile: return IniFile.Create(data);
|
||||
//case SupportedFileType.InstallShieldArchiveV3: return InstallShieldArchiveV3.Create(data);
|
||||
case SupportedFileType.InstallShieldCAB: return InstallShieldCabinet.Create(data);
|
||||
//case SupportedFileType.LDSCRYPT: return LDSCRYPT.Create(data);
|
||||
case SupportedFileType.MicrosoftCAB: return MicrosoftCabinet.Create(data);
|
||||
//case SupportedFileType.MicrosoftLZ: return MicrosoftLZ.Create(data);
|
||||
case SupportedFileType.MPQ: return MoPaQ.Create(data);
|
||||
case SupportedFileType.N3DS: return N3DS.Create(data);
|
||||
case SupportedFileType.NCF: return NCF.Create(data);
|
||||
case SupportedFileType.Nitro: return Nitro.Create(data);
|
||||
case SupportedFileType.PAK: return PAK.Create(data);
|
||||
case SupportedFileType.PFF: return PFF.Create(data);
|
||||
//case SupportedFileType.PIC: return PIC.Create(data);
|
||||
//case SupportedFileType.PKZIP: return PKZIP.Create(data);
|
||||
case SupportedFileType.PLJ: return PlayJAudioFile.Create(data);
|
||||
//case SupportedFileType.PLJPlaylist: return PlayJPlaylist.Create(data);
|
||||
case SupportedFileType.Quantum: return Quantum.Create(data);
|
||||
//case SupportedFileType.RAR: return RAR.Create(data);
|
||||
//case SupportedFileType.SevenZip: return SevenZip.Create(data);
|
||||
//case SupportedFileType.SFFS: return SFFS.Create(data);
|
||||
case SupportedFileType.SGA: return SGA.Create(data);
|
||||
//case SupportedFileType.TapeArchive: return TapeArchive.Create(data);
|
||||
//case SupportedFileType.Textfile: return Textfile.Create(data);
|
||||
case SupportedFileType.VBSP: return VBSP.Create(data);
|
||||
case SupportedFileType.VPK: return VPK.Create(data);
|
||||
case SupportedFileType.WAD: return WAD.Create(data);
|
||||
//case SupportedFileType.XZ: return XZ.Create(data);
|
||||
case SupportedFileType.XZP: return XZP.Create(data);
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an instance of a wrapper based on the executable type
|
||||
/// </summary>
|
||||
/// <param name="stream">Stream data to parse</param>
|
||||
/// <returns>IWrapper representing the executable, null on error</returns>
|
||||
public static IWrapper? CreateExecutableWrapper(Stream? stream)
|
||||
{
|
||||
// If we have no stream
|
||||
if (stream == null)
|
||||
return null;
|
||||
|
||||
// Try to get an MS-DOS wrapper first
|
||||
var wrapper = MSDOS.Create(stream);
|
||||
if (wrapper == null || !(wrapper is MSDOS msdos))
|
||||
return null;
|
||||
|
||||
// Check for a valid new executable address
|
||||
if (msdos.Model.Header?.NewExeHeaderAddr == null || msdos.Model.Header.NewExeHeaderAddr >= stream.Length)
|
||||
return wrapper;
|
||||
|
||||
// Try to read the executable info
|
||||
stream.Seek(msdos.Model.Header.NewExeHeaderAddr, SeekOrigin.Begin);
|
||||
var magic = stream.ReadBytes(4);
|
||||
|
||||
// If we didn't get valid data at the offset
|
||||
if (magic == null)
|
||||
{
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
// New Executable
|
||||
else if (magic.StartsWith(SabreTools.Models.NewExecutable.Constants.SignatureBytes))
|
||||
{
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
return NewExecutable.Create(stream);
|
||||
}
|
||||
|
||||
// Linear Executable
|
||||
else if (magic.StartsWith(SabreTools.Models.LinearExecutable.Constants.LESignatureBytes)
|
||||
|| magic.StartsWith(SabreTools.Models.LinearExecutable.Constants.LXSignatureBytes))
|
||||
{
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
return LinearExecutable.Create(stream);
|
||||
}
|
||||
|
||||
// Portable Executable
|
||||
else if (magic.StartsWith(SabreTools.Models.PortableExecutable.Constants.SignatureBytes))
|
||||
{
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
return PortableExecutable.Create(stream);
|
||||
}
|
||||
|
||||
// Everything else fails
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
113
publish-nix.sh
Executable file
113
publish-nix.sh
Executable file
@@ -0,0 +1,113 @@
|
||||
#! /bin/bash
|
||||
|
||||
# This batch file assumes the following:
|
||||
# - .NET 8.0 (or newer) SDK is installed and in PATH
|
||||
# - zip is installed and in PATH
|
||||
# - Git is installed and in PATH
|
||||
#
|
||||
# If any of these are not satisfied, the operation may fail
|
||||
# in an unpredictable way and result in an incomplete output.
|
||||
|
||||
# Optional parameters
|
||||
USE_ALL=false
|
||||
NO_BUILD=false
|
||||
NO_ARCHIVE=false
|
||||
while getopts "uba" OPTION
|
||||
do
|
||||
case $OPTION in
|
||||
u)
|
||||
USE_ALL=true
|
||||
;;
|
||||
b)
|
||||
NO_BUILD=true
|
||||
;;
|
||||
a)
|
||||
NO_ARCHIVE=true
|
||||
;;
|
||||
*)
|
||||
echo "Invalid option provided"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Set the current directory as a variable
|
||||
BUILD_FOLDER=$PWD
|
||||
|
||||
# Set the current commit hash
|
||||
COMMIT=`git log --pretty=%H -1`
|
||||
|
||||
# Create the build matrix arrays
|
||||
FRAMEWORKS=("net8.0")
|
||||
RUNTIMES=("win-x86" "win-x64" "linux-x64" "osx-x64")
|
||||
|
||||
# Use expanded lists, if requested
|
||||
if [ $USE_ALL = true ]
|
||||
then
|
||||
FRAMEWORKS=("net20" "net35" "net40" "net452" "net462" "net472" "net48" "netcoreapp3.1" "net5.0" "net6.0" "net7.0" "net8.0")
|
||||
RUNTIMES=("win-x86" "win-x64" "win-arm64" "linux-x64" "linux-arm64" "osx-x64")
|
||||
fi
|
||||
|
||||
# Create the filter arrays
|
||||
SINGLE_FILE_CAPABLE=("net5.0" "net6.0" "net7.0" "net8.0")
|
||||
VALID_CROSS_PLATFORM_FRAMEWORKS=("netcoreapp3.1" "net5.0" "net6.0" "net7.0" "net8.0")
|
||||
VALID_CROSS_PLATFORM_RUNTIMES=("win-arm64" "linux-x64" "linux-arm64" "osx-x64")
|
||||
|
||||
# Only build if requested
|
||||
if [ $NO_BUILD = false ]
|
||||
then
|
||||
# Restore Nuget packages for all builds
|
||||
echo "Restoring Nuget packages"
|
||||
dotnet restore
|
||||
|
||||
# Create Nuget Package
|
||||
dotnet pack SabreTools.Printing/SabreTools.Printing.csproj --output $BUILD_FOLDER
|
||||
|
||||
# Build Test
|
||||
for FRAMEWORK in "${FRAMEWORKS[@]}"
|
||||
do
|
||||
for RUNTIME in "${RUNTIMES[@]}"
|
||||
do
|
||||
# If we have an invalid combination of framework and runtime
|
||||
if [ ! $(echo ${VALID_CROSS_PLATFORM_FRAMEWORKS[@]} | fgrep -w $FRAMEWORK) ] && [ $(echo ${VALID_CROSS_PLATFORM_RUNTIMES[@]} | fgrep -w $RUNTIME) ]
|
||||
then
|
||||
continue
|
||||
fi
|
||||
|
||||
# Only .NET 5 and above can publish to a single file
|
||||
if [[ $(echo ${SINGLE_FILE_CAPABLE[@]} | fgrep -w $FRAMEWORK) ]]
|
||||
then
|
||||
dotnet publish Test/Test.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
|
||||
dotnet publish Test/Test.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
|
||||
else
|
||||
dotnet publish Test/Test.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT
|
||||
dotnet publish Test/Test.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:DebugType=None -p:DebugSymbols=false
|
||||
fi
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
||||
# Only create archives if requested
|
||||
if [ $NO_ARCHIVE = false ]
|
||||
then
|
||||
# Create Test archives
|
||||
for FRAMEWORK in "${FRAMEWORKS[@]}"
|
||||
do
|
||||
for RUNTIME in "${RUNTIMES[@]}"
|
||||
do
|
||||
# If we have an invalid combination of framework and runtime
|
||||
if [ ! $(echo ${VALID_CROSS_PLATFORM_FRAMEWORKS[@]} | fgrep -w $FRAMEWORK) ] && [ $(echo ${VALID_CROSS_PLATFORM_RUNTIMES[@]} | fgrep -w $RUNTIME) ]
|
||||
then
|
||||
continue
|
||||
fi
|
||||
|
||||
cd $BUILD_FOLDER/Test/bin/Debug/${FRAMEWORK}/${RUNTIME}/publish/
|
||||
zip -r $BUILD_FOLDER/SabreTools.Printing_${FRAMEWORK}_${RUNTIME}_debug.zip .
|
||||
cd $BUILD_FOLDER/Test/bin/Release/${FRAMEWORK}/${RUNTIME}/publish/
|
||||
zip -r $BUILD_FOLDER/SabreTools.Printing_${FRAMEWORK}_${RUNTIME}_release.zip .
|
||||
done
|
||||
done
|
||||
|
||||
# Reset the directory
|
||||
cd $BUILD_FOLDER
|
||||
fi
|
||||
105
publish-win.ps1
Normal file
105
publish-win.ps1
Normal file
@@ -0,0 +1,105 @@
|
||||
# This batch file assumes the following:
|
||||
# - .NET 8.0 (or newer) SDK is installed and in PATH
|
||||
# - 7-zip commandline (7z.exe) is installed and in PATH
|
||||
# - Git for Windows is installed and in PATH
|
||||
#
|
||||
# If any of these are not satisfied, the operation may fail
|
||||
# in an unpredictable way and result in an incomplete output.
|
||||
|
||||
# Optional parameters
|
||||
param(
|
||||
[Parameter(Mandatory = $false)]
|
||||
[Alias("UseAll")]
|
||||
[switch]$USE_ALL,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[Alias("NoBuild")]
|
||||
[switch]$NO_BUILD,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[Alias("NoArchive")]
|
||||
[switch]$NO_ARCHIVE
|
||||
)
|
||||
|
||||
# Set the current directory as a variable
|
||||
$BUILD_FOLDER = $PSScriptRoot
|
||||
|
||||
# Set the current commit hash
|
||||
$COMMIT = git log --pretty=format:"%H" -1
|
||||
|
||||
# Create the build matrix arrays
|
||||
$FRAMEWORKS = @('net8.0')
|
||||
$RUNTIMES = @('win-x86', 'win-x64', 'linux-x64', 'osx-x64')
|
||||
|
||||
# Use expanded lists, if requested
|
||||
if ($USE_ALL.IsPresent)
|
||||
{
|
||||
$FRAMEWORKS = @('net20', 'net35', 'net40', 'net452', 'net462', 'net472', 'net48', 'netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0')
|
||||
$RUNTIMES = @('win-x86', 'win-x64', 'win-arm64', 'linux-x64', 'linux-arm64', 'osx-x64')
|
||||
}
|
||||
|
||||
# Create the filter arrays
|
||||
$SINGLE_FILE_CAPABLE = @('net5.0', 'net6.0', 'net7.0', 'net8.0')
|
||||
$VALID_CROSS_PLATFORM_FRAMEWORKS = @('netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0')
|
||||
$VALID_CROSS_PLATFORM_RUNTIMES = @('win-arm64', 'linux-x64', 'linux-arm64', 'osx-x64')
|
||||
|
||||
# Only build if requested
|
||||
if (!$NO_BUILD.IsPresent)
|
||||
{
|
||||
# Restore Nuget packages for all builds
|
||||
Write-Host "Restoring Nuget packages"
|
||||
dotnet restore
|
||||
|
||||
# Create Nuget Package
|
||||
dotnet pack SabreTools.Printing\SabreTools.Printing.csproj --output $BUILD_FOLDER
|
||||
|
||||
# Build Test
|
||||
foreach ($FRAMEWORK in $FRAMEWORKS)
|
||||
{
|
||||
foreach ($RUNTIME in $RUNTIMES)
|
||||
{
|
||||
# If we have an invalid combination of framework and runtime
|
||||
if ($VALID_CROSS_PLATFORM_FRAMEWORKS -notcontains $FRAMEWORK -and $VALID_CROSS_PLATFORM_RUNTIMES -contains $RUNTIME)
|
||||
{
|
||||
continue
|
||||
}
|
||||
|
||||
# Only .NET 5 and above can publish to a single file
|
||||
if ($SINGLE_FILE_CAPABLE -contains $FRAMEWORK)
|
||||
{
|
||||
dotnet publish Test\Test.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
|
||||
dotnet publish Test\Test.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
|
||||
}
|
||||
else
|
||||
{
|
||||
dotnet publish Test\Test.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT
|
||||
dotnet publish Test\Test.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:DebugType=None -p:DebugSymbols=false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Only create archives if requested
|
||||
if (!$NO_ARCHIVE.IsPresent)
|
||||
{
|
||||
# Create Test archives
|
||||
foreach ($FRAMEWORK in $FRAMEWORKS)
|
||||
{
|
||||
foreach ($RUNTIME in $RUNTIMES)
|
||||
{
|
||||
# If we have an invalid combination of framework and runtime
|
||||
if ($VALID_CROSS_PLATFORM_FRAMEWORKS -notcontains $FRAMEWORK -and $VALID_CROSS_PLATFORM_RUNTIMES -contains $RUNTIME)
|
||||
{
|
||||
continue
|
||||
}
|
||||
|
||||
Set-Location -Path $BUILD_FOLDER\Test\bin\Debug\${FRAMEWORK}\${RUNTIME}\publish\
|
||||
7z a -tzip $BUILD_FOLDER\SabreTools.Printing_${FRAMEWORK}_${RUNTIME}_debug.zip *
|
||||
Set-Location -Path $BUILD_FOLDER\Test\bin\Release\${FRAMEWORK}\${RUNTIME}\publish\
|
||||
7z a -tzip $BUILD_FOLDER\SabreTools.Printing_${FRAMEWORK}_${RUNTIME}_release.zip *
|
||||
}
|
||||
}
|
||||
|
||||
# Reset the directory
|
||||
Set-Location -Path $PSScriptRoot
|
||||
}
|
||||
Reference in New Issue
Block a user