private static EmulatorProcess SelectEmulator(List <Emulator> emulators) { List <EmulatorProcess> foundEmulators = new List <EmulatorProcess>(); foreach (var item in emulators) { foreach (var p in Process.GetProcessesByName(item.ProcessName)) { var t = new EmulatorProcess(item, p); foundEmulators.Add(t); } } if (foundEmulators.Count == 0) { return(null); } if (foundEmulators.Count == 1) { return(foundEmulators[0]); } Console.Clear(); int i = 1; foreach (var item in foundEmulators) { Console.WriteLine($"{i:D2}) {item.Stats.ProcessName} {item.Process.MainWindowTitle}"); i++; } Console.Write("Select Emulator: "); var input = Console.ReadLine(); if (!int.TryParse(input, out i)) { return(null); } i--; if (i < 0 || i >= foundEmulators.Count) { return(null); } return(foundEmulators[i]); }
public static bool TryMountEmulator(List <Emulator> emulators) { bool result; EmulatorProcess emulator = SelectEmulator(emulators); if (emulator == null) { return(false); } result = MountEmulator(emulator); if (result) { Console.WriteLine(emulator.Stats.ProcessDescription); } return(result); }
private static bool MountEmulator(EmulatorProcess emu) { ExpressTest.ExpressionEvaluator ExpressionEvalulator; string ramStartExpression = emu.Stats.RamStart; Emulator = emu; if (Emulator == null) { return(false); } foreach (ProcessModule item in Emulator.Process.Modules) { IntPtr baseAddress = item.BaseAddress; string moduleName = "`" + item.ModuleName.ToLowerInvariant() + "`"; if (ramStartExpression.Contains(moduleName)) { //if (baseAddress. ramStartExpression = ramStartExpression.Replace (moduleName, baseAddress.ToString("X")); emu.WatchedModules.Add(item); } } Func <long, long> ReadProc; if (emu.Stats.ProcessType == 64) { ReadProc = ReadProcess64; } else { ReadProc = ReadProcess32; } ExpressionEvalulator = new ExpressTest.ExpressionEvaluator(ReadProc); RamPointer = new IntPtr(ExpressionEvalulator.Evaluate(ramStartExpression)); if (RamPointer == new IntPtr(0)) { return(false); } return(true); }