[Help]Patch Server

02/17/2015 22:40 Aurorauser#31
null
02/18/2015 00:55 ThunderNikk#32
Are you sure you just don't want someone to write the program for you?

Wait...oh never mind.
02/18/2015 00:58 wr4tes#33
kendi kendine ne sıkıntı yaptın gardaş ya triplere girme mk ;)
02/18/2015 01:00 Aurorauser#34
null
02/18/2015 03:46 XavierDeFawks#35
Code:
        private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            string[] files = Directory.GetFiles(dir_label.Text);

            Invoke(new MethodInvoker(delegate
            {
                progressBar1.Value = 0;
                progressBar1.Maximum = files.Length;
            }));

            CompressionMode mode;
            if (radio_inflate.Checked) { mode = CompressionMode.Decompress; }
            else { mode = CompressionMode.Compress; }

            foreach (string file in files)
            {
                string filename = "";
                if (radio_inflate.Checked) { StringCipher.Decode(Path.GetFileName(file), ref filename); }
                else if (radio_deflate.Checked) { StringCipher.Encode(Path.GetFileName(file), ref filename); }

                byte[] data;
                int data_size;

                try
                {
                    using (FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read))
                    {
                        using (BinaryReader br = new BinaryReader(fs))
                        {
                            if (radio_inflate.Checked)
                            {
                                br.ReadBytes(5);
                                br.ReadInt32();
                                int size = br.ReadInt32();
                                data = br.ReadBytes(size);
                            }
                            else
                            {
                                data = br.ReadBytes((int)fs.Length);

                                XOREn XOR = new XOREn();
                                byte xor_index = 0;

                                if (XOR.Encrypted(Path.GetExtension(file))) { XOR.Xor(ref data, ref xor_index); }

                            }
                        }
                    }
                }
                catch (Exception ex) { data = new byte[0]; }

                data_size = data.Length;

                try
                {
                    using (MemoryStream mem = new MemoryStream())
                    {
                        using (ZlibStream stream = new ZlibStream(mem, mode))
                        {
                            stream.Write(data, 0, data.Length);
                        }
                        data = mem.ToArray();
                    }
                }
                catch { MessageBox.Show(filename); }

                using(FileStream fs = File.Create(Path.GetDirectoryName(file) + "\\" + filename))
                {
                    using(BinaryWriter bw = new BinaryWriter(fs))
                    {
                        if (radio_inflate.Checked)
                        {
                            XOREn XOR = new XOREn();
                            byte xor_index = 0;

                            if (XOR.Encrypted(Path.GetExtension(filename))) { XOR.Xor(ref data, ref xor_index); }

                            bw.Write(data);
                        }
                        else
                        {
                            bw.Write(new byte[5] { 0x00, 0x51, 0x3F, 0x99, 0x1A });
                            bw.Write((int)data_size);
                            bw.Write((int)data.Length);
                            bw.Write(data);
                        }
                    }
                }

                File.Delete(file);
                Invoke(new MethodInvoker(delegate { progressBar1.Value++; }));
            }
        }
Piece of code from an app i wrote a while back to pack and unpack patch files.
02/18/2015 05:29 Aurorauser#36
null
02/18/2015 06:15 XavierDeFawks#37
XOREn and StringCipher is part of a custom library i made for client data files.
02/18/2015 17:33 Aurorauser#38
null
02/18/2015 18:16 XavierDeFawks#39
This is the zlib library I used. [Only registered and activated users can see links. Click Here To Register...]

P.S.
The code he posted is not the correct string cipher. Mine is a custom written class for resource file names. Look up a project i released a while back called DataBurner the class is called something different but its still the same methods.

And it will also have the XOR method although it may or may not be in its own class in that version.
02/18/2015 19:07 Aurorauser#40
null
02/18/2015 19:11 XavierDeFawks#41
I have read and replied. :p
02/19/2015 02:45 Aurorauser#42
null
01/28/2016 08:02 Makenci#43
null