From 8b628fd6ced95c66884ed1b3f6e7d23e324ff024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B2=81=E6=A0=91=E4=BA=BA?= Date: Sat, 14 Sep 2024 20:54:10 +0100 Subject: [PATCH] refactor: slice NCM parsing --- src/decrypt-worker/crypto/ncm/ncm_pc.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/decrypt-worker/crypto/ncm/ncm_pc.ts b/src/decrypt-worker/crypto/ncm/ncm_pc.ts index 5c847ec..a68dc1b 100644 --- a/src/decrypt-worker/crypto/ncm/ncm_pc.ts +++ b/src/decrypt-worker/crypto/ncm/ncm_pc.ts @@ -8,8 +8,13 @@ export class NCMCrypto implements CryptoBase { ncm = new NCMFile(); async checkBySignature(buffer: ArrayBuffer) { + const data = new Uint8Array(buffer); + let len = 1024; try { - this.ncm.open(new Uint8Array(buffer)); + while (len !== 0) { + console.debug('NCM/open: read %d bytes', len); + len = this.ncm.open(data.subarray(0, len)); + } } catch (error) { return false; }