davinder101
asked on
Z_DATA_ERROR ,Windows Programming
Hi Experts
I am using Zlib for compressing of my data. It is giving the Z_DATA_ERROR every time.I am not able to figure out the reason for this. Please let me know where I am doing wrong the source code is given below:
bBuffcompress= new BYTE[12*1024*1024];
bBuffUncompress = new BYTE[12*1024*1024];
DWORD dwUncompressSize =12*1024*1024;
do
{
DWORD dwByteRead = 0;
memset(&drCluChunk,0x00,si zeof(drClu Chunk));
ReadFile(hBackupFile, &drCluChunk, sizeof(drCluChunk),&dwByte Read,NULL) ;
dwtotelbyteRead = dwtotelbyteRead + dwByteRead;
if(drCluChunk.dwTotalClust er != 0)
{
DWORD mFTclusteinfile = OnResetClusterLocation(m_B ackupParam eter._dwRo otStartClu ster);
DWORD dwCurrentFilePosition;
dwCurrentFilePosition = SetFilePointer(hBackupFile ,0,NULL,FI LE_CURRENT );
if(drCluChunk.dwClusterSta rtFrom == 0)
{
//Partition boot record
DWORD dw =0;
LARGE_INTEGER lrMovePos ={0},
lrCurrentPos ={0};
lrMovePos.QuadPart = 7;
SetFilePointerEx(hBackupFi le,lrMoveP os ,&lrCurrentPos, FILE_CURRENT);
memset(&ntfsHeader,0x00,si zeof(ntfsH eader));
BYTE *Buffer = new BYTE[SECTSIZE];
ReadFile(hBackupFile,Buffe r,SECTSIZE ,&dw,NULL) ;
memcpy(&ntfsHeader,Buffer, sizeof(ntf sHeader));
LARGE_INTEGER lrMovePos1 ={0},
lrCurrentPos1 ={0};
lrMovePos1.QuadPart = dwCurrentFilePosition;
SetFilePointerEx(hBackupFi le,lrMoveP os1,&lrCur rentPos1,F ILE_BEGIN) ;
}
if(mFTclusteinfile !=0)
{
DWORD dwReturnValue = 0;
DWORD comprssbuffsize = 0;
LARGE_INTEGER lrMovePos ={0},
lrCurrentPos ={0};
lrMovePos.QuadPart = mFTclusteinfile;
SetFilePointerEx(hBackupFi le,lrMoveP os ,&lrCurrentPos, FILE_CURRENT);
bBuffcompress = new BYTE[drCluChunk.dwCompress Size];
ReadFile(hBackupFile,bBuff compress,d rCluChunk. dwCompress Size,&dwRe turnValue, NULL);
int nFlag = uncompress(bBuffUncompress ,&dwUncomp ressSize,b Buffcompre ss,drCluCh unk.dwComp ressSize);
}
nFlag gives (-3) the Z_DATA_ERROR.
PLease help me out I am stuck here.
I am using Zlib for compressing of my data. It is giving the Z_DATA_ERROR every time.I am not able to figure out the reason for this. Please let me know where I am doing wrong the source code is given below:
bBuffcompress= new BYTE[12*1024*1024];
bBuffUncompress = new BYTE[12*1024*1024];
DWORD dwUncompressSize =12*1024*1024;
do
{
DWORD dwByteRead = 0;
memset(&drCluChunk,0x00,si
ReadFile(hBackupFile, &drCluChunk, sizeof(drCluChunk),&dwByte
dwtotelbyteRead = dwtotelbyteRead + dwByteRead;
if(drCluChunk.dwTotalClust
{
DWORD mFTclusteinfile = OnResetClusterLocation(m_B
DWORD dwCurrentFilePosition;
dwCurrentFilePosition = SetFilePointer(hBackupFile
if(drCluChunk.dwClusterSta
{
//Partition boot record
DWORD dw =0;
LARGE_INTEGER lrMovePos ={0},
lrCurrentPos ={0};
lrMovePos.QuadPart = 7;
SetFilePointerEx(hBackupFi
memset(&ntfsHeader,0x00,si
BYTE *Buffer = new BYTE[SECTSIZE];
ReadFile(hBackupFile,Buffe
memcpy(&ntfsHeader,Buffer,
LARGE_INTEGER lrMovePos1 ={0},
lrCurrentPos1 ={0};
lrMovePos1.QuadPart = dwCurrentFilePosition;
SetFilePointerEx(hBackupFi
}
if(mFTclusteinfile !=0)
{
DWORD dwReturnValue = 0;
DWORD comprssbuffsize = 0;
LARGE_INTEGER lrMovePos ={0},
lrCurrentPos ={0};
lrMovePos.QuadPart = mFTclusteinfile;
SetFilePointerEx(hBackupFi
bBuffcompress = new BYTE[drCluChunk.dwCompress
ReadFile(hBackupFile,bBuff
int nFlag = uncompress(bBuffUncompress
}
nFlag gives (-3) the Z_DATA_ERROR.
PLease help me out I am stuck here.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
That error occurs if the data input is corrupted...
Reference can be found here.
http://www.zlib.net/zlib_how.html
Z_DATA_ERROR indicates that inflate() detected an error in the zlib compressed data format,
which means that either the data is not a zlib stream to begin with, or that the data was corrupted
somewhere along the way since it was compressed. The other error to be processed is
Z_MEM_ERROR, which can occur since memory allocation is deferred until inflate() needs it, unlike
deflate(),whose memory is allocated at the start by deflateInit().