Example #1
0
        protected int UZDLLPassword(ref UNZIPCBCh pwd, int bufsize,
                                    [MarshalAs(UnmanagedType.LPStr)] String msg,
                                    [MarshalAs(UnmanagedType.LPStr)] String entryname)
        {
            if (m_Password == null | m_Password == string.Empty)
            {
                return(-1);
            }

            if (m_Password.Length >= bufsize)
            {
                MessageBox.Show("Length of supplied password exceeds available pw buffer size "
                                + bufsize.ToString() + "!", "Password Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(5); // IZ_PW_ERROR
            }

            //clear the byte array
            for (int i = 0; i < bufsize; i++)
            {
                pwd.ch[i] = 0;
            }

            m_EncodingANSI.GetBytes(m_Password, 0, m_Password.Length, pwd.ch, 0);

            return(0);
        }
Example #2
0
        //-- Callback For UNZIP32.DLL - Password Function
        public static short UZDLLPass(ref UNZIPCBCh p, int n, ref UNZIPCBCh m, ref UNZIPCBCh Name)
        {
            short functionReturnValue = 0;

            string prompt     = null;
            short  xx         = 0;
            string szpassword = null;

            //-- Always Put This In Callback Routines!
            // ERROR: Not supported in C#: OnErrorStatement


            functionReturnValue = 1;

            if (uVBSkip == 1)
            {
                return(functionReturnValue);
            }

            //-- Get The Zip File Password
            szpassword = Interaction.InputBox("Please Enter The Password!");

            //-- No Password So Exit The Function
            if (string.IsNullOrEmpty(szpassword))
            {
                uVBSkip = 1;
                return(functionReturnValue);
            }

            //-- Zip File Password So Process It
            for (xx = 0; xx <= 255; xx++)
            {
                if (m.ch[xx] == 0)
                {
                    break;                     // TODO: might not be correct. Was : Exit For
                }
                else
                {
                    prompt = prompt + Strings.Chr(m.ch[xx]);
                }
            }

            for (xx = 0; xx <= n - 1; xx++)
            {
                p.ch[xx] = 0;
            }

            for (xx = 0; xx <= Strings.Len(szpassword) - 1; xx++)
            {
                p.ch[xx] = Strings.Asc(Strings.Mid(szpassword, xx + 1, 1));
            }

            p.ch[xx] = Convert.ToByte(Strings.AscW(0));
            // Put Null Terminator For C

            functionReturnValue = 0;
            return(functionReturnValue);
        }
Example #3
0
        protected int UZDLLReplace(ref UNZIPCBCh fname, uint fnbufsiz)
        {
            ReplaceFileOptionsEnum ReplaceFileOption = ReplaceFileOptionsEnum.ReplaceNo; //Default
            string s = string.Empty;
            int    i = 0;

            if (fnbufsiz > fname.ch.Length)
            {
                fnbufsiz = (uint)fname.ch.Length;
            }
            for (i = 0; i < fnbufsiz; i++)
            {
                if (fname.ch[i] == 0)
                {
                    break;
                }
            }
            s = m_EncodingANSI.GetString(fname.ch, 0, i);

            DialogResult rslt = MessageBox.Show("Overwrite [" + s + "]?  Click Cancel to skip all.",
                                                "Overwrite Confirmation", MessageBoxButtons.YesNoCancel,
                                                MessageBoxIcon.Question);

            switch (rslt)
            {
            case DialogResult.No:
                ReplaceFileOption = ReplaceFileOptionsEnum.ReplaceNo;
                break;

            case DialogResult.Yes:
                ReplaceFileOption = ReplaceFileOptionsEnum.ReplaceYes;
                break;

            case DialogResult.Cancel:
                ReplaceFileOption = ReplaceFileOptionsEnum.ReplaceNone;
                break;
            }
            return(ConvertEnumToInt(ReplaceFileOption));
        }
Example #4
0
        //-- Callback For UNZIP32.DLL - Receive Message Function
        public static void UZReceiveDLLMessage(int ucsize, int csiz, short cfactor, short mo, short dy, short yr, short hh, short mm, byte c, ref UNZIPCBCh fname,

                                               ref UNZIPCBCh meth, int crc, byte fCrypt)
        {
            string s0     = null;
            int    xx     = 0;
            string strout = null;

            //-- Always Put This In Callback Routines!
            // ERROR: Not supported in C#: OnErrorStatement


            //------------------------------------------------
            //-- This Is Where The Received Messages Are
            //-- Printed Out And Displayed.
            //-- You Can Modify Below!
            //------------------------------------------------

            strout = Strings.Space(80);

            //-- For Zip Message Printing
            if (uZipNumber == 0)
            {
                Strings.Mid(strout, 1, 50) = "Filename:";
                Strings.Mid(strout, 53, 4) = "Size";
                Strings.Mid(strout, 62, 4) = "Date";
                Strings.Mid(strout, 71, 4) = "Time";
                uZipMessage = strout + Constants.vbNewLine;
                strout      = Strings.Space(80);
            }

            s0 = "";

            //-- Do Not Change This For Next!!!
            for (xx = 0; xx <= 255; xx++)
            {
                if (fname.ch[xx] == 0)
                {
                    break;                     // TODO: might not be correct. Was : Exit For
                }
                s0 = s0 + Strings.Chr(fname.ch[xx]);
            }

            //-- Assign Zip Information For Printing
            Strings.Mid(strout, 1, 50) = Strings.Mid(s0, 1, 50);
            Strings.Mid(strout, 51, 7) = Strings.Right("        " + Conversion.Str(ucsize), 7);
            Strings.Mid(strout, 60, 3) = Strings.Right("0" + Strings.Trim(Conversion.Str(mo)), 2) + "/";
            Strings.Mid(strout, 63, 3) = Strings.Right("0" + Strings.Trim(Conversion.Str(dy)), 2) + "/";
            Strings.Mid(strout, 66, 2) = Strings.Right("0" + Strings.Trim(Conversion.Str(yr)), 2);
            Strings.Mid(strout, 70, 3) = Strings.Right(Conversion.Str(hh), 2) + ":";
            Strings.Mid(strout, 73, 2) = Strings.Right("0" + Strings.Trim(Conversion.Str(mm)), 2);

            // Mid(strout, 75, 2) = Right(" " & Str(cfactor), 2)
            // Mid(strout, 78, 8) = Right("        " & Str(csiz), 8)
            // s0 = ""
            // For xx = 0 To 255
            //     If meth.ch(xx) = 0 Then exit for
            //     s0 = s0 & Chr(meth.ch(xx))
            // Next xx

            //-- Do Not Modify Below!!!
            uZipMessage = uZipMessage + strout + Constants.vbNewLine;
            uZipNumber  = uZipNumber + 1;
        }
Example #5
0
    protected int UZDLLReplace(ref UNZIPCBCh fname, uint fnbufsiz)
    {
      ReplaceFileOptionsEnum ReplaceFileOption = ReplaceFileOptionsEnum.ReplaceNo; //Default
      string s = string.Empty;
      int i = 0;

      if (fnbufsiz > fname.ch.Length) fnbufsiz = (uint)fname.ch.Length;
      for (i = 0; i < fnbufsiz; i++)
        if (fname.ch[i] == 0) break;
      s = m_EncodingANSI.GetString(fname.ch, 0, i);

      DialogResult rslt = MessageBox.Show("Overwrite [" + s + "]?  Click Cancel to skip all.",
                                  "Overwrite Confirmation", MessageBoxButtons.YesNoCancel,
                                  MessageBoxIcon.Question);
      switch (rslt)
      {
        case DialogResult.No:
          ReplaceFileOption = ReplaceFileOptionsEnum.ReplaceNo;
          break;
        case DialogResult.Yes:
          ReplaceFileOption = ReplaceFileOptionsEnum.ReplaceYes;
          break;
        case DialogResult.Cancel:
          ReplaceFileOption = ReplaceFileOptionsEnum.ReplaceNone;
          break;
      }
      return ConvertEnumToInt(ReplaceFileOption);
    }
Example #6
0
    protected int UZDLLPassword(ref UNZIPCBCh pwd, int bufsize,
                        [MarshalAs(UnmanagedType.LPStr)]String msg,
                        [MarshalAs(UnmanagedType.LPStr)]String entryname)
    {
      if (m_Password == null | m_Password == string.Empty) return -1;

      if (m_Password.Length >= bufsize)
      {
        MessageBox.Show("Length of supplied password exceeds available pw buffer size "
                    + bufsize.ToString() + "!", "Password Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
        return 5;  // IZ_PW_ERROR
      }

      //clear the byte array
      for (int i = 0; i < bufsize; i ++)
        pwd.ch[i] = 0;

      m_EncodingANSI.GetBytes(m_Password, 0, m_Password.Length, pwd.ch, 0);

      return 0;
    }
Example #7
0
        //-- Callback For UNZIP32.DLL - Receive Message Function
        public static void UZReceiveDLLMessage(int ucsize, int csiz, short cfactor, short mo, short dy, short yr, short hh, short mm, byte c, ref UNZIPCBCh fname,
            
            ref UNZIPCBCh meth, int crc, byte fCrypt)
        {
            string s0 = null;
            int xx = 0;
            string strout = null;

            //-- Always Put This In Callback Routines!
             // ERROR: Not supported in C#: OnErrorStatement

            //------------------------------------------------
            //-- This Is Where The Received Messages Are
            //-- Printed Out And Displayed.
            //-- You Can Modify Below!
            //------------------------------------------------

            strout = Strings.Space(80);

            //-- For Zip Message Printing
            if (uZipNumber == 0) {
                Strings.Mid(strout, 1, 50) = "Filename:";
                Strings.Mid(strout, 53, 4) = "Size";
                Strings.Mid(strout, 62, 4) = "Date";
                Strings.Mid(strout, 71, 4) = "Time";
                uZipMessage = strout + Constants.vbNewLine;
                strout = Strings.Space(80);
            }

            s0 = "";

            //-- Do Not Change This For Next!!!
            for (xx = 0; xx <= 255; xx++) {
                if (fname.ch[xx] == 0)
                    break; // TODO: might not be correct. Was : Exit For
                s0 = s0 + Strings.Chr(fname.ch[xx]);
            }

            //-- Assign Zip Information For Printing
            Strings.Mid(strout, 1, 50) = Strings.Mid(s0, 1, 50);
            Strings.Mid(strout, 51, 7) = Strings.Right("        " + Conversion.Str(ucsize), 7);
            Strings.Mid(strout, 60, 3) = Strings.Right("0" + Strings.Trim(Conversion.Str(mo)), 2) + "/";
            Strings.Mid(strout, 63, 3) = Strings.Right("0" + Strings.Trim(Conversion.Str(dy)), 2) + "/";
            Strings.Mid(strout, 66, 2) = Strings.Right("0" + Strings.Trim(Conversion.Str(yr)), 2);
            Strings.Mid(strout, 70, 3) = Strings.Right(Conversion.Str(hh), 2) + ":";
            Strings.Mid(strout, 73, 2) = Strings.Right("0" + Strings.Trim(Conversion.Str(mm)), 2);

            // Mid(strout, 75, 2) = Right(" " & Str(cfactor), 2)
            // Mid(strout, 78, 8) = Right("        " & Str(csiz), 8)
            // s0 = ""
            // For xx = 0 To 255
            //     If meth.ch(xx) = 0 Then exit for
            //     s0 = s0 & Chr(meth.ch(xx))
            // Next xx

            //-- Do Not Modify Below!!!
            uZipMessage = uZipMessage + strout + Constants.vbNewLine;
            uZipNumber = uZipNumber + 1;
        }
Example #8
0
        //-- Callback For UNZIP32.DLL - Password Function
        public static short UZDLLPass(ref UNZIPCBCh p, int n, ref UNZIPCBCh m, ref UNZIPCBCh Name)
        {
            short functionReturnValue = 0;

            string prompt = null;
            short xx = 0;
            string szpassword = null;

            //-- Always Put This In Callback Routines!
             // ERROR: Not supported in C#: OnErrorStatement

            functionReturnValue = 1;

            if (uVBSkip == 1)
                return functionReturnValue;

            //-- Get The Zip File Password
            szpassword = Interaction.InputBox("Please Enter The Password!");

            //-- No Password So Exit The Function
            if (string.IsNullOrEmpty(szpassword)) {
                uVBSkip = 1;
                return functionReturnValue;
            }

            //-- Zip File Password So Process It
            for (xx = 0; xx <= 255; xx++) {
                if (m.ch[xx] == 0) {
                    break; // TODO: might not be correct. Was : Exit For
                } else {
                    prompt = prompt + Strings.Chr(m.ch[xx]);
                }
            }

            for (xx = 0; xx <= n - 1; xx++) {
                p.ch[xx] = 0;
            }

            for (xx = 0; xx <= Strings.Len(szpassword) - 1; xx++) {
                p.ch[xx] = Strings.Asc(Strings.Mid(szpassword, xx + 1, 1));
            }

            p.ch[xx] = Convert.ToByte(Strings.AscW(0));
            // Put Null Terminator For C

            functionReturnValue = 0;
            return functionReturnValue;
        }