├── .gitignore ├── Arc ├── LZSS.cpp ├── LZSS.h ├── Zlib.cpp └── Zlib.h ├── ArcFile.cpp ├── ArcFile.h ├── Base ├── YCFile.cpp ├── YCFile.h ├── YCFileFind.cpp ├── YCFileFind.h ├── YCFileFindSx.cpp ├── YCFileFindSx.h ├── YCIni.cpp ├── YCIni.h ├── YCLibrary.cpp ├── YCLibrary.h ├── YCLocalMemory.cpp ├── YCLocalMemory.h ├── YCStdioFile.cpp ├── YCStdioFile.h ├── YCString.cpp └── YCString.h ├── Common.h ├── Docs └── Susie Plugin API Rev4+α.md ├── Error.cpp ├── Error.h ├── Extract.cpp ├── Extract.h ├── Extract ├── AOS.cpp ├── AOS.h ├── Ahx.cpp ├── Ahx.h ├── Alcot.cpp ├── Alcot.h ├── Aselia.cpp ├── Aselia.h ├── Axl.cpp ├── Axl.h ├── Baldr.cpp ├── Baldr.h ├── Circus.cpp ├── Circus.h ├── CircusPak.cpp ├── CircusPak.h ├── Clannad.cpp ├── Clannad.h ├── Cyc.cpp ├── Cyc.h ├── EntisGLS.cpp ├── EntisGLS.h ├── Ethornell.cpp ├── Ethornell.h ├── FateFD.cpp ├── FateFD.h ├── Himauri.cpp ├── Himauri.h ├── InnocentGrey.cpp ├── InnocentGrey.h ├── Izumo.cpp ├── Izumo.h ├── Katakoi.cpp ├── Katakoi.h ├── LostChild.cpp ├── LostChild.h ├── Majiro.cpp ├── Majiro.h ├── MeltyBlood.cpp ├── MeltyBlood.h ├── Navel.cpp ├── Navel.h ├── Nitro.cpp ├── Nitro.h ├── Nscr.cpp ├── Nscr.h ├── Oyatu.cpp ├── Oyatu.h ├── Pajamas.cpp ├── Pajamas.h ├── QLIE.cpp ├── QLIE.h ├── Retouch.cpp ├── Retouch.h ├── Spitan.cpp ├── Spitan.h ├── Standard.cpp ├── Standard.h ├── SummerDays.cpp ├── SummerDays.h ├── TCD │ ├── TCD2.cpp │ ├── TCD2.h │ ├── TCD3.cpp │ ├── TCD3.h │ ├── TCDBase.cpp │ └── TCDBase.h ├── TH2.cpp ├── TH2.h ├── TaskForce.cpp ├── TaskForce.h ├── TrH.cpp ├── TrH.h ├── VA.cpp ├── VA.h ├── Will.cpp ├── Will.h ├── Windmill.cpp ├── Windmill.h ├── Ykc.cpp ├── Ykc.h ├── Yuris.cpp ├── Yuris.h ├── cpz │ ├── Cmv.cpp │ ├── Cmv.h │ ├── Cpz.cpp │ ├── Cpz.h │ ├── JBP1.cpp │ ├── JBP1.h │ ├── PB.cpp │ ├── PB.h │ ├── PB2A.cpp │ ├── PB2A.h │ ├── PB3B.cpp │ └── PB3B.h ├── krkr │ ├── Braban.cpp │ ├── Braban.h │ ├── Fate.cpp │ ├── Fate.h │ ├── FateFD.cpp │ ├── FateFD.h │ ├── FlyingShine.cpp │ ├── FlyingShine.h │ ├── Hachukano.cpp │ ├── Hachukano.h │ ├── Himesyo.cpp │ ├── Himesyo.h │ ├── Krkr.cpp │ ├── Krkr.h │ ├── Natsupochi.cpp │ ├── Natsupochi.h │ ├── SisMiko.cpp │ ├── SisMiko.h │ ├── Specialite.cpp │ ├── Specialite.h │ ├── Tengu.cpp │ ├── Tengu.h │ ├── Tlg.cpp │ ├── Tlg.h │ ├── TokiPaku.cpp │ ├── TokiPaku.h │ ├── Yotsunoha.cpp │ └── Yotsunoha.h └── paz │ ├── AngelType.cpp │ ├── AngelType.h │ ├── BSFre.cpp │ ├── BSFre.h │ ├── Haruoto.cpp │ ├── Haruoto.h │ ├── HaruotoFD.cpp │ ├── HaruotoFD.h │ ├── Paz.cpp │ ├── Paz.h │ ├── WindRP.cpp │ ├── WindRP.h │ ├── ef_ffd.cpp │ ├── ef_ffd.h │ ├── ef_first.cpp │ ├── ef_first.h │ ├── ef_latter.cpp │ ├── ef_latter.h │ ├── ef_sfm.cpp │ ├── ef_sfm.h │ ├── ef_trial.cpp │ └── ef_trial.h ├── ExtractBase.cpp ├── ExtractBase.h ├── ExtractData.sln ├── ExtractData.vcxproj ├── ExtractData.vcxproj.filters ├── File.cpp ├── File.h ├── FindFile.cpp ├── FindFile.h ├── Image.cpp ├── Image.h ├── Image ├── Bmp.cpp ├── Bmp.h ├── ImageBase.cpp ├── ImageBase.h ├── Jpg.cpp ├── Jpg.h ├── Png.cpp ├── Png.h ├── Tga.cpp └── Tga.h ├── Ini.cpp ├── Ini.h ├── LastDir.cpp ├── LastDir.h ├── Libs ├── lpng163 │ ├── ANNOUNCE │ ├── CHANGES │ ├── INSTALL │ ├── LICENSE │ ├── README │ ├── TODO │ ├── libpng-manual.txt │ ├── png.5 │ ├── png.c │ ├── png.h │ ├── pngconf.h │ ├── pngdebug.h │ ├── pngerror.c │ ├── pngget.c │ ├── pnginfo.h │ ├── pnglibconf.h │ ├── pngmem.c │ ├── pngpread.c │ ├── pngpriv.h │ ├── pngread.c │ ├── pngrio.c │ ├── pngrtran.c │ ├── pngrutil.c │ ├── pngset.c │ ├── pngstruct.h │ ├── pngtest.c │ ├── pngtrans.c │ ├── pngwio.c │ ├── pngwrite.c │ ├── pngwtran.c │ ├── pngwutil.c │ ├── projects │ │ └── vstudio │ │ │ ├── WARNING │ │ │ ├── libpng │ │ │ └── libpng.vcxproj │ │ │ ├── pnglibconf │ │ │ └── pnglibconf.vcxproj │ │ │ ├── pngstest │ │ │ └── pngstest.vcxproj │ │ │ ├── pngtest │ │ │ └── pngtest.vcxproj │ │ │ ├── pngunknown │ │ │ └── pngunknown.vcxproj │ │ │ ├── pngvalid │ │ │ └── pngvalid.vcxproj │ │ │ ├── readme.txt │ │ │ ├── vstudio.sln │ │ │ ├── zlib.props │ │ │ └── zlib │ │ │ └── zlib.vcxproj │ └── scripts │ │ └── pngwin.rc └── zlib-1.2.11 │ ├── ChangeLog │ ├── FAQ │ ├── INDEX │ ├── README │ ├── adler32.c │ ├── compress.c │ ├── contrib │ ├── README.contrib │ ├── masmx64 │ │ ├── bld_ml64.bat │ │ ├── gvmat64.asm │ │ ├── gvmat64.lst │ │ ├── inffas8664.c │ │ ├── inffasx64.asm │ │ ├── inffasx64.lst │ │ └── readme.txt │ ├── masmx86 │ │ ├── bld_ml32.bat │ │ ├── inffas32.asm │ │ ├── match686.asm │ │ └── readme.txt │ └── vstudio │ │ ├── readme.txt │ │ ├── vc10 │ │ ├── miniunz.vcxproj │ │ ├── miniunz.vcxproj.filters │ │ ├── minizip.vcxproj │ │ ├── minizip.vcxproj.filters │ │ ├── testzlib.vcxproj │ │ ├── testzlib.vcxproj.filters │ │ ├── testzlibdll.vcxproj │ │ ├── testzlibdll.vcxproj.filters │ │ ├── zlib.rc │ │ ├── zlibstat.vcxproj │ │ ├── zlibstat.vcxproj.filters │ │ ├── zlibvc.def │ │ ├── zlibvc.sln │ │ ├── zlibvc.vcxproj │ │ └── zlibvc.vcxproj.filters │ │ ├── vc11 │ │ ├── miniunz.vcxproj │ │ ├── minizip.vcxproj │ │ ├── testzlib.vcxproj │ │ ├── testzlibdll.vcxproj │ │ ├── zlib.rc │ │ ├── zlibstat.vcxproj │ │ ├── zlibvc.def │ │ ├── zlibvc.sln │ │ └── zlibvc.vcxproj │ │ ├── vc12 │ │ ├── miniunz.vcxproj │ │ ├── minizip.vcxproj │ │ ├── testzlib.vcxproj │ │ ├── testzlibdll.vcxproj │ │ ├── zlib.rc │ │ ├── zlibstat.vcxproj │ │ ├── zlibvc.def │ │ ├── zlibvc.sln │ │ └── zlibvc.vcxproj │ │ ├── vc14 │ │ ├── miniunz.vcxproj │ │ ├── minizip.vcxproj │ │ ├── testzlib.vcxproj │ │ ├── testzlibdll.vcxproj │ │ ├── zlib.rc │ │ ├── zlibstat.vcxproj │ │ ├── zlibvc.def │ │ ├── zlibvc.sln │ │ └── zlibvc.vcxproj │ │ └── vc9 │ │ ├── miniunz.vcproj │ │ ├── minizip.vcproj │ │ ├── testzlib.vcproj │ │ ├── testzlibdll.vcproj │ │ ├── zlib.rc │ │ ├── zlibstat.vcproj │ │ ├── zlibvc.def │ │ ├── zlibvc.sln │ │ └── zlibvc.vcproj │ ├── crc32.c │ ├── crc32.h │ ├── deflate.c │ ├── deflate.h │ ├── doc │ ├── algorithm.txt │ ├── rfc1950.txt │ ├── rfc1951.txt │ ├── rfc1952.txt │ └── txtvsbin.txt │ ├── gzclose.c │ ├── gzguts.h │ ├── gzlib.c │ ├── gzread.c │ ├── gzwrite.c │ ├── infback.c │ ├── inffast.c │ ├── inffast.h │ ├── inffixed.h │ ├── inflate.c │ ├── inflate.h │ ├── inftrees.c │ ├── inftrees.h │ ├── trees.c │ ├── trees.h │ ├── uncompr.c │ ├── zconf.h │ ├── zlib.3.pdf │ ├── zlib.h │ ├── zlib2ansi │ ├── zutil.c │ └── zutil.h ├── MD5.cpp ├── MD5.h ├── Mzx.cpp ├── Mzx.h ├── Readme.md ├── Reg.cpp ├── Reg.h ├── Search ├── AhxSearch.cpp ├── AhxSearch.h ├── BmpSearch.cpp ├── BmpSearch.h ├── JpgSearch.cpp ├── JpgSearch.h ├── MidSearch.cpp ├── MidSearch.h ├── MpgSearch.cpp ├── MpgSearch.h ├── OggSearch.cpp ├── OggSearch.h ├── PngSearch.cpp ├── PngSearch.h ├── SearchBase.cpp ├── SearchBase.h ├── WavSearch.cpp ├── WavSearch.h ├── WmvSearch.cpp └── WmvSearch.h ├── Sound ├── Ogg.cpp ├── Ogg.h ├── Wav.cpp └── Wav.h ├── StdAfx.cpp ├── StdAfx.h ├── Susie.cpp ├── Susie.h ├── Types.h ├── UI ├── Ctrl │ ├── Button.cpp │ ├── Button.h │ ├── CheckBox.cpp │ ├── CheckBox.h │ ├── Color.cpp │ ├── Color.h │ ├── CtrlBase.cpp │ ├── CtrlBase.h │ ├── EditBox.cpp │ ├── EditBox.h │ ├── Font.cpp │ ├── Font.h │ ├── GroupBox.cpp │ ├── GroupBox.h │ ├── Label.cpp │ ├── Label.h │ ├── ListView.cpp │ ├── ListView.h │ ├── RadioBtn.cpp │ ├── RadioBtn.h │ ├── StatusBar.cpp │ ├── StatusBar.h │ ├── ToolBar.cpp │ ├── ToolBar.h │ ├── UpDown.cpp │ └── UpDown.h ├── DataBase │ ├── DBListView.cpp │ ├── DBListView.h │ ├── DataBase.cpp │ └── DataBase.h ├── Dialog │ ├── ExistsDialog.cpp │ ├── ExistsDialog.h │ ├── FileDialog.cpp │ ├── FileDialog.h │ ├── FolderDialog.cpp │ ├── FolderDialog.h │ ├── FolderInputDialog.cpp │ ├── FolderInputDialog.h │ ├── SearchDialog.cpp │ ├── SearchDialog.h │ ├── VersionInfo.cpp │ └── VersionInfo.h ├── DragDrop │ ├── DataObject.cpp │ ├── DataObject.h │ ├── DropSource.cpp │ ├── DropSource.h │ ├── EnumFORMATETC.cpp │ ├── EnumFORMATETC.h │ ├── STGMEDIUM.cpp │ └── STGMEDIUM.h ├── ExtractData.cpp ├── ExtractData.h ├── MainListView.cpp ├── MainListView.h ├── MainToolBar.cpp ├── MainToolBar.h ├── Option.cpp ├── Option.h ├── ProgressBar.cpp ├── ProgressBar.h ├── SusieListView.cpp ├── SusieListView.h ├── WinMain.cpp ├── WinMain.h ├── WindowBase.cpp └── WindowBase.h ├── Utils ├── BitUtils.cpp └── BitUtils.h ├── bzip2 ├── blocksort.cpp ├── bzlib.cpp ├── bzlib.h ├── bzlib_private.h ├── compress.cpp ├── crctable.cpp ├── decompress.cpp ├── huffman.cpp └── randtable.cpp ├── gpl.ja.txt ├── gpl.txt └── res ├── ExtractData.ico ├── ExtractData.rc ├── MainToolBar.bmp ├── ResExtractData.h └── SearchToolBar.bmp /.gitignore: -------------------------------------------------------------------------------- 1 | #ignore thumbnails created by windows 2 | Thumbs.db 3 | #Ignore files build by Visual Studio 4 | *.obj 5 | *.exe 6 | *.pdb 7 | *.user 8 | *.sdf 9 | *.opensdf 10 | *.aps 11 | *.pch 12 | *.vspscc 13 | *_i.c 14 | *_p.c 15 | *.ncb 16 | *.suo 17 | *.tlb 18 | *.tlh 19 | *.bak 20 | *.cache 21 | *.ilk 22 | *.log 23 | [Bb]in 24 | [Dd]ebug*/ 25 | *.lib 26 | *.sbr 27 | obj/ 28 | [Rr]elease*/ 29 | _ReSharper*/ 30 | [Tt]est[Rr]esult* 31 | -------------------------------------------------------------------------------- /Arc/LZSS.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CArcFile; 4 | 5 | class CLZSS 6 | { 7 | public: 8 | bool Decode(CArcFile* archive); 9 | 10 | bool Decomp(CArcFile* archive, size_t dic_size, size_t dic_ptr, size_t length_offset); 11 | bool Decomp(u8* dst, size_t dst_size, const u8* src, size_t src_size, size_t dic_size, size_t dic_ptr, size_t length_offset); 12 | }; 13 | -------------------------------------------------------------------------------- /Arc/Zlib.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Arc/Zlib.h" 3 | 4 | #include "ArcFile.h" 5 | #include "Common.h" 6 | #include "Image.h" 7 | 8 | bool CZlib::Decode(CArcFile* archive) 9 | { 10 | const SFileInfo* file_info = archive->GetOpenFileInfo(); 11 | 12 | if (file_info->format != _T("zlib")) 13 | return false; 14 | 15 | DecompressFile(archive); 16 | 17 | return true; 18 | } 19 | 20 | void CZlib::DecompressFile(CArcFile* archive) 21 | { 22 | SFileInfo* file_info = archive->GetOpenFileInfo(); 23 | 24 | // Ensure buffer 25 | std::vector z_buf(file_info->size_cmp); 26 | std::vector buf(file_info->size_org); 27 | 28 | // zlib Decompression 29 | archive->Read(z_buf.data(), z_buf.size()); 30 | Decompress(buf.data(), &file_info->size_org, z_buf.data(), z_buf.size()); 31 | 32 | if (lstrcmp(PathFindExtension(file_info->name), _T(".bmp")) == 0) 33 | { 34 | CImage image; 35 | image.Init(archive, buf.data()); 36 | image.Write(file_info->size_org); 37 | } 38 | else 39 | { 40 | // Output 41 | archive->OpenFile(); 42 | archive->WriteFile(buf.data(), file_info->size_org); 43 | } 44 | } 45 | 46 | // Function to expand memory with zlib 47 | int CZlib::Decompress(u8* dst, u32* dst_size, const u8* src, u32 src_size) 48 | { 49 | unsigned long dst_size_tmp = 0; 50 | const int result = uncompress(dst, &dst_size_tmp, src, src_size); 51 | 52 | *dst_size = static_cast(dst_size_tmp); 53 | return result; 54 | } 55 | 56 | // Function to expand memory with zlib 57 | int CZlib::Decompress(u8* dst, u32 dst_size, const u8* src, u32 src_size) 58 | { 59 | unsigned long dst_size_tmp = dst_size; 60 | return uncompress(dst, &dst_size_tmp, src, src_size); 61 | } 62 | -------------------------------------------------------------------------------- /Arc/Zlib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CArcFile; 4 | 5 | class CZlib 6 | { 7 | public: 8 | bool Decode(CArcFile* archive); 9 | void DecompressFile(CArcFile* archive); 10 | int Decompress(u8* dst, u32* dst_size, const u8* src, u32 src_size); 11 | int Decompress(u8* dst, u32 dst_size, const u8* src, u32 src_size); 12 | }; 13 | -------------------------------------------------------------------------------- /Base/YCFile.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class YCFile 4 | { 5 | public: 6 | enum 7 | { 8 | modeCreate = 0x00000001, 9 | modeNoTruncate = 0x00000002, 10 | modeRead = 0x00000004, 11 | modeReadWrite = 0x00000008, 12 | modeWrite = 0x00000010, 13 | modeNoInherit = 0x00000020, 14 | shareDenyNone = 0x00000040, 15 | shareDenyRead = 0x00000080, 16 | shareDenyWrite = 0x00000100, 17 | shareExclusive = 0x00000200, 18 | shareCompat = 0x00000400, 19 | typeText = 0x00000800, 20 | typeBinary = 0x00001000, 21 | osNoBuffer = 0x00002000, 22 | osWriteThrough = 0x00004000, 23 | osRandomAccess = 0x00008000, 24 | osSequentialScan = 0x00010000, 25 | }; 26 | 27 | enum class SeekMode 28 | { 29 | begin, 30 | current, 31 | end, 32 | }; 33 | 34 | YCFile(); 35 | virtual ~YCFile(); 36 | 37 | YCFile(const YCFile&) = delete; 38 | YCFile& operator=(const YCFile&) = delete; 39 | 40 | YCFile(YCFile&&) = default; 41 | YCFile& operator=(YCFile&&) = default; 42 | 43 | virtual bool Open(LPCTSTR file_path, u32 open_flags); 44 | 45 | virtual void Close(); 46 | 47 | virtual DWORD Read(void* buffer, u32 read_size); 48 | virtual DWORD Write(const void* buffer, u32 write_size); 49 | 50 | virtual u64 Seek(s64 offset, SeekMode seek_mode); 51 | virtual u64 SeekHed(s64 offset = 0); 52 | virtual u64 SeekEnd(s64 offset = 0); 53 | virtual u64 SeekCur(s64 offset); 54 | 55 | virtual u64 GetPosition(); 56 | virtual u64 GetLength(); 57 | 58 | virtual YCString GetFilePath() const; 59 | virtual YCString GetFileName() const; 60 | virtual YCString GetFileExt() const; 61 | 62 | protected: 63 | YCString m_file_path; 64 | YCString m_file_name; 65 | YCString m_file_extension; 66 | 67 | private: 68 | HANDLE m_file; 69 | }; 70 | -------------------------------------------------------------------------------- /Base/YCFileFind.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //---------------------------------------------------------------------------------------- 4 | //-- File Search Class ------------------------------------------------------------------- 5 | //---------------------------------------------------------------------------------------- 6 | 7 | class YCFileFind final 8 | { 9 | public: 10 | YCFileFind(); 11 | ~YCFileFind(); 12 | 13 | bool FindFirstFile(LPCTSTR file_path); 14 | bool FindFirstFile(LPCTSTR directory_path, LPCTSTR file_name); 15 | bool FindNextFile(); 16 | void Close(); 17 | 18 | YCString GetFileName() const; 19 | YCString GetFilePath() const; 20 | YCString GetFileTitle() const; 21 | 22 | bool IsDirectory() const; 23 | bool IsDots() const; 24 | 25 | private: 26 | HANDLE m_find_handle; 27 | WIN32_FIND_DATA m_find_data; 28 | YCString m_path_to_folder; 29 | }; 30 | -------------------------------------------------------------------------------- /Base/YCFileFindSx.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "YCFileFindSx.h" 3 | 4 | /// File Search 5 | /// 6 | /// @param dst_file_paths Storage location 7 | /// @param target_folder_path Directory to search for 8 | /// @param target_file_name Target filename (can be a wildcard) 9 | /// @param search_subdirectories Search for subdirectories (true: Search, false: Don't search) 10 | /// 11 | bool YCFileFindSx::FindFile(std::vector& dst_file_paths, LPCTSTR target_folder_path, LPCTSTR target_file_name, bool search_subdirectories) 12 | { 13 | bool result = false; 14 | 15 | // Searching for file 16 | YCFileFind target; 17 | 18 | if (target.FindFirstFile(target_folder_path, target_file_name)) 19 | { 20 | do 21 | { 22 | // Marker 23 | if (target.IsDots()) 24 | { 25 | continue; 26 | } 27 | 28 | // Directory 29 | if (target.IsDirectory()) 30 | { 31 | continue; 32 | } 33 | 34 | // Add to the list of files found 35 | dst_file_paths.push_back(target.GetFilePath()); 36 | 37 | } 38 | while (target.FindNextFile()); 39 | 40 | result = true; 41 | } 42 | 43 | target.Close(); 44 | 45 | // Do not search the subdirectories 46 | if (!search_subdirectories) 47 | { 48 | return result; 49 | } 50 | 51 | // Search directory 52 | if (target.FindFirstFile(target_folder_path, _T("*.*"))) 53 | { 54 | do 55 | { 56 | // Marker 57 | if (target.IsDots()) 58 | { 59 | continue; 60 | } 61 | 62 | // Not a directory 63 | if (!target.IsDirectory()) 64 | { 65 | continue; 66 | } 67 | 68 | // Recursive call 69 | FindFile(dst_file_paths, target.GetFilePath(), target_file_name, search_subdirectories); 70 | } 71 | while (target.FindNextFile()); 72 | 73 | result = true; 74 | } 75 | 76 | target.Close(); 77 | 78 | return result; 79 | } 80 | -------------------------------------------------------------------------------- /Base/YCFileFindSx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class YCFileFindSx 4 | { 5 | public: 6 | bool FindFile(std::vector& dst_file_paths, LPCTSTR target_folder_path, LPCTSTR target_file_name = _T("*.*"), bool search_subdirectories = true); 7 | }; 8 | -------------------------------------------------------------------------------- /Base/YCIni.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "YCIni.h" 3 | 4 | /// Constructor 5 | YCIni::YCIni(LPCTSTR ini_path) 6 | { 7 | // Gets the execution path of the file 8 | std::array exe_folder_path; 9 | ::GetModuleFileName(nullptr, exe_folder_path.data(), static_cast(exe_folder_path.size())); 10 | ::PathRemoveFileSpec(exe_folder_path.data()); 11 | 12 | // Get INI file path 13 | m_ini_path.Format(_T("%s\\%s"), exe_folder_path.data(), ini_path); 14 | } 15 | 16 | YCIni::~YCIni() = default; 17 | 18 | /// Set a section name 19 | void YCIni::SetSection(LPCTSTR section) 20 | { 21 | m_section = section; 22 | } 23 | 24 | /// Set a section name 25 | /// 26 | /// @param id String ID 27 | /// 28 | void YCIni::SetSection(u32 id) 29 | { 30 | std::array buffer; 31 | 32 | ::LoadString(::GetModuleHandle(nullptr), id, buffer.data(), static_cast(buffer.size())); 33 | 34 | SetSection(buffer.data()); 35 | } 36 | 37 | /// Set key name 38 | void YCIni::SetKey(LPCTSTR key) 39 | { 40 | m_key = key; 41 | } 42 | 43 | /// Gets a string 44 | /// 45 | /// @param dst Storage location for the string 46 | /// @param dst_size Buffer size 47 | /// @param default_string Default value 48 | /// 49 | void YCIni::ReadStr(LPTSTR dst, DWORD dst_size, LPCTSTR default_string) 50 | { 51 | ::GetPrivateProfileString(m_section, m_key, default_string, dst, dst_size, m_ini_path); 52 | } 53 | 54 | /// Gets a string 55 | /// 56 | /// @param dst Storage location for the string 57 | /// @param default_string Default value 58 | /// 59 | void YCIni::ReadStr(YCString& dst, const YCString& default_string) 60 | { 61 | std::array buffer; 62 | 63 | ReadStr(buffer.data(), static_cast(buffer.size()), default_string); 64 | 65 | dst = buffer.data(); 66 | } 67 | 68 | /// Sets the string 69 | void YCIni::WriteStr(LPCTSTR str) 70 | { 71 | ::WritePrivateProfileString(m_section, m_key, str, m_ini_path); 72 | } 73 | 74 | /// Delete section 75 | bool YCIni::DeleteSection(LPCTSTR section) 76 | { 77 | if (section == nullptr) 78 | section = m_section; 79 | 80 | return ::WritePrivateProfileString(section, nullptr, nullptr, m_ini_path) != 0; 81 | } 82 | -------------------------------------------------------------------------------- /Base/YCLibrary.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "YCLibrary.h" 3 | 4 | YCLibrary::YCLibrary() 5 | { 6 | } 7 | 8 | YCLibrary::~YCLibrary() 9 | { 10 | Free(); 11 | } 12 | 13 | /// Load the specified module 14 | /// 15 | /// @param file_path Load module name 16 | /// 17 | bool YCLibrary::Load(LPCTSTR file_path) 18 | { 19 | m_module = ::LoadLibrary(file_path); 20 | 21 | return m_module != nullptr; 22 | } 23 | 24 | /// Release the loaded module 25 | void YCLibrary::Free() 26 | { 27 | if (m_module == nullptr) 28 | return; 29 | 30 | ::FreeLibrary(m_module); 31 | m_module = nullptr; 32 | } 33 | 34 | /// Gets the function address 35 | /// 36 | /// @param proc_name Name of the function 37 | /// 38 | FARPROC YCLibrary::GetProcAddress(LPCTSTR proc_name) const 39 | { 40 | if (m_module == nullptr) 41 | return nullptr; 42 | 43 | // Done as a last resort because there is no GetProcAddressW 44 | const YCStringA string_proc_name = proc_name; 45 | 46 | return ::GetProcAddress(m_module, string_proc_name); 47 | } 48 | -------------------------------------------------------------------------------- /Base/YCLibrary.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /// LoadLibrary API Wrapper Class 4 | class YCLibrary final 5 | { 6 | public: 7 | YCLibrary(); 8 | ~YCLibrary(); 9 | 10 | bool Load(LPCTSTR file_path); 11 | void Free(); 12 | 13 | FARPROC GetProcAddress(LPCTSTR proc_name) const; 14 | 15 | protected: 16 | HMODULE m_module = nullptr; 17 | }; 18 | -------------------------------------------------------------------------------- /Base/YCLocalMemory.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "YCLocalMemory.h" 3 | 4 | YCLocalMemory::YCLocalMemory() 5 | { 6 | } 7 | 8 | YCLocalMemory::~YCLocalMemory() 9 | { 10 | // Free memory 11 | Free(); 12 | } 13 | 14 | /// Allocation of memory 15 | /// 16 | /// @param flags Flags 17 | /// @param bytes Bytes to allocate 18 | /// 19 | bool YCLocalMemory::Alloc(u32 flags, u32 bytes) 20 | { 21 | m_memory_handle = ::LocalAlloc(flags, bytes); 22 | 23 | if (m_memory_handle == nullptr) 24 | throw std::bad_alloc(); 25 | 26 | return m_memory_handle != nullptr; 27 | } 28 | 29 | /// Release Memory 30 | bool YCLocalMemory::Free() 31 | { 32 | Unlock(); 33 | 34 | if (m_memory_handle != nullptr) 35 | { 36 | if (::LocalFree(m_memory_handle) != nullptr) 37 | return false; 38 | 39 | m_memory_handle = nullptr; 40 | } 41 | 42 | return true; 43 | } 44 | 45 | /// Lock Memory 46 | void* YCLocalMemory::Lock() 47 | { 48 | m_memory_ptr = ::LocalLock(m_memory_handle); 49 | 50 | return m_memory_ptr; 51 | } 52 | 53 | /// Unlock Memory 54 | bool YCLocalMemory::Unlock() 55 | { 56 | if (m_memory_ptr != nullptr) 57 | { 58 | while (::LocalUnlock(m_memory_handle)); 59 | m_memory_ptr = nullptr; 60 | } 61 | 62 | return true; 63 | } 64 | 65 | /// Get Memory Size 66 | u32 YCLocalMemory::GetSize() const 67 | { 68 | if (m_memory_handle == nullptr) 69 | return 0; 70 | 71 | return ::LocalSize(m_memory_handle); 72 | } 73 | 74 | /// Get Memory Handle 75 | HLOCAL& YCLocalMemory::GetHandle() 76 | { 77 | return m_memory_handle; 78 | } 79 | 80 | /// Get Memory Pointer 81 | void* YCLocalMemory::GetPtr() const 82 | { 83 | return m_memory_ptr; 84 | } 85 | -------------------------------------------------------------------------------- /Base/YCLocalMemory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /// Local Memory Class 4 | class YCLocalMemory final 5 | { 6 | public: 7 | YCLocalMemory(); 8 | ~YCLocalMemory(); 9 | 10 | bool Alloc(u32 flags, u32 bytes); 11 | bool Free(); 12 | 13 | void* Lock(); 14 | bool Unlock(); 15 | 16 | u32 GetSize() const; 17 | 18 | HLOCAL& GetHandle(); 19 | void* GetPtr() const; 20 | 21 | protected: 22 | HLOCAL m_memory_handle = nullptr; 23 | void* m_memory_ptr = nullptr; 24 | }; 25 | -------------------------------------------------------------------------------- /Base/YCStdioFile.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "YCFile.h" 4 | 5 | //---------------------------------------------------------------------------------------- 6 | //-- Text File Class --------------------------------------------------------------------- 7 | //---------------------------------------------------------------------------------------- 8 | 9 | class YCStdioFile : public YCFile 10 | { 11 | public: 12 | YCStdioFile(); 13 | ~YCStdioFile() override; 14 | 15 | YCStdioFile(const YCStdioFile&) = delete; 16 | YCStdioFile& operator=(const YCStdioFile&) = delete; 17 | 18 | YCStdioFile(YCStdioFile&&) = default; 19 | YCStdioFile& operator=(YCStdioFile&&) = default; 20 | 21 | bool Open(LPCTSTR file_path, u32 open_flags) override; 22 | void Close() override; 23 | 24 | DWORD Read(void* buffer, u32 read_size) override; 25 | DWORD Write(const void* buffer, u32 write_size) override; 26 | 27 | virtual LPTSTR ReadString(LPTSTR buffer, u32 buffer_size); 28 | virtual bool ReadString(YCString& buffer); 29 | virtual void WriteString(LPCTSTR buffer); 30 | 31 | u64 Seek(s64 offset, SeekMode seek_mode) override; 32 | 33 | private: 34 | using FilePtr = std::unique_ptr; 35 | FilePtr m_stream; 36 | }; 37 | -------------------------------------------------------------------------------- /Base/YCString.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lioncash/ExtractData/e42dde4e96f00be68ac36f1b5b09b4a3211bd10a/Base/YCString.h -------------------------------------------------------------------------------- /Error.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Error.h" 3 | 4 | extern bool g_bThreadEnd; 5 | 6 | // Function that displays the error message obtained by GetLastError() 7 | void CError::LastError(HWND hWnd) 8 | { 9 | g_bThreadEnd = true; 10 | LPTSTR lpMsgBuf = nullptr; 11 | FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 12 | nullptr, 13 | GetLastError(), 14 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language 15 | lpMsgBuf, 16 | 0, 17 | nullptr); 18 | 19 | if (lpMsgBuf) 20 | { 21 | MessageBox(hWnd, lpMsgBuf, _T("Error"), MB_OK | MB_ICONINFORMATION); 22 | LocalFree(lpMsgBuf); 23 | } 24 | } 25 | 26 | void CError::Message(HWND hWnd, LPCTSTR mes, ...) 27 | { 28 | TCHAR string[1024]; 29 | va_list list; 30 | 31 | va_start(list, mes); 32 | wvsprintf(string, mes, list); 33 | va_end(list); 34 | 35 | g_bThreadEnd = true; 36 | MessageBox(hWnd, string, _T("Error"), MB_OK | MB_ICONSTOP); 37 | } 38 | 39 | void CError::bad_alloc(HWND hWnd) 40 | { 41 | g_bThreadEnd = TRUE; 42 | Message(hWnd, _T("You do not have enough free memory...")); 43 | } 44 | -------------------------------------------------------------------------------- /Error.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class CError 7 | { 8 | public: 9 | void LastError(HWND hWnd); 10 | void Message(HWND hWnd, LPCTSTR mes, ...); 11 | void bad_alloc(HWND hWnd); 12 | }; 13 | -------------------------------------------------------------------------------- /Extract.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CArcFile; 4 | class CExtractBase; 5 | class CSearchBase; 6 | 7 | class CExtract 8 | { 9 | public: 10 | CExtract(); 11 | void SetClass(); 12 | void SetSearchClass(); 13 | static bool Mount(CArcFile* archive); 14 | static bool Decode(CArcFile* archive, bool convert); 15 | static bool Search(CArcFile* archive); 16 | void Close(); 17 | 18 | private: 19 | static std::vector m_class; 20 | static std::vector m_search_class; 21 | static std::set m_decode_class; 22 | }; 23 | -------------------------------------------------------------------------------- /Extract/AOS.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CAOS final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | private: 12 | struct SABMHeader 13 | { 14 | BITMAPFILEHEADER bmp_file_header; // Bitmap File Header 15 | BITMAPINFOHEADER bmp_info_header; // Bitmap Info Header 16 | u16 unknown[2]; // Unknown 17 | u32 frames; // Number of frames 18 | }; 19 | 20 | bool DecodeABM(CArcFile* archive); 21 | bool DecodeMask(CArcFile* archive); 22 | bool DecodeScript(CArcFile* archive); 23 | 24 | bool DecompABM(u8* dst, size_t dst_size, const u8* src, size_t src_size); 25 | bool DecompScript(u8* dst, size_t dst_size, const u8* src, size_t src_size); 26 | 27 | u32 CreateHuffmanTable(u32* bit0_table, u32* bit1_table, const u8* src, size_t* src_ptr, size_t* table_ptr, u32* current_src, u32* bit_shift); 28 | bool DecompHuffman(u8* dst, size_t dst_size, const u32* bit0_table, const u32* bit1_table, const u8* src, size_t dwRoot, u32 current_src, u32 bit_shift); 29 | }; 30 | -------------------------------------------------------------------------------- /Extract/Ahx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lioncash/ExtractData/e42dde4e96f00be68ac36f1b5b09b4a3211bd10a/Extract/Ahx.cpp -------------------------------------------------------------------------------- /Extract/Ahx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CAhx final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | void Decode(CArcFile* archive, const u8* ahx_buf, size_t ahx_buf_len); 12 | int Decompress(u8* dst, const u8* src, int srclen); 13 | }; 14 | -------------------------------------------------------------------------------- /Extract/Alcot.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lioncash/ExtractData/e42dde4e96f00be68ac36f1b5b09b4a3211bd10a/Extract/Alcot.cpp -------------------------------------------------------------------------------- /Extract/Alcot.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CAlcot final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | private: 12 | bool DecodeASB(CArcFile* archive); 13 | bool DecodeCPB(CArcFile* archive); 14 | 15 | void Decomp(u8* dst, size_t dst_size, const u8* src); 16 | void Decrypt(u8* src, size_t src_size, size_t dst_size); 17 | }; 18 | -------------------------------------------------------------------------------- /Extract/Aselia.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lioncash/ExtractData/e42dde4e96f00be68ac36f1b5b09b4a3211bd10a/Extract/Aselia.cpp -------------------------------------------------------------------------------- /Extract/Aselia.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CAselia final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | }; 10 | -------------------------------------------------------------------------------- /Extract/Axl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CAxl final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | private: 12 | void InitMountKey(const void* decryption_key); 13 | bool CreateKey(u8* key, size_t* key_length, const u8* index, size_t index_size); 14 | bool DecryptIndex(u8* index, size_t index_size, u64 archive_size); 15 | 16 | std::array m_decryption_key{}; 17 | size_t m_length = 0; 18 | }; 19 | -------------------------------------------------------------------------------- /Extract/Baldr.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Extract/Baldr.h" 3 | 4 | #include "ArcFile.h" 5 | #include "Common.h" 6 | 7 | namespace 8 | { 9 | 10 | struct SPACFileInfo 11 | { 12 | char filename[64]; 13 | u32 offset; 14 | u32 file_size; 15 | u32 compressed_file_size; 16 | }; 17 | 18 | } // Anonymous namespace 19 | 20 | /// Mounting 21 | /// 22 | /// @param archive Archive 23 | /// 24 | bool CBaldr::Mount(CArcFile* archive) 25 | { 26 | if (archive->GetArcExten() != _T(".pac")) 27 | return false; 28 | 29 | if (memcmp(archive->GetHeader(), "PAC", 3) != 0) 30 | return false; 31 | 32 | if (memcmp(&archive->GetHeader()[72], "\0\0\0\0", 4) != 0) 33 | return false; 34 | 35 | // Get filecount 36 | u32 num_files; 37 | archive->Seek(4, FILE_BEGIN); 38 | archive->ReadU32(&num_files); 39 | 40 | // Get flags 41 | u32 flags; 42 | archive->ReadU32(&flags); 43 | 44 | // Get compressed formats 45 | YCString format; 46 | switch (flags) 47 | { 48 | case 0: // No compression 49 | break; 50 | 51 | case 1: // LZSS 52 | format = _T("LZ"); 53 | break; 54 | 55 | case 2: // Unknown 56 | break; 57 | 58 | case 3: // ZLIB 59 | format = _T("zlib"); 60 | break; 61 | } 62 | 63 | // Get index 64 | std::vector file_indices(num_files); 65 | archive->Read(file_indices.data(), sizeof(SPACFileInfo) * num_files); 66 | 67 | // Get file info 68 | for (const auto& entry : file_indices) 69 | { 70 | // Get filename 71 | char filename[65]; 72 | memcpy(filename, entry.filename, 64); 73 | filename[64] = '\0'; 74 | 75 | if (strlen(filename) <= 4) 76 | { 77 | archive->SeekHed(); 78 | return false; 79 | } 80 | 81 | // Add to listview 82 | SFileInfo file_info; 83 | file_info.name = filename; 84 | file_info.size_org = entry.file_size; 85 | file_info.size_cmp = entry.compressed_file_size; 86 | file_info.start = entry.offset; 87 | file_info.end = file_info.start + file_info.size_cmp; 88 | file_info.format = format; 89 | 90 | archive->AddFileInfo(file_info); 91 | } 92 | 93 | return true; 94 | } 95 | -------------------------------------------------------------------------------- /Extract/Baldr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CBaldr final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | }; 10 | -------------------------------------------------------------------------------- /Extract/Circus.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CCircus final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | private: 12 | struct SPCMHeader; 13 | 14 | bool MountPCK(CArcFile* archive); 15 | bool MountVoiceDat(CArcFile* archive); 16 | bool MountCRX(CArcFile* archive); 17 | bool MountPCM(CArcFile* archive); 18 | 19 | bool DecodeCRX(CArcFile* archive); 20 | bool DecodeCRX1(CArcFile* archive, const u8* src, size_t src_size); 21 | bool DecodeCRX2(CArcFile* archive, const u8* src, size_t src_size); 22 | bool DecodePCM(CArcFile* archive); 23 | bool DecodePCM1(CArcFile* archive, const SPCMHeader& pcm_header); 24 | bool DecodePCM2(CArcFile* archive, const SPCMHeader& pcm_header); 25 | 26 | bool DecompLZSS(u8* dst, size_t dst_size, const u8* src, size_t src_size); 27 | bool DecompCRX2(u8* dst, size_t dst_size, const u8* src, size_t src_size, s32 width, s32 height, u16 bpp, u16 flags); 28 | bool DecompPCM1(u8* dst, size_t dst_size, const u8* src, size_t src_size); 29 | bool DecompPCM2(u8* dst, size_t dst_size, const u8* src, size_t src_size); 30 | }; 31 | -------------------------------------------------------------------------------- /Extract/CircusPak.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lioncash/ExtractData/e42dde4e96f00be68ac36f1b5b09b4a3211bd10a/Extract/CircusPak.cpp -------------------------------------------------------------------------------- /Extract/CircusPak.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CCircusPak final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | private: 12 | using DecryptionFunction = void(*)(u8*, size_t, const u8*); 13 | 14 | bool MountPakForKujiraCons(CArcFile* archive); 15 | bool MountPakForKujira(CArcFile* archive); 16 | bool MountPakForACDC(CArcFile* archive); 17 | bool MountPakForDCGS(CArcFile* archive); 18 | 19 | bool DecodePakForKujiraCons(CArcFile* archive); 20 | bool DecodePakForKujira(CArcFile* archive); 21 | bool DecodePakForACDC(CArcFile* archive); 22 | bool DecodePakForDCGS(CArcFile* archive); 23 | 24 | bool DecodeBMP(CArcFile* archive, const u8* src, size_t src_size); 25 | bool DecodeCps(CArcFile* archive, const u8* src, size_t src_size); 26 | bool DecodeEtc(CArcFile* archive, DecryptionFunction decryption_function, const u8* key); 27 | 28 | bool DecompCCC0(u8* dst, size_t dst_size, const u8* src, size_t src_size); 29 | bool DecompCCM0(u8* dst, size_t dst_size, const u8* src, size_t src_size); 30 | 31 | u32 GetBit(const u8* src, size_t* src_bit_idx, u32 num_bits_to_read); 32 | 33 | static void Decrypt1(u8* target, size_t target_size, const u8* key); 34 | static void Decrypt2(u8* target, size_t target_size, const u8* key); 35 | }; 36 | -------------------------------------------------------------------------------- /Extract/Clannad.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CClannad final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | }; 11 | -------------------------------------------------------------------------------- /Extract/Cyc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CCyc final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | private: 12 | // References gtb, Mount gpk (dwq has been archived) 13 | bool MountGpk(CArcFile* archive); 14 | // References vtb, Mount vpk (wgq has been archived) 15 | bool MountVpk(CArcFile* archive); 16 | // Mount dwq (BMP: PACKTYPE=0, PACKBMP+MASK: PACKTYPE=3A, JPEG: PACKTYPE=5, JPEG+MASK: PACKTYPE=7A) 17 | bool MountDwq(CArcFile* archive); 18 | // Mount wgq (OGG: PACKTYPE=6) 19 | bool MountWgq(CArcFile* archive); 20 | // Mount vaw (WAV: PACKTYPE=0, RIFF OGG: PACKTYPE=2) 21 | bool MountVaw(CArcFile* archive); 22 | // Mount xtx (Text Data) 23 | bool MountXtx(CArcFile* archive); 24 | // Mount fxf (Inverted data bit xtx) 25 | bool MountFxf(CArcFile* archive); 26 | 27 | // Decode dwq 28 | bool DecodeDwq(CArcFile* archive); 29 | // Decode wgq 30 | bool DecodeWgq(CArcFile* archive); 31 | // Decode vaw 32 | bool DecodeVaw(CArcFile* archive); 33 | // Decode xtx 34 | bool DecodeXtx(CArcFile* archive); 35 | // Decode fxf 36 | bool DecodeFxf(CArcFile* archive); 37 | 38 | // RLE decompression to dst 39 | void DecompRLE(u8* dst, const u8* src, s32 width, s32 height); 40 | // RGB to BGR 41 | void RGBtoBGR(u8* buf, s32 width, s32 height); 42 | }; 43 | -------------------------------------------------------------------------------- /Extract/EntisGLS.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lioncash/ExtractData/e42dde4e96f00be68ac36f1b5b09b4a3211bd10a/Extract/EntisGLS.cpp -------------------------------------------------------------------------------- /Extract/EntisGLS.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CEntisGLS final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | }; 11 | -------------------------------------------------------------------------------- /Extract/Ethornell.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CEthornell final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | private: 12 | bool DecodeBSE(CArcFile* archive); 13 | bool DecodeDSC(CArcFile* archive); 14 | bool DecodeCBG(CArcFile* archive); 15 | bool DecodeStd(CArcFile* archive); 16 | 17 | bool DecodeBSE10(u8* data); 18 | bool DecodeBSE11(u8* data); 19 | 20 | u32 GetKey(u32* key); 21 | s32 GetKeyBSE10(s32* key); 22 | s32 GetKeyBSE11(s32* key); 23 | 24 | u32 GetVariableData(const u8* src, size_t* read_length); 25 | 26 | void DecompDSC(u8* dst, size_t dst_size, const u8* src, size_t src_size); 27 | void DecompCBG(u8* dst, u8* src); 28 | 29 | void DecryptBGType1(u8* dst, const u8* src, s32 width, s32 height, u16 bpp); 30 | }; 31 | -------------------------------------------------------------------------------- /Extract/FateFD.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CFateFD : public CExtractBase 4 | { 5 | protected: 6 | // Decode Info 7 | struct DecodeInfo 8 | { 9 | BYTE key; 10 | DWORD size; 11 | }; 12 | 13 | public: 14 | BOOL Mount(CArcFile* pclArc); 15 | BOOL Decode(CArcFile* pclArc); 16 | }; 17 | -------------------------------------------------------------------------------- /Extract/Himauri.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lioncash/ExtractData/e42dde4e96f00be68ac36f1b5b09b4a3211bd10a/Extract/Himauri.cpp -------------------------------------------------------------------------------- /Extract/Himauri.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CHimauri final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | private: 12 | bool MountHim4(CArcFile* archive); 13 | bool MountHim5(CArcFile* archive); 14 | 15 | void Decomp(u8* dst, size_t dst_size, const u8* src, size_t src_size); 16 | bool Compose(u8* dst, size_t dst_size, const u8* base, size_t base_size, const u8* diff, size_t diff_size); 17 | }; 18 | -------------------------------------------------------------------------------- /Extract/InnocentGrey.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CInnocentGrey final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | }; 11 | -------------------------------------------------------------------------------- /Extract/Izumo.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Extract/Izumo.h" 3 | 4 | #include "ArcFile.h" 5 | #include "Common.h" 6 | 7 | // Function to get file information from IZUMO *.dat files 8 | bool CIzumo::Mount(CArcFile* archive) 9 | { 10 | if (archive->GetArcExten() != _T(".dat") || memcmp(archive->GetHeader(), "PAK0", 4) != 0) 11 | return false; 12 | 13 | // Get index size (Starting address of the first file) 14 | u32 index_size; 15 | archive->Seek(4, FILE_BEGIN); 16 | archive->ReadU32(&index_size); 17 | 18 | // Get number of bytes to be skipped 19 | u32 dummy; 20 | archive->ReadU32(&dummy); 21 | const u32 skip = dummy << 3; 22 | 23 | // Get file count 24 | u32 num_files; 25 | archive->ReadU32(&num_files); 26 | 27 | // Skip unknown data 28 | archive->Seek(skip, FILE_CURRENT); 29 | 30 | // Skip segments 31 | index_size -= 16 + skip; 32 | 33 | // Get index 34 | std::vector index(index_size); 35 | archive->Read(index.data(), index.size()); 36 | const u8* index_ptr = index.data(); 37 | 38 | // Get filename index 39 | const u8* file_name_index = index_ptr + (num_files << 4); 40 | 41 | // Remove unneeded filenames 42 | for (u32 i = 1; i < dummy; i++) 43 | { 44 | file_name_index += file_name_index[0] + 1; 45 | } 46 | 47 | for (u32 i = 0; i < num_files; i++) 48 | { 49 | // Get file name 50 | TCHAR file_name[256]; 51 | const u8 len = *file_name_index++; 52 | memcpy(file_name, file_name_index, len); 53 | file_name[len] = _T('\0'); 54 | 55 | // Add to list view 56 | SFileInfo file_info; 57 | file_info.name = file_name; 58 | file_info.size_org = *reinterpret_cast(&index_ptr[4]); 59 | file_info.size_cmp = file_info.size_org; 60 | file_info.start = *reinterpret_cast(&index_ptr[0]); 61 | file_info.end = file_info.start + file_info.size_cmp; 62 | archive->AddFileInfo(file_info); 63 | 64 | index_ptr += 16; 65 | file_name_index += len; 66 | } 67 | 68 | return true; 69 | } 70 | -------------------------------------------------------------------------------- /Extract/Izumo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CIzumo final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | }; 10 | -------------------------------------------------------------------------------- /Extract/Katakoi.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CKatakoi final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | private: 12 | bool MountIar(CArcFile* archive); 13 | bool MountWar(CArcFile* archive); 14 | 15 | bool DecodeIar(CArcFile* archive); 16 | bool DecodeWar(CArcFile* archive); 17 | 18 | bool GetNameIndex(CArcFile* archive, std::vector& sec, u32& name_index); 19 | bool GetPathToSec(LPTSTR sec_path, const YCString& archive_path); 20 | 21 | void GetBit(const u8*& src, u32& flags); 22 | bool DecompImage(u8* dst, size_t dst_size, const u8* src, size_t src_size); 23 | 24 | bool Compose(u8* dst, size_t dst_size, const u8* src, size_t src_size, s32 dst_width, s32 src_width, u16 bpp); 25 | bool DecodeCompose(CArcFile* archive, const u8* diff, size_t diff_size, s32 diff_width, s32 diff_height, u16 diff_bpp); 26 | }; 27 | -------------------------------------------------------------------------------- /Extract/LostChild.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CLostChild final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | bool Extract(CArcFile* archive) override; 11 | 12 | private: 13 | bool DecodeESUR(CArcFile* archive); 14 | bool DecodeLAD(CArcFile* archive); 15 | 16 | bool DecompLZSS(u8* dst, size_t dst_size, const u8* src, size_t src_size, size_t dic_size, size_t dic_ptr, size_t length_offset); 17 | }; 18 | -------------------------------------------------------------------------------- /Extract/Majiro.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lioncash/ExtractData/e42dde4e96f00be68ac36f1b5b09b4a3211bd10a/Extract/Majiro.cpp -------------------------------------------------------------------------------- /Extract/Majiro.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CMajiro final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | private: 12 | bool MountArc1(CArcFile* archive); 13 | bool MountArc2(CArcFile* archive); 14 | bool MountMJO(CArcFile* archive); 15 | bool MountRC(CArcFile* archive); 16 | 17 | bool DecodeMJO(CArcFile* archive); 18 | bool DecodeRC(CArcFile* archive); 19 | 20 | void read_bits_24(u8* dst, size_t dst_size, const u8* src, size_t src_size, s32 width); 21 | void read_bits_8(u8* dst, size_t dst_size, const u8* src, size_t src_size, s32 width); 22 | 23 | bool AppendMask(CArcFile* archive, u8* dst, size_t dst_size, const u8* src, size_t src_size); 24 | }; 25 | -------------------------------------------------------------------------------- /Extract/MeltyBlood.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CMeltyBlood final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | private: 12 | void Decrypt(CArcFile* archive); 13 | }; 14 | -------------------------------------------------------------------------------- /Extract/Navel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CNavel final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | private: 12 | bool MountPac(CArcFile* archive); 13 | bool MountWpd(CArcFile* archive); 14 | }; 15 | -------------------------------------------------------------------------------- /Extract/Nitro.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lioncash/ExtractData/e42dde4e96f00be68ac36f1b5b09b4a3211bd10a/Extract/Nitro.cpp -------------------------------------------------------------------------------- /Extract/Nitro.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | struct SFileInfo; 6 | 7 | class CNitro final : public CExtractBase 8 | { 9 | public: 10 | bool Mount(CArcFile* archive) override; 11 | bool Decode(CArcFile* archive) override; 12 | 13 | private: 14 | bool MountPak1(CArcFile* archive); 15 | bool MountPak2(CArcFile* archive); 16 | bool MountPak3(CArcFile* archive); 17 | bool MountPak4(CArcFile* archive); 18 | bool MountPK2(CArcFile* archive); 19 | bool MountN3Pk(CArcFile* archive); 20 | bool MountPck(CArcFile* archive); 21 | bool MountNpp(CArcFile* archive); 22 | bool MountNpa(CArcFile* archive); 23 | 24 | bool DecodePak1(CArcFile* archive); 25 | bool DecodePak3(CArcFile* archive); 26 | bool DecodePak4(CArcFile* archive); 27 | bool DecodePK2(CArcFile* archive); 28 | bool DecodeN3Pk(CArcFile* archive); 29 | bool DecodeNpa(CArcFile* archive); 30 | 31 | void DecryptPak3(u8* data, size_t size, size_t offset, const SFileInfo* file_info); 32 | void DecryptPak4(u8* data, size_t size, size_t offset, const SFileInfo* file_info); 33 | void DecryptN3Pk(u8* data, size_t size, size_t offset, const SFileInfo* file_info, u8& key); 34 | void DecryptNpa(u8* data, size_t size, size_t offset, const SFileInfo* file_info); 35 | }; 36 | -------------------------------------------------------------------------------- /Extract/Nscr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CNscr final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | private: 12 | bool MountNsa(CArcFile* archive); 13 | bool MountSar(CArcFile* archive); 14 | bool MountScr(CArcFile* archive); 15 | 16 | bool DecodeScr(CArcFile* archive); 17 | bool DecodeNBZ(CArcFile* archive); 18 | bool DecodeSPB(CArcFile* archive); 19 | bool DecodeLZSS(CArcFile* archive); 20 | 21 | void GetFileExt(YCString& dst, const u8* buffer); 22 | u32 GetBit(const u8* src, size_t num_bits_to_read, size_t* num_bytes_read); 23 | 24 | u8 m_mask_for_get_bit = 0; 25 | u8 m_src_for_get_bit = 0; 26 | }; 27 | -------------------------------------------------------------------------------- /Extract/Oyatu.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lioncash/ExtractData/e42dde4e96f00be68ac36f1b5b09b4a3211bd10a/Extract/Oyatu.cpp -------------------------------------------------------------------------------- /Extract/Oyatu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class COyatu final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | private: 12 | bool IsSupported(CArcFile* archive); 13 | 14 | bool DecodeSound(CArcFile* archive, const u8* key); 15 | bool DecodeBGM(CArcFile* archive); 16 | bool DecodeKOE(CArcFile* archive); 17 | bool DecodeMSE(CArcFile* archive); 18 | }; 19 | -------------------------------------------------------------------------------- /Extract/Pajamas.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CPajamas final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | private: 12 | bool MountDat1(CArcFile* archive); 13 | bool MountDat2(CArcFile* archive); 14 | 15 | bool DecodeEPA(CArcFile* archive); 16 | void DecompEPA(u8* dst, size_t dst_size, const u8* src, size_t src_size, u32 width); 17 | }; 18 | -------------------------------------------------------------------------------- /Extract/QLIE.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lioncash/ExtractData/e42dde4e96f00be68ac36f1b5b09b4a3211bd10a/Extract/QLIE.cpp -------------------------------------------------------------------------------- /Extract/QLIE.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CQLIE final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | private: 12 | enum 13 | { 14 | ABIMGDAT10 = 0x00000000, 15 | ABIMGDAT11, 16 | ABSNDDAT10, 17 | ABSNDDAT11, 18 | }; 19 | 20 | struct FileNameInfo 21 | { 22 | YCString file_name; // Filename 23 | u32 count; // Number of times 24 | }; 25 | 26 | bool DecodeB(CArcFile* archive, u8* src, u32 src_size); 27 | bool DecodeABMP7(CArcFile* archive, u8* src, u32 src_size); 28 | bool DecodeABMP10(CArcFile* archive, u8* src, u32 src_size, u32* src_index_ptr = nullptr, const YCString& b_file_name = _T("")); 29 | 30 | void Decomp(u8* dst, u32 dst_size, const u8* src, u32 src_size); 31 | 32 | static void DecryptFileName(u8* in, u32 size, u32 seed); 33 | static void Decrypt(u8* buf, u32 buf_len, u32 seed); 34 | 35 | u64 padw(u64 a, u64 b); 36 | u32 crc_or_something(const u8* buff, size_t len); 37 | static void DecryptFileNameV3(u8* buff, u32 len, u32 seed); 38 | static void DecryptV3(u8* buff, u32 len, u32 seed); 39 | 40 | YCString GetExtension(const u8* src); 41 | 42 | void EraseNotUsePathWord(YCString& path); 43 | }; 44 | -------------------------------------------------------------------------------- /Extract/Retouch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CRetouch final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | private: 12 | bool MountGYU(CArcFile* archive); 13 | 14 | bool DecodeGYU(CArcFile* archive); 15 | 16 | bool DecryptGYU(u8* src, size_t src_size, u32 key); 17 | 18 | bool DecompGYU(u8* dst, size_t dst_size, const u8* src, size_t src_size); 19 | }; 20 | -------------------------------------------------------------------------------- /Extract/Spitan.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lioncash/ExtractData/e42dde4e96f00be68ac36f1b5b09b4a3211bd10a/Extract/Spitan.cpp -------------------------------------------------------------------------------- /Extract/Spitan.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CSpitan final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | 10 | private: 11 | bool MountSound(CArcFile* archive); 12 | bool MountGraphic1(CArcFile* archive); 13 | bool MountGraphic2(CArcFile* archive); 14 | bool MountGraphic3(CArcFile* archive); 15 | }; 16 | -------------------------------------------------------------------------------- /Extract/Standard.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Extract/Standard.h" 3 | 4 | #include "ArcFile.h" 5 | #include "Arc/LZSS.h" 6 | #include "Arc/Zlib.h" 7 | #include "Common.h" 8 | #include "Extract/Ahx.h" 9 | #include "Image.h" 10 | #include "Sound/Ogg.h" 11 | 12 | /// Mounting 13 | bool CStandard::Mount(CArcFile* archive) 14 | { 15 | // Get file info 16 | SFileInfo file_info; 17 | file_info.name = archive->GetArcName(); 18 | file_info.size_org = archive->GetArcSize(); 19 | file_info.size_cmp = file_info.size_org; 20 | file_info.start = 0; 21 | file_info.end = file_info.size_org; 22 | 23 | archive->AddFileInfo(file_info); 24 | 25 | return true; 26 | } 27 | 28 | /// Decoding 29 | bool CStandard::Decode(CArcFile* archive) 30 | { 31 | if (DecodeLZSS(archive)) 32 | return true; 33 | 34 | if (DecodeZlib(archive)) 35 | return true; 36 | 37 | if (DecodeAhx(archive)) 38 | return true; 39 | 40 | if (DecodeImage(archive)) 41 | return true; 42 | 43 | if (DecodeOgg(archive)) 44 | return true; 45 | 46 | return Extract(archive); 47 | } 48 | 49 | /// LZSS Decoding 50 | bool CStandard::DecodeLZSS(CArcFile* archive) 51 | { 52 | CLZSS lzss; 53 | 54 | return lzss.Decode(archive); 55 | } 56 | 57 | /// zlib Decoding 58 | bool CStandard::DecodeZlib(CArcFile* archive) 59 | { 60 | CZlib zlib; 61 | 62 | return zlib.Decode(archive); 63 | } 64 | 65 | /// AHX Decoding 66 | bool CStandard::DecodeAhx(CArcFile* archive) 67 | { 68 | CAhx ahx; 69 | 70 | return ahx.Decode(archive); 71 | } 72 | 73 | /// Image Decoding 74 | bool CStandard::DecodeImage(CArcFile* archive) 75 | { 76 | CImage image; 77 | 78 | return image.Decode(archive); 79 | } 80 | 81 | /// Ogg Vorbis Decoding 82 | bool CStandard::DecodeOgg(CArcFile* archive) 83 | { 84 | COgg ogg; 85 | 86 | return ogg.Decode(archive); 87 | } 88 | 89 | /// Extraction 90 | bool CStandard::Extract(CArcFile* archive) 91 | { 92 | archive->OpenFile(); 93 | archive->ReadWrite(); 94 | archive->CloseFile(); 95 | 96 | return true; 97 | } 98 | -------------------------------------------------------------------------------- /Extract/Standard.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CStandard : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | bool Extract(CArcFile* archive) override; 11 | 12 | protected: 13 | virtual bool DecodeLZSS(CArcFile* archive); 14 | virtual bool DecodeZlib(CArcFile* archive); 15 | virtual bool DecodeAhx(CArcFile* archive); 16 | virtual bool DecodeImage(CArcFile* archive); 17 | virtual bool DecodeOgg(CArcFile* archive); 18 | }; 19 | -------------------------------------------------------------------------------- /Extract/SummerDays.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CSummerDays final : public CExtractBase 6 | { 7 | public: 8 | CSummerDays(); 9 | ~CSummerDays() override; 10 | 11 | bool Mount(CArcFile* archive) override; 12 | 13 | private: 14 | struct Context; 15 | 16 | bool Sub(CArcFile* archive, LPTSTR path); 17 | u16 CreateNewContext(CArcFile* archive, u16 length); 18 | int FindContextTypeWithCode(u16 code); 19 | 20 | std::vector m_contexts; 21 | u16 m_context_count = 0; 22 | 23 | u32 m_rest_archive_size = 0; 24 | }; 25 | -------------------------------------------------------------------------------- /Extract/TCD/TCD2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Extract/TCD/TCDBase.h" 4 | 5 | class CTCD2 final : public CTCDBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | 10 | private: 11 | bool DecompRLE2(u8* dst, size_t dst_size, const u8* src, size_t src_size) override; 12 | }; 13 | -------------------------------------------------------------------------------- /Extract/TCD/TCD3.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lioncash/ExtractData/e42dde4e96f00be68ac36f1b5b09b4a3211bd10a/Extract/TCD/TCD3.cpp -------------------------------------------------------------------------------- /Extract/TCD/TCD3.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Extract/TCD/TCDBase.h" 4 | 5 | class CTCD3 final : public CTCDBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | 10 | private: 11 | bool DecompRLE2(u8* dst, size_t dst_size, const u8* src, size_t src_size) override; 12 | }; 13 | -------------------------------------------------------------------------------- /Extract/TCD/TCDBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //---------------------------------------------------------------------------------------- 4 | //-- TCD Base Class ---------------------------------------------------------------------- 5 | //---------------------------------------------------------------------------------------- 6 | 7 | #include "ExtractBase.h" 8 | 9 | class CTCDBase : public CExtractBase 10 | { 11 | public: 12 | bool Mount(CArcFile* archive) override; 13 | bool Decode(CArcFile* archive) override; 14 | 15 | protected: 16 | virtual bool DecodeTCT(CArcFile* archive); 17 | virtual bool DecodeTSF(CArcFile* archive); 18 | virtual bool DecodeSPD(CArcFile* archive); 19 | virtual bool DecodeOgg(CArcFile* archive); 20 | 21 | virtual bool DecompLZSS(u8* dst, size_t dst_size, const u8* src, size_t src_size); 22 | virtual bool DecompRLE0(u8* dst, size_t dst_size, const u8* src, size_t src_size); 23 | virtual bool DecompRLE2(u8* dst, size_t dst_size, const u8* src, size_t src_size); 24 | virtual bool DecompSPD(u8* dst, size_t dst_size, const u8* src, size_t src_size, s32 width); 25 | 26 | virtual bool Decrypt(u8* data, size_t data_size); 27 | }; 28 | -------------------------------------------------------------------------------- /Extract/TH2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CTH2 final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | private: 12 | bool MountKCAP(CArcFile* archive); 13 | bool MountLAC(CArcFile* archive); 14 | bool MountDpl(CArcFile* archive); 15 | bool MountWMV(CArcFile* archive); 16 | 17 | bool DecodeWMV(CArcFile* archive); 18 | bool DecodeEtc(CArcFile* archive); 19 | }; 20 | -------------------------------------------------------------------------------- /Extract/TaskForce.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CTaskForce final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | private: 12 | bool MountDat(CArcFile* archive); 13 | bool MountTlz(CArcFile* archive); 14 | bool MountBma(CArcFile* archive); 15 | 16 | bool DecodeTlz(CArcFile* archive); 17 | bool DecodeBma(CArcFile* archive); 18 | bool DecodeTGA(CArcFile* archive); 19 | }; 20 | -------------------------------------------------------------------------------- /Extract/TrH.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Extract/TrH.h" 3 | 4 | #include "ArcFile.h" 5 | #include "Common.h" 6 | #include "Sound/Wav.h" 7 | 8 | namespace 9 | { 10 | // PX Format 11 | struct PXHeader 12 | { 13 | u8 px_id[4]; // "fPX " 14 | u32 file_size; // File Size 15 | u8 ctrk_id[4]; // "cTRK" 16 | u32 data_size; // Number of bytes of waveform data 17 | u32 dummy1; // Unknown 18 | u32 dummy2; // Unknown 19 | u32 dummy3; // Unknown 20 | u32 freq; // Sampling Rate 21 | u16 dummy4; // Unknown 22 | u16 channels; // Number of channels 23 | u32 chunk_byte; // Number of bytes per chunk 24 | u16 bits; // Number of bits per sample(bit/sample) 25 | u16 format_id; // Format ID 26 | }; 27 | } // Anonymous namespace 28 | 29 | bool CTrH::Mount(CArcFile* archive) 30 | { 31 | if (archive->GetArcExten() != _T(".px") || memcmp(archive->GetHeader(), "fPX ", 4) != 0) 32 | return false; 33 | 34 | return archive->Mount(); 35 | } 36 | 37 | // Function to convert to WAV 38 | bool CTrH::Decode(CArcFile* archive) 39 | { 40 | const SFileInfo* file_info = archive->GetOpenFileInfo(); 41 | 42 | if (file_info->format != _T("PX") || memcmp(archive->GetHeader(), "fPX ", 4) != 0) 43 | return false; 44 | 45 | // Read px header 46 | PXHeader header; 47 | archive->Read(&header, sizeof(PXHeader)); 48 | 49 | // Output 50 | CWav wav; 51 | wav.Init(archive, file_info->size_org - 44, header.freq, header.channels, header.bits); 52 | wav.Write(); 53 | 54 | return true; 55 | } 56 | -------------------------------------------------------------------------------- /Extract/TrH.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CTrH final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | }; 11 | -------------------------------------------------------------------------------- /Extract/VA.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CVA final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | private: 12 | bool MountNwa(CArcFile* archive); 13 | bool MountNwk(CArcFile* archive); 14 | bool MountOvk(CArcFile* archive); 15 | bool DecodeNwa(CArcFile* archive); 16 | 17 | int GetBits(u8*& data, int& shift, int bits); 18 | }; 19 | -------------------------------------------------------------------------------- /Extract/Will.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lioncash/ExtractData/e42dde4e96f00be68ac36f1b5b09b4a3211bd10a/Extract/Will.cpp -------------------------------------------------------------------------------- /Extract/Will.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CWill final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | private: 12 | void DecompLZSS(u8* dst, size_t dst_size, const u8* src, size_t src_size); 13 | 14 | bool AppendMask(u8* dst, size_t dst_size, const u8* src, size_t src_size, const u8* mask, size_t mask_size); 15 | }; 16 | -------------------------------------------------------------------------------- /Extract/Windmill.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CWindmill final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | }; 11 | -------------------------------------------------------------------------------- /Extract/Ykc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CYkc final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | private: 12 | bool DecodeYKS(CArcFile* archive); 13 | bool DecodeYKG(CArcFile* archive); 14 | }; 15 | -------------------------------------------------------------------------------- /Extract/Yuris.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CYuris final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | private: 12 | bool MountYPF(CArcFile* archive); 13 | bool MountYMV(CArcFile* archive); 14 | 15 | bool DecodeYMV(CArcFile* archive); 16 | }; 17 | -------------------------------------------------------------------------------- /Extract/cpz/Cmv.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CCmv final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | }; 11 | -------------------------------------------------------------------------------- /Extract/cpz/Cpz.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../ExtractBase.h" 4 | 5 | struct SFileInfo; 6 | 7 | class CCpz final : public CExtractBase 8 | { 9 | public: 10 | bool Mount(CArcFile* archive) override; 11 | bool Decode(CArcFile* archive) override; 12 | 13 | private: 14 | bool MountCpz1(CArcFile* archive); 15 | bool MountCpz2(CArcFile* archive); 16 | bool MountCpz3(CArcFile* archive); 17 | bool MountCpz5(CArcFile* archive); 18 | 19 | bool DecodeCpz1(CArcFile* archive); 20 | bool DecodeCpz2(CArcFile* archive); 21 | bool DecodeCpz3(CArcFile* archive); 22 | bool DecodeCpz5(CArcFile* archive); 23 | 24 | static void Decrypt1(u8* target, size_t size); 25 | static void Decrypt2(u8* target, size_t size, u32 key); 26 | static void Decrypt3(u8* target, size_t size, u32 key); 27 | static void Decrypt5(u8* target, size_t size, u32 key); 28 | 29 | static const u8* InitDecryptWithTable5(u32 key, u32 seed); 30 | static void DecryptWithTable5(u8* target, size_t size, const u8* decryption_table, u32 key); 31 | static void DecryptOfData5(u8* target, size_t size, const u8* decryption_table, const u32* key, u32 seed); 32 | 33 | // Callback function from PB3B 34 | static void OnDecrypt3FromPB3B(u8* target, size_t target_size, CArcFile* archive, const SFileInfo& file_info); 35 | static void OnDecrypt5FromPB3B(u8* target, size_t target_size, CArcFile* archive, const SFileInfo& file_info); 36 | }; 37 | -------------------------------------------------------------------------------- /Extract/cpz/JBP1.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lioncash/ExtractData/e42dde4e96f00be68ac36f1b5b09b4a3211bd10a/Extract/cpz/JBP1.cpp -------------------------------------------------------------------------------- /Extract/cpz/JBP1.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CJBP1 final 4 | { 5 | public: 6 | void Decomp(u8* pbtDst, const u8* pbtSrc, u16 wBpp = 0, const u8* pbtAlpha = nullptr, u32 dwAlphaSize = 0); 7 | 8 | private: 9 | void DCT(u8* arg1, u8* arg2); 10 | s32 GetNBit(const u8*& lpin, u32 code, u32& bit_buffer, u32& bit_remain); 11 | s32 MakeTree(u8* lp1, s32 size, u32* lp2); 12 | void YCC2RGB(u8* dc, u8* ac, const s16* Y, const s16* CbCr, s32 line); 13 | }; 14 | -------------------------------------------------------------------------------- /Extract/cpz/PB.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "PB.h" 3 | 4 | /// Decompress LZSS 5 | /// 6 | /// @param dst Destination 7 | /// @param dst_size Destination size 8 | /// @param flags Flag data 9 | /// @param flags_size Flag data size 10 | /// @param src Compressed data 11 | /// @param src_size Compressed data size 12 | /// 13 | void CPB::DecompLZSS(u8* dst, size_t dst_size, const u8* flags, size_t flags_size, const u8* src, size_t src_size) 14 | { 15 | // Initialize Dictionary 16 | constexpr size_t dictionary_size = 2048; 17 | std::vector dictionary(dictionary_size); 18 | size_t dictionary_ptr = 2014; 19 | 20 | // Decompress 21 | size_t src_ptr = 0; 22 | size_t flags_ptr = 0; 23 | size_t dst_ptr = 0; 24 | u8 code = 0x80; 25 | 26 | while (src_ptr < src_size && dst_ptr < dst_size && flags_ptr < flags_size) 27 | { 28 | if (code == 0) 29 | { 30 | flags_ptr++; 31 | code = 0x80; 32 | } 33 | 34 | // Is Compressed 35 | if (flags[flags_ptr] & code) 36 | { 37 | const u16 work = *reinterpret_cast(&src[src_ptr]); 38 | 39 | size_t back = work >> 5; 40 | size_t length = (work & 0x1F) + 3; 41 | 42 | // Adjust so that the buffer is not exceeded 43 | if (dst_ptr + length > dst_size) 44 | { 45 | length = dst_size - dst_ptr; 46 | } 47 | 48 | // Dictionary Reference 49 | for (size_t i = 0; i < length; i++) 50 | { 51 | dst[dst_ptr + i] = dictionary[dictionary_ptr++] = dictionary[back++]; 52 | 53 | dictionary_ptr &= dictionary_size - 1; 54 | back &= dictionary_size - 1; 55 | } 56 | 57 | src_ptr += 2; 58 | dst_ptr += length; 59 | } 60 | else // Not compressed 61 | { 62 | dst[dst_ptr++] = dictionary[dictionary_ptr++] = src[src_ptr++]; 63 | 64 | dictionary_ptr &= dictionary_size - 1; 65 | } 66 | 67 | code >>= 1; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Extract/cpz/PB.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CPB 4 | { 5 | public: 6 | virtual ~CPB() = default; 7 | 8 | void DecompLZSS(u8* dst, size_t dst_size, const u8* flags, size_t flags_size, const u8* src, size_t src_size); 9 | }; 10 | -------------------------------------------------------------------------------- /Extract/cpz/PB2A.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Extract/cpz/PB.h" 4 | 5 | class CArcFile; 6 | 7 | class CPB2A final : public CPB 8 | { 9 | public: 10 | bool Decode(CArcFile* archive, u8* src, size_t src_size); 11 | 12 | private: 13 | void Decrypt(u8* target, size_t size); 14 | 15 | bool Decode1(CArcFile* archive, const u8* src, size_t src_size, s32 width, s32 height, u16 bpp); 16 | bool Decode2(CArcFile* archive, const u8* src, size_t src_size, s32 width, s32 height, u16 bpp); 17 | bool Decode4(CArcFile* archive, const u8* src, size_t src_size, s32 width, s32 height, u16 bpp); 18 | bool Decode5(CArcFile* archive, const u8* src, size_t src_size, s32 width, s32 height, u16 bpp); 19 | bool Decode6(CArcFile* archive, const u8* src, size_t src_size, s32 width, s32 height, u16 bpp); 20 | 21 | bool Decomp1(u8* dst, size_t dst_size, const u8* src, size_t src_size, s32 width, s32 height, u16 bpp); 22 | bool Decomp2(u8* dst, size_t dst_size, const u8* src, size_t src_size, s32 width, s32 height, u16 bpp); 23 | bool Decomp4(u8* dst, size_t dst_size, const u8* src, size_t src_size, s32 width, s32 height, u16 bpp); 24 | bool Decomp5(u8* dst, size_t dst_size, const u8* src, size_t src_size, s32 width, s32 height, u16 bpp, const u8* base, u32 frame_number); 25 | bool Decomp6(u8* dst, size_t dst_size, const u8* src, size_t src_size, s32 width, s32 height, u16 bpp, const u8* base, u32 frame_number); 26 | }; 27 | -------------------------------------------------------------------------------- /Extract/cpz/PB3B.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lioncash/ExtractData/e42dde4e96f00be68ac36f1b5b09b4a3211bd10a/Extract/cpz/PB3B.cpp -------------------------------------------------------------------------------- /Extract/cpz/PB3B.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Extract/cpz/PB.h" 4 | 5 | class CArcFile; 6 | struct SFileInfo; 7 | 8 | class CPB3B final : public CPB 9 | { 10 | public: 11 | using PB3B_DECRYPT = void (*)(u8*, size_t, CArcFile*, const SFileInfo&); 12 | 13 | bool Decode(CArcFile* archive, u8* src, size_t src_size, PB3B_DECRYPT decryption_function); 14 | 15 | private: 16 | void Decrypt(u8* target, size_t size); 17 | 18 | bool Decode1(CArcFile* archive, const u8* src, size_t src_size, s32 width, s32 height, u16 bpp); 19 | bool Decode3(CArcFile* archive, const u8* src, size_t src_size, s32 width, s32 height, u16 bpp); 20 | bool Decode4(CArcFile* archive, const u8* src, size_t src_size, s32 width, s32 height, u16 bpp); 21 | bool Decode5(CArcFile* archive, const u8* src, size_t src_size, s32 width, s32 height, u16 bpp); 22 | bool Decode6(CArcFile* archive, const u8* src, size_t src_size, s32 width, s32 height, u16 bpp, PB3B_DECRYPT decryption_function); 23 | 24 | bool Decomp1(u8* dst, size_t dst_size, const u8* src, size_t src_size, s32 width, s32 height, u16 bpp); 25 | bool Decomp3(u8* dst, size_t dst_size, const u8* src, size_t src_size, s32 width, s32 height, u16 bpp); 26 | bool Decomp4(u8* dst, size_t dst_size, const u8* src, size_t src_size, s32 width, s32 height, u16 bpp); 27 | bool Decomp5(u8* dst, size_t dst_size, const u8* src, size_t src_size, s32 width, s32 height, u16 bpp); 28 | bool Decomp6(u8* dst, size_t dst_size, const u8* src, size_t src_size, s32 width, s32 height, u16 bpp); 29 | }; 30 | -------------------------------------------------------------------------------- /Extract/krkr/Braban.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Extract/krkr/Braban.h" 3 | 4 | #include "ArcFile.h" 5 | #include "Common.h" 6 | 7 | /// Determine if decryption is possible 8 | /// 9 | /// @param archive Archive 10 | /// 11 | bool CBraban::OnCheckDecrypt(CArcFile* archive) 12 | { 13 | return CheckTpm("C42B141D42FCBCDA29850FA9E9FE3FF2"); 14 | } 15 | 16 | /// Initialization of the decryption process 17 | /// 18 | /// @param archive Archive 19 | /// 20 | u32 CBraban::OnInitDecrypt(CArcFile* archive) 21 | { 22 | return ((archive->GetOpenFileInfo()->key ^ 0xFF) & 0xFF) - 1; 23 | } 24 | 25 | /// Decryption Process 26 | /// 27 | /// @param target Data to be decoded 28 | /// @param target_size Data size 29 | /// @param offset Location of data to be decoded 30 | /// @param decrypt_key Decryption key 31 | /// 32 | size_t CBraban::OnDecrypt(u8* target, size_t target_size, size_t offset, u32 decrypt_key) 33 | { 34 | const u8 byte_decrypt_key = static_cast(decrypt_key); 35 | 36 | for (size_t i = 0; i < target_size; i++) 37 | { 38 | target[i] ^= byte_decrypt_key; 39 | } 40 | 41 | return target_size; 42 | } 43 | -------------------------------------------------------------------------------- /Extract/krkr/Braban.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Extract/krkr/Krkr.h" 4 | 5 | class CBraban final : public CKrkr 6 | { 7 | public: 8 | bool OnCheckDecrypt(CArcFile* archive) override; 9 | u32 OnInitDecrypt(CArcFile* archive) override; 10 | size_t OnDecrypt(u8* target, size_t target_size, size_t offset, u32 decrypt_key) override; 11 | }; 12 | -------------------------------------------------------------------------------- /Extract/krkr/Fate.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Extract/krkr/Fate.h" 3 | 4 | #include "ArcFile.h" 5 | 6 | /// Determine if decryption is possible 7 | /// 8 | /// @param archive Archive 9 | /// 10 | bool CFate::OnCheckDecrypt(CArcFile* archive) 11 | { 12 | static const std::array md5 = {{ 13 | "4BE5F676CE80429B3245DA9E721FE23B", 14 | "7570E3AFA14F221268DCC48CAEE1277F", 15 | }}; 16 | 17 | return std::any_of(md5.begin(), md5.end(), [this](const char* str) { return CheckTpm(str); }); 18 | } 19 | 20 | /// Initialization of Decryption Routine 21 | /// 22 | /// @param archive Archive 23 | /// 24 | u32 CFate::OnInitDecrypt(CArcFile* archive) 25 | { 26 | return 0x36; 27 | } 28 | 29 | /// Decryption Process 30 | /// 31 | /// @param target Data to be decoded 32 | /// @param target_size Data size 33 | /// @param offset Location of data to be decoded 34 | /// @param decrypt_key Decryption key 35 | /// 36 | size_t CFate::OnDecrypt(u8* target, size_t target_size, size_t offset, u32 decrypt_key) 37 | { 38 | for (size_t i = 0; i < target_size; i++) 39 | { 40 | target[i] ^= decrypt_key; 41 | 42 | const size_t byte_offset = offset + i; 43 | 44 | if (byte_offset == 0x13) 45 | { 46 | target[i] ^= 0x01; 47 | } 48 | 49 | if (byte_offset == 0x2EA29) 50 | { 51 | target[i] ^= 0x03; 52 | } 53 | } 54 | 55 | return target_size; 56 | } 57 | -------------------------------------------------------------------------------- /Extract/krkr/Fate.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Extract/krkr/Krkr.h" 4 | 5 | class CFate final : public CKrkr 6 | { 7 | public: 8 | bool OnCheckDecrypt(CArcFile* archive) override; 9 | u32 OnInitDecrypt(CArcFile* archive) override; 10 | size_t OnDecrypt(u8* target, size_t target_size, size_t offset, u32 decrypt_key) override; 11 | }; 12 | -------------------------------------------------------------------------------- /Extract/krkr/FateFD.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Extract/krkr/Krkr.h" 4 | 5 | class CFateFD final : public CKrkr 6 | { 7 | public: 8 | bool OnCheckDecrypt(CArcFile* archive) override; 9 | u32 OnInitDecrypt(CArcFile* archive) override; 10 | size_t OnDecrypt(u8* target, size_t target_size, size_t offset, u32 decrypt_key) override; 11 | 12 | private: 13 | std::array m_key; 14 | std::array m_offset; 15 | 16 | // Decode Info 17 | struct DecodeInfo 18 | { 19 | u8 key; 20 | size_t size; 21 | }; 22 | }; 23 | -------------------------------------------------------------------------------- /Extract/krkr/FlyingShine.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Extract/krkr/FlyingShine.h" 3 | 4 | #include "ArcFile.h" 5 | #include "Common.h" 6 | 7 | /// Determine if decryption is possible 8 | /// 9 | /// @param archive Archive 10 | /// 11 | bool CFlyingShine::OnCheckDecrypt(CArcFile* archive) 12 | { 13 | return CheckTpm("2FAA3AF83558C93EC2C44F06DD727ED5"); 14 | } 15 | 16 | /// Initialization of the decryption process 17 | /// 18 | /// @param archive Archive 19 | /// 20 | u32 CFlyingShine::OnInitDecrypt(CArcFile* archive) 21 | { 22 | return archive->GetOpenFileInfo()->key & 0xFFFF; 23 | } 24 | 25 | /// Decryption Process 26 | /// 27 | /// @param target Data to be decoded 28 | /// @param target_size Data size 29 | /// @param offset Location of data to be decoded 30 | /// @param decrypt_key Decryption key 31 | /// 32 | size_t CFlyingShine::OnDecrypt(u8* target, size_t target_size, size_t offset, u32 decrypt_key) 33 | { 34 | const u8 decrypt_key1 = static_cast((decrypt_key >> 8) & 0xFF); 35 | const u8 decrypt_key2 = static_cast((decrypt_key & 0xFF) % 8); 36 | 37 | for (size_t i = 0; i < target_size; i++) 38 | { 39 | target[i] ^= decrypt_key1; 40 | 41 | // Rotate Right 42 | target[i] = (target[i] >> decrypt_key2) | (target[i] << (8 - decrypt_key2)); 43 | } 44 | 45 | return target_size; 46 | } 47 | -------------------------------------------------------------------------------- /Extract/krkr/FlyingShine.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Extract/krkr/Krkr.h" 4 | 5 | class CFlyingShine final : public CKrkr 6 | { 7 | public: 8 | bool OnCheckDecrypt(CArcFile* archive) override; 9 | u32 OnInitDecrypt(CArcFile* archive) override; 10 | size_t OnDecrypt(u8* target, size_t target_size, size_t offset, u32 decrypt_key) override; 11 | }; 12 | -------------------------------------------------------------------------------- /Extract/krkr/Hachukano.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Extract/krkr/Hachukano.h" 3 | 4 | #include "ArcFile.h" 5 | #include "Common.h" 6 | 7 | /// Determine if decryption is possible 8 | /// 9 | /// @param archive Archive 10 | /// 11 | bool CHachukano::OnCheckDecrypt(CArcFile* archive) 12 | { 13 | return archive->CheckExe(_T("hachukano.exe")); 14 | } 15 | 16 | /// Initialization of the decryption process 17 | /// 18 | /// @param archive Archive 19 | /// 20 | u32 CHachukano::OnInitDecrypt(CArcFile* archive) 21 | { 22 | const SFileInfo* file_info = archive->GetOpenFileInfo(); 23 | LPCTSTR file_ext = PathFindExtension(file_info->name); 24 | 25 | if (lstrcmp(file_ext, _T(".dll")) == 0 || file_info->name == _T("startup.tjs")) 26 | { 27 | // Files we don't decode 28 | SetDecryptRequirement(false); 29 | return 0; 30 | } 31 | 32 | // Size to decrypt 33 | if (lstrcmp(file_ext, _T(".ks")) != 0 && 34 | lstrcmp(file_ext, _T(".tjs")) != 0 && 35 | lstrcmp(file_ext, _T(".asd")) != 0) 36 | { 37 | SetDecryptSize(512); 38 | } 39 | 40 | // Decryption key 41 | m_change_decrypt_key = 0; 42 | 43 | return file_info->key ^ 0x03020100; 44 | } 45 | 46 | /// Decryption Process 47 | /// 48 | /// @param target Data to be decoded 49 | /// @param target_size Data size 50 | /// @param offset Location of data to be decoded 51 | /// @param decrypt_key Decryption key 52 | /// 53 | size_t CHachukano::OnDecrypt(u8* target, size_t target_size, size_t offset, u32 decrypt_key) 54 | { 55 | // Decrypt 56 | for (size_t i = 0; i < target_size; i += sizeof(u32)) 57 | { 58 | if ((i & 255) == 0) 59 | { 60 | m_change_decrypt_key = 0; 61 | } 62 | else 63 | { 64 | m_change_decrypt_key += 0x04040404; 65 | } 66 | 67 | *reinterpret_cast(&target[i]) ^= decrypt_key ^ m_change_decrypt_key; 68 | } 69 | 70 | return target_size; 71 | } 72 | -------------------------------------------------------------------------------- /Extract/krkr/Hachukano.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Extract/krkr/Krkr.h" 4 | 5 | class CHachukano final : public CKrkr 6 | { 7 | public: 8 | bool OnCheckDecrypt(CArcFile* archive) override; 9 | u32 OnInitDecrypt(CArcFile* archive) override; 10 | size_t OnDecrypt(u8* target, size_t target_size, size_t offset, u32 decrypt_key) override; 11 | 12 | private: 13 | u32 m_change_decrypt_key = 0; 14 | }; 15 | -------------------------------------------------------------------------------- /Extract/krkr/Himesyo.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Extract/krkr/Himesyo.h" 3 | 4 | #include "ArcFile.h" 5 | #include "Common.h" 6 | 7 | /// Determine if decryption is possible 8 | /// 9 | /// @param archive Archive 10 | /// 11 | bool CHimesyo::OnCheckDecrypt(CArcFile* archive) 12 | { 13 | return archive->CheckExe( _T("himesyo.exe") ); 14 | } 15 | 16 | /// Initialization of the decryption process 17 | /// 18 | /// @param archive Archive 19 | /// 20 | u32 CHimesyo::OnInitDecrypt(CArcFile* archive) 21 | { 22 | const SFileInfo* file_info = archive->GetOpenFileInfo(); 23 | LPCTSTR file_ext = PathFindExtension(file_info->name); 24 | 25 | if (lstrcmp(file_ext, _T(".dll")) == 0 || file_info->name == _T("startup.tjs")) 26 | { 27 | // Files we don't decode 28 | SetDecryptRequirement(false); 29 | return 0; 30 | } 31 | 32 | // Size to decrypt 33 | if (lstrcmp(file_ext, _T(".ks")) != 0 && 34 | lstrcmp(file_ext, _T(".tjs")) != 0 && 35 | lstrcmp(file_ext, _T(".asd")) != 0) 36 | { 37 | SetDecryptSize(256); 38 | } 39 | 40 | // Decryption key 41 | m_change_decrypt_key = 0; 42 | 43 | return file_info->key ^ 0x03020100 ^ 0xFFFFFFFF; 44 | } 45 | 46 | /// Decryption Process 47 | /// 48 | /// @param target Data to be decoded 49 | /// @param target_size Data size 50 | /// @param offset Location of data to be decoded 51 | /// @param decrypt_key Decryption key 52 | /// 53 | size_t CHimesyo::OnDecrypt(u8* target, size_t target_size, size_t offset, u32 decrypt_key) 54 | { 55 | for (size_t i = 0; i < target_size; i += sizeof(u32)) 56 | { 57 | if ((i & 255) == 0) 58 | { 59 | m_change_decrypt_key = 0; 60 | } 61 | else 62 | { 63 | m_change_decrypt_key += 0x04040404; 64 | } 65 | 66 | *reinterpret_cast(&target[i]) ^= decrypt_key ^ m_change_decrypt_key; 67 | } 68 | 69 | return target_size; 70 | } 71 | -------------------------------------------------------------------------------- /Extract/krkr/Himesyo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Extract/krkr/Krkr.h" 4 | 5 | class CHimesyo final : public CKrkr 6 | { 7 | public: 8 | bool OnCheckDecrypt(CArcFile* archive) override; 9 | u32 OnInitDecrypt(CArcFile* archive) override; 10 | size_t OnDecrypt(u8* target, size_t target_size, size_t offset, u32 decrypt_key) override; 11 | 12 | private: 13 | u32 m_change_decrypt_key = 0; 14 | }; 15 | -------------------------------------------------------------------------------- /Extract/krkr/Krkr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../ExtractBase.h" 4 | 5 | class CKrkr : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | bool Extract(CArcFile* archive) override; 11 | 12 | protected: 13 | // Check whether or not it can be decoded 14 | virtual bool OnCheckDecrypt(CArcFile* archive); 15 | 16 | // Check tpm 17 | bool CheckTpm(const char* md5) const; 18 | 19 | // Set decryption key 20 | void InitDecrypt(CArcFile* archive); 21 | virtual u32 OnInitDecrypt(CArcFile* archive); 22 | 23 | // Decoding 24 | size_t Decrypt(u8* target, size_t target_size, size_t offset); 25 | virtual size_t OnDecrypt(u8* target, size_t target_size, size_t offset, u32 decrypt_key); 26 | 27 | // Set decryption request 28 | void SetDecryptRequirement(bool decrypt); 29 | 30 | // Set decryption size 31 | void SetDecryptSize(size_t decrypt_size); 32 | 33 | // Find XP3 from within an EXE file 34 | bool FindXP3FromExecuteFile(CArcFile* archive, size_t* offset); 35 | 36 | private: 37 | bool m_decrypt = false; // Decryption request 38 | u32 m_decrypt_key = 0; 39 | size_t m_decrypt_size = 0; // Decryption size 40 | YCString m_tpm_path; 41 | CArcFile* m_archive = nullptr; 42 | 43 | void SetMD5ForTpm(CArcFile* archive); 44 | }; 45 | -------------------------------------------------------------------------------- /Extract/krkr/Natsupochi.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Extract/krkr/Natsupochi.h" 3 | 4 | #include "ArcFile.h" 5 | #include "Common.h" 6 | 7 | /// Determine if decryption is possible 8 | /// 9 | /// @param archive Archive 10 | /// 11 | bool CNatsupochi::OnCheckDecrypt(CArcFile* archive) 12 | { 13 | return CheckTpm("B1CCCE8E4048B563B316D8BAEDF7E2B1"); 14 | } 15 | 16 | /// Initialization of the decryption process 17 | /// 18 | /// @param archive Archive 19 | /// 20 | u32 CNatsupochi::OnInitDecrypt(CArcFile* archive) 21 | { 22 | return archive->GetOpenFileInfo()->key >> 3; 23 | } 24 | 25 | /// Decryption Process 26 | /// 27 | /// @param target Data to be decoded 28 | /// @param target_size Data size 29 | /// @param offset Location of data to be decoded 30 | /// @param decrypt_key Decryption key 31 | /// 32 | size_t CNatsupochi::OnDecrypt(u8* target, size_t target_size, size_t offset, u32 decrypt_key) 33 | { 34 | const u8 byte_decrypt_key = static_cast(decrypt_key); 35 | 36 | for (size_t i = 0; i < target_size; i++) 37 | { 38 | target[i] ^= byte_decrypt_key; 39 | } 40 | 41 | return target_size; 42 | } 43 | -------------------------------------------------------------------------------- /Extract/krkr/Natsupochi.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Extract/krkr/Krkr.h" 4 | 5 | class CNatsupochi final : public CKrkr 6 | { 7 | public: 8 | bool OnCheckDecrypt(CArcFile* archive) override; 9 | u32 OnInitDecrypt(CArcFile* archive) override; 10 | size_t OnDecrypt(u8* target, size_t target_size, size_t offset, u32 decrypt_key) override; 11 | }; 12 | -------------------------------------------------------------------------------- /Extract/krkr/SisMiko.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Extract/krkr/SisMiko.h" 3 | 4 | #include "ArcFile.h" 5 | #include "Common.h" 6 | 7 | /// Determine if decryption is possible 8 | /// 9 | /// @param archive Archive 10 | /// 11 | bool CSisMiko::OnCheckDecrypt(CArcFile* archive) 12 | { 13 | return archive->CheckExe( _T("SisuMiko.exe") ); 14 | } 15 | 16 | /// Initialization of the decryption process 17 | /// 18 | /// @param archive Archive 19 | /// 20 | u32 CSisMiko::OnInitDecrypt(CArcFile* archive) 21 | { 22 | const SFileInfo* file_info = archive->GetOpenFileInfo(); 23 | LPCTSTR file_ext = PathFindExtension(file_info->name); 24 | const u32 key = archive->GetOpenFileInfo()->key; 25 | 26 | if (lstrcmp(file_ext, _T(".dll")) == 0 || file_info->name == _T("startup.tjs")) 27 | { 28 | // Files we don't decrypt 29 | SetDecryptRequirement(false); 30 | return 0; 31 | } 32 | 33 | // Size to decrypt 34 | if (lstrcmp(file_ext, _T(".ks")) != 0 && 35 | lstrcmp(file_ext, _T(".tjs")) != 0 && 36 | lstrcmp(file_ext, _T(".asd")) != 0) 37 | { 38 | SetDecryptSize(256); 39 | } 40 | 41 | // Decryption Key 42 | return ~(key << 16 | key >> 16); 43 | } 44 | 45 | /// Decryption Process 46 | /// 47 | /// @param target Data to be decoded 48 | /// @param target_size Data size 49 | /// @param offset Location of data to be decoded 50 | /// @param decrypt_key Decryption key 51 | /// 52 | size_t CSisMiko::OnDecrypt(u8* target, size_t target_size, size_t offset, u32 decrypt_key) 53 | { 54 | for (size_t i = 0; i < target_size; i += sizeof(u32)) 55 | { 56 | *reinterpret_cast(&target[i]) ^= decrypt_key; 57 | } 58 | 59 | return target_size; 60 | } 61 | -------------------------------------------------------------------------------- /Extract/krkr/SisMiko.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Extract/krkr/Krkr.h" 4 | 5 | class CSisMiko final : public CKrkr 6 | { 7 | public: 8 | bool OnCheckDecrypt(CArcFile* archive) override; 9 | u32 OnInitDecrypt(CArcFile* archive) override; 10 | size_t OnDecrypt(u8* target, size_t target_size, size_t offset, u32 decrypt_key) override; 11 | }; 12 | -------------------------------------------------------------------------------- /Extract/krkr/Specialite.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Extract/krkr/Specialite.h" 3 | 4 | #include "ArcFile.h" 5 | 6 | /// Determine if decryption is possible 7 | /// 8 | /// @param archive Archive 9 | /// 10 | bool CSpecialite::OnCheckDecrypt(CArcFile* archive) 11 | { 12 | return CheckTpm("F78FF15C0BD396080BCDF431AED59211"); 13 | } 14 | 15 | /// Initialization of the decryption process 16 | /// 17 | /// @param archive Archive 18 | /// 19 | u32 CSpecialite::OnInitDecrypt(CArcFile* archive) 20 | { 21 | return 0xAF; 22 | } 23 | 24 | /// Decryption Process 25 | /// 26 | /// @param target Data to be decoded 27 | /// @param target_size Data size 28 | /// @param offset Location of data to be decoded 29 | /// @param decrypt_key Decryption key 30 | /// 31 | size_t CSpecialite::OnDecrypt(u8* target, size_t target_size, size_t offset, u32 decrypt_key) 32 | { 33 | const u8 byte_decrypt_key = static_cast(decrypt_key); 34 | 35 | for (size_t i = 0; i < target_size; i++) 36 | { 37 | target[i] ^= byte_decrypt_key; 38 | target[i] += 1; 39 | } 40 | 41 | return target_size; 42 | } 43 | -------------------------------------------------------------------------------- /Extract/krkr/Specialite.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Extract/krkr/Krkr.h" 4 | 5 | class CSpecialite final : public CKrkr 6 | { 7 | public: 8 | bool OnCheckDecrypt(CArcFile* archive) override; 9 | u32 OnInitDecrypt(CArcFile* archive) override; 10 | size_t OnDecrypt(u8* target, size_t target_size, size_t offset, u32 decrypt_key) override; 11 | }; 12 | -------------------------------------------------------------------------------- /Extract/krkr/Tengu.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Extract/krkr/Tengu.h" 3 | 4 | #include "ArcFile.h" 5 | 6 | /// Determine if decryption is possible 7 | /// 8 | /// @param archive Archive 9 | /// 10 | bool CTengu::OnCheckDecrypt(CArcFile* archive) 11 | { 12 | return CheckTpm("CE093BB86595E62ADBCB1280CA6583EF"); 13 | } 14 | 15 | /// Initialization of the decryption process 16 | /// 17 | /// @param archive Archive 18 | /// 19 | u32 CTengu::OnInitDecrypt(CArcFile* archive) 20 | { 21 | // Decryption Key 22 | return 0x08; 23 | } 24 | 25 | /// Decryption Process 26 | /// 27 | /// @param target Data to be decoded 28 | /// @param target_size Data size 29 | /// @param offset Location of data to be decoded 30 | /// @param decrypt_key Decryption key 31 | /// 32 | size_t CTengu::OnDecrypt(u8* target, size_t target_size, size_t offset, u32 decrypt_key) 33 | { 34 | const u8 byte_decrypt_key = static_cast(decrypt_key); 35 | 36 | // Decryption 37 | for (size_t i = 0; i < target_size; i++) 38 | { 39 | target[i] ^= byte_decrypt_key; 40 | } 41 | 42 | if (memcmp(target, "\xFE\xFE\x01\xFF\xFE", 5) != 0) 43 | { 44 | return target_size; 45 | } 46 | 47 | // Temporary Copy 48 | std::vector temporary(target, target + target_size); 49 | memset(target, 0, target_size); 50 | 51 | // Decryption 52 | for (size_t i = 5, j = 0; i < target_size; i += sizeof(u16), j += sizeof(u16)) 53 | { 54 | u16 work1 = *reinterpret_cast(&temporary[i]); 55 | u16 work2 = work1; 56 | 57 | work1 = (work1 & 0x5555) << 1; 58 | work2 = (work2 & 0xAAAA) >> 1; 59 | 60 | *reinterpret_cast(&target[j]) = work1 | work2; 61 | } 62 | 63 | // Convert to a multi-byte character 64 | YCStringA work = reinterpret_cast(target); 65 | strcpy(reinterpret_cast(target), work); 66 | 67 | return static_cast(work.GetLength()); 68 | } 69 | -------------------------------------------------------------------------------- /Extract/krkr/Tengu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Extract/krkr/Krkr.h" 4 | 5 | class CTengu final : public CKrkr 6 | { 7 | public: 8 | bool OnCheckDecrypt(CArcFile* archive) override; 9 | u32 OnInitDecrypt(CArcFile* archive) override; 10 | size_t OnDecrypt(u8* target, size_t target_size, size_t offset, u32 decrypt_key) override; 11 | }; 12 | -------------------------------------------------------------------------------- /Extract/krkr/Tlg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CTlg final : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | bool Decode(CArcFile* archive, u8* src); 11 | 12 | private: 13 | bool DecompTLG5(CArcFile* archive, const u8* src); 14 | bool DecompTLG6(CArcFile* archive, const u8* src); 15 | u32 DecompLZSS(u8* dst, const u8* src, size_t src_size, u8* dictionary, u32 initial_r); 16 | void ComposeColors(u8* dst, const u8* upper, const u8* const* buffer, u32 width, u32 colors); 17 | 18 | void TVPTLG6DecodeGolombValues(u8* pixelbuf, u32 pixel_count, const u8* bit_pool, u8 color); 19 | 20 | void TVPTLG6DecodeLineGeneric(const u32* prev_line, u32* current_line, u32 width, 21 | u32 start_block, u32 block_limit, const u8* filter_types, 22 | u32 skip_block_bytes, const u32* in, u32 initial_p, 23 | u32 odd_skip, u32 dir); 24 | 25 | void TVPTLG6DecodeLine(const u32* prev_line, u32* current_line, u32 width, 26 | u32 block_count, const u8* filter_types, u32 skip_block_bytes, 27 | const u32* in, u32 initial_p, u32 odd_skip, 28 | u32 dir); 29 | 30 | u32 make_gt_mask(u32 a, u32 b); 31 | u32 packed_bytes_add(u32 a, u32 b); 32 | u32 med2(u32 a, u32 b, u32 c); 33 | u32 med(u32 a, u32 b, u32 c, u32 v); 34 | u32 avg(u32 a, u32 b, u32 c, u32 v); 35 | 36 | void InitTLG6Table(); 37 | }; 38 | -------------------------------------------------------------------------------- /Extract/krkr/TokiPaku.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Extract/krkr/TokiPaku.h" 3 | 4 | #include "ArcFile.h" 5 | #include "Common.h" 6 | 7 | /// Determine if decryption is possible 8 | /// 9 | /// @param archive Archive 10 | /// 11 | bool CTokiPaku::OnCheckDecrypt(CArcFile* archive) 12 | { 13 | // return CheckTpm("510BE09DF50DB143E90D3837D416FD0F"); 14 | return CheckTpm("A9D18BCE341E20D25DB4DBFAAE7FBF5B"); 15 | } 16 | 17 | /// Initialization of the decryption process 18 | /// 19 | /// @param archive Archive 20 | /// 21 | u32 CTokiPaku::OnInitDecrypt(CArcFile* archive) 22 | { 23 | const SFileInfo* file_info = archive->GetOpenFileInfo(); 24 | LPCTSTR file_ext = PathFindExtension(file_info->name); 25 | 26 | if (lstrcmp(file_ext, _T(".dll")) == 0) 27 | { 28 | // Don't decrypt 29 | SetDecryptRequirement(false); 30 | return 0; 31 | } 32 | 33 | // Size to decrypt 34 | if (lstrcmp(file_ext, _T(".ks")) != 0 && 35 | lstrcmp(file_ext, _T(".tjs")) != 0 && 36 | lstrcmp(file_ext, _T(".asd")) != 0) 37 | { 38 | SetDecryptSize(256); 39 | } 40 | 41 | // Decryption Key 42 | u32 decrypt_key = 0xFFFFFFFF; 43 | u8* key = reinterpret_cast(&decrypt_key); 44 | for (int i = 0; i < lstrlen(file_ext); i++) 45 | { 46 | key[i] = ~file_ext[i]; 47 | } 48 | 49 | return decrypt_key; 50 | } 51 | 52 | /// Decryption Process 53 | /// 54 | /// @param target Data to be decoded 55 | /// @param target_size Data size 56 | /// @param offset Location of data to be decoded 57 | /// @param decrypt_key Decryption key 58 | /// 59 | size_t CTokiPaku::OnDecrypt(u8* target, size_t target_size, size_t offset, u32 decrypt_key) 60 | { 61 | for (size_t i = 0; i < target_size; i += sizeof(u32)) 62 | { 63 | *reinterpret_cast(&target[i]) ^= decrypt_key; 64 | } 65 | 66 | return target_size; 67 | } 68 | -------------------------------------------------------------------------------- /Extract/krkr/TokiPaku.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Extract/krkr/Krkr.h" 4 | 5 | class CTokiPaku final : public CKrkr 6 | { 7 | public: 8 | bool OnCheckDecrypt(CArcFile* archive) override; 9 | u32 OnInitDecrypt(CArcFile* archive) override; 10 | size_t OnDecrypt(u8* target, size_t target_size, size_t offset, u32 decrypt_key) override; 11 | }; 12 | -------------------------------------------------------------------------------- /Extract/krkr/Yotsunoha.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Extract/krkr/Yotsunoha.h" 3 | 4 | #include "ArcFile.h" 5 | #include "Common.h" 6 | 7 | /// Determine if decryption is possible 8 | /// 9 | /// @param archive Archive 10 | /// 11 | bool CYotsunoha::OnCheckDecrypt(CArcFile* archive) 12 | { 13 | return CheckTpm("AAF0A99EAF4018CB1AA5E0D9065C2239"); 14 | } 15 | 16 | /// Initialization of the decryption process 17 | /// 18 | /// @param archive Archive 19 | /// 20 | u32 CYotsunoha::OnInitDecrypt(CArcFile* archive) 21 | { 22 | const SFileInfo* file_info = archive->GetOpenFileInfo(); 23 | 24 | // Decryption key 25 | return ((file_info->key >> 8) & 0xFF) ^ (file_info->key & 0xFF); 26 | } 27 | 28 | /// Decryption Process 29 | /// 30 | /// @param target Data to be decoded 31 | /// @param target_size Data size 32 | /// @param offset Location of data to be decoded 33 | /// @param decrypt_key Decryption key 34 | /// 35 | size_t CYotsunoha::OnDecrypt(u8* target, size_t target_size, size_t offset, u32 decrypt_key) 36 | { 37 | // Decryption 38 | const u8 byte_decrypt_key = static_cast(decrypt_key); 39 | 40 | for (size_t i = 0; i < target_size; i++) 41 | { 42 | target[i] ^= byte_decrypt_key; 43 | } 44 | 45 | return target_size; 46 | } 47 | -------------------------------------------------------------------------------- /Extract/krkr/Yotsunoha.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Extract/krkr/Krkr.h" 4 | 5 | class CYotsunoha final : public CKrkr 6 | { 7 | public: 8 | bool OnCheckDecrypt(CArcFile* archive) override; 9 | u32 OnInitDecrypt(CArcFile* archive) override; 10 | size_t OnDecrypt(u8* target, size_t target_size, size_t offset, u32 decrypt_key) override; 11 | }; 12 | -------------------------------------------------------------------------------- /Extract/paz/AngelType.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Extract/paz/Paz.h" 4 | 5 | class CAngelType final : public CPaz 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | protected: 12 | void InitMountKey(CArcFile* archive) override; 13 | void InitDecodeKey(CArcFile* archive) override; 14 | }; 15 | -------------------------------------------------------------------------------- /Extract/paz/BSFre.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Extract/paz/Paz.h" 4 | 5 | //---------------------------------------------------------------------------------------- 6 | //-- BITTERSWEET FOOLS Repackage --------------------------------------------------------- 7 | //---------------------------------------------------------------------------------------- 8 | 9 | class CBSFre final : public CPaz 10 | { 11 | public: 12 | bool Mount(CArcFile* archive) override; 13 | bool Decode(CArcFile* archive) override; 14 | 15 | private: 16 | void InitMountKey(CArcFile* archive) override; 17 | void InitDecodeKey(CArcFile* archive) override; 18 | }; 19 | -------------------------------------------------------------------------------- /Extract/paz/Haruoto.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Extract/paz/Paz.h" 4 | 5 | class CHaruoto : public CPaz 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | protected: 12 | void InitMountKey(CArcFile* archive) override; 13 | void InitDecodeKey(CArcFile* archive) override; 14 | }; 15 | -------------------------------------------------------------------------------- /Extract/paz/HaruotoFD.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Extract/paz/Paz.h" 4 | 5 | class CHaruotoFD : public CPaz 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | protected: 12 | void InitMountKey(CArcFile* archive) override; 13 | void InitDecodeKey(CArcFile* archive) override; 14 | 15 | void DecodeTable2() override; 16 | 17 | void DecodeData(u8* target, size_t size) override; 18 | }; 19 | -------------------------------------------------------------------------------- /Extract/paz/Paz.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CPaz : public CExtractBase 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | protected: 12 | struct KeyInfo 13 | { 14 | YCString type; 15 | u8 key[64]; 16 | }; 17 | 18 | using Key = std::array; 19 | using MovieTable = std::array; 20 | using Table = std::array; 21 | 22 | // Initialization of the table of 72 + 4096 bytes 23 | virtual void InitTable(); 24 | 25 | // Initialization of the movie table 26 | virtual size_t InitMovieTable(const u8* table); 27 | 28 | // Get the base archive filename 29 | void GetBaseArcName(LPTSTR dst, LPCTSTR archive_name); 30 | 31 | // Set 32 byte keys (Keys differ for each file) 32 | virtual void InitMountKey(CArcFile* archive) = 0; 33 | virtual void InitDecodeKey(CArcFile* archive) = 0; 34 | size_t SetKey(CArcFile* archive, const std::array& key_info); 35 | 36 | // Decrypt the table 37 | virtual void DecodeTable1(); 38 | virtual void DecodeTable2(); 39 | 40 | // Cipher-specific decryption 41 | virtual void Decrypt(u8* target, size_t size) {} 42 | virtual void Decrypt2(u8* target, size_t size) {} 43 | 44 | // Decrypt the data 45 | virtual void DecodeData(u8* target, size_t size); 46 | 47 | // Decrypt movie data 48 | virtual void DecodeMovieData(u8* target, size_t size); 49 | 50 | // Decode u32 value 51 | virtual u32 DecodeValueByTable(u32 value, const Table& table); 52 | virtual void DecodeValue(u32* value1, u32* value2, const Table& table); 53 | 54 | // Get 55 | Table& GetTable(); 56 | MovieTable& GetMovieTable(); 57 | 58 | Key& GetKey(); 59 | virtual size_t GetMovieBufSize(const CArcFile* archive); 60 | 61 | private: 62 | std::array m_table; 63 | std::array m_movie_table; 64 | std::array m_key; 65 | }; 66 | -------------------------------------------------------------------------------- /Extract/paz/WindRP.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Extract/paz/Haruoto.h" 4 | 5 | class CWindRP final : public CHaruoto 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | protected: 12 | void InitMountKey(CArcFile* archive) override; 13 | void InitDecodeKey(CArcFile* archive) override; 14 | }; 15 | -------------------------------------------------------------------------------- /Extract/paz/ef_ffd.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Extract/paz/HaruotoFD.h" 4 | 5 | class Cef_ffd final : public CHaruotoFD 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | private: 12 | void InitMountKey(CArcFile* archive) override; 13 | void InitDecodeKey(CArcFile* archive) override; 14 | }; 15 | -------------------------------------------------------------------------------- /Extract/paz/ef_first.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Extract/paz/HaruotoFD.h" 4 | 5 | class Cef_first final : public CHaruotoFD 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | private: 12 | bool IsSupported(const CArcFile* archive); 13 | 14 | void InitMountKey(CArcFile* archive) override; 15 | void InitDecodeKey(CArcFile* archive) override; 16 | 17 | size_t InitMovieTable(const u8* table) override; 18 | 19 | void DecodeTable1() override; 20 | 21 | void Decrypt(u8* target, size_t size) override; 22 | 23 | void DecodeMovieData(u8* target, size_t size) override; 24 | 25 | size_t GetMovieBufSize(const CArcFile* archive) override; 26 | 27 | u8 m_key = 0; 28 | u8 m_movie_table[256][256]; 29 | u32 m_movie_table_id = 0; 30 | }; 31 | -------------------------------------------------------------------------------- /Extract/paz/ef_latter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Extract/paz/HaruotoFD.h" 4 | 5 | class CEFLatter final : public CHaruotoFD 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | private: 12 | bool IsSupported(const CArcFile* archive); 13 | 14 | void InitMountKey(CArcFile* archive) override; 15 | void InitDecodeKey(CArcFile* archive) override; 16 | 17 | size_t InitMovieTable(const u8* table) override; 18 | 19 | void Decrypt(u8* target, size_t size) override; 20 | void Decrypt2(u8* target, size_t size) override; 21 | 22 | void SetDecryptKey2(CArcFile* archive); 23 | 24 | void DecodeMovieData(u8* target, size_t size) override; 25 | 26 | u8 m_key = 0; 27 | 28 | char m_key_string[256]; 29 | std::array m_key_table; 30 | u32 m_key_table_index1 = 0; 31 | u32 m_key_table_index2 = 0; 32 | 33 | std::array m_movie_decode_table; 34 | u32 m_movie_decode_table_ptr = 0; 35 | }; 36 | -------------------------------------------------------------------------------- /Extract/paz/ef_sfm.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Extract/paz/HaruotoFD.h" 4 | 5 | //---------------------------------------------------------------------------------------- 6 | //-- ef - Second Fan Mix ----------------------------------------------------------------- 7 | //---------------------------------------------------------------------------------------- 8 | 9 | class CEFsfm final : public CHaruotoFD 10 | { 11 | public: 12 | bool Mount(CArcFile* archive) override; 13 | bool Decode(CArcFile* archive) override; 14 | 15 | private: 16 | bool IsSupported(const CArcFile* archive) const; 17 | 18 | void InitMountKey(CArcFile* archive) override; 19 | void InitDecodeKey(CArcFile* archive) override; 20 | 21 | size_t InitMovieTable(const u8* table) override; 22 | 23 | void DecodeMovieData(u8* target, size_t size) override; 24 | 25 | size_t GetMovieBufSize(const CArcFile* archive) override; 26 | 27 | u8 m_key = 0; 28 | u8 m_movie_table[256][256]; 29 | u32 m_movie_table_id = 0; 30 | }; 31 | -------------------------------------------------------------------------------- /Extract/paz/ef_trial.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Extract/paz/HaruotoFD.h" 4 | 5 | class Cef_trial final : public CHaruotoFD 6 | { 7 | public: 8 | bool Mount(CArcFile* archive) override; 9 | bool Decode(CArcFile* archive) override; 10 | 11 | protected: 12 | void InitMountKey(CArcFile* archive) override; 13 | void InitDecodeKey(CArcFile* archive) override; 14 | }; 15 | -------------------------------------------------------------------------------- /ExtractBase.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "ExtractBase.h" 3 | #include "ArcFile.h" 4 | 5 | bool CExtractBase::Decode(CArcFile* archive) 6 | { 7 | return false; 8 | } 9 | 10 | bool CExtractBase::Extract(CArcFile* archive) 11 | { 12 | return false; 13 | } 14 | -------------------------------------------------------------------------------- /ExtractBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CArcFile; 4 | 5 | class CExtractBase 6 | { 7 | public: 8 | virtual ~CExtractBase() = default; 9 | 10 | virtual bool Mount(CArcFile* archive) = 0; 11 | virtual bool Decode(CArcFile* archive); 12 | virtual bool Extract(CArcFile* archive); 13 | }; 14 | -------------------------------------------------------------------------------- /File.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CFile 4 | { 5 | public: 6 | enum class OpenMode 7 | { 8 | Read, 9 | Write 10 | }; 11 | 12 | CFile(); 13 | virtual ~CFile(); 14 | 15 | CFile(const CFile&) = delete; 16 | CFile& operator=(const CFile&) = delete; 17 | 18 | CFile(CFile&&) = default; 19 | CFile& operator=(CFile&&) = default; 20 | 21 | virtual HANDLE Open(LPCTSTR filename, OpenMode mode); 22 | virtual bool OpenForRead(LPCTSTR filename); 23 | virtual bool OpenForWrite(LPCTSTR filename); 24 | virtual void Close(); 25 | virtual u32 Read(void* buffer, u32 size); 26 | virtual u32 ReadLine(void* buffer, u32 buffer_size, bool delete_line_code = false); 27 | virtual u32 Write(const void* buffer, u32 size); 28 | virtual void WriteLine(const void* buffer); 29 | virtual u64 Seek(s64 offset, u32 seek_mode); 30 | virtual u64 SeekHed(s64 offset = 0); 31 | virtual u64 SeekEnd(s64 offset = 0); 32 | virtual u64 SeekCur(s64 offset); 33 | virtual u64 GetFilePointer(); 34 | virtual u64 GetFileSize(); 35 | 36 | protected: 37 | HANDLE m_file; 38 | }; 39 | -------------------------------------------------------------------------------- /FindFile.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Common.h" 3 | #include "FindFile.h" 4 | 5 | std::vector CFindFile::DoFind(LPCTSTR base_path, LPCTSTR file_name) 6 | { 7 | HANDLE find_handle; 8 | WIN32_FIND_DATA work; 9 | TCHAR base_path_array[MAX_PATH]; 10 | TCHAR file_path_array[MAX_PATH]; 11 | 12 | //-- File Searching ------------------------------------------------------------------------ 13 | 14 | lstrcpy(base_path_array, base_path); 15 | PathRemoveBackslash(base_path_array); 16 | 17 | _stprintf(file_path_array, _T("%s\\%s"), base_path_array, file_name); 18 | 19 | find_handle = FindFirstFile(file_path_array, &work); 20 | 21 | if (find_handle != INVALID_HANDLE_VALUE) 22 | { 23 | do 24 | { 25 | // Add to the list of files found 26 | YCString file_path = base_path_array; 27 | file_path += _T("\\"); 28 | file_path += work.cFileName; 29 | 30 | m_file_paths.push_back(file_path); 31 | } while (FindNextFile(find_handle, &work)); 32 | 33 | FindClose(find_handle); 34 | } 35 | 36 | //-- Search Directory -------------------------------------------------------------------- 37 | 38 | _stprintf(file_path_array, _T("%s\\*.*"), base_path_array); // Search for all files 39 | 40 | find_handle = FindFirstFile(file_path_array, &work); 41 | 42 | if (find_handle != INVALID_HANDLE_VALUE) 43 | { 44 | do 45 | { 46 | if (!(work.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) 47 | { 48 | // Is not a folder 49 | continue; 50 | } 51 | 52 | if (lstrcmp(work.cFileName, _T(".")) == 0 || lstrcmp(work.cFileName, _T("..")) == 0) 53 | { 54 | // Is not current route 55 | continue; 56 | } 57 | 58 | // Prepare directory discovery (add to the directory search path discovery) 59 | _stprintf(file_path_array, _T("%s\\%s"), base_path_array, work.cFileName); 60 | 61 | // Recursive call 62 | DoFind(file_path_array, file_name); 63 | } while (FindNextFile(find_handle, &work)); 64 | 65 | FindClose(find_handle); 66 | } 67 | 68 | return m_file_paths; 69 | } 70 | 71 | void CFindFile::Clear() 72 | { 73 | m_file_paths.clear(); 74 | } 75 | -------------------------------------------------------------------------------- /FindFile.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CFindFile 4 | { 5 | public: 6 | std::vector DoFind(LPCTSTR base_path, LPCTSTR file_name); 7 | void Clear(); 8 | 9 | private: 10 | std::vector m_file_paths; 11 | }; 12 | -------------------------------------------------------------------------------- /Image.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | #include "Image/Bmp.h" 5 | #include "Image/Png.h" 6 | 7 | struct SOption; 8 | 9 | class CImage : public CExtractBase 10 | { 11 | public: 12 | CImage(); 13 | 14 | bool Mount(CArcFile* archive) override; 15 | bool Decode(CArcFile* archive) override; 16 | 17 | bool Init(CArcFile* archive, void* bmp, const YCString& file_name = _T("")); 18 | bool Init(CArcFile* archive, s32 width, s32 height, u16 bpp, const void* pallet = nullptr, size_t pallet_size = 1024, const YCString& file_name = _T("")); 19 | 20 | void Close(); 21 | 22 | bool Write(size_t bmp_size, bool progress = true); 23 | bool Write(const void* bmp_data, size_t bmp_data_size, bool progress = true); 24 | bool WriteReverse(size_t bmp_size, bool progress = true); 25 | bool WriteReverse(const void* bmp_data, size_t bmp_data_size, bool progress = true); 26 | 27 | bool WriteCompoBGRA(size_t bmp_size, bool progress = true); 28 | bool WriteCompoBGRA(const void* bmp_data, size_t bmp_data_size, bool progress = true); 29 | bool WriteCompoBGRAReverse(size_t bmp_size, bool progress = true); 30 | bool WriteCompoBGRAReverse(const void* bmp_data, size_t bmp_data_size, bool progress = true); 31 | 32 | bool WriteCompoRGBA(size_t bmp_size, bool progress = true); 33 | bool WriteCompoRGBA(const void* bmp_data, size_t bmp_data_size, bool progress = true); 34 | bool WriteCompoRGBAReverse(size_t bmp_size, bool progress = true); 35 | bool WriteCompoRGBAReverse(const void* bmp_data, size_t bmp_data_size, bool progress = true); 36 | 37 | LPBITMAPFILEHEADER GetBmpFileHeader() const; 38 | LPBITMAPINFOHEADER GetBmpInfoHeader() const; 39 | 40 | protected: 41 | CArcFile* m_archive = nullptr; 42 | SOption* m_option = nullptr; 43 | 44 | u8* m_bmp_data = nullptr; 45 | bool m_is_valid_bmp_header = true; 46 | BITMAPFILEHEADER* m_bmp_file_header = nullptr; 47 | BITMAPINFOHEADER* m_bmp_info_header = nullptr; 48 | 49 | CBmp m_bmp; 50 | CPng m_png; 51 | }; 52 | -------------------------------------------------------------------------------- /Image/Bmp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Image/ImageBase.h" 4 | 5 | class CArcFile; 6 | 7 | class CBmp final : public CImageBase 8 | { 9 | public: 10 | bool Mount(CArcFile* archive); 11 | 12 | private: 13 | BITMAPFILEHEADER m_bmp_file_header; 14 | BITMAPINFOHEADER m_bmp_info_header; 15 | std::array m_pallet; 16 | 17 | bool OnInit(const YCString& file_name) override; 18 | bool OnCreatePallet(const u8* pallet, size_t pallet_size) override; 19 | 20 | void WriteHed(const YCString& file_name); 21 | void WriteLine(const u8* buffer) override; 22 | void WriteLineWithAlphaBlend(u8* buffer24, const u8* buffer32) override; 23 | }; 24 | -------------------------------------------------------------------------------- /Image/Jpg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ImageBase.h" 4 | 5 | class CJpglib 6 | { 7 | protected: 8 | static void memory_init_source(j_decompress_ptr cinfo); 9 | static boolean memory_fill_input_buffer(j_decompress_ptr cinfo); 10 | static void memory_skip_input_data(j_decompress_ptr cinfo, long num_bytes); 11 | static void memory_term_source(j_decompress_ptr cinfo); 12 | static void jpeg_memory_src(j_decompress_ptr cinfo, void* data, unsigned long len); 13 | }; 14 | 15 | class CJpg : public CJpglib 16 | { 17 | private: 18 | jpeg_decompress_struct m_cinfo; 19 | jpeg_error_mgr m_jerr; 20 | 21 | JSAMPARRAY m_dst; 22 | std::valarray m_bmpbuf; 23 | 24 | public: 25 | CJpg(); 26 | ~CJpg(); 27 | 28 | void Close(); 29 | 30 | // Expand the JPEG data stored in the src 31 | LPBYTE Decomp(LPBYTE src, DWORD len, LPDWORD dstSize); 32 | // Alpha blending using the mask 33 | void AlphaBlend(LPBYTE dst, LPBYTE mask, DWORD bg); 34 | 35 | // jpg compression rate 36 | void SetQuality(int quality); 37 | // jpg compressed output 38 | void Write(CArcFile* pArc, LPBYTE dst, DWORD dstSize); 39 | // jpg compressed output (reversed) 40 | void WriteReverse(CArcFile* pArc, LPBYTE dst, DWORD dstSize); 41 | 42 | LONG GetWidth() { return m_cinfo.output_width; } 43 | LONG GetHeight() { return m_cinfo.output_height; } 44 | }; 45 | -------------------------------------------------------------------------------- /Image/Png.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Image/ImageBase.h" 4 | 5 | class CPng final : public CImageBase 6 | { 7 | public: 8 | CPng(); 9 | ~CPng() override; 10 | 11 | void SetCompressLevel(int compression_level); 12 | int GetCompressLevel() const; 13 | 14 | void SetCallback(); 15 | 16 | void Close(); 17 | 18 | bool Compress(LPCTSTR dst_path, const void* bmp, size_t bmp_size); 19 | bool Compress(LPCTSTR dst_path, const void* dib, size_t dib_size, const void* pallet, size_t palle_size, u16 pallet_bpp, s32 width, s32 height, u16 bpp); 20 | bool Compress(void* dst, size_t dst_size, const void* bmp, size_t bmp_size); 21 | bool Compress(void* dst, size_t dst_size, const void* dib, size_t dib_size, const void* pallet, size_t pallet_size, u16 pallet_bpp, s32 width, s32 height, u16 bpp); 22 | 23 | bool Decompress(); 24 | 25 | private: 26 | enum class Mode 27 | { 28 | Read = 0x00000000, 29 | Write = 0x00000001 30 | }; 31 | 32 | bool OnInit(const YCString& file_name) override; 33 | bool OnCreatePallet(const u8* pallet, size_t pallet_size) override; 34 | 35 | void WriteLine(const u8* buffer) override; 36 | void WriteLineWithAlphaBlend(u8* buffer24, const u8* buffer32) override; 37 | void OnWriteFinish() override; 38 | 39 | png_structp m_png_ptr = nullptr; 40 | png_infop m_info_ptr = nullptr; 41 | std::array m_pallet; 42 | 43 | png_structp m_png = nullptr; 44 | png_infop m_png_info = nullptr; 45 | void* m_param = nullptr; 46 | u32 m_flags = 0; 47 | int m_compression_level = 1; 48 | 49 | Mode m_mode = Mode::Read; 50 | }; 51 | -------------------------------------------------------------------------------- /Image/Tga.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CArcFile; 4 | 5 | class CTga final 6 | { 7 | public: 8 | struct TGAHeader 9 | { 10 | u8 id; 11 | u8 color_map; 12 | u8 image_type; 13 | u8 color_map_info[5]; 14 | u16 origin_x; 15 | u16 origin_y; 16 | u16 width; 17 | u16 height; 18 | u8 depth; 19 | u8 descriptor; 20 | }; 21 | 22 | bool Decode(CArcFile* archive, const u8* src, size_t src_size, const YCString& file_last_name = _T("")); 23 | 24 | bool Decomp(u8* dst, size_t dst_size, const u8* src, size_t src_size); 25 | 26 | private: 27 | bool DecompRLE(u8* dst, size_t dst_size, const u8* src, size_t src_size, u8 bpp); 28 | }; 29 | -------------------------------------------------------------------------------- /Ini.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "res/ResExtractData.h" 3 | #include "Common.h" 4 | #include "Ini.h" 5 | 6 | CIni::CIni() 7 | { 8 | TCHAR modulePath[MAX_PATH]; 9 | GetModuleFileName(NULL, modulePath, sizeof(modulePath)); 10 | PathRemoveFileSpec(modulePath); 11 | 12 | TCHAR szIniPath[MAX_PATH]; 13 | wsprintf(szIniPath, _T("%s\\ExtractData.ini"), modulePath); 14 | 15 | m_sIniPath = szIniPath; 16 | } 17 | 18 | CIni::CIni(LPCTSTR IniName) 19 | { 20 | TCHAR modulePath[MAX_PATH]; 21 | GetModuleFileName(NULL, modulePath, sizeof(modulePath)); 22 | PathRemoveFileSpec(modulePath); 23 | 24 | TCHAR szIniPath[MAX_PATH]; 25 | wsprintf(szIniPath, _T("%s\\%s.ini"), modulePath, IniName); 26 | 27 | m_sIniPath = szIniPath; 28 | } 29 | 30 | void CIni::SetSection(HINSTANCE hInst, UINT uID) 31 | { 32 | TCHAR section[256]; 33 | LoadString(hInst, uID, section, sizeof(section)); 34 | SetSection(section); 35 | } 36 | 37 | void CIni::GetHex(LPDWORD hex, LPCTSTR def) 38 | { 39 | TCHAR str[256]; 40 | GetPrivateProfileString(m_sSection, m_sKey, def, str, sizeof(str), m_sIniPath); 41 | *hex = strtoul( str, NULL, 16 ); 42 | } 43 | 44 | void CIni::GetStr(LPTSTR str, LPCTSTR def, DWORD len) 45 | { 46 | GetPrivateProfileString(m_sSection, m_sKey, def, str, len, m_sIniPath); 47 | } 48 | 49 | void CIni::GetStr(YCString& str, YCString def) 50 | { 51 | TCHAR szStr[1024]; 52 | GetPrivateProfileString(m_sSection, m_sKey, def, szStr, 1024, m_sIniPath); 53 | str = szStr; 54 | } 55 | 56 | void CIni::WriteBool(BOOL flag) 57 | { 58 | TCHAR str[256]; 59 | wsprintf(str, _T("%d"), flag); 60 | WritePrivateProfileString(m_sSection, m_sKey, str, m_sIniPath); 61 | } 62 | 63 | void CIni::WriteDec(INT dec) 64 | { 65 | TCHAR str[256]; 66 | wsprintf(str, _T("%d"), dec); 67 | WritePrivateProfileString(m_sSection, m_sKey, str, m_sIniPath); 68 | } 69 | 70 | void CIni::WriteHex(DWORD hex) 71 | { 72 | TCHAR str[256]; 73 | wsprintf(str, _T("%06x"), hex); 74 | WritePrivateProfileString(m_sSection, m_sKey, str, m_sIniPath); 75 | } 76 | 77 | void CIni::WriteStr(LPCTSTR str) 78 | { 79 | WritePrivateProfileString(m_sSection, m_sKey, str, m_sIniPath); 80 | } 81 | 82 | BOOL CIni::DeleteSection() 83 | { 84 | return WritePrivateProfileString(m_sSection, NULL, NULL, m_sIniPath); 85 | } 86 | -------------------------------------------------------------------------------- /Ini.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Common.h" 4 | 5 | class CIni 6 | { 7 | private: 8 | YCString m_sIniPath; 9 | YCString m_sSection; 10 | YCString m_sKey; 11 | 12 | public: 13 | CIni(); 14 | CIni(LPCTSTR IniName); 15 | 16 | void SetSection(HINSTANCE hInst, UINT uID); 17 | void SetSection(LPCTSTR section) { m_sSection = section; } 18 | void SetKey(LPCTSTR key) { m_sKey = key; } 19 | 20 | template 21 | void GetDec(_Ty* dec, CONST _Ty def) 22 | { 23 | *dec = GetPrivateProfileInt(m_sSection, m_sKey, def, m_sIniPath); 24 | } 25 | 26 | template 27 | void GetDec(_Ty* dec) 28 | { 29 | *dec = GetPrivateProfileInt(m_sSection, m_sKey, *dec, m_sIniPath); 30 | } 31 | 32 | void GetHex(LPDWORD hex, LPCTSTR def); 33 | void GetStr(LPTSTR str, LPCTSTR def, CONST DWORD len); 34 | void GetStr(YCString& str, YCString def); 35 | 36 | void WriteBool(BOOL flag); 37 | void WriteDec(INT dec); 38 | void WriteHex(DWORD hex); 39 | void WriteStr(LPCTSTR str); 40 | 41 | BOOL DeleteSection(); 42 | }; 43 | -------------------------------------------------------------------------------- /LastDir.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Common.h" 3 | #include "LastDir.h" 4 | 5 | /// Constructor 6 | CLastDir::CLastDir() 7 | { 8 | LoadIni(); 9 | } 10 | 11 | /// Load ini file 12 | void CLastDir::LoadIni() 13 | { 14 | YCIni ini(SBL_STR_INI_EXTRACTDATA); 15 | 16 | ini.SetSection(_T("LastDir")); 17 | 18 | ini.SetKey(_T("LastReadFileDir")); 19 | ini.ReadStr(m_open, sizeof(m_open), _T("")); 20 | ini.SetKey(_T("LastSaveFolderDir")); 21 | ini.ReadStr(m_save, sizeof(m_save), _T("")); 22 | } 23 | 24 | /// Save ini file 25 | void CLastDir::SaveIni() 26 | { 27 | YCIni ini(SBL_STR_INI_EXTRACTDATA); 28 | 29 | ini.SetSection(_T("LastDir")); 30 | 31 | ini.SetKey(_T("LastReadFileDir")); 32 | ini.WriteStr(m_open); 33 | ini.SetKey(_T("LastSaveFolderDir")); 34 | ini.WriteStr(m_save); 35 | } 36 | 37 | /// Get the last opened folder 38 | LPTSTR CLastDir::GetOpen() 39 | { 40 | return m_open; 41 | } 42 | 43 | /// Get the last opened folder 44 | LPCTSTR CLastDir::GetOpen() const 45 | { 46 | return m_open; 47 | } 48 | 49 | /// Get the last folder where something was saved to 50 | LPTSTR CLastDir::GetSave() 51 | { 52 | return m_save; 53 | } 54 | 55 | /// Get the last folder where something was saved to 56 | LPCTSTR CLastDir::GetSave() const 57 | { 58 | return m_save; 59 | } 60 | -------------------------------------------------------------------------------- /LastDir.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CLastDir 4 | { 5 | public: 6 | CLastDir(); 7 | 8 | void LoadIni(); 9 | void SaveIni(); 10 | 11 | LPTSTR GetOpen(); 12 | LPCTSTR GetOpen() const; 13 | 14 | LPTSTR GetSave(); 15 | LPCTSTR GetSave() const; 16 | 17 | private: 18 | TCHAR m_open[_MAX_DIR]; 19 | TCHAR m_save[_MAX_DIR]; 20 | }; 21 | -------------------------------------------------------------------------------- /Libs/lpng163/TODO: -------------------------------------------------------------------------------- 1 | /* 2 | TODO - list of things to do for libpng: 3 | 4 | Final bug fixes. 5 | Better C++ wrapper/full C++ implementation? 6 | Fix problem with C++ and EXTERN "C". 7 | cHRM transformation. 8 | Remove setjmp/longjmp usage in favor of returning error codes. As a start on 9 | this, minimize the use of png_error(), replacing them with 10 | png_warning(); return(0); or similar. 11 | Palette creation. 12 | Add "grayscale->palette" transformation and "palette->grayscale" detection. 13 | Improved dithering. 14 | Multi-lingual error and warning message support. 15 | Complete sRGB transformation (presently it simply uses gamma=0.45455). 16 | Man pages for function calls. 17 | Better documentation. 18 | Better filter selection 19 | (counting huffman bits/precompression? filter inertia? filter costs?). 20 | Histogram creation. 21 | Text conversion between different code pages (Latin-1 -> Mac and DOS). 22 | Avoid building gamma tables whenever possible. 23 | Use greater precision when changing to linear gamma for compositing against 24 | background and doing rgb-to-gray transformation. 25 | Investigate pre-incremented loop counters and other loop constructions. 26 | Add interpolated method of handling interlacing. 27 | Extend pngvalid.c to validate more of the libpng transformations. 28 | Refactor preprocessor conditionals to compile entire statements 29 | 30 | */ 31 | -------------------------------------------------------------------------------- /Libs/lpng163/projects/vstudio/WARNING: -------------------------------------------------------------------------------- 1 | WARNING 2 | ======= 3 | Libpng 1.6 does not use the default run-time library when building static 4 | library builds of libpng; instead of the shared DLL runtime it uses a static 5 | runtime. If you need to change this make sure to change the setting on all the 6 | relevant projects: 7 | 8 | libpng 9 | zlib 10 | all the test programs 11 | 12 | The runtime library settings for each build are as follows: 13 | 14 | Release Debug 15 | DLL /MD /MDd 16 | Library /MT /MTd 17 | 18 | NOTICE that libpng 1.5 erroneously used /MD for Debug DLL builds; if you used 19 | the debug builds in your app and you changed your app to use /MD you will need 20 | to change it to /MDd for libpng 1.6. 21 | 22 | The Visual Studio 2010 defaults for a Win32 DLL or Static Library project are 23 | as follows: 24 | 25 | Release Debug 26 | DLL /MD /MDd 27 | Static Library /MD /MDd 28 | -------------------------------------------------------------------------------- /Libs/lpng163/projects/vstudio/zlib.props: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | 20 | 35 | ..\..\..\..\zlib-1.2.5 36 | 37 | 43 | true 44 | 45 | 46 | -------------------------------------------------------------------------------- /Libs/zlib-1.2.11/INDEX: -------------------------------------------------------------------------------- 1 | CMakeLists.txt cmake build file 2 | ChangeLog history of changes 3 | FAQ Frequently Asked Questions about zlib 4 | INDEX this file 5 | Makefile dummy Makefile that tells you to ./configure 6 | Makefile.in template for Unix Makefile 7 | README guess what 8 | configure configure script for Unix 9 | make_vms.com makefile for VMS 10 | test/example.c zlib usages examples for build testing 11 | test/minigzip.c minimal gzip-like functionality for build testing 12 | test/infcover.c inf*.c code coverage for build coverage testing 13 | treebuild.xml XML description of source file dependencies 14 | zconf.h.cmakein zconf.h template for cmake 15 | zconf.h.in zconf.h template for configure 16 | zlib.3 Man page for zlib 17 | zlib.3.pdf Man page in PDF format 18 | zlib.map Linux symbol information 19 | zlib.pc.in Template for pkg-config descriptor 20 | zlib.pc.cmakein zlib.pc template for cmake 21 | zlib2ansi perl script to convert source files for C++ compilation 22 | 23 | amiga/ makefiles for Amiga SAS C 24 | as400/ makefiles for AS/400 25 | doc/ documentation for formats and algorithms 26 | msdos/ makefiles for MSDOS 27 | nintendods/ makefile for Nintendo DS 28 | old/ makefiles for various architectures and zlib documentation 29 | files that have not yet been updated for zlib 1.2.x 30 | qnx/ makefiles for QNX 31 | watcom/ makefiles for OpenWatcom 32 | win32/ makefiles for Windows 33 | 34 | zlib public header files (required for library use): 35 | zconf.h 36 | zlib.h 37 | 38 | private source files used to build the zlib library: 39 | adler32.c 40 | compress.c 41 | crc32.c 42 | crc32.h 43 | deflate.c 44 | deflate.h 45 | gzclose.c 46 | gzguts.h 47 | gzlib.c 48 | gzread.c 49 | gzwrite.c 50 | infback.c 51 | inffast.c 52 | inffast.h 53 | inffixed.h 54 | inflate.c 55 | inflate.h 56 | inftrees.c 57 | inftrees.h 58 | trees.c 59 | trees.h 60 | uncompr.c 61 | zutil.c 62 | zutil.h 63 | 64 | source files for sample programs 65 | See examples/README.examples 66 | 67 | unsupported contributions by third parties 68 | See contrib/README.contrib 69 | -------------------------------------------------------------------------------- /Libs/zlib-1.2.11/contrib/masmx64/bld_ml64.bat: -------------------------------------------------------------------------------- 1 | ml64.exe /Flinffasx64 /c /Zi inffasx64.asm 2 | ml64.exe /Flgvmat64 /c /Zi gvmat64.asm 3 | -------------------------------------------------------------------------------- /Libs/zlib-1.2.11/contrib/masmx64/readme.txt: -------------------------------------------------------------------------------- 1 | Summary 2 | ------- 3 | This directory contains ASM implementations of the functions 4 | longest_match() and inflate_fast(), for 64 bits x86 (both AMD64 and Intel EM64t), 5 | for use with Microsoft Macro Assembler (x64) for AMD64 and Microsoft C++ 64 bits. 6 | 7 | gvmat64.asm is written by Gilles Vollant (2005), by using Brian Raiter 686/32 bits 8 | assembly optimized version from Jean-loup Gailly original longest_match function 9 | 10 | inffasx64.asm and inffas8664.c were written by Chris Anderson, by optimizing 11 | original function from Mark Adler 12 | 13 | Use instructions 14 | ---------------- 15 | Assemble the .asm files using MASM and put the object files into the zlib source 16 | directory. You can also get object files here: 17 | 18 | http://www.winimage.com/zLibDll/zlib124_masm_obj.zip 19 | 20 | define ASMV and ASMINF in your project. Include inffas8664.c in your source tree, 21 | and inffasx64.obj and gvmat64.obj as object to link. 22 | 23 | 24 | Build instructions 25 | ------------------ 26 | run bld_64.bat with Microsoft Macro Assembler (x64) for AMD64 (ml64.exe) 27 | 28 | ml64.exe is given with Visual Studio 2005, Windows 2003 server DDK 29 | 30 | You can get Windows 2003 server DDK with ml64 and cl for AMD64 from 31 | http://www.microsoft.com/whdc/devtools/ddk/default.mspx for low price) 32 | -------------------------------------------------------------------------------- /Libs/zlib-1.2.11/contrib/masmx86/bld_ml32.bat: -------------------------------------------------------------------------------- 1 | ml /coff /Zi /c /Flmatch686.lst match686.asm 2 | ml /coff /Zi /c /Flinffas32.lst inffas32.asm 3 | -------------------------------------------------------------------------------- /Libs/zlib-1.2.11/contrib/masmx86/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | Summary 3 | ------- 4 | This directory contains ASM implementations of the functions 5 | longest_match() and inflate_fast(). 6 | 7 | 8 | Use instructions 9 | ---------------- 10 | Assemble using MASM, and copy the object files into the zlib source 11 | directory, then run the appropriate makefile, as suggested below. You can 12 | donwload MASM from here: 13 | 14 | http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=7a1c9da0-0510-44a2-b042-7ef370530c64 15 | 16 | You can also get objects files here: 17 | 18 | http://www.winimage.com/zLibDll/zlib124_masm_obj.zip 19 | 20 | Build instructions 21 | ------------------ 22 | * With Microsoft C and MASM: 23 | nmake -f win32/Makefile.msc LOC="-DASMV -DASMINF" OBJA="match686.obj inffas32.obj" 24 | 25 | * With Borland C and TASM: 26 | make -f win32/Makefile.bor LOCAL_ZLIB="-DASMV -DASMINF" OBJA="match686.obj inffas32.obj" OBJPA="+match686c.obj+match686.obj+inffas32.obj" 27 | 28 | -------------------------------------------------------------------------------- /Libs/zlib-1.2.11/contrib/vstudio/vc10/miniunz.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {048af943-022b-4db6-beeb-a54c34774ee2} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm 7 | 8 | 9 | {c1d600d2-888f-4aea-b73e-8b0dd9befa0c} 10 | h;hpp;hxx;hm;inl;inc 11 | 12 | 13 | {0844199a-966b-4f19-81db-1e0125e141b9} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Libs/zlib-1.2.11/contrib/vstudio/vc10/minizip.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {c0419b40-bf50-40da-b153-ff74215b79de} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm 7 | 8 | 9 | {bb87b070-735b-478e-92ce-7383abb2f36c} 10 | h;hpp;hxx;hm;inl;inc 11 | 12 | 13 | {f46ab6a6-548f-43cb-ae96-681abb5bd5db} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Libs/zlib-1.2.11/contrib/vstudio/vc10/testzlib.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {c1f6a2e3-5da5-4955-8653-310d3efe05a9} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm 7 | 8 | 9 | {c2aaffdc-2c95-4d6f-8466-4bec5890af2c} 10 | h;hpp;hxx;hm;inl;inc 11 | 12 | 13 | {c274fe07-05f2-461c-964b-f6341e4e7eb5} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | Source Files 53 | 54 | 55 | Source Files 56 | 57 | 58 | -------------------------------------------------------------------------------- /Libs/zlib-1.2.11/contrib/vstudio/vc10/testzlibdll.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {fa61a89f-93fc-4c89-b29e-36224b7592f4} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm 7 | 8 | 9 | {d4b85da0-2ba2-4934-b57f-e2584e3848ee} 10 | h;hpp;hxx;hm;inl;inc 11 | 12 | 13 | {e573e075-00bd-4a7d-bd67-a8cc9bfc5aca} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Libs/zlib-1.2.11/contrib/vstudio/vc10/zlib.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define IDR_VERSION1 1 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE 5 | FILEVERSION 1, 2, 11, 0 6 | PRODUCTVERSION 1, 2, 11, 0 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 8 | FILEFLAGS 0 9 | FILEOS VOS_DOS_WINDOWS32 10 | FILETYPE VFT_DLL 11 | FILESUBTYPE 0 // not used 12 | BEGIN 13 | BLOCK "StringFileInfo" 14 | BEGIN 15 | BLOCK "040904E4" 16 | //language ID = U.S. English, char set = Windows, Multilingual 17 | 18 | BEGIN 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" 20 | VALUE "FileVersion", "1.2.11\0" 21 | VALUE "InternalName", "zlib\0" 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" 23 | VALUE "ProductName", "ZLib.DLL\0" 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" 25 | VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0" 26 | END 27 | END 28 | BLOCK "VarFileInfo" 29 | BEGIN 30 | VALUE "Translation", 0x0409, 1252 31 | END 32 | END 33 | -------------------------------------------------------------------------------- /Libs/zlib-1.2.11/contrib/vstudio/vc11/zlib.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define IDR_VERSION1 1 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE 5 | FILEVERSION 1, 2, 11, 0 6 | PRODUCTVERSION 1, 2, 11, 0 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 8 | FILEFLAGS 0 9 | FILEOS VOS_DOS_WINDOWS32 10 | FILETYPE VFT_DLL 11 | FILESUBTYPE 0 // not used 12 | BEGIN 13 | BLOCK "StringFileInfo" 14 | BEGIN 15 | BLOCK "040904E4" 16 | //language ID = U.S. English, char set = Windows, Multilingual 17 | 18 | BEGIN 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" 20 | VALUE "FileVersion", "1.2.11\0" 21 | VALUE "InternalName", "zlib\0" 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" 23 | VALUE "ProductName", "ZLib.DLL\0" 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" 25 | VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0" 26 | END 27 | END 28 | BLOCK "VarFileInfo" 29 | BEGIN 30 | VALUE "Translation", 0x0409, 1252 31 | END 32 | END 33 | -------------------------------------------------------------------------------- /Libs/zlib-1.2.11/contrib/vstudio/vc12/zlib.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define IDR_VERSION1 1 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE 5 | FILEVERSION 1, 2, 11, 0 6 | PRODUCTVERSION 1, 2, 11, 0 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 8 | FILEFLAGS 0 9 | FILEOS VOS_DOS_WINDOWS32 10 | FILETYPE VFT_DLL 11 | FILESUBTYPE 0 // not used 12 | BEGIN 13 | BLOCK "StringFileInfo" 14 | BEGIN 15 | BLOCK "040904E4" 16 | //language ID = U.S. English, char set = Windows, Multilingual 17 | 18 | BEGIN 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" 20 | VALUE "FileVersion", "1.2.11\0" 21 | VALUE "InternalName", "zlib\0" 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" 23 | VALUE "ProductName", "ZLib.DLL\0" 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" 25 | VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0" 26 | END 27 | END 28 | BLOCK "VarFileInfo" 29 | BEGIN 30 | VALUE "Translation", 0x0409, 1252 31 | END 32 | END 33 | -------------------------------------------------------------------------------- /Libs/zlib-1.2.11/contrib/vstudio/vc14/zlib.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define IDR_VERSION1 1 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE 5 | FILEVERSION 1, 2, 11, 0 6 | PRODUCTVERSION 1, 2, 11, 0 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 8 | FILEFLAGS 0 9 | FILEOS VOS_DOS_WINDOWS32 10 | FILETYPE VFT_DLL 11 | FILESUBTYPE 0 // not used 12 | BEGIN 13 | BLOCK "StringFileInfo" 14 | BEGIN 15 | BLOCK "040904E4" 16 | //language ID = U.S. English, char set = Windows, Multilingual 17 | 18 | BEGIN 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" 20 | VALUE "FileVersion", "1.2.11\0" 21 | VALUE "InternalName", "zlib\0" 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" 23 | VALUE "ProductName", "ZLib.DLL\0" 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" 25 | VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0" 26 | END 27 | END 28 | BLOCK "VarFileInfo" 29 | BEGIN 30 | VALUE "Translation", 0x0409, 1252 31 | END 32 | END 33 | -------------------------------------------------------------------------------- /Libs/zlib-1.2.11/contrib/vstudio/vc9/zlib.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define IDR_VERSION1 1 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE 5 | FILEVERSION 1, 2, 11, 0 6 | PRODUCTVERSION 1, 2, 11, 0 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 8 | FILEFLAGS 0 9 | FILEOS VOS_DOS_WINDOWS32 10 | FILETYPE VFT_DLL 11 | FILESUBTYPE 0 // not used 12 | BEGIN 13 | BLOCK "StringFileInfo" 14 | BEGIN 15 | BLOCK "040904E4" 16 | //language ID = U.S. English, char set = Windows, Multilingual 17 | 18 | BEGIN 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" 20 | VALUE "FileVersion", "1.2.11\0" 21 | VALUE "InternalName", "zlib\0" 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" 23 | VALUE "ProductName", "ZLib.DLL\0" 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" 25 | VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0" 26 | END 27 | END 28 | BLOCK "VarFileInfo" 29 | BEGIN 30 | VALUE "Translation", 0x0409, 1252 31 | END 32 | END 33 | -------------------------------------------------------------------------------- /Libs/zlib-1.2.11/gzclose.c: -------------------------------------------------------------------------------- 1 | /* gzclose.c -- zlib gzclose() function 2 | * Copyright (C) 2004, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include "gzguts.h" 7 | 8 | /* gzclose() is in a separate file so that it is linked in only if it is used. 9 | That way the other gzclose functions can be used instead to avoid linking in 10 | unneeded compression or decompression routines. */ 11 | int ZEXPORT gzclose(file) 12 | gzFile file; 13 | { 14 | #ifndef NO_GZCOMPRESS 15 | gz_statep state; 16 | 17 | if (file == NULL) 18 | return Z_STREAM_ERROR; 19 | state = (gz_statep)file; 20 | 21 | return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); 22 | #else 23 | return gzclose_r(file); 24 | #endif 25 | } 26 | -------------------------------------------------------------------------------- /Libs/zlib-1.2.11/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); 12 | -------------------------------------------------------------------------------- /Libs/zlib-1.2.11/zlib.3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lioncash/ExtractData/e42dde4e96f00be68ac36f1b5b09b4a3211bd10a/Libs/zlib-1.2.11/zlib.3.pdf -------------------------------------------------------------------------------- /MD5.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct SMD5 4 | { 5 | char szABCD[32]; 6 | u32 adwABCD[4]; 7 | }; 8 | 9 | class CMD5 10 | { 11 | public: 12 | CMD5(); 13 | 14 | SMD5 Calculate(LPCTSTR file_path); 15 | SMD5 Calculate(const void* src, size_t src_size, const u32* initialize = nullptr, bool alignment = false); 16 | 17 | size_t CalculatePadding(size_t size); 18 | void AppendPadding(void* src, size_t src_size, u32 padding); 19 | 20 | protected: 21 | u32 CalculateSub1(u32 x, u32 y, u32 z); 22 | u32 CalculateSub2(u32 x, u32 y, u32 z); 23 | u32 CalculateSub3(u32 x, u32 y, u32 z); 24 | u32 CalculateSub4(u32 x, u32 y, u32 z); 25 | void CalculateSub5(u32& a, u32 b, u32 c, u32 d, u32 k, u32 s, u32 i); 26 | void CalculateSub6(u32& a, u32 b, u32 c, u32 d, u32 k, u32 s, u32 i); 27 | void CalculateSub7(u32& a, u32 b, u32 c, u32 d, u32 k, u32 s, u32 i); 28 | void CalculateSub8(u32& a, u32 b, u32 c, u32 d, u32 k, u32 s, u32 i); 29 | 30 | u32 RotateLeft(u32 value, u32 shift); 31 | void ValueToStr(char* md5_dst, u32 md5); 32 | void MD5ToStrings(char* md5_dst, const u32* md5); 33 | 34 | private: 35 | SMD5 m_md5_value; 36 | std::array m_x; 37 | }; 38 | -------------------------------------------------------------------------------- /Mzx.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Mzx.h" 3 | 4 | void CMzx::Decompress(u8* dst, size_t length, const u8* src) 5 | { 6 | std::array ring_buffer{}; 7 | u8 last1 = 0; 8 | u8 last2 = 0; 9 | 10 | const u8* psrc = src + 8; 11 | u8* pdst = dst; 12 | u32 ring_wpos = 0; 13 | int clear_count = 0; 14 | 15 | for (size_t i = 0; i < length; ) 16 | { 17 | if (clear_count <= 0) 18 | { 19 | clear_count = 0x1000; 20 | last1 = 0; 21 | last2 = 0; 22 | } 23 | clear_count -= (*psrc & 3) == 2 ? 1 : (*psrc >> 2) + 1; 24 | 25 | switch (*psrc & 3) 26 | { 27 | case 0: 28 | for (int j = *psrc >> 2; j >= 0; j--) 29 | { 30 | *pdst++ = last1; 31 | *pdst++ = last2; 32 | i += 2; 33 | } 34 | 35 | psrc++; 36 | break; 37 | 38 | case 1: 39 | { 40 | int j = *psrc++ >> 2; 41 | int k = *psrc++; 42 | k = -k * 2 - 2; 43 | 44 | for ( ; j >= 0; j--) 45 | { 46 | *pdst = pdst[k]; pdst++; 47 | *pdst = pdst[k]; pdst++; 48 | i += 2; 49 | } 50 | 51 | last1 = pdst[-2]; 52 | last2 = pdst[-1]; 53 | break; 54 | } 55 | 56 | case 2: 57 | last1 = *pdst++ = ring_buffer[(*psrc >> 2) * 2]; 58 | last2 = *pdst++ = ring_buffer[(*psrc >> 2) * 2 + 1]; 59 | i += 2; 60 | psrc++; 61 | break; 62 | 63 | default: 64 | for (int j = *psrc++ >> 2; j >= 0; j--) 65 | { 66 | last1 = ring_buffer[ring_wpos++] = *pdst++ = *psrc++; 67 | last2 = ring_buffer[ring_wpos++] = *pdst++ = *psrc++; 68 | ring_wpos &= 0x7f; 69 | i += 2; 70 | } 71 | break; 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Mzx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CMzx 4 | { 5 | public: 6 | void Decompress(u8* dst, size_t length, const u8* src); 7 | }; 8 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | ## License information 2 | You are using source code that is protected by the GPLv2. 3 | 4 | When making derivative works, please follow the GPL. 5 | 6 | 7 | ## Compile Information 8 | 9 | - Visual Studio 2017 10 | - libpng and zlib (included in the VS solution file) 11 | 12 | ## Long-term TODOs 13 | 14 | - Linux and macOS support. 15 | -------------------------------------------------------------------------------- /Reg.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Common.h" 3 | #include "Reg.h" 4 | 5 | bool CReg::GetValue(YCString& value, LPCTSTR key_path, LPCTSTR key_name) 6 | { 7 | // Retrieve the handle of the key name 8 | const LPTSTR next_key_path_component = PathFindNextComponent(key_path); 9 | const YCString full_key(key_path, next_key_path_component - key_path - 1); 10 | 11 | // Convert to a numeric handle name 12 | HKEY key; 13 | if (full_key == _T("HKEY_CLASSES_ROOT")) 14 | key = HKEY_CLASSES_ROOT; 15 | else if (full_key == _T("HKEY_CURRENT_USER")) 16 | key = HKEY_CURRENT_USER; 17 | else if (full_key == _T("HKEY_LOCAL_MACHINE")) 18 | key = HKEY_LOCAL_MACHINE; 19 | else if (full_key == _T("HKEY_USERS")) 20 | key = HKEY_USERS; 21 | else if (full_key == _T("HKEY_CURRENT_CONFIG")) 22 | key = HKEY_CURRENT_CONFIG; 23 | else 24 | return false; 25 | 26 | // Retrieve the name of the subkey 27 | const LPCTSTR key_path_end = key_path + lstrlen(key_path); 28 | const YCString sub_key(next_key_path_component, key_path_end - next_key_path_component); 29 | 30 | HKEY result; 31 | if (RegOpenKeyEx(key, sub_key, 0, KEY_QUERY_VALUE, &result) != 0) 32 | return false; 33 | 34 | u8 data[MAX_PATH]; 35 | DWORD data_size = sizeof(data); 36 | if (RegQueryValueEx(result, key_name, nullptr, nullptr, data, &data_size) != 0) 37 | return false; 38 | 39 | value = reinterpret_cast(data); 40 | 41 | RegCloseKey(result); 42 | 43 | return true; 44 | } 45 | -------------------------------------------------------------------------------- /Reg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CReg 4 | { 5 | public: 6 | bool GetValue(YCString& value, LPCTSTR key_path, LPCTSTR key_name); 7 | }; 8 | -------------------------------------------------------------------------------- /Search/AhxSearch.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Search/AhxSearch.h" 3 | 4 | #include "ArcFile.h" 5 | #include "Common.h" 6 | #include "UI/ProgressBar.h" 7 | #include "Utils/BitUtils.h" 8 | 9 | CAhxSearch::CAhxSearch() 10 | { 11 | InitHeader("\x80\x00\x00\x20\x11\x00\x00\x01\x00\x00", 10); 12 | InitFooter("AHXE(c)CRI", 10); 13 | } 14 | 15 | void CAhxSearch::Mount(CArcFile* archive) 16 | { 17 | SFileInfo file_info; 18 | 19 | // Get start address 20 | file_info.start = archive->GetArcPointer(); 21 | 22 | // Get file ssize 23 | archive->Seek(GetHeaderSize() + 2, FILE_CURRENT); 24 | archive->Read(&file_info.size_org, 4); 25 | file_info.size_org = BitUtils::Swap32(file_info.size_org) << 1; 26 | archive->GetProg()->UpdatePercent(4); 27 | 28 | // Search footer 29 | if (!SearchFooter(archive)) 30 | return; 31 | 32 | // Get exit address 33 | file_info.end = archive->GetArcPointer(); 34 | 35 | // Get compressedfile size 36 | file_info.size_cmp = file_info.end - file_info.start; 37 | 38 | archive->AddFileInfo(file_info, GetNumFiles(), _T(".ahx")); 39 | } 40 | -------------------------------------------------------------------------------- /Search/AhxSearch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SearchBase.h" 4 | 5 | class CAhxSearch final : public CSearchBase 6 | { 7 | public: 8 | CAhxSearch(); 9 | void Mount(CArcFile* archive) override; 10 | }; 11 | -------------------------------------------------------------------------------- /Search/BmpSearch.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Search/BmpSearch.h" 3 | 4 | #include "ArcFile.h" 5 | #include "Common.h" 6 | #include "UI/ProgressBar.h" 7 | 8 | CBmpSearch::CBmpSearch() 9 | { 10 | InitHeader("BM****\0\0\0\0\x36*\0\0\x28\0\0\0", 18); 11 | } 12 | 13 | void CBmpSearch::Mount(CArcFile* archive) 14 | { 15 | SFileInfo file_info; 16 | 17 | // Get start address 18 | file_info.start = archive->GetArcPointer(); 19 | 20 | // Get file size 21 | archive->Seek(2, FILE_CURRENT); 22 | archive->Read(&file_info.size_org, 4); 23 | 24 | // Corresponds to the case filesize 25 | if (file_info.size_org == 0) 26 | { 27 | // Get the full size 28 | archive->Seek(16, FILE_CURRENT); 29 | archive->Read(&file_info.size_org, 4); 30 | 31 | // If it is not written, also search the end of the BMP (avoids an infinite loop) 32 | if (file_info.size_org == 0) 33 | return; 34 | 35 | // +54(BMP header size) 36 | file_info.size_org += 54; 37 | } 38 | 39 | file_info.size_cmp = file_info.size_org; 40 | 41 | // Get exit address 42 | file_info.end = file_info.start + file_info.size_org; 43 | 44 | // Find the end of the BMP file 45 | archive->Seek(file_info.end, FILE_BEGIN); 46 | archive->GetProg()->UpdatePercent(file_info.size_org); 47 | 48 | archive->AddFileInfo(file_info, GetNumFiles(), _T(".bmp")); 49 | } 50 | -------------------------------------------------------------------------------- /Search/BmpSearch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SearchBase.h" 4 | 5 | class CBmpSearch final : public CSearchBase 6 | { 7 | public: 8 | CBmpSearch(); 9 | void Mount(CArcFile* archive) override; 10 | }; 11 | -------------------------------------------------------------------------------- /Search/JpgSearch.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Search/JpgSearch.h" 3 | 4 | #include "ArcFile.h" 5 | #include "Common.h" 6 | #include "UI/ProgressBar.h" 7 | #include "Utils/BitUtils.h" 8 | 9 | CJpgSearch::CJpgSearch() 10 | { 11 | InitHeader("\xFF\xD8\xFF\xE0**JFIF", 10); 12 | InitFooter("\xFF\xD9", 2); 13 | } 14 | 15 | void CJpgSearch::Mount(CArcFile* archive) 16 | { 17 | SFileInfo file_info; 18 | 19 | // Get start address 20 | file_info.start = archive->GetArcPointer(); 21 | 22 | // Skip FFD8 23 | archive->Seek(2, FILE_CURRENT); 24 | 25 | // JPEG Image Search 26 | while (true) 27 | { 28 | // Get marker 29 | std::array marker; 30 | if (archive->Read(marker.data(), marker.size()) == 0) 31 | return; 32 | 33 | // Exit the loop when we reach the JPEG image data 34 | if (std::memcmp(marker.data(), "\xFF\xDA", marker.size()) == 0) 35 | break; 36 | 37 | // Get the size of the data area 38 | u16 length; 39 | if (archive->ReadU16(&length) == 0) 40 | return; 41 | length = BitUtils::Swap16(length); 42 | 43 | // Advance to the next data area 44 | archive->Seek(length - 2, FILE_CURRENT); 45 | } 46 | 47 | // Advance the progress bar 48 | archive->GetProg()->UpdatePercent(archive->GetArcPointer() - file_info.start); 49 | 50 | // Get footer 51 | if (!SearchFooter(archive)) 52 | return; 53 | 54 | // Get exit address 55 | file_info.end = archive->GetArcPointer(); 56 | 57 | // Get file size 58 | file_info.size_org = file_info.end - file_info.start; 59 | file_info.size_cmp = file_info.size_org; 60 | 61 | archive->AddFileInfo(file_info, GetNumFiles(), _T(".jpg")); 62 | } 63 | -------------------------------------------------------------------------------- /Search/JpgSearch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SearchBase.h" 4 | 5 | class CJpgSearch final : public CSearchBase 6 | { 7 | public: 8 | CJpgSearch(); 9 | void Mount(CArcFile* archive) override; 10 | }; 11 | -------------------------------------------------------------------------------- /Search/MidSearch.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Search/MidSearch.h" 3 | 4 | #include "ArcFile.h" 5 | #include "Common.h" 6 | #include "UI/ProgressBar.h" 7 | #include "Utils/BitUtils.h" 8 | 9 | CMidSearch::CMidSearch() 10 | { 11 | InitHeader("MThd\0\0\0\x06", 8); 12 | } 13 | 14 | void CMidSearch::Mount(CArcFile* archive) 15 | { 16 | SFileInfo file_info; 17 | 18 | // Get the head position 19 | file_info.start = archive->GetArcPointer(); 20 | 21 | // Get the number of tracks 22 | u16 tracks; 23 | archive->SeekCur(GetHeaderSize() + 2); 24 | archive->ReadU16(&tracks); 25 | tracks = BitUtils::Swap16(tracks); 26 | archive->SeekCur(2); 27 | 28 | // Get end positions 29 | for (unsigned short cnt = 0; cnt < tracks; cnt++) 30 | { 31 | std::array marker; 32 | archive->Read(marker.data(), marker.size()); 33 | 34 | // Invalid MIDI 35 | if (std::memcmp(marker.data(), "MTrk", marker.size()) != 0) 36 | { 37 | return; 38 | } 39 | 40 | // Get track size 41 | u32 track_size; 42 | archive->ReadU32(&track_size); 43 | track_size = BitUtils::Swap32(track_size); 44 | 45 | // Advance to next track 46 | archive->SeekCur(track_size); 47 | } 48 | 49 | file_info.end = archive->GetArcPointer(); 50 | 51 | // Get file size 52 | file_info.size_org = file_info.end - file_info.start; 53 | file_info.size_cmp = file_info.size_org; 54 | 55 | // Update progress bar 56 | archive->GetProg()->UpdatePercent(file_info.size_org); 57 | 58 | archive->AddFileInfo(file_info, GetNumFiles(), _T(".mid")); 59 | } 60 | -------------------------------------------------------------------------------- /Search/MidSearch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SearchBase.h" 4 | 5 | //---------------------------------------------------------------------------------------- 6 | //-- MIDI Search Class ------------------------------------------------------------------- 7 | //---------------------------------------------------------------------------------------- 8 | 9 | class CMidSearch final : public CSearchBase 10 | { 11 | public: 12 | CMidSearch(); 13 | void Mount(CArcFile* archive) override; 14 | }; 15 | -------------------------------------------------------------------------------- /Search/MpgSearch.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Search/MpgSearch.h" 3 | 4 | #include "ArcFile.h" 5 | #include "Common.h" 6 | #include "UI/ProgressBar.h" 7 | 8 | CMpgSearch::CMpgSearch() 9 | { 10 | InitHeader("\x00\x00\x01\xBA\x21\x00\x01\x00", 8); 11 | InitFooter("\xFF\xFF\xFF\xFF\x00\x00\x01\xB9", 8); 12 | } 13 | 14 | void CMpgSearch::Mount(CArcFile* archive) 15 | { 16 | // Corresponds to CVM 17 | LPCTSTR file_extension = (lstrcmpi(archive->GetArcExten(), _T(".cvm")) == 0) ? _T(".sfd") : _T(".mpg"); 18 | 19 | SFileInfo file_info; 20 | 21 | // Get start address 22 | file_info.start = archive->GetArcPointer(); 23 | archive->Seek(GetHeaderSize(), FILE_CURRENT); 24 | archive->GetProg()->UpdatePercent(GetHeaderSize()); 25 | 26 | // Get footer 27 | if (!SearchFooter(archive)) 28 | return; 29 | 30 | // Get exit address 31 | file_info.end = archive->GetArcPointer(); 32 | 33 | // Get file size 34 | file_info.size_org = file_info.end - file_info.start; 35 | file_info.size_cmp = file_info.size_org; 36 | 37 | archive->AddFileInfo(file_info, GetNumFiles(), file_extension); 38 | } 39 | -------------------------------------------------------------------------------- /Search/MpgSearch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SearchBase.h" 4 | 5 | class CMpgSearch final : public CSearchBase 6 | { 7 | public: 8 | CMpgSearch(); 9 | void Mount(CArcFile* archive) override; 10 | }; 11 | -------------------------------------------------------------------------------- /Search/OggSearch.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Search/OggSearch.h" 3 | 4 | #include "ArcFile.h" 5 | #include "Common.h" 6 | #include "Sound/Ogg.h" 7 | #include "UI/ProgressBar.h" 8 | 9 | COggSearch::COggSearch() = default; 10 | 11 | void COggSearch::OnInit(const SOption* option) 12 | { 13 | if (option->bHighSearchOgg) 14 | InitHeader("\x4F\x67\x67\x53\x00\x02", 6); 15 | else 16 | InitHeader("\x4F\x67\x67\x53", 4); 17 | } 18 | 19 | void COggSearch::Mount(CArcFile* archive) 20 | { 21 | COgg ogg; 22 | ogg.Init(archive); 23 | 24 | SFileInfo file_info; 25 | 26 | // Get start address 27 | file_info.start = archive->GetArcPointer(); 28 | 29 | // Serial number when reading the header from memory 30 | u32 serial_no; 31 | archive->Seek(14, FILE_CURRENT); 32 | archive->ReadU32(&serial_no); 33 | 34 | archive->Seek(file_info.start, FILE_BEGIN); 35 | u32 read_count = 0; 36 | file_info.size_org = 0; 37 | 38 | while (true) 39 | { 40 | read_count++; 41 | 42 | // Read the OGG header 43 | const u32 page_size = ogg.ReadHeader(); 44 | OggPageHeader header = ogg.GetHeader(); 45 | 46 | //If the serial number is different than what we have 47 | if (header.serial_no != serial_no) 48 | { 49 | ogg.SeekToPreviousHeader(); 50 | break; 51 | } 52 | 53 | // If it is no longer OggS 54 | if (std::memcmp(header.pattern, GetHeader(), 4) != 0) 55 | { 56 | ogg.SeekToPreviousHeader(); 57 | break; 58 | } 59 | 60 | // Exit after the beginning of the OGG until we hit the next header 61 | if (read_count > 1 && std::memcmp(header.pattern, GetHeader(), 4) == 0 && header.type == 2) 62 | { 63 | ogg.SeekToPreviousHeader(); 64 | break; 65 | } 66 | 67 | // Exit after we hit the end of the file 68 | if (page_size == 0) 69 | break; 70 | 71 | // Add to the file size 72 | file_info.size_org += page_size; 73 | 74 | // Advance to the next OggS 75 | ogg.NextPage(); 76 | 77 | archive->GetProg()->UpdatePercent(page_size); 78 | } 79 | 80 | if (file_info.size_org == 0) 81 | return; 82 | 83 | file_info.size_cmp = file_info.size_org; 84 | 85 | // Get exit address 86 | file_info.end = file_info.start + file_info.size_org; 87 | 88 | archive->AddFileInfo(file_info, GetNumFiles(), _T(".ogg")); 89 | } 90 | -------------------------------------------------------------------------------- /Search/OggSearch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SearchBase.h" 4 | 5 | class COggSearch final : public CSearchBase 6 | { 7 | public: 8 | COggSearch(); 9 | void Mount(CArcFile* archive) override; 10 | 11 | private: 12 | void OnInit(const SOption* option) override; 13 | }; 14 | -------------------------------------------------------------------------------- /Search/PngSearch.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Search/PngSearch.h" 3 | 4 | #include "ArcFile.h" 5 | #include "Common.h" 6 | #include "UI/ProgressBar.h" 7 | #include "Utils/BitUtils.h" 8 | 9 | CPngSearch::CPngSearch() 10 | { 11 | InitHeader("\x89\x50\x4E\x47\x0D\x0A\x1A\x0A", 8); 12 | InitFooter("\x49\x45\x4E\x44\xAE\x42\x60\x82", 8); 13 | } 14 | 15 | void CPngSearch::Mount(CArcFile* archive) 16 | { 17 | SFileInfo file_info; 18 | 19 | // Get start address 20 | file_info.start = archive->GetArcPointer(); 21 | archive->SeekCur(GetHeaderSize()); 22 | 23 | // Search the file end 24 | std::array chunk_name; 25 | 26 | do 27 | { 28 | // Get chunk length 29 | u32 length; 30 | if (archive->ReadU32(&length) == 0) 31 | return; 32 | 33 | length = BitUtils::Swap32(length); 34 | 35 | // Get chunk name 36 | if (archive->Read(chunk_name.data(), chunk_name.size()) == 0) 37 | return; 38 | 39 | // Advance the file pointer to chunk length + CRC segments 40 | // if(length + 4 > archive->GetArcSize()) 41 | // { 42 | // return; 43 | // } 44 | 45 | archive->SeekCur(length + 4); 46 | } while (std::memcmp(chunk_name.data(), "IEND", chunk_name.size()) != 0); // Keep looping until IEND is reached 47 | 48 | // Get exit address 49 | file_info.end = archive->GetArcPointer(); 50 | 51 | // Get file size 52 | file_info.size_org = file_info.end - file_info.start; 53 | file_info.size_cmp = file_info.size_org; 54 | 55 | // Update progress bar 56 | archive->GetProg()->UpdatePercent(file_info.size_org); 57 | 58 | archive->AddFileInfo(file_info, GetNumFiles(), _T(".png")); 59 | } 60 | -------------------------------------------------------------------------------- /Search/PngSearch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SearchBase.h" 4 | 5 | class CPngSearch final : public CSearchBase 6 | { 7 | public: 8 | CPngSearch(); 9 | void Mount(CArcFile* archive) override; 10 | }; 11 | -------------------------------------------------------------------------------- /Search/SearchBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CArcFile; 4 | struct SOption; 5 | 6 | class CSearchBase 7 | { 8 | private: 9 | enum PatternType 10 | { 11 | PATTERN_HEADER, 12 | PATTERN_FOOTER 13 | }; 14 | 15 | public: 16 | static constexpr size_t SEARCH_BUFFER_SIZE = 4096; 17 | 18 | CSearchBase(); 19 | virtual ~CSearchBase(); 20 | 21 | void Init(); 22 | void Init(const SOption* option); 23 | 24 | const u8* GetHeader() const { return m_pattern[PATTERN_HEADER].pattern; } 25 | u32 GetHeaderSize() const { return m_pattern[PATTERN_HEADER].size; } 26 | const u8* GetFooter() const { return m_pattern[PATTERN_FOOTER].pattern; } 27 | u32 GetFooterSize() const { return m_pattern[PATTERN_FOOTER].size; } 28 | u32& GetNumFiles() { return m_num_files; } 29 | 30 | bool CmpHeader(const u8* buf) const { return CmpMem(buf, GetHeader(), GetHeaderSize()); } 31 | bool CmpFooter(const u8* buf) const { return CmpMem(buf, GetFooter(), GetFooterSize()); } 32 | 33 | bool CmpMem(const u8* data, const u8* pattern, size_t size) const; 34 | bool Search(const u8* data, u32 search_size); 35 | bool SearchFooter(CArcFile* archive); 36 | 37 | void SetOffset(u32 offset) { m_offset = offset; } 38 | u32 GetOffset() const { return m_offset; } 39 | 40 | virtual void Mount(CArcFile* archive) = 0; 41 | 42 | protected: 43 | // Virtual function for when you want to do something during initialization 44 | virtual void OnInit(const SOption* option) {} 45 | 46 | void InitHeader(const void* pattern, u32 size); 47 | void InitFooter(const void* pattern, u32 size); 48 | 49 | private: 50 | struct Pattern 51 | { 52 | // Pattern string 53 | u8 pattern[32]; 54 | u32 size; 55 | }; 56 | 57 | std::array m_pattern; 58 | u32 m_offset = 0; 59 | u32 m_num_files = 0; 60 | void InitPattern(const void* pattern, u32 size, PatternType type); 61 | }; 62 | -------------------------------------------------------------------------------- /Search/WavSearch.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Search/WavSearch.h" 3 | 4 | #include "ArcFile.h" 5 | #include "Common.h" 6 | #include "UI/ProgressBar.h" 7 | 8 | CWavSearch::CWavSearch() 9 | { 10 | InitHeader("RIFF****WAVE", 12); 11 | } 12 | 13 | void CWavSearch::Mount(CArcFile* archive) 14 | { 15 | SFileInfo file_info; 16 | 17 | // Get start address 18 | file_info.start = archive->GetArcPointer(); 19 | 20 | // Get file size 21 | archive->Seek(4, FILE_CURRENT); 22 | archive->Read(&file_info.size_org, 4); 23 | file_info.size_org += 8; 24 | file_info.size_cmp = file_info.size_org; 25 | 26 | // Get exit address 27 | file_info.end = file_info.start + file_info.size_org; 28 | 29 | // Go to the end of the WAV file 30 | archive->Seek(file_info.end, FILE_BEGIN); 31 | archive->GetProg()->UpdatePercent(file_info.size_org); 32 | 33 | archive->AddFileInfo(file_info, GetNumFiles(), _T(".wav")); 34 | } 35 | -------------------------------------------------------------------------------- /Search/WavSearch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SearchBase.h" 4 | 5 | class CWavSearch final : public CSearchBase 6 | { 7 | public: 8 | CWavSearch(); 9 | void Mount(CArcFile* archive) override; 10 | }; 11 | -------------------------------------------------------------------------------- /Search/WmvSearch.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Search/WmvSearch.h" 3 | 4 | #include "ArcFile.h" 5 | #include "Common.h" 6 | #include "UI/ProgressBar.h" 7 | 8 | CWmvSearch::CWmvSearch() 9 | { 10 | InitHeader("\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C", 16); 11 | InitFooter("\xA1\xDC\xAB\x8C\x47\xA9\xCF\x11\x8E\xE4\x00\xC0\x0C\x20\x53\x65\x68", 17); 12 | } 13 | 14 | void CWmvSearch::Mount(CArcFile* archive) 15 | { 16 | SFileInfo file_info; 17 | 18 | // Get start address 19 | file_info.start = archive->GetArcPointer(); 20 | archive->Seek(GetHeaderSize(), FILE_CURRENT); 21 | 22 | // Search the auxiliary header 23 | if (!SearchFooter(archive)) 24 | return; 25 | 26 | // Amount of progress advanced by the search bar 27 | const u64 search_offset = archive->GetArcPointer() - file_info.start - GetHeaderSize(); 28 | 29 | // Get file size 30 | archive->Seek(23, FILE_CURRENT); 31 | archive->Read(&file_info.size_org, 4); 32 | file_info.size_cmp = file_info.size_org; 33 | 34 | // Get exit address 35 | file_info.end = file_info.start + file_info.size_org; 36 | 37 | // Go to the end of the WMV file 38 | archive->Seek(file_info.end, FILE_BEGIN); 39 | archive->GetProg()->UpdatePercent(file_info.size_org - search_offset); 40 | 41 | archive->AddFileInfo(file_info, GetNumFiles(), _T(".wmv")); 42 | } 43 | -------------------------------------------------------------------------------- /Search/WmvSearch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SearchBase.h" 4 | 5 | class CWmvSearch final : public CSearchBase 6 | { 7 | public: 8 | CWmvSearch(); 9 | void Mount(CArcFile* archive) override; 10 | }; 11 | -------------------------------------------------------------------------------- /Sound/Ogg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ExtractBase.h" 4 | 5 | class CArcFile; 6 | 7 | #pragma pack(push, 1) 8 | struct OggPageHeader 9 | { 10 | u8 pattern[4]; 11 | u8 version; 12 | u8 type; 13 | u8 granule_position[8]; 14 | u32 serial_no; 15 | u32 page_no; 16 | u32 checksum; 17 | u8 page_segments; 18 | u8 segment_table[256]; 19 | }; 20 | #pragma pack(pop) 21 | 22 | class COgg final : public CExtractBase 23 | { 24 | public: 25 | bool Mount(CArcFile* archive) override; 26 | bool Decode(CArcFile* archive) override; 27 | void Decode(CArcFile* archive, u8* buf); 28 | 29 | void Init(CArcFile* archive); 30 | u32 ReadHeader(); 31 | u32 ReadHeader(const u8* buf); 32 | void NextPage(); 33 | void SeekToPreviousHeader(); 34 | 35 | void FixCRC(u8* data, u32 page_size); 36 | 37 | const OggPageHeader& GetHeader() const { return m_vheader; } 38 | 39 | private: 40 | u32 GetSegSize(const OggPageHeader& vheader) const; 41 | u32 GetPageSize(const OggPageHeader& vheader) const; 42 | u32 GetPageSize(const OggPageHeader& vheader, u32 segment_size) const; 43 | 44 | CArcFile* m_archive = nullptr; 45 | OggPageHeader m_vheader{}; 46 | u32 m_segment_size = 0; 47 | u32 m_page_size = 0; 48 | }; 49 | -------------------------------------------------------------------------------- /Sound/Wav.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Sound/Wav.h" 3 | 4 | #include "ArcFile.h" 5 | 6 | void CWav::Init(CArcFile* archive, u32 data_size, u32 freq, u16 channels, u16 bits) 7 | { 8 | m_archive = archive; 9 | 10 | InitHeader(data_size, freq, channels, bits); 11 | 12 | m_archive->OpenFile(_T(".wav")); 13 | m_archive->WriteFile(&m_header, sizeof(Header)); 14 | } 15 | 16 | void CWav::InitHeader(u32 data_size, u32 freq, u16 channels, u16 bits) 17 | { 18 | memcpy(m_header.riff_id, "RIFF", 4); 19 | m_header.file_size = data_size + 36; 20 | memcpy(m_header.wave_id, "WAVE", 4); 21 | memcpy(m_header.fmt_id, "fmt ", 4); 22 | m_header.chunk_byte = 0x10; // Linear PCM always converted to 16 23 | m_header.format_id = 0x01; // Linear PCM always converted to 1 24 | m_header.channels = channels; 25 | m_header.freq = freq; 26 | m_header.bps = freq * (bits >> 3) * channels; 27 | m_header.block_size = (bits >> 3) * channels; 28 | m_header.bits = bits; 29 | memcpy(m_header.data_id, "data", 4); 30 | m_header.data_size = data_size; 31 | } 32 | 33 | void CWav::Write() 34 | { 35 | m_archive->ReadWrite(m_header.data_size); 36 | } 37 | 38 | void CWav::Write(const u8* buf) 39 | { 40 | m_archive->WriteFile(buf, m_header.data_size); 41 | } 42 | 43 | void CWav::Write(const u8* buf, size_t size) 44 | { 45 | m_archive->WriteFile(buf, size); 46 | } 47 | -------------------------------------------------------------------------------- /Sound/Wav.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class CArcFile; 6 | 7 | class CWav final 8 | { 9 | public: 10 | void Init(CArcFile* archive, u32 data_size, u32 freq, u16 channels, u16 bits); 11 | void Write(); 12 | void Write(const u8* buf); 13 | void Write(const u8* buf, size_t size); 14 | 15 | private: 16 | void InitHeader(u32 data_size, u32 freq, u16 channels, u16 bits); 17 | 18 | // WAV Format 19 | struct Header 20 | { 21 | u8 riff_id[4]; // "RIFF" 22 | u32 file_size; // Filesize 23 | u8 wave_id[4]; // "WAVE" 24 | u8 fmt_id[4]; // "fmt " 25 | u32 chunk_byte; // fmt Number of bytes in chunk 26 | u16 format_id; // Format ID 27 | u16 channels; // Number of channels 28 | u32 freq; // Sampling rate 29 | u32 bps; // Data rate (Byte/sec) 30 | u16 block_size; // Block size (Byte/sample * Number of channels) 31 | u16 bits; // Number of bits per sample (bit/sample) 32 | u8 data_id[4]; // "data" 33 | u32 data_size; // Number of bytes of waveform data 34 | }; 35 | 36 | CArcFile* m_archive = nullptr; 37 | Header m_header{}; 38 | }; 39 | -------------------------------------------------------------------------------- /StdAfx.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | -------------------------------------------------------------------------------- /StdAfx.h: -------------------------------------------------------------------------------- 1 | #define WINVER 0x0603 2 | #define _WIN32_WINNT 0x0603 3 | #define _CRT_SECURE_NO_WARNINGS 4 | #define _CRT_NON_CONFORMING_SWPRINTFS 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | 49 | #include 50 | #include 51 | 52 | #ifdef _DEBUG 53 | #define _CRTDBG_MAP_ALLOC 54 | #include 55 | #include 56 | //#define new new(_NORMAL_BLOCK, __FILE__, __LINE__) 57 | #endif 58 | 59 | #include "Types.h" 60 | 61 | #include "Base/YCString.h" 62 | #include "Base/YCFileFind.h" 63 | #include "Base/YCFileFindSx.h" 64 | #include "Base/YCLibrary.h" 65 | #include "Base/YCLocalMemory.h" 66 | #include "Base/YCIni.h" 67 | #include "Base/YCFile.h" 68 | #include "Base/YCStdioFile.h" 69 | 70 | -------------------------------------------------------------------------------- /Susie.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CArcFile; 4 | 5 | struct SSusieInfo 6 | { 7 | YCString name; // Filename 8 | YCString version; // Version info 9 | YCString info; // Plugin info 10 | YCString supported_formats; // Supported formats 11 | BOOL has_config_dialog; // Presence or absence of a configuration dialog 12 | YCString path; // File path 13 | BOOL validity; // Validity 14 | YCLibrary plugin; // Module 15 | }; 16 | 17 | class CSusie 18 | { 19 | public: 20 | bool Mount(CArcFile* archive); 21 | bool Decode(CArcFile* archive); 22 | 23 | void Init(); 24 | void Apply(); 25 | 26 | void LoadSpi(const YCString& susie_folder_path); 27 | void SaveSpi(); 28 | 29 | std::vector& GetSusie() { return m_main; } 30 | std::vector& GetSusieTmp() { return m_temporary; } 31 | 32 | private: 33 | static std::vector m_main; 34 | static std::vector m_temporary; 35 | }; 36 | -------------------------------------------------------------------------------- /Types.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | using s8 = std::int8_t; 6 | using s16 = std::int16_t; 7 | using s32 = std::int32_t; 8 | using s64 = std::int64_t; 9 | 10 | using u8 = std::uint8_t; 11 | using u16 = std::uint16_t; 12 | using u32 = std::uint32_t; 13 | using u64 = std::uint64_t; 14 | -------------------------------------------------------------------------------- /UI/Ctrl/Button.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UI/Ctrl/Button.h" 3 | 4 | // Function that generates / creates a button 5 | HWND CButton::Create(HWND window, LPCTSTR caption, UINT id, int x, int y, int cx, int cy) 6 | { 7 | Init(window, id); 8 | return CreateCtrl(_T("BUTTON"), BS_PUSHBUTTON | WS_TABSTOP, caption, x, y, cx, cy); 9 | } 10 | 11 | void CButton::SetDef() 12 | { 13 | LONG_PTR style = GetWindowLongPtr(GetCtrlHandle(), GWL_STYLE); 14 | style |= BS_DEFPUSHBUTTON; 15 | SetWindowLongPtr(GetCtrlHandle(), GWL_STYLE, style); 16 | } 17 | -------------------------------------------------------------------------------- /UI/Ctrl/Button.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "UI/Ctrl/CtrlBase.h" 4 | 5 | class CButton : public CCtrlBase 6 | { 7 | public: 8 | HWND Create(HWND window, LPCTSTR caption, UINT id, int x = 0, int y = 0, int cx = 0, int cy = 0) override; 9 | void SetDef(); 10 | }; 11 | -------------------------------------------------------------------------------- /UI/Ctrl/CheckBox.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UI/Ctrl/CheckBox.h" 3 | 4 | HWND CCheckBox::Create(HWND window, LPCTSTR caption, UINT id, int x, int y, int cx, int cy) 5 | { 6 | Init(window, id); 7 | return CreateCtrl(_T("BUTTON"), BS_AUTOCHECKBOX | WS_TABSTOP, caption, x, y, cx, cy); 8 | } 9 | 10 | void CCheckBox::SetCheck(BOOL flag) 11 | { 12 | Button_SetCheck(GetCtrlHandle(), flag); 13 | } 14 | 15 | BOOL CCheckBox::GetCheck() const 16 | { 17 | return Button_GetCheck(GetCtrlHandle()); 18 | } 19 | -------------------------------------------------------------------------------- /UI/Ctrl/CheckBox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "UI/Ctrl/CtrlBase.h" 4 | 5 | class CCheckBox : public CCtrlBase 6 | { 7 | public: 8 | HWND Create(HWND window, LPCTSTR caption, UINT id, int x = 0, int y = 0, int cx = 0, int cy = 0) override; 9 | 10 | void SetCheck(BOOL flag); 11 | BOOL GetCheck() const; 12 | }; 13 | -------------------------------------------------------------------------------- /UI/Ctrl/Color.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UI/Ctrl/Color.h" 3 | 4 | void CColor::Init(COLORREF color) 5 | { 6 | m_cc.lStructSize = sizeof(CHOOSECOLOR); 7 | m_cc.rgbResult = color; 8 | m_cc.Flags = CC_RGBINIT; 9 | } 10 | 11 | BOOL CColor::DoModal(HWND window) 12 | { 13 | m_cc.hwndOwner = window; 14 | return ChooseColor(&m_cc); 15 | } 16 | 17 | COLORREF CColor::GetColor() const 18 | { 19 | return m_cc.rgbResult; 20 | } 21 | -------------------------------------------------------------------------------- /UI/Ctrl/Color.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CColor 4 | { 5 | public: 6 | void Init(COLORREF color); 7 | BOOL DoModal(HWND window); 8 | 9 | COLORREF GetColor() const; 10 | 11 | private: 12 | CHOOSECOLOR m_cc; 13 | }; 14 | -------------------------------------------------------------------------------- /UI/Ctrl/CtrlBase.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UI/Ctrl/CtrlBase.h" 3 | 4 | CCtrlBase::CCtrlBase() = default; 5 | 6 | CCtrlBase::~CCtrlBase() = default; 7 | 8 | void CCtrlBase::Init(HWND window, UINT id) 9 | { 10 | m_window = window; 11 | m_inst = reinterpret_cast(GetWindowLongPtr(window, GWLP_HINSTANCE)); 12 | m_id = id; 13 | m_font.Create(); 14 | } 15 | 16 | HWND CCtrlBase::GetHandle() const 17 | { 18 | return m_window; 19 | } 20 | 21 | HINSTANCE CCtrlBase::GetInst() const 22 | { 23 | return m_inst; 24 | } 25 | 26 | HWND CCtrlBase::GetCtrlHandle() const 27 | { 28 | return m_ctrl; 29 | } 30 | 31 | UINT CCtrlBase::GetID() const 32 | { 33 | return m_id; 34 | } 35 | 36 | HFONT CCtrlBase::GetFont() const 37 | { 38 | return m_font.GetFont(); 39 | } 40 | 41 | HWND CCtrlBase::CreateCtrl(LPCTSTR class_name, DWORD style, LPCTSTR caption, int x, int y, int cx, int cy, DWORD ex_style) 42 | { 43 | style |= WS_CHILD | WS_VISIBLE; 44 | m_ctrl = ::CreateWindowEx(ex_style, 45 | class_name, caption, style, 46 | x, y, cx, cy, 47 | GetHandle(), reinterpret_cast(m_id), GetInst(), nullptr); 48 | 49 | SetFont(); 50 | 51 | return m_ctrl; 52 | } 53 | 54 | void CCtrlBase::SetFont() 55 | { 56 | SendMessage(GetCtrlHandle(), WM_SETFONT, reinterpret_cast(GetFont()), MAKELPARAM(TRUE, 0)); 57 | } 58 | 59 | void CCtrlBase::SetFocus() 60 | { 61 | ::SetFocus(GetCtrlHandle()); 62 | } 63 | 64 | void CCtrlBase::SetWindowPos(int x, int y, int cx, int cy) 65 | { 66 | MoveWindow(GetCtrlHandle(), x, y, cx, cy, TRUE); 67 | }; 68 | 69 | void CCtrlBase::Enable(bool flag) 70 | { 71 | EnableWindow(m_ctrl, flag != 0); 72 | } 73 | -------------------------------------------------------------------------------- /UI/Ctrl/CtrlBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "UI/Ctrl/Font.h" 4 | 5 | class CCtrlBase 6 | { 7 | public: 8 | CCtrlBase(); 9 | virtual ~CCtrlBase(); 10 | 11 | void Init(HWND window, UINT id); 12 | 13 | virtual HWND Create(HWND window, LPCTSTR caption, UINT id, int x = 0, int y = 0, int cx = 0, int cy = 0) = 0; 14 | 15 | HWND GetHandle() const; 16 | HINSTANCE GetInst() const; 17 | HWND GetCtrlHandle() const; 18 | UINT GetID() const; 19 | HFONT GetFont() const; 20 | 21 | void SetFont(); 22 | void SetFocus(); 23 | void SetWindowPos(int x, int y, int cx, int cy); 24 | 25 | void Enable(bool flag); 26 | 27 | protected: 28 | HWND CreateCtrl(LPCTSTR class_name, DWORD style, LPCTSTR caption, int x, int y, int cx, int cy, DWORD ex_style = 0); 29 | 30 | private: 31 | HWND m_window = nullptr; 32 | HINSTANCE m_inst = nullptr; 33 | HWND m_ctrl = nullptr; 34 | UINT m_id = 0; 35 | CFont m_font; 36 | }; 37 | -------------------------------------------------------------------------------- /UI/Ctrl/EditBox.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UI/Ctrl/EditBox.h" 3 | 4 | HWND CEditBox::Create(HWND window, LPCTSTR caption, UINT id, int x, int y, int cx, int cy) 5 | { 6 | Init(window, id); 7 | return CreateCtrl(_T("EDIT"), WS_BORDER | ES_AUTOHSCROLL | WS_TABSTOP, caption, x, y, cx, cy, WS_EX_CLIENTEDGE); 8 | } 9 | 10 | HWND CEditBox::Create(HWND window, DWORD caption_number, UINT id, int x, int y, int cx, int cy) 11 | { 12 | TCHAR caption[256]; 13 | _stprintf(caption, _T("%u"), caption_number); 14 | return Create(window, caption, id, x, y, cx, cy); 15 | } 16 | 17 | void CEditBox::GetText(LPTSTR text, int length) const 18 | { 19 | GetWindowText(GetCtrlHandle(), text, length); 20 | } 21 | 22 | void CEditBox::GetText(YCString& text) const 23 | { 24 | std::array window_text; 25 | GetWindowText(GetCtrlHandle(), window_text.data(), static_cast(window_text.size())); 26 | text = window_text.data(); 27 | } 28 | 29 | void CEditBox::GetText(LPDWORD text, BOOL hex) const 30 | { 31 | std::array window_text; 32 | GetWindowText(GetCtrlHandle(), window_text.data(), static_cast(window_text.size())); 33 | *text = (lstrcmp(window_text.data(), _T("")) == 0) ? 0 : (hex == FALSE) ? _tstoi(window_text.data()) : _tcstol(window_text.data(), nullptr, 16); 34 | } 35 | 36 | void CEditBox::SetText(LPCTSTR text) 37 | { 38 | SetWindowText(GetCtrlHandle(), text); 39 | } 40 | 41 | void CEditBox::SetLimit(int length) 42 | { 43 | SendMessage(GetCtrlHandle(), EM_SETLIMITTEXT, static_cast(length), 0); 44 | } 45 | -------------------------------------------------------------------------------- /UI/Ctrl/EditBox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "UI/Ctrl/CtrlBase.h" 4 | 5 | class CEditBox : public CCtrlBase 6 | { 7 | public: 8 | HWND Create(HWND window, LPCTSTR caption, UINT id, int x = 0, int y = 0, int cx = 0, int cy = 0) override; 9 | HWND Create(HWND window, DWORD caption_number, UINT id, int x = 0, int y = 0, int cx = 0, int cy = 0); 10 | void GetText(LPTSTR text, int length) const; 11 | void GetText(YCString& text) const; 12 | void GetText(LPDWORD text, BOOL hex) const; 13 | void SetText(LPCTSTR text); 14 | void SetLimit(int length); 15 | }; 16 | -------------------------------------------------------------------------------- /UI/Ctrl/Font.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UI/Ctrl/Font.h" 3 | 4 | CFont::CFont() 5 | { 6 | } 7 | 8 | CFont::~CFont() 9 | { 10 | if (m_font) 11 | DeleteObject(m_font); 12 | } 13 | 14 | // Function to set the font 15 | HFONT CFont::Create() 16 | { 17 | if (m_font == nullptr) 18 | { 19 | m_font = CreateFont( 20 | 13, // 0 if default font height (in logical units) 21 | 0, // Width, 0 if height is 0 22 | 0, // 10 times the angle of the display screen and the X-Axis 23 | 0, // Angle of each character 24 | 0, // Thickness 25 | 0, // Italics 26 | 0, // Underline 27 | 0, // Strikethrough 28 | DEFAULT_CHARSET, // Font Settings 29 | 0, // Approximation accuracy of the specified character and print character 30 | 0, // Accuracy when the character is outside the clipping region 31 | 0, // Output quality 32 | 0, // Character spacing 33 | // _T("MS UI Gothic") // The name of the typeface -- NOTE: This is the original typeface before I began translating the app 34 | _T("Segoe UI") // The name of the typeface -- NOTE: Changed to Segoe UI to make it better for English locale 35 | // TODO: Possibly make the font able to be set from within the application itself 36 | ); 37 | } 38 | 39 | return m_font; 40 | } 41 | 42 | HFONT CFont::GetFont() const 43 | { 44 | return m_font; 45 | } 46 | -------------------------------------------------------------------------------- /UI/Ctrl/Font.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CFont 4 | { 5 | public: 6 | CFont(); 7 | virtual ~CFont(); 8 | 9 | HFONT Create(); 10 | HFONT GetFont() const; 11 | 12 | private: 13 | HFONT m_font = nullptr; 14 | }; 15 | -------------------------------------------------------------------------------- /UI/Ctrl/GroupBox.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UI/Ctrl/GroupBox.h" 3 | 4 | HWND CGroupBox::Create(HWND window, LPCTSTR caption, UINT id, int x, int y, int cx, int cy) 5 | { 6 | Init(window, id); 7 | return CreateCtrl(_T("BUTTON"), BS_GROUPBOX, caption, x, y, cx, cy); 8 | } 9 | -------------------------------------------------------------------------------- /UI/Ctrl/GroupBox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "UI/Ctrl/CtrlBase.h" 4 | 5 | class CGroupBox : public CCtrlBase 6 | { 7 | public: 8 | HWND Create(HWND window, LPCTSTR caption, UINT id, int x, int y, int cx, int cy) override; 9 | }; 10 | -------------------------------------------------------------------------------- /UI/Ctrl/Label.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UI/Ctrl/Label.h" 3 | 4 | HWND CLabel::Create(HWND window, LPCTSTR caption, UINT id, int x, int y, int cx, int cy) 5 | { 6 | Init(window, id); 7 | return CreateCtrl(_T("STATIC"), SS_NOTIFY, caption, x, y, cx, cy); 8 | } 9 | -------------------------------------------------------------------------------- /UI/Ctrl/Label.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "UI/Ctrl/CtrlBase.h" 4 | 5 | class CLabel : public CCtrlBase 6 | { 7 | public: 8 | HWND Create(HWND window, LPCTSTR caption, UINT id, int x = 0, int y = 0, int cx = 0, int cy = 0) override; 9 | }; 10 | -------------------------------------------------------------------------------- /UI/Ctrl/ListView.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct SOption; 4 | 5 | // When you sort the list of parameters 6 | struct SORTPARAM 7 | { 8 | int column; 9 | bool direction; // 0 = ascending order, 1 = descending order 10 | }; 11 | 12 | class CListView 13 | { 14 | public: 15 | CListView(); 16 | virtual ~CListView(); 17 | 18 | void Init(HWND window, SOption& option); 19 | void SaveIni(); 20 | void Close(); 21 | 22 | void SetBkColor(); 23 | void SetTextColor(); 24 | 25 | void Sort(int column); 26 | void Enable(bool flag); 27 | void SetItemSelAll(u32 flag); 28 | void SetFocus(); 29 | void SetWindowPos(int x, int y, int cx, int cy); 30 | void Update(); 31 | 32 | u32 GetCountSel() const; 33 | int GetCount() const; 34 | HWND GetHandle() const; 35 | 36 | int GetNextItem(int nItem) const; 37 | int GetFocusItem() const; 38 | 39 | protected: 40 | HWND m_window = nullptr; 41 | HWND m_list = nullptr; 42 | HINSTANCE m_inst = nullptr; 43 | SOption* m_option = nullptr; 44 | SORTPARAM m_sort{}; 45 | static SORTPARAM* m_sort_ptr; 46 | 47 | HWND Create(u32 id, std::vector columns, int x = 0, int y = 0, int cx = 0, int cy = 0); 48 | 49 | template 50 | static bool retCompare(TYPE a, TYPE b) 51 | { 52 | return m_sort_ptr->direction ? (a > b) : (a < b); 53 | } 54 | 55 | virtual void OnSort() {} 56 | 57 | private: 58 | HIMAGELIST m_image = nullptr; 59 | u32 m_id = 0; 60 | }; 61 | -------------------------------------------------------------------------------- /UI/Ctrl/RadioBtn.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UI/Ctrl/RadioBtn.h" 3 | 4 | HWND CRadioBtn::Create(HWND window, LPCTSTR caption, UINT id, int x, int y, int cx, int cy) 5 | { 6 | Init(window, id); 7 | const DWORD group = (m_radios.empty()) ? WS_GROUP : 0; 8 | HWND radio = CreateCtrl(_T("BUTTON"), BS_AUTORADIOBUTTON | WS_TABSTOP | group, caption, x, y, cx, cy); 9 | m_radios.push_back(radio); 10 | m_ids.push_back(id); 11 | return radio; 12 | } 13 | 14 | void CRadioBtn::Close() 15 | { 16 | m_radios.clear(); 17 | m_ids.clear(); 18 | } 19 | 20 | void CRadioBtn::SetCheck(BOOL flag) 21 | { 22 | Button_SetCheck(GetCtrlHandle(), flag); 23 | } 24 | 25 | void CRadioBtn::SetCheck(DWORD num, BOOL flag) 26 | { 27 | Button_SetCheck(m_radios[num], flag); 28 | } 29 | 30 | BOOL CRadioBtn::GetCheck() const 31 | { 32 | return Button_GetCheck(GetCtrlHandle()); 33 | } 34 | 35 | BOOL CRadioBtn::GetCheck(DWORD num) const 36 | { 37 | return Button_GetCheck(m_radios[num]); 38 | } 39 | 40 | UINT CRadioBtn::GetID(DWORD num) const 41 | { 42 | return (num >= m_ids.size()) ? 0 : m_ids[num]; 43 | } 44 | -------------------------------------------------------------------------------- /UI/Ctrl/RadioBtn.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "UI/Ctrl/CtrlBase.h" 4 | 5 | class CRadioBtn : public CCtrlBase 6 | { 7 | public: 8 | HWND Create(HWND window, LPCTSTR caption, UINT id, int x = 0, int y = 0, int cx = 0, int cy = 0) override; 9 | 10 | void Close(); 11 | void SetCheck(BOOL flag); 12 | void SetCheck(DWORD num, BOOL flag); 13 | BOOL GetCheck() const; 14 | BOOL GetCheck(DWORD num) const; 15 | UINT GetID(DWORD num) const; 16 | 17 | private: 18 | std::vector m_radios; 19 | std::vector m_ids; 20 | }; 21 | -------------------------------------------------------------------------------- /UI/Ctrl/StatusBar.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UI/Ctrl/StatusBar.h" 3 | 4 | #include "Common.h" 5 | #include "UI/MainListView.h" 6 | 7 | constexpr u32 SB_SIZE = 2; 8 | 9 | CStatusBar::CStatusBar() 10 | { 11 | } 12 | 13 | void CStatusBar::Init(HWND window, SOption& option, CMainListView& listview) 14 | { 15 | m_window = window; 16 | m_option = &option; 17 | m_list_view = &listview; 18 | } 19 | 20 | // Function that creates a status bar 21 | HWND CStatusBar::Create(HWND window, SOption& option, CMainListView& listview) 22 | { 23 | Init(window, option, listview); 24 | 25 | HWND status_bar_window = CreateStatusWindow( 26 | WS_CHILD | WS_VISIBLE | CCS_BOTTOM, 27 | nullptr, 28 | m_window, 29 | ID_STATUS); 30 | m_status_bar_window = status_bar_window; 31 | 32 | int sb_size[SB_SIZE] = {}; 33 | SendMessage(status_bar_window, SB_SETPARTS, SB_SIZE, reinterpret_cast(sb_size)); 34 | 35 | SetCount(); 36 | 37 | return status_bar_window; 38 | } 39 | 40 | // Function to update the status bar: Displays the number of files 41 | void CStatusBar::SetCount() 42 | { 43 | TCHAR file_count[256]; 44 | _stprintf(file_count, _T("Files %d"), m_list_view->GetCount()); 45 | SendMessage(m_status_bar_window, SB_SETTEXT, 0 | 0, reinterpret_cast(file_count)); 46 | } 47 | 48 | void CStatusBar::SetWindowPos(int cx) 49 | { 50 | int sb_size[SB_SIZE]; 51 | sb_size[1] = cx; 52 | sb_size[0] = cx / 2; 53 | SendMessage(m_status_bar_window, SB_SETPARTS, SB_SIZE, reinterpret_cast(sb_size)); 54 | SendMessage(m_status_bar_window, WM_SIZE, 0, 0); 55 | } 56 | -------------------------------------------------------------------------------- /UI/Ctrl/StatusBar.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "UI/MainListView.h" 4 | 5 | class CStatusBar 6 | { 7 | public: 8 | CStatusBar(); 9 | 10 | void Init(HWND window, SOption& option, CMainListView& listview); 11 | HWND Create(HWND window, SOption& option, CMainListView& listview); 12 | void SetCount(); 13 | void SetWindowPos(int cx); 14 | 15 | protected: 16 | HWND m_window = nullptr; 17 | HWND m_status_bar_window = nullptr; 18 | SOption* m_option = nullptr; 19 | CMainListView* m_list_view = nullptr; 20 | }; 21 | -------------------------------------------------------------------------------- /UI/Ctrl/ToolBar.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CToolBar 4 | { 5 | public: 6 | CToolBar(); 7 | virtual ~CToolBar() = default; 8 | 9 | void Init(HWND window); 10 | HWND Create(HWND window, LPCTBBUTTON toolbar_button, UINT bitmap_id, int icon_cx, int ctIcon); 11 | 12 | virtual void LoadIni() {} 13 | virtual void SaveIni() {} 14 | 15 | virtual void SetWindowPos(); 16 | 17 | HWND GetHandle() const; 18 | HWND GetCtrlHandle() const; 19 | 20 | private: 21 | HWND m_window = nullptr; 22 | HINSTANCE m_inst = nullptr; 23 | HWND m_tool_bar = nullptr; 24 | }; 25 | -------------------------------------------------------------------------------- /UI/Ctrl/UpDown.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UI/Ctrl/UpDown.h" 3 | 4 | HWND CUpDown::Create(HWND window, HWND buddy, int pos, UINT id, int upper, int lower, int x, int y, int cx, int cy) 5 | { 6 | m_window = window; 7 | m_inst = reinterpret_cast(GetWindowLongPtr(window, GWLP_HINSTANCE)); 8 | m_id = id; 9 | 10 | m_ctrl = CreateUpDownControl( 11 | WS_CHILD | WS_BORDER | WS_VISIBLE | UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_WRAP | UDS_SETBUDDYINT, 12 | x, y, cx, cy, 13 | window, id, m_inst, buddy, 14 | upper, lower, pos); 15 | return m_ctrl; 16 | } 17 | -------------------------------------------------------------------------------- /UI/Ctrl/UpDown.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CUpDown 4 | { 5 | public: 6 | HWND Create(HWND window, HWND buddy, int pos, UINT id, int upper, int lower, int x = 0, int y = 0, int cx = 0, int cy = 0); 7 | 8 | private: 9 | HWND m_window = nullptr; 10 | HINSTANCE m_inst = nullptr; 11 | HWND m_ctrl = nullptr; 12 | UINT m_id = 0; 13 | }; 14 | -------------------------------------------------------------------------------- /UI/DataBase/DBListView.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Common.h" 4 | #include "UI/Ctrl/ListView.h" 5 | 6 | class CDBListView final : public CListView 7 | { 8 | public: 9 | void Create(HWND hWnd, SOption& option); 10 | void Show(NMLVDISPINFO* pDispInfo); 11 | 12 | void Sort(); 13 | void Sort(int column); 14 | static BOOL CompareFunc(const FILEINFODB& a, const FILEINFODB& b); 15 | void Update(int StartItem); 16 | 17 | private: 18 | std::vector m_entDB; 19 | }; 20 | -------------------------------------------------------------------------------- /UI/DataBase/DataBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ArcFile.h" 4 | #include "Common.h" 5 | #include "UI/Ctrl/Button.h" 6 | #include "UI/Ctrl/StatusBar.h" 7 | #include "UI/DataBase/DBListView.h" 8 | #include "UI/WindowBase.h" 9 | 10 | class CDataBase final : public CWindowBase 11 | { 12 | private: 13 | struct UndoRedo 14 | { 15 | std::vector entDB; 16 | std::vector selects; 17 | int focus; 18 | }; 19 | 20 | TCHAR m_DBFilePath[MAX_PATH]; 21 | HWND m_hWnd; 22 | std::vector m_UndoRedoList; 23 | bool m_bRedo; 24 | 25 | OPTION* m_pOption; 26 | CDBListView m_listview; 27 | CButton m_DelButton; 28 | CButton m_UndoButton; 29 | CButton m_AllSelButton; 30 | CButton m_EndButton; 31 | CStatusBar m_statusbar; 32 | 33 | public: 34 | CDataBase(); 35 | ~CDataBase(); 36 | 37 | int ReadFileInfo(); 38 | int DelFileInfo(); 39 | int SaveFileInfo(); 40 | 41 | int GetSelItem(std::vector* SelectedItemList); 42 | int GetUndo(); 43 | int GetRedo(); 44 | int SetUndo(); 45 | void ClearUndoRedo(); 46 | 47 | void DoModal(HWND hWnd); 48 | LRESULT WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp); 49 | 50 | BOOL Check(CArcFile* pArc); 51 | int Add(CArcFile* pArc); 52 | 53 | void SetOpt(OPTION& option) { m_pOption = &option; } 54 | }; 55 | -------------------------------------------------------------------------------- /UI/Dialog/ExistsDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UI/Dialog/ExistsDialog.h" 3 | 4 | #include "res/ResExtractData.h" 5 | 6 | DWORD CExistsDialog::m_overwrite; 7 | 8 | void CExistsDialog::DoModal(HWND window, LPCTSTR file_path) 9 | { 10 | if (m_overwrite == 0x01) 11 | { 12 | m_file_path = file_path; 13 | HINSTANCE inst = reinterpret_cast(GetWindowLongPtr(window, GWLP_HINSTANCE)); 14 | INT_PTR ret = DialogBoxParam(inst, _T("EXISTSDLG"), window, reinterpret_cast(WndStaticProc), reinterpret_cast(this)); 15 | if (ret == IDCANCEL) 16 | throw CExistsDialog(); 17 | } 18 | else if (m_overwrite == 0x10) 19 | { 20 | throw CExistsDialog(); 21 | } 22 | } 23 | 24 | LRESULT CExistsDialog::WndProc(HWND window, UINT msg, WPARAM wp, LPARAM lp) 25 | { 26 | switch (msg) 27 | { 28 | case WM_INITDIALOG: 29 | { 30 | Init(); 31 | SetWindowText(GetDlgItem(window, IDC_EXISTS_PATH), m_file_path); 32 | SetFocus(GetDlgItem(window, IDC_EXISTS_YES)); 33 | 34 | return FALSE; 35 | } 36 | 37 | case WM_COMMAND: 38 | { 39 | switch (LOWORD(wp)) 40 | { 41 | case IDC_EXISTS_YES: 42 | EndDialog(window, IDOK); 43 | return TRUE; 44 | 45 | case IDC_EXISTS_NO: 46 | case IDCANCEL: 47 | EndDialog(window, IDCANCEL); 48 | return TRUE; 49 | 50 | case IDC_EXISTS_ALLYES: 51 | m_overwrite = 0x00; 52 | EndDialog(window, IDOK); 53 | return TRUE; 54 | 55 | case IDC_EXISTS_ALLNO: 56 | m_overwrite = 0x10; 57 | EndDialog(window, IDCANCEL); 58 | return TRUE; 59 | } 60 | return FALSE; 61 | } 62 | } 63 | 64 | return FALSE; 65 | } 66 | -------------------------------------------------------------------------------- /UI/Dialog/ExistsDialog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "UI/WindowBase.h" 4 | 5 | class CExistsDialog : public CWindowBase 6 | { 7 | public: 8 | void DoModal(HWND window, LPCTSTR file_path); 9 | LRESULT WndProc(HWND window, UINT msg, WPARAM wp, LPARAM lp) override; 10 | DWORD& GetOverWrite() { return m_overwrite; } 11 | 12 | private: 13 | static DWORD m_overwrite; 14 | LPCTSTR m_file_path = nullptr; 15 | }; 16 | -------------------------------------------------------------------------------- /UI/Dialog/FileDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UI/Dialog/FileDialog.h" 3 | 4 | bool CFileDialog::DoModal(HWND window, LPTSTR file_names, LPTSTR dir) 5 | { 6 | OPENFILENAME ofn = {}; 7 | ofn.lStructSize = sizeof(ofn); 8 | ofn.hwndOwner = window; 9 | ofn.lpstrFilter = _T("All files (*.*)\0*.*\0\0"); 10 | ofn.lpstrFile = file_names; 11 | ofn.nFilterIndex = 1; 12 | ofn.nMaxFile = MAX_PATH * 1000; 13 | ofn.lpstrInitialDir = dir; 14 | ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_EXPLORER | OFN_ALLOWMULTISELECT; 15 | ofn.lpstrTitle = _T("Open File"); 16 | 17 | if (GetOpenFileName(&ofn) == 0) 18 | return false; 19 | 20 | GetCurrentDirectory(_MAX_DIR, dir); 21 | 22 | return true; 23 | } 24 | -------------------------------------------------------------------------------- /UI/Dialog/FileDialog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CFileDialog 4 | { 5 | public: 6 | static bool DoModal(HWND window, LPTSTR file_names, LPTSTR last_read_file_dir); 7 | }; 8 | -------------------------------------------------------------------------------- /UI/Dialog/FolderDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UI/Dialog/FolderDialog.h" 3 | 4 | #include "Common.h" 5 | 6 | bool CFolderDialog::DoModal(HWND window, LPCTSTR title, LPTSTR directory) 7 | { 8 | Microsoft::WRL::ComPtr dialog; 9 | auto hr = CoCreateInstance(CLSID_FileOpenDialog, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(dialog.GetAddressOf())); 10 | if (FAILED(hr)) 11 | return false; 12 | 13 | if (FAILED(dialog->SetTitle(YCStringW{title}))) 14 | return false; 15 | 16 | DWORD options; 17 | if (FAILED(dialog->GetOptions(&options))) 18 | return false; 19 | 20 | if (FAILED(dialog->SetOptions(options | FOS_PICKFOLDERS))) 21 | return false; 22 | 23 | if (FAILED(dialog->Show(window))) 24 | return false; 25 | 26 | Microsoft::WRL::ComPtr result; 27 | if (FAILED(dialog->GetResult(result.GetAddressOf()))) 28 | return false; 29 | 30 | wchar_t* folder_path; 31 | if (FAILED(result->GetDisplayName(SIGDN_FILESYSPATH, &folder_path))) 32 | return false; 33 | 34 | YCStringA folder_path_as_char{folder_path}; 35 | CoTaskMemFree(folder_path); 36 | 37 | std::memcpy(directory, folder_path_as_char.GetString(), folder_path_as_char.GetLength()); 38 | directory[folder_path_as_char.GetLength()] = '\0'; 39 | return true; 40 | } 41 | -------------------------------------------------------------------------------- /UI/Dialog/FolderDialog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CFolderDialog 4 | { 5 | public: 6 | bool DoModal(HWND window, LPCTSTR title, LPTSTR directory); 7 | }; 8 | -------------------------------------------------------------------------------- /UI/Dialog/FolderInputDialog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "UI/WindowBase.h" 4 | 5 | class CFolderInputDialog : public CWindowBase 6 | { 7 | public: 8 | INT_PTR DoModal(HWND window, LPTSTR save_dir); 9 | LRESULT WndProc(HWND window, UINT msg, WPARAM wp, LPARAM lp) override; 10 | 11 | private: 12 | LPTSTR m_save_dir = nullptr; 13 | }; 14 | -------------------------------------------------------------------------------- /UI/Dialog/SearchDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UI/Dialog/SearchDialog.h" 3 | 4 | #include "res/ResExtractData.h" 5 | #include "UI/Option.h" 6 | 7 | INT_PTR CSearchDialog::DoModal(HWND window, LPCTSTR archive_path) 8 | { 9 | m_archive_path = archive_path; 10 | HINSTANCE inst = reinterpret_cast(GetWindowLongPtr(window, GWLP_HINSTANCE)); 11 | return DialogBoxParam(inst, _T("SEARCHDLG"), window, reinterpret_cast(WndStaticProc), reinterpret_cast(this)); 12 | } 13 | 14 | LRESULT CSearchDialog::WndProc(HWND window, UINT msg, WPARAM wp, LPARAM lp) 15 | { 16 | static COption option; 17 | 18 | switch (msg) 19 | { 20 | case WM_INITDIALOG: 21 | Init(); 22 | TCHAR message[1024]; 23 | _stprintf(message, _T("%s is an unsupported file. \n Do you want to search through it anyway?"), m_archive_path); 24 | SetWindowText(GetDlgItem(window, IDC_SEARCH_MESSAGE), message); 25 | return FALSE; 26 | 27 | case WM_COMMAND: 28 | { 29 | switch (LOWORD(wp)) 30 | { 31 | case IDC_SEARCH_YES: 32 | EndDialog(window, IDYES); 33 | return TRUE; 34 | 35 | case IDC_SEARCH_NO: 36 | case IDCANCEL: 37 | EndDialog(window, IDNO); 38 | return TRUE; 39 | 40 | case IDC_SEARCH_OPTION: 41 | option.DoModal(window); 42 | return FALSE; 43 | } 44 | return FALSE; 45 | } 46 | } 47 | 48 | return FALSE; 49 | } 50 | -------------------------------------------------------------------------------- /UI/Dialog/SearchDialog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "UI/WindowBase.h" 4 | 5 | class CSearchDialog : public CWindowBase 6 | { 7 | public: 8 | INT_PTR DoModal(HWND window, LPCTSTR archive_path); 9 | LRESULT WndProc(HWND window, UINT msg, WPARAM wp, LPARAM lp) override; 10 | 11 | private: 12 | LPCTSTR m_archive_path = nullptr; 13 | }; 14 | -------------------------------------------------------------------------------- /UI/Dialog/VersionInfo.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UI/Dialog/VersionInfo.h" 3 | 4 | #include "res/ResExtractData.h" 5 | 6 | void CVersionInfo::DoModal(HWND window) 7 | { 8 | HINSTANCE inst = reinterpret_cast(GetWindowLongPtr(window, GWLP_HINSTANCE)); 9 | DialogBoxParam(inst, _T("MYVERSION"), window, reinterpret_cast(WndStaticProc), reinterpret_cast(this)); 10 | } 11 | 12 | // Version info dialog 13 | LRESULT CVersionInfo::WndProc(HWND window, UINT msg, WPARAM wp, LPARAM lp) 14 | { 15 | switch (msg) 16 | { 17 | case WM_INITDIALOG: 18 | Init(); 19 | SetFocus(GetDlgItem(window, IDC_OKBUTTON)); 20 | return FALSE; 21 | 22 | case WM_COMMAND: 23 | { 24 | switch (LOWORD(wp)) 25 | { 26 | case IDC_OKBUTTON: 27 | EndDialog(window, IDOK); 28 | return TRUE; 29 | 30 | case IDCANCEL: 31 | EndDialog(window, IDCANCEL); 32 | return TRUE; 33 | } 34 | return FALSE; 35 | } 36 | } 37 | 38 | return FALSE; 39 | } -------------------------------------------------------------------------------- /UI/Dialog/VersionInfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "UI/WindowBase.h" 4 | 5 | class CVersionInfo : public CWindowBase 6 | { 7 | public: 8 | void DoModal(HWND window); 9 | LRESULT WndProc(HWND window, UINT msg, WPARAM wp, LPARAM lp) override; 10 | }; 11 | -------------------------------------------------------------------------------- /UI/DragDrop/DataObject.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "UI/DragDrop/EnumFORMATETC.h" 4 | #include "UI/DragDrop/STGMEDIUM.h" 5 | 6 | class CDataObject : public IDataObject 7 | { 8 | public: 9 | CDataObject(); 10 | 11 | virtual HRESULT WINAPI QueryInterface(const IID& iid, LPVOID* ppv); 12 | virtual ULONG WINAPI AddRef(); 13 | virtual ULONG WINAPI Release(); 14 | 15 | virtual HRESULT WINAPI GetData(FORMATETC* pFormatetc, STGMEDIUM* pMedium); 16 | virtual HRESULT WINAPI GetDataHere(FORMATETC* pFormatetc, STGMEDIUM* pMedium); 17 | virtual HRESULT WINAPI QueryGetData(FORMATETC* pFormatetc); 18 | virtual HRESULT WINAPI GetCanonicalFormatEtc(FORMATETC* pFormatetcIn, FORMATETC* pFormatetcInOut); 19 | virtual HRESULT WINAPI SetData(FORMATETC* pFormatetc, STGMEDIUM* pMedium, BOOL bRelease); 20 | virtual HRESULT WINAPI EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC** ppEnumFormatetc); 21 | virtual HRESULT WINAPI DAdvise(FORMATETC* pFormatetc, DWORD advf, IAdviseSink* pAdvSink, DWORD *pdwConnection); 22 | virtual HRESULT WINAPI DUnadvise(DWORD dwConnection); 23 | virtual HRESULT WINAPI EnumDAdvise(IEnumSTATDATA** ppEnumAdvise); 24 | 25 | protected: 26 | class CObject 27 | { 28 | public: 29 | FORMATETC m_fmt; 30 | STGMEDIUM m_medium; 31 | 32 | public: 33 | CObject() 34 | { 35 | m_medium.tymed = TYMED_NULL; 36 | } 37 | 38 | ~CObject() 39 | { 40 | if (m_medium.tymed != TYMED_NULL) 41 | ReleaseStgMedium(&m_medium); 42 | } 43 | 44 | BOOL Set(FORMATETC* pf, STGMEDIUM* pm, BOOL bRelease) 45 | { 46 | m_fmt = *pf; 47 | 48 | if (bRelease) 49 | { 50 | m_medium = *pm; 51 | return TRUE; 52 | } 53 | 54 | return CSTGMEDIUM::Dup(&m_medium, pf, pm); 55 | } 56 | }; 57 | 58 | LONG m_RefCount; 59 | std::vector m_objects; 60 | }; 61 | -------------------------------------------------------------------------------- /UI/DragDrop/DropSource.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UI/DragDrop/DropSource.h" 3 | 4 | CDropSource::CDropSource() 5 | { 6 | m_RefCount = 1; 7 | } 8 | 9 | HRESULT WINAPI CDropSource::QueryInterface(const IID& iid, LPVOID* ppv) 10 | { 11 | if ((iid == IID_IDropSource) || (iid == IID_IUnknown)) 12 | { 13 | *ppv = (LPVOID)this; 14 | AddRef(); 15 | return S_OK; 16 | } 17 | 18 | *ppv = 0; 19 | return E_NOINTERFACE; 20 | } 21 | 22 | 23 | ULONG WINAPI CDropSource::AddRef() 24 | { 25 | InterlockedIncrement(&m_RefCount); 26 | return (ULONG)m_RefCount; 27 | } 28 | 29 | 30 | ULONG WINAPI CDropSource::Release() 31 | { 32 | if (InterlockedDecrement(&m_RefCount) == 0) 33 | delete this; 34 | 35 | return (ULONG)m_RefCount; 36 | } 37 | 38 | HRESULT WINAPI CDropSource::QueryContinueDrag(BOOL bEscapePressed, DWORD grfKeyState) 39 | { 40 | /* Decide whether or not to contine the drag */ 41 | 42 | /* When the mouse button is pressed or if the ESC has been pressed, both will discontinue the drag */ 43 | if (bEscapePressed || (MK_LBUTTON | MK_RBUTTON) == (grfKeyState & (MK_LBUTTON | MK_RBUTTON))) 44 | { 45 | return DRAGDROP_S_CANCEL; 46 | } 47 | 48 | /* When the mouse button is releasedd, then drop */ 49 | if ((grfKeyState & (MK_LBUTTON | MK_RBUTTON)) == 0) 50 | { 51 | return DRAGDROP_S_DROP; 52 | } 53 | 54 | return S_OK; 55 | } 56 | 57 | HRESULT WINAPI CDropSource::GiveFeedback(DWORD dwEffect) 58 | { 59 | /* Changing the mouse cursor to a special display is carried out here */ 60 | 61 | // Use standard mouse cursor 62 | return DRAGDROP_S_USEDEFAULTCURSORS; 63 | } 64 | -------------------------------------------------------------------------------- /UI/DragDrop/DropSource.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CDropSource : public IDropSource 4 | { 5 | private: 6 | LONG m_RefCount; 7 | 8 | public: 9 | CDropSource(); 10 | 11 | virtual HRESULT WINAPI QueryInterface(const IID& iid, LPVOID* ppv); 12 | virtual ULONG WINAPI AddRef(); 13 | virtual ULONG WINAPI Release(); 14 | 15 | virtual HRESULT WINAPI QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState); 16 | virtual HRESULT WINAPI GiveFeedback(DWORD dwEffect); 17 | }; 18 | -------------------------------------------------------------------------------- /UI/DragDrop/EnumFORMATETC.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UI/DragDrop/EnumFORMATETC.h" 3 | 4 | CEnumFORMATETC::CEnumFORMATETC() 5 | { 6 | m_RefCount = 1; 7 | m_current = 0; 8 | }; 9 | 10 | HRESULT WINAPI CEnumFORMATETC::QueryInterface(const IID& iid, LPVOID* ppv) 11 | { 12 | if (iid == IID_IEnumFORMATETC || iid == IID_IUnknown) 13 | { 14 | *ppv = (LPVOID)this; 15 | AddRef(); 16 | return S_OK; 17 | } 18 | 19 | *ppv = 0; 20 | return E_NOINTERFACE; 21 | } 22 | 23 | ULONG WINAPI CEnumFORMATETC::AddRef() 24 | { 25 | InterlockedIncrement(&m_RefCount); 26 | return (ULONG)m_RefCount; 27 | } 28 | 29 | ULONG WINAPI CEnumFORMATETC::Release() 30 | { 31 | if (InterlockedDecrement(&m_RefCount) == 0) 32 | delete this; 33 | 34 | return (ULONG)m_RefCount; 35 | } 36 | 37 | HRESULT WINAPI CEnumFORMATETC::Next(ULONG celt, FORMATETC* rgelt, ULONG* pceltFetched) 38 | { 39 | if (pceltFetched != NULL) 40 | *pceltFetched = 0; 41 | 42 | std::vector& fmt = m_fmt; 43 | if ((celt <= 0) || (rgelt == NULL) || (m_current >= fmt.size())) 44 | return S_FALSE; 45 | 46 | // pceltFetched can only be null when celt is 1 47 | if ((pceltFetched == NULL) && (celt != 1)) 48 | return S_FALSE; 49 | 50 | ULONG n = celt; 51 | while ((m_current < fmt.size()) && (n > 0)) 52 | { 53 | *rgelt++ = fmt[m_current]; 54 | m_current++; 55 | n--; 56 | } 57 | 58 | if (pceltFetched != NULL) 59 | *pceltFetched = celt - n; 60 | 61 | return (n == 0) ? S_OK : S_FALSE; 62 | } 63 | 64 | HRESULT WINAPI CEnumFORMATETC::Skip(ULONG celt) 65 | { 66 | size_t ctFmt = m_fmt.size(); 67 | 68 | while ((m_current < ctFmt) && (celt > 0)) 69 | { 70 | m_current++; 71 | celt--; 72 | } 73 | 74 | return (celt == 0) ? S_OK : S_FALSE; 75 | } 76 | 77 | HRESULT WINAPI CEnumFORMATETC::Reset() 78 | { 79 | m_current = 0; 80 | return S_OK; 81 | } 82 | 83 | HRESULT WINAPI CEnumFORMATETC::Clone(IEnumFORMATETC** ppEnum) 84 | { 85 | if (ppEnum == NULL) 86 | return E_POINTER; 87 | 88 | CEnumFORMATETC* pfmt = new CEnumFORMATETC; 89 | if (pfmt == NULL) 90 | return E_OUTOFMEMORY; 91 | 92 | pfmt->m_fmt = m_fmt; 93 | 94 | pfmt->m_current = m_current; 95 | *ppEnum = pfmt; 96 | 97 | return S_OK; 98 | } 99 | 100 | void CEnumFORMATETC::SetFormat(FORMATETC* fmt) 101 | { 102 | m_fmt.push_back(*fmt); 103 | } 104 | -------------------------------------------------------------------------------- /UI/DragDrop/EnumFORMATETC.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CEnumFORMATETC : public IEnumFORMATETC 4 | { 5 | friend class CEnumFORMATETC; 6 | 7 | public: 8 | CEnumFORMATETC(); 9 | 10 | virtual HRESULT WINAPI QueryInterface(const IID& iid, LPVOID* ppv); 11 | virtual ULONG WINAPI AddRef(); 12 | virtual ULONG WINAPI Release(); 13 | 14 | virtual HRESULT WINAPI Next(ULONG celt, FORMATETC* rgelt, ULONG* pceltFetched); 15 | virtual HRESULT WINAPI Skip(ULONG celt); 16 | virtual HRESULT WINAPI Reset(); 17 | virtual HRESULT WINAPI Clone(IEnumFORMATETC** ppEnum); 18 | 19 | void SetFormat(FORMATETC* fmt); 20 | 21 | private: 22 | LONG m_RefCount; 23 | 24 | protected: 25 | std::vector m_fmt; 26 | size_t m_current; 27 | }; 28 | -------------------------------------------------------------------------------- /UI/DragDrop/STGMEDIUM.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UI/DragDrop/STGMEDIUM.h" 3 | 4 | BOOL CSTGMEDIUM::Dup(STGMEDIUM* pdest, const FORMATETC* pFormatetc, const STGMEDIUM* pMedium) 5 | { 6 | HANDLE hVoid = NULL; 7 | 8 | switch (pMedium->tymed) 9 | { 10 | case TYMED_HGLOBAL: 11 | hVoid = OleDuplicateData(pMedium->hGlobal, pFormatetc->cfFormat, (UINT)NULL); 12 | pdest->hGlobal = (HGLOBAL)hVoid; 13 | break; 14 | 15 | case TYMED_GDI: 16 | hVoid = OleDuplicateData(pMedium->hBitmap, pFormatetc->cfFormat, (UINT)NULL); 17 | pdest->hBitmap = (HBITMAP)hVoid; 18 | break; 19 | 20 | case TYMED_MFPICT: 21 | hVoid = OleDuplicateData(pMedium->hMetaFilePict, pFormatetc->cfFormat, (UINT)NULL); 22 | pdest->hMetaFilePict = (HMETAFILEPICT)hVoid; 23 | break; 24 | 25 | case TYMED_ENHMF: 26 | hVoid = OleDuplicateData(pMedium->hEnhMetaFile, pFormatetc->cfFormat, (UINT)NULL); 27 | pdest->hEnhMetaFile = (HENHMETAFILE)hVoid; 28 | break; 29 | 30 | case TYMED_FILE: 31 | hVoid = OleDuplicateData(pMedium->lpszFileName, pFormatetc->cfFormat, (UINT)NULL); 32 | pdest->lpszFileName = (LPOLESTR)hVoid; 33 | break; 34 | } 35 | 36 | if (hVoid == NULL) 37 | return FALSE; 38 | 39 | pdest->tymed = pMedium->tymed; 40 | pdest->pUnkForRelease = pMedium->pUnkForRelease; 41 | if (pMedium->pUnkForRelease != NULL) 42 | pMedium->pUnkForRelease->AddRef(); 43 | 44 | return TRUE; 45 | } 46 | -------------------------------------------------------------------------------- /UI/DragDrop/STGMEDIUM.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CSTGMEDIUM 4 | { 5 | public: 6 | static BOOL Dup(STGMEDIUM* pdest, const FORMATETC* pFormatetc, const STGMEDIUM* pMedium); 7 | }; 8 | -------------------------------------------------------------------------------- /UI/ExtractData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Base/YCString.h" 4 | #include "Extract.h" 5 | #include "UI/WindowBase.h" 6 | 7 | #include 8 | 9 | class CArcFile; 10 | class CMainListView; 11 | struct SOption; 12 | 13 | enum class ExtractMode 14 | { 15 | Select, 16 | All 17 | }; 18 | 19 | class CExtractData : public CWindowBase, public CExtract 20 | { 21 | using ArchiveVector = std::vector>; 22 | public: 23 | CExtractData(); 24 | ~CExtractData() override; 25 | 26 | void Init(HWND parent, SOption& option, CMainListView& listview); 27 | 28 | void Open(LPTSTR open_dir); 29 | void OpenDrop(WPARAM wp); 30 | void OpenHistory(const YCString& file_path); 31 | void Mount(LPCTSTR archive_names); 32 | 33 | void SaveSel(LPTSTR pSaveDir, bool convert); 34 | void SaveAll(LPTSTR pSaveDir, bool convert); 35 | void SaveDrop(); 36 | void Decode(ExtractMode extract_mode, LPCTSTR save_dir, bool convert); 37 | void DecodeTmp(); 38 | 39 | void OpenRelate(); 40 | void DeleteTmpFile(); 41 | 42 | void LoadTmpFileList(); 43 | void SaveTmpFileList(); 44 | 45 | void Close(); 46 | 47 | ArchiveVector& GetArcList() { return m_archives; } 48 | 49 | LRESULT WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) override; 50 | 51 | private: 52 | HWND m_parent_window = nullptr; 53 | HINSTANCE m_parent_inst = nullptr; 54 | CMainListView* m_list_view = nullptr; 55 | TCHAR m_tmp_file_list_path[MAX_PATH]; 56 | 57 | LPCTSTR m_archive_names = nullptr; 58 | ExtractMode m_extract_mode = ExtractMode::Select; 59 | LPCTSTR m_save_dir = nullptr; 60 | bool m_convert = false; 61 | SOption* m_options = nullptr; 62 | bool m_input = false; 63 | ArchiveVector m_archives; 64 | 65 | std::set m_tmp_file_paths; 66 | 67 | void Save(ExtractMode extract_mode, LPTSTR save_dir, bool convert); 68 | static UINT WINAPI MountThread(LPVOID param); 69 | static UINT WINAPI DecodeThread(LPVOID param); 70 | }; 71 | -------------------------------------------------------------------------------- /UI/MainListView.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Common.h" 4 | #include "UI/Ctrl/ListView.h" 5 | 6 | class CMainListView : public CListView 7 | { 8 | public: 9 | void Create(HWND hWnd, SOption& option); 10 | void Show(); 11 | void Show(NMLVDISPINFO* disp_info); 12 | void ShowTip(LPNMLVGETINFOTIP tip); 13 | void Clear(); 14 | 15 | virtual void OnBeginDrag(NMHDR* nmhdr, LRESULT* result); 16 | 17 | std::vector& GetFileInfo() { return m_ent; } 18 | 19 | protected: 20 | void OnSort() override; 21 | 22 | private: 23 | std::vector m_ent; 24 | static bool CompareFunc(const SFileInfo& a, const SFileInfo& b); 25 | }; 26 | -------------------------------------------------------------------------------- /UI/MainToolBar.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "UI/Ctrl/ToolBar.h" 4 | 5 | class CArcFile; 6 | 7 | #define ID_TOOLBAR_OPEN_HISTORY 20000 8 | 9 | // Main toolbar 10 | class CMainToolBar : public CToolBar 11 | { 12 | public: 13 | HWND Create(HWND hWnd); 14 | void CreateMenuHistory(int iItem); 15 | void AddOpenHistory(std::vector>& archive_list); 16 | const std::vector& GetHistory() const { return m_open_history_list; } 17 | 18 | void LoadIni() override; 19 | void SaveIni() override; 20 | 21 | void SetWindowPos(int x, int y, int cx, int cy); 22 | 23 | private: 24 | std::vector m_open_history_list; 25 | }; 26 | 27 | // Search file toolbar 28 | class CSearchToolBar : public CToolBar 29 | { 30 | public: 31 | HWND Create(HWND hWnd); 32 | void SetCheckSearch(); 33 | void SetSearch(int nID); 34 | void SetWindowPos(int x, int y, int cx, int cy); 35 | 36 | private: 37 | int m_begin_id = 0; 38 | }; 39 | -------------------------------------------------------------------------------- /UI/Option.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Common.h" 4 | #include "UI/MainListView.h" 5 | #include "UI/MainToolBar.h" 6 | #include "UI/WindowBase.h" 7 | 8 | class COption : public CWindowBase 9 | { 10 | public: 11 | void Init(CSearchToolBar& toolbar, CMainListView& listview); 12 | void LoadIni(); 13 | static void SaveIni(); 14 | 15 | void DoModal(HWND hWnd); 16 | HWND CreateProp(HWND hWnd); 17 | 18 | SOption& GetOpt(); 19 | HWND GetParent() const; 20 | HWND GetHandle() const; 21 | 22 | private: 23 | static SOption m_option; 24 | static SOption m_option_tmp; 25 | static CMainListView* m_pListView; 26 | static CSearchToolBar* m_pToolBar; 27 | static HWND m_hDlg; 28 | static HWND m_hParentWnd; 29 | 30 | static int CALLBACK PropSheetProc(HWND hWnd, UINT msg, LPARAM lParam); 31 | static LRESULT CALLBACK StdProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp); 32 | static LRESULT CALLBACK ExtractProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp); 33 | static LRESULT CALLBACK SusieProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp); 34 | static void Apply(); 35 | }; 36 | -------------------------------------------------------------------------------- /UI/ProgressBar.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UI/ProgressBar.h" 3 | 4 | #include "res/ResExtractData.h" 5 | 6 | extern bool g_bThreadEnd; 7 | 8 | CProgBar::CProgBar() 9 | { 10 | } 11 | 12 | CProgBar::~CProgBar() 13 | { 14 | } 15 | 16 | void CProgBar::Init(HWND dlg, u64 all_file_size) 17 | { 18 | m_dlg = dlg; 19 | m_inst = reinterpret_cast(GetWindowLongPtr(dlg, GWLP_HINSTANCE)); 20 | m_all_file_size = all_file_size; 21 | m_dlg_item_percent = GetDlgItem(dlg, IDC_PERCENT); 22 | m_dlg_item_bar = GetDlgItem(dlg, IDC_PROGBAR1); 23 | m_dlg_item_archive = GetDlgItem(dlg, IDC_EXTFILENAME); 24 | SendMessage(m_dlg_item_bar, PBM_SETRANGE, static_cast(0), MAKELPARAM(0, 100)); 25 | // Show 0% 26 | UpdatePercent(0); 27 | } 28 | 29 | void CProgBar::ReplaceFileSize(u64 old_file_size, u64 new_file_size) 30 | { 31 | m_all_file_size = m_all_file_size - old_file_size + new_file_size; 32 | } 33 | 34 | void CProgBar::ReplaceAllFileSize(u64 new_file_size) 35 | { 36 | m_all_file_size += new_file_size; 37 | } 38 | 39 | // Function to update the percentage 40 | void CProgBar::UpdatePercent(u64 buffer_size) 41 | { 42 | m_prog_size += buffer_size; 43 | const int percent = static_cast(m_prog_size) / m_all_file_size * 100; 44 | 45 | if (percent > m_percent) 46 | { 47 | m_percent = percent; 48 | TCHAR percent_str[256]; 49 | _stprintf(percent_str, _T("%3d%%"), percent); 50 | SetWindowText(m_dlg_item_percent, percent_str); 51 | SendMessage(m_dlg_item_bar, PBM_SETPOS, percent, 0); 52 | } 53 | 54 | if (OnCancel()) 55 | throw -1; 56 | } 57 | 58 | // Function that updates to 100% 59 | void CProgBar::UpdatePercent() 60 | { 61 | UpdatePercent(m_all_file_size - m_prog_size); 62 | } 63 | 64 | void CProgBar::SetArcName(const YCString& archive_name) 65 | { 66 | // Show the archive file name 67 | SetWindowText(m_dlg_item_archive, archive_name); 68 | } 69 | 70 | void CProgBar::SetFileName(const YCString& file_name) 71 | { 72 | // Show the file name 73 | SetWindowText(m_dlg_item_archive, file_name); 74 | } 75 | 76 | // Function that is executed on canceling 77 | bool CProgBar::OnCancel() 78 | { 79 | return g_bThreadEnd; 80 | } 81 | -------------------------------------------------------------------------------- /UI/ProgressBar.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Common.h" 4 | 5 | class CProgBar 6 | { 7 | public: 8 | CProgBar(); 9 | ~CProgBar(); 10 | 11 | void Init(HWND dlg, u64 all_file_size); 12 | 13 | void ReplaceFileSize(u64 old_file_size, u64 new_file_size); 14 | void ReplaceAllFileSize(u64 new_file_size); 15 | void UpdatePercent(u64 buffer_size); 16 | void UpdatePercent(); 17 | void SetArcName(const YCString& archive_name); 18 | void SetFileName(const YCString& file_name); 19 | bool OnCancel(); 20 | 21 | HWND GetHandle() const { return m_dlg; } 22 | HINSTANCE GetInst() const { return m_inst; } 23 | 24 | protected: 25 | HWND m_dlg = nullptr; 26 | HINSTANCE m_inst = nullptr; 27 | HWND m_dlg_item_percent = nullptr; 28 | HWND m_dlg_item_bar = nullptr; 29 | HWND m_dlg_item_archive = nullptr; 30 | int m_percent = 0; 31 | u64 m_prog_size = 0; 32 | u64 m_all_file_size = 0; 33 | }; 34 | -------------------------------------------------------------------------------- /UI/SusieListView.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Susie.h" 4 | #include "UI/Ctrl/ListView.h" 5 | 6 | struct SOption; 7 | 8 | class CSusieListView : public CListView 9 | { 10 | public: 11 | void Create(HWND hWnd, SOption& option, int x = 0, int y = 0, int cx = 0, int cy = 0); 12 | void Show(); 13 | void Show(NMLVDISPINFO* disp_info); 14 | void ShowTip(LPNMLVGETINFOTIP tip); 15 | BOOL CustomDraw(LPNMLVCUSTOMDRAW custom_draw); 16 | void CreateMenu(LPARAM param); 17 | 18 | bool SetCheck(); 19 | void SetCheckAll(bool flag); 20 | 21 | SSusieInfo* GetFocusSusieInfo() { return &m_susie_info; } 22 | 23 | private: 24 | SSusieInfo m_susie_info; 25 | }; 26 | -------------------------------------------------------------------------------- /UI/WinMain.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "UI/WindowBase.h" 4 | 5 | class CWinMain : public CWindowBase 6 | { 7 | public: 8 | CWinMain(); 9 | ~CWinMain() override; 10 | 11 | int WinMain(HINSTANCE inst, HINSTANCE prev_inst, LPTSTR cmd_line, int cmd_show); 12 | ATOM InitApp(); 13 | bool InitInstance(); 14 | 15 | LRESULT WndProc(HWND window, UINT msg, WPARAM wp, LPARAM lp) override; 16 | 17 | void CreateMenu(LPARAM lp); 18 | void SetQuickMenu(HMENU menu); 19 | void SetQuickMenuItem(int id); 20 | 21 | protected: 22 | // Declaration for use in a member function 23 | WNDCLASSEX m_wc{}; 24 | 25 | // WinMain Arguments 26 | HINSTANCE m_inst = nullptr; 27 | HINSTANCE m_prev_inst = nullptr; 28 | LPTSTR m_cmd_line = nullptr; 29 | int m_cmd_show = 0; 30 | }; 31 | -------------------------------------------------------------------------------- /UI/WindowBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CWindowBase 4 | { 5 | public: 6 | CWindowBase(); 7 | virtual ~CWindowBase(); 8 | 9 | void Init(); 10 | void Init(LONG cx, LONG cy); 11 | void Init(UINT uID, LONG cx, LONG cy); 12 | static void Init(HWND window); 13 | static void Init(HWND window, LONG cx, LONG cy); 14 | void SaveIni(); 15 | 16 | bool Attach(HWND window); // Set 17 | bool Detach(); // Release 18 | 19 | // Static procedures 20 | static LRESULT CALLBACK WndStaticProc(HWND window, UINT msg, WPARAM wp, LPARAM lp); 21 | // Procedure for overriding 22 | virtual LRESULT WndProc(HWND window, UINT msg, WPARAM wp, LPARAM lp); 23 | 24 | void MoveWindowCenter(); 25 | void MoveWindowCenter(LONG cx, LONG cy); 26 | static void MoveWindowCenter(HWND window); 27 | static void MoveWindowCenter(HWND window, LONG cx, LONG cy); 28 | 29 | POINT GetCenterPt(const RECT& dlgrc); 30 | static POINT GetCenterPt(HWND window, const RECT& dlgrc); 31 | 32 | protected: 33 | HWND m_window = nullptr; 34 | HINSTANCE m_inst = nullptr; 35 | WNDPROC m_old_window_proc = nullptr; // Window procedure address 36 | bool m_is_dialog = false; // If dialog, then TRUE 37 | 38 | UINT m_id = 0; 39 | }; 40 | -------------------------------------------------------------------------------- /Utils/BitUtils.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Utils/BitUtils.h" 3 | 4 | namespace BitUtils 5 | { 6 | 7 | u16 Swap16(u16 value) 8 | { 9 | #ifdef _MSC_VER 10 | return _byteswap_ushort(value); 11 | #elif __linux__ 12 | return __builtin_bswap16(value); 13 | #else 14 | return (value << 8) | (value >> 8); 15 | #endif 16 | } 17 | 18 | u32 Swap32(u32 value) 19 | { 20 | #ifdef _MSC_VER 21 | return _byteswap_ulong(value); 22 | #elif __linux__ 23 | return __builtin_bswap32(value); 24 | #else 25 | return (Swap16(data) << 16) | Swap16(data >> 16); 26 | #endif 27 | } 28 | 29 | u64 Swap64(u64 value) 30 | { 31 | #ifdef _MSC_VER 32 | return _byteswap_uint64(value); 33 | #elif __linux__ 34 | return __builtin_bswap64(value); 35 | #else 36 | return (static_cast(Swap32(value)) << 32) | Swap32(value >> 32); 37 | #endif 38 | } 39 | 40 | u32 RotateLeft(const u32 value, int shift) 41 | { 42 | shift &= sizeof(value) * CHAR_BIT - 1; 43 | 44 | if (shift == 0) 45 | return value; 46 | 47 | return (value << shift) | (value >> (sizeof(value) * CHAR_BIT - shift)); 48 | } 49 | 50 | u32 RotateRight(const u32 value, int shift) 51 | { 52 | shift &= sizeof(value) * CHAR_BIT - 1; 53 | 54 | if (shift == 0) 55 | return value; 56 | 57 | return (value >> shift) | (value << (sizeof(value) * CHAR_BIT - shift)); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /Utils/BitUtils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace BitUtils 4 | { 5 | u16 Swap16(u16 value); 6 | u32 Swap32(u32 value); 7 | u64 Swap64(u64 value); 8 | 9 | u32 RotateLeft(u32 value, int shift); 10 | u32 RotateRight(u32 value, int shift); 11 | } 12 | -------------------------------------------------------------------------------- /gpl.ja.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lioncash/ExtractData/e42dde4e96f00be68ac36f1b5b09b4a3211bd10a/gpl.ja.txt -------------------------------------------------------------------------------- /res/ExtractData.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lioncash/ExtractData/e42dde4e96f00be68ac36f1b5b09b4a3211bd10a/res/ExtractData.ico -------------------------------------------------------------------------------- /res/ExtractData.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lioncash/ExtractData/e42dde4e96f00be68ac36f1b5b09b4a3211bd10a/res/ExtractData.rc -------------------------------------------------------------------------------- /res/MainToolBar.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lioncash/ExtractData/e42dde4e96f00be68ac36f1b5b09b4a3211bd10a/res/MainToolBar.bmp -------------------------------------------------------------------------------- /res/SearchToolBar.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lioncash/ExtractData/e42dde4e96f00be68ac36f1b5b09b4a3211bd10a/res/SearchToolBar.bmp --------------------------------------------------------------------------------