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); }
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); }
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)); }
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)); }
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()); }
public static unsafe string DecryptAvis(byte[] bufferEncrypted) { byte[] bufferDecrypted = DecryptAvisBuffer(bufferEncrypted); return(AGSStringUtils.ConvertCString(bufferDecrypted)); }
private void ReadStringsSection(BinaryReader reader, int size) { _stringsBlob = reader.ReadBytes(size); StringsStored = AGSStringUtils.ConvertNullTerminatedSequence(_stringsBlob); }