/// <summary>
 /// Timer event when looking for Game's Process (auto-Hook)
 /// As opposed to Aliens: Extermination program, it will not close itself when the game's process has finished as
 /// the "patch" to bypass dongle request makes the game to quit and reload itself.....
 /// </summary>
 private void tProcess_Tick(Object Sender, EventArgs e)
 {
     try
     {
         Process[] processes = Process.GetProcessesByName(_TargetProcess_Name);
         if (processes.Length > 0)
         {
             _TargetProcess = processes[0];
             WriteLog("Attached to Process " + _TargetProcess_Name + ".exe");
             Bgw_Mouse.RunWorkerAsync();
         }
     }
     catch
     { }
 }
Пример #2
0
        /// <summary>
        /// Timer event when looking for Game's Process (auto-Hook and auto-close)
        /// </summary>
        private void tProcess_Tick(Object Sender, EventArgs e)
        {
            if (!_TargetProcess_Hooked)
            {
                try
                {
                    Process[] processes = Process.GetProcessesByName(_TargetProcess_Name);
                    if (processes.Length > 0)
                    {
                        _TargetProcess                   = processes[0];
                        _TargetProcess_Handle            = _TargetProcess.Handle;
                        _TargetProcess_MemoryBaseAddress = _TargetProcess.MainModule.BaseAddress;

                        //Waiting for the game's MainWidowHandle to be created too
                        //If not, we can't get client size automatically
                        if (_TargetProcess_MemoryBaseAddress != IntPtr.Zero && _TargetProcess.MainWindowHandle != IntPtr.Zero)
                        {
                            _TargetProcess_Hooked = true;
                            WriteLog("Attached to Process " + _TargetProcess_Name + ".exe, ProcessHandle = " + _TargetProcess_Handle);
                            SetHack();
                            Bgw_Mouse.RunWorkerAsync();
                        }
                    }
                }
                catch
                {
                    //WriteLog("Error trying to hook " + _Target_Process_Name + ".exe");
                }
            }
            else
            {
                Process[] processes = Process.GetProcessesByName(_TargetProcess_Name);
                if (processes.Length <= 0)
                {
                    _TargetProcess_Hooked            = false;
                    _TargetProcess                   = null;
                    _TargetProcess_Handle            = IntPtr.Zero;
                    _TargetProcess_MemoryBaseAddress = IntPtr.Zero;
                    WriteLog(_TargetProcess_Name + ".exe closed");
                }
            }
        }