Add support for many more single file formats
This commit is contained in:
parent
0666713bc5
commit
1ff0c246a1
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
.vs/*
|
||||||
|
Conv2PSV/bin/*
|
||||||
|
Conv2PSV/obj/*
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
|
||||||
</startup>
|
</startup>
|
||||||
</configuration>
|
</configuration>
|
|
@ -8,9 +8,10 @@
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<RootNamespace>Conv2PSV</RootNamespace>
|
<RootNamespace>Conv2PSV</RootNamespace>
|
||||||
<AssemblyName>PS12PSV</AssemblyName>
|
<AssemblyName>PS12PSV</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
<TargetFrameworkProfile />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||||
<StartArguments>BASCUS-94228SPYRO.mcs</StartArguments>
|
<StartArguments>
|
||||||
|
</StartArguments>
|
||||||
<RemoteDebugEnabled>false</RemoteDebugEnabled>
|
<RemoteDebugEnabled>false</RemoteDebugEnabled>
|
||||||
<StartWorkingDirectory>C:\Users\earsy\Documents\visual studio 2017\Projects\Conv2PSV\Conv2PSV\bin\Debug</StartWorkingDirectory>
|
<StartWorkingDirectory>
|
||||||
|
</StartWorkingDirectory>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
Binary file not shown.
Before Width: | Height: | Size: 184 KiB After Width: | Height: | Size: 162 KiB |
|
@ -40,7 +40,7 @@ namespace Conv2PSV
|
||||||
|
|
||||||
static String GetTitle(String FileName)
|
static String GetTitle(String FileName)
|
||||||
{
|
{
|
||||||
if (Path.GetExtension(FileName) == ".mcs")
|
if (Path.GetExtension(FileName).ToLower() == ".mcs" || Path.GetExtension(FileName).ToLower() == ".ps1")
|
||||||
{
|
{
|
||||||
FileStream fs = File.OpenRead(FileName);
|
FileStream fs = File.OpenRead(FileName);
|
||||||
fs.Seek(0xA, SeekOrigin.Begin);
|
fs.Seek(0xA, SeekOrigin.Begin);
|
||||||
|
@ -48,17 +48,17 @@ namespace Conv2PSV
|
||||||
fs.Close();
|
fs.Close();
|
||||||
return Name;
|
return Name;
|
||||||
}
|
}
|
||||||
else if(Path.GetExtension(FileName) == ".gme")
|
else if(Path.GetExtension(FileName).ToLower() == ".mcb" || Path.GetExtension(FileName).ToLower() == ".psx" || Path.GetExtension(FileName).ToLower() == ".mcx" || Path.GetExtension(FileName).ToLower() == ".pda")
|
||||||
{
|
{
|
||||||
FileStream fs = File.OpenRead(FileName);
|
FileStream fs = File.OpenRead(FileName);
|
||||||
fs.Seek(0xFCA, SeekOrigin.Begin);
|
fs.Seek(0x0, SeekOrigin.Begin);
|
||||||
String Name = GetString(fs);
|
String Name = GetString(fs);
|
||||||
fs.Close();
|
fs.Close();
|
||||||
return Name;
|
return Name;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new FileNotFoundException();
|
return Path.GetFileNameWithoutExtension(FileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,34 +95,52 @@ namespace Conv2PSV
|
||||||
return PsvName;
|
return PsvName;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void WriteSC(String FilePath, Stream PSV)
|
static int GetScLen(String FilePath)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Writing SC Image");
|
if (Path.GetExtension(FilePath).ToLower() == ".mcs" || Path.GetExtension(FilePath).ToLower() == ".ps1")
|
||||||
if (Path.GetExtension(FilePath) == ".mcs")
|
|
||||||
{
|
{
|
||||||
FileStream MCS = File.OpenRead(FilePath);
|
FileStream MCS = File.OpenRead(FilePath);
|
||||||
long SCLen = MCS.Length - 0x80;
|
int SCLen = Convert.ToInt32(MCS.Length - 0x80);
|
||||||
MCS.Seek(0x80, SeekOrigin.Begin);
|
|
||||||
byte[] SCImage = new Byte[SCLen];
|
|
||||||
MCS.Read(SCImage, 0x00, (int)SCLen);
|
|
||||||
PSV.Write(SCImage, 0x00, (int)SCLen);
|
|
||||||
MCS.Close();
|
MCS.Close();
|
||||||
|
return SCLen;
|
||||||
}
|
}
|
||||||
else if (Path.GetExtension(FilePath) == ".gme")
|
else if (Path.GetExtension(FilePath).ToLower() == ".mcb" || Path.GetExtension(FilePath).ToLower() == ".psx" || Path.GetExtension(FilePath).ToLower() == ".mcx" || Path.GetExtension(FilePath).ToLower() == ".pda")
|
||||||
{
|
{
|
||||||
FileStream GME = File.OpenRead(FilePath);
|
FileStream PSX = File.OpenRead(FilePath);
|
||||||
GME.Seek(0xFC4, SeekOrigin.Begin);
|
int SCLen = Convert.ToInt32(PSX.Length - 0x36);
|
||||||
BinaryReader BGME = new BinaryReader(GME);
|
PSX.Close();
|
||||||
int SCLen = BGME.ReadInt16();
|
return SCLen;
|
||||||
GME.Seek(0x2F40, SeekOrigin.Begin);
|
|
||||||
byte[] SCImage = new Byte[SCLen];
|
|
||||||
GME.Read(SCImage, 0x00, SCLen);
|
|
||||||
PSV.Write(SCImage, 0x00, SCLen);
|
|
||||||
GME.Close();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new FileNotFoundException();
|
FileStream RAW = File.OpenRead(FilePath);
|
||||||
|
int SCLen = Convert.ToInt32(RAW.Length);
|
||||||
|
RAW.Close();
|
||||||
|
return SCLen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static void WriteSC(String FilePath, Stream PSV)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Writing SC Image");
|
||||||
|
if (Path.GetExtension(FilePath).ToLower() == ".mcs" || Path.GetExtension(FilePath).ToLower() == ".ps1")
|
||||||
|
{
|
||||||
|
FileStream MCS = File.OpenRead(FilePath);
|
||||||
|
MCS.Seek(0x80, SeekOrigin.Begin);
|
||||||
|
MCS.CopyTo(PSV);
|
||||||
|
MCS.Close();
|
||||||
|
}
|
||||||
|
else if (Path.GetExtension(FilePath).ToLower() == ".mcb" || Path.GetExtension(FilePath).ToLower() == ".psx" || Path.GetExtension(FilePath).ToLower() == ".mcx" || Path.GetExtension(FilePath).ToLower() == ".pda")
|
||||||
|
{
|
||||||
|
FileStream PSX = File.OpenRead(FilePath);
|
||||||
|
PSX.Seek(0x36, SeekOrigin.Begin);
|
||||||
|
PSX.CopyTo(PSV);
|
||||||
|
PSX.Close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FileStream RAW = File.OpenRead(FilePath);
|
||||||
|
RAW.CopyTo(PSV);
|
||||||
|
RAW.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +152,7 @@ namespace Conv2PSV
|
||||||
Console.WriteLine("Select Save");
|
Console.WriteLine("Select Save");
|
||||||
OpenFileDialog ofd = new OpenFileDialog();
|
OpenFileDialog ofd = new OpenFileDialog();
|
||||||
ofd.InitialDirectory = Directory.GetCurrentDirectory();
|
ofd.InitialDirectory = Directory.GetCurrentDirectory();
|
||||||
ofd.Filter = "PlayStation One Save Files (*.mcs, *.gme)|*.mcs;*.gme|MemCardREX Single Save (*.mcs)|*.mcs|PlayStation DEXDRIVE (Datel) (*.gme)|*.gme";
|
ofd.Filter = "PlayStation One Single Save Files (*.mcs, *.ps1, *.mcb, *.psx, *.mcx, *.mcb, *.mcx *.pda, *.raw)|*.mcs;*.ps1;*.mcb;*.psx;*.mcx;*.pda;*.raw|PSXGameEdit Single Save (*.mcs)|*.mcs|Memory Card Juggler Single Save (*.ps1)|*.ps1|Smart Link Single Save (*.mcb)|*.mcb|Action Replay, Caetla or Game Shark Single Save (*.psx)|*.psx|Datel Single Save (*.mcx, *.pda)|*.mcx;*.pda|RAW Single Save (*, *.raw)|*;*.raw";
|
||||||
DialogResult res = ofd.ShowDialog();
|
DialogResult res = ofd.ShowDialog();
|
||||||
if (res == DialogResult.OK)
|
if (res == DialogResult.OK)
|
||||||
{
|
{
|
||||||
|
@ -157,30 +175,50 @@ namespace Conv2PSV
|
||||||
PSV.SetLength(0);
|
PSV.SetLength(0);
|
||||||
BinaryWriter BW = new BinaryWriter(PSV);
|
BinaryWriter BW = new BinaryWriter(PSV);
|
||||||
WriteMagic(PSV);
|
WriteMagic(PSV);
|
||||||
|
// Write reserved space.
|
||||||
BW.Write((UInt32)0);
|
BW.Write((UInt32)0);
|
||||||
|
BW.Write((UInt64)0x00);
|
||||||
|
|
||||||
//Am lazy and dont want to implement sonys broken AES-CBC algorythm
|
// Am lazy and dont want to implement sonys broken AES-CBC
|
||||||
// Just do a seed i know the hmac key for
|
// Just do a seed i know the hmac key for
|
||||||
// ps3 wont care.
|
// ps3 wont care.
|
||||||
|
|
||||||
Byte[] StaticSeeed = { 0x42, 0x6C, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x42, 0x65, 0x20, 0x7E, 0x20, 0x57, 0x69, 0x63, 0x63, 0x61, 0x6E, 0x73 };
|
Byte[] StaticSeeed = { 0x42, 0x6C, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x42, 0x65, 0x20, 0x7E, 0x20, 0x57, 0x69, 0x63, 0x63, 0x61, 0x6E, 0x73 };
|
||||||
//"Blessed Be ~ Wiccans"(0x14) - Allways nice to add personality to your code where-ever possible.
|
//"Blessed Be ~ Wiccans" - Allways nice to add personality to your code where-ever possible.
|
||||||
|
|
||||||
PSV.Write(StaticSeeed, 0x00, 0x14);
|
PSV.Write(StaticSeeed, 0x00, 0x14);
|
||||||
|
int SCSize = GetScLen(FilePath);
|
||||||
|
Console.WriteLine("SC Image Size: " + SCSize.ToString());
|
||||||
|
|
||||||
PSV.Write(new Byte[0x14], 0x00, 0x14);
|
PSV.Write(new Byte[0x14], 0x00, 0x14);
|
||||||
Console.WriteLine("Writing Flags... ");
|
Console.WriteLine("Writing Header... ");
|
||||||
Byte[] Flags = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x03, 0x90, 0x00, 0x00};
|
BW.Write((UInt32)0x14); // 0x14 - PS1 Save, 0x2C PS2 Save.
|
||||||
PSV.Write(Flags, 0x00, 0x34);
|
BW.Write((UInt32)0x01); // 0x01 - PS1 Save, 0x02 PS2 Save.
|
||||||
|
|
||||||
|
BW.Write((UInt32)SCSize); // Fileisze
|
||||||
|
|
||||||
|
BW.Write((UInt32)0x84); // Unknown 2
|
||||||
|
BW.Write((UInt32)0x200); // Unknown 4
|
||||||
|
|
||||||
|
BW.Write((UInt64)0x00); // Reserved 2
|
||||||
|
BW.Write((UInt64)0x00); // Reserved 3
|
||||||
|
|
||||||
|
BW.Write((UInt32)0x2000); // Unknown 5
|
||||||
|
BW.Write((UInt32)0x9003); // Unknown 6
|
||||||
|
|
||||||
|
if (SaveTitle.Length > 20)
|
||||||
|
SaveTitle = SaveTitle.Substring(0, 20);
|
||||||
|
|
||||||
int Padding = (0x20 - SaveTitle.Length);
|
int Padding = (0x20 - SaveTitle.Length);
|
||||||
Console.WriteLine("Writing " + SaveTitle + " +" + Padding.ToString());
|
Console.WriteLine("Writing " + SaveTitle + " + 0x00*" + Padding.ToString());
|
||||||
WriteString(PSV, SaveTitle);
|
WriteString(PSV, SaveTitle);
|
||||||
BW.Write(new Byte[Padding], 0x00, Padding);
|
BW.Write(new Byte[Padding], 0x00, Padding);
|
||||||
|
|
||||||
|
Console.WriteLine("Writing SC Image ...");
|
||||||
WriteSC(FilePath, PSV);
|
WriteSC(FilePath, PSV);
|
||||||
|
|
||||||
byte[] Signature = SignatureGen(PSV);
|
byte[] Signature = SignatureGen(PSV);
|
||||||
Console.WriteLine("Writing Signature to file...");
|
Console.WriteLine("Signing...");
|
||||||
PSV.Seek(0x1C, SeekOrigin.Begin);
|
PSV.Seek(0x1C, SeekOrigin.Begin);
|
||||||
PSV.Write(Signature, 0x00, 0x14);
|
PSV.Write(Signature, 0x00, 0x14);
|
||||||
Console.WriteLine("Done!\n\nBlessed Be ~");
|
Console.WriteLine("Done!\n\nBlessed Be ~");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user