public override bool Load(Stream input) { if (this._IsLoaded == true) { return(true); } // Now that the engine supports both Zlib and Oodle, we need to know the type of block. // With M1: DE, we do this by adding a simple flag to the block which will be initialised // during the blocks construction. if (_UsesOodle) { input.Seek(this._DataOffset + 96, SeekOrigin.Begin); byte[] compressedData = input.ReadBytes((int)this._DataCompressedSize); this._Data = Oodle.Decompress(compressedData, (int)this._DataCompressedSize, (int)this.Size); } else { input.Seek(this._DataOffset, SeekOrigin.Begin); this._Data = new byte[this.Size]; using (ZLibStream stream = new ZLibStream(input, CompressionMode.Decompress, true)) { var length = stream.Read(this._Data, 0, this._Data.Length); if (length != this._Data.Length) { throw new InvalidOperationException(); } } } this._IsLoaded = true; return(true); }
public void Kraken_Compress(int level) { var path = Path.GetFullPath(Path.Combine("Resources", s_uncompressedFile)); var inbuffer = File.ReadAllBytes(path); var compressedBufferSizeNeeded = Oodle.GetCompressedBufferSizeNeeded(inbuffer.Length); var outdir = Path.Combine(Environment.CurrentDirectory, "ooz"); Directory.CreateDirectory(outdir); // oodle //IEnumerable<byte> outBuffer = new List<byte>(); //var r = Oodle.Compress(inbuffer, ref outBuffer, true, (Oodle.CompressionLevel)level); //var outpath = Path.Combine(outdir, $"{level}_oodle.kark"); //var final = outBuffer.ToArray(); //File.WriteAllBytes(outpath, final); #if _WINDOWS // kraken var outBuffer2 = new byte[compressedBufferSizeNeeded]; //var outBuffer2 = new byte[inbuffer.Length + 65536]; var r2 = KrakenNative.Compress(inbuffer, outBuffer2, (int)level); var outpath2 = Path.Combine(outdir, $"{(int)level}_kraken.kark"); var final2 = outBuffer2.Take(r2).ToArray(); File.WriteAllBytes(outpath2, final2); var compareFile = Path.GetFullPath(Path.Combine("Resources", $"{level}_oodle.kark")); var compareBytes = File.ReadAllBytes(compareFile); Assert.IsTrue(Enumerable.SequenceEqual(final2, compareBytes.Skip(8))); #endif }
public static Status CompressBuffer(byte[] rawBuf, out byte[] compBuf) { if (rawBuf.Length > 256) { //var compressedBufferSizeNeeded = GetCompressedBufferSizeNeeded(rawBuf.Length); //var compressedBuffer = new byte[compressedBufferSizeNeeded]; IEnumerable <byte> compressedBuffer = new List <byte>(); var compressedSize = Oodle.Compress(rawBuf, ref compressedBuffer, false, CompressionSettings.Get().CompressionLevel); var outArray = new byte[compressedSize + 8]; Array.Copy(BitConverter.GetBytes(KARK), 0, outArray, 0, 4); Array.Copy(BitConverter.GetBytes(rawBuf.Length), 0, outArray, 4, 4); Array.Copy(compressedBuffer.ToArray(), 0, outArray, 8, compressedSize); if (rawBuf.Length > outArray.Length) { compBuf = outArray; return(Status.Compressed); } } compBuf = rawBuf; return(Status.Uncompressed); }
private bool FlushOodleCompressedBlock(MemoryStream data, int blockLength) { byte[] compressed = Oodle.Compress(this._BlockBytes, blockLength, OodleFormat.Kraken, OodleCompressionLevel.Normal); Debug.Assert(compressed.Length != 0, "Compressed Block should not be empty"); data.WriteBytes(compressed); // If it doesn't fit within the range of ratio, store as uncompressed. if (!IsWithinCompressionRatio(compressed.Length, blockLength)) { return(false); } var compressedLength = (int)data.Length; if (data.Length < blockLength) { this._BaseStream.WriteValueS32(128 + compressedLength, this._Endian); this._BaseStream.WriteValueU8(1); CompressedBlockHeader compressedBlockHeader = new CompressedBlockHeader(); compressedBlockHeader.SetOodlePreset(); compressedBlockHeader.UncompressedSize = (uint)blockLength; compressedBlockHeader.CompressedSize = (uint)compressedLength; compressedBlockHeader.ChunkSize = 1; compressedBlockHeader.Unknown0C = (uint)blockLength; compressedBlockHeader.Chunks[0] = (ushort)compressedBlockHeader.CompressedSize; Console.WriteLine(compressedBlockHeader); compressedBlockHeader.Write(this._BaseStream, this._Endian); this._BaseStream.Write(new byte[96], 0, 96); // Empty padding. this._BaseStream.Write(data.GetBuffer(), 0, compressedLength); this._BlockOffset = 0; return(true); } return(false); }
public OodleStream(byte[] input, long decompressedLength) { Oodle.LoadOodleDll(); _baseStream = new MemoryStream(Decompress(input, decompressedLength), false) { Position = 0 }; }
public static void SetupClass(TestContext _) { var ass = AppDomain.CurrentDomain.BaseDirectory; if (!Oodle.Load()) { Assert.Fail("Could not load oo2ext_7_win64.dll."); } }
public void DecompressThrows(string data, int decompressedSize) { using var stream = File.Open(data, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); using var ms = new MemoryStream(); stream.CopyTo(ms); var compressedBuffer = ms.ToArray(); Assert.Throws <DecoderException>(() => Oodle.DecompressReplayData(compressedBuffer, decompressedSize)); }
public void Decompress(Oodle oodle, byte[] decompressedFile, uint offset) { foreach (Block block in Blocks) { uint expectedEnd = offset + block.DecompressedSize; block.Decompress(oodle, decompressedFile, offset); offset += block.DecompressedSize; } }
public int OodleTask(string path, string outpath, bool decompress, bool compress) { if (string.IsNullOrEmpty(path)) { return(0); } if (string.IsNullOrEmpty(outpath)) { outpath = Path.ChangeExtension(path, ".kark"); } if (decompress) { var file = File.ReadAllBytes(path); using var ms = new MemoryStream(file); using var br = new BinaryReader(ms); var oodleCompression = br.ReadBytes(4); if (!(oodleCompression.SequenceEqual(new byte[] { 0x4b, 0x41, 0x52, 0x4b }))) { throw new NotImplementedException(); } var size = br.ReadUInt32(); var buffer = br.ReadBytes(file.Length - 8); var unpacked = new byte[size]; var unpackedSize = Oodle.Decompress(buffer, unpacked); using var msout = new MemoryStream(); using var bw = new BinaryWriter(msout); bw.Write(unpacked); File.WriteAllBytes($"{outpath}.bin", msout.ToArray()); _loggerService.Success($"Finished decompressing: { outpath}.bin"); } if (compress) { var inbuffer = File.ReadAllBytes(path); IEnumerable <byte> outBuffer = new List <byte>(); var r = Oodle.Compress(inbuffer, ref outBuffer, true); File.WriteAllBytes(outpath, outBuffer.ToArray()); _loggerService.Success($"Finished compressing: {outpath}"); } return(1); }
public void DecompressTest(string data, int decompressedSize) { using var stream = File.Open(data, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); using var ms = new MemoryStream(); stream.CopyTo(ms); var compressedBuffer = ms.ToArray(); var result = Oodle.DecompressReplayData(compressedBuffer, decompressedSize); Assert.Equal(decompressedSize, result.Length); }
// Constructor #2 public App() { Directory.SetCurrentDirectory(AppContext.BaseDirectory); Init(); SetupExceptionHandling(); // load oodle if (!Oodle.Load()) { throw new FileNotFoundException($"oo2ext_7_win64.dll not found."); } }
public void DecompressTest() { var data = @"CompressedChunk/compressed.dump"; using var stream = File.Open(data, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); using var ms = new MemoryStream(); stream.CopyTo(ms); var compressedBuffer = ms.ToArray(); var decompressedSize = 441993; var compressedSize = 210703; var result = Oodle.DecompressReplayData(compressedBuffer, compressedSize, decompressedSize); Assert.Equal(decompressedSize, result.Length); }
/// <summary> /// Decompresses and copies a segment of zsize bytes from a stream to another stream /// </summary> /// <param name="stream"></param> /// <param name="outStream"></param> /// <param name="zSize"></param> /// <param name="size"></param> /// <exception cref="Exception"></exception> /// <exception cref="DecompressionException"></exception> public static void DecompressAndCopySegment(this Stream stream, Stream outStream, uint zSize, uint size) { if (zSize == size) { stream.CopyToWithLength(outStream, (int)zSize); } else { var oodleCompression = stream.ReadStruct <uint>(); if (oodleCompression == KARK) { var headerSize = stream.ReadStruct <uint>(); if (headerSize != size) { throw new DecompressionException($"Buffer size doesn't match size in info table. {headerSize} vs {size}"); } //const int SPAN_LEN = 5333;//32768; var length = (int)zSize - 8; var inputBuffer = new byte[length]; var read = stream.Read(inputBuffer); var outBuffer = new byte[size]; var unpackedSize = Oodle.Decompress(inputBuffer, outBuffer); //var inputBufferSpan = length <= SPAN_LEN // ? stackalloc byte[length] // : new byte[length]; //var outputBufferSpan = size <= SPAN_LEN ? stackalloc byte[(int)size] : new byte[size]; //stream.Read(inputBufferSpan); //var unpackedSize = Oodle.Decompress(inputBufferSpan, outputBufferSpan); if (unpackedSize != size) { throw new DecompressionException( $"Unpacked size {unpackedSize} doesn't match real size {size}."); } //outStream.Write(outputBufferSpan); outStream.Write(outBuffer); } else { stream.Seek(0, SeekOrigin.Begin); stream.CopyToWithLength(outStream, (int)zSize); } } }
public ME3PackageDecompressed Decompress() { string lib = @"G:\SteamSecondary\steamapps\common\Mass Effect Legendary Edition\Game\ME3\Binaries\Win64\oo2core_8_win64.dll"; uint maxOffset = Partitions.Max(i => i.DecompressOffset); long decompressTotalSize = Partitions.First(i => i.DecompressOffset == maxOffset).Chunk.DecompressedSize; decompressTotalSize += maxOffset; byte[] decompressedFile = new byte[decompressTotalSize]; using (Oodle oodle = new Oodle(lib)) { foreach (Partition partition in Partitions) { partition.Decompress(oodle, decompressedFile); } } return(new ME3PackageDecompressed(FileHeader, decompressedFile)); }
public void Read(BinaryReader br) { var magic = br.ReadUInt32(); if (magic != s_magic) { throw new InvalidParsingException("not a valid Archive"); } var version = br.ReadUInt32(); var size = br.ReadInt32(); var zsize = br.ReadInt32(); var count = br.ReadInt32(); var inbuffer = br.ReadBytes(zsize); if (size > zsize) { // buffer is compressed var outBuffer = new byte[size]; var r = Oodle.Decompress(inbuffer, outBuffer); using var ms = new MemoryStream(outBuffer); using var tempbr = new BinaryReader(ms); for (var i = 0; i < count; i++) { FileInfos.Add(tempbr.ReadCR2WString()); } } else if (size < zsize) { // error // extract as .bin file } else { // no compression using var ms = new MemoryStream(inbuffer); using var tempbr = new BinaryReader(ms); for (var i = 0; i < count; i++) { FileInfos.Add(tempbr.ReadCR2WString()); } } }
public static void DecompressBuffer(byte[] compBuf, out byte[] rawBuf) { using var ms = new MemoryStream(compBuf); using var br = new BinaryReader(ms); var header = br.ReadUInt32(); if (header == KARK) { var size = br.ReadUInt32(); var compressedData = br.ReadBytes(compBuf.Length - 8); rawBuf = new byte[size]; var r = Oodle.Decompress(compressedData, rawBuf); } else { throw new Exception(); } }
public void Kraken_Decompress(int level) { var testFile = Path.GetFullPath(Path.Combine("Resources", $"{level}_oodle.kark")); var outdir = Path.Combine(Environment.CurrentDirectory, "ooz"); Directory.CreateDirectory(outdir); using var fs = new FileStream(testFile, FileMode.Open, FileAccess.Read); using var br = new BinaryReader(fs); var oodleCompression = br.ReadBytes(4); if (!oodleCompression.SequenceEqual(new byte[] { 0x4b, 0x41, 0x52, 0x4b })) { throw new NotImplementedException(); } var size = br.ReadUInt32(); var buffer = br.ReadBytes((int)fs.Length - 8); // oodle var outBuffer1 = new byte[size]; { var unpackedSize = Oodle.Decompress(buffer, outBuffer1); var outpath = Path.Combine(outdir, "oodle.txt"); File.WriteAllBytes(outpath, outBuffer1); } #if _WINDOWS // kraken var outBuffer2 = new byte[size]; { KrakenLib.Load(); long unpackedSize2 = KrakenLib.Decompress(buffer, outBuffer2); var outpath2 = Path.Combine(outdir, "kraken.txt"); File.WriteAllBytes(outpath2, outBuffer2); } Assert.IsTrue(Enumerable.SequenceEqual(outBuffer1, outBuffer2)); #endif }
public void Write(BinaryWriter bw) { bw.Write(LxrsFooter.s_magic); bw.Write(LxrsFooter.s_version); using var ms = new MemoryStream(); using var tempBw = new BinaryWriter(ms); foreach (var s in FileInfos) { tempBw.WriteCR2WString(s); } var inbuffer = ms.ToByteArray(); IEnumerable <byte> outBuffer = new List <byte>(); var r = Oodle.Compress(inbuffer, ref outBuffer, false); bw.Write(inbuffer.Length); //size bw.Write(outBuffer.Count()); //zsize bw.Write(FileInfos.Count()); //count bw.Write(outBuffer.ToArray()); }
/// <summary> /// Decompresses and copies a segment of zsize bytes from a stream to another stream /// </summary> /// <param name="stream"></param> /// <param name="outStream"></param> /// <param name="zSize"></param> /// <param name="size"></param> /// <exception cref="Exception"></exception> /// <exception cref="DecompressionException"></exception> public static async Task DecompressAndCopySegmentAsync(this Stream stream, Stream outStream, uint zSize, uint size) { if (zSize == size) { stream.CopyToWithLength(outStream, (int)zSize); } else { var oodleCompression = stream.ReadStruct <uint>(); if (oodleCompression == KARK) { var headerSize = stream.ReadStruct <uint>(); if (headerSize != size) { throw new Exception($"Buffer size doesn't match size in info table. {headerSize} vs {size}"); } var inputBuffer = new byte[(int)zSize - 8]; var read = stream.Read(inputBuffer); var outputBuffer = new byte[size]; var unpackedSize = await Task.Run(() => Oodle.Decompress(inputBuffer, outputBuffer)); if (unpackedSize != size) { throw new DecompressionException( $"Unpacked size {unpackedSize} doesn't match real size {size}."); } outStream.Write(outputBuffer); } else { stream.Seek(0, SeekOrigin.Begin); stream.CopyToWithLength(outStream, (int)zSize); } } }
public static void Main(string[] args) { if (!Oodle.Load()) { Console.Error.WriteLine("Failed to load any oodle libraries. Aborting"); return; } var rootCommand = new RootCommand { new ArchiveCommand(), new UnbundleCommand(), new UncookCommand(), new ImportCommand(), new PackCommand(), new ExportCommand(), new DumpCommand(), new CR2WCommand(), new HashCommand(), new OodleCommand(), new TweakCommand(), new SettingsCommand(), }; var parser = new CommandLineBuilder(rootCommand) .UseDefaults() .UseHost(GenericHost.CreateHostBuilder) .Build(); parser.Invoke(args); }
/// <summary> /// Kraken-compresses a buffer and writes it to a stream. /// </summary> /// <param name="bw"></param> /// <param name="inbuffer"></param> /// <returns></returns> public static (uint, uint) CompressAndWrite(this BinaryWriter bw, byte[] inbuffer) { var size = (uint)inbuffer.Length; if (size < 256) { var crc = Crc32Algorithm.Compute(inbuffer); bw.Write(inbuffer); return(size, crc); } else { IEnumerable <byte> outBuffer = new List <byte>(); var r = Oodle.Compress(inbuffer, ref outBuffer, true); var b = outBuffer.ToArray(); var crc = Crc32Algorithm.Compute(b); bw.Write(b); return((uint)r, crc); } }
public static byte[] ReadFile(byte[] rawData) { List <byte> combinedData = new List <byte>(); using (Stream stream = new MemoryStream(rawData)) { using (BinaryReader reader = new BinaryReader(stream)) { long[] identifierOffsets = Helpers.LocateRawDataIdentifier(reader); long x = identifierOffsets[1]; // skip to this Raw Data Block's offset reader.BaseStream.Seek(x, SeekOrigin.Begin); // Header Block HeaderBlock header = new HeaderBlock { Identifier = reader.ReadInt64(), Version = reader.ReadInt16(), Compression = (Compression)Enum.ToObject(typeof(Compression), reader.ReadByte()) }; // skip 4 bytes reader.BaseStream.Seek(4, SeekOrigin.Current); // finish reading the Header Block header.BlockCount = reader.ReadInt32(); // Block Indices BlockIndex[] indices = new BlockIndex[header.BlockCount]; for (int i = 0; i < header.BlockCount; i++) { indices[i] = new BlockIndex { UncompressedSize = reader.ReadInt32(), CompressedSize = reader.ReadInt32() }; } // Data Chunks DataChunk[] chunks = new DataChunk[header.BlockCount]; for (int i = 0; i < header.BlockCount; i++) { chunks[i] = new DataChunk { Checksum = reader.ReadInt32(), Data = reader.ReadBytes(indices[i].CompressedSize) }; // if the compressedSize and uncompressedSize do not match, decompress data // otherwise, the data was not ever compressed byte[] decompressed = indices[i].CompressedSize == indices[i].UncompressedSize ? chunks[i].Data : Oodle.Decompress(chunks[i].Data, indices[i].CompressedSize, indices[i].UncompressedSize); // add decompressed data to combinedData combinedData.AddRange(decompressed); } } } using (Stream stream = new MemoryStream(combinedData.ToArray())) { byte[] data = new byte[stream.Length]; stream.Read(data, 0, data.Length); return(data); } }
/// <summary> /// Reads a file extracted from the forge file and writes all its decompressed data chunks to a file /// </summary> /// <param name="fileName"></param> public static bool ReadFile(string fileName) { string name = Path.GetFileNameWithoutExtension(fileName); List <byte[]> combinedData = new List <byte[]>(); using (Stream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read)) { using (BinaryReader reader = new BinaryReader(stream)) { long[] identifierOffsets = Helpers.LocateRawDataIdentifier(reader); long x = identifierOffsets[1]; // skip to this Raw Data Block's offset reader.BaseStream.Seek(x, SeekOrigin.Begin); // Header Block HeaderBlock header = new HeaderBlock { Identifier = reader.ReadInt64(), Version = reader.ReadInt16(), Compression = (Compression)Enum.ToObject(typeof(Compression), reader.ReadByte()) }; // skip 4 bytes reader.BaseStream.Seek(4, SeekOrigin.Current); // finish reading the Header Block header.BlockCount = reader.ReadInt32(); // Block Indices BlockIndex[] indices = new BlockIndex[header.BlockCount]; for (int i = 0; i < header.BlockCount; i++) { indices[i] = new BlockIndex { UncompressedSize = reader.ReadInt32(), CompressedSize = reader.ReadInt32() }; } // Data Chunks DataChunk[] chunks = new DataChunk[header.BlockCount]; for (int i = 0; i < header.BlockCount; i++) { chunks[i] = new DataChunk { Checksum = reader.ReadInt32(), Data = reader.ReadBytes(indices[i].CompressedSize) }; // if the compressedSize and uncompressedSize do not match, decompress data // otherwise, the data was not ever compressed byte[] decompressed = indices[i].CompressedSize == indices[i].UncompressedSize ? chunks[i].Data : Oodle.Decompress(chunks[i].Data, indices[i].CompressedSize, indices[i].UncompressedSize); // add decompressed data to combinedData combinedData.Add(decompressed); } } } // write all decompressed data chunks (stored in combinedData) to a combined file Helpers.WriteToTempFile($"{fileName}-combined", combinedData.ToArray()); return(true); }
public void CompareMemoryNormal() { List <string> originals = new(); Dictionary <ulong, string> hashDictionary = new(); hashDictionary.EnsureCapacity(500_000); var runtimeAssemblies = Directory.GetFiles(RuntimeEnvironment.GetRuntimeDirectory(), "*.dll"); var paths = new List <string>(runtimeAssemblies); var resolver = new PathAssemblyResolver(paths); var mlc = new MetadataLoadContext(resolver); var before = GC.GetTotalMemory(true); Assembly assembly; using (mlc) { assembly = mlc.LoadFromAssemblyPath("WolvenKit.Common.dll"); using var stream = assembly.GetManifestResourceStream(s_used); // read KARK header var oodleCompression = stream.ReadStruct <uint>(); if (oodleCompression != Oodle.KARK) { throw new DecompressionException($"Incorrect hash file."); } var outputsize = stream.ReadStruct <uint>(); // read the rest of the stream var outputbuffer = new byte[outputsize]; var inbuffer = stream.ToByteArray(true); Oodle.Decompress(inbuffer, outputbuffer); using (var ms = new MemoryStream(outputbuffer)) using (var sr = new StreamReader(ms)) { string line; while ((line = sr.ReadLine()) != null) { var hash = FNV1A64HashAlgorithm.HashString(line); if (hashDictionary.ContainsKey(hash)) { continue; } hashDictionary.Add(hash, line); } } } var after = GC.GetTotalMemory(true); double diff = after - before; Console.WriteLine($"Memory: {diff.ToString()}"); // compare var failed = 0; foreach (var s in originals) { var hash = FNV1A64HashAlgorithm.HashString(s); var gottenString = hashDictionary[hash].ToString(); if (!gottenString.Equals(s)) { failed++; } } }
protected static void Setup(TestContext context) { #region cp77 game dir // Init Console.WriteLine("BaseTestClass.BaseTestInitialize()"); s_config = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .Build(); s_writeToFile = bool.Parse(s_config.GetSection(s_writeToFileSetting).Value); // overrides hardcoded appsettings.json var cp77Dir = Environment.GetEnvironmentVariable("CP77_DIR", EnvironmentVariableTarget.User); if (!string.IsNullOrEmpty(cp77Dir) && new DirectoryInfo(cp77Dir).Exists) { s_gameDirectoryPath = cp77Dir; } else { s_gameDirectoryPath = s_config.GetSection(s_gameDirectorySetting).Value; } if (string.IsNullOrEmpty(s_gameDirectoryPath)) { throw new ConfigurationErrorsException($"'{s_gameDirectorySetting}' is not configured"); } var gameDirectory = new DirectoryInfo(s_gameDirectoryPath); if (!gameDirectory.Exists) { throw new ConfigurationErrorsException($"'{s_gameDirectorySetting}' is not a valid directory"); } #endregion #region oodle var gameBinDir = new DirectoryInfo(Path.Combine(gameDirectory.FullName, "bin", "x64")); var oodleInfo = new FileInfo(Path.Combine(gameBinDir.FullName, "oo2ext_7_win64.dll")); if (!oodleInfo.Exists) { Assert.Fail("Could not find oo2ext_7_win64.dll."); } var ass = AppDomain.CurrentDomain.BaseDirectory; var appOodleFileName = Path.Combine(ass, "oo2ext_7_win64.dll"); if (!File.Exists(appOodleFileName)) { oodleInfo.CopyTo(appOodleFileName); } if (!Oodle.Load()) { Assert.Fail("Could not load oo2ext_7_win64.dll."); } #endregion //protobuf RuntimeTypeModel.Default[typeof(IGameArchive)].AddSubType(20, typeof(Archive)); // IoC ServiceLocator.Default.RegisterInstance <ILoggerService>(new CatelLoggerService(false)); ServiceLocator.Default.RegisterType <IHashService, HashService>(); ServiceLocator.Default.RegisterType <IProgressService <double>, ProgressService <double> >(); ServiceLocator.Default.RegisterType <Red4ParserService>(); ServiceLocator.Default.RegisterType <MeshTools>(); //RIG, Cp77FileService ServiceLocator.Default.RegisterType <IArchiveManager, ArchiveManager>(); ServiceLocator.Default.RegisterType <IModTools, ModTools>(); //Cp77FileService, ILoggerService, IProgress, IHashService, Mesh, Target Locator.CurrentMutable.RegisterConstant(new HashService(), typeof(IHashService)); var hashService = ServiceLocator.Default.ResolveType <IHashService>(); s_bm = ServiceLocator.Default.ResolveType <IArchiveManager>(); var archivedir = new DirectoryInfo(Path.Combine(gameDirectory.FullName, "archive", "pc", "content")); s_bm.LoadFromFolder(archivedir); s_groupedFiles = s_bm.GetGroupedFiles(); var keyes = s_groupedFiles.Keys.ToList(); var keystring = string.Join(',', keyes); //Console.WriteLine(keystring); }
public static int Compress(byte[] inputBuffer, ref IEnumerable <byte> outputBuffer, bool useRedHeader, CompressionLevel level = CompressionLevel.Normal, Compressor compressor = Compressor.Kraken) { if (inputBuffer == null) { throw new ArgumentNullException(nameof(inputBuffer)); } var inputCount = inputBuffer.Length; if (inputCount <= 0 || inputCount > inputBuffer.Length) { throw new ArgumentOutOfRangeException(nameof(inputCount)); } if (outputBuffer == null) { throw new ArgumentNullException(nameof(outputBuffer)); } var result = 0; var compressedBufferSizeNeeded = Oodle.GetCompressedBufferSizeNeeded(inputCount); var compressedBuffer = new byte[compressedBufferSizeNeeded]; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { result = CompressionSettings.Get().UseOodle ? OodleLib.OodleLZ_Compress(inputBuffer, compressedBuffer, compressor, level) : KrakenNative.Compress(inputBuffer, compressedBuffer, (int)level); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { result = KrakenNative.Compress(inputBuffer, compressedBuffer, (int)level); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { result = OozNative.Kraken_Compress(inputBuffer, compressedBuffer, (int)level); } else { throw new NotImplementedException(); } if (result == 0 || inputCount <= (result + 8)) { outputBuffer = inputBuffer; return(outputBuffer.Count()); } if (useRedHeader) { // write KARK header var writelist = new List <byte>() { 0x4B, 0x41, 0x52, 0x4B //KARK, TODO: make this dependent on the compression algo }; // write size writelist.AddRange(BitConverter.GetBytes(inputCount)); // write compressed data writelist.AddRange(compressedBuffer.Take(result)); outputBuffer = writelist; } else { outputBuffer = compressedBuffer.Take(result); } return(outputBuffer.Count()); }
private void bunifuFlatButton3_Click(object sender, EventArgs e) { if (!_pressed) { if (Vars.Early && !Vars.IsEarly()) { new Alert("This item is early access only for the time being!", 7); } else { _pressed = true; richTextBox2.Text = ""; richTextBox2.Text += $@"[LOG]: Starting...{Environment.NewLine}"; if (Utilities.Disposed) { Utilities.InitProvider(Vars.Aes()); } var jsonArray = JArray.Parse(Vars.Endpoint($"{Vars.BASEENDPOINT}/api/v1/ProjectPlatoV2/items?itemName={Vars.Item}"))[0]; if (Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + $"//TAMELYBACKUP//{Vars.Item}")) { richTextBox2.Text += @"ERROR: ITEM ALREADY CONVERTED!" + Environment.NewLine; } else { if ((ItemType)int.Parse(jsonArray["type"].ToString()) != ItemType.CharacterPart) //Swapper handles swapping in two ways, mesh and cp { foreach (var assets in jsonArray["assets"]) //All FModel paths have their own swaps { var parentasset = assets["parentAsset"]?.ToString(); Utilities.ExportCompressed(parentasset + ".uasset", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)); string searchtype = null; List <string> Searches = assets["searches"].Select(swap => swap["value"].ToString()).ToList(); List <string> Replaces = assets["replaces"].Select(swap => swap["value"].ToString()).ToList(); var i = 0; foreach (var swap in Searches) { searchtype = swap.Contains("hex=") ? "hex" : "string"; switch (searchtype) { case "string": Utilities.Convert(swap, Replaces[i], Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + assets["parentAsset"] + ".uasset", 0); break; case "hex": Utilities.ConvertHex(swap.Replace("hex=", ""), Replaces[i].Replace("hex=", ""), Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + assets["parentAsset"] + ".uasset", 0); break; default: Utilities.Convert(swap, Replaces[i], Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + assets["parentAsset"] + ".uasset", 0); break; } i++; } try { File.Move( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + assets["parentAsset"] + ".uasset", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/" + Path.GetFileName(assets["parentAsset"] + ".uasset")); } catch { Directory.CreateDirectory( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/"); File.Copy( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + assets["parentAsset"] + ".uasset", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/" + Path.GetFileName(assets["parentAsset"] + ".uasset")); } } Directory.CreateDirectory( Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + $"//TAMELYBACKUP//{Vars.Item}"); foreach (var file in Directory.EnumerateFiles( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "//CompressedOutput")) { File.Move(file, Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + $"//TAMELYBACKUP//{Vars.Item}//{Path.GetFileName(file)}"); } Directory.Delete( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/FortniteGame", true); foreach (var file in Directory.GetFiles( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/")) { Oodle.Compress(file, file + ".compressed"); } foreach (var assets in jsonArray["assets"]) { foreach (var file in Directory.EnumerateFiles( Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + $"//TAMELYBACKUP//{Vars.Item}//")) { if (file.Contains(Path.GetFileName(assets["parentAsset"]?.ToString()))) { var data = File.ReadAllBytes( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/" + Path.GetFileName(assets["parentAsset"]?.ToString()) + ".uasset.compressed"); var newfile = Path.GetFileName(file); var asset = newfile.Split(".uasset").First() + ".uasset"; newfile = newfile.Replace(asset + " ", ""); var offset = long.Parse(newfile.Split(" in ").First()); var pakfile = newfile.Split(" in ").Last(); pakfile = pakfile.Replace("10_", "100_"); Utilities.OutdatedResearcher(Vars.PakPath + "//" + pakfile, offset, data); richTextBox2.Text += $@"[LOG]: Added Asset to Fortnite in {pakfile}" + Environment.NewLine; } } } Directory.Delete( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/", true); new Alert("Successfully Completed!", 3, pictureBox2.ImageLocation); } else { Utilities.ExportCompressed(Vars.Defaultgame, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)); Utilities.ExportCompressed(Vars.Femaleasset, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)); Utilities.ExportCompressed(Vars.Maleasset, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)); Utilities.ConvertHex( Vars.Femalesearch, Vars.Femalereplace, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + Vars.Femaleasset, 0); Utilities.ConvertHex( Vars.Malesearch, Vars.Malereplace, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + Vars.Maleasset, 0); Utilities.Convert( Vars.Bodysearchsingle, "", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + Vars.Defaultgame, 0); Utilities.Convert( Vars.Headsearchsingle, "", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + Vars.Defaultgame, 0); Utilities.ConvertHex(Vars.LengthSearch, Vars.LengthReplace, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + Vars.Defaultgame, 0); Utilities.Convert( Vars.Bodysearch, jsonArray["bodyCp"]?.ToString(), Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + Vars.Defaultgame, 0); richTextBox2.Text += "[LOG]: Swapped Body Character Part" + Environment.NewLine; Utilities.Convert( Vars.Headsearch, jsonArray["headCp"]?.ToString(), Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + Vars.Defaultgame, 0); richTextBox2.Text += "[LOG]: Swapped Head Character Part" + Environment.NewLine; try { File.Move( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + Vars.Defaultgame, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/" + Path.GetFileName(Vars.Defaultgame)); File.Move( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + Vars.Femaleasset, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/" + Path.GetFileName(Vars.Femaleasset)); File.Move( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + Vars.Maleasset, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/" + Path.GetFileName(Vars.Maleasset)); } catch { Directory.CreateDirectory( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/"); File.Move( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + Vars.Defaultgame, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/" + Path.GetFileName(Vars.Defaultgame)); File.Move( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + Vars.Femaleasset, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/" + Path.GetFileName(Vars.Femaleasset)); File.Move( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + Vars.Maleasset, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/" + Path.GetFileName(Vars.Maleasset)); } Directory.CreateDirectory( Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + $"//TAMELYBACKUP//{Vars.Item}"); foreach (var file in Directory.EnumerateFiles( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "//CompressedOutput")) { File.Move(file, Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + $"//TAMELYBACKUP//{Vars.Item}//{Path.GetFileName(file)}"); } Directory.Delete( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/FortniteGame", true); foreach (var file in Directory.GetFiles( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/")) { Oodle.Compress(file, file + ".compressed"); } foreach (var file in Directory.EnumerateFiles( Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + $"//TAMELYBACKUP//{Vars.Item}//")) { if (file.Contains(Path.GetFileName(Vars.Defaultgame) ?? string.Empty)) { var data = File.ReadAllBytes( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/DefaultGameDataCosmetics.uasset.compressed"); var newfile = Path.GetFileName(file); var asset = newfile.Split(".uasset").First() + ".uasset"; newfile = newfile.Replace(asset + " ", ""); var offset = long.Parse(newfile.Split(" in ").First()); var pakfile = newfile.Split(" in ").Last(); pakfile = pakfile.Replace("10_", "100_"); Utilities.OutdatedResearcher(Vars.PakPath + "//" + pakfile, offset, data); richTextBox2.Text += @"[LOG]: Added Asset to Fortnite in {pakfile}" + Environment.NewLine; } if (file.Contains(Path.GetFileName(Vars.Maleasset) ?? string.Empty)) { var data = File.ReadAllBytes( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/CP_Athena_Body_M_RebirthSoldier.uasset.compressed"); var newfile = Path.GetFileName(file); var asset = newfile.Split(".uasset").First() + ".uasset"; newfile = newfile.Replace(asset + " ", ""); var offset = long.Parse(newfile.Split(" in ").First()); var pakfile = newfile.Split(" in ").Last(); pakfile = pakfile.Replace("10_", "100_"); Utilities.OutdatedResearcher(Vars.PakPath + "//" + pakfile, offset, data); richTextBox2.Text += @"[LOG]: Made Male Invalid" + Environment.NewLine; } if (file.Contains(Path.GetFileName(Vars.Femaleasset) ?? string.Empty)) { var data = File.ReadAllBytes( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/CP_Body_Commando_F_RebirthDefaultA.uasset.compressed"); var newfile = Path.GetFileName(file); var asset = newfile.Split(".uasset").First() + ".uasset"; newfile = newfile.Replace(asset + " ", ""); var offset = long.Parse(newfile.Split(" in ").First()); var pakfile = newfile.Split(" in ").Last(); pakfile = pakfile.Replace("10_", "100_"); Utilities.OutdatedResearcher(Vars.PakPath + "//" + pakfile, offset, data); richTextBox2.Text += @"[LOG]: Made Female Invalid" + Environment.NewLine; } } Directory.Delete( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/", true); new Alert("Successfully Completed!", 3, pictureBox2.ImageLocation); } } } } _pressed = false; }
private void bunifuFlatButton3_Click(object sender, EventArgs e) { if (!_pressed) { if (Vars.Early && !Vars.IsEarly()) { new Alert("This item is early access only for the time being!", 7); } else { _pressed = true; richTextBox2.Text = ""; richTextBox2.Text += $@"[LOG]: Starting...{Environment.NewLine}"; if (Utilities.Disposed) { Utilities.InitProvider(Vars.Aes()); } if (Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + $"//TAMELYBACKUP//{Vars.Item}")) { richTextBox2.Text += @"ERROR: ITEM ALREADY CONVERTED!" + Environment.NewLine; } else { foreach (var f1le in Directory.EnumerateFiles(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "//PlatoPlugins")) { JObject cosmetics = JObject.Parse(File.ReadAllText(f1le)); if (cosmetics["name"]?.ToString() == Vars.Item) //Checks if it's the right cosmetic { if (cosmetics["type"]?.ToString() == "mesh") //Swapper handles swapping in two ways, mesh and cp { foreach (var assets in cosmetics["assets"]) //All FModel paths have their own swaps { var parentasset = assets["parentasset"]?.ToString(); Utilities.ExportCompressed(parentasset + ".uasset", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)); string searchtype = null; foreach (var swap in assets["swaps"]) { try { searchtype = swap["searchtype"]?.ToString(); } catch { } switch (searchtype) { case "string": Utilities.Convert(swap["search"]?.ToString(), swap["replace"]?.ToString(), Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + assets["parentasset"] + ".uasset", 0); richTextBox2.Text += $@"[LOG]: Swapped {swap["type"]}" + Environment.NewLine; break; case "hex": Utilities.ConvertHex(swap["search"]?.ToString(), swap["replace"]?.ToString(), Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + assets["parentasset"] + ".uasset", 0); richTextBox2.Text += $@"[LOG]: Swapped {swap["type"]}" + Environment.NewLine; break; default: if (swap["search"].Contains("hex=")) { Utilities.ConvertHex(swap["search"]?.ToString().Replace("hex=", ""), swap["replace"]?.ToString().Replace("hex=", ""), Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + assets["parentasset"] + ".uasset", 0); } else { Utilities.Convert(swap["search"]?.ToString(), swap["replace"]?.ToString(), Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + assets["parentasset"] + ".uasset", 0); } break; } } try { File.Move( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + assets["parentasset"] + ".uasset", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/" + Path.GetFileName(assets["parentasset"] + ".uasset")); } catch { Directory.CreateDirectory( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/"); File.Copy( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + assets["parentasset"] + ".uasset", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/" + Path.GetFileName(assets["parentasset"] + ".uasset")); } } Directory.CreateDirectory( Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + $"//TAMELYBACKUP//{cosmetics["name"]}"); foreach (var file in Directory.EnumerateFiles( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "//CompressedOutput")) { File.Move(file, Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + $"//TAMELYBACKUP//{cosmetics["name"]}//{Path.GetFileName(file)}"); } Directory.Delete( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/FortniteGame", true); foreach (var file in Directory.GetFiles( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/")) { Oodle.Compress(file, file + ".compressed"); } foreach (var assets in cosmetics["assets"]) { foreach (var file in Directory.EnumerateFiles( Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + $"//TAMELYBACKUP//{cosmetics["name"]}//")) { if (file.Contains(Path.GetFileName(assets["parentasset"]?.ToString()))) { var data = File.ReadAllBytes( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/" + Path.GetFileName(assets["parentasset"]?.ToString()) + ".uasset.compressed"); var newfile = Path.GetFileName(file); var asset = newfile.Split(".uasset").First() + ".uasset"; newfile = newfile.Replace(asset + " ", ""); var offset = long.Parse(newfile.Split(" in ").First()); var pakfile = newfile.Split(" in ").Last(); pakfile = pakfile.Replace("10_", "100_"); Utilities.OutdatedResearcher(Vars.PakPath + "//" + pakfile, offset, data); richTextBox2.Text += @"[LOG]: Added Asset to Fortnite" + Environment.NewLine; } } } Directory.Delete( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/", true); new Alert("Successfully Completed!", 3, pictureBox2.ImageLocation); } else { Utilities.ExportCompressed(Vars.Defaultgame, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)); Utilities.ExportCompressed(Vars.Femaleasset, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)); Utilities.ExportCompressed(Vars.Maleasset, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)); Utilities.ConvertHex( Vars.Femalesearch, Vars.Femalereplace, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + Vars.Femaleasset, 0); Utilities.ConvertHex( Vars.Malesearch, Vars.Malereplace, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + Vars.Maleasset, 0); Utilities.Convert( Vars.Bodysearchsingle, "", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + Vars.Defaultgame, 0); Utilities.Convert( Vars.Headsearchsingle, "", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + Vars.Defaultgame, 0); Utilities.ConvertHex(Vars.LengthSearch, Vars.LengthReplace, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + Vars.Defaultgame, 0); Utilities.Convert( Vars.Bodysearch, cosmetics["bodycp"]?.ToString(), Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + Vars.Defaultgame, 0); richTextBox2.Text += "[LOG]: Swapped Body Character Part" + Environment.NewLine; Utilities.Convert( Vars.Headsearch, cosmetics["headcp"]?.ToString(), Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + Vars.Defaultgame, 0); richTextBox2.Text += "[LOG]: Swapped Head Character Part" + Environment.NewLine; try { File.Move( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + Vars.Defaultgame, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/" + Path.GetFileName(Vars.Defaultgame)); File.Move( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + Vars.Femaleasset, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/" + Path.GetFileName(Vars.Femaleasset)); File.Move( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + Vars.Maleasset, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/" + Path.GetFileName(Vars.Maleasset)); } catch { Directory.CreateDirectory( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/"); File.Move( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + Vars.Defaultgame, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/" + Path.GetFileName(Vars.Defaultgame)); File.Move( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + Vars.Femaleasset, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/" + Path.GetFileName(Vars.Femaleasset)); File.Move( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + Vars.Maleasset, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/" + Path.GetFileName(Vars.Maleasset)); } Directory.CreateDirectory( Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + $"//TAMELYBACKUP//{cosmetics["name"]}"); foreach (var file in Directory.EnumerateFiles( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "//CompressedOutput")) { File.Move(file, Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + $"//TAMELYBACKUP//{cosmetics["name"]}//{Path.GetFileName(file)}"); } Directory.Delete( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/FortniteGame", true); foreach (var file in Directory.GetFiles( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/")) { Oodle.Compress(file, file + ".compressed"); } foreach (var file in Directory.EnumerateFiles( Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + $"//TAMELYBACKUP//{cosmetics["name"]}//")) { if (file.Contains(Path.GetFileName(Vars.Defaultgame) ?? string.Empty)) { var data = File.ReadAllBytes( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/DefaultGameDataCosmetics.uasset.compressed"); var newfile = Path.GetFileName(file); var asset = newfile.Split(".uasset").First() + ".uasset"; newfile = newfile.Replace(asset + " ", ""); var offset = long.Parse(newfile.Split(" in ").First()); var pakfile = newfile.Split(" in ").Last(); pakfile = pakfile.Replace("10_", "100_"); Utilities.OutdatedResearcher(Vars.PakPath + "//" + pakfile, offset, data); richTextBox2.Text += @"[LOG]: Added Asset to Fortnite" + Environment.NewLine; } if (file.Contains(Path.GetFileName(Vars.Maleasset) ?? string.Empty)) { var data = File.ReadAllBytes( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/CP_Athena_Body_M_RebirthSoldier.uasset.compressed"); var newfile = Path.GetFileName(file); var asset = newfile.Split(".uasset").First() + ".uasset"; newfile = newfile.Replace(asset + " ", ""); var offset = long.Parse(newfile.Split(" in ").First()); var pakfile = newfile.Split(" in ").Last(); pakfile = pakfile.Replace("10_", "100_"); Utilities.OutdatedResearcher(Vars.PakPath + "//" + pakfile, offset, data); richTextBox2.Text += @"[LOG]: Made Male Invalid" + Environment.NewLine; } if (file.Contains(Path.GetFileName(Vars.Femaleasset) ?? string.Empty)) { var data = File.ReadAllBytes( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/CP_Body_Commando_F_RebirthDefaultA.uasset.compressed"); var newfile = Path.GetFileName(file); var asset = newfile.Split(".uasset").First() + ".uasset"; newfile = newfile.Replace(asset + " ", ""); var offset = long.Parse(newfile.Split(" in ").First()); var pakfile = newfile.Split(" in ").Last(); pakfile = pakfile.Replace("10_", "100_"); Utilities.OutdatedResearcher(Vars.PakPath + "//" + pakfile, offset, data); richTextBox2.Text += @"[LOG]: Made Female Invalid" + Environment.NewLine; } } Directory.Delete( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/Temp/", true); new Alert("Successfully Completed!", 3, pictureBox2.ImageLocation); } } } } } } _pressed = false; }
public void Decompress(Oodle oodle, byte[] decompressedFile) { Chunk.Decompress(oodle, decompressedFile, DecompressOffset); }
public static TypeMappings Parse(FArchive Ar) { var magic = Ar.Read <ushort>(); if (magic != FileMagic) { throw new ParserException(".usmap file has an invalid magic constant"); } var version = Ar.Read <Version>(); if (version < 0 || version > Version.LATEST) { throw new ParserException($".usmap has an invalid version {(byte) version}"); } var compression = Ar.Read <ECompressionMethod>(); var compSize = Ar.Read <uint>(); var decompSize = Ar.Read <uint>(); var data = new byte[decompSize]; switch (compression) { case ECompressionMethod.None: if (compSize != decompSize) { throw new ParserException("No compression: Compression size must be equal to decompression size"); } Ar.Read(data, 0, (int)compSize); break; case ECompressionMethod.Oodle: Oodle.Decompress(Ar.ReadBytes((int)compSize), 0, (int)compSize, data, 0, (int)decompSize); break; case ECompressionMethod.Brotli: throw new NotImplementedException(); default: throw new ParserException($"Invalid compression method {compression}"); } Ar = new FByteArchive(Ar.Name, data); var nameSize = Ar.Read <uint>(); var nameLut = new List <String>((int)nameSize); for (int i = 0; i < nameSize; i++) { var nameLength = Ar.Read <byte>(); nameLut.Add(ReadStringUnsafe(Ar, nameLength)); } var enumCount = Ar.Read <uint>(); var enums = new Dictionary <string, Dictionary <int, string> >((int)enumCount); for (int i = 0; i < enumCount; i++) { var enumName = Ar.ReadName(nameLut) !; var enumNamesSize = Ar.Read <byte>(); var enumNames = new Dictionary <int, string>(enumNamesSize); for (int j = 0; j < enumNamesSize; j++) { var value = Ar.ReadName(nameLut) !; enumNames[j] = value; } enums.Add(enumName, enumNames); } var structCount = Ar.Read <uint>(); var structs = new Dictionary <string, Struct>(); var mappings = new TypeMappings(structs, enums); for (int i = 0; i < structCount; i++) { var s = ParseStruct(mappings, Ar, nameLut); structs[s.Name] = s; } return(mappings); }