From efca9adbd4097d890015f4254250fb03423a4593 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Tue, 5 May 2020 20:22:58 +0200 Subject: [PATCH] v0.62 --- UnAlz.cpp | 45 +++++++++++++++++--------------- UnAlz.h | 69 ++++++++++++++++++++++++++------------------------ UnAlzBzip2.cpp | 2 +- UnAlzUtils.h | 2 +- UnAlzbzlib.c | 8 ++++++ clear.bat | 2 +- main.cpp | 9 ++++--- readme.txt | 4 +-- 8 files changed, 80 insertions(+), 61 deletions(-) diff --git a/UnAlz.cpp b/UnAlz.cpp index 6bd9ff3..7424d5e 100755 --- a/UnAlz.cpp +++ b/UnAlz.cpp @@ -1,7 +1,13 @@ -#include "zlib/zlib.h" #include "bzip2/bzlib.h" #include "UnAlz.h" +#ifdef _WIN32 +# include "zlib/zlib.h" +#else +# include +#endif + + // utime ÇÔ¼ö ó¸® #if defined(_WIN32) || defined(__CYGWIN__) # include @@ -23,8 +29,8 @@ # include #endif -#ifdef __linux__ // __BYTE_ORDER °¡Á®¿À±â -# include // iconv.h ¶§¹®¿¡ ÇÊ¿ä +#if defined(__linux__) || defined(__GLIBC__) || defined(__GNU__) +# include #endif #if defined(__NetBSD__) @@ -38,7 +44,7 @@ #endif #ifdef _WIN32 // safe string ó¸® -# include "strsafe.h" +# include #endif @@ -159,7 +165,7 @@ CUnAlz::CUnAlz() { memset(m_files, 0, sizeof(m_files)); m_nErr = ERR_NOERR; - m_posCur = (FileList::iterator)NULL; + m_posCur = m_fileList.end();//(FileList::iterator)NULL; m_pFuncCallBack = NULL; m_pCallbackParam = NULL; m_bHalt = FALSE; @@ -331,7 +337,7 @@ void CUnAlz::Close() i->Clear(); } - m_posCur = (FileList::iterator)NULL; + m_posCur = m_fileList.end();//(FileList::iterator)NULL; } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -377,7 +383,7 @@ BOOL CUnAlz::ReadAlzFileHeader() //////////////////////////////////////////////////////////////////////////////////////////////////// BOOL CUnAlz::ReadLocalFileheader() { - SLocalFileHeader zipHeader; + SAlzLocalFileHeader zipHeader; int ret; ret = FRead(&(zipHeader.head), sizeof(zipHeader.head)); @@ -509,7 +515,7 @@ BOOL CUnAlz::ReadLocalFileheader() */ if(IsEncryptedFile(zipHeader.head.fileDescriptor)) - FRead(zipHeader.encChk, ENCR_HEADER_LEN); // xf86 + FRead(zipHeader.encChk, ALZ_ENCR_HEADER_LEN); // xf86 // SKIP FILE DATA zipHeader.dwFileDataPos = FTell(); // data ÀÇ À§Ä¡ ÀúÀåÇϱâ.. @@ -641,7 +647,7 @@ BOOL CUnAlz::SetCurrentFile(const char* szFileName) } } - m_posCur = (FileList::iterator)NULL; + m_posCur = m_fileList.end();//(FileList::iterator)NULL; return FALSE; } @@ -682,8 +688,7 @@ BOOL CUnAlz::ExtractCurrentFileToBuf(BYTE* pDestBuf, int nBufSize) //////////////////////////////////////////////////////////////////////////////////////////////////// BOOL CUnAlz::ExtractCurrentFile(const char* szDestPathName, const char* szDestFileName) { - if(m_posCur==(FileList::iterator)NULL) {ASSERT(0); return FALSE;} - + if(m_posCur==m_fileList.end()/*(FileList::iterator)NULL*/) {ASSERT(0); return FALSE;} BOOL ret=FALSE; SExtractDest dest; @@ -832,7 +837,7 @@ BOOL CUnAlz::ExtractTo(SExtractDest* dest) /// @date 2004-03-06 ¿ÀÈÄ 11:09:17 //////////////////////////////////////////////////////////////////////////////////////////////////// /* -BOOL CUnAlz::ExtractDeflate(FILE* fp, SLocalFileHeader& file) +BOOL CUnAlz::ExtractDeflate(FILE* fp, SAlzLocalFileHeader& file) { z_stream stream; BYTE* pInBuf=NULL; @@ -1044,7 +1049,7 @@ int CUnAlz::WriteToDest(SExtractDest* dest, BYTE* buf, int nSize) #define BZIP2_TAIL_SIZE 10 // ´ëÃæ 4+5 Á¤µµ.? BYTE bzip2Header[BZIP2_HEADER_SIZE] = {0x42, 0x5a, 0x68, 0x39, 0x31, 0x41, 0x59, 0x26, 0x53, 0x59}; -BOOL CUnAlz::ExtractBzip2_bak(FILE* fp, SLocalFileHeader& file) +BOOL CUnAlz::ExtractBzip2_bak(FILE* fp, SAlzLocalFileHeader& file) { bz_stream stream; BYTE* pInBuf=NULL; @@ -1137,7 +1142,7 @@ END : /// @date 2004-03-06 ¿ÀÈÄ 11:10:53 //////////////////////////////////////////////////////////////////////////////////////////////////// #define BUF_LEN (4096*2) -BOOL CUnAlz::ExtractRawfile(SExtractDest* dest, SLocalFileHeader& file) +BOOL CUnAlz::ExtractRawfile(SExtractDest* dest, SAlzLocalFileHeader& file) { BOOL ret = FALSE; BYTE buf[BUF_LEN]; @@ -1213,7 +1218,7 @@ BOOL CUnAlz::ExtractRawfile(SExtractDest* dest, SLocalFileHeader& file) /// @date 2004-03-01 ¿ÀÀü 5:47:36 //////////////////////////////////////////////////////////////////////////////////////////////////// #define BZIP2_EXTRACT_BUF_SIZE 0x2000 -BOOL CUnAlz::ExtractBzip2(SExtractDest* dest, SLocalFileHeader& file) +BOOL CUnAlz::ExtractBzip2(SExtractDest* dest, SAlzLocalFileHeader& file) { BZFILE *bzfp = NULL; int smallMode = 0; @@ -1332,7 +1337,7 @@ BOOL CUnAlz::ExtractBzip2(SExtractDest* dest, SLocalFileHeader& file) /// @return /// @date 2004-03-06 ¿ÀÈÄ 11:11:36 //////////////////////////////////////////////////////////////////////////////////////////////////// -BOOL CUnAlz::ExtractDeflate2(SExtractDest* dest, SLocalFileHeader& file) +BOOL CUnAlz::ExtractDeflate2(SExtractDest* dest, SAlzLocalFileHeader& file) { z_stream stream; BYTE pInBuf[IN_BUF_SIZE]; @@ -1742,7 +1747,7 @@ void CUnAlz::CryptUpdateKeys(CHAR c) BOOL CUnAlz::CryptCheck(CHAR *buf) { CHAR b = 0; - for (int i = 0; i < ENCR_HEADER_LEN; i++) + for (int i = 0; i < ALZ_ENCR_HEADER_LEN; i++) { b = buf[i]; CryptDecode((CHAR&)b); @@ -1831,11 +1836,11 @@ BOOL CUnAlz::CryptCheck(const BYTE* buf) { int i; BYTE c; - BYTE temp[ENCR_HEADER_LEN]; + BYTE temp[ALZ_ENCR_HEADER_LEN]; - memcpy(temp, buf, ENCR_HEADER_LEN); // Àӽà º¹»ç. + memcpy(temp, buf, ALZ_ENCR_HEADER_LEN); // Àӽà º¹»ç. - for(i=0;i +#include #include using namespace std; @@ -212,10 +218,10 @@ namespace UNALZ # pragma pack(1) #endif -static const char UNALZ_VERSION[] = "CUnAlz0.61"; -static const char UNALZ_COPYRIGHT[] = "Copyright(C) 2004-2007 by hardkoder@gmail ( http://www.kipple.pe.kr ) "; +static const char UNALZ_VERSION[] = "CUnAlz0.62"; +static const char UNALZ_COPYRIGHT[] = "Copyright(C) 2004-2008 by kippler@gmail.com ( http://www.kipple.pe.kr ) "; -enum {ENCR_HEADER_LEN=12}; // xf86 +enum {ALZ_ENCR_HEADER_LEN=12}; // xf86 // ¸Ç ÆÄÀÏ ¾Õ.. struct SAlzHeader { @@ -263,7 +269,7 @@ enum ALZ_FILE_DESCRIPTOR ALZ_FILE_DESCRIPTOR_FILESIZEFIELD_8BYTE = 0x80, }; -struct _SLocalFileHeaderHead ///< °íÁ¤ Çì´õ. +struct _SAlzLocalFileHeaderHead ///< °íÁ¤ Çì´õ. { SHORT fileNameLength; BYTE fileAttribute; // from http://www.zap.pe.kr, enum FILE_ATTRIBUE Âü°í @@ -287,12 +293,12 @@ struct _SLocalFileHeaderHead ///< */ }; -struct SLocalFileHeader +struct SAlzLocalFileHeader { - SLocalFileHeader() { memset(this, 0, sizeof(*this)); } - //~SLocalFileHeader() { if(fileName) free(fileName); if(extraField) free(extraField); } + SAlzLocalFileHeader() { memset(this, 0, sizeof(*this)); } + //~SAlzLocalFileHeader() { if(fileName) free(fileName); if(extraField) free(extraField); } void Clear() { if(fileName) free(fileName); fileName=NULL; if(extraField) free(extraField);extraField=NULL; } - _SLocalFileHeaderHead head; + _SAlzLocalFileHeaderHead head; BYTE compressionMethod; ///< ¾ÐÃà ¹æ¹ý : 2 - deflate, 1 - º¯Çü bzip2, 0 - ¾ÐÃà ¾ÈÇÔ. BYTE unknown; @@ -305,10 +311,10 @@ struct SLocalFileHeader BYTE* extraField; INT64 dwFileDataPos; ///< file data °¡ ÀúÀåµÈ À§Ä¡.. - BYTE encChk[ENCR_HEADER_LEN]; // xf86 + BYTE encChk[ALZ_ENCR_HEADER_LEN]; // xf86 }; -struct _SCentralDirectoryStructureHead +struct _SAlzCentralDirectoryStructureHead { UINT32 dwUnknown; ///< Ç×»ó NULL ÀÌ´øµ¥.. UINT32 dwUnknown2; ///< ¾Æ¸¶µµ crc @@ -337,7 +343,7 @@ struct SCentralDirectoryStructure { SCentralDirectoryStructure() { memset(this, 0, sizeof(*this)); } //~SCentralDirectoryStructure() { if(fileName) free(fileName); if(extraField) free(extraField);if(fileComment)free(fileComment); } - _SCentralDirectoryStructureHead head; + _SAlzCentralDirectoryStructureHead head; /* CHAR* fileName; BYTE* extraField; @@ -372,14 +378,11 @@ struct SEndOfCentralDirectoryRecord #ifdef _WIN32 # pragma pack(pop, UNALZ) ///< PACKING ¿ø»ó º¹±¸ #else -# ifdef __LP64__ // 64bit ´Â ÆÐÅ·ÀÌ 8byte ¸Â³ª ? À߸𸣰ڴÙ..... -# pragma pack(8) -# else -# pragma pack(4) -# endif +# pragma pack() // restore packing #endif + ///< PROGRESS CALLBACK FUNCTION - ¾ÐÃà ÇØÁ¦ ÁøÇà »óȲÀ» ¾Ë°í ½ÍÀ¸¸é ÀÌ°É ¾²¸é µÈ´Ù. typedef void (_UnAlzCallback)(const char* szFileName, INT64 nCurrent, INT64 nRange, void* param, BOOL* bHalt); @@ -420,7 +423,7 @@ public : ///< WIN32 #endif // _WIN32 public : - typedef vector FileList; ///< ÆÄÀÏ ¸ñ·Ï. + typedef vector FileList; ///< ÆÄÀÏ ¸ñ·Ï. FileList* GetFileList() { return &m_fileList; }; ///< file ¸ñ·Ï ¸®ÅÏ void SetCurrentFile(FileList::iterator newPos); ///< low level Á¢±Ù.. FileList::iterator GetCurFileHeader() { return m_posCur; }; ///< ÇöÀç (SetCurrentFile() ·Î ¼¼ÆõÈ) ÆÄÀÏ Á¤º¸ @@ -518,11 +521,11 @@ private : private : BOOL ExtractTo(SExtractDest* dest); - //BOOL ExtractDeflate(FILE* fp, SLocalFileHeader& file); - //BOOL ExtractBzip2_bak(FILE* fp, SLocalFileHeader& file); - ½ÇÆÐÇÑ(À߸øµÈ) ¹æ¹ý - BOOL ExtractDeflate2(SExtractDest* dest, SLocalFileHeader& file); - BOOL ExtractBzip2(SExtractDest* dest, SLocalFileHeader& file); - BOOL ExtractRawfile(SExtractDest* dest, SLocalFileHeader& file); + //BOOL ExtractDeflate(FILE* fp, SAlzLocalFileHeader& file); + //BOOL ExtractBzip2_bak(FILE* fp, SAlzLocalFileHeader& file); - ½ÇÆÐÇÑ(À߸øµÈ) ¹æ¹ý + BOOL ExtractDeflate2(SExtractDest* dest, SAlzLocalFileHeader& file); + BOOL ExtractBzip2(SExtractDest* dest, SAlzLocalFileHeader& file); + BOOL ExtractRawfile(SExtractDest* dest, SAlzLocalFileHeader& file); private : // bzip2 ÆÄÀÏ Ã³¸® ÇÔ¼ö.. typedef void MYBZFILE; diff --git a/UnAlzBzip2.cpp b/UnAlzBzip2.cpp index 67b2c02..b4d764e 100755 --- a/UnAlzBzip2.cpp +++ b/UnAlzBzip2.cpp @@ -4,7 +4,7 @@ /// ¾à°£ÀÇ ¼öÁ¤À» °¡ÇÑ ¼Ò½ºµéÀÌ´Ù.. /// FILE* handle °ü·Ã ºÎºÐµéÀÌ ¼öÁ¤µÇ¾ú´Ù. /// -/// @author hardkoder@gmail.com +/// @author kippler@gmail.com /// @date 2004-10-03 ¿ÀÈÄ 3:09:11 /// //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/UnAlzUtils.h b/UnAlzUtils.h index 1d29b48..f8fe16a 100755 --- a/UnAlzUtils.h +++ b/UnAlzUtils.h @@ -2,7 +2,7 @@ /// /// unalz °ü·Ã À¯Æ¿ ¸ðÀ½ /// -/// @author hardkoder +/// @author kippler@gmail.com /// @date 2005-06-23 ¿ÀÈÄ 9:55:34 /// //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/UnAlzbzlib.c b/UnAlzbzlib.c index c297f06..794ce99 100755 --- a/UnAlzbzlib.c +++ b/UnAlzbzlib.c @@ -1,3 +1,11 @@ +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// +/// modified for .alz handling +/// +/// @author kippler@gmail.com +/// @date 2007-04-12 ¿ÀÈÄ 9:06:32 +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// // ALZ ¾ÐÃà ÇØÁ¦¸¦ À§Çؼ­ ¼öÁ¤µÈ bzip2 ¼Ò½º // [ALZ] ¶ó°í Ç¥½ÃµÈ ºÎºÐÀÌ ¼öÁ¤µÈ ºÎºÐÀÌ´Ù. diff --git a/clear.bat b/clear.bat index 29b0cd9..631cca1 100755 --- a/clear.bat +++ b/clear.bat @@ -1,4 +1,4 @@ -del *.plg *.obj *.o *.sbr *.pch *.pdb *.res *.bsc *.pcc *.idb *.pdb *.ncb *.aps *.ilk 2*.log *.map *.opt *.exp *.sup *.dpbcd gebug.txt *_d.exe *_d.dll *_d.lib *_debug.dll *_debug.exe *.tlh *.tli *.scc *.bak /s +del *.plg *.obj *.o *.sbr *.pch *.pdb *.res *.bsc *.pcc *.idb *.pdb *.ncb *.aps *.ilk 2*.log *.map *.opt *.exp *.sup *.dpbcd gebug.txt *_d.exe *_d.dll *_d.lib *_debug.dll *_debug.exe *.tlh *.tli *.scc *.bak *.suo *.vspscc /s del unalz.exe rmdir bin rmdir release diff --git a/main.cpp b/main.cpp index 2b77f42..3cba714 100755 --- a/main.cpp +++ b/main.cpp @@ -30,8 +30,9 @@ void Copyright() // printf("unalz v0.54 (2005/11/21) \n"); // printf("unalz v0.55 (2006/03/10) \n"); // printf("unalz v0.60 (2006/12/31) \n"); - printf("unalz v0.61 (2007/02/10) \n"); - printf("Copyright(C) 2004-2007 by hardkoder@gmail (http://www.kipple.pe.kr) \n"); +// printf("unalz v0.61 (2007/02/10) \n"); + printf("unalz v0.62 (2008/04/04) \n"); + printf("Copyright(C) 2004-2008 by kippler@gmail.com (http://www.kipple.pe.kr) \n"); } @@ -273,9 +274,11 @@ int main(int argc, char* argv[]) } else { + char temp[256]; char pwd[256]; printf("Enter Password : "); - fgets(pwd,256,stdin); + fgets(temp,256,stdin); + sscanf(temp, "%s\n", pwd); // remove \n unalz.SetPassword(pwd); } } diff --git a/readme.txt b/readme.txt index 237bcb8..9501f9f 100755 --- a/readme.txt +++ b/readme.txt @@ -1,8 +1,8 @@ - unalz v0.61 + unalz v0.62 - Copyright(C) 2004-2007 by hardkoder (http://www.kipple.pe.kr) + Copyright(C) 2004-2008 by hardkoder (http://www.kipple.pe.kr) - ÃÖÃÊ ÀÛ¼ºÀÏ : v0.20 - 2004/10/22