吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 4698|回复: 10
收起左侧

[其他原创] LOL Skin自动更新小工具源码

  [复制链接]
18382747915 发表于 2020-12-9 16:54
本帖最后由 18382747915 于 2020-12-9 16:57 编辑

成品已发布到精品软件区 地址:https://www.52pojie.cn/thread-1325080-1-1.html
源码可以拿来参考一下:
[C#] 纯文本查看 复制代码
 public static class DRQ
    {
        private static HttpHelper http = new HttpHelper();
        /// <summary>
        /// 获取软件最新版本
        /// </summary>
        /// <param name="edition">版本号</param>
        /// <param name="downloadUrl">下载地址</param>
        public static void GetEdition(ref string edition, ref string downloadUrl)
        {
            try
            {
                HttpItem item = new HttpItem
                {
                    URL = "http://leagueskin.net/p/download-mod-skin-2020-chn",
                    Host = "leagueskin.net",
                };
                var req = http.GetHtml(item);
                if (req.StatusCode == HttpStatusCode.OK)
                {
                    string re = "http://s3.modskinlolvn.com/ModSkin_(.*?).zip";
                    Regex r = new Regex(re, RegexOptions.None);
                    MatchCollection matchCollection = r.Matches(req.Html);
                    if (matchCollection.Count > 0)
                    {
                        edition = matchCollection[matchCollection.Count - 1].Groups[1].Value;
                        downloadUrl = matchCollection[matchCollection.Count - 1].Groups[0].Value;
                    }
                }
            }
            catch (Exception ex)
            {
                WriteLog(ex.Message);
            }
        }
        public static bool DownliadFile(string url)
        {
            try
            {
                HttpItem item = new HttpItem
                {
                    URL = url,
                    Referer= "http://leagueskin.net/p/download-mod-skin-2020-chn",

                    ResultType = ResultType.Byte,
                    Host = "s3.modskinlolvn.com",
                };
                var result = http.GetHtml(item);
                if (result.StatusCode == HttpStatusCode.OK)
                {
                    byte[] by = result.ResultByte;
                    if (by.Length > 100)
                    {
                        using (FileStream fs = new FileStream("File/LOL.zip", FileMode.Create, FileAccess.Write))
                        {
                            fs.Write(by, 0, by.Length);
                            fs.Close();
                            return true;
                        }
                    }
                }
                return false;
            }
            catch (Exception ex)
            {
                WriteLog(ex.Message);
                return false;
            }

        }
        /// <summary>        
        /// 下载文件        
        /// </summary>        
        /// <param name="URL">下载文件地址</param>       
        /// <param name="Filename">下载后的存放地址</param>        
        /// <param name="Prog">用于显示的进度条</param>        
        ///<param name="label1">显示文字</param>      
        public static bool DownloadFile(string URL, string filename,  Form1 form)
        {
            float percent = 0;
            try
            {
                System.Net.HttpWebRequest Myrq = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(URL);
                Myrq.Host = "s3.modskinlolvn.com";
                Myrq.Referer = "http://leagueskin.net/p/download-mod-skin-2020-chn";
                System.Net.HttpWebResponse myrp = (System.Net.HttpWebResponse)Myrq.GetResponse();
                long totalBytes = myrp.ContentLength;
                if (form.uCProcessLineExt != null)
                {
                    form.Invoke(new EventHandler(delegate
                    {
                        form.uCProcessLineExt.MaxValue= (int)totalBytes;
                    }));
                }
                System.IO.Stream st = myrp.GetResponseStream();
                System.IO.Stream so = new System.IO.FileStream(filename, System.IO.FileMode.Create);
                long totalDownloadedByte = 0;
                byte[] by = new byte[1024];
                int osize = st.Read(by, 0, (int)by.Length);
                while (osize > 0)
                {
                    totalDownloadedByte = osize + totalDownloadedByte;
                    System.Windows.Forms.Application.DoEvents();
                    so.Write(by, 0, osize);
                    form.Invoke(new EventHandler(delegate 
                    {
                        if (form.uCProcessLineExt != null)
                        {
                            form.uCProcessLineExt.Value = (int)totalDownloadedByte;
                        }
                        osize = st.Read(by, 0, (int)by.Length);
                        percent = (float)totalDownloadedByte / (float)totalBytes * 100;
                        System.Windows.Forms.Application.DoEvents(); //必须加注这句代码,否则label1将因为循环执行太快而来不及显示信息
                    }));

                }
                so.Close();
                st.Close();
                return true;
            }
            catch (System.Exception ex)
            {
                WriteLog(ex.Message);
                return false;
            }
        }

        static void WriteLog(string str)
        {
            if (!System.IO.Directory.Exists("ErrLog"))
            {
                Directory.CreateDirectory("ErrLog");
            }
            using (var sw = new StreamWriter(@"ErrLog\ErrLog.txt", true))
            {
                sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ":" + str);
                sw.Close();
            }
        }
    }

//Program类源码
[C#] 纯文本查看 复制代码
 static class LOLskin
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            string edition = "";
            string url = "";
            string rootdirectory = "C://DataBase//";
            Form1 frmLoading = new Form1();
            frmLoading.BackgroundWorkAction = delegate ()
            {
                try
                {
                    if (!Directory.Exists(rootdirectory))
                    {
                        Directory.CreateDirectory(rootdirectory);//第一次使用创建文件夹
                    }
                    frmLoading.CurrentMsg = new KeyValuePair<int, string>(1, "正在查询最新版本...");
                    DRQ.GetEdition(ref edition, ref url);//获取最新版本
                    Thread.Sleep(2000);
                    frmLoading.CurrentMsg = new KeyValuePair<int, string>(40, "正在检测是否需要更新...");
                    Version v1 = new Version(Edit());
                    Version v2 = new Version(edition);
                    if (v1 >= v2)
                    {
                        frmLoading.CurrentMsg = new KeyValuePair<int, string>(100, "未检测到新版本,即将打开文件...");
                        Thread.Sleep(2000);
                        OpenExe();//打开文件
                        Environment.Exit(0);
                    }
                    frmLoading.CurrentMsg = new KeyValuePair<int, string>(0, "正在下载新版本...");
                    string path = rootdirectory + "LOL.zip";
                    DRQ.DownloadFile(url, path, frmLoading);//下载文件
                    frmLoading.CurrentMsg = new KeyValuePair<int, string>(0, "正在解压文件...");
                    Thread.Sleep(2000);
                    Delete();//删除历史文件
                    if (SharpZip.UnpackFiles(path, rootdirectory))//解压文件
                    {
                        File.Delete(path);//删除压缩包
                    }
                    frmLoading.CurrentMsg = new KeyValuePair<int, string>(100, "解压成功,正在打开文件...");
                    Thread.Sleep(2000);
                    OpenExe();
                    
                }
                catch (Exception ex)
                {
                    WriteLog(ex.Message);
                }
            };
            frmLoading.ShowDialog();


            void OpenExe()
            {
                DirectoryInfo root = new DirectoryInfo(rootdirectory);
                FileInfo[] files = root.GetFiles();
                foreach (var item in files)
                {
                    if (item.Name.Contains("LOLPRO") && item.Name.Contains(".exe"))
                    {
                        Process.Start(item.FullName);
                        return;
                    }
                }
            }
            //获取现存文件的版本
             string Edit()
            {
                DirectoryInfo root = new DirectoryInfo(rootdirectory);
                FileInfo[] files = root.GetFiles();
                foreach (var item in files)
                {
                    if (item.Name.Contains("LOLPRO") && item.Name.Contains(".exe"))
                    {
                        Regex r = new Regex("LOLPRO (.*?).exe", RegexOptions.None);
                        MatchCollection matchCollection = r.Matches(item.Name);
                        if (matchCollection.Count > 0)
                        {
                            return matchCollection[matchCollection.Count - 1].Groups[1].Value;
                        }
                    }
                }
                return "1.0";
            }
            /// <summary>
            /// 删除历史文件
            /// </summary>
             void Delete()
            {
                DirectoryInfo root = new DirectoryInfo(rootdirectory);
                FileInfo[] files = root.GetFiles();
                foreach (var item in files)
                {
                    if (item.Name.Contains(".exe"))
                    {
                        File.Delete(item.FullName);
                    }
                }

            }
            /// <summary>
            /// 写文件
            /// </summary>
            /// <param name="str"></param>
             void WriteLog(string str)
            {
                if (!System.IO.Directory.Exists("ErrLog"))
                {
                    Directory.CreateDirectory("ErrLog");
                }


                using (var sw = new StreamWriter(@"ErrLog\ErrLog.txt", true))
                {
                    sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")+":"+str);
                    sw.WriteLine("---------------------------------------------------------");
                    sw.Close();
                }
            }
        }
    }

// 界面后台form1.cs
[C#] 纯文本查看 复制代码
 public partial class Form1 : FrmLoading
    {
        public UCProcessLineExt uCProcessLineExt { get; set; }
        public Form1()
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterScreen;
            uCProcessLineExt = this.ucProcessLineExt1;
        }
        protected override void BindingProcessMsg(string strText, int intValue)
        {
            label1.Text = strText;
            this.ucProcessLineExt1.Value = intValue;
        }
        private Point mPoint = new Point();
        private void Form1_MouseMove_1(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                Point myPosittion = MousePosition;
                myPosittion.Offset(-mPoint.X, -mPoint.Y);
                Location = myPosittion;
            }
        }

        private void Form1_MouseUp(object sender, MouseEventArgs e)
        {
            mPoint.X = e.X;
            mPoint.Y = e.Y;

        }
    }

//解压类
[C#] 纯文本查看 复制代码
 public static class SharpZip
    {
        /// <summary>
        /// 压缩
        /// </summary> 
        /// <param name="filename"> 压缩后的文件名(包含物理路径)</param>
        /// <param name="directory">待压缩的文件夹(包含物理路径)</param>
        public static void PackFiles(string filename, string directory)
        {
            try
            {
                FastZip fz = new FastZip();
                fz.CreateEmptyDirectories = true;
                fz.CreateZip(filename, directory, true, "");
                fz = null;
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 解压缩
        /// </summary>
        /// <param name="file">待解压文件名(包含物理路径)</param>
        /// <param name="dir"> 解压到哪个目录中(包含物理路径)</param>
        public static bool UnpackFiles(string file, string dir)
        {
            try
            {
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }
                ZipInputStream s = new ZipInputStream(File.OpenRead(file));
                ZipEntry theEntry;
                while ((theEntry = s.GetNextEntry()) != null)
                {
                    string directoryName = Path.GetDirectoryName(theEntry.Name);
                    string fileName = Path.GetFileName(theEntry.Name);
                    if (directoryName != String.Empty)
                    {
                        Directory.CreateDirectory(dir + directoryName);
                    }
                    if (fileName != String.Empty)
                    {
                        FileStream streamWriter = File.Create(dir + theEntry.Name);
                        int size = 2048;
                        byte[] data = new byte[2048];
                        while (true)
                        {
                            size = s.Read(data, 0, data.Length);
                            if (size > 0)
                            {
                                streamWriter.Write(data, 0, size);
                            }
                            else
                            {
                                break;
                            }
                        }
                        streamWriter.Close();
                    }
                }
                s.Close();
                return true;
            }
            catch (Exception)
            {
                throw;
            }
        }
    }

    public class ClassZip
    {
        #region 私有方法
        /// <summary>
        /// 递归压缩文件夹方法
        /// </summary>
        private static bool ZipFileDictory(string FolderToZip, ZipOutputStream s, string ParentFolderName)
        {
            bool res = true;
            string[] folders, filenames;
            ZipEntry entry = null;
            FileStream fs = null;
            Crc32 crc = new Crc32();
            try
            {
                entry = new ZipEntry(Path.Combine(ParentFolderName, Path.GetFileName(FolderToZip) + "/"));
                s.PutNextEntry(entry);
                s.Flush();
                filenames = Directory.GetFiles(FolderToZip);
                foreach (string file in filenames)
                {
                    fs = File.OpenRead(file);
                    byte[] buffer = new byte[fs.Length];
                    fs.Read(buffer, 0, buffer.Length);
                    entry = new ZipEntry(Path.Combine(ParentFolderName, Path.GetFileName(FolderToZip) + "/" + Path.GetFileName(file)));
                    entry.DateTime = DateTime.Now;
                    entry.Size = fs.Length;
                    fs.Close();
                    crc.Reset();
                    crc.Update(buffer);
                    entry.Crc = crc.Value;
                    s.PutNextEntry(entry);
                    s.Write(buffer, 0, buffer.Length);
                }
            }
            catch
            {
                res = false;
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                    fs = null;
                }
                if (entry != null)
                {
                    entry = null;
                }
                GC.Collect();
                GC.Collect(1);
            }
            folders = Directory.GetDirectories(FolderToZip);
            foreach (string folder in folders)
            {
                if (!ZipFileDictory(folder, s, Path.Combine(ParentFolderName, Path.GetFileName(FolderToZip))))
                {
                    return false;
                }
            }
            return res;
        }

        /// <summary>
        /// 压缩目录
        /// </summary>
        /// <param name="FolderToZip">待压缩的文件夹,全路径格式</param>
        /// <param name="ZipedFile">压缩后的文件名,全路径格式</param>
        private static bool ZipFileDictory(string FolderToZip, string ZipedFile, int level)
        {
            bool res;
            if (!Directory.Exists(FolderToZip))
            {
                return false;
            }
            ZipOutputStream s = new ZipOutputStream(File.Create(ZipedFile));
            s.SetLevel(level);
            res = ZipFileDictory(FolderToZip, s, "");
            s.Finish();
            s.Close();
            return res;
        }

        /// <summary>
        /// 压缩文件
        /// </summary>
        /// <param name="FileToZip">要进行压缩的文件名</param>
        /// <param name="ZipedFile">压缩后生成的压缩文件名</param>
        private static bool ZipFile(string FileToZip, string ZipedFile, int level)
        {
            if (!File.Exists(FileToZip))
            {
                throw new System.IO.FileNotFoundException("指定要压缩的文件: " + FileToZip + " 不存在!");
            }
            FileStream ZipFile = null;
            ZipOutputStream ZipStream = null;
            ZipEntry ZipEntry = null;
            bool res = true;
            try
            {
                ZipFile = File.OpenRead(FileToZip);
                byte[] buffer = new byte[ZipFile.Length];
                ZipFile.Read(buffer, 0, buffer.Length);
                ZipFile.Close();

                ZipFile = File.Create(ZipedFile);
                ZipStream = new ZipOutputStream(ZipFile);
                ZipEntry = new ZipEntry(Path.GetFileName(FileToZip));
                ZipStream.PutNextEntry(ZipEntry);
                ZipStream.SetLevel(level);

                ZipStream.Write(buffer, 0, buffer.Length);
            }
            catch
            {
                res = false;
            }
            finally
            {
                if (ZipEntry != null)
                {
                    ZipEntry = null;
                }
                if (ZipStream != null)
                {
                    ZipStream.Finish();
                    ZipStream.Close();
                }
                if (ZipFile != null)
                {
                    ZipFile.Close();
                    ZipFile = null;
                }
                GC.Collect();
                GC.Collect(1);
            }
            return res;
        }
        #endregion

        /// <summary>
        /// 压缩
        /// </summary>
        /// <param name="FileToZip">待压缩的文件目录</param>
        /// <param name="ZipedFile">生成的目标文件</param>
        /// <param name="level">6</param>
        public static bool Zip(String FileToZip, String ZipedFile, int level)
        {
            if (Directory.Exists(FileToZip))
            {
                return ZipFileDictory(FileToZip, ZipedFile, level);
            }
            else if (File.Exists(FileToZip))
            {
                return ZipFile(FileToZip, ZipedFile, level);
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 解压
        /// </summary>
        /// <param name="FileToUpZip">待解压的文件</param>
        /// <param name="ZipedFolder">解压目标存放目录</param>
        public static void UnZip(string FileToUpZip, string ZipedFolder)
        {
            if (!File.Exists(FileToUpZip))
            {
                return;
            }
            if (!Directory.Exists(ZipedFolder))
            {
                Directory.CreateDirectory(ZipedFolder);
            }
            ZipInputStream s = null;
            ZipEntry theEntry = null;
            string fileName;
            FileStream streamWriter = null;
            try
            {
                s = new ZipInputStream(File.OpenRead(FileToUpZip));
                while ((theEntry = s.GetNextEntry()) != null)
                {
                    if (theEntry.Name != String.Empty)
                    {
                        fileName = Path.Combine(ZipedFolder, theEntry.Name);
                        if (fileName.EndsWith("/") || fileName.EndsWith("\\"))
                        {
                            Directory.CreateDirectory(fileName);
                            continue;
                        }
                        streamWriter = File.Create(fileName);
                        int size = 2048;
                        byte[] data = new byte[2048];
                        while (true)
                        {
                            size = s.Read(data, 0, data.Length);
                            if (size > 0)
                            {
                                streamWriter.Write(data, 0, size);
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                }
            }
            finally
            {
                if (streamWriter != null)
                {
                    streamWriter.Close();
                    streamWriter = null;
                }
                if (theEntry != null)
                {
                    theEntry = null;
                }
                if (s != null)
                {
                    s.Close();
                    s = null;
                }
                GC.Collect();
                GC.Collect(1);
            }
        }
    }

    public class ZipHelper
    {
        #region 私有变量
        String the_rar;
        RegistryKey the_Reg;
        Object the_Obj;
        String the_Info;
        ProcessStartInfo the_StartInfo;
        Process the_Process;
        #endregion

        /// <summary>
        /// 压缩
        /// </summary>
        /// <param name="zipname">要解压的文件名</param>
        /// <param name="zippath">要压缩的文件目录</param>
        /// <param name="dirpath">初始目录</param>
        public void EnZip(string zipname, string zippath, string dirpath)
        {
            try
            {
                the_Reg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRAR.exe\Shell\Open\Command");
                the_Obj = the_Reg.GetValue("");
                the_rar = the_Obj.ToString();
                the_Reg.Close();
                the_rar = the_rar.Substring(1, the_rar.Length - 7);
                the_Info = " a    " + zipname + "  " + zippath;
                the_StartInfo = new ProcessStartInfo();
                the_StartInfo.FileName = the_rar;
                the_StartInfo.Arguments = the_Info;
                the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                the_StartInfo.WorkingDirectory = dirpath;
                the_Process = new Process();
                the_Process.StartInfo = the_StartInfo;
                the_Process.Start();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }

        /// <summary>
        /// 解压缩
        /// </summary>
        /// <param name="zipname">要解压的文件名</param>
        /// <param name="zippath">要解压的文件路径</param>
        public void DeZip(string zipname, string zippath)
        {
            try
            {
                the_Reg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRar.exe\Shell\Open\Command");
                the_Obj = the_Reg.GetValue("");
                the_rar = the_Obj.ToString();
                the_Reg.Close();
                the_rar = the_rar.Substring(1, the_rar.Length - 7);
                the_Info = " X " + zipname + " " + zippath;
                the_StartInfo = new ProcessStartInfo();
                the_StartInfo.FileName = the_rar;
                the_StartInfo.Arguments = the_Info;
                the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                the_Process = new Process();
                the_Process.StartInfo = the_StartInfo;
                the_Process.Start();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
    }

免费评分

参与人数 6吾爱币 +11 热心值 +6 收起 理由
王帅帅 + 1 + 1 鼓励转贴优秀软件安全工具和文档!
苏紫方璇 + 7 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
seazer + 2 + 1 第一次1天,第二次30天,有没有过检测方法啊?
MichaelWin + 1 热心回复!
zxh0 + 1 谢谢@Thanks!
煮蛋的笨蛋 + 1 + 1 谢谢@Thanks!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

xscbelieve 发表于 2020-12-9 17:11
非常感谢
骨朵视觉 发表于 2020-12-9 17:13
a1194029110 发表于 2020-12-9 17:41
国服不是加驱动了嘛,这软件好像没用了,要去驱动才可以用
丹下樱 发表于 2020-12-9 17:49
最近这东西封一天的问题解决了吗?
Anaesthesia 发表于 2020-12-9 18:13
是个好东西,但是这个东西现怎么更新也是封号1天。
zxh0 发表于 2020-12-9 18:24
感谢分享
清风入梦 发表于 2020-12-9 18:27
很喜欢的
buaiwanyouxi 发表于 2020-12-9 18:57
lol skin也开始封号了。。
hackxl 发表于 2020-12-9 19:03
为了个自wei皮肤 封号  值得吗
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-1 12:02

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表