public void CalculateIsControlEnabled() { int EmulationMode = ApplicationSettings.GetInstance().EmulationMode; if (EmulationConstants.IsValidValue(EmulationMode) && EmulationMode == EmulationConstants.ONLY_VIGEM) { Element_Toggle.Visibility = UIConstants.VISIBILITY_COLLAPSED; Element_TextBlock_Description.Visibility = UIConstants.VISIBILITY_COLLAPSED; Element_TextBlock_Warning.Visibility = UIConstants.VISIBILITY_VISIBLE; } else { Element_Toggle.Visibility = UIConstants.VISIBILITY_VISIBLE; Element_TextBlock_Description.Visibility = UIConstants.VISIBILITY_VISIBLE; Element_TextBlock_Warning.Visibility = UIConstants.VISIBILITY_COLLAPSED; } }
public int GetValue() { RadioButton checkedRadioButton = Panel_RadioButtonGroup.Children.OfType <RadioButton>(). Where(n => n.IsChecked == true).First(); if (checkedRadioButton != null && checkedRadioButton.Tag != null) { int tag = Int32.Parse(checkedRadioButton.Tag.ToString()); if (EmulationConstants.IsValidValue(tag)) { Log.Information("EmulationPickerControl tag is " + tag); return(tag); } } Log.Information("EmulationPickerControl tag is null"); return(-1); }
public void SetInitialRadioChecked() { // if vigem is installed there are no restrictions // use the last known setting (assuming the are valid) if (IsVigemInstalled) { int initialTag = ApplicationSettings.GetInstance().EmulationMode; if (EmulationConstants.IsValidValue(initialTag)) { SetRadioCheckedForTag(initialTag); } else { SetRadioCheckedForTag(EmulationConstants.VIGEM_AND_PROCESS_INJECTION); } } // if vigem isnt installed then we can only do process injection else { SetRadioCheckedForTag(EmulationConstants.ONLY_PROCESS_INJECTION); } }
public static int Inject(int emulationMode, string processName, string dllToInject) { Log.Logger.Information("Injector.Inject {emulationMode:{0}||{1}, processName:{2}, dllToInject:{3}", emulationMode, EmulationConstants.ToString(emulationMode), processName, dllToInject); EmulationMode = emulationMode; // Find the process Process process = FindProcess(processName); if (process == null) { string error = string.Format("{0} not found in list of processes", processName); Log.Error(error); throw new InterceptorException(error); } // Full path to our dll file string injectionLibrary = Path.Combine(Path.GetDirectoryName(typeof(InjectionInterface).Assembly.Location), dllToInject); Log.Information("Injector.Inject() injectionLibrary " + injectionLibrary); bool shouldInject = false; try { //Original from Komefai // //if (InjectionMode == InjectionMode.Auto) //{ // if (_ipcServer == null) // { // // Setup remote hooking // _channelName = DateTime.Now.ToString(); // _ipcServer = RemoteHooking.IpcCreateServer<InjectionInterface>(ref _channelName, // WellKnownObjectMode.Singleton, // WellKnownSidType.WorldSid); // // shouldInject = true; // } //} //else if (InjectionMode == InjectionMode.Compatibility) //{ // // Setup remote hooking // _channelName = null; // _ipcServer = RemoteHooking.IpcCreateServer<InjectionInterface>(ref _channelName, WellKnownObjectMode.Singleton); // shouldInject = true; //} if (_ipcServer == null) { Log.Debug("Injector.Inject making ipcServer1"); // Setup remote hooking _channelName = DateTime.Now.ToString("yy-MM-dd hh:mm:ss"); _ipcServer = RemoteHooking.IpcCreateServer <InjectionInterface>(ref _channelName, WellKnownObjectMode.Singleton, WellKnownSidType.WorldSid); Log.Debug("Injector.Inject _ipcServer1 made"); } if (_ipcServer2 == null) { Log.Debug("Injector.Inject making ipcServer2"); _channelName2 = "dotnethooks"; _ipcServer2 = RemoteHooking.IpcCreateServer <InjectionInterface>(ref _channelName2, WellKnownObjectMode.Singleton, WellKnownSidType.WorldSid); shouldInject = true; Log.Debug("Injector.Inject _ipcServer2 made"); } } catch (Exception ex) { string error = string.Format("Failed to setup IPC server: {0}", ex.Message); ExceptionLogger.LogException(error, ex); throw new InterceptorException(error, ex); } try { Log.Information("Injector.Inject() shouldInject " + shouldInject); // Inject dll into the process if (shouldInject) { Log.Debug("Injector.Inject RemoteHooking.Inject start"); RemoteHooking.Inject( process.Id, // ID of process to inject into (_noGAC ? InjectionOptions.DoNotRequireStrongName : InjectionOptions.Default), // if not using GAC allow assembly without strong name injectionLibrary, // 32-bit version (the same because AnyCPU) injectionLibrary, // 64-bit version (the same because AnyCPU) _channelName ); Log.Debug("Injector.Inject RemoteHooking.Inject done"); } // Success return(process.Id); } catch (DllNotFoundException ex) { ExceptionLogger.LogException("DllNotFoundException, this looks fatal", ex); throw ex; } catch (Exception ex) { string error = string.Format("Failed to inject to target: {0}", ex.Message); ExceptionLogger.LogException(error, ex); throw new InterceptorException(error, ex); } }