Beispiel #1
0
        private void MemoryWriteTimer_Tick(object sender, EventArgs e)
        {
            if (Process.GetProcessesByName("halo2").Length > 0)
            {
                statusPanel.BackColor = Color.Green;
                statusLabel.Text      = "Halo 2 process detected.";

                if (!isActive)
                {
                    HaloMemoryWriter.TryConnectToProcess();
                    MouseInput.Start();
                    writeFOVToMemory();
                    writeCrosshairOffsetToMemory();
                    isActive = true;

                    jsonHelper.OutputJsonToFile(jsonHelper.Serialize
                                                    (new JsonData(numFoV.Value, numViewOffset.Value, numHorizontal.Value, numVertical.Value)));
                }
            }
            else
            {
                statusPanel.BackColor = Color.Red;
                statusLabel.Text      = "Halo 2 process not detected.";
                isActive = false;
            }
        }
Beispiel #2
0
 private void processList_SelectionChangeCommitted(object sender, System.EventArgs e)
 {
     if (processList.SelectedItem != null)
     {
         HaloMemoryWriter.TryConnectToProcess(processList.SelectedItem.ToString());
     }
 }
Beispiel #3
0
        public void writeFOVToMemory()
        {
            float defaultRadians = (float)(70 * Math.PI / 180);
            float targetRadians  = (float)((double)numFoV.Value * Math.PI / 180);

            HaloMemoryWriter.WriteToMemory((uint)HaloMemoryWriter.BaseAddress + MouseThingy.FOV_MULTIPLIER_OFFSET, BitConverter.GetBytes(targetRadians / defaultRadians));
            HaloMemoryWriter.WriteToMemory((uint)HaloMemoryWriter.BaseAddress + MouseThingy.FOV_VEHICLE_MULTIPLIER_OFFSET, BitConverter.GetBytes(targetRadians / defaultRadians));
        }
Beispiel #4
0
        public void writeCrosshairOffsetToMemory()
        {
            uint crosshairOffsetAddress = (uint)HaloMemoryWriter.BaseAddress.ToInt32() + MouseThingy.CROSSHAIR_OFFSET_POINTER;

            byte[] crosshairOffsetData = new byte[4];
            HaloMemoryWriter.ReadFromMemory(crosshairOffsetAddress, crosshairOffsetData);
            HaloMemoryWriter.WriteToMemory((uint)((uint)(BitConverter.ToInt32(crosshairOffsetData, 0)) + MouseThingy.CROSSHAIR_OFFSET_POINTER_OFFSET), BitConverter.GetBytes((float)numViewOffset.Value));
        }
Beispiel #5
0
        /// <summary>
        /// Actually performs the write to fov memory.
        /// </summary>
        public void writeFOVToMemory()
        {
            // Find the proper value from degrees
            float targetRadians = (float)((double)numFoV.Value * Math.PI / 180);

            // Write the value to the vehicle and player FOV's
            HaloMemoryWriter.WriteToMemory((uint)HaloMemoryWriter.BaseAddress + MouseThingy.FOV_MULTIPLIER_OFFSET, BitConverter.GetBytes(targetRadians / MouseThingy.DEFAULT_RADIANS));
            HaloMemoryWriter.WriteToMemory((uint)HaloMemoryWriter.BaseAddress + MouseThingy.FOV_VEHICLE_MULTIPLIER_OFFSET, BitConverter.GetBytes(targetRadians / MouseThingy.DEFAULT_RADIANS));
        }
Beispiel #6
0
        private void bnOk_Click(object sender, System.EventArgs e)
        {
            byte[] data = null;


            if (dataList.SelectedItem == null)
            {
                return;
            }

            switch (dataList.SelectedItem.ToString())
            {
            case "Int":
                int unconvertedInt;
                if (int.TryParse(tbData.Text, out unconvertedInt))
                {
                    data = BitConverter.GetBytes(unconvertedInt);
                }
                break;

            case "String":
                char[] unconvertedString = tbData.Text.ToCharArray();
                data = Encoding.UTF8.GetBytes(unconvertedString);
                break;

            case "Float":
                float unconvertedFloat;
                if (float.TryParse(tbData.Text, out unconvertedFloat))
                {
                    data = BitConverter.GetBytes(unconvertedFloat);
                }
                break;

            default:
                MessageBox.Show("Please select a valid type!");
                return;
            }

            if (data == null)
            {
                MessageBox.Show("Couldn't parse data!");
                return;
            }

            uint memAddr;

            if (!uint.TryParse(tbAddress.Text, out memAddr))
            {
                MessageBox.Show("Couldn't parse address!");
                return;
            }

            MessageBox.Show(HaloMemoryWriter.WriteToMemory(memAddr, data).ToString());
        }
Beispiel #7
0
        /// <summary>
        /// Actually performs the write to crosshair offset memory.
        /// </summary>
        public void writeCrosshairOffsetToMemory()
        {
            // Read the address the pointer is pointing to
            uint crosshairOffsetAddress = (uint)HaloMemoryWriter.BaseAddress.ToInt32() + MouseThingy.CROSSHAIR_OFFSET_POINTER;

            byte[] crosshairOffsetData = new byte[4];
            // Offset that address by the crosshair offset
            HaloMemoryWriter.ReadFromMemory(crosshairOffsetAddress, crosshairOffsetData);
            // Write the current crosshair offset to that memory address
            HaloMemoryWriter.WriteToMemory((uint)((uint)(BitConverter.ToInt32(crosshairOffsetData, 0)) + MouseThingy.CROSSHAIR_OFFSET_POINTER_OFFSET), BitConverter.GetBytes((float)numViewOffset.Value));
        }
Beispiel #8
0
        private static void UpdateMouse(object thing)
        {
            Vector2 newMousePos;

            GetCursorPos(out newMousePos);
            Vector2 mouseDelta = newMousePos - oldMousePos;

            // Update halo view angle here
            float hmul;

            if (_f.GetHMul(out hmul))
            {
                float h_delta = mouseDelta.X * hmul;

                byte[] temp = new byte[4];
                uint   h_addr;
                if (_f.GetHAddr(out h_addr))
                {
                    HaloMemoryWriter.ReadFromMemory(h_addr, temp);
                    float h_prev = BitConverter.ToSingle(temp, 0);
                    h_prev -= h_delta;
                    h_prev  = h_prev % (float)(2 * Math.PI);
                    temp    = BitConverter.GetBytes(h_prev);
                    HaloMemoryWriter.WriteToMemory(h_addr, temp);
                }
            }

            float vmul;

            if (_f.GetVMul(out vmul))
            {
                float v_delta = mouseDelta.Y * vmul;

                byte[] temp = new byte[4];
                uint   v_addr;
                if (_f.GetVAddr(out v_addr))
                {
                    HaloMemoryWriter.ReadFromMemory(v_addr, temp);
                    float v_prev = BitConverter.ToSingle(temp, 0);
                    v_prev += v_delta;
                    v_prev  = (float)(((v_prev + (Math.PI / 2)) % Math.PI) - (Math.PI / 2));
                    temp    = BitConverter.GetBytes(v_prev);
                    HaloMemoryWriter.WriteToMemory(v_addr, temp);
                }
            }

            oldMousePos = newMousePos;
        }
Beispiel #9
0
        /// <summary>
        /// Gets all the processes and adds them to the dropdown list
        /// </summary>
        private void UpdateProcesses()
        {
            lstProcessList.SuspendLayout();
            lstProcessList.Items.Clear();
            List <string> processNames = HaloMemoryWriter.GetProcessNames();

            for (int i = 0; i < processNames.Count; i++)
            {
                lstProcessList.Items.Add(processNames[i]);
                if (processNames[i] == "halo2")
                {
                    if (HaloMemoryWriter.TryConnectToProcess(processNames[i]))
                    {
                        lstProcessList.SelectedIndex = i;
                    }
                }
            }
            lstProcessList.ResumeLayout();
        }
Beispiel #10
0
        private void UpdateProcesses()
        {
            processList.Items.Clear();

            HaloMemoryWriter.GetProcessNames().ForEach((string name) => processList.Items.Add(name));
        }
Beispiel #11
0
        private static void UpdateMouse(object thing)
        {
            if (!HaloMemoryWriter.IsForegrounded())
            {
                return;
            }
            CURSORINFO pci;

            pci.cbSize = Marshal.SizeOf(typeof(CURSORINFO));
            GetCursorInfo(out pci);
            if (pci.flags == 1)
            {
                return;
            }

            Vector2 newMousePos;

            GetCursorPos(out newMousePos);
            Vector2 mouseDelta = newMousePos - oldMousePos;

            byte[] currentFovBytes = new byte[4];
            HaloMemoryWriter.ReadFromMemory((uint)HaloMemoryWriter.BaseAddress + MouseThingy.CURRENT_FOV_OFFSET, currentFovBytes);
            float currentFoV = BitConverter.ToSingle(currentFovBytes, 0);

            // Update halo view angle here
            float hmul;

            if (MouseThingy.MainForm.GetHMul(out hmul))
            {
                float horizontalDelta = mouseDelta.X * hmul * currentFoV / MouseThingy.SensitivityDivisor;

                byte[] temp = new byte[4];
                uint   horizontalAddress;
                if (MouseThingy.MainForm.GetHAddr(out horizontalAddress))
                {
                    HaloMemoryWriter.ReadFromMemory(horizontalAddress, temp);
                    float horizontalPrevious = BitConverter.ToSingle(temp, 0);
                    horizontalPrevious -= horizontalDelta;
                    horizontalPrevious  = horizontalPrevious % (float)(2 * Math.PI);
                    temp = BitConverter.GetBytes(horizontalPrevious);
                    HaloMemoryWriter.WriteToMemory(horizontalAddress, temp);
                }
            }

            float vmul;

            if (MouseThingy.MainForm.GetVMul(out vmul))
            {
                float verticalDelta = mouseDelta.Y * -vmul * currentFoV / MouseThingy.SensitivityDivisor;

                byte[] temp = new byte[4];
                uint   verticalAddress;
                if (MouseThingy.MainForm.GetVAddr(out verticalAddress))
                {
                    HaloMemoryWriter.ReadFromMemory(verticalAddress, temp);
                    float verticalPrevious = BitConverter.ToSingle(temp, 0);
                    verticalPrevious += verticalDelta;
                    if (verticalPrevious > MAXIMUM_VERTICAL_VIEW_ANGLE)
                    {
                        verticalPrevious = MAXIMUM_VERTICAL_VIEW_ANGLE;
                    }
                    else if (verticalPrevious < -MAXIMUM_VERTICAL_VIEW_ANGLE)
                    {
                        verticalPrevious = -MAXIMUM_VERTICAL_VIEW_ANGLE;
                    }
                    verticalPrevious = (float)(((verticalPrevious + (Math.PI / 2)) % Math.PI) - (Math.PI / 2));
                    temp             = BitConverter.GetBytes(verticalPrevious);
                    HaloMemoryWriter.WriteToMemory(verticalAddress, temp);
                }
            }

            // Center Cursor on same monitor as process
            Screen activeProcessScreen = Screen.FromHandle(HaloMemoryWriter.SelectedProcess.MainWindowHandle);

            oldMousePos = new Vector2((activeProcessScreen.Bounds.Width / 2) + activeProcessScreen.Bounds.X, (activeProcessScreen.Bounds.Height / 2) + activeProcessScreen.Bounds.Y);
            SetCursorPos(oldMousePos.X, oldMousePos.Y);

            // MouseThingy.MainForm.writeFOVToMemory();
            MouseThingy.MainForm.writeCrosshairOffsetToMemory();
        }
Beispiel #12
0
        private static void UpdateMouse(object thing)
        {
            Vector2 newMousePos;

            GetCursorPos(out newMousePos);
            Vector2 mouseDelta = newMousePos - oldMousePos;

            // Update halo view angle here
            float hmul;

            if (_f.GetHMul(out hmul))
            {
                float h_delta = mouseDelta.X * hmul;

                byte[] temp = new byte[4];
                uint   h_addr;
                if (_f.GetHAddr(out h_addr))
                {
                    HaloMemoryWriter.ReadFromMemory(h_addr, temp);
                    float h_prev = BitConverter.ToSingle(temp, 0);
                    h_prev -= h_delta;
                    h_prev  = h_prev % (float)(2 * Math.PI);
                    temp    = BitConverter.GetBytes(h_prev);
                    HaloMemoryWriter.WriteToMemory(h_addr, temp);
                }
            }

            float vmul;

            if (_f.GetVMul(out vmul))
            {
                float v_delta = mouseDelta.Y * -vmul;

                byte[] temp = new byte[4];
                uint   v_addr;
                if (_f.GetVAddr(out v_addr))
                {
                    HaloMemoryWriter.ReadFromMemory(v_addr, temp);
                    float v_prev = BitConverter.ToSingle(temp, 0);
                    v_prev += v_delta;
                    v_prev  = (float)(((v_prev + (Math.PI / 2)) % Math.PI) - (Math.PI / 2));
                    temp    = BitConverter.GetBytes(v_prev);
                    HaloMemoryWriter.WriteToMemory(v_addr, temp);
                }
            }

            oldMousePos = newMousePos;

            // Center cursor if not minimized
            if (!HaloMemoryWriter.IsWindowMinimized())
            {
                SetCursorPos(Screen.PrimaryScreen.Bounds.Width / 2, Screen.PrimaryScreen.Bounds.Height / 2);
            }

            oldMousePos = new Vector2(Screen.PrimaryScreen.Bounds.Width / 2, Screen.PrimaryScreen.Bounds.Height / 2);

            uint fovAddr;

            if (_f.GetFovAddr(out fovAddr))
            {
                byte[] fovdata = new byte[4];
                HaloMemoryWriter.ReadFromMemory(fovAddr, fovdata);
                float fov = BitConverter.ToSingle(fovdata, 0);
                _f.SetFovText(fov);
            }
        }
Beispiel #13
0
        private static void UpdateMouse(object thing)
        {
            // If the process isn't focused, don't bother updating the mouse
            if (!HaloMemoryWriter.IsForegrounded())
            {
                return;
            }

            CURSORINFO pci;

            pci.cbSize = Marshal.SizeOf(typeof(CURSORINFO));
            GetCursorInfo(out pci);
            // If the cursor is visible, we don't want to update the position or center the mouse, so exit
            if (pci.flags == 1)
            {
                return;
            }

            Vector2 newMousePos;

            GetCursorPos(out newMousePos);
            Vector2 mouseDelta = newMousePos - oldMousePos;

            byte[] currentFovBytes = new byte[4];
            HaloMemoryWriter.ReadFromMemory((uint)HaloMemoryWriter.BaseAddress + MouseThingy.CURRENT_FOV_OFFSET, currentFovBytes);
            float currentFoV = BitConverter.ToSingle(currentFovBytes, 0);

            // Update halo view angle here
            float horizontalSensitivity = MouseThingy.MainForm.GetHMul();
            // Calculate the new horizontal delta based
            float horizontalDelta = mouseDelta.X * horizontalSensitivity * currentFoV / MouseThingy.SensitivityDivisor;

            uint horizontalAddress;

            if (MouseThingy.MainForm.GetHAddr(out horizontalAddress))
            {
                byte[] temp = new byte[4];
                HaloMemoryWriter.ReadFromMemory(horizontalAddress, temp);
                float horizontalPrevious = BitConverter.ToSingle(temp, 0);
                horizontalPrevious -= horizontalDelta;
                horizontalPrevious  = horizontalPrevious % (float)(2 * Math.PI);
                temp = BitConverter.GetBytes(horizontalPrevious);
                HaloMemoryWriter.WriteToMemory(horizontalAddress, temp);
            }

            float verticalSensitivity = MouseThingy.MainForm.GetVMul();
            float verticalDelta       = mouseDelta.Y * -verticalSensitivity * currentFoV / MouseThingy.SensitivityDivisor;

            uint verticalAddress;

            if (MouseThingy.MainForm.GetVAddr(out verticalAddress))
            {
                byte[] temp = new byte[4];
                HaloMemoryWriter.ReadFromMemory(verticalAddress, temp);
                float verticalPrevious = BitConverter.ToSingle(temp, 0);
                verticalPrevious += verticalDelta;
                // Maximum view angle fix
                // This works because we know based on the delta if we're going to wrap around so we never let that happen
                if (verticalPrevious > MouseThingy.MAXIMUM_VERTICAL_VIEW_ANGLE)
                {
                    verticalPrevious = MouseThingy.MAXIMUM_VERTICAL_VIEW_ANGLE;
                }
                else if (verticalPrevious < -MouseThingy.MAXIMUM_VERTICAL_VIEW_ANGLE)
                {
                    verticalPrevious = -MouseThingy.MAXIMUM_VERTICAL_VIEW_ANGLE;
                }
                verticalPrevious = (float)(((verticalPrevious + (Math.PI / 2)) % Math.PI) - (Math.PI / 2));
                temp             = BitConverter.GetBytes(verticalPrevious);
                HaloMemoryWriter.WriteToMemory(verticalAddress, temp);
            }

            // Center Cursor on same monitor as process
            Screen activeProcessScreen = Screen.FromHandle(HaloMemoryWriter.SelectedProcess.MainWindowHandle);

            oldMousePos = new Vector2((activeProcessScreen.Bounds.Width / 2) + activeProcessScreen.Bounds.X, (activeProcessScreen.Bounds.Height / 2) + activeProcessScreen.Bounds.Y);
            SetCursorPos(oldMousePos.X, oldMousePos.Y);

            // MouseThingy.MainForm.writeFOVToMemory();

            // Write the crosshair offset to memory every frame
            // TODO: This does not need to happen every frame. In fact, this should happen very rarely.
            MouseThingy.MainForm.writeCrosshairOffsetToMemory();
        }