void CompressStuff(int i, ref FARCFile[] Files, ref KKtIO writer) { Files[i].Offset = (int)writer.Position; if (Signature == Farc.FArc) { KKtIO reader = KKtIO.OpenReader(Files[i].Name); writer.Write(reader.ReadBytes((int)reader.Length)); Files[i].SizeUnc = (int)reader.Length; } else { Files[i].Data = File.ReadAllBytes(Files[i].Name); if (Signature != Farc.FArc) { MemoryStream stream = new MemoryStream(); using (GZipStream gZipStream = new GZipStream(stream, CompressionMode.Compress)) gZipStream.Write(Files[i].Data, 0, Files[i].Data.Length); Files[i].SizeUnc = Files[i].Data.Length; Files[i].Data = stream.ToArray(); Files[i].SizeComp = Files[i].Data.Length; } else if (Signature == Farc.FARC) { int AlignData = (int)Main.Align(Files[i].Data.Length, 0x40); byte[] Data = new byte[AlignData]; for (int i1 = 0; i1 < Files[i].Data.Length; i1++) { Data[i1] = Files[i].Data[i1]; } for (int i1 = Files[i].Data.Length; i1 < AlignData; i1++) { Data[i1] = 0x78; } Files[i].Data = Encrypt(Data, false); } writer.Write(Files[i].Data); Files[i].Data = null; } if (Signature != Farc.FARC) { int Align = (int)Main.Align(writer.Position, 0x20) - (int)writer.Position; for (int i1 = 0; i1 < Align; i1++) { if (Signature == Farc.FArc) { writer.Write((byte)0x00); } else { writer.Write((byte)0x78); } } } }
public static int BINReader(ref AUTH Data, string file) { Data = new AUTH { dataArray = new string[4], Name = new List <string>(), Value = new List <string>() }; KKtIO reader = KKtIO.OpenReader(file + ".bin"); reader.Format = KKtMain.Format.F; Data.Signature = reader.ReadInt32(); if (Data.Signature != 0x44334123) { return(0); } Data.Signature = reader.ReadInt32(); if (Data.Signature != 0x5F5F5F41) { return(0); } reader.ReadInt64(); byte[] STRData = reader.ReadBytes((int)(reader.Length - reader.Position)); string TempSTRData = ""; foreach (byte a in STRData) { if (a == 0x0A) { if (!TempSTRData.StartsWith("#")) { Data.dataArray = TempSTRData.Split('='); Data.Name.Add(Data.dataArray[0]); Data.Value.Add(Data.dataArray[1]); } TempSTRData = ""; } else { TempSTRData += Convert.ToChar(a); } } for (int i = 0; i < Data.Name.Count; i++) { if (Data.Name[i] == "category.length") { Data.Category = new string[int.Parse(Data.Value[i])]; } else if (Data.Name[i] == "uid.length") { Data.UID = new UID[int.Parse(Data.Value[i])]; } } if (Data.Category != null) { for (int i0 = 0; i0 < Data.Category.Length; i0++) { for (int i = 0; i < Data.Name.Count; i++) { if (Data.Name[i] == "category." + i0 + ".value") { Data.Category[i0] = Data.Value[i]; } } } } if (Data.UID != null) { for (int i0 = 0; i0 < Data.UID.Length; i0++) { Data.UID[i0].Category = ""; Data.UID[i0].Size = -1; Data.UID[i0].Value = ""; for (int i = 0; i < Data.Name.Count; i++) { if (Data.Name[i] == "uid." + i0 + ".category") { Data.UID[i0].Category = Data.Value[i]; } else if (Data.Name[i] == "uid." + i0 + ".size") { Data.UID[i0].Size = int.Parse(Data.Value[i]); } else if (Data.Name[i] == "uid." + i0 + ".value") { Data.UID[i0].Value = Data.Value[i]; } } } } reader.Close(); return(1); }