Пример #1
0
        private static T Read <T>(this MemorySharp _mem, bool isRelative = false, params IntPtr[] addresses)
        {
            if (addresses.Length == 0)
            {
                throw new InvalidOperationException("Cannot read a value from unspecified addresses.");
            }

            if (addresses.Length == 1)
            {
                return(_mem.Read <T>(addresses[0], isRelative));
            }

            var temp = _mem.Read <IntPtr>(addresses[0], isRelative);

            if (temp == IntPtr.Zero)
            {
                throw new InvalidOperationException("First addresses returned 0");
            }

            for (var i = 1; i < addresses.Length - 1; i++)
            {
                temp = _mem.Read <IntPtr>(temp + (int)addresses[i], isRelative);
            }
            return(_mem.Read <T>(temp + (int)addresses[addresses.Length - 1], isRelative));
        }
Пример #2
0
        public object GetValueFromPtr(MemorySharp m, IntPtr adr)
        {
            string result = "ERROR";

            try
            {
                if (retHEX.Checked)
                {
                    result = "0x" + m.Read <int>(adr, false).ToString("X4");
                }
                if (retINT.Checked)
                {
                    result = m.Read <int>(adr, false).ToString();
                }
                if (retUINT.Checked)
                {
                    result = m.Read <uint>(adr, false).ToString();
                }
                if (retFLOAT.Checked)
                {
                    result = m.Read <float>(adr, false).ToString();
                }
                if (retSTRING.Checked)
                {
                    result = m.ReadString(adr, false);
                }
            }
            catch { }
            return(result);
        }
Пример #3
0
#pragma warning restore AsyncFixer01 // Unnecessary async/await usage

        private static byte[] ReadSessionKeyFromProcessMemory(string processId)
        {
            using (MemorySharp memorySharpProvider = new MemorySharp(Int32.Parse(processId)))
            {
                IntPtr sub_6B0970Result  = memorySharpProvider.Read <IntPtr>((IntPtr)0x00C79CF4, false);
                IntPtr sessionKeyAddress = sub_6B0970Result + 0x508;
                return(memorySharpProvider.Read <byte>(sessionKeyAddress, 40, false));
            }
        }
Пример #4
0
        public void SingleEntity(int entityId)
        {
            if (!_process.IsRunning)
            {
                throw new SharpAimException("Game is not running, please start the game.");
            }

            try
            {
                // Get the address for our Entities
                EntityAddr = _process["client.dll"].Read <int>(Base.MainOffsets.EntityList + ((entityId - 1) * 0x10));

                // Update
                Health       = _process.Read <int>(new IntPtr(EntityAddr) + (int)Base.EntityOffsets.Health, false);
                ActiveWeapon = _process.Read <byte>(new IntPtr(EntityAddr) + (int)Base.EntityOffsets.ActiveWeapon, false);
                Team         = _process.Read <byte>(new IntPtr(EntityAddr) + (int)Base.EntityOffsets.Team, false);
                Dormant      = _process.Read <byte>(new IntPtr(EntityAddr) + (int)Base.EntityOffsets.Dormant, false);
                Spotted      = _process.Read <byte>(new IntPtr(EntityAddr) + (int)Base.EntityOffsets.Spotted, false);
                Name         = GetPlayerName(entityId);

                Position.X = _process.Read <float>(new IntPtr(EntityAddr) + (int)Base.EntityOffsets.Position, false);
                Position.Z = _process.Read <float>(new IntPtr(EntityAddr) + (int)Base.EntityOffsets.Position + 0x04, false);
                Position.Y = _process.Read <float>(new IntPtr(EntityAddr) + (int)Base.EntityOffsets.Position + 0x08, false);
            }
            catch (Exception e)
            {
                Console.WriteLine($"Exception caught: {e}");
            }
        }
Пример #5
0
        public NameWakeupData GetDummy()
        {
            var index = _memorySharp.Read <byte>(_p2IdOffset);

            var result = _nameWakeupDataList[index];

            return(result);
        }
Пример #6
0
 public static int GetFPS()
 {
     using (var m = new MemorySharp(getProcess()))
     {
         var   fpsPtr   = new IntPtr(0x34B8C50);
         int[] integers = m.Read <int>(fpsPtr, 1);
         int   math     = 1000000 / integers[0];
         return(math);
     }
 }
Пример #7
0
        public Form1()
        {
            InitializeComponent();
            initMemory();
            if (isDDRunning())
            {
                numericUpDown_fov.Value = m.Read <int>(new IntPtr(pFov + OFFSET_FOV), false);
            }

            numericUpDown_fov.Enabled = isDDRunning();
        }
Пример #8
0
        private void initMemory()
        {
            dd = findProcess("dd");
            if (dd == null)
            {
                return;
            }
            m = new MemorySharp(dd);

            if (pFov == -1)
            {
                pFov = m.Read <int>(new IntPtr(0x1F4AA0), true);
            }
        }
Пример #9
0
 public static int ReadStaticInt(int playerNumber)
 {
     try
     {
         if (playerNumber == 1)
         {
             return(_memorySharp.Read <int>(_p1CharIndex));
         }
         else if (playerNumber == 2)
         {
             return(_memorySharp.Read <int>(_p2CharIndex));
         }
         else
         {
             return(0);
         }
     }
     catch (System.ArgumentException)
     {
         Dispose();
         return(0);
     }
 }
Пример #10
0
        static void Main(string[] args)
        {
            Console.Write("Enter Warcraft ProcessId: ");
            string processId = Console.ReadLine();

            //TODO: Move this into a provider or something. We want to support several clients/offsets
            using (MemorySharp memorySharpProvider = new MemorySharp(int.Parse(processId)))
            {
                //This returns out of the ARC4_Process functions by jumping accross the ARC4 logic into the final routine
                //memorySharpProvider.Assembly.Inject(new string[1] { "JMP 0x774EBE" }, (IntPtr)(0x00774EA0 + 0x11));
                //memorySharpProvider.Assembly.Inject(new string[1] { "JMP 0x774FD3" }, (IntPtr)(0x00774EA0 + 0x3B)); //short circuit ARC4 with jump
                //memorySharpProvider.Assembly.Inject(new string[1] { "JMP 0x775025" }, (IntPtr)(0x00774EA0 + 0x138));

                //memorySharpProvider.Assembly.Inject(new string[2] { "push ebp", "mov [ebp + 0x14], [ebp + 0x10]" }, (IntPtr)(0x00774EA0));

                //memorySharpProvider.Assembly.Inject(new string[] {"JMP 0x632BFB"}, (IntPtr)0x632B50 + 0x9D);
                //memorySharpProvider.Assembly.Inject(new string[] { "JMP 0x632BFB" }, (IntPtr)0x632B50 + 0x1E);
                //memorySharpProvider.Assembly.Inject(new string[] { "JMP 0x632BFD" }, (IntPtr)0x632B50 + 0xD);
                //memorySharpProvider.Assembly.Inject(new string[] { "JMP 0x466C05" }, (IntPtr)0x466BF0 + 0x13);

                //memorySharpProvider.Assembly.Inject(new string[] { "JMP 0x406F79" }, (IntPtr)0x406F40 + 0xA);

                //
                //memorySharpProvider.Assembly.Inject(new string[] { "JMP 0x632BFD" }, (IntPtr)0x632B50 + 0x9D);

                //memorySharpProvider.Assembly.Inject(new string[] { "JMP short 0x4678CA" }, (IntPtr)0x4675F0 + 0x2AE);
                IntPtr sub_6B0970Result  = memorySharpProvider.Read <IntPtr>((IntPtr)0x00C79CF4, false);
                IntPtr sessionKeyAddress = sub_6B0970Result + 0x508;
                byte[] key = memorySharpProvider.Read <byte>(sessionKeyAddress, 40, false);
                Console.WriteLine($"{nameof(sub_6B0970Result)}: {sub_6B0970Result}");

                Console.WriteLine($"Key: {key.Aggregate("", (s, b) => $"{s} {b}")}");
            }

            Console.WriteLine("Patched. Press any key.");
            Console.ReadKey();
        }
Пример #11
0
        public void Update()
        {
            if (!_process.IsRunning)
            {
                throw new SharpAimException("Game is not running, please start the game.");
            }

            // Get the LocalPlayer address
            LocalPlayer = _process["client.dll"].Read <int>(Base.MainOffsets.LocalPlayer);

            // Update
            Health        = _process.Read <int>(new IntPtr(LocalPlayer) + (int)Base.EntityOffsets.Health, false);
            ActiveWeapon  = _process.Read <byte>(new IntPtr(LocalPlayer) + (int)Base.EntityOffsets.ActiveWeapon, false);
            Team          = _process.Read <byte>(new IntPtr(LocalPlayer) + (int)Base.EntityOffsets.Team, false);
            Position.X    = _process.Read <float>(new IntPtr(LocalPlayer) + (int)Base.EntityOffsets.Position, false);
            Position.Z    = _process.Read <float>(new IntPtr(LocalPlayer) + (int)Base.EntityOffsets.Position + 0x04, false);
            Position.Y    = _process.Read <float>(new IntPtr(LocalPlayer) + (int)Base.EntityOffsets.Position + 0x08, false);
            IsInCrosshair = _process.Read <byte>(new IntPtr(LocalPlayer) + (int)Base.EntityOffsets.CrosshairId, false);
        }
Пример #12
0
        public void InitializeMemory(Process p, string Hack)
        {
            Memory = new MemorySharp(p);
            CleanUpMememory();

            var injected = Memory.Read <byte>((IntPtr)0x00567FB0, false);

            if (injected == 85)
            {
                var HackModule = Memory.Modules.Inject(Hack);
                if (HackModule.IsValid)
                {
                    Console.Beep();
                }

                GameClient.Hack = Hack;
            }
        }
Пример #13
0
        public void InitializeMemory(Process p, string Hack)
        {
            Console.WriteLine("InitializeMemory(Process p, string Hack)");
            Memory = new MemorySharp(p);

            var injected = Memory.Read <byte>((IntPtr)DAStaticPointers.ETDA, false);

            if (injected == 85)
            {
                var HackModule = Memory.Modules.Inject(Hack);
                if (HackModule.IsValid)
                {
                    Console.Beep();
                }

                GameClient.Hack = Hack;
            }
        }
Пример #14
0
        public GameInstance(Process process)
        {
            Process = process;
            Memory  = new MemorySharp(process);

            // Initialize the base pointer, by getting it from the static offset.
            IntPtr baseStaticAddress = new IntPtr((int)Offsets.Base1);
            IntPtr basePtr           = (IntPtr)Memory.Read <int>(baseStaticAddress);

            BasePointer = Memory[basePtr, false];

            //DLLs.Injector.Inject(process, Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DLLs", "SpeedRacer.dll"));
            //DLLs.Injector.Inject(process, Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "EasyHook32.dll"));
            Memory.Modules.Inject(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "EasyHook32.dll"));
            //DLLs.Injector.Inject(process, Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SpeedRacer.dll"));
            Module = Memory.Modules.Inject(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SpeedRacer.dll"));
            Module.FindFunction("HookFunctions").Execute();
            Thread.Sleep(1000);
        }
Пример #15
0
 private void btnSaveRecording_Click(object sender, EventArgs e)
 {
     using (MemorySharp sharp = new MemorySharp(process))
     {
         var recording = sharp.Read <byte>(recordingOffset, 14406);
         using (var dialog = new SaveFileDialog
         {
             Filter = "Dummy Recording|*.acrdummy",
             Title = "Save the current dummy recording",
             RestoreDirectory = true
         })
         {
             if (dialog.ShowDialog() == DialogResult.OK)
             {
                 File.WriteAllBytes(dialog.FileName, recording);
             }
         }
     }
 }
Пример #16
0
        /// <summary>
        ///     Performs a pattern scan.
        /// </summary>
        /// <param name="pattern">The byte array that contains the pattern of bytes we're looking for.</param>
        /// <param name="mask">
        ///     The mask that defines the byte pattern we are searching for.
        ///     <example>
        ///         <code>
        /// var bytes = new byte[]{55,45,00,00,55} ;
        /// var mask = "xx??x";
        /// </code>
        ///     </example>
        /// </param>
        /// <param name="offsetToAdd">The offset to add to the offset result found from the pattern.</param>
        /// <param name="rebaseResult">
        ///     If the final address result should be rebased to the base address of the
        ///     <see cref="ProcessModule" /> the pattern data resides in.
        /// </param>
        /// <returns>A new <see cref="PatternScanResult" /> instance.</returns>
        public PatternScanResult FindPattern(byte[] pattern, string mask, int offsetToAdd, bool rebaseResult)
        {
            for (var offset = 0; offset < Data.Length; offset++)
            {
                if (mask.Where((m, b) => m == 'x' && pattern[b] != Data[b + offset]).Any())
                {
                    continue;
                }

                var found = MemorySharp.Read <IntPtr>(BaseAddress + offset + offsetToAdd);

                var result = new PatternScanResult
                {
                    OriginalAddress = found,
                    Address         = rebaseResult ? found : IntPtr.Subtract(found, (int)BaseAddress),
                    Offset          = (IntPtr)offset
                };

                return(result);
            }
            throw new Exception("Could not find the pattern.");
        }
Пример #17
0
        /// <summary>
        /// Reads the user struct.
        /// </summary>
        /// <param name="sharp">The memory sharp instance</param>
        /// <param name="address">The address of the player</param>
        public void Read(MemorySharp sharp, IntPtr address)
        {
            // Read the position of the user
            PosX = sharp.Read <float>(address + 0xD0, false);
            PosY = sharp.Read <float>(address + 0xD4, false);
            PosZ = sharp.Read <float>(address + 0xD8, false);
            Map  = sharp.Read <ushort>(address + 0x160, false);

            // Read the character id
            CharId = sharp.Read <uint>(address + 0x128, false);

            // Read the character name
            var nameBytes = sharp.Read <byte>(address + 0x184, 21, false);

            Name = Encoding.ASCII.GetString(nameBytes);
            Name = Name.Trim('\0');
        }
Пример #18
0
        private void tmr_ReadPad_Tick(object sender, EventArgs e)
        {
            if (controllerConnected)
            {
                if (pcsx2Running)
                {
                    long   pcsx2Offset = GameHelper.GetPcsx2Offset(pcsx2);
                    IntPtr pcsx2Intptr = new IntPtr(pcsx2Offset);

                    m = new MemorySharp(pcsx2);

                    int luiHeap = 0;
                    try
                    {
                        luiHeap = m.Read <byte>(IntPtr.Add(pcsx2Intptr, GameHelper.LUI_HEAP_OFFSET), false);
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show("Make sure the game is running before starting the application \n Closing");
                        this.Close();
                    }


                    if (GameHelper.GetCurrentElfFile(luiHeap) == GameHelper.CurrentElf.ONLINE)
                    {
                        gGameOffset = m.Read <int>(IntPtr.Add(pcsx2Intptr, GameHelper.ONLINE_PLAYER_POINTER_OFFSET), false) + pcsx2Offset;
                        if (m.Read <int>(IntPtr.Add(pcsx2Intptr, GameHelper.CONNECTED_TO_AS_ADDRESS_OFFSET), false) == 1)
                        {
                            var state = controller.GetState();

                            var buttonsPressed = state.Gamepad.Buttons;

                            if (buttonsPressed.HasFlag(GamepadButtonFlags.LeftShoulder))
                            {
                                if (pressedInit == false)
                                {
                                    pct_TriggerButton.Image = Properties.Resources.L1;
                                    pnl_Buttons.Visible     = true;
                                    processGameData(GameHelper.SHORTCUT_L1_CIRCLE_TYPE_ID, GameHelper.SHORTCUT_L1_TRIANGLE_TYPE_ID, GameHelper.SHORTCUT_L1_SQUARE_TYPE_ID,
                                                    GameHelper.SHORTCUT_L1_X_TYPE_ID, GameHelper.SHORTCUT_L1_CIRCLE_CATEGORY_ID, GameHelper.SHORTCUT_L1_TRIANGLE_CATEGORY_ID,
                                                    GameHelper.SHORTCUT_L1_SQUARE_CATEGORY_ID, GameHelper.SHORTCUT_L1_X_CATEGORY_ID, GameHelper.SHORTCUT_L1_CIRCLE_ID,
                                                    GameHelper.SHORTCUT_L1_TRIANGLE_ID, GameHelper.SHORTCUT_L1_SQUARE_ID, GameHelper.SHORTCUT_L1_X_ID, GameHelper.SHORTCUT_L1_CIRCLE_MESSAGE,
                                                    GameHelper.SHORTCUT_L1_TRIANGLE_MESSAGE, GameHelper.SHORTCUT_L1_SQUARE_MESSAGE, GameHelper.SHORTCUT_L1_X_MESSAGE);


                                    pressedInit = true;
                                }
                            }
                            else if (state.Gamepad.LeftTrigger > 10)
                            {
                                if (pressedInit == false)
                                {
                                    pct_TriggerButton.Image = Properties.Resources.L2;
                                    pnl_Buttons.Visible     = true;
                                    processGameData(GameHelper.SHORTCUT_L2_CIRCLE_TYPE_ID, GameHelper.SHORTCUT_L2_TRIANGLE_TYPE_ID, GameHelper.SHORTCUT_L2_SQUARE_TYPE_ID,
                                                    GameHelper.SHORTCUT_L2_X_TYPE_ID, GameHelper.SHORTCUT_L2_CIRCLE_CATEGORY_ID, GameHelper.SHORTCUT_L2_TRIANGLE_CATEGORY_ID,
                                                    GameHelper.SHORTCUT_L2_SQUARE_CATEGORY_ID, GameHelper.SHORTCUT_L2_X_CATEGORY_ID, GameHelper.SHORTCUT_L2_CIRCLE_ID,
                                                    GameHelper.SHORTCUT_L2_TRIANGLE_ID, GameHelper.SHORTCUT_L2_SQUARE_ID, GameHelper.SHORTCUT_L2_X_ID, GameHelper.SHORTCUT_L2_CIRCLE_MESSAGE,
                                                    GameHelper.SHORTCUT_L2_TRIANGLE_MESSAGE, GameHelper.SHORTCUT_L2_SQUARE_MESSAGE, GameHelper.SHORTCUT_L2_X_MESSAGE);


                                    pressedInit = true;
                                }
                            }
                            else if (buttonsPressed.HasFlag(GamepadButtonFlags.RightShoulder))
                            {
                                if (pressedInit == false)
                                {
                                    pct_TriggerButton.Image = Properties.Resources.R1;
                                    pnl_Buttons.Visible     = true;
                                    processGameData(GameHelper.SHORTCUT_R1_CIRCLE_TYPE_ID, GameHelper.SHORTCUT_R1_TRIANGLE_TYPE_ID, GameHelper.SHORTCUT_R1_SQUARE_TYPE_ID,
                                                    GameHelper.SHORTCUT_R1_X_TYPE_ID, GameHelper.SHORTCUT_R1_CIRCLE_CATEGORY_ID, GameHelper.SHORTCUT_R1_TRIANGLE_CATEGORY_ID,
                                                    GameHelper.SHORTCUT_R1_SQUARE_CATEGORY_ID, GameHelper.SHORTCUT_R1_X_CATEGORY_ID, GameHelper.SHORTCUT_R1_CIRCLE_ID,
                                                    GameHelper.SHORTCUT_R1_TRIANGLE_ID, GameHelper.SHORTCUT_R1_SQUARE_ID, GameHelper.SHORTCUT_R1_X_ID, GameHelper.SHORTCUT_R1_CIRCLE_MESSAGE,
                                                    GameHelper.SHORTCUT_R1_TRIANGLE_MESSAGE, GameHelper.SHORTCUT_R1_SQUARE_MESSAGE, GameHelper.SHORTCUT_R1_X_MESSAGE);


                                    pressedInit = true;
                                }
                            }
                            else if (state.Gamepad.RightTrigger > 10)
                            {
                                if (pressedInit == false)
                                {
                                    pct_TriggerButton.Image = Properties.Resources.R2;
                                    pnl_Buttons.Visible     = true;
                                    processGameData(GameHelper.SHORTCUT_R2_CIRCLE_TYPE_ID, GameHelper.SHORTCUT_R2_TRIANGLE_TYPE_ID, GameHelper.SHORTCUT_R2_SQUARE_TYPE_ID,
                                                    GameHelper.SHORTCUT_R2_X_TYPE_ID, GameHelper.SHORTCUT_R2_CIRCLE_CATEGORY_ID, GameHelper.SHORTCUT_R2_TRIANGLE_CATEGORY_ID,
                                                    GameHelper.SHORTCUT_R2_SQUARE_CATEGORY_ID, GameHelper.SHORTCUT_R2_X_CATEGORY_ID, GameHelper.SHORTCUT_R2_CIRCLE_ID,
                                                    GameHelper.SHORTCUT_R2_TRIANGLE_ID, GameHelper.SHORTCUT_R2_SQUARE_ID, GameHelper.SHORTCUT_R2_X_ID, GameHelper.SHORTCUT_R2_CIRCLE_MESSAGE,
                                                    GameHelper.SHORTCUT_R2_TRIANGLE_MESSAGE, GameHelper.SHORTCUT_R2_SQUARE_MESSAGE, GameHelper.SHORTCUT_R2_X_MESSAGE);

                                    pressedInit = true;
                                }
                            }
                            else
                            {
                                pnl_Buttons.Visible = false;
                                pressedInit         = false;
                            }
                        }
                    }
                    if (GameHelper.GetCurrentElfFile(luiHeap) == GameHelper.CurrentElf.OFFLINE)
                    {
                        gGameOffset = m.Read <int>(IntPtr.Add(pcsx2Intptr, GameHelper.OFFLINE_PLAYER_POINTER_OFFSET), false) + pcsx2Offset;
                        if (m.Read <int>(IntPtr.Add(pcsx2Intptr, GameHelper.LOGGED_IN_OFFLINE_MODE_OFFSET), false) != 0)
                        {
                            var state = controller.GetState();

                            var buttonsPressed = state.Gamepad.Buttons;

                            if (buttonsPressed.HasFlag(GamepadButtonFlags.LeftShoulder))
                            {
                                if (pressedInit == false)
                                {
                                    pct_TriggerButton.Image = Properties.Resources.L1;
                                    pnl_Buttons.Visible     = true;
                                    processGameData(GameHelper.SHORTCUT_L1_CIRCLE_TYPE_ID, GameHelper.SHORTCUT_L1_TRIANGLE_TYPE_ID, GameHelper.SHORTCUT_L1_SQUARE_TYPE_ID,
                                                    GameHelper.SHORTCUT_L1_X_TYPE_ID, GameHelper.SHORTCUT_L1_CIRCLE_CATEGORY_ID, GameHelper.SHORTCUT_L1_TRIANGLE_CATEGORY_ID,
                                                    GameHelper.SHORTCUT_L1_SQUARE_CATEGORY_ID, GameHelper.SHORTCUT_L1_X_CATEGORY_ID, GameHelper.SHORTCUT_L1_CIRCLE_ID,
                                                    GameHelper.SHORTCUT_L1_TRIANGLE_ID, GameHelper.SHORTCUT_L1_SQUARE_ID, GameHelper.SHORTCUT_L1_X_ID, GameHelper.SHORTCUT_L1_CIRCLE_MESSAGE,
                                                    GameHelper.SHORTCUT_L1_TRIANGLE_MESSAGE, GameHelper.SHORTCUT_L1_SQUARE_MESSAGE, GameHelper.SHORTCUT_L1_X_MESSAGE);


                                    pressedInit = true;
                                }
                            }
                            else if (state.Gamepad.LeftTrigger > 10)
                            {
                                if (pressedInit == false)
                                {
                                    pct_TriggerButton.Image = Properties.Resources.L2;
                                    pnl_Buttons.Visible     = true;
                                    processGameData(GameHelper.SHORTCUT_L2_CIRCLE_TYPE_ID, GameHelper.SHORTCUT_L2_TRIANGLE_TYPE_ID, GameHelper.SHORTCUT_L2_SQUARE_TYPE_ID,
                                                    GameHelper.SHORTCUT_L2_X_TYPE_ID, GameHelper.SHORTCUT_L2_CIRCLE_CATEGORY_ID, GameHelper.SHORTCUT_L2_TRIANGLE_CATEGORY_ID,
                                                    GameHelper.SHORTCUT_L2_SQUARE_CATEGORY_ID, GameHelper.SHORTCUT_L2_X_CATEGORY_ID, GameHelper.SHORTCUT_L2_CIRCLE_ID,
                                                    GameHelper.SHORTCUT_L2_TRIANGLE_ID, GameHelper.SHORTCUT_L2_SQUARE_ID, GameHelper.SHORTCUT_L2_X_ID, GameHelper.SHORTCUT_L2_CIRCLE_MESSAGE,
                                                    GameHelper.SHORTCUT_L2_TRIANGLE_MESSAGE, GameHelper.SHORTCUT_L2_SQUARE_MESSAGE, GameHelper.SHORTCUT_L2_X_MESSAGE);


                                    pressedInit = true;
                                }
                            }
                            else if (buttonsPressed.HasFlag(GamepadButtonFlags.RightShoulder))
                            {
                                if (pressedInit == false)
                                {
                                    pct_TriggerButton.Image = Properties.Resources.R1;
                                    pnl_Buttons.Visible     = true;
                                    processGameData(GameHelper.SHORTCUT_R1_CIRCLE_TYPE_ID, GameHelper.SHORTCUT_R1_TRIANGLE_TYPE_ID, GameHelper.SHORTCUT_R1_SQUARE_TYPE_ID,
                                                    GameHelper.SHORTCUT_R1_X_TYPE_ID, GameHelper.SHORTCUT_R1_CIRCLE_CATEGORY_ID, GameHelper.SHORTCUT_R1_TRIANGLE_CATEGORY_ID,
                                                    GameHelper.SHORTCUT_R1_SQUARE_CATEGORY_ID, GameHelper.SHORTCUT_R1_X_CATEGORY_ID, GameHelper.SHORTCUT_R1_CIRCLE_ID,
                                                    GameHelper.SHORTCUT_R1_TRIANGLE_ID, GameHelper.SHORTCUT_R1_SQUARE_ID, GameHelper.SHORTCUT_R1_X_ID, GameHelper.SHORTCUT_R1_CIRCLE_MESSAGE,
                                                    GameHelper.SHORTCUT_R1_TRIANGLE_MESSAGE, GameHelper.SHORTCUT_R1_SQUARE_MESSAGE, GameHelper.SHORTCUT_R1_X_MESSAGE);


                                    pressedInit = true;
                                }
                            }
                            else if (state.Gamepad.RightTrigger > 10)
                            {
                                if (pressedInit == false)
                                {
                                    pct_TriggerButton.Image = Properties.Resources.R2;
                                    pnl_Buttons.Visible     = true;
                                    processGameData(GameHelper.SHORTCUT_R2_CIRCLE_TYPE_ID, GameHelper.SHORTCUT_R2_TRIANGLE_TYPE_ID, GameHelper.SHORTCUT_R2_SQUARE_TYPE_ID,
                                                    GameHelper.SHORTCUT_R2_X_TYPE_ID, GameHelper.SHORTCUT_R2_CIRCLE_CATEGORY_ID, GameHelper.SHORTCUT_R2_TRIANGLE_CATEGORY_ID,
                                                    GameHelper.SHORTCUT_R2_SQUARE_CATEGORY_ID, GameHelper.SHORTCUT_R2_X_CATEGORY_ID, GameHelper.SHORTCUT_R2_CIRCLE_ID,
                                                    GameHelper.SHORTCUT_R2_TRIANGLE_ID, GameHelper.SHORTCUT_R2_SQUARE_ID, GameHelper.SHORTCUT_R2_X_ID, GameHelper.SHORTCUT_R2_CIRCLE_MESSAGE,
                                                    GameHelper.SHORTCUT_R2_TRIANGLE_MESSAGE, GameHelper.SHORTCUT_R2_SQUARE_MESSAGE, GameHelper.SHORTCUT_R2_X_MESSAGE);

                                    pressedInit = true;
                                }
                            }
                            else
                            {
                                pnl_Buttons.Visible = false;
                                pressedInit         = false;
                            }
                        }
                    }
                }
            }
        }
Пример #19
0
 private void TeleportToDestination()
 {
     if (GameProcess != null)
     {
         if (GameProcess.IsRunning == true)
         {
             PointerAddress = GameProcess.Read <int>(CharacterPointers.CurrentCharacter);
             if (PointerAddress != 0)
             {
                 GameProcess.Write <float>((IntPtr)(PointerAddress + (int)CharacterPointerOffsets.XVelocity), CurrentWarps[MenuWarpIndex].XVelocity, false);
                 GameProcess.Write <float>((IntPtr)(PointerAddress + (int)CharacterPointerOffsets.YVelocity), CurrentWarps[MenuWarpIndex].YVelocity, false);
                 GameProcess.Write <float>((IntPtr)(PointerAddress + (int)CharacterPointerOffsets.ZVelocity), CurrentWarps[MenuWarpIndex].ZVelocity, false);
                 GameProcess.Write <float>((IntPtr)(PointerAddress + (int)CharacterPointerOffsets.XPosition), CurrentWarps[MenuWarpIndex].XPosition, false);
                 GameProcess.Write <float>((IntPtr)(PointerAddress + (int)CharacterPointerOffsets.YPosition), CurrentWarps[MenuWarpIndex].YPosition, false);
                 GameProcess.Write <float>((IntPtr)(PointerAddress + (int)CharacterPointerOffsets.ZPosition), CurrentWarps[MenuWarpIndex].ZPosition, false);
                 GameProcess.Write <ushort>((IntPtr)(PointerAddress + (int)CharacterPointerOffsets.XRotation), CurrentWarps[MenuWarpIndex].XRotation, false);
                 GameProcess.Write <ushort>((IntPtr)(PointerAddress + (int)CharacterPointerOffsets.YRotation), CurrentWarps[MenuWarpIndex].YRotation, false);
                 GameProcess.Write <ushort>((IntPtr)(PointerAddress + (int)CharacterPointerOffsets.ZRotation), CurrentWarps[MenuWarpIndex].ZRotation, false);
                 GameProcess.Write <float>((IntPtr)(PointerAddress + (int)CharacterPointerOffsets.XCharacterThickness), CurrentWarps[MenuWarpIndex].XCharacterThickness, false);
                 GameProcess.Write <float>((IntPtr)(PointerAddress + (int)CharacterPointerOffsets.YCharacterThickness), CurrentWarps[MenuWarpIndex].YCharacterThickness, false);
                 GameProcess.Write <float>((IntPtr)(PointerAddress + (int)CharacterPointerOffsets.TeamMatesFollowingSomething), CurrentWarps[MenuWarpIndex].TeamMatesFollowingSomething, false);
                 GameProcess.Write <float>((IntPtr)(PointerAddress + (int)CharacterPointerOffsets.TeamMatesFollowingSomething2), CurrentWarps[MenuWarpIndex].TeamMatesFollowingSomething2, false);
                 GameProcess.Write <float>((IntPtr)(PointerAddress + (int)CharacterPointerOffsets.TeamMatesFollowingSomething3), CurrentWarps[MenuWarpIndex].TeamMatesFollowingSomething3, false);
             }
         }
     }
 }
Пример #20
0
        private void processGameData(string cirTypeIDAddress, string triTypeIDAddress, string sqTypeIDAddress, string xTypeIDAddress,
                                     string cirCatIDAddress, string triCatIDAddress, string sqCatIDAddress, string xCatIDAddress, string cirIDAddress, string triIDAddress,
                                     string sqIDAddress, string xIDAddress, string cirMessageAddress, string triMessageAddress, string sqMessageAddress, string xMessageAddress)
        {
            int             circleTypeID       = m.Read <byte>(CalculateNewAddress(cirTypeIDAddress, gGameOffset), false);
            int             triangleTypeID     = m.Read <byte>(CalculateNewAddress(triTypeIDAddress, gGameOffset), false);
            int             squareTypeID       = m.Read <byte>(CalculateNewAddress(sqTypeIDAddress, gGameOffset), false);
            int             crossTypeID        = m.Read <byte>(CalculateNewAddress(xTypeIDAddress, gGameOffset), false);
            string          circleCategoryID   = m.Read <byte>(CalculateNewAddress(cirCatIDAddress, gGameOffset), false).ToString("X1");
            string          triangleCategoryID = m.Read <byte>(CalculateNewAddress(triCatIDAddress, gGameOffset), false).ToString("X1");
            string          squareCategoryID   = m.Read <byte>(CalculateNewAddress(sqCatIDAddress, gGameOffset), false).ToString("X1");
            string          crossCategoryID    = m.Read <byte>(CalculateNewAddress(xCatIDAddress, gGameOffset), false).ToString("X1");
            string          circleID           = m.Read <short>(CalculateNewAddress(cirIDAddress, gGameOffset), false).ToString("X4");
            string          triangleID         = m.Read <short>(CalculateNewAddress(triIDAddress, gGameOffset), false).ToString("X4");
            string          squareID           = m.Read <short>(CalculateNewAddress(sqIDAddress, gGameOffset), false).ToString("X4");
            string          crossID            = m.Read <short>(CalculateNewAddress(xIDAddress, gGameOffset), false).ToString("X4");
            string          circleMessage      = ByteConverstionHelper.converyBytesToSJIS(m.Read <byte>(CalculateNewAddress(cirMessageAddress, gGameOffset), 20, false));
            string          triangleMessag     = ByteConverstionHelper.converyBytesToSJIS(m.Read <byte>(CalculateNewAddress(triMessageAddress, gGameOffset), 20, false));
            string          squareMessage      = ByteConverstionHelper.converyBytesToSJIS(m.Read <byte>(CalculateNewAddress(sqMessageAddress, gGameOffset), 20, false));
            string          crossMessage       = ByteConverstionHelper.converyBytesToSJIS(m.Read <byte>(CalculateNewAddress(xMessageAddress, gGameOffset), 20, false));
            ShortCutIDModel SCIDM;

            // 1 = Spell, 2 = Item, 0 = Message

            if (circleTypeID == 1)
            {
                SCIDM           = GameHelper.ShortCutIdData.Find(x => x._id == circleID);
                lbl_Circle.Text = SCIDM._name;
            }
            else if (circleTypeID == 2)
            {
                SCIDM           = GameHelper.ShortCutIdData.Find(x => x._id == circleID && x._categoryID == circleCategoryID);
                lbl_Circle.Text = SCIDM._name;
            }
            else if (circleTypeID == 0)
            {
                lbl_Circle.Text = circleMessage;
            }
            else if (circleTypeID == 255)
            {
                lbl_Circle.Text = "Unused";
            }

            if (triangleTypeID == 1)
            {
                SCIDM             = GameHelper.ShortCutIdData.Find(x => x._id == triangleID);
                lbl_Triangle.Text = SCIDM._name;
            }
            else if (triangleTypeID == 2)
            {
                SCIDM             = GameHelper.ShortCutIdData.Find(x => x._id == triangleID && x._categoryID == triangleCategoryID);
                lbl_Triangle.Text = SCIDM._name;
            }
            else if (triangleTypeID == 0)
            {
                lbl_Triangle.Text = triangleMessag;
            }
            else if (triangleTypeID == 255)
            {
                lbl_Triangle.Text = "Unused";
            }

            if (squareTypeID == 1)
            {
                SCIDM           = GameHelper.ShortCutIdData.Find(x => x._id == squareID);
                lbl_Square.Text = SCIDM._name;
            }
            else if (squareTypeID == 2)
            {
                SCIDM           = GameHelper.ShortCutIdData.Find(x => x._id == squareID && x._categoryID == squareCategoryID);
                lbl_Square.Text = SCIDM._name;
            }
            else if (squareTypeID == 0)
            {
                lbl_Square.Text = squareMessage;
            }
            else if (squareTypeID == 255)
            {
                lbl_Square.Text = "Unused";
            }

            if (crossTypeID == 1)
            {
                SCIDM          = GameHelper.ShortCutIdData.Find(x => x._id == crossID);
                lbl_Cross.Text = SCIDM._name;
            }
            else if (crossTypeID == 2)
            {
                SCIDM          = GameHelper.ShortCutIdData.Find(x => x._id == crossID && x._categoryID == crossCategoryID);
                lbl_Cross.Text = SCIDM._name;
            }
            else if (crossTypeID == 0)
            {
                lbl_Cross.Text = crossMessage;
            }
            else if (crossTypeID == 255)
            {
                lbl_Cross.Text = "Unused";
            }
        }
        private void tmr_GameData_Tick(object sender, EventArgs e)
        {
            try
            {
                Process pcsx2       = Process.GetProcesses().First(p => p.ProcessName.StartsWith(PCSX2PROCESSNAME));
                long    pcsx2Offset = GameHelper.GetPcsx2Offset(pcsx2);
                IntPtr  pcsx2Intptr = new IntPtr(pcsx2Offset);

                mem = new MemorySharp(pcsx2);
                string areaWord1 = "";
                string areaWord2 = "";
                string areaWord3 = "";

                if (mem.IsRunning)
                {
                    if (mem.Read <byte>(IntPtr.Add(pcsx2Intptr, GameHelper.CONNECTED_TO_AS_ADDRESS), 4, false).First() == 0x01)
                    {
                        //Get party count
                        //Not really useful right now since I can't seem to get this to display
                        int partyCount = mem.Read <byte>(IntPtr.Add(pcsx2Intptr, GameHelper.PARTY_COUNT_ADDRESS), false);

                        //Get the server name
                        string serverName = ByteConverstionHelper.converyBytesToSJIS(mem.Read <byte>(IntPtr.Add(pcsx2Intptr, GameHelper.SERVER_NAME_ADDRESS), 20, false));

                        //Get the town you are in.
                        //This address actually shows the current zone ccs file. So when you zone into an area this will update to that zone's CCS file
                        //Could be useful to display the area you are in but using the default assets wouldn't be telling of where the player actually is.
                        string townFileName = mem.ReadString(IntPtr.Add(pcsx2Intptr, GameHelper.ZONE_CCS_FILE_LOADED), Encoding.Default, false, 12).Split('.')[0].ToLower();

                        //Don't want the timer to continue if the player is just sitting in town.
                        if (townFileName.ToLower().Contains("town"))
                        {
                            presence.Timestamps = new Timestamps()
                            {
                                Start = null
                            };
                            sessionStarted = false;
                        }

                        //Check to see if we are in a zone. (Could technically use townFileName, but I haven't done extensive testing with that to see if it is
                        // always a zone file name that is loaded there.)

                        if (mem.Read <byte>(IntPtr.Add(pcsx2Intptr, GameHelper.IN_AREA_ADDRESS), 4, false).First() == 0x01)
                        {
                            //Get the pointer addresses and add their offsets to them
                            IntPtr areawordPointerAddress =
                                new IntPtr(mem.Read <int>(IntPtr.Add(pcsx2Intptr, GameHelper.AREA_WORD_POINTER), false) +
                                           pcsx2Offset);
                            IntPtr areaword1Pointer =
                                new IntPtr(mem.Read <int>(
                                               areawordPointerAddress + GameHelper.AREA_WORD_ONE_POINTER_OFFSET, false) + pcsx2Offset);
                            IntPtr areaWord2Pointer =
                                new IntPtr(mem.Read <int>(
                                               areawordPointerAddress + GameHelper.AREA_WORD_TWO_POINTER_OFFSET, false) + pcsx2Offset);
                            IntPtr areaWord3Pointer =
                                new IntPtr(mem.Read <int>(
                                               areawordPointerAddress + GameHelper.AREA_WORD_THREE_POINTER_OFFSET, false) + pcsx2Offset);

                            //Get the keywords.
                            areaWord1    = ByteConverstionHelper.converyBytesToSJIS(mem.Read <byte>(areaword1Pointer, 12, false)).Substring(4);
                            areaWord2    = ByteConverstionHelper.converyBytesToSJIS(mem.Read <byte>(areaWord2Pointer, 12, false)).Substring(4);
                            areaWord3    = ByteConverstionHelper.converyBytesToSJIS(mem.Read <byte>(areaWord3Pointer, 12, false)).Substring(4);
                            townFileName = "default";
                            //Check to see if the game is started (if the player is in a zone) so the timer won't constantly reset
                            if (!sessionStarted)
                            {
                                presence.Timestamps = new Timestamps()
                                {
                                    Start = DateTime.UtcNow
                                };

                                sessionStarted = true;
                            }
                        }
                        setPresence(serverName, areaWord1, areaWord2, areaWord3, partyCount, townFileName);
                    }
                }
                else
                {
                    client.SetPresence(defaultPresence);
                    sessionStarted = false;
                }
            }
            catch (Exception)
            {
                client.SetPresence(defaultPresence);
                sessionStarted = false;
            }
        }
Пример #22
0
        public T Read <T>(IntPtr Address)
        {
            T read = mem.Read <T>(Address);

            return(read);
        }
Пример #23
0
        public void GetBaseAddress()
        {
            Thread.Sleep(1500);

            Program.runningForm.SetTooltipStrip("waiting for load music select screen.");
            int baseaddr  = 0;
            var stripText = Program.runningForm.GetTooltipStrip();

            while (true)
            {
                try {
                    //ini로 설정 저장. 사용하지 않음
                    //WritePrivateProfileString("setting", "DSTY", Program.lr2helper.GetFormText(textboxDSTY).ToString(), setting_path);

                    try {
                        baseaddr = sharp.Read <int>(vmem_getbaseaddr_reg, false);
                    } catch (Exception) {
                    }

                    if (stripText.Length > 50)
                    {
                        Program.runningForm.SetTooltipStrip("waiting for load music select screen.");
                    }
                    Program.runningForm.SetTooltipStrip(stripText + ".");
                    if (baseaddr > 0)
                    {
                        LR2value.baseaddr = baseaddr;

                        Program.runningForm.SetTooltipStrip("LR2 attach complete.");
                        Thread.Sleep(1000);
                        break;
                    }
                    if (!sharp.IsRunning) //LR2 프로세스 체크
                    {
                        Thread th_initFirstprocess = new Thread(new ThreadStart(initFirstprocess));
                        Program.runningForm.SetTooltipStrip("LR2 process is terminated!");
                        Thread.Sleep(2000);
                        th_initFirstprocess.Start();
                        break;
                    }
                    if (flag_interrupt == 1)
                    {
                        break;
                    }
                    Thread.Sleep(1000);
                } catch (Exception e) {
                    WriteLog(e.ToString());
                    Thread.Sleep(1000);
                }
            }
        }
Пример #24
0
 public T Read <T>(IntPtr address, bool isRelative = true)
 {
     return(m.Read <T>(address, isRelative));
 }
Пример #25
0
        private void HOTKEYS()
        {
            if (!pcsx2Running)
            {
                return;
            }
            //Numpad Brightness Toggle ON (NUMPAD 1)
            if (GetAsyncKeyState(Keys.NumPad1) < 0)
            {
                var cheatString = @"204B858C 40800000
                    204B859C 40800000
                    204B85AC 40800000";

                var cheat = ParseCheat(cheatString);

                foreach (var code in cheat.Codes)
                {
                    m.Write <int>(code.Address, code.Data, false);
                }
            }

            //Numpad Brightness Toggle OFF (NUMPAD 0)
            if (GetAsyncKeyState(Keys.NumPad0) < 0)
            {
                var cheatString = @"204B858C 00000000
                    204B859C 00000000
                    204B85AC 00000000";

                var cheat = ParseCheat(cheatString);

                foreach (var code in cheat.Codes)
                {
                    m.Write <int>(code.Address, code.Data, false);
                }
            }

            //Brightness Adjustments (NUMPAD +)
            if (GetAsyncKeyState(Keys.Add) < 0)
            {
                IntPtr address  = GameHelper.BRIGHTNESS1;
                float  oldValue = m.Read <float>(address, false);
                float  newValue = oldValue + 2;
                m.Write(address, value: newValue, false);
            }

            //Brightness Adjustments (NUMPAD -)
            if (GetAsyncKeyState(Keys.Subtract) < 0)
            {
                IntPtr address  = GameHelper.BRIGHTNESS1;
                float  oldValue = m.Read <float>(address, false);
                float  newValue = oldValue - 2;
                m.Write(address, value: newValue, false);
            }

            //Lock Perfect Brightness
            if (lockBrightness_checkBox.Checked)
            {
                if (!pcsx2Running)
                {
                    return;
                }

                var cheatString = @"204B858C 40500000
                    204B859C 40500000
                    204B85AC 40500000";

                var cheat = ParseCheat(cheatString);

                foreach (var code in cheat.Codes)
                {
                    m.Write <int>(code.Address, code.Data, false);
                }
            }
        }
Пример #26
0
 /// <summary>
 /// Converts a pointer to a given type. This function converts the value of the pointer or the pointed value,
 /// according if the data type is primitive or reference.
 /// </summary>
 /// <param name="memorySharp">The concerned process.</param>
 /// <param name="pointer">The pointer to convert.</param>
 /// <returns>The return value is the pointer converted to the given data type.</returns>
 public static T PtrToObject(MemorySharp memorySharp, IntPtr pointer)
 {
     return(ByteArrayToObject(CanBeStoredInRegisters
                               ? BitConverter.GetBytes(pointer.ToInt64())
                               : memorySharp.Read <byte>(pointer, Size, false)));
 }