Exemplo n.º 1
0
        public void WriteSourceBlock(BinaryWriter writer, int roomVersion)
        {
            byte[] buffer = AGSStringUtils.GetASCIIBytes(SourceCode);

            //NOTE(adm244): not a bug, it encrypts by decrypting
            buffer = AGSEncryption.DecryptAvisBuffer(buffer);

            writer.Write((Int32)buffer.Length);
            writer.Write((byte[])buffer);
        }
Exemplo n.º 2
0
        public void ReadSourceBlock(BinaryReader reader, int roomVersion)
        {
            int length = reader.ReadInt32();

            byte[] buffer = reader.ReadBytes(length);

            //NOTE(adm244): not a bug, it decrypts by encrypting
            buffer     = AGSEncryption.EncryptAvisBuffer(buffer);
            SourceCode = AGSStringUtils.ConvertToString(buffer);
        }
Exemplo n.º 3
0
        public static string DecryptSalt(string textEncrypted, int salt)
        {
            byte[] bufferDecrypted = new byte[textEncrypted.Length];

            for (int i = 0; i < bufferDecrypted.Length; ++i)
            {
                //NOTE(adm244): convert char to byte before subtracting, so we underflow properly
                bufferDecrypted[i] = (byte)((byte)textEncrypted[i] - salt);
            }

            return(AGSStringUtils.ConvertCString(bufferDecrypted));
        }
Exemplo n.º 4
0
        public static string ReadFixedCString(this BinaryReader reader, int length)
        {
            if (length < 1)
            {
                return(string.Empty);
            }

            if (reader.EOF())
            {
                return(string.Empty);
            }

            char[] buffer = reader.ReadChars(length);

            //NOTE(adm244): the reason why we use ConvertCString here is that we expect that
            // the string can be null-terminated (when it's actual length is less the the length specified)
            // Should we consider using a different method for this case??
            return(AGSStringUtils.ConvertCString(buffer));
        }
Exemplo n.º 5
0
        private ReferencedString[] GetReferencedStrings(byte[] stringsBlob)
        {
            var strings = new List <ReferencedString>();

            for (int i = 0; i < Fixups.Length; ++i)
            {
                if (Fixups[i].Type == Fixup.FixupType.String)
                {
                    Debug.Assert(Fixups[i].Offset > 0);
                    Debug.Assert(Fixups[i].Offset < Code.Length);

                    int    index            = Code[Fixups[i].Offset];
                    string stringReferenced = AGSStringUtils.ConvertCString(stringsBlob, index);

                    strings.Add(new ReferencedString()
                    {
                        Text   = stringReferenced,
                        Offset = Fixups[i].Offset
                    });
                }
            }

            return(strings.ToArray());
        }
Exemplo n.º 6
0
 public static unsafe string DecryptAvis(byte[] bufferEncrypted)
 {
     byte[] bufferDecrypted = DecryptAvisBuffer(bufferEncrypted);
     return(AGSStringUtils.ConvertCString(bufferDecrypted));
 }
Exemplo n.º 7
0
 private void ReadStringsSection(BinaryReader reader, int size)
 {
     _stringsBlob  = reader.ReadBytes(size);
     StringsStored = AGSStringUtils.ConvertNullTerminatedSequence(_stringsBlob);
 }