Esempio n. 1
0
        Stream DecryptDat(ArcFile arc, Entry entry)
        {
            byte[] input       = arc.File.View.ReadBytes(entry.Offset, entry.Size);
            int    text_offset = 3600;
            int    text_length = (int)(entry.Size - text_offset - 2);

            m_rng.SRand((sbyte)input[input.Length - 1]);
            for (int i = 0; i < text_length; i += 2)
            {
                input[text_offset + i] ^= (byte)Key[m_rng.Rand() % Key.Length];
            }
            return(new MemoryStream(input));
        }
Esempio n. 2
0
        byte[] DecryptIndex(ArcView idx)
        {
            int idx_size = (int)idx.MaxOffset - 4;

            byte[] output = new byte[idx_size];
            using (var view = idx.CreateViewAccessor(0, (uint)idx.MaxOffset))
                unsafe
                {
                    var rng = new CRuntimeRandomGenerator();
                    rng.SRand(view.ReadInt32(idx_size));
                    byte *ptr = view.GetPointer(0);
                    try
                    {
                        for (int i = 0; i < idx_size; ++i)
                        {
                            output[i] = (byte)(ptr[i] ^ IndexKey[rng.Rand() % IndexKey.Length]);
                        }
                        return(output);
                    }
                    finally
                    {
                        view.SafeMemoryMappedViewHandle.ReleasePointer();
                    }
                }
        }