Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Z_DATA_ERROR ,Windows Programming

Posted on 2010-11-22
2
Medium Priority
?
864 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 9

Accepted Solution

by:
masheik earned 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

721 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