diff --git a/AimbotForm.cs b/AimbotForm.cs new file mode 100644 index 0000000..93cf9cb --- /dev/null +++ b/AimbotForm.cs @@ -0,0 +1,387 @@ +using System; +using System.Text; +using GameOverlay.Drawing; +using GameOverlay.Windows; +using SharpDX; +using Point = GameOverlay.Drawing.Point; +using Color = GameOverlay.Drawing.Color; +using Rectangle = GameOverlay.Drawing.Rectangle; +using RawVector2 = SharpDX.Mathematics.Interop.RawVector2; +using ShpVector3 = SharpDX.Vector3; +using ShpVector2 = SharpDX.Vector2; +using System.Windows.Forms; + +namespace PUBGMESP +{ + public interface IAimbotForm + { + void Initialize(); + void Update(); + } + public class AimTarget + { + public ShpVector2 Screen2D; + public float CrosshairDistance; + public int uniqueID; + } + public class AimbotForm : IAimbotForm + { + public readonly OverlayWindow _window; + private readonly Graphics _graphics; + private readonly GameMemSearch _ueSearch; + + private Font _font; + private Font _infoFont; + private Font _bigfont; + private SolidBrush _black; + private SolidBrush _red; + private SolidBrush _green; + private SolidBrush _blue; + private SolidBrush _orange; + private SolidBrush _purple; + private SolidBrush _yellow; + private SolidBrush _white; + private SolidBrush _transparent; + private SolidBrush _txtBrush; + private SolidBrush[] _randomBrush; + private SolidBrush _boxBrush; + private int BestTargetUniqID = -1; + + private DisplayData _data; + private int playerCount; + + // offset + private int actorOffset, boneOffset, tmpOffset; + + + public AimbotForm(RECT rect, GameMemSearch ueSearch) + { + this._ueSearch = ueSearch; + + _window = new OverlayWindow(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top) + { + IsTopmost = true, + IsVisible = true + }; + + _window.SizeChanged += _window_SizeChanged; + + _graphics = new Graphics + { + MeasureFPS = true, + Height = _window.Height, + PerPrimitiveAntiAliasing = true, + TextAntiAliasing = true, + UseMultiThreadedFactories = false, + VSync = true, + Width = _window.Width, + WindowHandle = IntPtr.Zero + }; + + // offset + actorOffset = 320; + boneOffset = 1408; + tmpOffset = 776; + } + + ~AimbotForm() + { + _graphics.Dispose(); + _window.Dispose(); + } + + public void Initialize() + { + _window.CreateWindow(); + + _graphics.WindowHandle = _window.Handle; + _graphics.Setup(); + + _font = _graphics.CreateFont("Microsoft YaHei", 10); + _infoFont = _graphics.CreateFont("Microsoft YaHei", 12); + _bigfont = _graphics.CreateFont("Microsoft YaHei", 18, true); + + _black = _graphics.CreateSolidBrush(0, 0, 0); + _red = _graphics.CreateSolidBrush(255, 99, 71); + _green = _graphics.CreateSolidBrush(Color.Green); + _blue = _graphics.CreateSolidBrush(135, 206, 250); + _orange = _graphics.CreateSolidBrush(255, 97, 0); + _purple = _graphics.CreateSolidBrush(255, 105, 180); + _yellow = _graphics.CreateSolidBrush(255, 255, 0); + _white = _graphics.CreateSolidBrush(255, 255, 255); + _transparent = _graphics.CreateSolidBrush(0, 0, 0, 0); + _randomBrush = new SolidBrush[] + { + _orange,_red,_green,_blue,_yellow,_white,_purple + }; + _txtBrush = _graphics.CreateSolidBrush(0, 0, 0, 0.5f); + } + + public void UpdateData(DisplayData data) + { + _data = data; + } + + public void Update() + { + var gfx = _graphics; + gfx.BeginScene(); + gfx.ClearScene(_transparent); + + if (Settings.ShowMenu) + { + + DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 + 115), "Aimbot Menu"); + if (Settings.aimEnabled) + { + DrawShadowText(gfx, _font, _red, new Point(20f, _window.Height / 2 + 130), "Aimbot ON (F5) : " + Settings.aimEnabled.ToString()); + } + else + { + DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 + 130), "Aimbot OF (F5) : " + Settings.aimEnabled.ToString()); + } + if (Settings.bDrawFow) + { + DrawShadowText(gfx, _font, _red, new Point(20f, _window.Height / 2 + 145), "FOV SHOW (F6) : " + Settings.bDrawFow.ToString()); + } + else + { + DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 + 145), "FOV HIDE (F6) : " + Settings.bDrawFow.ToString()); + } + + DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 + 160), "┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈"); + } + + // Read View Matrix + long viewMatrixAddr = Mem.ReadMemory(Mem.ReadMemory(_data.ViewMatrixBase) + 32) + 512; + D3DMatrix viewMatrix = Algorithms.ReadViewMatrix(viewMatrixAddr); + + var AimTargets = new AimTarget[_data.Players.Length]; + float fClosestDist = -1; + // Draw Player ESP + if (Settings.PlayerESP) + { + for (int i = 0; i < _data.Players.Length; i++) + { + + var player = _data.Players[i]; + //if (player.Health <= 0) continue; + if (Algorithms.WorldToScreenPlayer(viewMatrix, player.Position, out ShpVector3 playerScreen, out int distance, _window.Width, _window.Height)) + { + // Too Far not render + if (distance > 500) continue; + float x = playerScreen.X; + float y = playerScreen.Y; + float h = playerScreen.Z; + float w = playerScreen.Z / 2; + + try + { + _boxBrush = _randomBrush[player.TeamID % 7]; + } + catch (IndexOutOfRangeException) + { + _boxBrush = _green; + } + //DrawShadowText(gfx,_font, _green, new Point((x - playerScreen.Z / 4) - 3, y - 15), player.Pose.ToString()); + + // Adjust Box + if (player.Pose == 1114636288) + { + y = playerScreen.Y + playerScreen.Z / 5; + h -= playerScreen.Z / 5; + } + if (player.Pose == 1112014848 || player.Status == 7) + { + y = playerScreen.Y + playerScreen.Z / 4; + h -= playerScreen.Z / 4; + } + + int ScreenCenterX = _window.Width / 2, ScreenCenterY = _window.Height / 2; + + if (Settings.aimEnabled) + { + long tmpAddv = Mem.ReadMemory(player.Address + tmpOffset); + long bodyAddv = tmpAddv + actorOffset; + long boneAddv = Mem.ReadMemory(tmpAddv + boneOffset) + 48; + ShpVector3 headPos = Algorithms.GetBoneWorldPosition(bodyAddv, boneAddv + 5 * 48); + + headPos.Z += 7; + + var clampPos = headPos - player.Position; + bool w2sHead = Algorithms.WorldToScreen3DBox(viewMatrix, new ShpVector3(headPos.X, headPos.Y - (Settings.bPredict * 2), headPos.Z - (Settings.bYAxis * 8)), out ShpVector2 HeadPosition, _window.Width, _window.Height); + + AimTargets[i] = new AimTarget(); + AimTargets[i].Screen2D = HeadPosition; + AimTargets[i].uniqueID = player.TeamID; + AimTargets[i].CrosshairDistance = ShpVector2.Distance(HeadPosition, new ShpVector2(ScreenCenterX, ScreenCenterY)); + + if (BestTargetUniqID == -1) + { + if (Algorithms.isInside(ScreenCenterX, ScreenCenterY, Settings.bFovArray[Settings.bFovInt], AimTargets[i].Screen2D.X, AimTargets[i].Screen2D.Y)) + { + fClosestDist = AimTargets[i].CrosshairDistance; + BestTargetUniqID = AimTargets[i].uniqueID; + } + } + if (MainForm.GetAsyncKeyState(Settings.bAimKeys[Settings.bAimKeyINT])) + { + if (BestTargetUniqID != -1) + { + var best = FindAimTargetByUniqueID(AimTargets, BestTargetUniqID); + + if (best != null) + { + { + var roundPos = new ShpVector2((float)Math.Round(best.Screen2D.X), (float)Math.Round(best.Screen2D.Y)); + AimAtPosV2(roundPos.X, roundPos.Y, _window.Width, _window.Height, false); + + } + } + } + } + else + { + BestTargetUniqID = -1; + } + } + if (Settings.bDrawFow) + { + gfx.DrawCircle(_red, ScreenCenterX, ScreenCenterY, Settings.bFovArray[Settings.bFovInt], 2); + } + } + } + + gfx.EndScene(); + } + } + + private static AimTarget FindAimTargetByUniqueID(AimTarget[] array, int uniqueID) + { + var entityList = array; + for (int i = 0; i < entityList.Length; i++) + { + var current = entityList[i]; + if (current == null) + continue; + + if (current.uniqueID == uniqueID) + return current; + } + return null; + } + //uc port + private void AimAtPosV2(float x, float y, int Width, int Height , bool smooth) + { + int ScreenCenterX = Width / 2, ScreenCenterY = Height / 2; + + float AimSpeed = (float)Settings.bSmooth + 1f;; + float TargetX = 0; + float TargetY = 0; + + //X Axis + if (x != 0) + { + if (x > ScreenCenterX) + { + TargetX = -(ScreenCenterX - x); + TargetX /= AimSpeed; + if (TargetX + ScreenCenterX > ScreenCenterX * 2) TargetX = 0; + } + + if (x < ScreenCenterX) + { + TargetX = x - ScreenCenterX; + TargetX /= AimSpeed; + if (TargetX + ScreenCenterX < 0) TargetX = 0; + } + } + + //Y Axis + + if (y != 0) + { + if (y > ScreenCenterY) + { + TargetY = -(ScreenCenterY - y); + TargetY /= AimSpeed; + if (TargetY + ScreenCenterY > ScreenCenterY * 2) TargetY = 0; + } + + if (y < ScreenCenterY) + { + TargetY = y - ScreenCenterY; + TargetY /= AimSpeed; + if (TargetY + ScreenCenterY < 0) TargetY = 0; + } + } + + if (!smooth) + { + MainForm.mouse_event(1, (int)TargetX, (int)(TargetY), 0, UIntPtr.Zero); + return; + } + + TargetX /= 10; + TargetY /= 10; + + if (Math.Abs(TargetX) < 1) + { + if (TargetX > 0) + { + TargetX = 1; + } + if (TargetX < 0) + { + TargetX = -1; + } + } + if (Math.Abs(TargetY) < 1) + { + if (TargetY > 0) + { + TargetY = 1; + } + if (TargetY < 0) + { + TargetY = -1; + } + } + MainForm.mouse_event(1, (int)TargetX, (int)(TargetY), 0, UIntPtr.Zero); + } + + private void _window_SizeChanged(object sender, OverlaySizeEventArgs e) + { + if (_graphics == null) return; + + if (_graphics.IsInitialized) + { + _graphics.Resize(e.Width, e.Height); + } + else + { + _graphics.Width = e.Width; + _graphics.Height = e.Height; + } + } + + private void DrawShadowText(Graphics gfx, Font font, IBrush brush, Point pt, string txt) + { + var bpPt = new Point(pt.X - 1, pt.Y + 1); + //var bpPt2 = new Point(pt.X + 1, pt.Y - 1); + gfx.DrawText(font, _txtBrush, bpPt, txt); + //gfx.DrawText(font, _txtBrush, bpPt2, txt); + gfx.DrawText(font, brush, pt, txt); + + } + private void DrawShadowText(Graphics gfx, Font font, float fontSize, IBrush brush, Point pt, string txt) + { + var bpPt = new Point(); + bpPt.X = pt.X - 1; + bpPt.Y = pt.Y + 1; + gfx.DrawText(font, fontSize, _txtBrush, bpPt, txt); + gfx.DrawText(font, fontSize, brush, pt, txt); + } + } + +} diff --git a/Algorithms.cs b/Algorithms.cs new file mode 100644 index 0000000..55a7a90 --- /dev/null +++ b/Algorithms.cs @@ -0,0 +1,250 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SharpDX; +using ShpVector3 = SharpDX.Vector3; +using ShpVector2 = SharpDX.Vector2; +namespace PUBGMESP +{ + internal class Algorithms + { + /// + /// Check if enemy is inside fov circle + /// + /// + /// + /// + /// + /// + /// + public static bool isInside(float circle_x, float circle_y, + float rad, float x, float y) + { + // Compare radius of circle with distance + // of its center from given point + if ((x - circle_x) * (x - circle_x) + + (y - circle_y) * (y - circle_y) <= rad * rad) + return true; + else + return false; + } + + /// + /// Get Distance Between Enemy And Player + /// + /// + /// + /// + /// + /// + public static double GetDistance(double x1, double y1, double x2, double y2) + { + return Math.Sqrt(Math.Pow((x2 - x1), 2) + Math.Pow((y2 - y1), 2)); + } + + /// + /// Read View Matrix + /// + /// + /// + public static D3DMatrix ReadViewMatrix(long vAddv) => Mem.ReadMemory(vAddv); + + /// + /// Read FTTransform + /// + /// + /// + public static FTTransform ReadFTTransform(long vAddv) => Mem.ReadMemory(vAddv); + + public static FTTransform2 ReadFTransform2(long vAddv) => Mem.ReadMemory(vAddv); + + /// + /// Get Bone's world position + /// + /// + /// + /// + public static ShpVector3 GetBoneWorldPosition(long actorAddv, long boneAddv) + { + + var bone = ReadFTransform2(boneAddv); + var actor = ReadFTransform2(actorAddv); + var boneMatrix = ToMatrixWithScale(bone.Translation, bone.Scale3D, bone.Rotation); + var componentToWorldMatrix = ToMatrixWithScale(actor.Translation, actor.Scale3D, actor.Rotation); + var newMatrix = MatrixMultiplication(boneMatrix, componentToWorldMatrix); + ShpVector3 bonePos = new ShpVector3(); + bonePos.X = newMatrix._41; + bonePos.Y = newMatrix._42; + bonePos.Z = newMatrix._43; + return bonePos; + } + + /// + /// To Matrix With Scale + /// + /// + /// + /// + /// + private static D3DMatrix ToMatrixWithScale(Vector3 translation, Vector3 scale, Vector4 rot) + { + D3DMatrix m = new D3DMatrix + { + _41 = translation.X, + _42 = translation.Y, + _43 = translation.Z + }; + + float x2 = rot.X + rot.X; + float y2 = rot.Y + rot.Y; + float z2 = rot.Z + rot.Z; + + float xx2 = rot.X * x2; + float yy2 = rot.Y * y2; + float zz2 = rot.Z * z2; + m._11 = (1.0f - (yy2 + zz2)) * scale.X; + m._22 = (1.0f - (xx2 + zz2)) * scale.Y; + m._33 = (1.0f - (xx2 + yy2)) * scale.Z; + + float yz2 = rot.Y * z2; + float wx2 = rot.W * x2; + m._32 = (yz2 - wx2) * scale.Z; + m._23 = (yz2 + wx2) * scale.Y; + + float xy2 = rot.X * y2; + float wz2 = rot.W * z2; + m._21 = (xy2 - wz2) * scale.Y; + m._12 = (xy2 + wz2) * scale.X; + + float xz2 = rot.X * z2; + float wy2 = rot.W * y2; + m._31 = (xz2 + wy2) * scale.Z; + m._13 = (xz2 - wy2) * scale.X; + + m._14 = 0.0f; + m._24 = 0.0f; + m._34 = 0.0f; + m._44 = 1.0f; + + return m; + } + + /// + /// D3DMatrix Mutiplication + /// + /// + /// + /// + public static D3DMatrix MatrixMultiplication(D3DMatrix pM1, D3DMatrix pM2) + { + D3DMatrix pOut = new D3DMatrix + { + _11 = pM1._11 * pM2._11 + pM1._12 * pM2._21 + pM1._13 * pM2._31 + pM1._14 * pM2._41, + _12 = pM1._11 * pM2._12 + pM1._12 * pM2._22 + pM1._13 * pM2._32 + pM1._14 * pM2._42, + _13 = pM1._11 * pM2._13 + pM1._12 * pM2._23 + pM1._13 * pM2._33 + pM1._14 * pM2._43, + _14 = pM1._11 * pM2._14 + pM1._12 * pM2._24 + pM1._13 * pM2._34 + pM1._14 * pM2._44, + _21 = pM1._21 * pM2._11 + pM1._22 * pM2._21 + pM1._23 * pM2._31 + pM1._24 * pM2._41, + _22 = pM1._21 * pM2._12 + pM1._22 * pM2._22 + pM1._23 * pM2._32 + pM1._24 * pM2._42, + _23 = pM1._21 * pM2._13 + pM1._22 * pM2._23 + pM1._23 * pM2._33 + pM1._24 * pM2._43, + _24 = pM1._21 * pM2._14 + pM1._22 * pM2._24 + pM1._23 * pM2._34 + pM1._24 * pM2._44, + _31 = pM1._31 * pM2._11 + pM1._32 * pM2._21 + pM1._33 * pM2._31 + pM1._34 * pM2._41, + _32 = pM1._31 * pM2._12 + pM1._32 * pM2._22 + pM1._33 * pM2._32 + pM1._34 * pM2._42, + _33 = pM1._31 * pM2._13 + pM1._32 * pM2._23 + pM1._33 * pM2._33 + pM1._34 * pM2._43, + _34 = pM1._31 * pM2._14 + pM1._32 * pM2._24 + pM1._33 * pM2._34 + pM1._34 * pM2._44, + _41 = pM1._41 * pM2._11 + pM1._42 * pM2._21 + pM1._43 * pM2._31 + pM1._44 * pM2._41, + _42 = pM1._41 * pM2._12 + pM1._42 * pM2._22 + pM1._43 * pM2._32 + pM1._44 * pM2._42, + _43 = pM1._41 * pM2._13 + pM1._42 * pM2._23 + pM1._43 * pM2._33 + pM1._44 * pM2._43, + _44 = pM1._41 * pM2._14 + pM1._42 * pM2._24 + pM1._43 * pM2._34 + pM1._44 * pM2._44 + }; + + return pOut; + } + + /// + /// Player's World To Screen Function + /// + /// + /// + /// + /// + /// + /// + public static bool WorldToScreenPlayer(D3DMatrix viewMatrix, ShpVector3 pos, out ShpVector3 screen, out int distance, int windowWidth, int windowHeight) + { + screen = new ShpVector3(); + //ScreenW = (GameViewMatrix._14 * _Enemy_Point.x) + (GameViewMatrix._24* _Enemy_Point.y) + (GameViewMatrix._34 * _Enemy_Point.z + GameViewMatrix._44); + float screenW = (viewMatrix._14 * pos.X) + (viewMatrix._24 * pos.Y) + (viewMatrix._34 * pos.Z + viewMatrix._44); + distance = (int)(screenW / 100); + if (screenW < 0.0001f) return false; + + // float ScreenY = (GameViewMatrix._12 * _Enemy_Point.x) + (GameViewMatrix._22 * _Enemy_Point.y) + (GameViewMatrix._32 * (_Enemy_Point.z + 85) + GameViewMatrix._42); + float screenY = (viewMatrix._12 * pos.X) + (viewMatrix._22 * pos.Y) + (viewMatrix._32 * (pos.Z + 85) + viewMatrix._42); + // float ScreenX = (GameViewMatrix._11 * _Enemy_Point.x) + (GameViewMatrix._21 * _Enemy_Point.y) + (GameViewMatrix._31 * _Enemy_Point.z + GameViewMatrix._41); + float screenX = (viewMatrix._11 * pos.X) + (viewMatrix._21 * pos.Y) + (viewMatrix._31 * pos.Z + viewMatrix._41); + screen.Y = (windowHeight / 2) - (windowHeight / 2) * screenY / screenW; + screen.X = (windowWidth / 2) + (windowWidth / 2) * screenX / screenW; + // float y1 = (pDxm->s_height / 2) - (GameViewMatrix._12*_Enemy_Point.x + GameViewMatrix._22 * _Enemy_Point.y + GameViewMatrix._32 *(_Enemy_Point.z - 95) + GameViewMatrix._42) *(pDxm->s_height / 2) / ScreenW; + float y1 = (windowHeight / 2) - (viewMatrix._12 * pos.X + viewMatrix._22 * pos.Y + viewMatrix._32 * (pos.Z - 95) + viewMatrix._42) * (windowHeight / 2) / screenW; + screen.Z = y1 - screen.Y; + return true; + } + + /// + /// Bone's World to Screen Function + /// + /// + /// + /// + /// + /// + /// + public static bool WorldToScreenBone(D3DMatrix viewMatrix, ShpVector3 pos, out ShpVector2 screen, out int distance, int windowWidth, int windowHeight) + => WorldToScreenItem(viewMatrix, pos, out screen, out distance, windowWidth, windowHeight); + + /// Item's World To Screen Function + /// + /// + /// + /// + /// + /// + /// + /// + public static bool WorldToScreenItem(D3DMatrix viewMatrix, ShpVector3 pos, out ShpVector2 screen, out int distance, int windowWidth, int windowHeight) + { + screen = new ShpVector2(); + float screenW = (viewMatrix._14 * pos.X) + (viewMatrix._24 * pos.Y) + (viewMatrix._34 * pos.Z + viewMatrix._44); + distance = (int)(screenW / 100); + if (screenW < 0.0001f) return false; + screenW = 1 / screenW; + float sightX = (windowWidth / 2); + float sightY = (windowHeight / 2); + screen.X = sightX + (viewMatrix._11 * pos.X + viewMatrix._21 * pos.Y + viewMatrix._31 * pos.Z + viewMatrix._41) * screenW * sightX; + screen.Y = sightY - (viewMatrix._12 * pos.X + viewMatrix._22 * pos.Y + viewMatrix._32 * pos.Z + viewMatrix._42) * screenW * sightY; + return !float.IsNaN(screen.X) && !float.IsNaN(screen.Y); + } + + + public static bool WorldToScreen3DBox(D3DMatrix viewMatrix, ShpVector3 position, out ShpVector2 res, int sw, int sh) + { + res.X = 0f; + res.Y = 0f; + D3DMatrix matrix = viewMatrix; + double num = (double)(position.X * matrix._14 + position.Y * matrix._24 + position.Z * matrix._34 + matrix._44); + if (num < 0.100000001490116) return false; + double num2 = (double)(position.X * matrix._11 + position.Y * matrix._21 + position.Z * matrix._31 + matrix._41); + double num3 = (double)(position.X * matrix._12 + position.Y * matrix._22 + position.Z * matrix._32 + matrix._42); + num2 /= num; + num3 /= num; + float num4 = (float)(sw / 2); + float num5 = (float)(sh / 2); + res.X = (float)((double)num4 * num2 + (num2 + (double)num4)); + res.Y = (float)(-(float)((double)num5 * num3) + (num3 + (double)num5)); + return !float.IsNaN(res.X) && !float.IsNaN(res.Y); + } + + + } +} diff --git a/App.config b/App.config new file mode 100644 index 0000000..ecdcf8a --- /dev/null +++ b/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/Classes.cs b/Classes.cs new file mode 100644 index 0000000..6fffe5d --- /dev/null +++ b/Classes.cs @@ -0,0 +1,223 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +using SharpDX; +using ShpVector3 = SharpDX.Vector3; +using ShpVector2 = SharpDX.Vector2; +namespace PUBGMESP +{ + public class DisplayData + { + public long ViewMatrixBase; + public long myObjectAddress; + public PlayerData[] Players; + public ItemData[] Items; + public VehicleData[] Vehicles; + public BoxData[] Boxes; + public GrenadeData[] Grenades; + + public DisplayData(long viewMatrixBase,long myObjectAddress) + { + this.ViewMatrixBase = viewMatrixBase; + this.myObjectAddress = myObjectAddress; + } + } + + public class PlayerData + { + public string Type; + public long Address; + public int Status; + public ShpVector3 Position; + public int Pose; + public float Health; + public string Name; + public bool IsRobot; + public int TeamID; + public int IsTeam; + } + + public class ItemData + { + public Item Type; + public ShpVector3 Position; + public string Name; + } + + public class VehicleData + { + public Vehicle Type; + public ShpVector3 Position; + public string Name; + } + + public class BoxData + { + public string[] Items; + public ShpVector3 Position; + } + + public class GrenadeData + { + public Grenade Type; + public ShpVector3 Position; + } + + /// + /// Item Type + /// + public enum Item + { + [Description("Useless")] + Useless, + [Description("[Med] Enegy Drink")] + EnegyDrink, + [Description("[Med] Epinephrine")] + Epinephrine, + [Description("[Med] Pain Killer")] + PainKiller, + [Description("[Med] First Aid Kit")] + AidKit, + [Description("[Armor] Lv.3 Bag")] + BagLv3, + [Description("[Armor] Lv.2 Bag")] + BagLv2, + [Description("[Armor] Lv.2 Armor")] + ArmorLv2, + [Description("[Armor] Lv.3 Armor")] + ArmorLv3, + [Description("[Armor] Lv.3 Helmet")] + HelmetLv3, + [Description("[Armor] Lv.2 Helmet")] + HelmetLv2, + [Description("[Sniper] AWM")] + AWM, + [Description("[Rifle] SCAR-L")] + SCARL, + [Description("[Sniper] Kar-98")] + Kar98, + [Description("[Rifle] M762")] + M762, + [Description("[MachineGun] DP-28")] + DP28, + [Description("[Rifle] Groza")] + Groza, + [Description("[Rifle] AKM")] + AKM, + [Description("[Rifle] AUG")] + AUG, + [Description("[Rifle] QBZ")] + QBZ, + [Description("[MachineGun] M249")] + M249, + [Description("[Rifle] M4A1")] + M4A1, + [Description("[Ammo] 300 Magnum Ammo")] + AmmoMagnum, + [Description("[Ammo] 7.62 Ammo")] + Ammo762, + [Description("[Ammo] 5.56 Ammo")] + Ammo556, + [Description("[Scope] 4x Scope")] + Scope4x, + [Description("[Scope] 6x Scope")] + Scope6x, + [Description("[Scope] 8x Scope")] + Scope8x, + [Description("[Apendix] Rifle Silenter")] + RifleSilenter, + [Description("[Apendix] Rifle Rapid Expansion Magazine")] + RifleMagazine, + [Description("[Armor] Ghillie Suit")] + GhillieSuit, + [Description("[Pistol] Flare Gun")] + FlareGun, + [Description("[Sniper] M24")] + M24, + [Description("[Apendix] Sniper Silenter")] + SniperSilenter, + [Description("[Sniper] MK14")] + MK14, + [Description("[Sniper] SKS")] + SKS, + [Description("[Ammo] Grenade")] + Grenade + } + + /// + /// Grenade Type + /// + public enum Grenade + { + [Description("Unknown")] + Unknown, + [Description("Smoke Grenade")] + Smoke, + [Description("Cocktail Grenade")] + Burn, + [Description("Flash Grenade")] + Flash, + [Description("Fragment Grenade")] + Explode + } + + /// + /// Vehicle Type + /// + public enum Vehicle + { + [Description("Unknown")] + Unknown, + [Description("BRDM")] + BRDM, + [Description("Scooter")] + Scooter, + [Description("Motorcycle")] + Motorcycle, + [Description("MotorcycleCart")] + MotorcycleCart, + [Description("Snowmobile")] + Snowmobile, + [Description("Tuk")] + Tuk, + [Description("Buggy")] + Buggy, + [Description("Sports")] + Sports, + [Description("Dacia")] + Dacia, + [Description("Rony")] + Rony, + [Description("PickUp")] + PickUp, + [Description("UAZ")] + UAZ, + [Description("MiniBus")] + MiniBus, + [Description("PG117")] + PG117, + [Description("AquaRail")] + AquaRail, + [Description("AirPlane")] + BP_AirDropPlane_C + + } + + /// + /// Aimbot Position + /// + public enum AimPosition + { + [Description("Head")] + Head, + [Description("Chest")] + Chest, + [Description("Waist")] + Waist + } +} diff --git a/ESPForm.cs b/ESPForm.cs new file mode 100644 index 0000000..eff8619 --- /dev/null +++ b/ESPForm.cs @@ -0,0 +1,564 @@ +using System; +using System.Text; +using GameOverlay.Drawing; +using GameOverlay.Windows; +using SharpDX; +using Point = GameOverlay.Drawing.Point; +using Color = GameOverlay.Drawing.Color; +using Rectangle = GameOverlay.Drawing.Rectangle; +using RawVector2 = SharpDX.Mathematics.Interop.RawVector2; +using ShpVector3 = SharpDX.Vector3; +using ShpVector2 = SharpDX.Vector2; +namespace PUBGMESP +{ + public interface IESPForm + { + void Initialize(); + void Update(); + } + + public class ESPForm : IESPForm + { + public readonly OverlayWindow _window; + private readonly Graphics _graphics; + private readonly GameMemSearch _ueSearch; + + private Font _font; + private Font _infoFont; + private Font _bigfont; + private SolidBrush _black; + private SolidBrush _red; + private SolidBrush _green; + private SolidBrush _blue; + private SolidBrush _orange; + private SolidBrush _purple; + private SolidBrush _yellow; + private SolidBrush _white; + private SolidBrush _transparent; + private SolidBrush _txtBrush; + private SolidBrush[] _randomBrush; + private SolidBrush _boxBrush; + + + private DisplayData _data; + private int playerCount; + + // offset + private int actorOffset, boneOffset, tmpOffset; + + + public ESPForm(RECT rect, GameMemSearch ueSearch) + { + this._ueSearch = ueSearch; + + _window = new OverlayWindow(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top) + { + IsTopmost = true, + IsVisible = true + }; + + _window.SizeChanged += _window_SizeChanged; + + _graphics = new Graphics + { + MeasureFPS = true, + Height = _window.Height, + PerPrimitiveAntiAliasing = true, + TextAntiAliasing = true, + UseMultiThreadedFactories = false, + VSync = true, + Width = _window.Width, + WindowHandle = IntPtr.Zero + }; + + // offset + actorOffset = 320; + boneOffset = 1408; + tmpOffset = 776; + } + + ~ESPForm() + { + _graphics.Dispose(); + _window.Dispose(); + } + + public void Initialize() + { + _window.CreateWindow(); + + _graphics.WindowHandle = _window.Handle; + _graphics.Setup(); + + _font = _graphics.CreateFont("Microsoft YaHei", 10); + _infoFont = _graphics.CreateFont("Microsoft YaHei", 12); + _bigfont = _graphics.CreateFont("Microsoft YaHei", 18, true); + + _black = _graphics.CreateSolidBrush(0, 0, 0); + _red = _graphics.CreateSolidBrush(255, 99, 71); + _green = _graphics.CreateSolidBrush(Color.Green); + _blue = _graphics.CreateSolidBrush(135, 206, 250); + _orange = _graphics.CreateSolidBrush(255, 97, 0); + _purple = _graphics.CreateSolidBrush(255, 105, 180); + _yellow = _graphics.CreateSolidBrush(255, 255, 0); + _white = _graphics.CreateSolidBrush(255, 255, 255); + _transparent = _graphics.CreateSolidBrush(0, 0, 0, 0); + _randomBrush = new SolidBrush[] + { + _orange,_red,_green,_blue,_yellow,_white,_purple + }; + _txtBrush = _graphics.CreateSolidBrush(0, 0, 0, 0.5f); + } + + public void UpdateData(DisplayData data) + { + _data = data; + } + + public void Update() + { + var gfx = _graphics; + gfx.BeginScene(); + gfx.ClearScene(_transparent); + // Draw FPS + //gfx.DrawTextWithBackground(_font, _red, _black, 10, 10, "FPS: " + gfx.FPS); + // Draw Menu + if (Settings.ShowMenu) + { + //gfx.FillRectangle(_menuBrush, 10f, _window.Height / 2 - 75, 180, _window.Height / 2 + 165); + DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 - 65), " [ AM7 PUBG ] "); + DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 - 50), "┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈"); + DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 - 35), "ESP Menu"); + if (Settings.PlayerESP) + { + DrawShadowText(gfx, _font, _red, new Point(20f, _window.Height / 2 - 20), "Player ESP (Num1) : " + Settings.PlayerESP.ToString()); + } + else + { + DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 - 20), "Player ESP (Num1) : " + Settings.PlayerESP.ToString()); + } + if (Settings.PlayerBox) + { + DrawShadowText(gfx, _font, _red, new Point(20f, _window.Height / 2 - 5), "Player Box (Num2) : " + Settings.PlayerBox.ToString()); + } + else + { + DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 - 5), "Player Box (Num2) : " + Settings.PlayerBox.ToString()); + } + if (Settings.PlayerBone) + { + DrawShadowText(gfx, _font, _red, new Point(20f, _window.Height / 2 + 10), "Player Bone (Num3) : " + Settings.PlayerBone.ToString()); + } + else + { + DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 + 10), "Player Bone (Num3) : " + Settings.PlayerBone.ToString()); + } + if (Settings.PlayerLines) + { + DrawShadowText(gfx, _font, _red, new Point(20f, _window.Height / 2 + 25), "Player Line (Num4) : " + Settings.PlayerLines.ToString()); + } + else + { + DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 + 25), "Player Line (Num4) : " + Settings.PlayerLines.ToString()); + } + if (Settings.PlayerHealth) + { + DrawShadowText(gfx, _font, _red, new Point(20f, _window.Height / 2 + 40), "Player Health (Num5) : " + Settings.PlayerHealth.ToString()); + } + else + { + DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 + 40), "Player Health (Num5) : " + Settings.PlayerHealth.ToString()); + } + if (Settings.ItemESP) + { + DrawShadowText(gfx, _font, _red, new Point(20f, _window.Height / 2 + 55), "Item ESP (Num6) : " + Settings.ItemESP.ToString()); + } + else + { + DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 + 55), "Item ESP (Num6) : " + Settings.ItemESP.ToString()); + } + if (Settings.VehicleESP) + { + DrawShadowText(gfx, _font, _red, new Point(20f, _window.Height / 2 + 70), "Vehicle ESP (Num7) : " + Settings.VehicleESP.ToString()); + } + else + { + DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 + 70), "Vehicle ESP (Num7) : " + Settings.VehicleESP.ToString()); + } + if (Settings.Player3dBox) + { + DrawShadowText(gfx, _font, _red, new Point(20f, _window.Height / 2 + 85), "Player 3D Box (Num8) : " + Settings.Player3dBox.ToString()); + } + else + { + DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 + 85), "Player 3D Box (Num8) : " + Settings.Player3dBox.ToString()); + } + DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 + 100), "┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈"); + } + if (_data.Players.Length > 0) + { + playerCount = _data.Players.Length; + DrawShadowText(gfx, _bigfont, _red, new Point(_window.Width / 2 - 40f, 40f), "Enemy near : " + playerCount); + } + // Read View Matrix + long viewMatrixAddr = Mem.ReadMemory(Mem.ReadMemory(_data.ViewMatrixBase) + 32) + 512; + D3DMatrix viewMatrix = Algorithms.ReadViewMatrix(viewMatrixAddr); + // Draw Player ESP + if (Settings.PlayerESP) + { + foreach (var player in _data.Players) + { + + //if (player.Health <= 0) continue; + if (Algorithms.WorldToScreenPlayer(viewMatrix, player.Position, out ShpVector3 playerScreen, out int distance, _window.Width, _window.Height)) + { + // Too Far not render + if (distance > 500) continue; + float x = playerScreen.X; + float y = playerScreen.Y; + float h = playerScreen.Z; + float w = playerScreen.Z / 2; + + try + { + _boxBrush = _randomBrush[player.TeamID % 7]; + } + catch (IndexOutOfRangeException) + { + _boxBrush = _green; + } + //DrawShadowText(gfx,_font, _green, new Point((x - playerScreen.Z / 4) - 3, y - 15), player.Pose.ToString()); + + // Adjust Box + if (player.Pose == 1114636288) + { + y = playerScreen.Y + playerScreen.Z / 5; + h -= playerScreen.Z / 5; + } + if (player.Pose == 1112014848 || player.Status == 7) + { + y = playerScreen.Y + playerScreen.Z / 4; + h -= playerScreen.Z / 4; + } + + // Draw Info + StringBuilder sb = new StringBuilder("["); + if (player.IsRobot) + sb.Append("[Bot] "); + sb.Append(player.Name); + DrawShadowText(gfx, _infoFont, _boxBrush, new Point(x + w / 2, y - 5), sb.ToString()); + // Draw Distance + sb = new StringBuilder("["); + sb.Append(distance).Append("M]"); + DrawShadowText(gfx, _font, _boxBrush, new Point(x + w / 2, y + 7), sb.ToString()); + + if (Settings.PlayerBox) + { + // Draw Box + gfx.DrawRectangle(_boxBrush, Rectangle.Create(x - playerScreen.Z / 4 - 3, y - 5, w + 3, h + 5), 1); + } + if (Settings.Player3dBox) + { + Draw3DBox(viewMatrix, player, playerScreen, _window.Width, _window.Height, 180f); + // Draw Box + //gfx.DrawRectangle(_boxBrush, Rectangle.Create(x - playerScreen.Z / 4 - 3, y - 5, w + 3, h + 5), 1); + } + if (Settings.PlayerBone) + { + // Draw Bone + long tmpAddv = Mem.ReadMemory(player.Address + tmpOffset); + long bodyAddv = tmpAddv + actorOffset; + long boneAddv = Mem.ReadMemory(tmpAddv + boneOffset) + 48; + DrawPlayerBone(bodyAddv, boneAddv, w, viewMatrix, _window.Width, _window.Height); + } + if (Settings.PlayerHealth) + { + // Draw Health + DrawPlayerBlood((x - playerScreen.Z / 4) - 8, y - 5, h + 5, 3, player.Health); + } + if (Settings.PlayerLines) + { + // Draw Line + gfx.DrawLine(_white, new Line(_window.Width / 2, 0, x, y), 2); + } + } + } + } + // Draw Item ESP + if (Settings.ItemESP) + { + foreach (var item in _data.Items) + { + if (Algorithms.WorldToScreenItem(viewMatrix, item.Position, out ShpVector2 itemScreen, out int distance, _window.Width, _window.Height)) + { + // Too Far not render + if (distance > 100) continue; + // Draw Item + string disStr = string.Format("[{0}m]", distance); + DrawShadowText(gfx, _font, _yellow, new Point(itemScreen.X, itemScreen.Y), item.Name); + DrawShadowText(gfx, _font, _yellow, new Point(itemScreen.X, itemScreen.Y + 10), disStr); + } + } + foreach (var box in _data.Boxes) + { + if (Algorithms.WorldToScreenItem(viewMatrix, box.Position, out ShpVector2 itemScreen, out int distance, _window.Width, _window.Height)) + { + // Too Far not render + if (distance > 100) continue; + DrawShadowText(gfx, _font, _yellow, new Point(itemScreen.X, itemScreen.Y), "Lootbox [" + distance.ToString() + "M]"); + } + } + } + // Draw Vehicle ESP + if (Settings.VehicleESP) + { + foreach (var car in _data.Vehicles) + { + if (Algorithms.WorldToScreenItem(viewMatrix, car.Position, out ShpVector2 carScreen, out int distance, _window.Width, _window.Height)) + { + // Too Far not render + if (distance > 300) continue; + string disStr = string.Format("[{0}m]", distance); + // Draw Car + DrawShadowText(gfx, _font, _blue, new Point(carScreen.X, carScreen.Y), car.Name); + DrawShadowText(gfx, _font, _blue, new Point(carScreen.X, carScreen.Y + 10), disStr); + } + } + } + // Grenade alert + foreach (var gre in _data.Grenades) + { + if (Algorithms.WorldToScreenItem(viewMatrix, gre.Position, out ShpVector2 greScreen, out int distance, _window.Width, _window.Height)) + { + DrawShadowText(gfx, _font, 15, _red, new Point(greScreen.X, greScreen.Y), string.Format("!!! {0} !!! [{1}M]", gre.Type.GetDescription(), distance)); + } + } + gfx.EndScene(); + } + private void Draw3DBox(D3DMatrix viewMatrix, PlayerData player, ShpVector3 playersc, int winWidth, int winHeight, float hei= 180f) + { + float num = 70f; + float num2 = 60f; + float num3 = 50f; + float num4 = 85f; + hei = 180f; + ShpVector3 vector = new ShpVector3(num3, -num2 / 2f, 0f); + ShpVector3 vector2 = new ShpVector3(num3, num2 / 2f, 0f); + ShpVector3 vector3 = new ShpVector3(num3 - num, num2 / 2f, 0f); + ShpVector3 vector4 = new ShpVector3(num3 - num, -num2 / 2f, 0f); + + Matrix matrix = Matrix.RotationZ((6.28318548f * (player.Position.Y ) / 180f / 2f)); + ShpVector3 vector5 = new ShpVector3(player.Position.X, player.Position.Y, player.Position.Z - num4); + vector = ShpVector3.TransformCoordinate(vector, matrix) + vector5; + vector2 = ShpVector3.TransformCoordinate(vector2, matrix) + vector5; + vector3 = ShpVector3.TransformCoordinate(vector3, matrix) + vector5; + vector4 = ShpVector3.TransformCoordinate(vector4, matrix) + vector5; + ShpVector2 vector6; + + if (!Algorithms.WorldToScreen3DBox(viewMatrix, vector, out vector6, winWidth, winHeight)) + return; + ShpVector2 vector7; + if (!Algorithms.WorldToScreen3DBox(viewMatrix, vector2, out vector7, winWidth, winHeight)) + return; + ShpVector2 vector8; + if (!Algorithms.WorldToScreen3DBox(viewMatrix, vector3, out vector8, winWidth, winHeight)) + return; + ShpVector2 vector9; + if (!Algorithms.WorldToScreen3DBox(viewMatrix, vector4, out vector9, winWidth, winHeight)) + return; + + RawVector2[] array = new RawVector2[] + { + vector6, + vector7, + vector8, + vector9, + vector6 + }; + DrawLines(array, _boxBrush); + vector.Z += hei; + + bool arg_240_0 = Algorithms.WorldToScreen3DBox(viewMatrix, vector, out vector6, winWidth, winHeight); + vector2.Z += hei; + bool flag = Algorithms.WorldToScreen3DBox(viewMatrix, vector2, out vector7, winWidth, winHeight); + vector3.Z += hei; + bool flag2 = Algorithms.WorldToScreen3DBox(viewMatrix, vector3, out vector8, winWidth, winHeight); + vector4.Z += hei; + bool flag3 = Algorithms.WorldToScreen3DBox(viewMatrix, vector4, out vector9, winWidth, winHeight); + if (!arg_240_0 || !flag || !flag2 || !flag3) + { + return; + } + RawVector2[] array2 = new RawVector2[] + { + vector6, + vector7, + vector8, + vector9, + vector6 + }; + DrawLines(array2, _boxBrush); + DrawLine(new RawVector2(array[0].X, array[0].Y), new RawVector2(array2[0].X, array2[0].Y), _boxBrush); + DrawLine(new RawVector2(array[1].X, array[1].Y), new RawVector2(array2[1].X, array2[1].Y), _boxBrush); + DrawLine(new RawVector2(array[2].X, array[2].Y), new RawVector2(array2[2].X, array2[2].Y), _boxBrush); + DrawLine(new RawVector2(array[3].X, array[3].Y), new RawVector2(array2[3].X, array2[3].Y), _boxBrush); + } + public void DrawLines( RawVector2[] point0, IBrush gxx) + { + if (point0.Length < 2) + { + return; + } + for (int i = 0; i < point0.Length - 1; i++) + { + DrawLine(point0[i], point0[i + 1], _boxBrush); + } + } + public void DrawLine(RawVector2 a, RawVector2 b, IBrush gcolr) + { + _graphics.DrawLine(_boxBrush, a.X, a.Y, b.X, b.Y, 1f); + } + private void DrawPlayerBone(long bodyAddv, long boneAddv, float w, D3DMatrix viewMatrix, int winWidth, int winHeight) + { + + float sightX = winWidth / 2, sightY = winHeight / 2; + + ShpVector3 headPos = Algorithms.GetBoneWorldPosition(bodyAddv, boneAddv + 5 * 48); + headPos.Z += 7; + ShpVector2 head; + Algorithms.WorldToScreenBone(viewMatrix, headPos, out head, out int distance, winWidth, winHeight); + ShpVector2 neck = head; + ShpVector2 chest; + ShpVector3 chestPos = Algorithms.GetBoneWorldPosition(bodyAddv, boneAddv + 4 * 48); + Algorithms.WorldToScreenBone(viewMatrix, chestPos, out chest, out distance, winWidth, winHeight); + ShpVector2 pelvis; + ShpVector3 pelvisPos = Algorithms.GetBoneWorldPosition(bodyAddv, boneAddv + 1 * 48); + Algorithms.WorldToScreenBone(viewMatrix, pelvisPos, out pelvis, out distance, winWidth, winHeight); + ShpVector2 lSholder; + ShpVector3 lSholderPos = Algorithms.GetBoneWorldPosition(bodyAddv, boneAddv + 11 * 48); + Algorithms.WorldToScreenBone(viewMatrix, lSholderPos, out lSholder, out distance, winWidth, winHeight); + ShpVector2 rSholder; + ShpVector3 rSholderPos = Algorithms.GetBoneWorldPosition(bodyAddv, boneAddv + 32 * 48); + Algorithms.WorldToScreenBone(viewMatrix, rSholderPos, out rSholder, out distance, winWidth, winHeight); + ShpVector2 lElbow; + ShpVector3 lElbowPos = Algorithms.GetBoneWorldPosition(bodyAddv, boneAddv + 12 * 48); + Algorithms.WorldToScreenBone(viewMatrix, lElbowPos, out lElbow, out distance, winWidth, winHeight); + ShpVector2 rElbow; + ShpVector3 rElbowPos = Algorithms.GetBoneWorldPosition(bodyAddv, boneAddv + 33 * 48); + Algorithms.WorldToScreenBone(viewMatrix, rElbowPos, out rElbow, out distance, winWidth, winHeight); + ShpVector2 lWrist; + ShpVector3 lWristPos = Algorithms.GetBoneWorldPosition(bodyAddv, boneAddv + 63 * 48); + Algorithms.WorldToScreenBone(viewMatrix, lWristPos, out lWrist, out distance, winWidth, winHeight); + ShpVector2 rWrist; + ShpVector3 rWristPos = Algorithms.GetBoneWorldPosition(bodyAddv, boneAddv + 62 * 48); + Algorithms.WorldToScreenBone(viewMatrix, rWristPos, out rWrist, out distance, winWidth, winHeight); + ShpVector2 lThigh; + ShpVector3 lThighPos = Algorithms.GetBoneWorldPosition(bodyAddv, boneAddv + 52 * 48); + Algorithms.WorldToScreenBone(viewMatrix, lThighPos, out lThigh, out distance, winWidth, winHeight); + ShpVector2 rThigh; + ShpVector3 rThighPos = Algorithms.GetBoneWorldPosition(bodyAddv, boneAddv + 56 * 48); + Algorithms.WorldToScreenBone(viewMatrix, rThighPos, out rThigh, out distance, winWidth, winHeight); + ShpVector2 lKnee; + ShpVector3 lKneePos = Algorithms.GetBoneWorldPosition(bodyAddv, boneAddv + 53 * 48); + Algorithms.WorldToScreenBone(viewMatrix, lKneePos, out lKnee, out distance, winWidth, winHeight); + ShpVector2 rKnee; + ShpVector3 rKneePos = Algorithms.GetBoneWorldPosition(bodyAddv, boneAddv + 57 * 48); + Algorithms.WorldToScreenBone(viewMatrix, rKneePos, out rKnee, out distance, winWidth, winHeight); + ShpVector2 lAnkle; + ShpVector3 lAnklePos = Algorithms.GetBoneWorldPosition(bodyAddv, boneAddv + 54 * 48); + Algorithms.WorldToScreenBone(viewMatrix, lAnklePos, out lAnkle, out distance, winWidth, winHeight); + ShpVector2 rAnkle; + ShpVector3 rAnklePos = Algorithms.GetBoneWorldPosition(bodyAddv, boneAddv + 58 * 48); + Algorithms.WorldToScreenBone(viewMatrix, rAnklePos, out rAnkle, out distance, winWidth, winHeight); + + if (head != null && chest != null && pelvis != null && lSholder != null + && rSholder != null && lElbow != null && rElbow != null && lWrist != null + && rWrist != null && lThigh != null && rThigh != null && lKnee != null + && rKnee != null && lAnkle != null && rAnkle != null) + { + + _graphics.DrawCircle(_white, new Circle(head.X, head.Y, w / 6), 1); + _graphics.DrawLine(_white, new Line(neck.X, neck.Y, chest.X, chest.Y), 1); + _graphics.DrawLine(_white, new Line(chest.X, chest.Y, pelvis.X, pelvis.Y), 1); + + _graphics.DrawLine(_white, new Line(chest.X, chest.Y, lSholder.X, lSholder.Y), 1); + _graphics.DrawLine(_white, new Line(chest.X, chest.Y, rSholder.X, rSholder.Y), 1); + + _graphics.DrawLine(_white, new Line(lSholder.X, lSholder.Y, lElbow.X, lElbow.Y), 1); + _graphics.DrawLine(_white, new Line(rSholder.X, rSholder.Y, rElbow.X, rElbow.Y), 1); + + _graphics.DrawLine(_white, new Line(lElbow.X, lElbow.Y, lWrist.X, lWrist.Y), 1); + _graphics.DrawLine(_white, new Line(rElbow.X, rElbow.Y, rWrist.X, rWrist.Y), 1); + + _graphics.DrawLine(_white, new Line(pelvis.X, pelvis.Y, lThigh.X, lThigh.Y), 1); + _graphics.DrawLine(_white, new Line(pelvis.X, pelvis.Y, rThigh.X, rThigh.Y), 1); + + _graphics.DrawLine(_white, new Line(lThigh.X, lThigh.Y, lKnee.X, lKnee.Y), 1); + _graphics.DrawLine(_white, new Line(rThigh.X, rThigh.Y, rKnee.X, rKnee.Y), 1); + + _graphics.DrawLine(_white, new Line(lKnee.X, lKnee.Y, lAnkle.X, lAnkle.Y), 1); + _graphics.DrawLine(_white, new Line(rKnee.X, rKnee.Y, rAnkle.X, rAnkle.Y), 1); + + } + } + + + private void DrawShadowText(Graphics gfx, Font font, IBrush brush, Point pt, string txt) + { + var bpPt = new Point(pt.X - 1, pt.Y + 1); + //var bpPt2 = new Point(pt.X + 1, pt.Y - 1); + gfx.DrawText(font, _txtBrush, bpPt, txt); + //gfx.DrawText(font, _txtBrush, bpPt2, txt); + gfx.DrawText(font, brush, pt, txt); + + } + private void DrawShadowText(Graphics gfx, Font font, float fontSize, IBrush brush, Point pt, string txt) + { + var bpPt = new Point(); + bpPt.X = pt.X - 1; + bpPt.Y = pt.Y + 1; + gfx.DrawText(font, fontSize, _txtBrush, bpPt, txt); + gfx.DrawText(font, fontSize, brush, pt, txt); + } + + private void DrawPlayerBlood(float x, float y, float h, float w, float fBlood) + { + if (fBlood > 70.0) + { + //FillRGB(x, y, 5, h, TextBlack); + //FillRGB(x, y, 5, h * fBlood / 100.0, TextGreen); + _graphics.FillRectangle(_black, Rectangle.Create(x, y, w, h)); + _graphics.FillRectangle(_green, Rectangle.Create(x, y, w, h * fBlood / 100)); + } + if (fBlood > 30.0 && fBlood <= 70.0) + { + //FillRGB(x, y, 5, h, TextBlack); + //FillRGB(x, y, 5, h * fBlood / 100.0, TextYellow); + _graphics.FillRectangle(_black, Rectangle.Create(x, y, w, h)); + _graphics.FillRectangle(_yellow, Rectangle.Create(x, y, w, h * fBlood / 100)); + } + if (fBlood > 0.0 && fBlood <= 30.0) + { + //FillRGB(x, y, 5, h, TextBlack); + //FillRGB(x, y, 5, h * fBlood / 100.0, TextRed); + _graphics.FillRectangle(_black, Rectangle.Create(x, y, w, h)); + _graphics.FillRectangle(_red, Rectangle.Create(x, y, w, h * fBlood / 100)); + } + } + + private void _window_SizeChanged(object sender, OverlaySizeEventArgs e) + { + if (_graphics == null) return; + + if (_graphics.IsInitialized) + { + _graphics.Resize(e.Width, e.Height); + } + else + { + _graphics.Width = e.Width; + _graphics.Height = e.Height; + } + } + } +} diff --git a/FodyWeavers.xml b/FodyWeavers.xml new file mode 100644 index 0000000..a5dcf04 --- /dev/null +++ b/FodyWeavers.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/FodyWeavers.xsd b/FodyWeavers.xsd new file mode 100644 index 0000000..44a5374 --- /dev/null +++ b/FodyWeavers.xsd @@ -0,0 +1,111 @@ + + + + + + + + + + + + A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks + + + + + A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. + + + + + A list of unmanaged 32 bit assembly names to include, delimited with line breaks. + + + + + A list of unmanaged 64 bit assembly names to include, delimited with line breaks. + + + + + The order of preloaded assemblies, delimited with line breaks. + + + + + + This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file. + + + + + Controls if .pdbs for reference assemblies are also embedded. + + + + + Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option. + + + + + As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off. + + + + + Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code. + + + + + Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior. + + + + + A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with | + + + + + A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |. + + + + + A list of unmanaged 32 bit assembly names to include, delimited with |. + + + + + A list of unmanaged 64 bit assembly names to include, delimited with |. + + + + + The order of preloaded assemblies, delimited with |. + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs new file mode 100644 index 0000000..1bd0e91 --- /dev/null +++ b/MainForm.Designer.cs @@ -0,0 +1,80 @@ +namespace PUBGMESP +{ + partial class MainForm + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows 窗体设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.Btn_Activate = new System.Windows.Forms.Button(); + this.LoopTimer = new System.Windows.Forms.Timer(this.components); + this.UpdateTimer = new System.Windows.Forms.Timer(this.components); + this.SuspendLayout(); + // + // Btn_Activate + // + this.Btn_Activate.Dock = System.Windows.Forms.DockStyle.Fill; + this.Btn_Activate.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.Btn_Activate.Location = new System.Drawing.Point(0, 0); + this.Btn_Activate.Name = "Btn_Activate"; + this.Btn_Activate.Size = new System.Drawing.Size(419, 47); + this.Btn_Activate.TabIndex = 0; + this.Btn_Activate.Text = "Inject"; + this.Btn_Activate.UseVisualStyleBackColor = true; + this.Btn_Activate.Click += new System.EventHandler(this.Btn_Activate_Click); + // + // LoopTimer + // + this.LoopTimer.Interval = 500; + this.LoopTimer.Tick += new System.EventHandler(this.Loop_Tick); + // + // UpdateTimer + // + this.UpdateTimer.Tick += new System.EventHandler(this.Update_Tick); + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.SystemColors.Control; + this.ClientSize = new System.Drawing.Size(419, 47); + this.Controls.Add(this.Btn_Activate); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Name = "MainForm"; + this.Text = "PUBGM HACK - [ AM7 ]"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing); + this.Load += new System.EventHandler(this.MainForm_Load); + this.ResumeLayout(false); + + } + + #endregion + private System.Windows.Forms.Button Btn_Activate; + private System.Windows.Forms.Timer LoopTimer; + private System.Windows.Forms.Timer UpdateTimer; + } +} + diff --git a/MainForm.cs b/MainForm.cs new file mode 100644 index 0000000..92c6575 --- /dev/null +++ b/MainForm.cs @@ -0,0 +1,520 @@ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Diagnostics; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Security; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Forms; +using static PUBGMESP.SigScanSharp; +using ShpVector3 = SharpDX.Vector3; +using ShpVector2 = SharpDX.Vector2; +namespace PUBGMESP +{ + public partial class MainForm : Form + { + #region Modules + SigScanSharp sigScan; + GameMemSearch ueSearch; + ESPForm espForm; + AimbotForm aimbotForm; + #endregion + + #region Variables + const string WINDOW_NAME = "腾讯手游助手【极速傲引擎】"; + const string WINDOW_NAME_G = "Gameloop【Turbo AOW Motoru】"; + IntPtr hwnd = IntPtr.Zero; + RECT rect; + long uWorld; + long uWorlds; + long uLevel; + long gNames; + long viewWorld; + long gameInstance; + long playerController; + long playerCarry; + int myTeamID; + long uMyself; + long myWorld; + long uCamera; + long uCursor; + long uMyObject; + Vector3 myObjectPos; + long entityEntry; + long entityCount; + #endregion + + public MainForm() + { + InitializeComponent(); + } + + private void MainForm_Load(object sender, EventArgs e) + { + } + + private void Btn_Activate_Click(object sender, EventArgs e) + { + // Enable Debug Privilige + EnableDebugPriv(); + // Get Window Handle + hwnd = FindWindow("TXGuiFoundation", "Gameloop【Turbo AOW Engine】"); + Console.WriteLine(hwnd); + if (hwnd == IntPtr.Zero) + { + hwnd = FindWindow("TXGuiFoundation", WINDOW_NAME_G); + if (hwnd == IntPtr.Zero) + { + MessageBox.Show("Please Open Emulator First!!!"); + return; + } + } + hwnd = FindWindowEx(hwnd, 0, "AEngineRenderWindowClass", "AEngineRenderWindow"); + + // Find true aow_exe process + var aowHandle = FindTrueAOWHandle(); + + // Initialize Memory + Mem.Initialize(aowHandle); + if (Mem.m_pProcessHandle == IntPtr.Zero) + { + MessageBox.Show("Error", "Cannot initialize simulator memory, please restart simulator then retry"); + return; + } + else + { + // Initialize SigScan + sigScan = new SigScanSharp(Mem.m_pProcessHandle); + } + + // Find UWorld Offset + ueSearch = new GameMemSearch(sigScan); + var cands = ueSearch.ViewWorldSearchCandidates(); + viewWorld = ueSearch.GetViewWorld(cands); + uWorld = viewWorld - 4217216; + gNames = viewWorld - 1638204; + if (uWorld > 0) + { + // Start Drawing ESP + LoopTimer.Enabled = true; + UpdateTimer.Enabled = true; + GetWindowRect(hwnd, out rect); + espForm = new ESPForm(rect, ueSearch); + aimbotForm = new AimbotForm(rect, ueSearch); + new Thread(ESPThread).Start(); + new Thread(AimbotThread).Start(); + new Thread(InfoThread).Start(); + Btn_Activate.Enabled = false; + Btn_Activate.Text = "Injected"; + } + else + { + MessageBox.Show("Unable to initialize, please check if simulator and game is running"); + } + } + + private void InfoThread() + { + // offset + int controllerOffset, posOffset, healthOffset, nameOffset, teamIDOffset, poseOffset, statusOffset; + controllerOffset = 96; + posOffset = 336; + healthOffset = 1912; + nameOffset = 1512; + teamIDOffset = 1552; + statusOffset = 868; + poseOffset = 288; + while (true) + { + // Read Basic Offset + uWorlds = Mem.ReadMemory(uWorld); + uLevel = Mem.ReadMemory(uWorlds + 32); + gameInstance = Mem.ReadMemory(uWorlds + 36); + playerController = Mem.ReadMemory(gameInstance + controllerOffset); + playerCarry = Mem.ReadMemory(playerController + 32); + uMyObject = Mem.ReadMemory(playerCarry + 788); + //uMyself = Mem.ReadMemory(uLevel + 124); + //uMyself = Mem.ReadMemory(uMyself + 36); + //uMyself = Mem.ReadMemory(uMyself + 312); + //uCamera = Mem.ReadMemory(playerCarry + 804) + 832; + //uCursor = playerCarry + 732; + //myWorld = Mem.ReadMemory(uMyObject + 312); + //myObjectPos = Mem.ReadMemory(myWorld + posOffset); + entityEntry = Mem.ReadMemory(uLevel + 112); + entityCount = Mem.ReadMemory(uLevel + 116); + // Initilize Display Data + DisplayData data = new DisplayData(viewWorld, uMyObject); + List playerList = new List(); + List itemList = new List(); + List vehicleList = new List(); + List boxList = new List(); + List grenadeList = new List(); + for (int i = 0; i < entityCount; i++) + { + long entityAddv = Mem.ReadMemory(entityEntry + i * 4); + long entityStruct = Mem.ReadMemory(entityAddv + 16); + string entityType = GameData.GetEntityType(gNames, entityStruct); + if (Settings.PlayerESP) + { + // if entity is player + if (GameData.IsPlayer(entityType)) + { + //Console.WriteLine(entityType); + long playerWorld = Mem.ReadMemory(entityAddv + 312); + // read player info + // dead player continue + int status = Mem.ReadMemory(playerWorld + statusOffset); + + if (status == 6) + continue; + // my team player continue + //int isTeam = Mem.ReadMemory(Mem.ReadMemory(Mem.ReadMemory(entityAddv + 724 + 4)) + 20); + //if (isTeam > 0) + // continue; + Mem.WriteMemory(Mem.ReadMemory(uMyObject + 2656) + 352, 300000); + + string name = Encoding.Unicode.GetString(Mem.ReadMemory(Mem.ReadMemory(entityAddv + nameOffset), 32)); + name = name.Substring(0, name.IndexOf('\0')); + PlayerData playerData = new PlayerData + { + Type = entityType, + Address = entityAddv, + Position = Mem.ReadMemory(playerWorld + posOffset), + Status = status, + Pose = Mem.ReadMemory(playerWorld + poseOffset), + IsRobot = Mem.ReadMemory(entityAddv + 692) == 0 ? true : false, + Health = Mem.ReadMemory(entityAddv + healthOffset), + Name = name, + TeamID = Mem.ReadMemory(entityAddv + teamIDOffset), + //IsTeam = isTeam + }; + if (playerData.Address == uMyObject || playerData.Address == uMyself) + { + myTeamID = playerData.TeamID; + continue; + } + if (playerData.TeamID == myTeamID) + continue; + //Console.WriteLine(entityType); + playerList.Add(playerData); + continue; + } + } + if (Settings.ItemESP) + { + // check if this entity is item + Item item = GameData.GetItemType(entityType); + if (item != Item.Useless) + { + // Read Item Info + ItemData itemData = new ItemData + { + Name = item.GetDescription(), + Position = Mem.ReadMemory(Mem.ReadMemory(entityAddv + 312) + posOffset), + Type = item + }; + itemList.Add(itemData); + } + // check if this entity is box + if (GameData.IsBox(entityType)) + { + // Read Box Info + long boxEntity = Mem.ReadMemory(entityAddv + 312); + BoxData boxData = new BoxData(); + boxData.Position = Mem.ReadMemory(boxEntity + posOffset); + boxList.Add(boxData); + continue; + } + } + if (Settings.VehicleESP) + { + Vehicle vehicle = GameData.GetVehicleType(entityType); + if (vehicle != Vehicle.Unknown) + { + // Read Vehicle Info + VehicleData vehicleData = new VehicleData + { + Position = Mem.ReadMemory(Mem.ReadMemory(entityAddv + 312) + posOffset), + Type = vehicle, + Name = vehicle.GetDescription() + }; + vehicleList.Add(vehicleData); + continue; + } + } + // check if the entity is a grenade + Grenade grenade = GameData.GetGrenadeType(entityType); + if (grenade != Grenade.Unknown) + { + long grenadeEntity = Mem.ReadMemory(entityAddv + 312); + GrenadeData greData = new GrenadeData + { + Type = grenade, + Position = Mem.ReadMemory(grenadeEntity + posOffset) + }; + grenadeList.Add(greData); + } + } + data.Players = playerList.ToArray(); + data.Items = itemList.ToArray(); + data.Vehicles = vehicleList.ToArray(); + data.Boxes = boxList.ToArray(); + data.Grenades = grenadeList.ToArray(); + espForm.UpdateData(data); + aimbotForm.UpdateData(data); + Thread.Sleep(10); + } + } + + private void ESPThread() + { + espForm.Initialize(); + while (true) + { + espForm.Update(); + //Thread.Sleep(10); + } + } + private void AimbotThread() + { + aimbotForm.Initialize(); + while (true) + { + aimbotForm.Update(); + //Thread.Sleep(10); + } + } + private IntPtr FindTrueAOWHandle() + { + IntPtr aowHandle = IntPtr.Zero; + uint maxThread = 0; + IntPtr handle = CreateToolhelp32Snapshot(0x2, 0); + if ((int)handle > 0) + { + ProcessEntry32 pe32 = new ProcessEntry32(); + pe32.dwSize = (uint)Marshal.SizeOf(pe32); + int bMore = Process32First(handle, ref pe32); + while (bMore == 1) + { + IntPtr temp = Marshal.AllocHGlobal((int)pe32.dwSize); + Marshal.StructureToPtr(pe32, temp, true); + ProcessEntry32 pe = (ProcessEntry32)Marshal.PtrToStructure(temp, typeof(ProcessEntry32)); + Marshal.FreeHGlobal(temp); + if (pe.szExeFile.Contains("aow_exe.exe") && pe.cntThreads > maxThread) + { + maxThread = pe.cntThreads; + aowHandle = (IntPtr)pe.th32ProcessID; + } + + bMore = Process32Next(handle, ref pe32); + } + CloseHandle(handle); + } + return aowHandle; + } + + + private bool EnableDebugPriv() + { + IntPtr hToken = IntPtr.Zero; + if (!OpenProcessToken(Process.GetCurrentProcess().Handle, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref hToken)) + { + return false; + } + LUID luid = new LUID(); + if (!LookupPrivilegeValue(null, "SeDebugPrivilege", ref luid)) + { + CloseHandle(hToken); + return false; + } + TOKEN_PRIVILEGES tp = new TOKEN_PRIVILEGES(); + tp.PrivilegeCount = 1; + tp.Privileges = new LUID_AND_ATTRIBUTES[1]; + tp.Privileges[0].Luid = luid; + tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; + if (!AdjustTokenPrivileges(hToken, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero)) + { + return false; + } + CloseHandle(hToken); + return true; + } + + + + #region WIN32 API + [DllImport("user32.dll", SetLastError = true)] + private static extern IntPtr GetWindow(IntPtr hWnd, uint uCmd); + + [DllImport("user32.dll")] + [ + return: MarshalAs(UnmanagedType.Bool) + ] + private static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect); + + [DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)] + private static extern IntPtr FindWindow(string lpClassName, string lpWindowName); + + [DllImport("user32.dll", EntryPoint = "FindWindowEx", SetLastError = true)] + + + private static extern IntPtr FindWindowEx(IntPtr hwndParent, uint hwndChildAfter, string lpszClass, string lpszWindow); + + [DllImport("User32.dll")] + public static extern bool GetAsyncKeyState(Keys vKey); + + private const int TOKEN_ADJUST_PRIVILEGES = 0x0020; + private const int TOKEN_QUERY = 0x00000008; + private const int SE_PRIVILEGE_ENABLED = 0x00000002; + + [DllImport("advapi32", SetLastError = true), SuppressUnmanagedCodeSecurityAttribute] + private static extern bool OpenProcessToken(IntPtr ProcessHandle, int DesiredAccess, ref IntPtr TokenHandle); + + [DllImport("kernel32", SetLastError = true), SuppressUnmanagedCodeSecurityAttribute] + private static extern bool CloseHandle(IntPtr handle); + + [StructLayout(LayoutKind.Sequential)] + private struct LUID + { + public UInt32 LowPart; + public Int32 HighPart; + } + + [StructLayout(LayoutKind.Sequential, Pack = 4)] + private struct LUID_AND_ATTRIBUTES + { + public LUID Luid; + public UInt32 Attributes; + } + + [DllImport("advapi32.dll", SetLastError = true)] + private static extern bool LookupPrivilegeValue(string lpSystemName, string lpName, ref LUID lpLuid); + + struct TOKEN_PRIVILEGES + { + public int PrivilegeCount; + [MarshalAs(UnmanagedType.ByValArray)] + public LUID_AND_ATTRIBUTES[] Privileges; + } + // Use this signature if you want the previous state information returned + [DllImport("advapi32.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + private static extern bool AdjustTokenPrivileges(IntPtr TokenHandle, + [MarshalAs(UnmanagedType.Bool)]bool DisableAllPrivileges, + ref TOKEN_PRIVILEGES NewState, + UInt32 BufferLengthInBytes, + IntPtr prev, + IntPtr relen); + + [DllImport("KERNEL32.DLL ")] + public static extern IntPtr CreateToolhelp32Snapshot(uint flags, uint processid); + [DllImport("KERNEL32.DLL ")] + public static extern int Process32First(IntPtr handle, ref ProcessEntry32 pe); + [DllImport("KERNEL32.DLL ")] + public static extern int Process32Next(IntPtr handle, ref ProcessEntry32 pe); + + [StructLayout(LayoutKind.Sequential)] + public struct ProcessEntry32 + { + public uint dwSize; + public uint cntUsage; + public uint th32ProcessID; + public IntPtr th32DefaultHeapID; + public uint th32ModuleID; + public uint cntThreads; + public uint th32ParentProcessID; + public int pcPriClassBase; + public uint dwFlags; + + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public string szExeFile; + }; + [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo); + #endregion + + private void Loop_Tick(object sender, EventArgs e) + { + GetWindowRect(hwnd, out rect); + if (espForm != null) + { + espForm._window.FitToWindow(hwnd, true); + } + if (aimbotForm != null) + { + aimbotForm._window.FitToWindow(hwnd, true); + } + } + + private void Update_Tick(object sender, EventArgs e) + { + if (GetAsyncKeyState(Keys.End)) + { + System.Environment.Exit(-1); + } + if (GetAsyncKeyState(Keys.End)) + { + this.Close(); + } + if (GetAsyncKeyState(Keys.Home)) + { + Settings.ShowMenu = !Settings.ShowMenu; + } + if (GetAsyncKeyState(Keys.NumPad1)) + { + Settings.PlayerESP = !Settings.PlayerESP; + } + if (GetAsyncKeyState(Keys.NumPad2)) + { + Settings.PlayerBox = !Settings.PlayerBox; + } + if (GetAsyncKeyState(Keys.NumPad3)) + { + Settings.PlayerBone = !Settings.PlayerBone; + } + if (GetAsyncKeyState(Keys.NumPad4)) + { + Settings.PlayerLines = !Settings.PlayerLines; + } + if (GetAsyncKeyState(Keys.NumPad5)) + { + Settings.PlayerHealth = !Settings.PlayerHealth; + } + if (GetAsyncKeyState(Keys.NumPad6)) + { + Settings.ItemESP = !Settings.ItemESP; + } + if (GetAsyncKeyState(Keys.NumPad7)) + { + Settings.VehicleESP = !Settings.VehicleESP; + } + if (GetAsyncKeyState(Keys.NumPad8)) + { + Settings.Player3dBox = !Settings.Player3dBox; + } + if (GetAsyncKeyState(Keys.F5)) + { + Settings.aimEnabled = !Settings.aimEnabled; + } + if (GetAsyncKeyState(Keys.F6)) + { + Settings.bDrawFow = !Settings.bDrawFow; + } + } + [DllImport("user32.dll")] + public static extern void mouse_event(uint dwFlags, int dx, int dy, uint dwData, UIntPtr dwExtraInfo); + + private void MainForm_FormClosing(object sender, FormClosingEventArgs e) + { + // Stop ESP + System.Environment.Exit(-1); + } + } +} diff --git a/MainForm.resx b/MainForm.resx new file mode 100644 index 0000000..80e2017 --- /dev/null +++ b/MainForm.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 111, 17 + + \ No newline at end of file diff --git a/PUBESP.csproj b/PUBESP.csproj new file mode 100644 index 0000000..3e48a89 --- /dev/null +++ b/PUBESP.csproj @@ -0,0 +1,145 @@ + + + + + + Debug + AnyCPU + {69B42FC8-AB08-415D-A225-7F0FE305EAEB} + WinExe + PUBESP + PUBESP + v4.7.2 + 512 + true + true + + + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + true + + + x64 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + true + + + LocalIntranet + + + false + + + + Properties\app.manifest + + + + + + + + packages\Costura.Fody.4.1.0\lib\net40\Costura.dll + + + packages\GameOverlay.Net.4.0.3\lib\GameOverlay.dll + + + packages\SharpDX.4.2.0\lib\net45\SharpDX.dll + + + packages\SharpDX.Direct2D1.4.2.0\lib\net45\SharpDX.Direct2D1.dll + + + packages\SharpDX.DXGI.4.2.0\lib\net45\SharpDX.DXGI.dll + + + packages\SharpDX.Mathematics.4.2.0\lib\net45\SharpDX.Mathematics.dll + + + + + + + + + + + + + + + + + + + + Form + + + MainForm.cs + + + + + + + + + MainForm.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + \ No newline at end of file diff --git a/PUBESP.csproj.user b/PUBESP.csproj.user new file mode 100644 index 0000000..c597a10 --- /dev/null +++ b/PUBESP.csproj.user @@ -0,0 +1,6 @@ + + + + false + + \ No newline at end of file diff --git a/PUBESP.sln b/PUBESP.sln new file mode 100644 index 0000000..ad1039a --- /dev/null +++ b/PUBESP.sln @@ -0,0 +1,49 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29519.87 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PUBESP", "PUBESP.csproj", "{69B42FC8-AB08-415D-A225-7F0FE305EAEB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|ARM = Debug|ARM + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|ARM = Release|ARM + Release|ARM64 = Release|ARM64 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {69B42FC8-AB08-415D-A225-7F0FE305EAEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {69B42FC8-AB08-415D-A225-7F0FE305EAEB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {69B42FC8-AB08-415D-A225-7F0FE305EAEB}.Debug|ARM.ActiveCfg = Debug|Any CPU + {69B42FC8-AB08-415D-A225-7F0FE305EAEB}.Debug|ARM.Build.0 = Debug|Any CPU + {69B42FC8-AB08-415D-A225-7F0FE305EAEB}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {69B42FC8-AB08-415D-A225-7F0FE305EAEB}.Debug|ARM64.Build.0 = Debug|Any CPU + {69B42FC8-AB08-415D-A225-7F0FE305EAEB}.Debug|x64.ActiveCfg = Debug|Any CPU + {69B42FC8-AB08-415D-A225-7F0FE305EAEB}.Debug|x64.Build.0 = Debug|Any CPU + {69B42FC8-AB08-415D-A225-7F0FE305EAEB}.Debug|x86.ActiveCfg = Debug|Any CPU + {69B42FC8-AB08-415D-A225-7F0FE305EAEB}.Debug|x86.Build.0 = Debug|Any CPU + {69B42FC8-AB08-415D-A225-7F0FE305EAEB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {69B42FC8-AB08-415D-A225-7F0FE305EAEB}.Release|Any CPU.Build.0 = Release|Any CPU + {69B42FC8-AB08-415D-A225-7F0FE305EAEB}.Release|ARM.ActiveCfg = Release|Any CPU + {69B42FC8-AB08-415D-A225-7F0FE305EAEB}.Release|ARM.Build.0 = Release|Any CPU + {69B42FC8-AB08-415D-A225-7F0FE305EAEB}.Release|ARM64.ActiveCfg = Release|Any CPU + {69B42FC8-AB08-415D-A225-7F0FE305EAEB}.Release|ARM64.Build.0 = Release|Any CPU + {69B42FC8-AB08-415D-A225-7F0FE305EAEB}.Release|x64.ActiveCfg = Release|Any CPU + {69B42FC8-AB08-415D-A225-7F0FE305EAEB}.Release|x64.Build.0 = Release|Any CPU + {69B42FC8-AB08-415D-A225-7F0FE305EAEB}.Release|x86.ActiveCfg = Release|Any CPU + {69B42FC8-AB08-415D-A225-7F0FE305EAEB}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {168FB93D-00DD-42F6-93D6-0A7A4F763071} + EndGlobalSection +EndGlobal diff --git a/Patterns.cs b/Patterns.cs new file mode 100644 index 0000000..6f415c1 --- /dev/null +++ b/Patterns.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PUBGMESP +{ + internal class Patterns + { + #region ESP + public static string viewWorldSearch = "02 00 00 00 80 00 00 00 FF FF FF FF 00 00 00 00 01"; + #endregion + } +} diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..50ad8d5 --- /dev/null +++ b/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace PUBGMESP +{ + static class Program + { + /// + /// 应用程序的主入口点。 + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new MainForm()); + } + } +} diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e875382 --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("PUBGMESP")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PUBGMESP")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("69b42fc8-ab08-415d-a225-7f0fe305eaeb")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs new file mode 100644 index 0000000..9fb9d65 --- /dev/null +++ b/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// Bu kod araç tarafından oluşturuldu. +// Çalışma Zamanı Sürümü:4.0.30319.42000 +// +// Bu dosyada yapılacak değişiklikler yanlış davranışa neden olabilir ve +// kod yeniden oluşturulursa kaybolur. +// +//------------------------------------------------------------------------------ + +namespace PUBESP.Properties { + using System; + + + /// + /// Yerelleştirilmiş dizeleri aramak gibi işlemler için, türü kesin olarak belirtilmiş kaynak sınıfı. + /// + // Bu sınıf ResGen veya Visual Studio gibi bir araç kullanılarak StronglyTypedResourceBuilder + // sınıfı tarafından otomatik olarak oluşturuldu. + // Üye eklemek veya kaldırmak için .ResX dosyanızı düzenleyin ve sonra da ResGen + // komutunu /str seçeneğiyle yeniden çalıştırın veya VS projenizi yeniden oluşturun. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Bu sınıf tarafından kullanılan, önbelleğe alınmış ResourceManager örneğini döndürür. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PUBESP.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Tümü için geçerli iş parçacığının CurrentUICulture özelliğini geçersiz kular + /// CurrentUICulture özelliğini tüm kaynak aramaları için geçersiz kılar. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Properties/Resources.resx b/Properties/Resources.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Properties/Resources.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs new file mode 100644 index 0000000..d14936a --- /dev/null +++ b/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// Bu kod araç tarafından oluşturuldu. +// Çalışma Zamanı Sürümü:4.0.30319.42000 +// +// Bu dosyada yapılacak değişiklikler yanlış davranışa neden olabilir ve +// kod yeniden oluşturulursa kaybolur. +// +//------------------------------------------------------------------------------ + +namespace PUBESP.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.4.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/Properties/Settings.settings b/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Properties/app.manifest b/Properties/app.manifest new file mode 100644 index 0000000..15b2b8c --- /dev/null +++ b/Properties/app.manifest @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Settings.cs b/Settings.cs new file mode 100644 index 0000000..262e182 --- /dev/null +++ b/Settings.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PUBGMESP +{ + internal class Settings + { + public static bool PlayerESP = true; + public static bool PlayerBone = false; + public static bool PlayerBox = false; + public static bool Player3dBox = true; + public static bool PlayerLines = true; + public static bool PlayerHealth = false; + public static bool ItemESP = false; + public static bool VehicleESP = false; + public static bool ShowMenu = true; + + // aimbot + public static bool aimEnabled = true; + public static bool bDrawFow = true; + public static int bSmooth = 11; + public static int bFovInt = 2; + public static int bPredict = 1; + public static int bYAxis = 2; + public static int bAimKeyINT = 2; + public static string[] aimkeys = { "CAPSLOCK", "LBUTTON", "RBUTTON", "LSHIFT", "V", "E", "Q" }; + public static System.Windows.Forms.Keys[] bAimKeys = new System.Windows.Forms.Keys[] { System.Windows.Forms.Keys.CapsLock, System.Windows.Forms.Keys.LButton, System.Windows.Forms.Keys.RButton, System.Windows.Forms.Keys.LShiftKey, System.Windows.Forms.Keys.V, System.Windows.Forms.Keys.E, System.Windows.Forms.Keys.Q }; + public static float[] bFovArray = new float[] + { + 60f, + 90f, + 120f, + 160f, + 300f, + 300f + }; + } +} diff --git a/Structs.cs b/Structs.cs new file mode 100644 index 0000000..9e519b3 --- /dev/null +++ b/Structs.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; + +namespace PUBGMESP +{ + + [StructLayout(LayoutKind.Sequential)] + public struct RECT + { + public int left; + public int top; + public int right; + public int bottom; + } + + [StructLayout(LayoutKind.Explicit)] + internal struct FTTransform + { + [FieldOffset(0x00)] + public Vector4 Rotation; + [FieldOffset(0x10)] + public Vector3 Translation; + [FieldOffset(0x1C)] + public Vector3 Scale3D; + } + + [StructLayout(LayoutKind.Explicit)] + internal struct FTTransform2 + { + [FieldOffset(0x00)] + public Vector4 Rotation; + [FieldOffset(0x10)] + public Vector3 Translation; + [FieldOffset(0x20)] + public Vector3 Scale3D; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct D3DMatrix + { + public float _11, _12, _13, _14; + public float _21, _22, _23, _24; + public float _31, _32, _33, _34; + public float _41, _42, _43, _44; + } + + [StructLayout(LayoutKind.Sequential)] + public struct Vector2 + { + public float X; + public float Y; + } + + [StructLayout(LayoutKind.Sequential)] + public struct Vector3 + { + public float X; + public float Y; + public float Z; + } + + [StructLayout(LayoutKind.Sequential)] + public struct Vector4 + { + + public float X; + public float Y; + public float Z; + public float W; + + public Vector4(float x, float y, float z, float w) : this() + { + this.W = w; + this.X = x; + this.Y = y; + this.Z = z; + } + } +} diff --git a/Utilities.cs b/Utilities.cs new file mode 100644 index 0000000..1a774a7 --- /dev/null +++ b/Utilities.cs @@ -0,0 +1,759 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Linq; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Text; +using System.Windows.Forms; +using static PUBGMESP.SigScanSharp; + +namespace PUBGMESP +{ + + + public class SigScanSharp + { + public class BypaPH : IDisposable + { + [DllImport("BypaPH.dll", EntryPoint = "CreateInstance")] + static extern IntPtr BypaPH_ctor(uint pID); + [DllImport("BypaPH.dll", EntryPoint = "DeleteInstance")] + static extern void BypaPH_dtor(IntPtr pInstance); + [DllImport("BypaPH.dll", EntryPoint = "RWVM")] + static extern bool BypaPH_RWVM(IntPtr pInstance, UIntPtr BaseAddress, [Out] byte[] Buffer, UIntPtr BufferSize, out ulong NumberOfBytesReadOrWritten, + bool read = true, bool unsafeRequest = false); + IntPtr pInstance; + public BypaPH(int pID) + { + pInstance = BypaPH_ctor((uint)pID); + } + public bool ReadProcessMem(ulong BaseAddress, out byte[] Buffer, int BufferSize, out ulong NumberOfBytesRead) + { + byte[] buf = new byte[BufferSize]; + bool b = BypaPH_RWVM(pInstance, new UIntPtr(BaseAddress), buf, new UIntPtr((uint)buf.Length), out NumberOfBytesRead); + + Buffer = buf; + return b; + } + public bool WriteProcessMem(ulong BaseAddress, byte[] Buffer, out ulong NumberOfBytesWittin) + { + return BypaPH_RWVM(pInstance, new UIntPtr(BaseAddress), Buffer, new UIntPtr((uint)Buffer.Length), out NumberOfBytesWittin, false); + } + public void Dispose() + { + BypaPH_dtor(pInstance); + } + } + private IntPtr g_hProcess { get; set; } + private byte[] g_arrModuleBuffer { get; set; } + private long g_lpModuleBase { get; set; } + + private Win32.MEMORY_BASIC_INFORMATION MBI; + + private static byte question = (byte)'?'; + + private Dictionary g_dictStringPatterns { get; } + + public SigScanSharp(IntPtr hProc) + { + g_hProcess = hProc; + g_dictStringPatterns = new Dictionary(); + } + + public bool SelectModule(ProcessModule targetModule) + { + g_lpModuleBase = (long)targetModule.BaseAddress; + g_arrModuleBuffer = new byte[targetModule.ModuleMemorySize]; + + g_dictStringPatterns.Clear(); + + return Win32.ReadProcessMemory(g_hProcess, g_lpModuleBase, g_arrModuleBuffer, targetModule.ModuleMemorySize); + } + + public void AddPattern(string szPatternName, string szPattern) + { + g_dictStringPatterns.Add(szPatternName, szPattern); + } + + private bool PatternCheck(int nOffset, byte[] arrPattern) + { + for (int i = 0; i < arrPattern.Length; i++) + { + if (arrPattern[i] == question) + continue; + + if (arrPattern[i] != this.g_arrModuleBuffer[nOffset + i]) + return false; + } + + return true; + } + + private bool PatternCheck(int nOffset, byte[] arrPattern, byte[] source) + { + if (nOffset + arrPattern.Length > source.Length) return false; + for (int i = 0; i < arrPattern.Length; i++) + { + if (arrPattern[i] == question) + continue; + + if (arrPattern[i] != source[nOffset + i]) + return false; + } + + return true; + } + + public long FindPattern(string szPattern, out long lTime) + { + if (g_arrModuleBuffer == null || g_lpModuleBase == 0) + throw new Exception("Selected module is null"); + + Stopwatch stopwatch = Stopwatch.StartNew(); + + byte[] arrPattern = ParsePatternString(szPattern); + + for (int nModuleIndex = 0; nModuleIndex < g_arrModuleBuffer.Length; nModuleIndex++) + { + if (this.g_arrModuleBuffer[nModuleIndex] != arrPattern[0]) + continue; + + if (PatternCheck(nModuleIndex, arrPattern)) + { + lTime = stopwatch.ElapsedMilliseconds; + return g_lpModuleBase + (long)nModuleIndex; + } + } + + lTime = stopwatch.ElapsedMilliseconds; + return 0; + } + + public long[] FindPatternsAllRegion(string szPattern, long iStartAddress = 0, long iEndAddress = 0x7FFFFFFF) + { + byte[] arrPattern = ParsePatternString(szPattern); + long iAddress = iStartAddress; int ptrBytesRead = 0; byte[] bBuffer; + List matchAddvs = new List(); + do + { + int iRead = Win32.VirtualQueryEx(g_hProcess, (IntPtr)iAddress, out MBI, (uint)Marshal.SizeOf(MBI)); + if ((iRead > 0) && ((long)MBI.RegionSize > 0)) + { + //bBuffer = new byte[(long)MBI.RegionSize]; + bBuffer = Mem.ReadMemory((long)MBI.BaseAddress, (int)MBI.RegionSize); + //Win32.ReadProcessMemory(g_hProcess, (long)MBI.BaseAddress, bBuffer, bBuffer.Length, ptrBytesRead); + for (int i = 0; i < bBuffer.Length; i++) + { + if (bBuffer[i] != arrPattern[0]) continue; + if (PatternCheck(i, arrPattern, bBuffer)) + { + matchAddvs.Add((long)(iAddress + i)); + i += arrPattern.Length; + } + } + } + iAddress = (long)(MBI.BaseAddress.ToInt64() + MBI.RegionSize.ToInt64()); + } while (iAddress <= iEndAddress); + return matchAddvs.ToArray(); + } + + public Dictionary FindPatterns(out long lTime) + { + if (g_arrModuleBuffer == null || g_lpModuleBase == 0) + throw new Exception("Selected module is null"); + + Stopwatch stopwatch = Stopwatch.StartNew(); + + byte[][] arrBytePatterns = new byte[g_dictStringPatterns.Count][]; + long[] arrResult = new long[g_dictStringPatterns.Count]; + + // PARSE PATTERNS + for (int nIndex = 0; nIndex < g_dictStringPatterns.Count; nIndex++) + arrBytePatterns[nIndex] = ParsePatternString(g_dictStringPatterns.ElementAt(nIndex).Value); + + // SCAN FOR PATTERNS + for (int nModuleIndex = 0; nModuleIndex < g_arrModuleBuffer.Length; nModuleIndex++) + { + for (int nPatternIndex = 0; nPatternIndex < arrBytePatterns.Length; nPatternIndex++) + { + if (arrResult[nPatternIndex] != 0) + continue; + + if (this.PatternCheck(nModuleIndex, arrBytePatterns[nPatternIndex])) + arrResult[nPatternIndex] = g_lpModuleBase + (long)nModuleIndex; + } + } + + Dictionary dictResultFormatted = new Dictionary(); + + // FORMAT PATTERNS + for (int nPatternIndex = 0; nPatternIndex < arrBytePatterns.Length; nPatternIndex++) + dictResultFormatted[g_dictStringPatterns.ElementAt(nPatternIndex).Key] = arrResult[nPatternIndex]; + + lTime = stopwatch.ElapsedMilliseconds; + return dictResultFormatted; + } + + private byte[] ParsePatternString(string szPattern) + { + List patternbytes = new List(); + + foreach (var szByte in szPattern.Split(' ')) + patternbytes.Add(szByte == "?" ? (byte)'?' : Convert.ToByte(szByte, 16)); + + return patternbytes.ToArray(); + } + + private static class Win32 + { + [DllImport("kernel32.dll")] + public static extern bool ReadProcessMemory(IntPtr hProcess, long lpBaseAddress, byte[] lpBuffer, int dwSize, int lpNumberOfBytesRead = 0); + + [DllImport("kernel32.dll")] + internal static extern Int32 VirtualQueryEx(IntPtr hProcess, IntPtr lpAddress, out Win32.MEMORY_BASIC_INFORMATION lpBuffer, uint dwLength); + + [StructLayout(LayoutKind.Sequential)] + public struct MEMORY_BASIC_INFORMATION + { + public IntPtr BaseAddress; + public IntPtr AllocationBase; + public uint AllocationProtect; + public IntPtr RegionSize; + public uint State; + public uint Protect; + public uint Type; + } + } + } + + public class Mem + { + public static int m_iNumberOfBytesRead = 0; + public static int m_iNumberOfBytesWritten = 0; + public static Process m_Process; + public static IntPtr m_pProcessHandle = IntPtr.Zero; + public static Int64 BaseAddress; + private const int PROCESS_VM_OPERATION = 8; + private const int PROCESS_VM_READ = 16; + private const int PROCESS_VM_WRITE = 32; + + public static void Initialize(string ProcessName) + { + if ((uint)Process.GetProcessesByName(ProcessName).Length > 0U) + { + Mem.m_Process = Process.GetProcessesByName(ProcessName)[0]; + Mem.BaseAddress = Process.GetProcessesByName(ProcessName)[0].MainModule.BaseAddress.ToInt64(); + } + else + { + int num = (int)MessageBox.Show("Emulator should start first!!!"); + Environment.Exit(1); + } + Mem.m_pProcessHandle = Mem.OpenProcess(0x1F0FFF, false, Mem.m_Process.Id); + } + public static BypaPH ByPH; + public static void Initialize(IntPtr ptr) + { + if (ptr != IntPtr.Zero) + { + ByPH = new BypaPH((int)ptr); + Mem.m_pProcessHandle = Mem.OpenProcess(0x1F0FFF, false, (int)ptr); + } + } + + public static Int64 GetModuleAdress(string ModuleName) + { + Int64 num; + try + { + foreach (ProcessModule module in (ReadOnlyCollectionBase)Mem.m_Process.Modules) + { + if (!ModuleName.Contains(".dll")) + ModuleName = ModuleName.Insert(ModuleName.Length, ".dll"); + if (ModuleName == module.ModuleName) + { + num = (Int64)module.BaseAddress; + goto label_13; + } + } + } + catch + { + } + num = -1; + label_13: + return num; + } + + public static string ReadString(Int64 address, int _Size) + { + return Encoding.Default.GetString(ReadMemory(address, _Size)); + } + + + public static T ReadMemory(Int64 Adress) where T : struct + { + ulong num; + byte[] numArray = new byte[Marshal.SizeOf(typeof(T))]; + ByPH.ReadProcessMem((ulong)Adress, out numArray, numArray.Length, out num); + //Mem.ReadProcessMemory((int)Mem.m_pProcessHandle, Adress, numArray, numArray.Length, ref Mem.m_iNumberOfBytesRead); + return Mem.ByteArrayToStructure(numArray); + } + + public static byte[] ReadMemory(Int64 address, int _Size) + { + ulong num; + byte[] numArray = new byte[_Size]; + ByPH.ReadProcessMem((ulong)address, out numArray, numArray.Length, out num); + //Mem.ReadProcessMemory((int)Mem.m_pProcessHandle, address, numArray, _Size, ref Mem.m_iNumberOfBytesRead); + return numArray; + } + + public static float[] ReadMatrix(Int64 Adress, int MatrixSize) where T : struct + { + byte[] numArray = new byte[Marshal.SizeOf(typeof(T)) * MatrixSize]; + ulong num; + ByPH.ReadProcessMem((ulong)Adress, out numArray, numArray.Length, out num); + return Mem.ConvertToFloatArray(numArray); + } + + public static void WriteMemory(Int64 Adress, object Value) where T : struct + { + byte[] byteArray = Mem.StructureToByteArray(Value); + ulong num; + ByPH.WriteProcessMem((ulong)Adress, byteArray, out num); + //Mem.WriteProcessMemory((int)Mem.m_pProcessHandle, Adress, byteArray, byteArray.Length, out Mem.m_iNumberOfBytesWritten); + } + + public static void WriteMemory(Int64 Adress, byte[] byteArray) + { + ulong num; + ByPH.WriteProcessMem((ulong)Adress, byteArray, out num); + } + + public static byte[] PatternToBytes(string pattern, int offset = 0) + { + var patternArr = pattern.Split(' '); + List result = new List(); + for (int i = offset; i < patternArr.Length; i++) + { + if (patternArr[i] == "?") continue; + result.Add(Convert.ToByte(patternArr[i], 16)); + } + return result.ToArray(); + } + + public static float[] ConvertToFloatArray(byte[] bytes) + { + if ((uint)(bytes.Length % 4) > 0U) + throw new ArgumentException(); + float[] numArray = new float[bytes.Length / 4]; + for (int index = 0; index < numArray.Length; ++index) + numArray[index] = BitConverter.ToSingle(bytes, index * 4); + return numArray; + } + + private static T ByteArrayToStructure(byte[] bytes) where T : struct + { + GCHandle gcHandle = GCHandle.Alloc((object)bytes, GCHandleType.Pinned); + try + { + return (T)Marshal.PtrToStructure(gcHandle.AddrOfPinnedObject(), typeof(T)); + } + finally + { + gcHandle.Free(); + } + } + + public static IntPtr AllocateMemory(uint size) + { + return VirtualAllocEx(Mem.m_pProcessHandle, IntPtr.Zero, size, AllocationType.Commit, MemoryProtection.ReadWrite); + } + + private static byte[] StructureToByteArray(object obj) + { + int length = Marshal.SizeOf(obj); + byte[] destination = new byte[length]; + IntPtr num = Marshal.AllocHGlobal(length); + Marshal.StructureToPtr(obj, num, true); + Marshal.Copy(num, destination, 0, length); + Marshal.FreeHGlobal(num); + return destination; + } + + [DllImport("kernel32.dll")] + private static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId); + + + [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)] + static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, uint dwSize, AllocationType flAllocationType, MemoryProtection flProtect); + + [Flags] + public enum AllocationType + { + Commit = 0x1000, + Reserve = 0x2000, + Decommit = 0x4000, + Release = 0x8000, + Reset = 0x80000, + Physical = 0x400000, + TopDown = 0x100000, + WriteWatch = 0x200000, + LargePages = 0x20000000 + } + + [Flags] + public enum MemoryProtection + { + Execute = 0x10, + ExecuteRead = 0x20, + ExecuteReadWrite = 0x40, + ExecuteWriteCopy = 0x80, + NoAccess = 0x01, + ReadOnly = 0x02, + ReadWrite = 0x04, + WriteCopy = 0x08, + GuardModifierflag = 0x100, + NoCacheModifierflag = 0x200, + WriteCombineModifierflag = 0x400 + } + } + + public class GameMemSearch + { + SigScanSharp sgn; + public GameMemSearch(SigScanSharp sgn) + { + this.sgn = sgn; + } + + public long[] ViewWorldSearchCandidates(long startAddv = 0x26000000, long endAddv = 0x30000000) + { + long[] tmpViewWorlds = sgn.FindPatternsAllRegion(Patterns.viewWorldSearch, startAddv, endAddv); + long[] viewWorlds = new long[tmpViewWorlds.Length]; + for (int i = 0; i < viewWorlds.Length; i++) + viewWorlds[i] = tmpViewWorlds[i] - 32; + return viewWorlds; + } + + public long GetViewWorld(long[] cands) + { + long tmp; + float t1, t2, t3, t4; + for (int i = 0; i < cands.Length; i++) + { + tmp = Mem.ReadMemory(Mem.ReadMemory(cands[i]) + 32) + 512; + t1 = Mem.ReadMemory(tmp + 56); + t2 = Mem.ReadMemory(tmp + 40); + t3 = Mem.ReadMemory(tmp + 24); + t4 = Mem.ReadMemory(tmp + 8); + if (t1 >= 3 && t2 == 0 && t3 == 0 && t4 == 0) + { + return cands[i]; + } + } + return -1; + } + } + + public static class GameData + { + /// + /// Tell if a entity is player + /// + /// + /// + public static bool IsPlayer(string str) + { + if (str.Contains("BP_PlayerPawn")) + return true; + return false; + } + + + /// + /// Get Box Item From Item Code + /// + /// + /// + public static Item GetBoxItemType(long code) + { + if (code == 601001) + return Item.EnegyDrink; + if (code == 601002) + return Item.Epinephrine; + if (code == 601003) + return Item.PainKiller; + if (code == 601005) + return Item.AidKit; + if (code == 501006) + return Item.BagLv3; + if (code == 503003) + return Item.ArmorLv3; + if (code == 502003) + return Item.HelmetLv3; + if (code == 103003) + return Item.AWM; + if (code == 101003) + return Item.SCARL; + if (code == 103001) + return Item.Kar98; + if (code == 101008) + return Item.M762; + if (code == 105002) + return Item.DP28; + if (code == 101005) + return Item.Groza; + if (code == 101001) + return Item.AKM; + if (code == 101006) + return Item.AUG; + if (code == 101007) + return Item.QBZ; + if (code == 105001) + return Item.M249; + if (code == 101004) + return Item.M4A1; + if (code == 306001) + return Item.AmmoMagnum; + if (code == 302001) + return Item.Ammo762; + if (code == 303001) + return Item.Ammo556; + if (code == 203004) + return Item.Scope4x; + if (code == 203015) + return Item.Scope6x; + if (code == 203005) + return Item.Scope8x; + if (code == 201011) + return Item.RifleSilenter; + if (code == 204013) + return Item.RifleMagazine; + if (code == 403990 || code == 403187) + return Item.GhillieSuit; + return Item.Useless; + } + + + /// + /// Tell if an item is box + /// + /// + /// + public static bool IsBox(string str) + { + if (str.Contains("PlayerDeadInventoryBox") || str.Contains("PickUpListWrapperActor") || str.Contains("AirDrop")) + return true; + return false; + } + + /// + /// Get Grenade Type + /// + /// + /// + public static Grenade GetGrenadeType(string str) + { + if (str.Contains("BP_Grenade_Smoke_C")) + return Grenade.Smoke; + if (str.Contains("BP_Grenade_Burn_C")) + return Grenade.Burn; + if (str.Contains("BP_Grenade_tun_C")) + return Grenade.Flash; + if (str.Contains("BP_Grenade_Shoulei_C")) + return Grenade.Explode; + return Grenade.Unknown; + } + + /// + /// Get Vehicle Type + /// + /// + /// + public static Vehicle GetVehicleType(string str) + { + if (str.Contains("BRDM")) + return Vehicle.BRDM; + if (str.Contains("Scooter")) + return Vehicle.Scooter; + if (str.Contains("Motorcycle")) + return Vehicle.Motorcycle; + if (str.Contains("MotorcycleCart")) + return Vehicle.MotorcycleCart; + if (str.Contains("Snowmobile")) + return Vehicle.Snowmobile; + if (str.Contains("Tuk")) + return Vehicle.Tuk; + if (str.Contains("Buggy")) + return Vehicle.Buggy; + if (str.Contains("open")) + return Vehicle.Sports; + if (str.Contains("close")) + return Vehicle.Sports; + if (str.Contains("Dacia")) + return Vehicle.Dacia; + if (str.Contains("Rony")) + return Vehicle.Rony; + if (str.Contains("UAZ")) + return Vehicle.UAZ; + if (str.Contains("MiniBus")) + return Vehicle.MiniBus; + if (str.Contains("PG117")) + return Vehicle.PG117; + if (str.Contains("AquaRail")) + return Vehicle.AquaRail; + if (str.Contains("BP_AirDropPlane_C")) + return Vehicle.BP_AirDropPlane_C; + //if (str.Contains("PickUp")) + //{ + // if (str.Contains("PickUp_BP")) + // { + // if (str != "PickUpListWrapperActor") + // return Vehicle.PickUp; + // } + //} + return Vehicle.Unknown; + } + + /// + /// Get Item's Type + /// + /// + /// + public static Item GetItemType(string str) + { + //if (!str.Contains("Pickup") || !str.Contains("PickUp")) + // return Item.Useless; + if (str.Contains("Grenade_Shoulei_Weapon_Wra")) + return Item.Grenade; + if (str.Contains("MZJ_4X")) + return Item.Scope4x; + if (str.Contains("MZJ_6X")) + return Item.Scope6x; + if (str.Contains("MZJ_8X")) + return Item.Scope8x; + if (str.Contains("DJ_Large_EQ")) + return Item.RifleMagazine; + if (str.Contains("QK_Sniper_Suppressor")) + return Item.SniperSilenter; + if (str.Contains("QK_Large_Suppressor")) + return Item.RifleSilenter; + //if (str.Contains("Ammo_556mm")) + // return Item.Ammo556; + //if (str.Contains("Ammo_762mm")) + // return Item.Ammo762; + //if (str.Contains("Ammo_300Magnum")) + // return Item.AmmoMagnum; + if (str.Contains("Helmet_Lv3")) + return Item.HelmetLv3; + if (str.Contains("Armor_Lv3")) + return Item.ArmorLv3; + if (str.Contains("Bag_Lv3")) + return Item.BagLv3; + if (str.Contains("Helmet_Lv2")) + return Item.HelmetLv2; + if (str.Contains("Armor_Lv2")) + return Item.ArmorLv2; + if (str.Contains("Bag_Lv2")) + return Item.BagLv2; + if (str.Contains("Firstaid")) + return Item.AidKit; + if (str.Contains("Injection")) + return Item.Epinephrine; + if (str.Contains("Pills")) + return Item.PainKiller; + if (str.Contains("Drink")) + return Item.EnegyDrink; + if (!str.Contains("Wrapper")) + return Item.Useless; + if (str.Contains("Pistol_Flaregun")) + return Item.FlareGun; + if (str.Contains("AWM")) + return Item.AWM; + if (str.Contains("Kar98k")) + return Item.Kar98; + if (str.Contains("Mk14")) + return Item.MK14; + if (str.Contains("DP28")) + return Item.DP28; + if (str.Contains("SKS")) + return Item.SKS; + if (str.Contains("Groza")) + return Item.Groza; + if (str.Contains("M762")) + return Item.M762; + if (str.Contains("AKM")) + return Item.AKM; + if (str.Contains("M249")) + return Item.M249; + if (str.Contains("M24")) + return Item.M24; + if (str.Contains("AUG")) + return Item.AUG; + if (str.Contains("QBZ")) + return Item.QBZ; + if (str.Contains("M416")) + return Item.M4A1; + if (str.Contains("SCAR")) + return Item.SCARL; + + return Item.Useless; + } + + /// + /// Get Entity's Type + /// + /// + /// + /// + public static string GetEntityType(long gNames, long id) + { + string result = ""; + long gname = Mem.ReadMemory(gNames); + if (id > 0 && id < 2000000) + { + long page = id / 16384; + long index = id % 16384; + long secPartAddv = Mem.ReadMemory(gname + page * 4); + if (secPartAddv > 0) + { + long nameAddv = Mem.ReadMemory(secPartAddv + index * 4); + if (nameAddv > 0) + { + result = Mem.ReadString(nameAddv + 8, 32); + } + } + } + return result; + } + + + } + + internal static class Utility + { + public static string GetDescription(this Enum value) + { + FieldInfo field = value.GetType().GetField(value.ToString()); + + DescriptionAttribute attribute + = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) + as DescriptionAttribute; + + return attribute == null ? value.ToString() : attribute.Description; + } + + public static bool CheckFeasible(this Vector2 vec) + { + if (vec.X > 1 && vec.Y > 1) + return true; + return false; + } + } +} + diff --git a/dependencies/BypaPH.dll b/dependencies/BypaPH.dll new file mode 100644 index 0000000..0922e93 Binary files /dev/null and b/dependencies/BypaPH.dll differ diff --git a/dependencies/kprocesshacker.sys b/dependencies/kprocesshacker.sys new file mode 100644 index 0000000..4da0af3 Binary files /dev/null and b/dependencies/kprocesshacker.sys differ diff --git a/packages.config b/packages.config new file mode 100644 index 0000000..a0f77de --- /dev/null +++ b/packages.config @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file