Beispiel #1
0
        private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                StatusLabel.Text           = e.Error.Message;
                MainMenuSpyStart.Enabled   = true;
                MainMenuSpyAttach.Enabled  = true;
                MainMenuSpyDetach.Enabled  = false;
                MainMenuDictionary.Enabled = true;
                Unpack.Enabled             = true;
            }
            else if (e.Result is DictionaryArgs)
            {
                DictionaryArgs args = (DictionaryArgs)e.Result;

                if (args.Load)
                {
                    StatusLabel.Text = "Loading finished.";
                }
                else if (args.Save)
                {
                    StatusLabel.Text = "Saving finished.";
                }
                else if (args.Merge)
                {
                    StatusLabel.Text = String.Format("Merging finished. There is {0} new hashes and {1} new file names.");
                }

                MainMenuDictionary.Enabled = true;
            }
            else if (e.Result is MythicLoadArgs)
            {
                MythicLoadArgs args = (MythicLoadArgs)e.Result;
                TreeNode       parent, child;

                foreach (MythicPackage p in args.Result)
                {
                    parent     = new TreeNode(p.Info.Name);
                    parent.Tag = p;
                    TreeView.Nodes.Add(parent);

                    for (int i = 0; i < p.Blocks.Count; i++)
                    {
                        child     = new TreeNode(String.Format("Block_{0}", i));
                        child.Tag = p.Blocks[i];
                        parent.Nodes.Add(child);
                    }
                }

                if (args.Result.Length > 0)
                {
                    TreeView.SelectedImageIndex = 0;
                    ChangePackage(args.Result[0]);
                }

                StatusLabel.Text = "Loading finished.";

                if (HashDictionary.NewUnknowns > 0)
                {
                    if (MessageBox.Show(String.Format("Found {0} new hashes. Save dictionary?", HashDictionary.NewUnknowns), "Save Dictionary", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        SaveDictionary(HashDictionary.DICTIONARY);
                    }
                }
            }
            else if (e.Result is SpyPathArgs || e.Result is SpyProcessArgs)
            {
                StatusLabel.Text          = "Process terminated.";
                MainMenuSpyStart.Enabled  = true;
                MainMenuSpyAttach.Enabled = true;
                MainMenuSpyDetach.Enabled = false;

                if (HashDictionary.NewFileNames > 0)
                {
                    UpdateFileNames();

                    if (MessageBox.Show(String.Format("Found {0} new file names. Save dictionary?", HashDictionary.NewFileNames), "Save Dictionary", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        SaveDictionary(HashDictionary.DICTIONARY);
                    }
                }
            }
            else if (e.Result is UnpackArgs)
            {
                StatusLabel.Text = "Unpacking finished.";
                Unpack.Enabled   = true;
            }
            else if (e.Result is SearchArgs)
            {
                SearchArgs args = (SearchArgs)e.Result;

                StatusLabel.Text = String.Format("Found {0} file names", args.Found);

                if (args.Found > 0)
                {
                    UpdateFileNames();
                }
            }
        }
Beispiel #2
0
        private void Worker_DoWork(object sender, DoWorkEventArgs e)
        {
            if (e.Argument is DictionaryArgs)
            {
                DictionaryArgs args = (DictionaryArgs)e.Argument;

                if (args.Load)
                {
                    HashDictionary.LoadDictionary(args.Name);
                }
                else if (args.Save)
                {
                    HashDictionary.SaveDictionary(args.Name);
                }
                else if (args.Merge)
                {
                    HashDictionary.MergeDictionary(args.Name);
                }
            }
            else if (e.Argument is MythicLoadArgs)
            {
                MythicLoadArgs  args  = (MythicLoadArgs)e.Argument;
                MythicPackage[] packs = new MythicPackage[args.Names.Length];

                for (int i = 0; i < args.Names.Length; i++)
                {
                    packs[i] = MythicPackage.Read(args.Names[i]);
                }

                args.Result = packs;
            }
            else if (e.Argument is SpyProcessArgs)
            {
                SpyProcessArgs args = (SpyProcessArgs)e.Argument;

                m_Spy.Init(args.Process);
                m_Spy.MainLoop();
            }
            else if (e.Argument is SpyPathArgs)
            {
                SpyPathArgs args = (SpyPathArgs)e.Argument;

                m_Spy.Init(args.Path);
                m_Spy.MainLoop();
            }
            else if (e.Argument is UnpackArgs)
            {
                UnpackArgs args = (UnpackArgs)e.Argument;

                if (args.IsPackage)
                {
                    args.Package.Decompress(UnpackArgs.Path, args.Package.Info.Name);
                }
                else if (args.IsBlock)
                {
                    using (FileStream stream = File.OpenRead(args.Package.Info.FullName))
                    {
                        using (BinaryReader reader = new BinaryReader(stream))
                            args.Block.Decompress(reader, UnpackArgs.Path, args.Package.Info.Name);
                    }
                }
                else if (args.IsFile)
                {
                    using (FileStream stream = File.OpenRead(args.Package.Info.FullName))
                    {
                        using (BinaryReader reader = new BinaryReader(stream))
                            args.File.Decompress(reader, UnpackArgs.Path, String.Format("{0}_{1}", args.Package.Info.Name, args.Block.Index));
                    }
                }
            }
            else if (e.Argument is SearchArgs)
            {
                SearchArgs args = (SearchArgs)e.Argument;

                args.Found = 0;

                for (int i = args.From; i < args.To; i++)
                {
                    if (SearchKeyword(String.Format("{0}{1}{2}", args.Before, i.ToString("D" + args.Length), args.After), true))
                    {
                        args.Found += 1;
                    }
                }
            }

            e.Result = e.Argument;
        }