Ejemplo n.º 1
0
        public bool Initialize(IntPtr targetWindow, string targetWindowName, int width, int height, int fps)
        {
            m_width            = width;
            m_height           = height;
            m_length           = m_width * m_height * 4;
            m_desiredFPS       = fps;
            m_targetWindow     = targetWindow;
            m_targetWindowName = targetWindowName;

            // get working dir for loading D3D9Hook.dll
            System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
            string dllPath = a.Location;
            int    pos     = dllPath.LastIndexOf('\\');

            dllPath  = dllPath.Remove(pos);
            dllPath += "\\D3D9Hook.dll";

            // inject into target process (must be a directx appliction using d3d9.dll)
            if (!ProcessInjector.DoProcessInjection(m_targetWindow, m_targetWindowName, dllPath))
            {
                return(false);
            }

            // Set D3D9Hook.dll capture size
            PinvokeD3D9Hook.SetCapSize(m_width, m_height);

            return(true);
        }
        public ProcessInjectionServiceImpl(ProcessInjector injector, ProcessInjectionConfiguration configuration)
        {
            logger.Info("Initializing Process Injection Service");

             this.injector = injector;
             this.configuration = configuration;
        }
        public ProcessInjectionServiceImpl(ProcessInjector injector, ProcessInjectionConfiguration configuration)
        {
            logger.Info("Initializing Process Injection Service");

            this.injector      = injector;
            this.configuration = configuration;
        }
Ejemplo n.º 4
0
        private void Window_Initialized(object sender, EventArgs e)
        {
            CultureInfo.DefaultThreadCurrentCulture   = new CultureInfo("en-US");
            CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("en-US");

            if (!Directory.Exists("data"))
            {
                MessageBox.Show(Debugger.IsAttached ? @"""data"" folder and/or sqlite3.dll not found. Make sure to copy the data folder and sqlite3.dll to the output directory." : "Some files are missing, please reinstall.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                Environment.Exit(-1);
            }

            if (!Debugger.IsAttached)
            {
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            }
            _uiManager = new UiManager();

            LoadExtensionDependencies();

            List <Assembly> assemblies = LoadExtensions();

            _extensionManager = new ExtensionManager(_uiManager, Dispatcher, ConfigDir, new FinalesFunkelnExtension());
            _extensionManager.AddAssemblies(assemblies);
            _extensionManager.InitExtensions();

            foreach (var x in _extensionManager.Extensions)
            {
                var item = new ExtensionMenuItem(x.Value);
                item.Views.AddRange(_uiManager.GetViewsByExtension(x.Value));
                ViewsMenuItem.Items.Add(item);
            }

            DockingManager.Layout.RootPanel = new LayoutPanel(_mainPane = new LayoutDocumentPane());


            foreach (var view in _uiManager.GetViews())
            {
                LayoutContent c = new DocumentViewControl(view);
                _mainPane.Children.Add(c);
            }

#if AIRDEBUG && DEBUG
            _processInjector = new ProcessInjector("adl");          //AirDebugLauncher
#elif LCU
            _processInjector = new ProcessInjector("LeagueClient"); //New LoL client
#else
            _processInjector = new ProcessInjector("lolclient");
#endif

            _processInjector.Injected      += pi_Injected;
            _processInjector.ProcessFound  += ProcessInjector_ProcessFound;
            _processInjector.ProcessExited += _processInjector_ProcessExited;
            _processInjector.Start();
        }
Ejemplo n.º 5
0
        void ProcessInjector_ProcessFound(object sender, Process e)
        {
            ProcessInjector pi = sender as ProcessInjector;

            if (pi == null)
            {
                return;
            }

            Thread.Sleep(1000);
            string loldir = null;

            try
            {
                loldir = Path.GetDirectoryName(e.MainModule.FileName) ?? string.Empty;
            }
            catch (Win32Exception)
            {
                MessageBox.Show("Cannot access the lolclient process. If this error persists try runnig as an administrator.", "Error");
                return;
            }

            _lolProperties = new YamlFile(Path.Combine(loldir, LolPropertiesFilename));
            _lcuSettings   = new YamlFile(Path.Combine(loldir, LcuSettingsPath, LcuSettingsFilename));
            //string host = ((dynamic)_lolProperties)["region_data"][((dynamic)_lcuSettings)["install"]["globals"]["region"]]["servers"]["lcds"]["lcds_host"];
            _rtmpAddress = ((dynamic)_lolProperties)["region_data"][((dynamic)_lcuSettings)["install"]["globals"]["region"]]["servers"]["lcds"]["lcds_host"];

            if (_rtmpAddress == null)
            {
                return;
            }

            _certificate = GetCertificate(_rtmpAddress);

            if (_certificate == null)
            {
                Dispatcher.Invoke(() => MessageBox.Show(this, "This program is not compatible with your region: " + _lolProperties["platformId"] + ".\n", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning));

                return;
            }

            if (!IsInstalled(_certificate))
            {
                MessageBoxResult res = MessageBoxResult.None;

                Dispatcher.Invoke(() => res = MessageBox.Show(this, "A certificate needs to be installed.\n\n" +
                                                              "You can see which certificates are installed under Views->FinalesFunkeln->Certificates and uninstall them at any time.\n\nInstall the certificate now?", "Confirmation",
                                                              MessageBoxButton.YesNo, MessageBoxImage.Information));
                if (res != MessageBoxResult.Yes)
                {
                    return;
                }
                InstallCertificate(_certificate);
            }

            InitProxy();
            _lolClient = new LolClient(loldir, _lolProperties, _proxy, e, _extensionManager);
            _extensionManager.FireLolClientInjectedEvent(_lolClient);
            try
            {
                pi.Inject();
                _lolClientProcess = e;
            }
            catch (WarningException ex)
            {
                //I think this only happens when we try to inject into an already redirected app.
            }
            catch (AccessViolationException ex)
            {
                //Not sure what to do if that happens
                if (Debugger.IsAttached)
                {
                    Debugger.Break();
                }
            }
        }
Ejemplo n.º 6
0
        public MainForm()
        {
            InitializeComponent();

            Logger.Instance.Register(new DefaultListener(Levels.All, OnLog));
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            Application.ThreadException += Application_ThreadException;
            StaticLogger.Info(string.Format("Version {0}", Version));

            Settings.Load(SettingsFile);

            Certificates = new Dictionary <LeagueRegion, CertificateHolder>
            {
                { LeagueRegion.NA, new CertificateHolder("prod.na1.lol.riotgames.com", Resources.prod_na1_lol_riotgames_com) },
                { LeagueRegion.EUW, new CertificateHolder("prod.eu.lol.riotgames.com", Resources.prod_eu_lol_riotgames_com) },
                { LeagueRegion.EUNE, new CertificateHolder("prod.eun1.lol.riotgames.com", Resources.prod_eun1_lol_riotgames_com) },
                { LeagueRegion.BR, new CertificateHolder("prod.br.lol.riotgame.com", Resources.prod_br_lol_riotgames_com) }
            };
            ModuleResolvers = new Dictionary <ProcessInjector.GetModuleFrom, RadioButton>
            {
                { ProcessInjector.GetModuleFrom.Toolhelp32Snapshot, ToolHelpRadio },
                { ProcessInjector.GetModuleFrom.ProcessClass, ProcessRadio },
                { ProcessInjector.GetModuleFrom.Mirroring, MirrorRadio }
            };
            foreach (var kv in ModuleResolvers)
            {
                kv.Value.Click += moduleresolvers_Click;
            }

            RegionsFullText = new Dictionary <LeagueRegion, string>
            {
                { LeagueRegion.NA, "North America" },
                { LeagueRegion.EUW, "Europe West" },
                { LeagueRegion.EUNE, "Europe Nordic & East" },
                { LeagueRegion.BR, "Brazil" }
            };

            //Database = Db4oEmbedded.OpenFile(CreateConfig(), "db.yap");

            var cert = Certificates.FirstOrDefault(kv => kv.Key == Settings.Region).Value;

            if (cert == null)
            {
                cert = Certificates.First().Value;
            }

            Injector   = new ProcessInjector("lolclient");
            Connection = new RtmpsProxyHost(2099, cert.Domain, 2099, cert.Certificate);
            Reader     = new MessageReader(Connection);

            Connection.Connected += Connection_Connected;
            Injector.Injected    += Injector_Injected;
            Reader.ObjectRead    += Reader_ObjectRead;

            //Recorder must be initiated after Reader.ObjectRead as
            //the last event handler is called first
            //Recorder = new GameStorage(Database, Connection);

            Connection.CallResult += Connection_Call;
            Connection.Notify     += Connection_Notify;


            foreach (var kv in Certificates)
            {
                RegionList.Items.Add(RegionsFullText[kv.Key]);
            }
            int idx = RegionList.Items.IndexOf(RegionsFullText[Settings.Region]);

            //StaticLogger.Info("Index: " + idx);
            RegionList.SelectedIndex = idx != -1 ? idx : 0;              //This ends up calling UpdateRegion so no reason to initialize the connection here.

            Installer = new CertificateInstaller(Certificates.Select(c => c.Value.Certificate).ToArray());

            TrackingQueue.Process += TrackingQueue_Process;
            launcher.ProcessFound += launcher_ProcessFound;

#if DEBUG
            button1.Visible = true;
#endif

            StaticLogger.Info("Startup Completed");
        }
Ejemplo n.º 7
0
        public MainForm()
        {
            InitializeComponent();

            Logger.Instance.Register(new DefaultListener(Levels.All, OnLog));
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            Application.ThreadException += Application_ThreadException;
            StaticLogger.Info(string.Format("Version {0}", Version));

            Settings.Load(SettingsFile);

            Icons = new Dictionary <string, Icon>
            {
                { "Red", Icon.FromHandle(Resources.circle_red.GetHicon()) },
                { "Yellow", Icon.FromHandle(Resources.circle_yellow.GetHicon()) },
                { "Green", Icon.FromHandle(Resources.circle_green.GetHicon()) },
            };

            Certificates = LoadCertificates(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Content/Certificates"));
            if (Certificates.Count < 1)
            {
                MessageBox.Show("Unable to load any certificates");
                Application.Exit();
                return;
            }

            ModuleResolvers = new Dictionary <ProcessInjector.GetModuleFrom, RadioButton>
            {
                { ProcessInjector.GetModuleFrom.Toolhelp32Snapshot, ToolHelpRadio },
                { ProcessInjector.GetModuleFrom.ProcessClass, ProcessRadio },
                { ProcessInjector.GetModuleFrom.Mirroring, MirrorRadio }
            };
            foreach (var kv in ModuleResolvers)
            {
                kv.Value.Click += moduleresolvers_Click;
            }

            Database = Db4oEmbedded.OpenFile(CreateConfig(), "db.yap");

            var cert = Certificates.FirstOrDefault(kv => kv.Key == Settings.Region).Value;

            if (cert == null)
            {
                cert = Certificates.First().Value;
            }

            Injector   = new ProcessInjector("lolclient");
            Connection = new RtmpsProxyHost(2099, cert.Domain, 2099, cert.Certificate);
            Reader     = new MessageReader(Connection);

            Connection.Connected += Connection_Connected;
            Injector.Injected    += Injector_Injected;
            Reader.ObjectRead    += Reader_ObjectRead;

            //Recorder must be initiated after Reader.ObjectRead as
            //the last event handler is called first
            Recorder = new GameStorage(Database, Connection);

            Connection.CallResult += Connection_Call;
            Connection.Notify     += Connection_Notify;


            foreach (var kv in Certificates)
            {
                RegionList.Items.Add(kv.Key);
            }
            int idx = RegionList.Items.IndexOf(Settings.Region);

            RegionList.SelectedIndex = idx != -1 ? idx : 0;              //This ends up calling UpdateRegion so no reason to initialize the connection here.

            DefaultGameTab.Text = Settings.DefaultGameTab;

            Installer = new CertificateInstaller(Certificates.Select(c => c.Value.Certificate).ToArray());

            TrackingQueue.Process += TrackingQueue_Process;
            launcher.ProcessFound += launcher_ProcessFound;

#if DEBUG
            button1.Visible = true;
#endif

            StaticLogger.Info("Startup Completed");
        }
Ejemplo n.º 8
0
        void ProcessInjector_ProcessFound(object sender, Process e)
        {
            ProcessInjector pi = sender as ProcessInjector;

            if (pi == null)
            {
                return;
            }

#if !LCU    //The new lol client has a separate process for the UI
            //sometimes it takes a while for the main module to be loaded...
            while (e.MainWindowHandle == IntPtr.Zero)
#endif
            Thread.Sleep(1000);
            string loldir = null;
            try
            {
#if AIRDEBUG && DEBUG
                string wmiQuery = string.Format("select CommandLine from Win32_Process where Name='{0}'", "adl.exe");
                ManagementObjectSearcher   searcher            = new ManagementObjectSearcher(wmiQuery);
                ManagementObjectCollection retObjectCollection = searcher.Get();
                foreach (ManagementObject retObject in retObjectCollection)
                {
                    loldir = ProcessHelper.SplitCommandLineArgs((string)retObject["CommandLine"])[2];
                }
#elif LCU
                loldir = Path.GetDirectoryName(e.MainModule.FileName) ?? string.Empty;
                loldir = Path.Combine(loldir, @"../../../../lol_air_client/releases/0.0.4.147/deploy");
                //TODO this directory is just a placeholder
#else
                loldir = Path.GetDirectoryName(e.MainModule.FileName) ?? string.Empty;
#endif
            }
            catch (Win32Exception)
            {
                MessageBox.Show("Cannot access the lolclient process. If this error persists try runnig as an administrator.", "Error");
                return;
            }
            _lolProperties = new PropertiesFile(Path.Combine(loldir, LolPropertiesFilename));
            var host = _lolProperties["host"];
            _rtmpAddress = host.Contains(",") ? host.Substring(0, host.IndexOf(',')) : host;

            if (_rtmpAddress == null)
            {
                return;
            }

            _certificate = GetCertificate(_rtmpAddress);

            if (_certificate == null)
            {
                Dispatcher.Invoke(() => MessageBox.Show(this, "This program is not compatible with your region: " + _lolProperties["platformId"] + ".\n", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning));

                return;
            }

            if (!IsInstalled(_certificate))
            {
                MessageBoxResult res = MessageBoxResult.None;

                Dispatcher.Invoke(() => res = MessageBox.Show(this, "A certificate needs to be installed.\n\n" +
                                                              "You can see which certificates are installed under Views->FinalesFunkeln->Certificates and uninstall them at any time.\n\nInstall the certificate now?", "Confirmation",
                                                              MessageBoxButton.YesNo, MessageBoxImage.Information));
                if (res != MessageBoxResult.Yes)
                {
                    return;
                }
                InstallCertificate(_certificate);
            }

            InitProxy();
            _lolClient = new LolClient(loldir, _lolProperties, _proxy, e, _extensionManager);
            _extensionManager.FireLolClientInjectedEvent(_lolClient);
            try
            {
                pi.Inject();
                _lolClientProcess = e;
            }
            catch (WarningException ex)
            {
                //I think this only happens when we try to inject into an already redirected app.
            }
            catch (AccessViolationException ex)
            {
                //Not sure what to do if that happens
                if (Debugger.IsAttached)
                {
                    Debugger.Break();
                }
            }
        }
Ejemplo n.º 9
0
        public MainForm()
        {
            String regionFromFileName = System.AppDomain.CurrentDomain.FriendlyName;

            Console.WriteLine(regionFromFileName);
            regionFromFileName = regionFromFileName.Replace("LoLTeamChecker", "");
            Console.WriteLine(regionFromFileName);
            regionFromFileName = regionFromFileName.Replace(".exe", "");
            Console.WriteLine(regionFromFileName);
            if (regionFromFileName.Length != 0)
            {
                Settings.Region = regionFromFileName;
            }

            InitializeComponent();
            Logger.Instance.Register(new DefaultListener(Levels.All, OnLog));
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            Application.ThreadException += Application_ThreadException;
            //StaticLogger.Info(string.Format("Version {0}", Version));

            //Settings.Load(SettingsFile);

            Icons = new Dictionary <string, Icon>
            {
                { "Red", Icon.FromHandle(Resources.circle_red.GetHicon()) },
                { "Yellow", Icon.FromHandle(Resources.circle_yellow.GetHicon()) },
                { "Green", Icon.FromHandle(Resources.circle_green.GetHicon()) },
            };

            Certificates = LoadCertificates();
            if (Certificates.Count < 1)
            {
                MessageBox.Show("Unable to load any certificates");
                Application.Exit();
                return;
            }
            var cert = Certificates.FirstOrDefault(kv => kv.Key == Settings.Region).Value;

            if (cert == null)
            {
                cert = Certificates.First().Value;
            }

            Injector   = new ProcessInjector("lolclient");
            Connection = new RtmpsProxyHost(2099, cert.Domain, 2099, cert.Certificate);
            Reader     = new MessageReader(Connection);

            Connection.Connected += Connection_Connected;
            Injector.Injected    += Injector_Injected;
            Reader.ObjectRead    += Reader_ObjectRead;

            Connection.CallResult += Connection_Call;
            Connection.Notify     += Connection_Notify;

            /*
             *          foreach (var kv in Certificates)
             *                  RegionList.Items.Add(kv.Key);
             *          int idx = RegionList.Items.IndexOf(Settings.Region);
             *          RegionList.SelectedIndex = idx != -1 ? idx : 0;	 //This ends up calling UpdateRegion so no reason to initialize the connection here.
             */
            Installer = new CertificateInstaller(Certificates.Select(c => c.Value.Certificate).ToArray());
            Installer.Uninstall();
            if (!Installer.IsInstalled)
            {
                Installer.Install();
            }

            TrackingQueue.Process += TrackingQueue_Process;
            launcher.ProcessFound += launcher_ProcessFound;

            StaticLogger.Info("Startup Completed");
        }