Solved

Z_DATA_ERROR ,Windows Programming

Posted on 2010-11-22
2
850 Views
Last Modified: 2012-05-10
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,sizeof(drCluChunk));
       ReadFile(hBackupFile, &drCluChunk, sizeof(drCluChunk),&dwByteRead,NULL);
       dwtotelbyteRead = dwtotelbyteRead + dwByteRead;
       if(drCluChunk.dwTotalCluster != 0)
      {
      DWORD mFTclusteinfile = OnResetClusterLocation(m_BackupParameter._dwRootStartCluster);
      DWORD dwCurrentFilePosition;  
      dwCurrentFilePosition = SetFilePointer(hBackupFile,0,NULL,FILE_CURRENT);
      if(drCluChunk.dwClusterStartFrom == 0)
      {
            //Partition boot record
            DWORD dw =0;
            LARGE_INTEGER      lrMovePos ={0},
            lrCurrentPos ={0};
            lrMovePos.QuadPart = 7;
            SetFilePointerEx(hBackupFile,lrMovePos ,&lrCurrentPos, FILE_CURRENT);
            memset(&ntfsHeader,0x00,sizeof(ntfsHeader));
            BYTE *Buffer = new BYTE[SECTSIZE];
            ReadFile(hBackupFile,Buffer,SECTSIZE,&dw,NULL);      
            memcpy(&ntfsHeader,Buffer,sizeof(ntfsHeader));
            LARGE_INTEGER      lrMovePos1 ={0},
            lrCurrentPos1 ={0};
            lrMovePos1.QuadPart = dwCurrentFilePosition;
            SetFilePointerEx(hBackupFile,lrMovePos1,&lrCurrentPos1,FILE_BEGIN);

      }
             if(mFTclusteinfile !=0)
      {
            DWORD dwReturnValue = 0;
            DWORD comprssbuffsize = 0;
            LARGE_INTEGER      lrMovePos ={0},
            lrCurrentPos ={0};
            lrMovePos.QuadPart = mFTclusteinfile;
            SetFilePointerEx(hBackupFile,lrMovePos ,&lrCurrentPos, FILE_CURRENT);
            bBuffcompress      = new BYTE[drCluChunk.dwCompressSize];
         ReadFile(hBackupFile,bBuffcompress,drCluChunk.dwCompressSize,&dwReturnValue,NULL);
int nFlag = uncompress(bBuffUncompress,&dwUncompressSize,bBuffcompress,drCluChunk.dwCompressSize);
}


nFlag gives (-3) the Z_DATA_ERROR.


PLease help me out  I am stuck here.
0
Comment
Question by:davinder101
  • 2
2 Comments
 
LVL 9

Accepted Solution

by:
masheik earned 500 total points
ID: 34187739
Hi,

  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().
0
 
LVL 9

Expert Comment

by:masheik
ID: 34187740
Hi,

  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().
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now