Esempio n. 1
0
        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];
            KrakenLib.Load();
            var r2       = KrakenLib.Compress(inbuffer, outBuffer2, (int)level);
            var outpath2 = Path.Combine(outdir, $"{(int)level}_kraken.kark");
            var final2   = outBuffer2.Take(r2).ToArray();
            File.WriteAllBytes(outpath2, final2);
#endif

            var compareFile  = Path.GetFullPath(Path.Combine("Resources", $"{level}_oodle.kark"));
            var compareBytes = File.ReadAllBytes(compareFile);
            Assert.IsTrue(Enumerable.SequenceEqual(final2, compareBytes.Skip(8)));
        }
Esempio n. 2
0
    public const uint KARK = 1263681867; // 0x4b, 0x41, 0x52, 0x4b

    public static bool Load()
    {
        // try get oodle dll from game
        if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
        {
            var result = false;
            if (TryCopyOodleLib())
            {
                result = OodleLib.Load(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "oo2ext_7_win64.dll"));
                if (result)
                {
                    CompressionSettings.Get().CompressionLevel = CompressionLevel.Optimal2;
                    CompressionSettings.Get().UseOodle         = true;
                    return(true);
                }
            }

            // try load Kraken
            result = KrakenLib.Load();
            if (result)
            {
                return(true);
            }

            Log.Error("Could not automatically find oo2ext_7_win64.dll. " +
                      "Please manually copy and paste the DLL found in <gamedir>\\Cyberpunk 2077\\bin\\x64\\oo2ext_7_win64.dll into this folder: " +
                      $"{AppDomain.CurrentDomain.BaseDirectory}.");
            return(false);
        }

        if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
        {
            return(KrakenLib.Load());
        }

        if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
        {
        }
        throw new NotImplementedException();
    }
Esempio n. 3
0
        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
        }