bool C3dsTool::encryptFile() { bool bResult = false; if (m_nEncryptMode == CNcch::kEncryptModeAesCtr && m_bCounterValid) { bResult = FEncryptAesCtrFile(m_pFileName, m_Key, m_Counter, 0, 0, true, 0); } else if (m_nEncryptMode == CNcch::kEncryptModeXor && m_pXorFileName != nullptr) { bResult = FEncryptXorFile(m_pFileName, m_pXorFileName, 0, 0, true, 0); } else if (CNcch::IsCxiFile(m_pFileName)) { CNcch ncch; ncch.SetFileName(m_pFileName); ncch.SetVerbose(m_bVerbose); ncch.SetEncryptMode(m_nEncryptMode); ncch.SetKey(m_Key); ncch.SetExtendedHeaderXorFileName(m_pExtendedHeaderXorFileName); ncch.SetExeFsXorFileName(m_pExeFsXorFileName); ncch.SetExeFsTopXorFileName(m_pExeFsTopXorFileName); ncch.SetRomFsXorFileName(m_pRomFsXorFileName); ncch.SetExeFsTopAutoKey(m_bExeFsTopAutoKey); ncch.SetRomFsAutoKey(m_bRomFsAutoKey); bResult = ncch.EncryptFile(); } else if (CNcch::IsCfaFile(m_pFileName)) { CNcch ncch; ncch.SetFileName(m_pFileName); ncch.SetVerbose(m_bVerbose); ncch.SetEncryptMode(m_nEncryptMode); ncch.SetKey(m_Key); ncch.SetExeFsXorFileName(m_pExeFsXorFileName); ncch.SetRomFsXorFileName(m_pRomFsXorFileName); ncch.SetRomFsAutoKey(m_bRomFsAutoKey); bResult = ncch.EncryptFile(); } return bResult; }
bool C3dsTool::createFile() { bool bResult = false; switch (m_eFileType) { case kFileTypeCci: { CNcsd ncsd; ncsd.SetFileName(m_pFileName); ncsd.SetVerbose(m_bVerbose); ncsd.SetHeaderFileName(m_pHeaderFileName); ncsd.SetNcchFileName(m_pNcchFileName); ncsd.SetNotPad(m_bNotPad); bResult = ncsd.CreateFile(); } break; case kFileTypeCxi: { CNcch ncch; ncch.SetFileName(m_pFileName); ncch.SetVerbose(m_bVerbose); ncch.SetHeaderFileName(m_pHeaderFileName); ncch.SetEncryptMode(m_nEncryptMode); ncch.SetKey(m_Key); ncch.SetNotUpdateExtendedHeaderHash(m_bNotUpdateExtendedHeaderHash); ncch.SetNotUpdateExeFsHash(m_bNotUpdateExeFsHash); ncch.SetNotUpdateRomFsHash(m_bNotUpdateRomFsHash); ncch.SetExtendedHeaderFileName(m_pExtendedHeaderFileName); ncch.SetLogoRegionFileName(m_pLogoRegionFileName); ncch.SetPlainRegionFileName(m_pPlainRegionFileName); ncch.SetExeFsFileName(m_pExeFsFileName); ncch.SetRomFsFileName(m_pRomFsFileName); ncch.SetExtendedHeaderXorFileName(m_pExtendedHeaderXorFileName); ncch.SetExeFsXorFileName(m_pExeFsXorFileName); ncch.SetExeFsTopXorFileName(m_pExeFsTopXorFileName); ncch.SetRomFsXorFileName(m_pRomFsXorFileName); ncch.SetExeFsTopAutoKey(m_bExeFsTopAutoKey); ncch.SetRomFsAutoKey(m_bRomFsAutoKey); bResult = ncch.CreateFile(); } break; case kFileTypeCfa: { CNcch ncch; ncch.SetFileName(m_pFileName); ncch.SetVerbose(m_bVerbose); ncch.SetHeaderFileName(m_pHeaderFileName); ncch.SetEncryptMode(m_nEncryptMode); ncch.SetKey(m_Key); ncch.SetNotUpdateExeFsHash(m_bNotUpdateExeFsHash); ncch.SetNotUpdateRomFsHash(m_bNotUpdateRomFsHash); ncch.SetExeFsFileName(m_pExeFsFileName); ncch.SetRomFsFileName(m_pRomFsFileName); ncch.SetExeFsXorFileName(m_pExeFsXorFileName); ncch.SetRomFsXorFileName(m_pRomFsXorFileName); ncch.SetRomFsAutoKey(m_bRomFsAutoKey); bResult = ncch.CreateFile(); } break; case kFileTypeExeFs: { CExeFs exeFs; exeFs.SetFileName(m_pFileName); exeFs.SetVerbose(m_bVerbose); exeFs.SetHeaderFileName(m_pHeaderFileName); exeFs.SetExeFsDirName(m_pExeFsDirName); exeFs.SetCompress(m_bCompress); bResult = exeFs.CreateFile(); } break; case kFileTypeRomFs: { CRomFs romFs; romFs.SetFileName(m_pFileName); romFs.SetVerbose(m_bVerbose); romFs.SetRomFsDirName(m_pRomFsDirName); romFs.SetRomFsFileName(m_pRomFsFileName); bResult = romFs.CreateFile(); } break; case kFileTypeBanner: { CBanner banner; banner.SetFileName(m_pFileName); banner.SetVerbose(m_bVerbose); banner.SetBannerDirName(m_pBannerDirName); bResult = banner.CreateFile(); } break; default: break; } return bResult; }