Esempio n. 1
0
        public bool Uninstall()
        {
            try
            {
                var store = new X509Store(StoreName.Root, StoreLocation.LocalMachine);
                store.Open(OpenFlags.MaxAllowed);
                foreach (var cert in Certificates)
                {
                    if (!store.Certificates.Contains(cert))
                    {
                        continue;
                    }
                    store.Remove(cert);
                }
                store.Close();

                return(true);
            }
            catch (SecurityException se)
            {
                StaticLogger.Warning(se);
            }
            catch (Exception e)
            {
                StaticLogger.Error("Failed to uninstall " + e);
            }

            return(false);
        }
Esempio n. 2
0
        public bool Uninstall()
        {
            try
            {
                var store = new X509Store(StoreName.Root, StoreLocation.LocalMachine);
                store.Open(OpenFlags.MaxAllowed);
                foreach (var cert in Certificates)
                {
                    X509Certificate2 storeCert;
                    while ((storeCert = FindCertificateByCommonName(store.Certificates, cert)) != null)
                    {
                        store.Remove(storeCert);
                    }
                }
                store.Close();

                return(true);
            }
            catch (SecurityException se)
            {
                StaticLogger.Warning(se);
            }
            catch (Exception e)
            {
                StaticLogger.Error("Failed to uninstall " + e);
            }

            return(false);
        }
Esempio n. 3
0
        /// <summary>
        /// Read the next line/object from the stream
        /// </summary>
        /// <returns>Object (FlashObject), Line(string) or Null if the line match failed</returns>
        public object Read()
        {
            var line = Reader.ReadLine();

            if (line == null)
            {
                throw new EndOfStreamException();
            }

            var match = Regex.Match(line, LogMatch);

            if (match.Success)
            {
                try
                {
                    match = Regex.Match(line, ObjectMatch);
                    if (match.Success)
                    {
                        var obj = FlashSerializer.Deserialize(Reader);
                        obj.Name = match.Groups[1].Value;
                        return(obj);
                    }
                    return(line);
                }
                catch (EndOfStreamException)
                {
                    throw; //Pipe was broken, lets rethrow
                }
                catch (Exception ex)
                {
                    StaticLogger.Error(ex);
                }
            }
            return(null);
        }
Esempio n. 4
0
        /// <summary>
        /// Helper method which sets all the properties in the class to their respected FlashObject field.
        /// Use InternalNameAttribute to specify a property which has a FlashObject counter-part.
        /// SetFields does not travel the hierarchy. So Derived types must make their own separate call to SetFields.
        /// </summary>
        /// <param name="obj">Object to change properties</param>
        /// <param name="flash">Flash object to get fields from</param>
        public static void SetFields <T>(T obj, FlashObject flash)
        {
            if (flash == null)
            {
                return;
            }

            foreach (var prop in typeof(T).GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly))
            {
                var intern = prop.GetCustomAttributes(typeof(InternalNameAttribute), false).FirstOrDefault() as InternalNameAttribute;
                if (intern == null)
                {
                    continue;
                }

                object value;
                var    type = prop.PropertyType;

                try
                {
                    if (type == typeof(string))
                    {
                        value = flash[intern.Name].Value;
                    }
                    else if (type == typeof(int))
                    {
                        value = Parse.Int(flash[intern.Name].Value);
                    }
                    else if (type == typeof(long))
                    {
                        value = Parse.Long(flash[intern.Name].Value);
                    }
                    else if (type == typeof(bool))
                    {
                        value = Parse.Bool(flash[intern.Name].Value);
                    }
                    else
                    {
                        try
                        {
                            value = Activator.CreateInstance(type, flash[intern.Name]);
                        }
                        catch (Exception e)
                        {
                            throw new NotSupportedException(string.Format("Type {0} not supported by flash serializer", type.FullName), e);
                        }
                    }
                    prop.SetValue(obj, value, null);
                }
                catch (Exception e)
                {
                    StaticLogger.Error(string.Format("Error parsing {0}#{1}", typeof(T).FullName, prop.Name));
                    StaticLogger.Error(e);
                }
            }
        }
Esempio n. 5
0
        protected virtual void RecvLoop()
        {
            while (RecvThread != null)
            {
                try
                {
                    using (var pipe = new NamedPipeClientStream(PipeName))
                    {
                        using (var reader = new LogReader(pipe))
                        {
                            pipe.Connect(0);

                            IsConnected = pipe.IsConnected;

                            while (pipe.IsConnected)
                            {
                                var obj = reader.Read();
                                if (obj != null)
                                {
                                    if (obj is FlashObject)
                                    {
                                        DoProcessObject((FlashObject)obj);
                                    }
                                    else if (obj is string)
                                    {
                                        DoProcessLine((string)obj);
                                    }
                                }
                            }
                        }
                    }
                }
                catch (IOException)
                {
                    //Pipe was broken, lets start listening again
                }
                catch (TimeoutException)
                {
                }
                catch (Exception ex)
                {
                    StaticLogger.Error(ex);
                }
                finally
                {
                    IsConnected = false;
                }

                Thread.Sleep(500);
            }
        }
Esempio n. 6
0
        private void MainForm_Shown(object sender, EventArgs e)
        {
            SetTitle("(Checking)");
            Task.Factory.StartNew(GetGeneral);
            TrackingQueue.Enqueue("startup");

            Settings_Loaded(this, new EventArgs());
            UpdateIcon();

            //Add this after otherwise it will save immediately due to RegionList.SelectedIndex
            Settings.PropertyChanged += Settings_PropertyChanged;

            //Start after the form is shown otherwise Invokes will fail
            Connection.Start();
            Injector.Start();
            launcher.Start();

            //Fixes the team controls size on start as they keep getting messed up in the WYSIWYG
            MainForm_Resize(this, new EventArgs());

            try
            {
                var filename = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "lolbans", "LoLLoader.dll");
                if (File.Exists(filename))
                {
                    StaticLogger.Info("Uninstalling old loader");

                    var shortfilename = AppInit.GetShortPath(filename);

                    var dlls = AppInit.AppInitDlls32;
                    if (dlls.Contains(shortfilename))
                    {
                        dlls.Remove(AppInit.GetShortPath(shortfilename));
                        AppInit.AppInitDlls32 = dlls;
                    }

                    if (File.Exists(filename))
                    {
                        File.Delete(filename);
                    }
                }
            }
            catch (SecurityException se)
            {
                StaticLogger.Warning(se);
            }
            catch (Exception ex)
            {
                StaticLogger.Error("Failed to uninstall " + ex);
            }
        }
Esempio n. 7
0
 void LogToFile(object obj)
 {
     try
     {
         lock (LogLock)
         {
             File.AppendAllText(LogFile, obj + Environment.NewLine);
         }
     }
     catch (Exception ex)
     {
         StaticLogger.Error(string.Format("[{0}] {1} ({2:MM/dd/yyyy HH:mm:ss.fff})", Levels.Fatal.ToString().ToUpper(), ex.Message, DateTime.UtcNow));
     }
 }
Esempio n. 8
0
        [PostProcessBuild(0)] // First to be called after build.
        public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
        {
            bool buildSuccessful = true;
            // ReSharper disable once PossibleNullReferenceException
            string buildFolder = Directory.GetParent(pathToBuiltProject).FullName;

            if (target == BuildTarget.StandaloneWindows ||
                target == BuildTarget.StandaloneWindows64 ||
                target == BuildTarget.StandaloneLinux64 ||
                target == BuildTarget.StandaloneOSX)
            {
                try
                {
                    CopyConfigFolder(buildFolder);
                }
                catch (Exception e)
                {
                    buildSuccessful = false;
                    StaticLogger.Error("Exception!", e);
                }
            }
            else
            {
                StaticLogger.Info("Target is not standalone, skipping config copy.");
            }

            BuildProcessorHookLibrary hookLibrary = LoadHookLibrary("postprocessing");

            if (hookLibrary != null)
            {
                for (int i = 0; i < hookLibrary.PostProcessorHooks.Length; ++i)
                {
                    if (!hookLibrary.PostProcessorHooks[i].RunHook(pathToBuiltProject))
                    {
                        buildSuccessful = false;
                    }
                }
            }

            if (buildSuccessful)
            {
                StaticLogger.Info("Successfully postprocessed build in " + buildFolder + ".");
            }
            else
            {
                StaticLogger.Error("There was an error postprocessing the build, check the console.");
            }
        }
Esempio n. 9
0
 protected void CheckLoop()
 {
     while (CheckThread != null)
     {
         if (CurrentProcess == null || CurrentProcess.HasExited)
         {
             IsInjected     = false;
             CurrentProcess = Process.GetProcessesByName(ProcessName).FirstOrDefault();
             if (CurrentProcess != null)
             {
                 try
                 {
                     Inject();
                     IsInjected = true;
                 }
                 catch (FileNotFoundException fe)
                 {
                     //LoLClient does not have ws2_32 yet. Lets try again in 1 second.
                     StaticLogger.Trace(fe.Message);
                     CurrentProcess = null;
                     Thread.Sleep(1000);
                     continue;
                 }
                 catch (WarningException we)
                 {
                     IsInjected = true;
                     StaticLogger.Info(we.Message);
                 }
                 catch (NotSupportedException nse)
                 {
                     StaticLogger.Warning(nse);
                 }
                 catch (Exception ex)
                 {
                     StaticLogger.Error(new Exception(string.Format("{0} [{1}]", ex.Message, From), ex));
                 }
             }
         }
         Thread.Sleep(500);
     }
 }
Esempio n. 10
0
        protected virtual void OnAccept(IAsyncResult ar)
        {
            ProxyClient client = null;

            try
            {
                if (!IsListening)
                {
                    return;
                }

                client = NewClient(Listener.EndAcceptTcpClient(ar));
                Listener.BeginAcceptTcpClient(OnAccept, null);

                lock (Clients)
                    Clients.Add(client);

                client.Start(RemoteAddress, RemotePort);

                if (client.SourceTcp.Client != null)
                {
                    StaticLogger.Info(string.Format("Client {0} connected", client.SourceTcp.Client.RemoteEndPoint));
                }
            }
            catch (Exception ex)
            {
                if (client != null)
                {
                    OnException(client, ex);
                }
                else
                {
                    //Ignore objectdisposed, happens when stopping
                    if (!(ex is ObjectDisposedException))
                    {
                        StaticLogger.Error(ex);
                    }
                }
            }
        }
Esempio n. 11
0
        void SetChanges(JObject data)
        {
            if (data == null)
            {
                return;
            }
            try
            {
                ChangesText.Text = "";

                foreach (var kv in data)
                {
                    ChangesText.SelectionFont = new Font(ChangesText.Font.FontFamily, ChangesText.Font.SizeInPoints, FontStyle.Bold);
                    ChangesText.AppendText(kv.Key);
                    ChangesText.AppendText(Environment.NewLine);
                    ChangesText.SelectionFont = new Font(ChangesText.Font.FontFamily, ChangesText.Font.SizeInPoints, ChangesText.Font.Style);
                    if (kv.Value is JArray)
                    {
                        var list = kv.Value as JArray;
                        foreach (var item in list)
                        {
                            ChangesText.AppendText(item.ToString());
                            ChangesText.AppendText(Environment.NewLine);
                        }
                    }
                    else
                    {
                        ChangesText.AppendText(kv.Value.ToString());
                        ChangesText.AppendText(Environment.NewLine);
                    }
                }
            }
            catch (Exception e)
            {
                StaticLogger.Error(e);
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Helper method which sets all the properties in the class to their respected FlashObject field.
        /// Use InternalNameAttribute to specify a property which has a FlashObject counter-part.
        /// SetFields does not travel the hierarchy. So Derived types must make their own separate call to SetFields.
        /// </summary>
        /// <param name="obj">Object to change properties</param>
        /// <param name="flash">Flash object to get fields from</param>
        public static void SetFields <T>(T obj, ASObject flash)
        {
            if (flash == null)
            {
                return;
            }

            foreach (var prop in typeof(T).GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly))
            {
                var intern = prop.GetAttribute <InternalNameAttribute>();
                if (intern == null)
                {
                    continue;
                }

                var    type = prop.PropertyType;
                object value;

                if (!flash.TryGetValue(intern.Name, out value))
                {
                    StaticLogger.Warning(string.Format("{0} missing ASObject property {1}", typeof(T).FullName, intern.Name));
                    continue;
                }

                try
                {
                    if (type == typeof(string))
                    {
                        value = Convert.ToString(flash[intern.Name]);
                    }
                    else if (type == typeof(Int32))
                    {
                        value = Convert.ToInt32(flash[intern.Name]);
                    }
                    else if (type == typeof(Int64))
                    {
                        value = Convert.ToInt64(flash[intern.Name]);
                    }
                    else if (type == typeof(double))
                    {
                        value = Convert.ToInt64(flash[intern.Name]);
                    }
                    else if (type == typeof(bool))
                    {
                        value = Convert.ToBoolean(flash[intern.Name]);
                    }
                    else if (type == typeof(DateTime))
                    {
                        value = Convert.ToDateTime(flash[intern.Name]);
                    }
                    else if (type == typeof(ASObject))
                    {
                        value = flash[intern.Name] as ASObject;
                    }
                    else if (type == typeof(ArrayCollection))
                    {
                        value = flash[intern.Name] as ArrayCollection;
                    }
                    else if (type == typeof(object))
                    {
                        value = flash[intern.Name];
                    }
                    else
                    {
                        try
                        {
                            value = Activator.CreateInstance(type, flash[intern.Name]);
                        }
                        catch (Exception e)
                        {
                            throw new NotSupportedException(string.Format("Type {0} not supported by flash serializer", type.FullName), e);
                        }
                    }
                    prop.SetValue(obj, value, null);
                }
                catch (Exception e)
                {
                    StaticLogger.Error(new Exception(string.Format("Error parsing {0}#{1}", typeof(T).FullName, prop.Name), e));
                }
            }
        }
Esempio n. 13
0
        private void MainForm_Shown(object sender, EventArgs e)
        {
            TrackingQueue.Enqueue("startup");

            Settings_Loaded(this, new EventArgs());
            UpdateStatus();

            //Add this after otherwise it will save immediately due to RegionList.SelectedIndex
            Settings.PropertyChanged += Settings_PropertyChanged;

            Settings.ModuleResolver = "Toolhelp32Snapshot";

            VersionLabel.Text = "v" + Version;

            //Start after the form is shown otherwise Invokes will fail
            Connection.Start();
            Injector.Start();
            launcher.Start();

            //Fixes the team controls size on start as they keep getting messed up in the WYSIWYG
            MainForm_Resize(this, new EventArgs());

            try
            {
                RegistryKey installed_versions = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP");
                string[]    version_names      = installed_versions.GetSubKeyNames();
                //version names start with 'v', eg, 'v3.5' which needs to be trimmed off before conversion
                double framework = Convert.ToDouble(version_names[version_names.Length - 1].Remove(0, 1), CultureInfo.InvariantCulture);

                if (framework < 4.0)
                {
                    if (MessageBox.Show("The Elophant Client requires the .NET Framework 4.0 Full version. Would you like to download it?", ".NET Framework 4.0 Full Not Found", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        Process.Start("http://www.microsoft.com/en-us/download/details.aspx?id=17718");
                    }

                    MessageBox.Show("The Elophant Client will now close.");
                    Process.GetCurrentProcess().Kill();
                    return;
                }
            }
            catch (Exception ex)
            {
                StaticLogger.Error(ex.ToString());
                MessageBox.Show("An unknown exception has occurred. Check the log for more information.");
                Process.GetCurrentProcess().Kill();
                return;
            }

            try
            {
                var filename = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "lolbans", "LoLLoader.dll");
                if (File.Exists(filename))
                {
                    StaticLogger.Info("Uninstalling old loader.");

                    var shortfilename = AppInit.GetShortPath(filename);

                    var dlls = AppInit.AppInitDlls32;
                    if (dlls.Contains(shortfilename))
                    {
                        dlls.Remove(AppInit.GetShortPath(shortfilename));
                        AppInit.AppInitDlls32 = dlls;
                    }

                    if (File.Exists(filename))
                    {
                        File.Delete(filename);
                    }
                }
            }
            catch (SecurityException se)
            {
                StaticLogger.Warning(se);
            }
            catch (Exception ex)
            {
                StaticLogger.Error("Failed to uninstall. Message: " + ex);
            }

            // NOT SURE IF THIS WORKS - TRYING TO AVOID THE USE OF AN INSTALL BUTTON
            try
            {
                if (!Installer.IsInstalled)
                {
                    if (!Wow.IsAdministrator)
                    {
                        MessageBox.Show("Please run the Elophant Client as the Administrator to install it.");
                        Process.GetCurrentProcess().Kill();
                        return;
                    }
                    try
                    {
                        Installer.Install();
                    }
                    catch (UnauthorizedAccessException uaex)
                    {
                        MessageBox.Show("Unable to fully install/uninstall. Make sure LoL is not running.");
                        StaticLogger.Warning(uaex);
                    }
                    //InstallButton.Text = Installer.IsInstalled ? "Uninstall" : "Install";
                    UpdateStatus();
                }
            }
            catch
            {
            }

            TryToCheckForUpdates();
        }
Esempio n. 14
0
        protected void CheckLoop()
        {
            bool showedError = false;

            while (CheckThread != null)
            {
                if (CurrentProcess != null)
                {
                    try
                    {
                        if (CurrentProcess.HasExited)
                        {
                            CurrentProcess = null;
                            IsInjected     = false;                         // update icon
                        }
                    }
                    catch (Exception ex)
                    {
                        if (!showedError)
                        {
                            ErrorMessage = "Privilege of LoLNotes must be greater or equal to that of the LoLClient.\n\nSituations where LoLClient is run as admin and LoLNotes is not are no good.";
                            showedError  = true;
                        }
                        StaticLogger.Error(ex);
                        CurrentProcess = null;
                        IsInjected     = false;                     // update icon
                    }
                }

                if (CurrentProcess == null)
                {
                    CurrentProcess = Process.GetProcessesByName(ProcessName).FirstOrDefault();
                    if (CurrentProcess != null)
                    {
                        try
                        {
                            Inject();
                            IsInjected = true;
                        }
                        catch (FileNotFoundException fe)
                        {
                            //LoLClient does not have ws2_32 yet. Lets try again in 1 second.
                            StaticLogger.Trace(fe.Message);
                            CurrentProcess = null;
                            Thread.Sleep(1000);
                            continue;
                        }
                        catch (WarningException we)
                        {
                            IsInjected = true;
                            StaticLogger.Info(we.Message);
                        }
                        catch (NotSupportedException nse)
                        {
                            StaticLogger.Warning(nse);
                        }
                        catch (Exception ex)
                        {
                            StaticLogger.Error(new Exception(string.Format("{0} [{1}]", ex.Message, From), ex));
                        }
                    }
                }
                Thread.Sleep(500);
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Replaces the invokeid
        /// </summary>
        /// <param name="notify"></param>
        protected void InternalReceive(Notify notify)
        {
            if (RtmpUtil.IsResult(notify))
            {
                int ourid = notify.InvokeId;

                CallResultWait callresult = null;
                lock (WaitLock)
                {
                    if (WaitInvokeList != null)
                    {
                        int idx = WaitInvokeList.FindIndex(crw => crw.Call.InvokeId == ourid);
                        if (idx != -1)
                        {
                            callresult = WaitInvokeList[idx];
                            WaitInvokeList.RemoveAt(idx);
                        }
                    }
                }

                //InvokeId was found in the waitlist, that means its one of our calls.
                if (callresult != null)
                {
                    callresult.Result = notify;
                    callresult.Wait.Set();

                    //Not blocking, lets send it to the handler instead.
                    if (!callresult.Blocking)
                    {
                        OnCall(callresult.Call, callresult.Result);
                    }

                    return;                     //Return, we don't want LoL receiving the message.
                }

                int theirid;
                lock (InvokeIds)
                {
                    if (!InvokeIds.TryGetValue(ourid, out theirid))
                    {
                        StaticLogger.Error(string.Format("Call id not found for {0}", notify));
                        return;
                    }
                    InvokeIds.Remove(ourid);
                }
                notify.InvokeId = theirid;
            }

            var buf = RtmpProtocolEncoder.Encode(remotecontext, CreatePacket(notify));

            if (buf == null)
            {
                StaticLogger.Fatal("Unable to encode " + notify);
            }
            else
            {
                var buff = buf.ToArray();
                if (logtofiles)
                {
                    using (var fs = File.Open("recv.dmp", FileMode.Append, FileAccess.Write))
                    {
                        fs.Write(buff, 0, buff.Length);
                    }
                }
                if (encode)
                {
                    base.OnReceive(buff, 0, buff.Length);
                }
            }
        }
Esempio n. 16
0
        void launcher_ProcessFound(object sender, ProcessMonitor.ProcessEventArgs e)
        {
            try
            {
                if (!Settings.DeleteLeaveBuster)
                {
                    return;
                }

                var dir = Path.GetDirectoryName(e.Process.MainModule.FileName);
                if (dir == null)
                {
                    StaticLogger.Warning("Launcher module not found");
                    return;
                }

                var needle = "\\RADS\\";
                var i      = dir.LastIndexOf(needle, StringComparison.InvariantCulture);
                if (i == -1)
                {
                    StaticLogger.Warning("Launcher Rads not found");
                    return;
                }

                dir = dir.Remove(i + needle.Length);
                dir = Path.Combine(dir, "projects\\lol_air_client\\releases");

                if (!Directory.Exists(dir))
                {
                    StaticLogger.Warning("lol_air_client directory not found");
                    return;
                }

                foreach (var ver in new DirectoryInfo(dir).GetDirectories())
                {
                    var filename = Path.Combine(ver.FullName, "deploy\\preferences\\global\\global.properties");
                    if (!File.Exists(filename))
                    {
                        StaticLogger.Warning(filename + " not found");
                        continue;
                    }

                    ASObject obj = null;
                    using (var amf = new AMFReader(File.OpenRead(filename)))
                    {
                        try
                        {
                            obj = amf.ReadAMF3Data() as ASObject;
                            if (obj == null)
                            {
                                StaticLogger.Warning("Failed to read " + filename);
                                continue;
                            }
                        }
                        catch (Exception ex)
                        {
                            StaticLogger.Warning("LeaverBuster: Unable to read global.properties '" + filename + "'");
                            continue;
                        }
                    }
                    object leaver;
                    object locale;
                    if ((obj.TryGetValue("leaverData", out leaver) && leaver != null) ||
                        (obj.TryGetValue("localeData", out locale) && locale != null))
                    {
                        obj["leaverData"] = null;
                        obj["localeData"] = null;
                        using (var amf = new AMFWriter(File.Open(filename, FileMode.Create, FileAccess.Write)))
                        {
                            try
                            {
                                amf.WriteAMF3Data(obj);
                                StaticLogger.Info("Removed leaverData/localeData from global.properties");
                            }
                            catch (Exception ex)
                            {
                                StaticLogger.Warning("LeaverBuster: Unable to write global.properties '" + filename + "'");
                                continue;
                            }
                        }
                    }
                    else
                    {
                        StaticLogger.Info("leaverData/localeData already removed from global.properties");
                    }
                }
            }
            catch (Exception ex)
            {
                StaticLogger.Error(ex);
            }
        }