示例#1
0
        Dictionary <string, string> WalkDirectoryTree(System.IO.DirectoryInfo root)
        {
            System.IO.FileInfo[] files = null;
            var fileMap = new Dictionary <string, string>();

            try
            {
                files = root.GetFiles("*.*");
            }
            // This is thrown if even one of the files requires permissions greater
            // than the application provides.
            catch (UnauthorizedAccessException e)
            {
                txtList.Text += e.Message + "\n";
                return(fileMap);
            }

            catch (System.IO.DirectoryNotFoundException e)
            {
                txtList.Text += e.Message + "\r\n";
                return(fileMap);
            }

            if (files != null)
            {
                var count = 0;
                progressBar.Maximum = files.Length;

                foreach (System.IO.FileInfo fi in files)
                {
                    count++;
                    if (fi.Name.Contains(".ini"))
                    { //Skip INI files
                        continue;
                    }
                    if (fi.Name == System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName)
                    { //Skip self EXE
                        continue;
                    }

                    // In this example, we only access the existing FileInfo object. If we
                    // want to open, delete or modify the file, then
                    // a try-catch block is required here to handle the case
                    // where the file has been deleted since the call to TraverseTree().
                    var md5 = UtilityLibrary.GetMD5(fi.FullName);
                    txtList.Text     += fi.Name + ": " + md5 + "\r\n";
                    progressBar.Value = count;
                    fileMap[fi.Name]  = md5;
                    txtList.Refresh();
                    updateTaskbarProgress();
                    Application.DoEvents();
                }
                //One final update of data
                progressBar.Value = count;
                txtList.Refresh();
                updateTaskbarProgress();
                Application.DoEvents();
            }
            return(fileMap);
        }
示例#2
0
        private string DownloadFile(string url, string path)
        {
            path = path.Replace("/", "\\");
            if (path.Contains("\\"))
            { //Make directory if needed.
                string dir = Application.StartupPath + "\\" + path.Substring(0, path.LastIndexOf("\\"));
                Directory.CreateDirectory(dir);
            }

            //Console.WriteLine(Application.StartupPath + "\\" + path);
            LogEvent(path + "...");
            string reason = UtilityLibrary.DownloadFile(url, path);

            if (reason != "")
            {
                if (reason == "404")
                {
                    LogEvent("Failed to download " + url + ", 404 error (website may be down?)");
                    //MessageBox.Show("Patch server could not be found. (404)");
                }
                else
                {
                    LogEvent("Failed to download " + url + " for untracked reason: " + reason);
                    //MessageBox.Show("Patch server failed: (" + reason + ")");
                }
                return(reason);
            }
            return("");
        }
示例#3
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            //MessageBox.Show("In case you didn't realize it, this patcher doesn't work yet. At this time it's purely under development for testing.");
            // tii.ProgressState = TaskbarItemProgressState.Normal;
            //  tii.ProgressValue = (double)50 /100;

            //Read:

            /*
             * var pv = JsonConvert.DeserializeObject<PatchVersion>(test);
             * MessageBox.Show(pv.ServerName);
             */
            //Write:

            /*
             * PatchVersion pv = new PatchVersion();
             * pv.ServerName = "Test";
             * pv.RootFiles.Add("eqgame.exe", "12345test");
             * txtList.Text = JsonConvert.SerializeObject(pv);
             */
            try {
                var hash = UtilityLibrary.GetEverquestExecutableHash(AppDomain.CurrentDomain.BaseDirectory);
                if (hash == "")
                {
                    MessageBox.Show("Please run this patcher in your Everquest directory.");
                    this.Close();
                    return;
                }
                switch (hash)
                {
                case "85218FC053D8B367F2B704BAC5E30ACC":
                    txtList.Text  = "You seem to have put me in a Secrets of Feydwer client directory";
                    clientVersion = "Secrets of Feydwer";
                    break;

                case "859E89987AA636D36B1007F11C2CD6E0":
                    txtList.Text  = "You seem to have put me in a Underfoot client directory";
                    clientVersion = "Underfoot";
                    break;

                case "BB42BC3870F59B6424A56FED3289C6D4":
                    txtList.Text  = "You seem to have put me in a Titanium client directory";
                    clientVersion = "Titanium";
                    break;

                default:
                    txtList.Text = "I don't recognize the Everquest client in my directory, send this to Shin: " + hash;
                    break;
                }
                txtList.Text += "\r\n\r\nIf you wish to help out, press the scan button on the bottom left and wait for it to complete, then copy paste this data as an Issue on github!";
            }
            catch (UnauthorizedAccessException err)
            {
                MessageBox.Show("You need to run this program with Administrative Privileges" + err.Message);
                return;
            }
        }
示例#4
0
 private void btnStart_Click(object sender, EventArgs e)
 {
     try {
         process = UtilityLibrary.StartEverquest();
     }
     catch (Exception err) {
         MessageBox.Show("An error occured: " + err.Message);
     }
 }
示例#5
0
        //Pass the working directory (or later, you can pass another directory) and it returns a hash if the file is found
        public static string GetEverquestExecutableHash(string path)
        {
            var di    = new System.IO.DirectoryInfo(path);
            var files = di.GetFiles("eqgame.exe");

            if (files == null || files.Length == 0)
            {
                return("");
            }
            return(UtilityLibrary.GetMD5(files[0].FullName));
        }
示例#6
0
 private void PlayGame()
 {
     try
     {
         process = UtilityLibrary.StartEverquest();
         if (process != null)
         {
             this.Close();
         }
         else
         {
             MessageBox.Show("The process failed to start");
         }
     }
     catch (Exception err)
     {
         MessageBox.Show("An error occured while trying to start everquest: " + err.Message);
     }
 }
示例#7
0
        private void StartPatch()
        {
            Process[] pname = Process.GetProcessesByName("eqgame");
            if (pname.Length != 0)
            {
                MessageBox.Show("Everquest is running, please close it.");
                return;
            }

            if (isPatching)
            {
                return;
            }
            isPatching    = true;
            btnCheck.Text = "Cancel";

            txtList.Text = "Patching...";

            using (var input = File.OpenText("filelist.yml"))
            {
                var deserializerBuilder = new DeserializerBuilder().WithNamingConvention(new CamelCaseNamingConvention());

                var deserializer = deserializerBuilder.Build();

                filelist = deserializer.Deserialize <FileList>(input);
            }

            foreach (var entry in filelist.downloads)
            {
                Application.DoEvents();
                var path = entry.name.Replace("/", "\\");
                //See if file exists.
                if (!File.Exists(path) || isPatchForce)
                {
                    //Console.WriteLine("Downloading: "+ entry.name);
                    filesToDownload.Add(entry);
                    if (entry.size < 1)
                    {
                        totalBytes += 1;
                    }
                    else
                    {
                        totalBytes += entry.size;
                    }
                }
                else
                {
                    var md5 = UtilityLibrary.GetMD5(path);

                    if (md5.ToUpper() != entry.md5.ToUpper())
                    {
                        Console.WriteLine(entry.name + ": " + md5 + " vs " + entry.md5);
                        filesToDownload.Add(entry);
                        if (entry.size < 1)
                        {
                            totalBytes += 1;
                        }
                        else
                        {
                            totalBytes += entry.size;
                        }
                    }
                }
                Application.DoEvents();
                if (!isPatching)
                {
                    LogEvent("Patching cancelled.");
                    return;
                }
            }

            if (filelist.deletes != null && filelist.deletes.Count > 0)
            {
                foreach (var entry in filelist.deletes)
                {
                    if (File.Exists(entry.name))
                    {
                        LogEvent("Deleting " + entry.name + "...");
                        File.Delete(entry.name);
                    }
                    Application.DoEvents();
                    if (!isPatching)
                    {
                        LogEvent("Patching cancelled.");
                        return;
                    }
                }
            }

            if (filesToDownload.Count == 0)
            {
                LogEvent("Up to date with patch " + filelist.version + ".");
                progressBar.Maximum = progressBar.Value = 1;
                IniLibrary.instance.LastPatchedVersion = filelist.version;
                IniLibrary.Save();
                btnCheck.BackColor = SystemColors.Control;
                btnCheck.Text      = "Force Full Download";
                labelPerc.Text     = "Done";
                isPatching         = false;
                isDone             = true;
                isPatchForce       = false;
                return;
            }

            LogEvent("Downloading " + totalBytes + " bytes for " + filesToDownload.Count + " files...");
            curBytes = 0;

            if (!isAsync)
            {
                //progressBar.Maximum = totalBytes;
                progressBar.Maximum = 100;
                progressBar.Value   = 0;
                foreach (var entry in filesToDownload)
                {
                    //progressBar.Value = (curBytes > totalBytes) ? totalBytes : curBytes;
                    progressBar.Value = (curBytes > totalBytes) ? 100 : (int)((100d / totalBytes) * (curBytes));;
                    string url = filelist.downloadprefix + entry.name.Replace("\\", "/");
                    DownloadFile(url, entry.name);
                    curBytes += entry.size;
                    Application.DoEvents();
                    if (!isPatching)
                    {
                        LogEvent("Patching cancelled.");
                        return;
                    }
                }
                progressBar.Value = progressBar.Maximum;
                LogEvent("Complete! Press Play to begin.");
                IniLibrary.instance.LastPatchedVersion = filelist.version;
                IniLibrary.Save();
                btnCheck.BackColor = SystemColors.Control;
                btnCheck.Text      = "Force Full Download";
                labelPerc.Text     = "Done";
                isPatching         = false;
                isDone             = true;
                isPatchForce       = false;
            }
            else
            {
                progressBar.Maximum = 100;
                progressBar.Value   = 0;
                string path;

                foreach (var entry in filesToDownload)
                {
                    isAsyncDone = false;
                    path        = entry.name.Replace("/", "\\");
                    string url = filelist.downloadprefix + path;

                    LogEvent(path + "...");

                    DownloadFileUrl(url, entry.name);

                    while (!isAsyncDone)
                    {
                        Application.DoEvents();
                        if (isCancelled || isError)
                        {
                            return;
                        }
                    }
                }

                //progressBar.Value = progressBar.Maximum;
                LogEvent("Complete! Press Play to begin.");
                IniLibrary.instance.LastPatchedVersion = filelist.version;
                IniLibrary.Save();
                btnCheck.BackColor = SystemColors.Control;
                btnCheck.Text      = "Force Full Download";
                labelPerc.Text     = "Done";
                isPatching         = false;
                isDone             = true;
                isPatchForce       = false;
            }
        }
示例#8
0
        private void detectClientVersion()
        {
            try
            {
                var hash = UtilityLibrary.GetEverquestExecutableHash(AppDomain.CurrentDomain.BaseDirectory);
                if (hash == "")
                {
                    MessageBox.Show("Please run this patcher in your Everquest directory.");
                    this.Close();
                    return;
                }
                switch (hash)
                {
                case "85218FC053D8B367F2B704BAC5E30ACC":
                    currentVersion   = VersionTypes.Secrets_Of_Feydwer;
                    splashLogo.Image = Properties.Resources.sof;
                    break;

                case "859E89987AA636D36B1007F11C2CD6E0":
                case "EF07EE6649C9A2BA2EFFC3F346388E1E78B44B48":     //one of the torrented uf clients, used by B&R too
                    currentVersion   = VersionTypes.Underfoot;
                    splashLogo.Image = Properties.Resources.underfoot;
                    break;

                case "A9DE1B8CC5C451B32084656FCACF1103":     //p99 client
                case "BB42BC3870F59B6424A56FED3289C6D4":     //vanilla titanium
                    currentVersion   = VersionTypes.Titanium;
                    splashLogo.Image = Properties.Resources.titanium;
                    break;

                case "368BB9F425C8A55030A63E606D184445":
                    currentVersion   = VersionTypes.Rain_Of_Fear;
                    splashLogo.Image = Properties.Resources.rof;
                    break;

                case "240C80800112ADA825C146D7349CE85B":
                case "A057A23F030BAA1C4910323B131407105ACAD14D":     //This is a custom ROF2 from a torrent download
                    currentVersion   = VersionTypes.Rain_Of_Fear_2;
                    splashLogo.Image = Properties.Resources.rof;
                    break;

                case "6BFAE252C1A64FE8A3E176CAEE7AAE60":     //This is one of the live EQ binaries.
                case "AD970AD6DB97E5BB21141C205CAD6E68":     //2016/08/27
                    currentVersion   = VersionTypes.Broken_Mirror;
                    splashLogo.Image = Properties.Resources.brokenmirror;
                    break;

                default:
                    currentVersion = VersionTypes.Unknown;
                    break;
                }
                if (currentVersion == VersionTypes.Unknown)
                {
                    if (MessageBox.Show("Unable to recognize the Everquest client in this directory, open a web page to report to devs?", "Visit", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
                    {
                        System.Diagnostics.Process.Start("https://github.com/Xackery/eqemupatcher/issues/new?title=A+New+EQClient+Found&body=Hi+I+Found+A+New+Client!+Hash:+" + hash);
                    }
                    txtList.Text = "Unable to recognize the Everquest client in this directory, send to developers: " + hash;
                }
                else
                {
                    //txtList.Text = "You seem to have put me in a " + clientVersions[currentVersion].FullName + " client directory";
                }

                //MessageBox.Show(""+currentVersion);

                //txtList.Text += "\r\n\r\nIf you wish to help out, press the scan button on the bottom left and wait for it to complete, then copy paste this data as an Issue on github!";
            }
            catch (UnauthorizedAccessException err)
            {
                MessageBox.Show("You need to run this program with Administrative Privileges" + err.Message);
                return;
            }
        }
示例#9
0
        private void StartPatch()
        {
            if (isPatching)
            {
                return;
            }
            isPatching    = true;
            btnCheck.Text = "Cancel";

            txtList.Text = "Patching...";
            FileList filelist;

            using (var input = File.OpenText("filelist.yml"))
            {
                var deserializerBuilder = new DeserializerBuilder().WithNamingConvention(new CamelCaseNamingConvention());

                var deserializer = deserializerBuilder.Build();

                filelist = deserializer.Deserialize <FileList>(input);
            }
            int totalBytes = 0;
            List <FileEntry> filesToDownload = new List <FileEntry>();

            foreach (var entry in filelist.downloads)
            {
                Application.DoEvents();
                var path = entry.name.Replace("/", "\\");
                //See if file exists.
                if (!File.Exists(path))
                {
                    //Console.WriteLine("Downloading: "+ entry.name);
                    filesToDownload.Add(entry);
                    if (entry.size < 1)
                    {
                        totalBytes += 1;
                    }
                    else
                    {
                        totalBytes += entry.size;
                    }
                }
                else
                {
                    var md5 = UtilityLibrary.GetMD5(path);

                    if (md5.ToUpper() != entry.md5.ToUpper())
                    {
                        Console.WriteLine(entry.name + ": " + md5 + " vs " + entry.md5);
                        filesToDownload.Add(entry);
                        if (entry.size < 1)
                        {
                            totalBytes += 1;
                        }
                        else
                        {
                            totalBytes += entry.size;
                        }
                    }
                }
                Application.DoEvents();
                if (!isPatching)
                {
                    LogEvent("Patching cancelled.");
                    return;
                }
            }

            if (filelist.deletes != null && filelist.deletes.Count > 0)
            {
                foreach (var entry in filelist.deletes)
                {
                    if (File.Exists(entry.name))
                    {
                        LogEvent("Deleting " + entry.name + "...");
                        File.Delete(entry.name);
                    }
                    Application.DoEvents();
                    if (!isPatching)
                    {
                        LogEvent("Patching cancelled.");
                        return;
                    }
                }
            }

            if (filesToDownload.Count == 0)
            {
                LogEvent("Up to date with patch " + filelist.version + ".");
                progressBar.Maximum = progressBar.Value = 1;
                IniLibrary.instance.LastPatchedVersion = filelist.version;
                IniLibrary.Save();
                btnCheck.BackColor = SystemColors.Control;
                btnCheck.Text      = "Patch";
                return;
            }

            LogEvent("Downloading " + totalBytes + " bytes for " + filesToDownload.Count + " files...");
            int curBytes = 0;

            progressBar.Maximum = totalBytes;
            progressBar.Value   = 0;
            foreach (var entry in filesToDownload)
            {
                progressBar.Value = (curBytes > totalBytes) ? totalBytes : curBytes;
                string url = filelist.downloadprefix + entry.name.Replace("\\", "/");
                DownloadFile(url, entry.name);
                curBytes += entry.size;
                Application.DoEvents();
                if (!isPatching)
                {
                    LogEvent("Patching cancelled.");
                    return;
                }
            }
            progressBar.Value = progressBar.Maximum;
            LogEvent("Complete! Press Play to begin.");
            IniLibrary.instance.LastPatchedVersion = filelist.version;
            IniLibrary.Save();
            btnCheck.BackColor = SystemColors.Control;
            btnCheck.Text      = "Patch";
        }