Exemplo n.º 1
0
        public static void HandleUrl(string url, MetroWindow window)
        {
            url = WebUtility.UrlDecode(url.Remove(0, FullName.Length));

            var r = Regex.Matches(url, "(project|projectGroup)/([^/]*)/([^/]*)/([^/]*)/?");

            foreach (Match m in r)
            {
                var linkType = m.Groups[1].ToString();

                switch (linkType)
                {
                case "project":
                    var gitHubUser     = m.Groups[2].ToString();
                    var repositoryName = m.Groups[3].ToString();
                    var assemblyName   = m.Groups[4].ToString();

                    var w = new InstallerWindow {
                        Owner = window
                    };
                    w.ListAssemblies(
                        string.Format("https://github.com/{0}/{1}", gitHubUser, repositoryName), true,
                        assemblyName != "" ? m.Groups[4].ToString() : null);
                    w.ShowDialog();
                    break;

                case "projectGroup":

                    var remaining  = url.Remove(0, 13);
                    var assemblies = new List <LeagueSharpAssembly>();

                    while (remaining.IndexOf("/", StringComparison.InvariantCulture) != -1)
                    {
                        var data = remaining.Split(new[] { '/' });
                        if (data.Length < 3)
                        {
                            break;
                        }

                        var assembly = new LeagueSharpAssembly(data[2], "",
                                                               string.Format("https://github.com/{0}/{1}", data[0], data[1]));
                        assemblies.Add(assembly);
                        for (int i = 0; i < 3; i++)
                        {
                            remaining = remaining.Remove(0, remaining.IndexOf("/", StringComparison.InvariantCulture) + 1);
                        }
                    }

                    if (assemblies.Count > 0)
                    {
                        assemblies.ForEach(
                            assembly => Config.Instance.SelectedProfile.InstalledAssemblies.Add(assembly));
                        ((MainWindow)window).PrepareAssemblies(assemblies, true, true, false);
                        ((MainWindow)window).ShowTextMessage(Utility.GetMultiLanguageText("Installer"),
                                                             Utility.GetMultiLanguageText("SuccessfullyInstalled"));
                    }
                    break;
                }
            }
        }
        public static List<LeagueSharpAssembly> GetAssemblies(string directory, string url = "")
        {
            var projectFiles = new List<string>();
            var foundAssemblies = new List<LeagueSharpAssembly>();

            try
            {
                projectFiles.AddRange(Directory.GetFiles(directory, "*.csproj", SearchOption.AllDirectories));
                foreach (var projectFile in projectFiles)
                {
                    var name = Path.GetFileNameWithoutExtension(projectFile);
                    var assembly = new LeagueSharpAssembly(name, projectFile, url);

                    if (!string.IsNullOrEmpty(url))
                    {
                        var entry = Config.Instance.DatabaseAssemblies?.FirstOrDefault(a => a.Name == name)
                                    ?? Config.Instance.DatabaseAssemblies?.FirstOrDefault(a => Path.GetFileNameWithoutExtension(a.GithubUrl) == name);

                        if (entry != null)
                        {
                            assembly.Description = entry.Description;
                            assembly.DisplayName = entry.Name;
                        }
                    }

                    foundAssemblies.Add(assembly);
                }
            }
            catch (Exception e)
            {
                Utility.Log(LogStatus.Error, "Updater", e.ToString(), Logs.MainLog);
            }

            return foundAssemblies;
        }
        public static List <LeagueSharpAssembly> GetAssemblies(string directory, string url = "")
        {
            var projectFiles    = new List <string>();
            var foundAssemblies = new List <LeagueSharpAssembly>();

            try
            {
                projectFiles.AddRange(Directory.GetFiles(directory, "*.csproj", SearchOption.AllDirectories));
                foreach (var projectFile in projectFiles)
                {
                    var name     = Path.GetFileNameWithoutExtension(projectFile);
                    var assembly = new LeagueSharpAssembly(name, projectFile, url);

                    if (!string.IsNullOrEmpty(url))
                    {
                        var entry = Config.Instance.DatabaseAssemblies?.FirstOrDefault(a => a.Name == name)
                                    ?? Config.Instance.DatabaseAssemblies?.FirstOrDefault(a => Path.GetFileNameWithoutExtension(a.GithubUrl) == name);

                        if (entry != null)
                        {
                            assembly.Description = entry.Description;
                            assembly.DisplayName = entry.Name;
                        }
                    }

                    foundAssemblies.Add(assembly);
                }
            }
            catch (Exception e)
            {
                Utility.Log(LogStatus.Error, "Updater", e.ToString(), Logs.MainLog);
            }

            return(foundAssemblies);
        }
        public static void HandleUrl(string url, MetroWindow window)
        {
            url = WebUtility.UrlDecode(url.Remove(0, FullName.Length));

            var r = Regex.Matches(url, "(project|projectGroup)/([^/]*)/([^/]*)/([^/]*)/?");
            foreach (Match m in r)
            {
                var linkType = m.Groups[1].ToString();
              
                switch (linkType)
                {
                    case "project":
                        var gitHubUser = m.Groups[2].ToString();
                        var repositoryName = m.Groups[3].ToString();
                        var assemblyName = m.Groups[4].ToString();

                        var w = new InstallerWindow { Owner = window };
                        w.ListAssemblies(
                            string.Format("https://github.com/{0}/{1}", gitHubUser, repositoryName), true,
                            assemblyName != "" ? m.Groups[4].ToString() : null);
                        w.ShowDialog();
                        break;

                    case "projectGroup":
                        
                        var remaining = url.Remove(0, 13);
                        var assemblies = new List<LeagueSharpAssembly>();

                        while (remaining.IndexOf("/", StringComparison.InvariantCulture) != -1)
                        {
                            var data = remaining.Split(new[] {'/'});
                            if (data.Length < 3)
                            {
                                break;
                            }
                            
                            var assembly = new LeagueSharpAssembly(data[2], "", 
                                string.Format("https://github.com/{0}/{1}", data[0], data[1]));
                            assemblies.Add(assembly);
                            for (int i = 0; i < 3; i++)
                            {
                                remaining = remaining.Remove(0, remaining.IndexOf("/", StringComparison.InvariantCulture) + 1);
                            }
                        }

                        if (assemblies.Count > 0)
                        {
                            assemblies.ForEach(
                                assembly => Config.Instance.SelectedProfile.InstalledAssemblies.Add(assembly));
                            ((MainWindow) window).PrepareAssemblies(assemblies, true, true, false);
                            ((MainWindow) window).ShowTextMessage(Utility.GetMultiLanguageText("Installer"),
                                Utility.GetMultiLanguageText("SuccessfullyInstalled"));
                        }
                        break;
                }
            }
        }
Exemplo n.º 5
0
 public static void UnloadAssembly(IntPtr wnd, LeagueSharpAssembly assembly)
 {
     if (assembly.Type != AssemblyType.Library && assembly.Status == AssemblyStatus.Ready)
     {
         var str    = string.Format("unload \"{0}\"", Path.GetFileName(assembly.PathToBinary));
         var lParam = new COPYDATASTRUCT {
             cbData = 1, dwData = str.Length * 2 + 2, lpData = str
         };
         SendMessage(wnd, 74U, IntPtr.Zero, ref lParam);
     }
 }
Exemplo n.º 6
0
 public static void LoadAssembly(IntPtr wnd, LeagueSharpAssembly assembly)
 {
     if (assembly.Type == AssemblyType.Executable && assembly.Status == AssemblyStatus.Ready)
     {
         var str    = string.Format("load \"{0}\"", assembly.PathToBinary);
         var lParam = new COPYDATASTRUCT {
             cbData = 1, dwData = str.Length * 2 + 2, lpData = str
         };
         SendMessage(wnd, 74U, IntPtr.Zero, ref lParam);
     }
 }
        public static LeagueSharpAssembly GetAssembly(string projectFile, string url = "")
        {
            LeagueSharpAssembly foundAssembly = null;
            try
            {
                    var name = Path.GetFileNameWithoutExtension(projectFile);
                    foundAssembly = new LeagueSharpAssembly(name, projectFile, url);
            }
            catch (Exception e)
            {
                Utility.Log(LogStatus.Error, "Updater GetAssembly", e.ToString(), Logs.MainLog);
            }

            return foundAssembly;
        }
Exemplo n.º 8
0
        public static LeagueSharpAssembly GetAssembly(string projectFile, string url = "")
        {
            LeagueSharpAssembly foundAssembly = null;

            try
            {
                var name = Path.GetFileNameWithoutExtension(projectFile);
                foundAssembly = new LeagueSharpAssembly(name, projectFile, url);
            }
            catch (Exception e)
            {
                Utility.Log(LogStatus.Error, "Updater GetAssembly", e.ToString(), Logs.MainLog);
            }

            return(foundAssembly);
        }
Exemplo n.º 9
0
        public static List <LeagueSharpAssembly> GetAssemblies(string directory, string url = "")
        {
            var projectFiles    = new List <string>();
            var foundAssemblies = new List <LeagueSharpAssembly>();

            try
            {
                projectFiles.AddRange(Directory.GetFiles(directory, "*.csproj", SearchOption.AllDirectories));
                foreach (var projectFile in projectFiles)
                {
                    var name     = Path.GetFileNameWithoutExtension(projectFile);
                    var assembly = new LeagueSharpAssembly(name, projectFile, url);

                    if (!string.IsNullOrEmpty(url))
                    {
                        var entry = Config.Instance.DatabaseAssemblies?.FirstOrDefault(a => a.GithubUrl.Contains(url) && a.Name == name)
                                    ?? Config.Instance.DatabaseAssemblies?.FirstOrDefault(
                            a => a.GithubUrl.Contains(url) && Path.GetFileNameWithoutExtension(a.GithubUrl) == name);

                        if (entry != null)
                        {
                            assembly.Author      = entry.AuthorName;
                            assembly.Description = entry.Description;
                            assembly.DisplayName = entry.Name;
                        }
                        else
                        {
                            var repositoryMatch = Regex.Match(url, @"^(http[s]?)://(?<host>.*?)/(?<author>.*?)/(?<repo>.*?)(/{1}|$)");
                            if (repositoryMatch.Success)
                            {
                                assembly.Author = repositoryMatch.Groups["author"].Value;
                            }
                        }
                    }

                    foundAssemblies.Add(assembly);
                }
            }
            catch (Exception e)
            {
                Utility.Log(LogStatus.Error, e.Message);
            }

            return(foundAssemblies);
        }
Exemplo n.º 10
0
 private void CloneItem_OnClick(object sender, RoutedEventArgs e)
 {
     if (InstalledAssembliesDataGrid.SelectedItems.Count <= 0)
     {
         return;
     }
     var selectedAssembly = (LeagueSharpAssembly)InstalledAssembliesDataGrid.SelectedItems[0];
     try
     {
         var source = Path.GetDirectoryName(selectedAssembly.PathToProjectFile);
         var destination = Path.Combine(Directories.LocalRepoDir, selectedAssembly.Name) + "_clone_" +
                           Environment.TickCount.GetHashCode().ToString("X");
         Utility.CopyDirectory(source, destination);
         var leagueSharpAssembly = new LeagueSharpAssembly(
             selectedAssembly.Name + "_clone",
             Path.Combine(destination, Path.GetFileName(selectedAssembly.PathToProjectFile)), "");
         leagueSharpAssembly.Compile();
         Config.SelectedProfile.InstalledAssemblies.Add(leagueSharpAssembly);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Exemplo n.º 11
0
        protected override void OnStartup(StartupEventArgs e)
        {
            if (File.Exists(Updater.SetupFile))
            {
                Thread.Sleep(1000);
            }

            bool createdNew;
            _mutex = new Mutex(true, Utility.Md5Hash(Environment.UserName), out createdNew);

            Utility.CreateFileFromResource(Directories.ConfigFilePath, "LeagueSharp.Loader.Resources.config.xml");

            var configCorrupted = false;
            try
            {
                Config.Instance = ((Config) Utility.MapXmlFileToClass(typeof(Config), Directories.ConfigFilePath));
            }
            catch (Exception)
            {
                configCorrupted = true;
            }

            if (!configCorrupted)
            {
                try
                {
                    if (File.Exists(Directories.ConfigFilePath + ".bak"))
                    {
                        File.Delete(Directories.ConfigFilePath + ".bak");
                    }
                    File.Copy(Directories.ConfigFilePath, Directories.ConfigFilePath + ".bak");
                    File.SetAttributes(Directories.ConfigFilePath + ".bak", FileAttributes.Hidden);
                }
                catch (Exception)
                {
                    //ignore
                }
            }
            else
            {
                try
                {
                    Config.Instance = ((Config)Utility.MapXmlFileToClass(typeof(Config), Directories.ConfigFilePath + ".bak"));
                    File.Delete(Directories.ConfigFilePath);
                    File.Copy(Directories.ConfigFilePath + ".bak", Directories.ConfigFilePath);
                    File.SetAttributes(Directories.ConfigFilePath, FileAttributes.Normal);
                }
                catch (Exception)
                {
                    File.Delete(Directories.ConfigFilePath + ".bak");
                    File.Delete(Directories.ConfigFilePath);
                    MessageBox.Show("Couldn't load config.xml.");
                    Environment.Exit(0);
                }
            }

            #region Add GameSetting DisableDrawings

            if (Config.Instance.Settings.GameSettings.All(x => x.Name != "Show Drawings"))
            {
                Config.Instance.Settings.GameSettings.Add(new GameSettings
                {
                    Name = "Show Drawings",
                    PosibleValues = new List<string> { "True", "False" },
                    SelectedValue = "True"
                });
            }

            if (Config.Instance.Settings.GameSettings.All(x => x.Name != "Show Ping"))
            {
                Config.Instance.Settings.GameSettings.Add(new GameSettings
                {
                    Name = "Show Ping",
                    PosibleValues = new List<string> { "True", "False" },
                    SelectedValue = "True"
                });
            }

            if (Config.Instance.Settings.GameSettings.All(x => x.Name != "Send Anonymous Assembly Statistics"))
            {
                Config.Instance.Settings.GameSettings.Add(new GameSettings
                {
                    Name = "Send Anonymous Assembly Statistics",
                    PosibleValues = new List<string> { "True", "False" },
                    SelectedValue = "True"
                });
            }

            if (Config.Instance.Settings.GameSettings.All(x => x.Name != "Always Inject Default Profile"))
            {
                Config.Instance.Settings.GameSettings.Add(new GameSettings
                {
                    Name = "Always Inject Default Profile",
                    PosibleValues = new List<string> { "True", "False" },
                    SelectedValue = "False"
                });
            }

            try
            {
                if (Config.Instance.Profiles.First().InstalledAssemblies.All(a => a.Name != "LeagueSharp.SDK"))
                {
                    var sdk = new LeagueSharpAssembly
                    {
                        Name = "LeagueSharp.SDK",
                        DisplayName = "LeagueSharp.SDK",
                        SvnUrl = "https://github.com/LeagueSharp/LeagueSharp.SDK",
                        InjectChecked = true,
                        InstallChecked = true,
                        PathToProjectFile = Path.Combine(Directories.RepositoryDir, "8443D874", "trunk", "LeagueSharp.SDK.csproj")
                    };

                    sdk.Update();
                    sdk.Compile();

                    Config.Instance.Profiles.First().InstalledAssemblies.Add(sdk);
                }
            }
            catch
            {
                // wtf
            }

            #endregion

            #region Remove the old loader

            try
            {
                if (String.Compare(
                   Process.GetCurrentProcess().ProcessName, "LeagueSharp.Loader.exe",
                   StringComparison.InvariantCultureIgnoreCase) != 0 && File.Exists(Path.Combine(Directories.CurrentDirectory, "LeagueSharp.Loader.exe")))
                {
                    File.Delete(Path.Combine(Directories.CurrentDirectory, "LeagueSharp.Loader.exe"));
                    File.Delete(Path.Combine(Directories.CurrentDirectory, "LeagueSharp.Loader.exe.config"));
                }
            }
            catch (Exception ex)
            {
                //ignore
            }

            #endregion

            #region AppData randomization

            try
            {
                if (!Directory.Exists(Directories.AppDataDirectory))
                {
                    Directory.CreateDirectory(Directories.AppDataDirectory);

                    var oldPath = Path.Combine(Environment.GetFolderPath(
                    Environment.SpecialFolder.ApplicationData), "LeagueSharp" + Environment.UserName.GetHashCode().ToString("X"));

                    var oldPath2 = Path.Combine(Environment.GetFolderPath(
                        Environment.SpecialFolder.ApplicationData), "LeagueSharp");

                    if (Directory.Exists(oldPath))
                    {
                        Utility.CopyDirectory(oldPath, Directories.AppDataDirectory, true, true);
                        Utility.ClearDirectory(oldPath);
                        Directory.Delete(oldPath, true);
                    }

                    if (Directory.Exists(oldPath2))
                    {
                        Utility.CopyDirectory(oldPath2, Directories.AppDataDirectory, true, true);
                        Utility.ClearDirectory(oldPath2);
                        Directory.Delete(oldPath2, true);
                    }
                }
            }
            catch (Exception ex)
            {
                //ignore
            }

            #endregion

            //Load the language resources.
            var dict = new ResourceDictionary();

            if (Config.Instance.SelectedLanguage != null)
            {
                dict.Source = new Uri(
                    "..\\Resources\\Language\\" + Config.Instance.SelectedLanguage + ".xaml", UriKind.Relative);
            }
            else
            {
                var lid = Thread.CurrentThread.CurrentCulture.ToString().Contains("-")
                    ? Thread.CurrentThread.CurrentCulture.ToString().Split('-')[0].ToUpperInvariant()
                    : Thread.CurrentThread.CurrentCulture.ToString().ToUpperInvariant();
                switch (lid)
                {
                    case "DE":
                        dict.Source = new Uri("..\\Resources\\Language\\German.xaml", UriKind.Relative);
                        break;
                    case "AR":
                        dict.Source = new Uri("..\\Resources\\Language\\Arabic.xaml", UriKind.Relative);
                        break;
                    case "ES":
                        dict.Source = new Uri("..\\Resources\\Language\\Spanish.xaml", UriKind.Relative);
                        break;
                    case "FR":
                        dict.Source = new Uri("..\\Resources\\Language\\French.xaml", UriKind.Relative);
                        break;
                    case "IT":
                        dict.Source = new Uri("..\\Resources\\Language\\Italian.xaml", UriKind.Relative);
                        break;
                    case "KO":
                        dict.Source = new Uri("..\\Resources\\Language\\Korean.xaml", UriKind.Relative);
                        break;
                    case "NL":
                        dict.Source = new Uri("..\\Resources\\Language\\Dutch.xaml", UriKind.Relative);
                        break;
                    case "PL":
                        dict.Source = new Uri("..\\Resources\\Language\\Polish.xaml", UriKind.Relative);
                        break;
                    case "PT":
                        dict.Source = new Uri("..\\Resources\\Language\\Portuguese.xaml", UriKind.Relative);
                        break;
                    case "RO":
                        dict.Source = new Uri("..\\Resources\\Language\\Romanian.xaml", UriKind.Relative);
                        break;
                    case "RU":
                        dict.Source = new Uri("..\\Resources\\Language\\Russian.xaml", UriKind.Relative);
                        break;
                    case "SE":
                        dict.Source = new Uri("..\\Resources\\Language\\Swedish.xaml", UriKind.Relative);
                        break;
                    case "TR":
                        dict.Source = new Uri("..\\Resources\\Language\\Turkish.xaml", UriKind.Relative);
                        break;
                    case "VI":
                        dict.Source = new Uri("..\\Resources\\Language\\Vietnamese.xaml", UriKind.Relative);
                        break;
                    case "ZH":
                        dict.Source = new Uri("..\\Resources\\Language\\Chinese.xaml", UriKind.Relative);
                        break;
                    case "LT":
                        dict.Source = new Uri("..\\Resources\\Language\\Lithuanian.xaml", UriKind.Relative);
                        break;
                    default:
                        dict.Source = new Uri("..\\Resources\\Language\\English.xaml", UriKind.Relative);
                        break;
                }
            }

            if (Config.Instance.SelectedColor != null)
            {
                ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent(Config.Instance.SelectedColor), ThemeManager.GetAppTheme("BaseLight"));
            }

            Resources.MergedDictionaries.Add(dict);

            #region Executable Randomization

            if (Assembly.GetExecutingAssembly().Location.EndsWith("loader.exe") || Assembly.GetExecutingAssembly().Location.EndsWith("Loader.exe"))
            {
                try
                {
                    if (Config.Instance.RandomName != null)
                    {
                        try
                        {
                            var oldFile = Path.Combine(Directories.CurrentDirectory, Config.Instance.RandomName);
                            var oldConfigFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Config.Instance.RandomName + ".config");

                            if (File.Exists(oldFile))
                            {
                                File.SetAttributes(oldFile, FileAttributes.Normal);
                                File.Delete(oldFile);
                            }

                            if (File.Exists(oldConfigFile))
                            {
                                File.SetAttributes(oldConfigFile, FileAttributes.Normal);
                                File.Delete(oldConfigFile);
                            }
                        }
                        catch
                        {
                        }

                        if (!createdNew)
                        {
                            if (e.Args.Length > 0)
                            {
                                var loader = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Config.Instance.RandomName)).FirstOrDefault();
                                if (loader != null && loader.MainWindowHandle != IntPtr.Zero)
                                {
                                    Clipboard.SetText(e.Args[0]);
                                    ShowWindow(loader.MainWindowHandle, 5);
                                    SetForegroundWindow(loader.MainWindowHandle);
                                }
                            }

                            _mutex = null;
                            Environment.Exit(0);
                        }
                    }

                    Config.Instance.RandomName = Utility.GetUniqueKey(6) + ".exe";
                    var filePath = Path.Combine(Directories.CurrentDirectory, "loader.exe");
                    var rndExePath = Path.Combine(Directories.CurrentDirectory, Config.Instance.RandomName);
                    Utility.MapClassToXmlFile(typeof(Config), Config.Instance, Directories.ConfigFilePath);

                    File.Copy(filePath, rndExePath);
                    File.Copy(filePath + ".config", rndExePath + ".config");
                    Process.Start(rndExePath);
                    Environment.Exit(0);
                }
                catch (Exception)
                {
                    // restart
                }
            }

            AppDomain.CurrentDomain.ProcessExit += (sender, args) =>
                {
                    try
                    {
                        if (_mutex != null && createdNew)
                        {
                            _mutex.ReleaseMutex();
                        }
                    }
                    catch
                    {
                    }

                    if (!Assembly.GetExecutingAssembly().Location.EndsWith("loader.exe"))
                    {
                        var oldConfigFile = Path.Combine(
                            AppDomain.CurrentDomain.BaseDirectory,
                            Config.Instance.RandomName + ".config");

                        var info = new ProcessStartInfo
                            {
                                Arguments =
                                    "/C choice /C Y /N /D Y /T 1 & Del " + Assembly.GetExecutingAssembly().Location + " "
                                    + oldConfigFile,
                                WindowStyle = ProcessWindowStyle.Hidden,
                                CreateNoWindow = true,
                                FileName = "cmd.exe"
                            };
                        Process.Start(info);
                    }
                };

            #endregion

            base.OnStartup(e);
        }
Exemplo n.º 12
0
        private void ConfigInit()
        {
            Utility.CreateFileFromResource(Directories.ConfigFilePath, "LeagueSharp.Loader.Resources.config.xml");

            var configCorrupted = false;
            try
            {
                Config.Instance = ((Config)Utility.MapXmlFileToClass(typeof(Config), Directories.ConfigFilePath));
            }
            catch (Exception)
            {
                configCorrupted = true;
            }

            if (!configCorrupted)
            {
                try
                {
                    if (File.Exists(Directories.ConfigFilePath + ".bak"))
                    {
                        File.Delete(Directories.ConfigFilePath + ".bak");
                    }
                    File.Copy(Directories.ConfigFilePath, Directories.ConfigFilePath + ".bak");
                    File.SetAttributes(Directories.ConfigFilePath + ".bak", FileAttributes.Hidden);
                }
                catch (Exception)
                {
                    //ignore
                }
            }
            else
            {
                try
                {
                    Config.Instance =
                        ((Config)Utility.MapXmlFileToClass(typeof(Config), Directories.ConfigFilePath + ".bak"));
                    File.Delete(Directories.ConfigFilePath);
                    File.Copy(Directories.ConfigFilePath + ".bak", Directories.ConfigFilePath);
                    File.SetAttributes(Directories.ConfigFilePath, FileAttributes.Normal);
                }
                catch (Exception)
                {
                    File.Delete(Directories.ConfigFilePath + ".bak");
                    File.Delete(Directories.ConfigFilePath);
                    MessageBox.Show("Couldn't load config.xml.");
                    Environment.Exit(0);
                }
            }

            #region Add GameSetting DisableDrawings

            if (Config.Instance.Settings.GameSettings.All(x => x.Name != "Show Drawings"))
            {
                Config.Instance.Settings.GameSettings.Add(
                    new GameSettings
                        {
                            Name = "Show Drawings",
                            PosibleValues = new List<string> { "True", "False" },
                            SelectedValue = "True"
                        });
            }

            if (Config.Instance.Settings.GameSettings.All(x => x.Name != "Show Ping"))
            {
                Config.Instance.Settings.GameSettings.Add(
                    new GameSettings
                        {
                            Name = "Show Ping",
                            PosibleValues = new List<string> { "True", "False" },
                            SelectedValue = "True"
                        });
            }

            if (Config.Instance.Settings.GameSettings.All(x => x.Name != "Send Anonymous Assembly Statistics"))
            {
                Config.Instance.Settings.GameSettings.Add(
                    new GameSettings
                        {
                            Name = "Send Anonymous Assembly Statistics",
                            PosibleValues = new List<string> { "True", "False" },
                            SelectedValue = "True"
                        });
            }

            if (Config.Instance.Settings.GameSettings.All(x => x.Name != "Always Inject Default Profile"))
            {
                Config.Instance.Settings.GameSettings.Add(
                    new GameSettings
                        {
                            Name = "Always Inject Default Profile",
                            PosibleValues = new List<string> { "True", "False" },
                            SelectedValue = "False"
                        });
            }

            try
            {
                if (Config.Instance.Profiles.First().InstalledAssemblies.All(a => a.Name != "LeagueSharp.SDK"))
                {
                    var sdk = new LeagueSharpAssembly
                        {
                            Name = "LeagueSharp.SDK",
                            DisplayName = "LeagueSharp.SDK",
                            SvnUrl = "https://github.com/LeagueSharp/LeagueSharp.SDK",
                            InjectChecked = true,
                            InstallChecked = true,
                            PathToProjectFile =
                                Path.Combine(Directories.RepositoryDir, "8443D874", "trunk", "LeagueSharp.SDK.csproj")
                        };

                    sdk.Update();
                    sdk.Compile();

                    Config.Instance.Profiles.First().InstalledAssemblies.Add(sdk);
                }
            }
            catch
            {
                // wtf
            }

            #endregion
        }
Exemplo n.º 13
0
        private void ConfigInit()
        {
            Config.Load();

            #region Add GameSetting DisableDrawings

            if (Config.Instance.Settings.GameSettings.All(x => x.Name != "Show Drawings"))
            {
                Config.Instance.Settings.GameSettings.Add(
                    new GameSettings { Name = "Show Drawings", PosibleValues = new List<string> { "True", "False" }, SelectedValue = "True" });
            }

            if (Config.Instance.Settings.GameSettings.All(x => x.Name != "Show Ping"))
            {
                Config.Instance.Settings.GameSettings.Add(
                    new GameSettings { Name = "Show Ping", PosibleValues = new List<string> { "True", "False" }, SelectedValue = "True" });
            }

            if (Config.Instance.Settings.GameSettings.All(x => x.Name != "Send Anonymous Assembly Statistics"))
            {
                Config.Instance.Settings.GameSettings.Add(
                    new GameSettings
                        {
                            Name = "Send Anonymous Assembly Statistics",
                            PosibleValues = new List<string> { "True", "False" },
                            SelectedValue = "True"
                        });
            }

            if (Config.Instance.Settings.GameSettings.All(x => x.Name != "Always Inject Default Profile"))
            {
                Config.Instance.Settings.GameSettings.Add(
                    new GameSettings
                        {
                            Name = "Always Inject Default Profile",
                            PosibleValues = new List<string> { "True", "False" },
                            SelectedValue = "False"
                        });
            }

            try
            {
                if (Config.Instance.Profiles.First().InstalledAssemblies.All(a => a.Name != "LeagueSharp.SDK"))
                {
                    var sdk = new LeagueSharpAssembly
                        {
                            Name = "LeagueSharp.SDK",
                            DisplayName = "LeagueSharp.SDK",
                            SvnUrl = "https://github.com/LeagueSharp/LeagueSharp.SDK",
                            InjectChecked = true,
                            InstallChecked = true,
                            PathToProjectFile = Path.Combine(Directories.RepositoryDir, "8443D874", "trunk", "LeagueSharp.SDK.csproj")
                        };

                    sdk.Update();
                    sdk.Compile();

                    Config.Instance.Profiles.First().InstalledAssemblies.Add(sdk);
                }
            }
            catch
            {
                // wtf
            }

            #endregion
        }
Exemplo n.º 14
0
 public static void UnloadAssembly(IntPtr wnd, LeagueSharpAssembly assembly)
 {
     if (assembly.Type != AssemblyType.Library)
     {
         var str = string.Format("unload \"{0}\"", Path.GetFileName(assembly.PathToBinary));
         var lParam = new COPYDATASTRUCT { cbData = 1, dwData = str.Length * 2 + 2, lpData = str };
         SendMessage(wnd, 74U, IntPtr.Zero, ref lParam);
     }
 }