public async void Inject(object procItems) // Suger by CM
        {
            if (SelectedProcItem.proc.HasExited)
            {
                await new ContentDialog
                {
                    Title           = "Eroge Helper",
                    Content         = "Process has gone.",
                    CloseButtonText = "OK"
                }.ShowAsync().ConfigureAwait(false);
                ProcItems.Remove(SelectedProcItem);
            }
            else
            {
                // 🧀
                MatchProcess.Collect(SelectedProcItem.proc.ProcessName);
                // Cheak if there is eh.config file
                var configPath = SelectedProcItem.proc.MainModule !.FileName + ".eh.config";
                if (File.Exists(configPath))
                {
                    GameConfig.Load(configPath);

                    log.Info($"Get HCode {GameConfig.HookCode} from file {SelectedProcItem.proc.ProcessName}.exe.eh.config");
                    // Display text window
                    await windowManager.ShowWindowAsync(IoC.Get <GameViewModel>()).ConfigureAwait(false);
                }
                else
                {
                    log.Info("Not find xml config file, open hook panel.");
                    await windowManager.ShowWindowAsync(IoC.Get <HookConfigViewModel>()).ConfigureAwait(false);
                }

                await TryCloseAsync().ConfigureAwait(false);

                Textractor.Init();
                GameHooker.Init();
            }
        }
示例#2
0
        /// <summary>
        /// Entry Point
        /// </summary>
        protected override async void OnStartup(object sender, System.Windows.StartupEventArgs e)
        {
            Log.Info("Started Logging");
            if (e.Args.Length == 0)
            {
                // Display select processes window
                await DisplayRootViewFor <SelectProcessViewModel>();
            }
            else
            {
                // Startup by shell menu
                var gamePath = e.Args[0];
                var gameDir  = gamePath.Substring(0, gamePath.LastIndexOf('\\'));
                Log.Info($"Game's path: {e.Args[0]}");
                Log.Info($"Locate Emulator status: {e.Args.Contains("/le")}");

                if (e.Args.Contains("/le"))
                {
                    // Use Locate Emulator
                    Process.Start(new ProcessStartInfo
                    {
                        FileName        = Directory.GetCurrentDirectory() + @"\libs\x86\LEProc.exe",
                        UseShellExecute = false,
                        Arguments       = File.Exists(gamePath + ".le.config")
                                               ? $"-run \"{gamePath}\""
                                               : $"\"{gamePath}\""
                    });
                    // XXX: LE may throw AccessViolationException which can not be catched
                }
                else
                {
                    // Direct start
                    Process.Start(new ProcessStartInfo
                    {
                        FileName         = gamePath,
                        UseShellExecute  = false,
                        WorkingDirectory = gameDir
                    });
                }

                // 🧀
                var findResult = MatchProcess.Collect(Path.GetFileNameWithoutExtension(gamePath));
                if (findResult != true)
                {
                    MessageBox.Show($"{Language.Strings.MessageBox_TimeoutInfo}", "Eroge Helper");
                    return;
                }

                // Cheak if there is eh.config file
                if (File.Exists(gamePath + ".eh.config"))
                {
                    GameConfig.Load(gamePath + ".eh.config");

                    Log.Info($"Get HCode {GameConfig.HookCode} from file " +
                             $"{Path.GetFileNameWithoutExtension(gamePath)}.exe.eh.config");
                    // Display text window

                    await Container.Resolve <IWindowManager>().ShowWindowAsync(Container.Resolve <GameViewModel>(), "InsideView");
                }
                else
                {
                    Log.Info("Not find xml config file, open hook panel.");
                    await DisplayRootViewFor <HookConfigViewModel>();
                }

                Textractor.Init();
                GameHooker.Init();
            }
        }