private void MemoryTimer_Tick(object sender, EventArgs e)
        {
            Task.Run(() =>
            {
                var wantedButtonState = false;

                if (SelectedMemory == null || !SelectedMemory.IsRunning())
                {
                    SetLabelText(StatusLabel, "Status: Not running");
                    StatusLabel.BeginInvoke((MethodInvoker) delegate
                    {
                        toolTip1.SetToolTip(StatusLabel, "Process not found or failed to write to memory!");
                        StatusLabel.ForeColor = Color.Orange;
                    });
                }
                else
                {
                    wantedButtonState = !Program.IsElevated && (SelectedMemory?.ProcMemory?.RequiresElevation() ?? false);

                    DoRAChecks();
                    DoFoV();
                    ToggleFog(settings.Fog);
                    DoDvars();
                }

                if (AdminLaunchButton.Visible != wantedButtonState)
                {
                    AdminLaunchButton.BeginInvoke((MethodInvoker) delegate { AdminLaunchButton.Visible = wantedButtonState; });
                }
            });
        }
Exemple #2
0
 private void UpdateStatus(string text, Color color)
 {
     if (text != null)
     {
         StatusLabel.BeginInvoke(
             ((Action)(() => StatusLabel.Text = text)));
     }
     if (color != Color.Empty)
     {
         StatusLabel.BeginInvoke(
             ((Action)(() => StatusLabel.BackColor = color)));
     }
 }
        private void DoFoV()
        {
            try
            {
                var isRunning = SelectedMemory?.IsRunning() ?? false;
                if (isRunning && (SelectedMemory?.ProcMemory?.RequiresElevation() ?? false))
                {
                    SetLabelText(StatusLabel, "Status: game requires elevation!");
                    StatusLabel.BeginInvoke((MethodInvoker) delegate
                    {
                        toolTip1.SetToolTip(StatusLabel, "Process requires elevation!");
                        StatusLabel.ForeColor = Color.Orange;
                    });
                    return;
                }

                var address = !isRunning ? -1 : !IsUO() ? MemoryAddresses.COD_FOV_ADDRESS : (isRunning ? (SelectedMemory.ProcMemory.DllImageAddress(MemoryAddresses.UO_CGAME_MP_DLL) + MemoryAddresses.UO_FOV_OFFSET) : -1);
                if (!isRunning || address <= 0)
                {
                    SetLabelText(StatusLabel, "Status: Not running");
                    StatusLabel.BeginInvoke((MethodInvoker) delegate
                    {
                        toolTip1.SetToolTip(StatusLabel, "Process not found or failed to write to memory!");
                        StatusLabel.ForeColor = Color.Orange;
                    });
                }
                else
                {
                    SelectedMemory.ProcMemory.WriteFloat(address, CurrentFoV);
                    SetLabelText(StatusLabel, "Status: Success!");
                    StatusLabel.BeginInvoke((MethodInvoker) delegate()
                    {
                        toolTip1.SetToolTip(StatusLabel, string.Empty);
                        StatusLabel.ForeColor = Color.DarkGreen;
                    });
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Log.WriteLine("An exception happened while trying to read/write FoV addresses: " + Environment.NewLine + ex.ToString());
            }
        }