public void Init(ExtensionManager extensionManager, UiManager uiManager, System.Windows.Threading.Dispatcher dispatcher) { extensionManager.LolClientInjected += (sender, e) => client = e; extensionManager.LolClientConnected += (sender, e) => ui.Client = client; extensionManager.LolClientDisconnected += (sender, e) => ui.Client = null; extensionManager.LolClientClosed += (sender, e) => client = null; uiManager.RegisterView(this, new View(this, "Call Lcds", "CallLcds:Main", ui)); }
internal void FireLolClientInjectedEvent(LolClient client) { if (LolClientInjected != null) LolClientInjected(this, client); }
void ProcessInjector_ProcessFound(object sender, Process e) { ProcessInjector pi = sender as ProcessInjector; if (pi == null) return; //sometimes it takes a while for the main module to be loaded... while (e.MainWindowHandle == IntPtr.Zero) Thread.Sleep(1000); #if AIRDEBUG && DEBUG string loldir = null; 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]; #else var loldir = Path.GetDirectoryName(e.MainModule.FileName)??string.Empty; #endif _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); _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(); } }
private void pm_LolClientInjected(object sender, LolClient e) { _dispatcher.InvokeAsync(() => _clientStatus.Status = ClientStates.Injected); }