Skip to content

Commit 323c76f

Browse files
Clean up debug logging, bump version to 2.4.0
Remove trophy_crimsonbalrog debug logging and Base64 diagnostic output. Keep bounds checking in GetBlock/ReadBlockRefList, Base64URL handling, Xor/Aes flag reorder, and FileStream changes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c85fd3e commit 323c76f

3 files changed

Lines changed: 2 additions & 27 deletions

File tree

Maple2.File.IO/Crypto/CryptoManager.cs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,22 +67,7 @@ private static byte[] Decrypt(PackVersion version, uint size, uint sizeCompresse
6767

6868
// Decode the base64 encoded string (handle both standard and URL-safe Base64)
6969
string b64 = Encoding.UTF8.GetString(src).Replace('-', '+').Replace('_', '/');
70-
try {
71-
src = Convert.FromBase64String(b64);
72-
} catch (FormatException) {
73-
const string valid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= \t\r\n";
74-
for (int i = 0; i < b64.Length; i++) {
75-
if (valid.IndexOf(b64[i]) < 0) {
76-
Console.Error.WriteLine($"[Base64 FAIL] Invalid char at {i}/{b64.Length}: 0x{(int)b64[i]:X4} '{b64[i]}'");
77-
Console.Error.WriteLine($"[Base64 FAIL] Context: ...{b64[Math.Max(0,i-8)..Math.Min(b64.Length,i+8)]}...");
78-
break;
79-
}
80-
}
81-
if (b64.Length % 4 != 0)
82-
Console.Error.WriteLine($"[Base64 FAIL] Length {b64.Length} not multiple of 4 (remainder {b64.Length % 4})");
83-
Console.Error.WriteLine($"[Base64 FAIL] flag=0x{(uint)flag:X8} size={size} sizeCompressed={sizeCompressed} srcLen={b64.Length}");
84-
throw;
85-
}
70+
src = Convert.FromBase64String(b64);
8671

8772
// Decrypt the AES encrypted block
8873
var pCipher = new AESCipher(key, iv);

Maple2.File.IO/Nif/NifDocument.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,6 @@ private void ParseImplementation() {
154154

155155
bool isLittleEndian = fileData[index] != 0;
156156

157-
if (RelPath.Contains("trophy_crimsonbalrog")) {
158-
using var md5 = System.Security.Cryptography.MD5.Create();
159-
byte[] hash = md5.ComputeHash(fileData);
160-
string dbg = $"[NIF DEBUG] {RelPath}: dataLen={fileData.Length} md5={Convert.ToHexString(hash)} " +
161-
$"headerLen={index - 4} endianByte=0x{fileData[index]:X2} isLittleEndian={isLittleEndian} " +
162-
$"swap={isLittleEndian != BitConverter.IsLittleEndian} BitConverter.IsLittleEndian={BitConverter.IsLittleEndian}\n" +
163-
$"[NIF DEBUG] bytes around endian flag [{index-2}..{index+3}]: {Convert.ToHexString(fileData, index - 2, 5)}\n";
164-
System.IO.File.AppendAllText(Path.Combine(Path.GetTempPath(), "nif_debug.log"), dbg);
165-
}
166-
167157
MemoryStream stream = new MemoryStream(fileData);
168158
Reader = new EndianReader(stream, isLittleEndian != BitConverter.IsLittleEndian);
169159

Maple2.File.Parser/Maple2.File.Parser.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<PackageTags>MapleStory2, File, Parser, m2d, xml</PackageTags>
1414
<!-- Use following lines to write the generated files to disk. -->
1515
<EmitCompilerGeneratedFiles Condition=" '$(Configuration)' == 'Debug' ">true</EmitCompilerGeneratedFiles>
16-
<PackageVersion>2.3.10</PackageVersion>
16+
<PackageVersion>2.4.0</PackageVersion>
1717
<TargetFramework>net8.0</TargetFramework>
1818
<PackageReadmeFile>README.md</PackageReadmeFile>
1919
<ImplicitUsings>enable</ImplicitUsings>

0 commit comments

Comments
 (0)