Tuesday, May 29, 2018

PUBG Mobile Mouse Helper

This is something I made a couple of days ago to enable me to rapid fire single shot weapons while negating recoils of most guns in PUBG Mobile's official PC version by Tencent. I first tried to achieve the same using AutoHotkey - but it, or perhaps my knowledge of it, quickly fell short. So, I decided to make something to the same effect in C. I did, but I wanted a nice GUI with the ability to modify the different parameters of the script. I thought my SimWin library could do the job but I decided trackbar controls would be better suited for the purpose of modulating the recoil parameters than some plain old textboxes, and unfortunately, I'd not implemented trackbars in SimWin yet. So, I decided .Net with P/Invoke would have to do. Two days later, here it is :

The primary goal and functionality of the program is quite simple but here are the major highlights :
  • Hold middle mouse button to auto fire single shot weapons
  • Allows modulation of four different parameters : i) Horizontal correction (dx) ii) Vertical correction (dy) iii) Sleep period between consecutive mouse moves during recoil correction* (WaitMs) iv) Delay period between consecutive shots fired (DelayMs)
  • Ability to save custom presets for different weapons along with six built-ins
  • Enter key switches between different presets when in monitoring mode for when within the game
  • Arrow keys modify the dx and dy parameters when in monitoring mode for when within the game
*The recoil correction has been implemented by basically holding and dragging the in-game cursor since the game crosshair doesn't correspond to the actual cursor position. And while the in-game cursor does correspond to the actual cursor position, it is constantly repositioned to somewhere near the center of the game window. So, a simple SetCursorPos() call doesn't do the trick (tried and failed). This is the reason mouse_event() calls have been used to simulate mouse movement in terms of x and y displacements - dx and dy - for recoil correction. Furthermore, looping through each of the dx and dy pixels without any artificially placed delays seems to be too quick for the game to register - the recoil correction stops working altogether. This is why a WaitMs delay is required.

The original C code that I experimented with is available here

Download the program here

Project @ GitHub

Note : .Net Framework 4.6.1 is required to run this program.

Update : Version 2.3 has been published on GitHub.

Friday, May 18, 2018

x64 inline hooking of ntdll functions

This is a 64-bit update to this code.
I learned a few things about 64-bit assembly and corresponding calling conventions during the writing of this fairly simple program. The code is self-explanatory and can be found here