private void FillBuffer() { m_current_block_length = m_view.Read(m_current_block_position, m_current_block, 0, (uint)BlockLength); for (int offset = 0; offset < m_current_block_length; offset += 0x10) { m_dec.DecryptBlock(m_current_block_position + offset, m_current_block, offset); } }
private static int ReadEncrypted(ArcView.Frame view, IMalieDecryptor dec, long offset, byte[] buffer, int index, int length) { int offset_pad = (int)offset & 0xF; int aligned_len = (offset_pad + length + 0xF) & ~0xF; byte[] aligned_buf; int block = 0; if (aligned_len == length) { aligned_buf = buffer; block = index; } else { aligned_buf = new byte[aligned_len]; } int read = view.Read(offset - offset_pad, aligned_buf, block, (uint)aligned_len); if (read < offset_pad) { return(0); } for (int block_count = aligned_len / 0x10; block_count > 0; --block_count) { dec.DecryptBlock(offset, aligned_buf, block); block += 0x10; offset += 0x10; } if (aligned_buf != buffer) { Buffer.BlockCopy(aligned_buf, offset_pad, buffer, index, length); } return(Math.Min(length, read - offset_pad)); }