Пример #1
0
        public static bool HookGame(ref IntPtr writeHandle, ref IntPtr readHandle, ref IntPtr processHandle)
        {
            IntPtr GameConsoleWindow = WinAPIHelper.FindWindow("JAMP WinConsole", null);

            if (GameConsoleWindow == IntPtr.Zero)
            {
                return(false);
            }


            IntPtr processId = new IntPtr();

            WinAPIHelper.GetWindowThreadProcessId(GameConsoleWindow, ref processId);
            if (processId == IntPtr.Zero)
            {
                return(false);
            }

            processHandle = WinAPIHelper.OpenProcess(0x1F0FFF, false, (int)processId);
            if (processHandle == IntPtr.Zero)
            {
                return(false);
            }

            writeHandle = WinAPIHelper.FindWindowEx(GameConsoleWindow, IntPtr.Zero, "edit", null);
            readHandle  = WinAPIHelper.FindWindowEx(GameConsoleWindow, writeHandle, "edit", null);
            return(true);
        }
Пример #2
0
        public string ReadConsole()
        {
            StringBuilder temp          = new StringBuilder(50000);
            int           consoleLength = WinAPIHelper.SendMessage(consoleReadHandle, WinAPIHelper.WM_GETTEXT, 50000, temp);

            return(temp.ToString());
        }
Пример #3
0
        public void GetUserData()
        {
            IntPtr buffer = new IntPtr();

            WinAPIHelper.ReadProcessMemory(gameProcessHandle, (IntPtr)HookHelper.PlayerClientNumAddress, ref buffer, 4, IntPtr.Zero); //get clientnum
            userData.ClientNum = buffer.ToInt32();
            userData.Name      = GetPlayerName(userData.ClientNum);
        }
Пример #4
0
        public string GetPlayerName(int clientNum)
        {
            if (clientNum < 0 && clientNum >= 32)
            {
                return(null);
            }

            IntPtr playerdataOffset = new IntPtr();

            WinAPIHelper.ReadProcessMemory(gameProcessHandle, (IntPtr)0x977d54 + 4 * (1131 + clientNum), ref playerdataOffset, 4, IntPtr.Zero); //get

            if (playerdataOffset.ToInt32() == 0)
            {
                return(null);
            }

            StringBuilder clientData = new StringBuilder(2000);

            WinAPIHelper.ReadProcessMemory(gameProcessHandle, new IntPtr(0x9797e4 + playerdataOffset.ToInt32()), clientData, 1024, IntPtr.Zero);
            string[] stats = clientData.ToString().Split('\\');
            return(RemoveColorModifiers(stats[1])); //hardcoded name offset
        }
Пример #5
0
 public void ExecuteConsoleCommand(string cmd)
 {
     WinAPIHelper.SendMessage(consoleWriteHandle, WinAPIHelper.WM_SETTEXT, 0, cmd);
     WinAPIHelper.SendMessage(consoleWriteHandle, 258, 13, 0); //pseudo "enter" key
 }