From 5a7083ddba2e2a17170339a03c663c93ef912ef6 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sun, 25 May 2025 22:26:16 +0200 Subject: [PATCH] snd_DvdSoundArchive OK --- config/SOUE01/splits.txt | 1 + config/SOUE01/symbols.txt | 14 +++++++------- configure.py | 2 +- src/nw4r/snd/snd_DvdSoundArchive.cpp | 20 +++++++++----------- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 5bbbc519..61a4d279 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2939,6 +2939,7 @@ nw4r/snd/snd_DisposeCallbackManager.cpp: nw4r/snd/snd_DvdSoundArchive.cpp: .text start:0x8046BB60 end:0x8046C1C8 align:16 + .data start:0x8056DBE8 end:0x8056DC70 nw4r/snd/snd_EnvGenerator.cpp: .text start:0x8046C1D0 end:0x8046C5A0 align:16 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index dad564e0..a23267f9 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -25209,11 +25209,11 @@ LoadHeader__Q34nw4r3snd15DvdSoundArchiveFPvUl = .text:0x8046BF60; // type:functi LoadLabelStringData__Q34nw4r3snd15DvdSoundArchiveFPvUl = .text:0x8046BFF0; // type:function size:0x88 Read__Q44nw4r3snd15DvdSoundArchive13DvdFileStreamFPvUl = .text:0x8046C080; // type:function size:0x2C Seek__Q44nw4r3snd15DvdSoundArchive13DvdFileStreamFlUl = .text:0x8046C0B0; // type:function size:0x80 -GetSize__Q44nw4r3snd15DvdSoundArchive13DvdFileStreamCFv = .text:0x8046C130; // type:function size:0x8 -Tell__Q44nw4r3snd15DvdSoundArchive13DvdFileStreamCFv = .text:0x8046C140; // type:function size:0x10 -detail_GetWaveDataFileAddress__Q34nw4r3snd15DvdSoundArchiveCFUl = .text:0x8046C150; // type:function size:0x8 -detail_GetFileAddress__Q34nw4r3snd15DvdSoundArchiveCFUl = .text:0x8046C160; // type:function size:0x8 -__dt__Q44nw4r3snd15DvdSoundArchive13DvdFileStreamFv = .text:0x8046C170; // type:function size:0x58 +GetSize__Q44nw4r3snd15DvdSoundArchive13DvdFileStreamCFv = .text:0x8046C130; // type:function size:0x8 scope:weak +Tell__Q44nw4r3snd15DvdSoundArchive13DvdFileStreamCFv = .text:0x8046C140; // type:function size:0x10 scope:weak +detail_GetWaveDataFileAddress__Q34nw4r3snd15DvdSoundArchiveCFUl = .text:0x8046C150; // type:function size:0x8 scope:weak +detail_GetFileAddress__Q34nw4r3snd15DvdSoundArchiveCFUl = .text:0x8046C160; // type:function size:0x8 scope:weak +__dt__Q44nw4r3snd15DvdSoundArchive13DvdFileStreamFv = .text:0x8046C170; // type:function size:0x58 scope:weak __ct__Q44nw4r3snd6detail12EnvGeneratorFv = .text:0x8046C1D0; // type:function size:0x44 Init__Q44nw4r3snd6detail12EnvGeneratorFf = .text:0x8046C220; // type:function size:0x40 Reset__Q44nw4r3snd6detail12EnvGeneratorFf = .text:0x8046C260; // type:function size:0x18 @@ -38591,8 +38591,8 @@ __vt__Q44nw4r3snd6detail19BiquadFilterBpf1024 = .data:0x8056DBA8; // type:object __vt__Q44nw4r3snd6detail18BiquadFilterBpf512 = .data:0x8056DBB8; // type:object size:0x10 __vt__Q44nw4r3snd6detail15BiquadFilterHpf = .data:0x8056DBC8; // type:object size:0x10 __vt__Q44nw4r3snd6detail15BiquadFilterLpf = .data:0x8056DBD8; // type:object size:0x10 -lbl_8056DBE8 = .data:0x8056DBE8; // type:object size:0x68 -lbl_8056DC50 = .data:0x8056DC50; // type:object size:0x20 +__vt__Q44nw4r3snd15DvdSoundArchive13DvdFileStream = .data:0x8056DBE8; // type:object size:0x64 +__vt__Q34nw4r3snd15DvdSoundArchive = .data:0x8056DC50; // type:object size:0x20 lbl_8056DC70 = .data:0x8056DC70; // type:object size:0x28 lbl_8056DC98 = .data:0x8056DC98; // type:object size:0x60 lbl_8056DCF8 = .data:0x8056DCF8; // type:object size:0x20 diff --git a/configure.py b/configure.py index 571e3191..2f9bb007 100644 --- a/configure.py +++ b/configure.py @@ -1025,7 +1025,7 @@ config.libs = [ Object(NonMatching, "nw4r/snd/snd_Channel.cpp"), Object(Matching, "nw4r/snd/snd_DisposeCallbackManager.cpp"), Object(NonMatching, "nw4r/snd/snd_debug.cpp"), - Object(NonMatching, "nw4r/snd/snd_DvdSoundArchive.cpp"), + Object(Matching, "nw4r/snd/snd_DvdSoundArchive.cpp"), Object(NonMatching, "nw4r/snd/snd_EnvGenerator.cpp"), Object(NonMatching, "nw4r/snd/snd_ExternalSoundPlayer.cpp"), Object(NonMatching, "nw4r/snd/snd_FrameHeap.cpp"), diff --git a/src/nw4r/snd/snd_DvdSoundArchive.cpp b/src/nw4r/snd/snd_DvdSoundArchive.cpp index 43a69d2e..ff98e4e4 100644 --- a/src/nw4r/snd/snd_DvdSoundArchive.cpp +++ b/src/nw4r/snd/snd_DvdSoundArchive.cpp @@ -56,8 +56,10 @@ bool DvdSoundArchive::Open(const char* pPath) { char extRoot[FILE_PATH_MAX]; for (int i = std::strlen(pPath) - 1; i >= 0; i--) { - if (pPath[i] == '/' || pPath[i] == '\\') { - // @bug Long path can overflow extRoot buffer + if ((pPath[i] == '/' || pPath[i] == '\\')) { + if (i >= FILE_PATH_MAX + 1) { + return false; + } std::strncpy(extRoot, pPath, i); extRoot[i] = '\0'; @@ -70,8 +72,10 @@ bool DvdSoundArchive::Open(const char* pPath) { } void DvdSoundArchive::Close() { - DVDClose(&mFileInfo); - mOpen = false; + if (mOpen) { + DVDClose(&mFileInfo); + mOpen = false; + } Shutdown(); } @@ -115,7 +119,7 @@ bool DvdSoundArchive::LoadFileHeader() { u8 headerArea[detail::SoundArchiveFile::HEADER_AREA_SIZE]; static const u32 headerAlignSize = - ut::RoundUp(sizeof(detail::SoundArchiveFile::Header), 32); + ROUND_UP(sizeof(detail::SoundArchiveFile::Header), 32); void* pFile = ut::RoundUp(headerArea, 32); @@ -173,9 +177,6 @@ bool DvdSoundArchive::LoadLabelStringData(void* pBuffer, u32 size) { DvdSoundArchive::DvdFileStream::DvdFileStream(const DVDFileInfo* pFileInfo, u32 offset, u32 size) : DvdLockedFileStream(pFileInfo, false), mOffset(offset), mSize(size) { - if (mSize == 0) { - mSize = ut::DvdFileStream::GetSize(); - } ut::DvdFileStream::Seek(mOffset, SEEKORG_BEG); } @@ -183,9 +184,6 @@ DvdSoundArchive::DvdFileStream::DvdFileStream(const DVDFileInfo* pFileInfo, DvdSoundArchive::DvdFileStream::DvdFileStream(s32 entrynum, u32 offset, u32 size) : DvdLockedFileStream(entrynum), mOffset(offset), mSize(size) { - if (mSize == 0) { - mSize = ut::DvdFileStream::GetSize(); - } ut::DvdFileStream::Seek(mOffset, SEEKORG_BEG); }