i really gotta goto slepes now so bye.

This commit is contained in:
Bluzume 2021-08-12 03:11:05 +12:00
parent ab1f4954e0
commit a2d10a9195
6 changed files with 183 additions and 8 deletions

Binary file not shown.

101
AppInfoCli/CXMLBuilder.cs Normal file
View File

@ -0,0 +1,101 @@
using General;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
namespace CXMLDecompiler
{
class CXMLBuilder
{
String MainDir = "";
String XMLFilename = "";
String CXMLFilename = "";
String MagicNumber = "";
FileStream InfoFile;
MemoryStream TreeTable;
MemoryStream StringIDTable;
MemoryStream IntIDTable;
MemoryStream StringTable;
MemoryStream CharTable;
MemoryStream HashIDTable;
MemoryStream IntArrayTable;
MemoryStream FloatArrayTable;
MemoryStream FileTable;
Boolean IsInitalized = false;
BinaryWriter bInfoFile;
BinaryWriter bTreeTable;
BinaryWriter bIntIDTable;
BinaryWriter bFloatArrayTable;
BinaryWriter bIntArrayTable;
BinaryWriter bHashIDTable;
BinaryWriter bStringIDTable;
XmlReader XMLFile;
public void Init(string XMLFile, string CxmlFile, string Magic)
{
MagicNumber = Magic;
InfoFile = File.Open(CxmlFile, FileMode.CreateNew, FileAccess.ReadWrite);
TreeTable = new MemoryStream();
StringIDTable = new MemoryStream();
IntIDTable = new MemoryStream();
StringTable = new MemoryStream();
CharTable = new MemoryStream();
HashIDTable = new MemoryStream();
IntArrayTable = new MemoryStream();
FloatArrayTable = new MemoryStream();
FileTable = new MemoryStream();
bInfoFile = new BinaryWriter(InfoFile);
bTreeTable = new BinaryWriter(TreeTable);
bIntIDTable = new BinaryWriter(IntIDTable);
bFloatArrayTable = new BinaryWriter(FloatArrayTable);
bIntArrayTable = new BinaryWriter(IntArrayTable);
bHashIDTable = new BinaryWriter(HashIDTable);
bStringIDTable = new BinaryWriter(StringIDTable);
CXMLFilename = CxmlFile;
XMLFilename = XMLFile;
MainDir = Path.GetDirectoryName(XMLFilename);
IsInitalized = true;
return;
}
public string DetectMagic(string XmlFileName)
{
string SearchFor = "<!--Decompiled with CXML Decompiler v6 By SilicaAndPina (Magic: \"";
string SearchFor2 = "\")--> ";
string xmlData = File.ReadAllText(XmlFileName);
int ind1 = xmlData.IndexOf(SearchFor);
xmlData = xmlData.Substring(ind1+ SearchFor.Length);
int ind2 = xmlData.IndexOf(SearchFor2);
xmlData = xmlData.Substring(0, ind2);
return xmlData;
}
public void BuildCXML(string XmlFile, string CxmlFile)
{
string Magic = DetectMagic(XmlFile);
Console.WriteLine("Magic Number: " + Magic);
if (!IsInitalized)
Init(XmlFile, XmlFile, "RCOF");
XmlReaderSettings XMLSettings = new XmlReaderSettings();
string XMLPath = Path.Combine(MainDir, XMLFilename);
XMLFile = XmlReader.Create(XMLPath, XMLSettings);
Tools.WriteStringToStream(InfoFile, Magic);
bInfoFile.Write((UInt32)0x0110);
}
}
}

View File

@ -90,7 +90,9 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CXML.cs" />
<Compile Include="CXMLReader.cs" />
<Compile Include="CXMLBuilder.cs" />
<Compile Include="GimConv.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Tools.cs" />

View File

@ -337,6 +337,10 @@ namespace CXML
InfoFile.Read(FileTable, 0x00, DataLength);
return FileTable;
}
public int ReadVersion()
{
return Tools.ReadIntAt(InfoFile, 0x4);
}
public void DecompileCXML(String CXMLFile, bool force = false)
{
@ -355,7 +359,8 @@ namespace CXML
string XMLPath = Path.Combine(MainDir, XMLFilename);
XMLFile = XmlWriter.Create(XMLPath, XMLSettings);
XMLFile.WriteStartDocument();
XMLFile.WriteComment("Decompiled with CXML Decompiler v6 By SilicaAndPina (Magic: \"" + MagicNumber + "\")");
XMLFile.WriteComment("Decompiled with CXML Decompiler v6 By SilicaAndPina (Magic: \"" + MagicNumber + "\", Version: \""+ ReadVersion()+"\")");
ReadElements();
XMLFile.WriteEndDocument();

62
AppInfoCli/GimConv.cs Normal file
View File

@ -0,0 +1,62 @@
using Ionic.Zip;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace CXMLDecompiler
{
class GimConv
{
static WebClient wc = new WebClient();
static bool DownloadCompleted = true;
public static void DownloadGimConv()
{
wc.DownloadProgressChanged += Wc_DownloadProgressChanged;
wc.DownloadDataCompleted += Wc_DownloadDataCompleted;
wc.DownloadDataAsync(new Uri("http://e1.dl.playstation.net/e1/downloads/ps3/themes/370/PS3_Custom_Theme_v200.zip")); // Thanks Sony :3
while (wc.IsBusy || !DownloadCompleted) { };
}
private static void Wc_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
{
Console.Write("\r\n");
MemoryStream zipStream = new MemoryStream(e.Result);
ZipFile zip = ZipFile.Read(zipStream);
foreach(ZipEntry zEntry in zip.Entries)
{
string filename = Path.GetFileName(zEntry.FileName);
if (filename == "msvcp71.dll" || filename == "msvcr71.dll" || zEntry.FileName.Contains("GimConv"))
{
string outputFilename = zEntry.FileName;
if (outputFilename.Contains("GimConv"))
outputFilename = outputFilename.Substring(outputFilename.IndexOf("GimConv"));
else
outputFilename = Path.Combine("GimConv", filename);
outputFilename = outputFilename.Replace("/", "\\");
Console.WriteLine("Extracting: " + outputFilename);
if (zEntry.IsDirectory)
{
Directory.CreateDirectory(outputFilename);
continue;
}
FileStream fs = File.Open(outputFilename, FileMode.CreateNew, FileAccess.ReadWrite);
zEntry.Extract(fs);
fs.Close();
}
}
DownloadCompleted = true;
}
private static void Wc_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
DownloadCompleted = false;
Console.Write("\rDownloading GimConv Directly from Sony " + e.BytesReceived + "/" + e.TotalBytesToReceive + " - " + e.ProgressPercentage.ToString() + "%");
}
}
}

View File

@ -1,4 +1,5 @@
using General;
using CXMLDecompiler;
using General;
using System;
using System.IO;
using System.Reflection;
@ -7,9 +8,12 @@ namespace CXMLCli
{
class Program
{
static void Main(string[] args)
static int Main(string[] args)
{
//args = "src20.vag -iv".Split(' ');
// Do you have gimconv?
if (!File.Exists(Path.Combine("GimConv", "GimConv.exe")))
GimConv.DownloadGimConv(); // Politely ask sony to give it to us.
bool Check = true;
@ -37,7 +41,7 @@ namespace CXMLCli
Console.WriteLine("\t-d --decompile Decompile CXML.");
Console.WriteLine("Example: " + Path.GetFileName(Assembly.GetEntryAssembly().Location) + " app.info -f -s -t -f -d");
Console.WriteLine("Default functonality is to Decompile,\nThis is canceled if any other arguments passed.");
return;
return 0;
}
String ArgsFull = String.Join(" ", args);
@ -50,7 +54,7 @@ namespace CXMLCli
string FileName = Path.GetFileNameWithoutExtension(path) + "-" + VAG.VAGAudio.GetFilename(path) + ".wav";
Console.WriteLine("Writing "+FileName);
File.WriteAllBytes(FileName, WaveData);
return;
return 0;
}
CXML.CXMLParser cxmlParser = new CXML.CXMLParser();
cxmlParser.Init(path, Check);
@ -139,7 +143,7 @@ namespace CXMLCli
cxmlParser.WaitExit = true;
}
if (ArgsFull.Contains("-d") || ArgsFull.Contains("--decompile"))
if (ArgsFull.Contains("-d") || ArgsFull.Contains("--decompile") && !ArgsFull.Contains("-dt"))
{
Console.WriteLine("Decompiling.");
cxmlParser.DecompileCXML(path, Check);
@ -147,6 +151,7 @@ namespace CXMLCli
if(cxmlParser.WaitExit)
Console.ReadKey();
}
return 0;
}
}