-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extraction of files from B.DAT
- Loading branch information
Showing
9 changed files
with
604 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 14 | ||
VisualStudioVersion = 14.0.24720.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ToDoTools", "ToDoTools\ToDoTools.csproj", "{45D36B35-4AD5-4BD4-89C8-AEA9DE6B1CAF}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{45D36B35-4AD5-4BD4-89C8-AEA9DE6B1CAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{45D36B35-4AD5-4BD4-89C8-AEA9DE6B1CAF}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{45D36B35-4AD5-4BD4-89C8-AEA9DE6B1CAF}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{45D36B35-4AD5-4BD4-89C8-AEA9DE6B1CAF}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// Les informations générales relatives à un assembly dépendent de | ||
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations | ||
// associées à un assembly. | ||
[assembly: AssemblyTitle("ToDoTools")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("ToDoTools")] | ||
[assembly: AssemblyCopyright("Copyright © 2016")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly | ||
// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de | ||
// COM, affectez la valeur true à l'attribut ComVisible sur ce type. | ||
[assembly: ComVisible(false)] | ||
|
||
// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM | ||
[assembly: Guid("45d36b35-4ad5-4bd4-89c8-aea9de6b1caf")] | ||
|
||
// Les informations de version pour un assembly se composent des quatre valeurs suivantes : | ||
// | ||
// Version principale | ||
// Version secondaire | ||
// Numéro de build | ||
// Révision | ||
// | ||
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut | ||
// en utilisant '*', comme indiqué ci-dessous : | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
using System; | ||
using System.IO; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using CRH.Framework.Disk; | ||
using CRH.Framework.Disk.DataTrack; | ||
using ToDoTools.sources; | ||
using TalesOfComp; | ||
|
||
namespace ToDoTools | ||
{ | ||
class ToDTMain | ||
{ | ||
static TextWriterTraceListener twtl_trace; | ||
static ConsoleTraceListener ctl_trace; | ||
static Stopwatch sw_watch; | ||
|
||
static void Main(string[] args) | ||
{ | ||
StreamWriter sw = new StreamWriter("ToDoTools.log"); | ||
twtl_trace = new TextWriterTraceListener(sw); | ||
ctl_trace = new ConsoleTraceListener(); | ||
Trace.Listeners.Add(twtl_trace); | ||
Trace.Listeners.Add(ctl_trace); | ||
Trace.AutoFlush = true; | ||
sw_watch = new Stopwatch(); | ||
|
||
try | ||
{ | ||
if (args.Length != 2 && args.Length != 3) | ||
throw new Exception("Incorrect parameters !"); | ||
|
||
sw_watch.Start(); | ||
|
||
if (args[0] == "-e") | ||
extractFromIso(args[1]); | ||
else if (args[0] == "-u") | ||
Archive.unpackFile(args[1]); | ||
else | ||
throw new Exception(string.Format("Unknow action {0}", args[0])); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Trace.WriteLine(ex.Message + Environment.NewLine, "ERROR"); | ||
usage(); | ||
return; | ||
} | ||
finally | ||
{ | ||
sw_watch.Stop(); | ||
Trace.WriteLine(string.Format("Terminated. Execution time : {0}", sw_watch.Elapsed)); | ||
} | ||
} | ||
|
||
public static void usage() | ||
{ | ||
Trace.WriteLine("Usage : ToDoTools.exe <action> <file> [mode]"); | ||
Trace.WriteLine(""); | ||
Trace.WriteLine("Actions :"); | ||
Trace.WriteLine(" -e : Extract files from image disk"); | ||
Trace.WriteLine(" -u : Unpack file"); | ||
Trace.WriteLine(" -p : Pack file"); | ||
Trace.WriteLine(" -d : Decompress file"); | ||
Trace.WriteLine(" -c : compress file"); | ||
Trace.WriteLine("<file> : Pathname of the file"); | ||
Trace.WriteLine("<mode> : Compression (-c) mode (0, 1, 3) or Archive (-p) mode (1, 2)"); | ||
} | ||
|
||
/// <summary> | ||
/// Ouvre un fichier image (iso) et retourne le track 1 | ||
/// </summary> | ||
/// <param name="as_isoName">Chemin de l'iso</param> | ||
/// <returns></returns> | ||
private static DataTrackReader openIso(string as_isoName) | ||
{ | ||
if (!File.Exists(as_isoName)) | ||
{ | ||
Trace.WriteLine("Unknown file : {0}", as_isoName); | ||
return null; | ||
} | ||
|
||
DiskReader dr_iso = DiskReader.InitFromIso(as_isoName, DiskFileSystem.ISO9660, DataTrackMode.MODE2_XA); | ||
|
||
return (DataTrackReader)dr_iso.DataTrack; | ||
} | ||
|
||
/// <summary> | ||
/// Récupère un index présent dans le SLUS | ||
/// </summary> | ||
/// <param name="dtr_track">Track 1 de l'iso</param> | ||
/// <param name="i_position">Adresse de l'index dans le fichier SLUS</param> | ||
/// <param name="nb">Nombre de pointeurs de l'index</param> | ||
/// <returns></returns> | ||
private static List<Global.st_index> readSlusIndex(DataTrackReader dtr_track, int i_position, int nb) | ||
{ | ||
List<Global.st_index> index = new List<Global.st_index>(); | ||
|
||
Stream st_file = dtr_track.ReadFile("/SLUS_006.26"); | ||
|
||
using (BinaryReader br_file = new BinaryReader(st_file)) | ||
{ | ||
br_file.BaseStream.Seek(i_position, SeekOrigin.Begin); | ||
|
||
Global.st_index elem; | ||
|
||
for (int i = 0; i < nb; i++) | ||
{ | ||
elem.id = i; | ||
elem.pos = br_file.ReadUInt32(); | ||
elem.size = br_file.ReadUInt32(); | ||
|
||
index.Add(elem); | ||
} | ||
} | ||
|
||
return index; | ||
} | ||
|
||
/// <summary> | ||
/// Extract all files for image disk and unpack those are archive | ||
/// </summary> | ||
/// <param name="as_isoName">Pathnam of the file</param> | ||
/// <returns></returns> | ||
public static bool extractFromIso(string as_isoName) | ||
{ | ||
DataTrackReader t_track = openIso(as_isoName); | ||
|
||
try | ||
{ | ||
t_track.ReadVolumeDescriptors(); | ||
t_track.BuildIndex(); | ||
|
||
foreach (DataTrackIndexEntry entry in t_track.FileEntries) | ||
{ | ||
Trace.WriteLine(string.Format("Extracting {0}...", entry.FullPath)); | ||
|
||
switch (Path.GetFileName(entry.FullPath)) | ||
{ | ||
case "B.DAT": | ||
t_track.ExtractFile(entry.FullPath, Global.pcs_dirDump + entry.FullPath); | ||
List<Global.st_index> index = readSlusIndex(t_track, 0xF3C00, 339); | ||
MemoryStream st_file = (MemoryStream)t_track.ReadFile(entry.FullPath); | ||
Archive.unpackBDat(st_file, index, entry.FullPath.Replace(".", "") + "/"); | ||
break; | ||
|
||
default: | ||
t_track.ExtractFile(entry.FullPath, Global.pcs_dirDump + entry.FullPath); | ||
break; | ||
} | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
Trace.WriteLine(ex.Message + Environment.NewLine, "ERROR"); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{45D36B35-4AD5-4BD4-89C8-AEA9DE6B1CAF}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>ToDoTools</RootNamespace> | ||
<AssemblyName>ToDoTools</AssemblyName> | ||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<TargetFrameworkProfile /> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="crh, Version=0.1.5877.39521, Culture=neutral, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>lib\crh.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="TalesOfComp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>lib\TalesOfComp.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="sources\Archive.cs" /> | ||
<Compile Include="sources\Global.cs" /> | ||
<Compile Include="ToDTMain.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<PropertyGroup> | ||
<PreBuildEvent> | ||
</PreBuildEvent> | ||
</PropertyGroup> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
Binary file not shown.
Binary file not shown.
Oops, something went wrong.