v0.62
This commit is contained in:
parent
f6f5938fe7
commit
efca9adbd4
8 changed files with 80 additions and 61 deletions
45
UnAlz.cpp
45
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 <zlib.h>
|
||||
#endif
|
||||
|
||||
|
||||
// utime 함수 처리
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
# include <time.h>
|
||||
|
@ -23,8 +29,8 @@
|
|||
# include <iconv.h>
|
||||
#endif
|
||||
|
||||
#ifdef __linux__ // __BYTE_ORDER 가져오기
|
||||
# include <errno.h> // iconv.h 때문에 필요
|
||||
#if defined(__linux__) || defined(__GLIBC__) || defined(__GNU__)
|
||||
# include <errno.h>
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
|
@ -38,7 +44,7 @@
|
|||
#endif
|
||||
|
||||
#ifdef _WIN32 // safe string 처리
|
||||
# include "strsafe.h"
|
||||
# include <strsafe.h>
|
||||
#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<ENCR_HEADER_LEN;i++)
|
||||
for(i=0;i<ALZ_ENCR_HEADER_LEN;i++)
|
||||
{
|
||||
c = temp[i] ^ DecryptByte();
|
||||
UpdateKeys(c);
|
||||
|
|
49
UnAlz.h
49
UnAlz.h
|
@ -2,7 +2,7 @@
|
|||
UNALZ : read and extract module for ALZ format.
|
||||
|
||||
LICENSE (zlib License)
|
||||
Copyright (C) 2004-2005 hardkoder@gmail , http://www.kipple.pe.kr
|
||||
Copyright (C) 2004-2007 kippler@gmail.com , http://www.kipple.pe.kr
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@ -109,6 +109,10 @@
|
|||
- unalz 0.60
|
||||
2007/02/10 - 리눅스등에서 strlcpy, strlcat 컴파일 에러 수정
|
||||
- unalz 0.61
|
||||
2007/04/12 - unalz command 라인 실행중 암호 입력시 \n이 포함되는 버그 수정
|
||||
2008/04/04 - debian 빌드 관련 수정 (by cwryu@debian )
|
||||
- 소스 정리, NULL iterator 관련 수정
|
||||
- unalz 0.62
|
||||
|
||||
기능 :
|
||||
- alz 파일의 압축 해제 (deflate/변형 bzip2/raw)
|
||||
|
@ -130,6 +134,8 @@
|
|||
#ifndef _UNALZ_H_
|
||||
#define _UNALZ_H_
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
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<SLocalFileHeader> FileList; ///< 파일 목록.
|
||||
typedef vector<SAlzLocalFileHeader> 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;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/// 약간의 수정을 가한 소스들이다..
|
||||
/// FILE* handle 관련 부분들이 수정되었다.
|
||||
///
|
||||
/// @author hardkoder@gmail.com
|
||||
/// @author kippler@gmail.com
|
||||
/// @date 2004-10-03 오후 3:09:11
|
||||
///
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
///
|
||||
/// unalz 관련 유틸 모음
|
||||
///
|
||||
/// @author hardkoder
|
||||
/// @author kippler@gmail.com
|
||||
/// @date 2005-06-23 오후 9:55:34
|
||||
///
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// modified for .alz handling
|
||||
///
|
||||
/// @author kippler@gmail.com
|
||||
/// @date 2007-04-12 ¿ÀÈÄ 9:06:32
|
||||
///
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// ALZ 압축 해제를 위해서 수정된 bzip2 소스
|
||||
// [ALZ] 라고 표시된 부분이 수정된 부분이다.
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
9
main.cpp
9
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue