102 lines
3.3 KiB
C#
102 lines
3.3 KiB
C#
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);
|
|
|
|
}
|
|
}
|
|
}
|