diff --git a/Goldleaf/Include/nsp/nsp_PFS0.hpp b/Goldleaf/Include/nsp/nsp_PFS0.hpp index 02ae760..4df7d56 100644 --- a/Goldleaf/Include/nsp/nsp_PFS0.hpp +++ b/Goldleaf/Include/nsp/nsp_PFS0.hpp @@ -39,6 +39,8 @@ namespace nsp u64 GetFileSize(u32 Index); void SaveFile(u32 Index, fs::Explorer *Exp, pu::String Path); u32 GetFileIndexByName(pu::String File); + + static const u32 INVALID_FILE = 0xFFFFFFFF; private: pu::String path; fs::Explorer *gexp; diff --git a/Goldleaf/Makefile b/Goldleaf/Makefile index 6fd1f9d..9a1f86a 100644 --- a/Goldleaf/Makefile +++ b/Goldleaf/Makefile @@ -12,7 +12,7 @@ VER_MINOR := 7 VER_MICRO := 3 APP_TITLE := GoldBricks -APP_AUTHOR := XorTroll +APP_AUTHOR := XorWar APP_VERSION := $(VER_MAJOR).$(VER_MINOR).$(VER_MICRO) APP_TITLEID := 050032A5CF12E000 diff --git a/Goldleaf/Source/Main.cpp b/Goldleaf/Source/Main.cpp index 5ca1cc6..fa16346 100644 --- a/Goldleaf/Source/Main.cpp +++ b/Goldleaf/Source/Main.cpp @@ -45,6 +45,7 @@ void Initialize() if(R_FAILED(setInitialize())) exit(1); if(R_FAILED(setsysInitialize())) exit(1); if(R_FAILED(usb::comms::Initialize())) exit(1); + if(R_FAILED(splCryptoInitialize())) exit(1); if(R_FAILED(splInitialize())) exit(1); if(R_FAILED(bpcInitialize())) exit(1); if(R_FAILED(nifmInitialize())) exit(1); @@ -69,6 +70,7 @@ void Finalize() delete sdcd; bpcExit(); splExit(); + splCryptoExit(); usb::comms::Exit(); setsysExit(); setExit(); diff --git a/Goldleaf/Source/nsp/nsp_Installer.cpp b/Goldleaf/Source/nsp/nsp_Installer.cpp index 1b6d559..686fb4e 100644 --- a/Goldleaf/Source/nsp/nsp_Installer.cpp +++ b/Goldleaf/Source/nsp/nsp_Installer.cpp @@ -295,14 +295,30 @@ namespace nsp NcmNcaId curid = rnca.ContentId; pu::String ncaname = hos::ContentIdAsString(curid); if(rnca.Type == ncm::ContentType::Meta) ncaname += ".cnmt"; - ncaname += ".nca"; - u32 idxncaname = nspentry.GetFileIndexByName(ncaname); + + u32 idxncaname; + + if((idxncaname = nspentry.GetFileIndexByName(ncaname + ".nca")) != PFS0::INVALID_FILE) + { + ncaname += ".nca"; + } + else if((idxncaname = nspentry.GetFileIndexByName(ncaname + ".ncz")) != PFS0::INVALID_FILE) + { + ncaname += ".ncz"; + } + else + { + return -1; + } + auto cursize = nspentry.GetFileSize(idxncaname); totalsize += cursize; ncaidxs.push_back(idxncaname); ncanames.push_back(ncaname); ncasizes.push_back(cursize); } + NcmContentStorage cst; + ncmOpenContentStorage(storage, &cst); for(u32 i = 0; i < ncas.size(); i++) { ncm::ContentRecord rnca = ncas[i]; @@ -310,11 +326,7 @@ namespace nsp pu::String ncaname = ncanames[i]; u64 ncasize = ncasizes[i]; u32 idxncaname = ncaidxs[i]; - - NcmContentStorage cst; - ncmOpenContentStorage(storage, &cst); ncm::DeletePlaceHolder(&cst, &curid); - ncm::CreatePlaceHolder(&cst, &curid, &curid, ncasize); NcaWriter writer(curid, &cst); u64 noff = 0; u64 szrem = ncasize; @@ -345,8 +357,8 @@ namespace nsp twrittensize += noff; ncmContentStorageRegister(&cst, &curid, &curid); ncm::DeletePlaceHolder(&cst, &curid); - serviceClose(&cst.s); } + serviceClose(&cst.s); return rc; } diff --git a/Goldleaf/Source/nsp/nsp_PFS0.cpp b/Goldleaf/Source/nsp/nsp_PFS0.cpp index eb34ca4..e072de2 100644 --- a/Goldleaf/Source/nsp/nsp_PFS0.cpp +++ b/Goldleaf/Source/nsp/nsp_PFS0.cpp @@ -123,15 +123,13 @@ namespace nsp u32 PFS0::GetFileIndexByName(pu::String File) { - u32 idx = 0; for(u32 i = 0; i < this->files.size(); i++) { if(strcasecmp(this->files[i].Name.AsUTF8().c_str(), File.AsUTF8().c_str()) == 0) { - idx = i; - break; + return i; } } - return idx; + return INVALID_FILE; } } \ No newline at end of file