Fix more more bugs
This commit is contained in:
parent
d1714f3c98
commit
e7f60f09c6
Binary file not shown.
|
@ -1,7 +1,9 @@
|
|||
using CXML;
|
||||
using General;
|
||||
using Ionic.Zlib;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
@ -13,7 +15,6 @@ namespace CXMLDecompiler
|
|||
{
|
||||
String MainDir = "";
|
||||
String XMLFilename = "";
|
||||
String CXMLFilename = "";
|
||||
String MagicNumber = "";
|
||||
Int32 Version;
|
||||
FileStream InfoFile;
|
||||
|
@ -29,6 +30,7 @@ namespace CXMLDecompiler
|
|||
MemoryStream FileTable;
|
||||
|
||||
Boolean IsInitalized = false;
|
||||
public Boolean HashStrings = false;
|
||||
|
||||
BinaryWriter bInfoFile;
|
||||
BinaryWriter bTreeTable;
|
||||
|
@ -65,7 +67,6 @@ namespace CXMLDecompiler
|
|||
bHashIDTable = new BinaryWriter(HashIDTable);
|
||||
bStringIDTable = new BinaryWriter(StringIDTable);
|
||||
|
||||
CXMLFilename = CxmlFile;
|
||||
XMLFilename = XMLFile;
|
||||
MainDir = Path.GetDirectoryName(XMLFilename);
|
||||
|
||||
|
@ -377,7 +378,12 @@ namespace CXMLDecompiler
|
|||
Console.WriteLine("Char: " + attribute.Value);
|
||||
break;
|
||||
case AttributeType.TYPE_HASH_ID:
|
||||
int HashTableOffset = AddGetHashIdTable(Int32.Parse(attribute.Value, System.Globalization.NumberStyles.HexNumber));
|
||||
int hashId = int.Parse(attribute.Value, NumberStyles.HexNumber);
|
||||
|
||||
if (HashStrings)
|
||||
hashId = int.Parse(Tools.GenerateShortHash(Encoding.UTF8.GetBytes(attribute.Value)), NumberStyles.HexNumber);
|
||||
|
||||
int HashTableOffset = AddGetHashIdTable(hashId);
|
||||
int HashTableSize = 4;
|
||||
bWorkRam.Write(HashTableOffset);
|
||||
bWorkRam.Write(HashTableSize);
|
||||
|
@ -432,14 +438,21 @@ namespace CXMLDecompiler
|
|||
Console.WriteLine("ID String: " + StringIdTableOffset + " sz: 0");
|
||||
break;
|
||||
case AttributeType.TYPE_ID_INT_LOOPBACK:
|
||||
int IntIdTableOffset = AddGetIntIdTable(int.Parse(attribute.Value, System.Globalization.NumberStyles.HexNumber), Convert.ToInt32(TreeTable.Position));
|
||||
int hash = int.Parse(attribute.Value, NumberStyles.HexNumber);
|
||||
if (HashStrings)
|
||||
hash = int.Parse(Tools.GenerateShortHash(Encoding.UTF8.GetBytes(attribute.Value)), NumberStyles.HexNumber);
|
||||
int IntIdTableOffset = AddGetIntIdTable(hash, Convert.ToInt32(TreeTable.Position));
|
||||
bWorkRam.Write(IntIdTableOffset);
|
||||
bWorkRam.Write((int)0x00);
|
||||
Console.WriteLine("Int Loopback: " + ElementName + " " + TreeTable.Position.ToString("X") + " (" + TreeTable.Position.ToString("X") + ")");
|
||||
Console.WriteLine("Loopback ID Int: " + IntIdTableOffset + " sz: 0");
|
||||
break;
|
||||
case AttributeType.TYPE_ID_INT:
|
||||
IntIdTableOffset = AddGetIntIdTable(int.Parse(attribute.Value, System.Globalization.NumberStyles.HexNumber), -1);
|
||||
hash = int.Parse(attribute.Value, NumberStyles.HexNumber);
|
||||
if (HashStrings)
|
||||
hash = int.Parse(Tools.GenerateShortHash(Encoding.UTF8.GetBytes(attribute.Value)), NumberStyles.HexNumber);
|
||||
IntIdTableOffset = AddGetIntIdTable(hash, -1);
|
||||
|
||||
bWorkRam.Write(IntIdTableOffset);
|
||||
bWorkRam.Write((int)0x00);
|
||||
Console.WriteLine("Int Id: " + IntIdTableOffset + " sz: 0");
|
||||
|
@ -635,6 +648,16 @@ namespace CXMLDecompiler
|
|||
FileTable.Seek(0x00, SeekOrigin.Begin);
|
||||
FileTable.CopyTo(InfoFile);
|
||||
|
||||
string excessData = GetTypingInformation("EXCESS");
|
||||
if (excessData != "0")
|
||||
{
|
||||
Console.WriteLine("Excess Data Found, Writing to end.");
|
||||
byte[] ExcessData = Convert.FromBase64String(excessData.Replace("*", "="));
|
||||
InfoFile.Read(ExcessData, 0x00, ExcessData.Length);
|
||||
byte[] UnCompressed = ZlibStream.UncompressBuffer(ExcessData);
|
||||
InfoFile.Write(UnCompressed, 0x00, UnCompressed.Length);
|
||||
}
|
||||
|
||||
InfoFile.Seek(0x8, SeekOrigin.Begin);
|
||||
bInfoFile.Write(TreeTableOffset);
|
||||
bInfoFile.Write(TreeTableSize);
|
||||
|
|
|
@ -364,6 +364,26 @@ namespace CXML
|
|||
typingInfo.value = value.ToString();
|
||||
SilicaTypingInformationList.Add(typingInfo);
|
||||
}
|
||||
public void Align(Stream s, int align)
|
||||
{
|
||||
|
||||
int size = Convert.ToInt32(s.Position);
|
||||
if (size % align != 0)
|
||||
{
|
||||
int totalAlign = (align - (size % align));
|
||||
for (int i = 0; i < totalAlign; i++)
|
||||
{
|
||||
s.Seek(0x1, SeekOrigin.Current);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void GotoEnd()
|
||||
{
|
||||
InfoFile.Seek(GetFileTableOffset(), SeekOrigin.Begin);
|
||||
InfoFile.Seek(GetFileTableSize(), SeekOrigin.Current);
|
||||
Align(InfoFile, 0x10);
|
||||
}
|
||||
|
||||
public void DecompileCXML(String CXMLFile, bool force = false)
|
||||
{
|
||||
|
||||
|
@ -390,6 +410,17 @@ namespace CXML
|
|||
XMLFile.Flush();
|
||||
XMLFile.Close();
|
||||
|
||||
GotoEnd();
|
||||
int bytesRemaining = Convert.ToInt32(InfoFile.Length - InfoFile.Position);
|
||||
if (bytesRemaining > 0) // Some RCS files have unexplainable random XML Data at the end of them, Dont ask me. im just the messanger
|
||||
{
|
||||
Console.WriteLine(bytesRemaining.ToString("X8") + " Excess Bytes Found, Shoving it in SilicaTypingInformation.");
|
||||
byte[] ExcessData = new byte[bytesRemaining];
|
||||
InfoFile.Read(ExcessData, 0x00, bytesRemaining);
|
||||
byte[] Compressed = ZlibStream.CompressBuffer(ExcessData);
|
||||
string base64 = Convert.ToBase64String(Compressed).Replace("=", "*");
|
||||
AddTypingInfo("EXCESS", base64);
|
||||
}
|
||||
for(int i = 0; i < SilicaTypingInformationList.Count; i++)
|
||||
{
|
||||
TypingInformation tinfo = SilicaTypingInformationList[i];
|
||||
|
|
|
@ -54,6 +54,8 @@ namespace CXMLDecompiler
|
|||
}
|
||||
zip.Dispose();
|
||||
zipStream.Dispose();
|
||||
|
||||
File.AppendAllText("GimConv\\GimConv.cfg", "option -psvindex8 {\r\n format_endian = little\r\n format_style = psp\r\n image_format = index8\r\n pixel_order = normal\r\n pixel_channel = rgba\r\n limit_image_width = 4096\r\n limit_image_height = 4096\r\n}");
|
||||
DownloadCompleted = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ namespace CXMLCli
|
|||
Console.WriteLine("\t-w --wait-exit Wait for keypress before exiting");
|
||||
Console.WriteLine("\t-d --decompile Decompile CXML to XML.");
|
||||
Console.WriteLine("\t-c --compile Compile XML to CXML");
|
||||
Console.WriteLine("\t-h --hash-string When Compiling, Generate new hashes");
|
||||
Console.WriteLine("Example Decompile: " + Path.GetFileName(Assembly.GetEntryAssembly().Location) + " app.info -d -p");
|
||||
Console.WriteLine("Example Compile: " + Path.GetFileName(Assembly.GetEntryAssembly().Location) + " app.xml app.info -c");
|
||||
Console.WriteLine("Default functonality is to Decompile,\nThis is canceled if any other arguments passed.");
|
||||
|
@ -200,6 +201,9 @@ namespace CXMLCli
|
|||
{
|
||||
Console.WriteLine("Compiling: " + path);
|
||||
CXMLBuilder builder = new CXMLBuilder();
|
||||
if (HasArg(ArgsFull, "-h") || HasArg(ArgsFull, "----hash-string"))
|
||||
builder.HashStrings = true;
|
||||
|
||||
builder.Init(path, args[1]);
|
||||
builder.BuildCXML(path, args[1]);
|
||||
Console.WriteLine("\n\nCOMPILATION COMPLETE!");
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
|
@ -258,7 +259,9 @@ namespace General
|
|||
|
||||
public static string GenerateShortHash(byte[] Data)
|
||||
{
|
||||
return GenerateHash(Data).Substring(0, 8);
|
||||
SHA1 sha = SHA1.Create();
|
||||
byte[] ShaBytes = sha.ComputeHash(Data);
|
||||
return BitConverter.ToInt32(ShaBytes, 0).ToString("X8");
|
||||
}
|
||||
|
||||
public static String ReadString(Stream ms, int limit = -1)
|
||||
|
|
Loading…
Reference in New Issue