Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
- [Core] fix bug with certain files [GI]
Browse files Browse the repository at this point in the history
  • Loading branch information
Razmoth committed Feb 3, 2024
1 parent c5870c9 commit 50e0af0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions AssetStudio/MhyFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,23 +193,23 @@ private void ReadFiles(Stream blocksStream, string path)

private void DescrambleChunk(Span<byte> input)
{
byte[] vector = new byte[0x10];
byte[] vector = new byte[input.Length];
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 0x10; j++)
for (int j = 0; j < input.Length; j++)
{
int k = mhy.MhyShiftRow[(2 - i) * 0x10 + j];
int idx = j % 8;
vector[j] = (byte)(mhy.MhyKey[idx] ^ mhy.SBox[(j % 4 * 0x100) | GF256Mul(mhy.MhyMul[idx], input[k])]);
vector[j] = (byte)(mhy.MhyKey[idx] ^ mhy.SBox[(j % 4 * 0x100) | GF256Mul(mhy.MhyMul[idx], input[k % input.Length])]);
}
vector.CopyTo(input);
vector.AsSpan(0, input.Length).CopyTo(input);
}
}
private void Descramble(Span<byte> input, int blockSize, int entrySize)
{
var roundedEntrySize = (entrySize + 0xF) / 0x10 * 0x10;
for (int i = 0; i < roundedEntrySize; i += 0x10)
DescrambleChunk(input.Slice(i + 4, 0x10));
DescrambleChunk(input.Slice(i + 4, Math.Min(input.Length - 4, 0x10)));

for (int i = 0; i < 4; i++)
input[i] ^= input[i + 4];
Expand Down

0 comments on commit 50e0af0

Please sign in to comment.