50# define VERSIONMADEBY (0x0)
54#define Z_BUFSIZE (64*1024)
57#ifndef Z_MAXFILENAMEINZIP
58#define Z_MAXFILENAMEINZIP (256)
62# define ALLOC(size) (malloc(size))
65# define TRYFREE(p) {if (p) free(p);}
77#define MAKEULONG64(a, b) ((ZPOS64_T)(((unsigned long)(a)) | ((ZPOS64_T)((unsigned long)(b))) << 32))
93# define DEF_MEM_LEVEL 8
95# define DEF_MEM_LEVEL MAX_MEM_LEVEL
98const char zip_copyright[] =
" zip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll";
101#define SIZEDATA_INDATABLOCK (4096-(4*4))
103#define LOCALHEADERMAGIC (0x04034b50)
104#define CENTRALHEADERMAGIC (0x02014b50)
105#define ENDHEADERMAGIC (0x06054b50)
106#define ZIP64ENDHEADERMAGIC (0x6064b50)
107#define ZIP64ENDLOCHEADERMAGIC (0x7064b50)
109#define FLAG_LOCALHEADER_OFFSET (0x06)
110#define CRC_LOCALHEADER_OFFSET (0x0e)
112#define SIZECENTRALHEADER (0x2e)
159 unsigned long keys[3];
177#ifndef NO_ADDFILEINEXISTINGZIP
185#define INCLUDECRYPTINGCODE_IFCRYPTALLOWED
215 ll->first_block =
ll->last_block =
NULL;
221 ll->first_block =
ll->last_block =
NULL;
228 const unsigned char* from_copy;
233 if (
ll->last_block ==
NULL)
236 if (
ll->first_block ==
NULL)
240 ldi =
ll->last_block;
241 from_copy = (
unsigned char*)
buf;
247 unsigned char* to_copy;
255 ll->last_block = ldi;
265 for (
i=0;
i<copy_this;
i++)
266 *(to_copy+
i)=*(from_copy+
i);
270 from_copy += copy_this ;
280#ifndef NO_ADDFILEINEXISTINGZIP
289 unsigned char buf[8];
291 for (
n = 0;
n < nbByte;
n++)
298 for (
n = 0;
n < nbByte;
n++)
313 unsigned char*
buf=(
unsigned char*)
dest;
315 for (
n = 0;
n < nbByte;
n++) {
322 for (
n = 0;
n < nbByte;
n++)
360 if (
ZERROR64(*pzlib_filefunc_def,filestream))
471#ifndef BUFREADCOMMENT
472#define BUFREADCOMMENT (0x400)
492 uSizeFile =
ZTELL64(*pzlib_filefunc_def,filestream);
494 if (uMaxBack>uSizeFile)
495 uMaxBack = uSizeFile;
502 while (uBackRead<uMaxBack)
508 uBackRead = uMaxBack;
511 uReadPos = uSizeFile-uBackRead ;
518 if (
ZREAD64(*pzlib_filefunc_def,filestream,
buf,uReadSize)!=uReadSize)
521 for (
i=(
int)uReadSize-3; (
i--)>0;)
523 if (((*(
buf+
i))==0x50) && ((*(
buf+
i+1))==0x4b) &&
524 ((*(
buf+
i+2))==0x05) && ((*(
buf+
i+3))==0x06))
557 uSizeFile =
ZTELL64(*pzlib_filefunc_def,filestream);
559 if (uMaxBack>uSizeFile)
560 uMaxBack = uSizeFile;
567 while (uBackRead<uMaxBack)
573 uBackRead = uMaxBack;
576 uReadPos = uSizeFile-uBackRead ;
583 if (
ZREAD64(*pzlib_filefunc_def,filestream,
buf,uReadSize)!=uReadSize)
586 for (
i=(
int)uReadSize-3; (
i--)>0;)
589 if (((*(
buf+
i))==0x50) && ((*(
buf+
i+1))==0x4b) && ((*(
buf+
i+2))==0x06) && ((*(
buf+
i+3))==0x07))
636 if (uL != 0x06064b50)
639 return relativeOffset;
654 uLong number_disk_with_CD;
664 int hasZIP64Record = 0;
672 else if(central_pos == 0)
720 if ((number_entry_CD!=number_entry) || (number_disk_with_CD!=0) || (number_disk!=0))
766 number_entry_CD = uL;
768 if ((number_entry_CD!=number_entry) || (number_disk_with_CD!=0) || (number_disk!=0))
772 size_central_dir = 0;
776 size_central_dir = uL;
779 offset_central_dir = 0;
783 offset_central_dir = uL;
791 if ((central_pos<offset_central_dir+size_central_dir) &&
811 byte_before_the_zipfile = central_pos - (offset_central_dir+size_central_dir);
815 ZPOS64_T size_central_dir_to_read = size_central_dir;
821 while ((size_central_dir_to_read>0) && (
err==
ZIP_OK))
824 if (read_this > size_central_dir_to_read)
825 read_this = size_central_dir_to_read;
833 size_central_dir_to_read-=read_this;
837 pziinit->
begin_pos = byte_before_the_zipfile;
860 if (pzlib_filefunc64_32_def==
NULL)
895# ifndef NO_ADDFILEINEXISTINGZIP
911# ifndef NO_ADDFILEINEXISTINGZIP
927 if (pzlib_filefunc32_def !=
NULL)
940 if (pzlib_filefunc_def !=
NULL)
943 zlib_filefunc64_32_def_fill.
zfile_func64 = *pzlib_filefunc_def;
969 uInt size_extrafield = size_extrafield_local;
1013 size_extrafield += 20;
1019 if ((
err==
ZIP_OK) && (size_filename > 0))
1025 if ((
err==
ZIP_OK) && (size_extrafield_local > 0))
1062 const void* extrafield_local,
uInt size_extrafield_local,
1063 const void* extrafield_global,
uInt size_extrafield_global,
1067 uLong versionMadeBy,
uLong flagBase,
int zip64)
1175 for (
i=0;
i<size_filename;
i++)
1178 for (
i=0;
i<size_extrafield_global;
i++)
1180 *(((
const char*)extrafield_global)+
i);
1182 for (
i=0;
i<size_comment;
i++)
1184 size_extrafield_global+
i) = *(
comment+
i);
1196 zi->
ci.bstream.avail_in = (
uInt)0;
1199 zi->
ci.bstream.total_in_hi32 = 0;
1200 zi->
ci.bstream.total_in_lo32 = 0;
1201 zi->
ci.bstream.total_out_hi32 = 0;
1202 zi->
ci.bstream.total_out_lo32 = 0;
1236 zi->
ci.bstream.bzalloc = 0;
1237 zi->
ci.bstream.bzfree = 0;
1240 err = BZ2_bzCompressInit(&zi->
ci.bstream,
level, 0,35);
1252 unsigned char bufHead[RAND_HEAD_LEN];
1253 unsigned int sizeHead;
1272 const void* extrafield_local,
uInt size_extrafield_local,
1273 const void* extrafield_global,
uInt size_extrafield_global,
1280 extrafield_local, size_extrafield_local,
1281 extrafield_global, size_extrafield_global,
1284 password, crcForCrypting, versionMadeBy, flagBase, 0);
1288 const void* extrafield_local,
uInt size_extrafield_local,
1289 const void* extrafield_global,
uInt size_extrafield_global,
1295 extrafield_local, size_extrafield_local,
1296 extrafield_global, size_extrafield_global,
1303 const void* extrafield_local,
uInt size_extrafield_local,
1304 const void* extrafield_global,
uInt size_extrafield_global,
1310 extrafield_local, size_extrafield_local,
1311 extrafield_global, size_extrafield_global,
1318 const void* extrafield_local,
uInt size_extrafield_local,
1319 const void* extrafield_global,
uInt size_extrafield_global,
1323 extrafield_local, size_extrafield_local,
1324 extrafield_global, size_extrafield_global,
1331 const void* extrafield_local,
uInt size_extrafield_local,
1332 const void* extrafield_global,
uInt size_extrafield_global,
1336 extrafield_local, size_extrafield_local,
1337 extrafield_global, size_extrafield_global,
1344 const void* extrafield_local,
uInt size_extrafield_local,
1345 const void*extrafield_global,
uInt size_extrafield_global,
1349 extrafield_local, size_extrafield_local,
1350 extrafield_global, size_extrafield_global,
1357 const void* extrafield_local,
uInt size_extrafield_local,
1358 const void*extrafield_global,
uInt size_extrafield_global,
1362 extrafield_local, size_extrafield_local,
1363 extrafield_global, size_extrafield_global,
1392 zi->
ci.bstream.total_in_lo32 = 0;
1393 zi->
ci.bstream.total_in_hi32 = 0;
1425 zi->
ci.bstream.next_in = (
void*)
buf;
1426 zi->
ci.bstream.avail_in =
len;
1429 while ((
err==BZ_RUN_OK) && (zi->
ci.bstream.avail_in>0))
1431 if (zi->
ci.bstream.avail_out == 0)
1440 if(
err != BZ_RUN_OK)
1445 uLong uTotalOutBefore_lo = zi->
ci.bstream.total_out_lo32;
1447 err=BZ2_bzCompress(&zi->
ci.bstream, BZ_RUN);
1453 if(
err == BZ_RUN_OK)
1491 for (
i = 0;
i < copy_this;
i++)
1519 uLong invalidValue = 0xffffffff;
1535 uLong uTotalOutBefore;
1552 while (
err==BZ_FINISH_OK)
1554 uLong uTotalOutBefore;
1555 if (zi->
ci.bstream.avail_out == 0)
1562 uTotalOutBefore = zi->
ci.bstream.total_out_lo32;
1563 err=BZ2_bzCompress(&zi->
ci.bstream, BZ_FINISH);
1564 if(
err == BZ_STREAM_END)
1570 if(
err == BZ_FINISH_OK)
1594 int tmperr = BZ2_bzCompressEnd(&zi->
ci.bstream);
1613 if(compressed_size >= 0xffffffff || uncompressed_size >= 0xffffffff || zi->
ci.
pos_local_header >= 0xffffffff)
1625 if(compressed_size >= 0xffffffff)
1634 if(uncompressed_size >= 0xffffffff)
1640 if(uncompressed_size >= 0xffffffff)
1644 if(compressed_size >= 0xffffffff)
1669 if(uncompressed_size >= 0xffffffff)
1675 if(compressed_size >= 0xffffffff)
1715 if(uncompressed_size >= 0xffffffff || compressed_size >= 0xffffffff )
1782 uLong Zip64DataSize = 44;
1854 if(
pos >= 0xffffffff)
1868 uInt size_global_comment = 0;
1870 if(global_comment !=
NULL)
1871 size_global_comment = (
uInt)
strlen(global_comment);
1875 if (
err ==
ZIP_OK && size_global_comment > 0)
1887 uLong size_centraldir = 0;
1901#ifndef NO_ADDFILEINEXISTINGZIP
1902 if (global_comment==
NULL)
1944#ifndef NO_ADDFILEINEXISTINGZIP
1966 pNewHeader = (
char*)
ALLOC((
unsigned)*dataLen);
1969 while(
p < (
pData + *dataLen))
const z_crc_t FAR *ZEXPORT get_crc_table()
ACPI_SIZE strlen(const char *String)
ssize_t buf_read(int, void *, size_t)
#define crc32(crc, buf, len)
void(* free_func)(voidpf opaque, voidpf address)
voidpf(* alloc_func)(voidpf opaque, uInt items, uInt size)
#define Z_DEFAULT_STRATEGY
int deflate(z_streamp strm, int flush) DECLSPEC_HIDDEN
int deflateEnd(z_streamp strm) DECLSPEC_HIDDEN
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
GLint GLint GLint GLint GLint x
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLenum GLuint GLenum GLsizei const GLchar * buf
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def *p_filefunc64_32, const zlib_filefunc_def *p_filefunc32)
void fill_fopen64_filefunc(zlib_filefunc64_def *pzlib_filefunc_def)
#define ZERROR64(filefunc, filestream)
#define ZLIB_FILEFUNC_MODE_EXISTING
#define ZOPEN64(filefunc, filename, mode)
#define ZSEEK64(filefunc, filestream, pos, mode)
#define ZLIB_FILEFUNC_SEEK_SET
#define ZREAD64(filefunc, filestream, buf, size)
#define ZCLOSE64(filefunc, filestream)
#define ZTELL64(filefunc, filestream)
#define ZLIB_FILEFUNC_MODE_CREATE
#define ZLIB_FILEFUNC_MODE_WRITE
#define ZLIB_FILEFUNC_SEEK_END
#define ZWRITE64(filefunc, filestream, buf, size)
#define ZLIB_FILEFUNC_MODE_READ
unsigned long long int ZPOS64_T
static void append(struct dump_context *dc, const void *data, unsigned size)
#define memcpy(s1, s2, n)
#define comment(fmt, arg1)
static unsigned(__cdecl *hash_bstr)(bstr_t s)
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
#define deflateInit2(strm, level, method, windowBits, memLevel, strategy)
#define zencode(pkeys, pcrc_32_tab, c, t)
Byte buffered_data[Z_BUFSIZE]
uInt pos_in_buffered_data
ZPOS64_T pos_zip64extrainfo
unsigned crypt_header_size
ZPOS64_T pos_local_header
uLong size_centralExtraFree
ZPOS64_T totalCompressedData
const z_crc_t * pcrc_32_tab
ZPOS64_T totalUncompressedData
linkedlist_datablock_internal * last_block
linkedlist_datablock_internal * first_block
unsigned char data[SIZEDATA_INDATABLOCK]
uLong avail_in_this_block
struct linkedlist_datablock_internal_s * next_datablock
uLong filled_in_this_block
ZPOS64_T add_position_when_writing_offset
linkedlist_data central_dir
zlib_filefunc64_32_def z_filefunc
seek_file_func zseek32_file
zlib_filefunc64_def zfile_func64
tell_file_func ztell32_file
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
int add_data_in_datablock(linkedlist_data *ll, const void *buf, uLong len)
int zip64local_putValue(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte)
zipFile ZEXPORT zipOpen2(const char *pathname, int append, zipcharpc *globalcomment, zlib_filefunc_def *pzlib_filefunc32_def)
struct linkedlist_data_s linkedlist_data
int ZEXPORT zipOpenNewFileInZip(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level)
int ZEXPORT zipOpenNewFileInZip64(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int zip64)
int ZEXPORT zipOpenNewFileInZip4(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw, int windowBits, int memLevel, int strategy, const char *password, uLong crcForCrypting, uLong versionMadeBy, uLong flagBase)
#define SIZECENTRALHEADER
int Write_EndOfCentralDirectoryRecord(zip64_internal *zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)
#define ZIP64ENDHEADERMAGIC
const char zip_copyright[]
int zip64local_getByte(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, int *pi)
int ZEXPORT zipRemoveExtraInfoBlock(char *pData, int *dataLen, short sHeader)
int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_size, uLong crc32)
uLong zip64local_TmzDateToDosDate(const tm_zip *ptm)
int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal *zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)
int ZEXPORT zipCloseFileInZipRaw(zipFile file, uLong uncompressed_size, uLong crc32)
int LoadCentralDirectoryRecord(zip64_internal *pziinit)
void zip64local_putValue_inmemory(void *dest, ZPOS64_T x, int nbByte)
int ZEXPORT zipClose(zipFile file, const char *global_comment)
ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream)
void free_datablock(linkedlist_datablock_internal *ldi)
int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw, int windowBits, int memLevel, int strategy, const char *password, uLong crcForCrypting, uLong versionMadeBy, uLong flagBase, int zip64)
#define CENTRALHEADERMAGIC
int ZEXPORT zipOpenNewFileInZip3(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw, int windowBits, int memLevel, int strategy, const char *password, uLong crcForCrypting)
int Write_LocalFileHeader(zip64_internal *zi, const char *filename, uInt size_extrafield_local, const void *extrafield_local)
int zip64FlushWriteBuffer(zip64_internal *zi)
zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc *globalcomment, zlib_filefunc64_32_def *pzlib_filefunc64_32_def)
#define SIZEDATA_INDATABLOCK
struct linkedlist_datablock_internal_s linkedlist_datablock_internal
zipFile ZEXPORT zipOpen2_64(const void *pathname, int append, zipcharpc *globalcomment, zlib_filefunc64_def *pzlib_filefunc_def)
ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream)
int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal *zi, ZPOS64_T zip64eocd_pos_inzip)
linkedlist_datablock_internal * allocate_new_datablock()
int zip64local_getShort(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, uLong *pX)
void init_linkedlist(linkedlist_data *ll)
int zip64local_getLong(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, uLong *pX)
void free_linkedlist(linkedlist_data *ll)
int ZEXPORT zipWriteInFileInZip(zipFile file, const void *buf, unsigned int len)
int ZEXPORT zipOpenNewFileInZip2_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw, int zip64)
int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw, int windowBits, int memLevel, int strategy, const char *password, uLong crcForCrypting, int zip64)
zipFile ZEXPORT zipOpen(const char *pathname, int append)
int ZEXPORT zipOpenNewFileInZip2(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw)
int ZEXPORT zipCloseFileInZip(zipFile file)
int zip64local_getLong64(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX)
#define ZIP64ENDLOCHEADERMAGIC
int Write_GlobalComment(zip64_internal *zi, const char *global_comment)
zipFile ZEXPORT zipOpen64(const void *pathname, int append)
#define APPEND_STATUS_ADDINZIP
#define ZIP_INTERNALERROR
#define APPEND_STATUS_CREATEAFTER
#define APPEND_STATUS_CREATE