internal WcxArchiveItem(WcxArchiveContext context, HeaderDataEx header, int index)
 {
     this.Context = context;
     this.Index = index;
     this.FName = header.FileName;
     this.Size = header.UnpSize | (header.UnpSizeHigh << 0x20);
     this.CompressedSize = header.PackSize | (header.UnpSizeHigh << 0x20);
     this.Attributes = header.FileAttr;
     this.CRC = header.FileCRC;
     this.Method = header.Method;
     this.InitializeArchiveItem(header.FileTime);
 }
 public int ReadHeader(IntPtr hArcData, ref HeaderDataEx headerEx)
 {
     int num2;
     try
     {
         if (this.FormatInfo.ReadHeaderEx != null)
         {
             return this.FormatInfo.ReadHeaderEx(hArcData, ref headerEx);
         }
         HeaderData headerData = new HeaderData();
         int num = this.FormatInfo.ReadHeader(hArcData, ref headerData);
         headerEx.ArcName = headerData.ArcName;
         headerEx.FileName = headerData.FileName;
         headerEx.Flags = headerData.Flags;
         headerEx.PackSize = headerData.PackSize;
         headerEx.UnpSize = headerData.UnpSize;
         headerEx.HostOS = headerData.HostOS;
         headerEx.FileCRC = headerData.FileCRC;
         headerEx.FileTime = headerData.FileTime;
         headerEx.UnpVer = headerData.UnpVer;
         headerEx.Method = headerData.Method;
         headerEx.FileAttr = headerData.FileAttr;
         headerEx.CmtBuf = headerData.CmtBuf;
         headerEx.CmtBufSize = headerData.CmtBufSize;
         headerEx.CmtSize = headerData.CmtSize;
         headerEx.CmtState = headerData.CmtState;
         num2 = num;
     }
     catch (Exception exception)
     {
         WcxException exception2 = new WcxException(-1, exception.Message, exception);
         exception2.Data.Add("Archive Format", this.FormatInfo.Name);
         throw exception2;
     }
     return num2;
 }
 private void ProcessExtract(object target)
 {
     try
     {
         OpenArchiveData archiveData = new OpenArchiveData {
             ArcName = base.Context.ArchiveName,
             OpenMode = PK_OM.PK_OM_EXTRACT
         };
         this.ArchiveHandle = base.Context.FormatInfo.OpenArchive(ref archiveData);
         this.ProcessResult = (this.ArchiveHandle == IntPtr.Zero) ? 15 : archiveData.OpenResult;
         if (this.ProcessResult == 0)
         {
             try
             {
                 if (base.Context.FormatInfo.SetProcessData != null)
                 {
                     ProcessDataProcCallback pProcessDataProc = new ProcessDataProcCallback(this.ProcessData);
                     base.Context.FormatInfo.SetProcessData(this.ArchiveHandle, pProcessDataProc);
                 }
                 int num = 0;
                 HeaderDataEx headerEx = new HeaderDataEx();
                 while (((num < base.Items.Count) && (this.ProcessResult == 0)) && ((this.ProcessResult = base.Context.ReadHeader(this.ArchiveHandle, ref headerEx)) == 0))
                 {
                     if (this.UsePipes)
                     {
                         if (base.Items.ContainsKey(this.CurrentItemIndex))
                         {
                             num++;
                             this.BeforeExtractItem.Set();
                             if (WaitHandle.WaitAny(new WaitHandle[] { this.TerminateEvent, this.ConfirmExtractItem }) == 0)
                             {
                                 break;
                             }
                         }
                         if (this.ExtractNeeded)
                         {
                             this.ProcessResult = base.Context.ProcessFile(this.ArchiveHandle, PK_OPERATION.PK_EXTRACT, null, @"\\.\pipe\" + this.PipeName);
                         }
                         else
                         {
                             this.ProcessResult = base.Context.ProcessFile(this.ArchiveHandle, PK_OPERATION.PK_SKIP, null, null);
                         }
                     }
                     else
                     {
                         this.ExtractNeeded = false;
                         if (base.Items.ContainsKey(this.CurrentItemIndex))
                         {
                             num++;
                             ProcessWcxItemEventArgs e = new ProcessWcxItemEventArgs(this);
                             ((ProcessItemHandler) target)(e);
                             if (e.Cancel)
                             {
                                 break;
                             }
                         }
                         if (!this.ExtractNeeded)
                         {
                             this.ProcessResult = base.Context.ProcessFile(this.ArchiveHandle, PK_OPERATION.PK_SKIP, null, null);
                         }
                     }
                     this.CurrentItemIndex++;
                 }
                 if (this.ProcessResult == 10)
                 {
                     this.ProcessResult = 0;
                 }
             }
             finally
             {
                 base.Context.FormatInfo.CloseArchive(this.ArchiveHandle);
             }
         }
     }
     finally
     {
         this.FinishedEvent.Set();
     }
 }