From 2b52a367f20869ed12545a3bd66b48bb42c07605 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B2=81=E6=A0=91=E4=BA=BA?= Date: Fri, 13 Sep 2024 00:00:35 +0100 Subject: [PATCH] fix #26: correctly calculate cover frame size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 鲁树人 --- src/ncmcrypt.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ncmcrypt.cpp b/src/ncmcrypt.cpp index 6524bd1..e2c7c73 100644 --- a/src/ncmcrypt.cpp +++ b/src/ncmcrypt.cpp @@ -391,12 +391,14 @@ NeteaseCrypt::NeteaseCrypt(std::string const &path) mMetaData = new NeteaseMusicMetadata(cJSON_Parse(modifyDecryptData.c_str())); } - // skip crc32 & unuse charset - if (!mFile.seekg(9, mFile.cur)) + // skip crc32 & image version + if (!mFile.seekg(5, mFile.cur)) { throw std::invalid_argument("can't seek file"); } + uint32_t cover_frame_len{0}; + read(reinterpret_cast(&cover_frame_len), 4); read(reinterpret_cast(&n), sizeof(n)); if (n > 0) @@ -410,4 +412,5 @@ NeteaseCrypt::NeteaseCrypt(std::string const &path) { std::cout << "[Warn] " << path << " missing album can't fix album image!" << std::endl; } + mFile.seekg(cover_frame_len - n, mFile.cur); }