Exemplo n.º 1
0
        private void OnChanged(object source, FileSystemEventArgs e)
        {
            //Only override if it's lol_air_client (this allows patching while Poro is running)
            if (!e.FullPath.Contains("lol_air_client"))
            {
                return;
            }

            _internalCounter += 1;

            if (_internalCounter == 3)
            {
                Console.WriteLine(string.Format("[LOG] LoLPatcher detected, server redirected to {0}", _settings.RTMPSHost));

                _internalCounter = 0;

                PoroProperties properties = new PoroProperties();
                properties.host = _settings.RTMPSHost;

                BindingFlags   bindingFlags       = BindingFlags.Public | BindingFlags.Instance;
                PropertyInfo[] members            = typeof(PoroProperties).GetProperties(bindingFlags).ToArray();
                List <string>  modifiedProperties = new List <string>();
                foreach (var x in members)
                {
                    modifiedProperties.Add(string.Format("{0}={1}", x.Name, x.GetValue(properties)));
                }

                //Override property file
                File.Delete(e.FullPath);
                File.WriteAllLines(e.FullPath, modifiedProperties.ToArray());
            }
        }
Exemplo n.º 2
0
        private void OnChanged(object source, FileSystemEventArgs e)
        {
            //Only override if it's lol_air_client (this allows patching while Poro is running)
            if (!e.FullPath.Contains("lol_air_client"))
            {
                return;
            }

            var diffInSeconds = (DateTime.Now - _lastWrite).TotalSeconds;

            //Only overwrite once every 5 seconds. This stops Poro from detecting itself and going into an infinite loop
            if (diffInSeconds < 5)
            {
                return;
            }

            Console.WriteLine(string.Format("[LOG] LoLPatcher detected, server redirected to {0}", _settings.RTMPSHost));

            //Generate the properties according to the current client's IP address
            PoroProperties properties = new PoroProperties();

            properties.host            = _settings.RTMPSHost;
            properties.xmpp_server_url = _settings.RTMPSHost;
            //properties.host = "prod.oc1.lol.riotgames.com"; //Uncomment for LoLNotes

            BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.Instance;

            PropertyInfo[] members            = typeof(PoroProperties).GetProperties(bindingFlags).ToArray();
            List <string>  modifiedProperties = new List <string>();

            foreach (var x in members)
            {
                modifiedProperties.Add(string.Format("{0}={1}", x.Name, x.GetValue(properties)));
            }

            //Wait for the file to be writeable
            FileStream fileWait = WaitForFile(e.FullPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);

            fileWait.Close();

            //Set the last write time of the properties to now
            _lastWrite = DateTime.Now;

            //Override property file
            File.Delete(e.FullPath);
            File.WriteAllLines(e.FullPath, modifiedProperties.ToArray());

            PoroServer.ClientLocation = e.FullPath.Replace("lol.properties", "");

            if (PatcherFound != null)
            {
                PatcherFound();
            }
        }