示例#1
0
        private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            if (msg == uCallBackMsg)
            {
                switch (wParam.ToInt32())
                {
                case (int)NativeMethods.ABNotify.ABN_FULLSCREENAPP:
                    IntPtr hWnd = NativeMethods.GetForegroundWindow();
                    //判断当前全屏的应用是否是桌面
                    if (hWnd.Equals(desktopHandle) || hWnd.Equals(shellHandle))
                    {
                        break;
                    }
                    //判断是否全屏
                    if ((int)lParam == 1)
                    {
                        Log.Info("The window is being maxsize");
                        if (fullScreenButton is not null)
                        {
                            fullScreenButton.Icon = new SymbolIcon {
                                Symbol = Symbol.BackToWindow
                            };
                            fullScreenButton.ToolTip = ErogeHelper.Language.Strings.GameView_SwitchWindow;
                        }
                    }
                    else
                    {
                        Log.Info("The window is being normalize or minimize");
                        if (fullScreenButton is not null)
                        {
                            fullScreenButton.Icon = new SymbolIcon {
                                Symbol = Symbol.FullScreen
                            };
                            fullScreenButton.ToolTip = ErogeHelper.Language.Strings.GameView_SwitchFullScreen;
                        }
                    }
                    GameHooker.CheckWindowHandler();
                    break;

                default:
                    break;
                }
            }

            return(IntPtr.Zero);
        }
        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();
            }
        }
示例#3
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();
            }
        }