示例#1
0
        /// <summary>
        /// Loads a SWF, saves it again and then loads what was saved. The final result is compared with
        /// a predicted output file to make sure it contains what it's supposed to contain.
        /// </summary>
        /// <param name="name">The name of the SWF which is retrieved from the resources folder.</param>
        /// <param name="reAssembleCode">If true, the ABC bytecode will be disassembled and re-assembled
        /// again to test the assembler.</param>
        private void ResaveWithPredictedOutput(string name, bool reAssembleCode)
        {
            StringBuilder binDump = new StringBuilder();

            using (SWFReader sr = new SWFReader(this.ResourceAsStream(name + @".swf"), new SWFReaderOptions()
            {
                StrictTagLength = true
            }, binDump, this))
            {
                SWF swf = null;
                try
                {
                    swf = sr.ReadSWF(new SWFContext(name));
                }
                finally
                {
                    using (FileStream fs = new FileStream(this.TestDir + name + @".bin.dump-1.txt", FileMode.Create))
                    {
                        byte[] dumpbindata = new ASCIIEncoding().GetBytes(binDump.ToString());
                        fs.Write(dumpbindata, 0, dumpbindata.Length);
                    }
                }

                Assert.IsNotNull(swf);

                if (reAssembleCode)
                {
                    swf.MarkCodeAsTampered();
                }

                /* Save it out, then reload it to make sure it can survive intact */
                this.SaveAndVerifyPredictedOutput(swf, name, false);
            }
        }
示例#2
0
 private void TestSWF(string name)
 {
     using (SWFReader swfIn = new SWFReader(ResourceAsStream(name), new SWFModeller.IO.SWFReaderOptions(), null, null))
     {
         SWF swf = swfIn.ReadSWF(new SWFContext(name));
         ConvertSWF(name, swf);
     }
 }
示例#3
0
 public Rect(SWFReader swf)
 {
     int nBits = (int)swf.ReadUB(5);
     xMin = swf.ReadSB(nBits);
     xMax = swf.ReadSB(nBits);
     yMin = swf.ReadSB(nBits);
     yMax = swf.ReadSB(nBits);
 }
示例#4
0
        /// <summary>
        /// App entry point
        /// </summary>
        /// <param name="args">Command line arguments</param>
        public static void Main(string[] args)
        {
            try
            {
                string config;
                string explode;

                string job = ParseArguments(args, out config, out explode);
                if (job == null && explode == null)
                {
                    PrintUsage();
                    Environment.Exit(-1);
                }

                if (explode != null)
                {
                    FileInfo swfFile = new FileInfo(explode);
                    using (FileStream swfIn = new FileStream(explode, FileMode.Open, FileAccess.Read))
                    {
                        ABCCatcher catcher = new ABCCatcher();
                        SWFReader  reader  = new SWFReader(swfIn, new SWFReaderOptions(), null, catcher);
                        reader.ReadSWF(new SWFContext(explode));
                        catcher.SaveAll(explode, swfFile.DirectoryName);
                    }
                }

                Swiffotron swiffotron;
                if (config == null)
                {
                    swiffotron = new Swiffotron(null);
                }
                else
                {
                    using (FileStream cfs = new FileStream(config, FileMode.Open, FileAccess.Read))
                    {
                        swiffotron = new Swiffotron(cfs);
                    }
                }

                if (job != null)
                {
                    using (FileStream jobfs = new FileStream(job, FileMode.Open, FileAccess.Read))
                    {
                        swiffotron.Process(jobfs);
                    }
                }
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            }
        }
示例#5
0
        public static Rect ReadRect(BinaryReader b)
        {
            uint NumberOfBits = SWFReader.ReadUnsignedBits(b, 5);
            Rect returnRect   = new Rect()
            {
                Nbits = NumberOfBits,
                Xmin  = SWFReader.ReadSignedBits(b, NumberOfBits),
                Xmax  = SWFReader.ReadSignedBits(b, NumberOfBits),
                Ymin  = SWFReader.ReadSignedBits(b, NumberOfBits),
                Ymax  = SWFReader.ReadSignedBits(b, NumberOfBits)
            };

            return(returnRect);
        }
        public static string GetCurrentVersion(string location)
        {
            location += "RADS\\projects\\lol_air_client\\releases\\";
            ASCIIEncoding encoding = new ASCIIEncoding();
            DirectoryInfo dInfo    = new DirectoryInfo(location);

            DirectoryInfo[] subdirs = null;
            try
            {
                subdirs = dInfo.GetDirectories();
            }
            catch { return("0.0.0.0"); }
            string latestVersion = "0.0.1";

            foreach (DirectoryInfo info in subdirs)
            {
                latestVersion = info.Name;
            }

            // https://github.com/eddy5641/LegendaryClient/blob/b6cbb58d3d2f5153f8cb1b693275c15064d6beac/LegendaryClient/Windows/LoginPage.xaml.cs#L232-L250
            string CommonLib = Path.Combine(location, latestVersion, "deploy\\lib\\ClientLibCommon.dat");
            var    reader    = new SWFReader(CommonLib);

            foreach (var secondSplit in from abcTag in reader.Tags.OfType <DoABC>()
                     where abcTag.Name.Contains("riotgames/platform/gameclient/application/Version")
                     select Encoding.Default.GetString(abcTag.ABCData)
                     into str
                     select str.Split((char)6)
                     into firstSplit

                     select firstSplit[0].Split((char)18))
            {
                try
                {
                    return(secondSplit[1]);
                }
                catch
                {
                    var thirdSplit = secondSplit[0].Split((char)19);
                    return(thirdSplit[1]);
                }
            }

            return("0");
        }
示例#7
0
        public void Run(string[] files)
        {
            try
            {
                foreach (string swfFile in files)
                {
                    if (!File.Exists(swfFile))
                    {
                        Console.WriteLine("Not found: " + swfFile);
                        return;
                    }
                }

                foreach (string swfFile in files)
                {
                    StringBuilder binDump   = new StringBuilder();
                    StringBuilder modelDump = new StringBuilder();

                    SWF swf = null;
                    using (FileStream fs = new FileStream(swfFile, FileMode.Open, FileAccess.Read))
                    {
                        swf = new SWFReader(fs, null, binDump, this).ReadSWF(new SWFContext(swfFile));
                        swf.ToStringModelView(0, modelDump);
                    }

                    using (FileStream binOut = new FileStream(swfFile + ".SWFDUMP.bin.txt", FileMode.Create))
                    {
                        byte[] ascii = new ASCIIEncoding().GetBytes(binDump.ToString());
                        binOut.Write(ascii, 0, ascii.Length);
                    }

                    using (FileStream modelOut = new FileStream(swfFile + ".SWFDUMP.model.txt", FileMode.Create))
                    {
                        byte[] ascii = new ASCIIEncoding().GetBytes(modelDump.ToString());
                        modelOut.Write(ascii, 0, ascii.Length);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
示例#8
0
        private static String GetVersion(String filename)
        {
            SWFReader reader = new SWFReader(filename);

            foreach (Tag tag in reader.Tags)
            {
                if (tag is DoABC)
                {
                    DoABC abcTag = (DoABC)tag;
                    if (abcTag.Name.Contains("riotgames/platform/gameclient/application/Version"))
                    {
                        var      str        = System.Text.Encoding.Default.GetString(abcTag.ABCData);
                        string[] firstSplit = str.Split((char)6);
                        //string[] secondSplit = firstSplit[0].Split((char)19);
                        return(firstSplit[0].Substring(firstSplit[0].IndexOf("CURRENT_VERSION") + 17)); //17 for CURRENT_VERSION + 2 hidden characters
                    }
                }
            }
            return("3.15.14_01_08_11_31");
        }
示例#9
0
        public void CheckCommits(Dictionary <string, byte[]> commits)
        {
            foreach (string key in commits.Keys)
            {
                byte[] data = commits[key];

                if (key.ToLower().EndsWith(".swf"))
                {
                    string swfDump = null;
                    try
                    {
                        using (MemoryStream ms = new MemoryStream(data))
                            using (SWFReader reader = new SWFReader(ms, new SWFReaderOptions()
                            {
                                StrictTagLength = true
                            }, null, null))
                            {
                                swfDump = SwfToString(reader.ReadSWF(new SWFContext(key)));
                            }
                    }
                    finally
                    {
                        lastCommitModelOutput = TestDir + key + ".model.txt";
                        using (FileStream fs = new FileStream(lastCommitModelOutput, FileMode.Create))
                        {
                            if (swfDump != null)
                            {
                                byte[] modeldata = new ASCIIEncoding().GetBytes(swfDump.ToString().Replace("\r", ""));
                                fs.Write(modeldata, 0, modeldata.Length);
                            }
                        }
                    }
                }
                else
                {
                    Assert.Fail("For unit tests, a file extension is required on output keys");
                }
            }
        }
        public LoginPage()
        {
            InitializeComponent();

            //Get client data after patcher completed
            Client.SQLiteDatabase = new SQLite.SQLiteConnection("gameStats_en_US.sqlite");
            Client.Champions      = (from s in Client.SQLiteDatabase.Table <champions>()
                                     orderby s.name
                                     select s).ToList();

            if (Properties.Settings.Default.FavouriteChamps == null)
            {
                Properties.Settings.Default.FavouriteChamps = new Int32[0];
            }

            foreach (champions c in Client.Champions)
            {
                string Source = Path.Combine(Client.ExecutingDirectory, "Assets", "champions", c.iconPath);
                c.icon = Client.GetImage(Source);
                Champions.InsertExtraChampData(c);
                if (Properties.Settings.Default.FavouriteChamps.Contains(c.id))
                {
                    c.IsFavourite = true;
                }
            }

            Client.ChampionSkins = (from s in Client.SQLiteDatabase.Table <championSkins>()
                                    orderby s.name
                                    select s).ToList();
            Client.SearchTags = (from s in Client.SQLiteDatabase.Table <championSearchTags>()
                                 orderby s.id
                                 select s).ToList();
            Client.Keybinds = (from s in Client.SQLiteDatabase.Table <keybindingEvents>()
                               orderby s.id
                               select s).ToList();
            Client.Items     = Items.PopulateItems();
            Client.Masteries = Masteries.PopulateMasteries();
            Client.Runes     = Runes.PopulateRunes();

            //Retrieve latest client version
            SWFReader reader = new SWFReader("ClientLibCommon.dat");

            foreach (Tag tag in reader.Tags)
            {
                if (tag is DoABC)
                {
                    DoABC abcTag = (DoABC)tag;
                    if (abcTag.Name.Contains("riotgames/platform/gameclient/application/Version"))
                    {
                        var str = System.Text.Encoding.Default.GetString(abcTag.ABCData);
                        //Ugly hack ahead - turn back now! (http://pastebin.com/yz1X4HBg)
                        string[] firstSplit  = str.Split((char)6);
                        string[] secondSplit = firstSplit[0].Split((char)18);
                        //Client.Version = secondSplit[1];
                    }
                }
            }

            if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SavedUsername))
            {
                RememberUsernameCheckbox.IsChecked = true;
                LoginUsernameBox.Text = Properties.Settings.Default.SavedUsername;
            }
            if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SavedPassword))
            {
                RememberPasswordCheckbox.IsChecked = true;
                LoginPasswordBox.Password          = Properties.Settings.Default.SavedPassword;
            }
            if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.Region))
            {
                RegionComboBox.SelectedValue = Properties.Settings.Default.Region;
            }
            string uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "champions", champions.GetChampion(Client.LatestChamp).splashPath);

            LoginImage.Source = Client.GetImage(uriSource);
            if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SavedPassword) &&
                !String.IsNullOrWhiteSpace(Properties.Settings.Default.Region) &&
                Properties.Settings.Default.AutoLogin)
            {
                AutoLoginCheckBox.IsChecked = true;
                LoginButton_Click(null, null);
            }
        }
示例#11
0
        public LoginPage()
        {
            InitializeComponent();
            Change();
            Client.donepatch     = true;
            Client.patching      = false;
            Version.TextChanged += WaterTextbox_TextChanged;
            bool x = Settings.Default.DarkTheme;

            if (!x)
            {
                var bc = new BrushConverter();
                HideGrid.Background = (Brush)bc.ConvertFrom("#B24F4F4F");
                LoggingInProgressRing.Foreground = (Brush)bc.ConvertFrom("#FFFFFFFF");
            }
            //#B2C8C8C8
            UpdateRegionComboBox.SelectedValue = Client.UpdateRegion;
            if (Client.UpdateRegion == "Garena" && !Client.Garena)
            {
                LoadGarena();
            }
            switch (Client.UpdateRegion)
            {
            case "PBE": RegionComboBox.ItemsSource = new[] { "PBE" };
                break;

            case "Live": RegionComboBox.ItemsSource = new[] { "BR", "EUNE", "EUW", "NA", "OCE", "RU", "LAS", "LAN", "TR", "CS" };
                break;

            case "Korea": RegionComboBox.ItemsSource = new[] { "KR" };
                break;

            case "Garena": RegionComboBox.ItemsSource = new[] { "PH", "SG", "SGMY", "TH", "TW", "VN" };
                break;
            }


            if (!Settings.Default.DisableLoginMusic)
            {
                SoundPlayer.Source = new Uri(Path.Combine(Client.ExecutingDirectory, "Client", "Login.mp3"));
                SoundPlayer.Play();
                Sound.IsChecked = false;
            }
            else
            {
                Sound.IsChecked = true;
            }

            if (!String.IsNullOrEmpty(Settings.Default.devKeyLoc))
            {
                if (Client.Authenticate(Settings.Default.devKeyLoc))
                {
                    Client.Dev          = true;
                    devKeyLabel.Content = "Dev";
                }
            }

            if (Settings.Default.LoginPageImage == "")
            {
                LoginPic.Source         = new Uri(Path.Combine(Client.ExecutingDirectory, "Client", "Login.mp4"));
                LoginPic.LoadedBehavior = MediaState.Manual;
                LoginPic.MediaEnded    += LoginPic_MediaEnded;
                SoundPlayer.MediaEnded += SoundPlayer_MediaEnded;
                LoginPic.Play();
            }
            else
            {
                if (
                    File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "champions",
                                             Settings.Default.LoginPageImage.Replace("\r\n", ""))))
                {
                    LoginImage.Source =
                        new BitmapImage(
                            new Uri(
                                Path.Combine(Client.ExecutingDirectory, "Assets", "champions",
                                             Settings.Default.LoginPageImage), UriKind.Absolute));
                }
            }

            Video.IsChecked = false;

            //Get client data after patcher completed

            Client.SQLiteDatabase = new SQLiteConnection(Path.Combine(Client.ExecutingDirectory, Client.sqlite));
            Client.Champions      = (from s in Client.SQLiteDatabase.Table <champions>()
                                     orderby s.name
                                     select s).ToList();

            FreeToPlayChampions.GetInstance();

            foreach (champions c in Client.Champions)
            {
                var source = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", c.iconPath),
                                     UriKind.Absolute);
                c.icon = new BitmapImage(source);
                Debugger.Log(0, "Log", "Requesting :" + c.name + " champ");
                Debugger.Log(0, "", Environment.NewLine);

                try
                {
                    c.IsFreeToPlay = FreeToPlayChampions.GetInstance().IsFreeToPlay(c);
                    Champions.InsertExtraChampData(c);
                    //why was this ever here? all of the needed info is already in the sqlite file
                }
                catch
                {
                    Client.Log("error, file not found", "NotFound");
                }
            }
            Client.ChampionSkins = (from s in Client.SQLiteDatabase.Table <championSkins>()
                                    orderby s.name
                                    select s).ToList();
            Client.ChampionAbilities = (from s in Client.SQLiteDatabase.Table <championAbilities>()
                                        //Needs Fixed
                                        orderby s.name
                                        select s).ToList();
            Client.SearchTags = (from s in Client.SQLiteDatabase.Table <championSearchTags>()
                                 orderby s.id
                                 select s).ToList();
            Client.Keybinds = (from s in Client.SQLiteDatabase.Table <keybindingEvents>()
                               orderby s.id
                               select s).ToList();
            Client.Items     = Items.PopulateItems();
            Client.Masteries = Masteries.PopulateMasteries();
            Client.Runes     = Runes.PopulateRunes();
            BaseUpdateRegion updateRegion = BaseUpdateRegion.GetUpdateRegion(Client.UpdateRegion);
            var patcher = new RiotPatcher();

            string tempString = patcher.GetListing(updateRegion.AirListing);

            string[] packages = patcher.GetManifest(
                updateRegion.AirManifest + "releases/" + tempString + "/packages/files/packagemanifest");
            foreach (
                string usestring in
                packages.Select(package => package.Split(',')[0])
                .Where(usestring => usestring.Contains("ClientLibCommon.dat")))
            {
                new WebClient().DownloadFile(new Uri(updateRegion.BaseLink + usestring),
                                             Path.Combine(Client.ExecutingDirectory, "ClientLibCommon.dat"));
            }

            var reader = new SWFReader(Path.Combine(Client.ExecutingDirectory, "ClientLibCommon.dat"));

            foreach (var secondSplit in from abcTag in reader.Tags.OfType <DoABC>()
                     where abcTag.Name.Contains("riotgames/platform/gameclient/application/Version")
                     select Encoding.Default.GetString(abcTag.ABCData)
                     into str
                     select str.Split((char)6)
                     into firstSplit

                     select firstSplit[0].Split((char)18))
            {
                try
                {
                    Client.Version = secondSplit[1];
                }
                catch
                {
                    var thirdSplit = secondSplit[0].Split((char)19);
                    Client.Version = thirdSplit[1];
                }
            }


            Version.Text = Client.Version;

            if (!String.IsNullOrWhiteSpace(Settings.Default.SavedUsername))
            {
                RememberUsernameCheckbox.IsChecked = true;
                LoginUsernameBox.Text = Settings.Default.SavedUsername;
            }
            if (!String.IsNullOrWhiteSpace(Settings.Default.SavedPassword))
            {
                SHA1 sha = new SHA1CryptoServiceProvider();
                RememberPasswordCheckbox.IsChecked = true;
                LoginPasswordBox.Password          =
                    Settings.Default.SavedPassword.DecryptStringAES(
                        sha.ComputeHash(Encoding.UTF8.GetBytes(Settings.Default.Guid)).ToString());
            }
            if (!String.IsNullOrWhiteSpace(Settings.Default.Region))
            {
                RegionComboBox.SelectedValue = Settings.Default.Region;
            }

            invisibleLoginCheckBox.IsChecked = Settings.Default.incognitoLogin;

            /*var uriSource =
             *  new Uri(
             *      Path.Combine(Client.ExecutingDirectory, "Assets", "champions",
             *          champions.GetChampion(Client.LatestChamp).splashPath), UriKind.Absolute);
             * LoginImage.Source = new BitmapImage(uriSource);*/
            if (Client.Garena)
            {
                Client.PVPNet = null;
                Client.PVPNet = new PVPNetConnection();
                BaseRegion Garenaregion = BaseRegion.GetRegion(Client.args[1]);
                Client.PVPNet.garenaToken = Client.args[2];
                Client.PVPNet.Connect("", "", Garenaregion.PVPRegion, Client.Version);
                Client.Region                    = Garenaregion;
                HideGrid.Visibility              = Visibility.Hidden;
                ErrorTextBox.Visibility          = Visibility.Hidden;
                LoggingInLabel.Visibility        = Visibility.Visible;
                LoggingInProgressRing.Visibility = Visibility.Visible;
                Client.PVPNet.OnError           += PVPNet_OnError;
                Client.PVPNet.OnLogin           += PVPNet_OnLogin;
                Client.PVPNet.OnMessageReceived += Client.OnMessageReceived;
            }

            if (String.IsNullOrWhiteSpace(Settings.Default.SavedPassword) ||
                String.IsNullOrWhiteSpace(Settings.Default.Region) || !Settings.Default.AutoLogin)
            {
                return;
            }

            AutoLoginCheckBox.IsChecked = true;
            LoginButton_Click(null, null);
        }
示例#12
0
        public LoginPage()
        {
            InitializeComponent();

            //Get client data after patcher completed
            string latestVersion = "0.0.0.0";
            string GameLocation  = Path.Combine("League of Legends", "RADS");

            if (Directory.Exists(GameLocation))
            {
                System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
                DirectoryInfo             dInfo    = new DirectoryInfo(Path.Combine(GameLocation, "projects", "lol_air_client", "releases"));
                DirectoryInfo[]           subdirs  = null;
                try
                {
                    subdirs = dInfo.GetDirectories();
                    foreach (DirectoryInfo info in subdirs)
                    {
                        latestVersion = GetGreaterVersion(latestVersion, info.Name);
                    }
                }
                catch (Exception er) { Console.WriteLine(er.Message); }
            }

            Client.SQLiteDatabase = new SQLite.SQLiteConnection(Path.Combine(GameLocation, "projects", "lol_air_client", "releases", latestVersion, "deploy", "assets", "data", "gameStats", "gameStats_en_US.sqlite"));
            Client.Champions      = (from s in Client.SQLiteDatabase.Table <champions>()
                                     orderby s.name
                                     select s).ToList();

            if (Properties.Settings.Default.FavouriteChamps == null)
            {
                Properties.Settings.Default.FavouriteChamps = new Int32[0];
            }

            foreach (champions c in Client.Champions)
            {
                string Source = Path.Combine(Client.ExecutingDirectory, "Assets", "champions", c.iconPath);
                c.icon = Client.GetImage(Source);
                Champions.InsertExtraChampData(c);
                if (Properties.Settings.Default.FavouriteChamps.Contains(c.id))
                {
                    c.IsFavourite = true;
                }
            }

            Client.ChampionSkins = (from s in Client.SQLiteDatabase.Table <championSkins>()
                                    orderby s.name
                                    select s).ToList();
            Client.SearchTags = (from s in Client.SQLiteDatabase.Table <championSearchTags>()
                                 orderby s.id
                                 select s).ToList();
            Client.Keybinds = (from s in Client.SQLiteDatabase.Table <keybindingEvents>()
                               orderby s.id
                               select s).ToList();
            Client.Items     = Items.PopulateItems();
            Client.Masteries = Masteries.PopulateMasteries();
            Client.Runes     = Runes.PopulateRunes();

            //Retrieve latest client version
            SWFReader reader = new SWFReader("ClientLibCommon.dat");

            foreach (Tag tag in reader.Tags)
            {
                if (tag is DoABC)
                {
                    DoABC abcTag = (DoABC)tag;
                    if (abcTag.Name.Contains("riotgames/platform/gameclient/application/Version"))
                    {
                        var str = System.Text.Encoding.Default.GetString(abcTag.ABCData);
                        //Ugly hack ahead - turn back now! (http://pastebin.com/yz1X4HBg)
                        string[] firstSplit  = str.Split((char)6);
                        string[] secondSplit = firstSplit[0].Split((char)19);
                        Client.Version = secondSplit[1];
                    }
                }
            }

            if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SavedUsername))
            {
                RememberUsernameCheckbox.IsChecked = true;
                LoginUsernameBox.Text = Properties.Settings.Default.SavedUsername;
            }
            if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SavedPassword))
            {
                RememberPasswordCheckbox.IsChecked = true;
                LoginPasswordBox.Password          = Properties.Settings.Default.SavedPassword;
            }
            if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.Region))
            {
                RegionComboBox.SelectedValue = Properties.Settings.Default.Region;
            }
            champions champ     = champions.GetChampion(Client.LatestChamp);
            string    uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "champions", champ.splashPath);

            LoginImage.Source = Client.GetImage(uriSource);
            if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SavedPassword) &&
                !String.IsNullOrWhiteSpace(Properties.Settings.Default.Region) &&
                Properties.Settings.Default.AutoLogin)
            {
                AutoLoginCheckBox.IsChecked = true;
                LoginButton_Click(null, null);
            }
        }
示例#13
0
        public LoginPage()
        {
            InitializeComponent();
            Client.donepatch     = true;
            Client.patching      = false;
            Version.TextChanged += WaterTextbox_TextChanged;
            bool x = Settings.Default.DarkTheme;

            if (!x)
            {
                var bc = new BrushConverter();
                HideGrid.Background = (Brush)bc.ConvertFrom("#B24F4F4F");
                LoggingInProgressRing.Foreground = (Brush)bc.ConvertFrom("#FFFFFFFF");
            }
            //#B2C8C8C8
            UpdateRegionComboBox.SelectedValue = Client.UpdateRegion;
            switch (Client.UpdateRegion)
            {
            case "PBE":
                RegionComboBox.ItemsSource          = new[] { "PBE" };
                LoginUsernameBox.Visibility         = Visibility.Visible;
                RememberUsernameCheckbox.Visibility = Visibility.Visible;
                break;

            case "Live":
                RegionComboBox.ItemsSource          = new[] { "BR", "EUNE", "EUW", "NA", "OCE", "RU", "LAS", "LAN", "TR", "CS" };
                LoginUsernameBox.Visibility         = Visibility.Visible;
                RememberUsernameCheckbox.Visibility = Visibility.Visible;
                break;

            case "Korea":
                RegionComboBox.ItemsSource          = new[] { "KR" };
                LoginUsernameBox.Visibility         = Visibility.Visible;
                RememberUsernameCheckbox.Visibility = Visibility.Visible;
                LoginPasswordBox.Visibility         = Visibility.Visible;
                break;

            case "Garena":
                RegionComboBox.ItemsSource          = new[] { "PH", "SG", "SGMY", "TH", "TW", "VN", "ID" };
                LoginUsernameBox.Visibility         = Visibility.Hidden;
                RememberUsernameCheckbox.Visibility = Visibility.Hidden;
                LoginPasswordBox.Visibility         = Visibility.Hidden;
                if (!string.IsNullOrEmpty(Settings.Default.DefaultGarenaRegion))
                {
                    RegionComboBox.SelectedValue = Settings.Default.DefaultGarenaRegion;      // Default Garena Region
                }
                break;
            }

            string themeLocation = Path.Combine(Client.ExecutingDirectory, "assets", "themes", Client.Theme);

            if (!Settings.Default.DisableLoginMusic)
            {
                string[] music;
                string   soundpath = Path.Combine(Client.ExecutingDirectory, "Assets", "sounds", "sound_o_heaven.ogg");
                if (DateTime.Now.Month == 4 && DateTime.Now.Day == 1)
                {
                    if (!File.Exists(soundpath))
                    {
                        using (WebClient wc = new WebClient())
                        {
                            wc.DownloadFile("http://images.wikia.com/leagueoflegends/images/1/10/Teemo.laugh3.ogg", soundpath);
                        }
                    }
                    music = new[] { soundpath };
                }
                else
                {
                    music = Directory.GetFiles(themeLocation, "*.mp3");
                }
                SoundPlayer.Source = new System.Uri(Path.Combine(themeLocation, music[0]));
                SoundPlayer.Play();
                Sound.IsChecked = false;
            }
            else
            {
                Sound.IsChecked = true;
            }

            if (DateTime.Now.Month == 4 && DateTime.Now.Day == 1)
            {
                string SkinPath = Path.Combine(Client.ExecutingDirectory, "Assets", "champions",
                                               "Teemo_Splash_" + new Random().Next(0, 8) + ".jpg");
                if (File.Exists(SkinPath))
                {
                    LoginImage.Source = new BitmapImage(new System.Uri(SkinPath, UriKind.Absolute));
                }
            }
            else if (Settings.Default.LoginPageImage == "")
            {
                string[] videos = Directory.GetFiles(themeLocation, "*.mp4");
                if (videos.Length > 0 && File.Exists(videos[0]))
                {
                    LoginPic.Source = new System.Uri(videos[0]);
                }
                LoginPic.LoadedBehavior = MediaState.Manual;
                LoginPic.MediaEnded    += LoginPic_MediaEnded;
                SoundPlayer.MediaEnded += SoundPlayer_MediaEnded;
                LoginPic.Play();
            }
            else
            {
                if (
                    File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "champions",
                                             Settings.Default.LoginPageImage.Replace("\r\n", ""))))
                {
                    LoginImage.Source =
                        new BitmapImage(
                            new System.Uri(
                                Path.Combine(Client.ExecutingDirectory, "Assets", "champions",
                                             Settings.Default.LoginPageImage), UriKind.Absolute));
                }
            }

            Video.IsChecked = false;

            //Get client data after patcher completed

            Client.SQLiteDatabase = new SQLiteConnection(Path.Combine(Client.ExecutingDirectory, Client.sqlite));

            // Check database error
            try
            {
                Client.Champions = (from s in Client.SQLiteDatabase.Table <champions>()
                                    orderby s.name
                                    select s).ToList();

                //* to remove just remove one slash from the comment
                //Pls bard the tard for april fools
                Client.Champions.Find(bard => bard.name == "Bard").displayName = "Tard";
                //*/
            }
            catch (Exception e) // Database broken?
            {
                Client.Log("Database is broken : \r\n" + e.Message + "\r\n" + e.Source);
                var overlay = new MessageOverlay
                {
                    MessageTextBox = { Text = "Database is broken. Click OK to exit LegendaryClient." },
                    MessageTitle   = { Content = "Database Error" }
                };
                Client.SQLiteDatabase.Close();
                File.Delete(Path.Combine(Client.ExecutingDirectory, Client.sqlite));
                overlay.AcceptButton.Click        += (o, i) => { Environment.Exit(0); };
                Client.OverlayContainer.Content    = overlay.Content;
                Client.OverlayContainer.Visibility = Visibility.Visible;
                return;
            }

            var FreeToPlay = FreeToPlayChampions.GetInstance();

            foreach (champions c in Client.Champions)
            {
                var source = new System.Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", c.iconPath),
                                            UriKind.Absolute);
                c.icon = new BitmapImage(source);

                if (FreeToPlay != null)
                {
                    c.IsFreeToPlay = FreeToPlay.IsFreeToPlay(c);
                }
                Champions.InsertExtraChampData(c);
            }

            Client.ChampionSkins = (from s in Client.SQLiteDatabase.Table <championSkins>()
                                    orderby s.name
                                    select s).ToList();
            Client.ChampionAbilities = (from s in Client.SQLiteDatabase.Table <championAbilities>()
                                        orderby s.name
                                        select s).ToList();

            Client.SQLiteDatabase.Close();
            Client.Items     = Items.PopulateItems();
            Client.Masteries = Masteries.PopulateMasteries();
            Client.Runes     = Runes.PopulateRunes();
            BaseUpdateRegion updateRegion = BaseUpdateRegion.GetUpdateRegion(Client.UpdateRegion);
            var patcher = new RiotPatcher();

            if (Client.UpdateRegion != "Garena")
            {
                string tempString = patcher.GetListing(updateRegion.AirListing);

                string[] packages = patcher.GetManifest(
                    updateRegion.AirManifest + "releases/" + tempString + "/packages/files/packagemanifest");
                foreach (
                    string usestring in
                    packages.Select(package => package.Split(',')[0])
                    .Where(usestring => usestring.Contains("ClientLibCommon.dat")))
                {
                    new WebClient().DownloadFile(new System.Uri(updateRegion.BaseLink + usestring),
                                                 Path.Combine(Client.ExecutingDirectory, "ClientLibCommon.dat"));
                }
            }
            var reader = new SWFReader(Path.Combine(Client.ExecutingDirectory, "ClientLibCommon.dat"));

            foreach (var secondSplit in from abcTag in reader.Tags.OfType <DoABC>()
                     where abcTag.Name.Contains("riotgames/platform/gameclient/application/Version")
                     select Encoding.Default.GetString(abcTag.ABCData)
                     into str
                     select str.Split((char)6)
                     into firstSplit

                     select firstSplit[0].Split((char)18))
            {
                if (secondSplit.Count() > 1)
                {
                    Client.Version = secondSplit[1];
                }
                else
                {
                    var thirdSplit = secondSplit[0].Split((char)19);
                    Client.Version = thirdSplit[1];
                }
            }


            Version.Text = Client.Version;

            if (!string.IsNullOrWhiteSpace(Settings.Default.SavedUsername))
            {
                RememberUsernameCheckbox.IsChecked = true;
                LoginUsernameBox.Text = Settings.Default.SavedUsername;
            }
            if (!string.IsNullOrWhiteSpace(Settings.Default.SavedPassword))
            {
                SHA1 sha = new SHA1CryptoServiceProvider();
                RememberPasswordCheckbox.IsChecked = true;
                LoginPasswordBox.Password          =
                    Settings.Default.SavedPassword.DecryptStringAES(
                        sha.ComputeHash(Encoding.UTF8.GetBytes(Settings.Default.Guid)).ToString());
            }
            if (!string.IsNullOrWhiteSpace(Settings.Default.Region))
            {
                RegionComboBox.SelectedValue = Settings.Default.Region;
            }

            invisibleLoginCheckBox.IsChecked = Settings.Default.incognitoLogin;
        }
示例#14
0
        private void PredictedOutputTest(string xmlIn, string swfOut, out Swiffotron swiffotron)
        {
            MockStore store;
            MockCache cache;

            swiffotron = CreateMockSwiffotron(out store, out cache);

            StringBuilder writeLog              = new StringBuilder();
            StringBuilder abcWriteLog           = new StringBuilder();
            Dictionary <string, byte[]> commits = new Dictionary <string, byte[]>();

            swiffotron.Process(ResourceAsStream(xmlIn), commits, writeLog, abcWriteLog, this, this);
            CheckCommits(commits);

            using (FileStream fs = new FileStream(TestDir + xmlIn + ".writelog.txt", FileMode.Create))
            {
                byte[] writeLogData = new ASCIIEncoding().GetBytes(writeLog.ToString());
                fs.Write(writeLogData, 0, writeLogData.Length);
            }

            using (FileStream fs = new FileStream(TestDir + xmlIn + ".abcwritelog.txt", FileMode.Create))
            {
                byte[] writeLogData = new ASCIIEncoding().GetBytes(abcWriteLog.ToString());
                fs.Write(writeLogData, 0, writeLogData.Length);
            }

            CopyStoreToTestDir(store);

            Assert.IsTrue(store.Has(swfOut), @"Output was not saved");

            /* Check that a valid SWF file was produced by reading it back: */
            StringBuilder binDump = new StringBuilder();

            SWF swf = null;

            SWFReader sr = new SWFReader(
                store.OpenInput(swfOut),
                new SWFReaderOptions()
            {
                StrictTagLength = true
            },
                binDump,
                this);     /* constantFilter is a delegate function that will throw an exception
                            * if it spots something objectionable in the SWF's constants. */

            try
            {
                swf = sr.ReadSWF(new SWFContext(swfOut));

                /* The delegate we gave to the SWF reader for trapping ABC constants will
                 * not have been run yet since the SWF reader doesn't parse the ABC unless
                 * it really needs to. Here's how we force it to, and run the filter
                 * delegate... */

                swf.ScriptProc(delegate(DoABC abc)
                {
                    AbcCode code = abc.Code; /* Transparently parses the ABC */
                });
            }
            finally
            {
                using (FileStream fs = new FileStream(TestDir + xmlIn + ".bin.dump.txt", FileMode.Create))
                {
                    byte[] dumpbindata = new ASCIIEncoding().GetBytes(binDump.ToString());
                    fs.Write(dumpbindata, 0, dumpbindata.Length);
                }
            }

            string predicted = TestDir + swfOut + ".model.predict.txt";

            using (Stream input = ResourceAsStream("predicted." + swfOut + ".txt"))
                using (FileStream output = new FileStream(predicted, FileMode.Create))
                {
                    Assert.IsNotNull(input, "Predicted output is missing! " + swfOut);
                    CopyStream(input, output);
                }

            using (StreamWriter acceptScript = new StreamWriter(new FileStream(TestDir + "accept.bat", FileMode.Create)))
            {
                acceptScript.WriteLine("copy \"" + lastCommitModelOutput + "\" \"" + new FileInfo("..\\..\\..\\SwiffotronTest\\res\\predicted\\" + swfOut + ".txt").FullName + "\"");
            }

            using (StreamWriter viewScript = new StreamWriter(new FileStream(TestDir + "viewdiff.bat", FileMode.Create)))
            {
                /* ISSUE 44: This should be a diff tool env var */
                viewScript.WriteLine("\"c:\\Program Files (x86)\\WinMerge\\WinMergeU.exe\" \"" + lastCommitModelOutput + "\" \"" + new FileInfo("..\\..\\..\\SwiffotronTest\\res\\predicted\\" + swfOut + ".txt").FullName + "\"");
            }

            CompareFiles(
                predicted,
                lastCommitModelOutput,
                "Predicted output failure! These files differ: " + swfOut + ".model.predict.txt" + ", " + swfOut + ".model.txt");
        }
示例#15
0
        /// <summary>
        /// Loads a SWF, saves it again and then loads what was saved. The final result is compared with
        /// a predicted output file to make sure it contains what it's supposed to contain.
        /// </summary>
        /// <param name="name">The name of the SWF which is retrieved from the resources folder.</param>
        /// <param name="reAssembleCode">If true, the ABC bytecode will be disassembled and re-assembled
        /// again to test the assembler.</param>
        private void ResaveWithPredictedOutput(string name, bool reAssembleCode)
        {
            StringBuilder binDump = new StringBuilder();
            using (SWFReader sr = new SWFReader(this.ResourceAsStream(name + @".swf"), new SWFReaderOptions() { StrictTagLength = true }, binDump, this))
            {
                SWF swf = null;
                try
                {
                    swf = sr.ReadSWF(new SWFContext(name));
                }
                finally
                {
                    using (FileStream fs = new FileStream(this.TestDir + name + @".bin.dump-1.txt", FileMode.Create))
                    {
                        byte[] dumpbindata = new ASCIIEncoding().GetBytes(binDump.ToString());
                        fs.Write(dumpbindata, 0, dumpbindata.Length);
                    }
                }

                Assert.IsNotNull(swf);

                if (reAssembleCode)
                {
                    swf.MarkCodeAsTampered();
                }

                /* Save it out, then reload it to make sure it can survive intact */
                this.SaveAndVerifyPredictedOutput(swf, name, false);
            }
        }