コード例 #1
0
ファイル: Form1.cs プロジェクト: lujiawen/helloworld
        public Form1()
        {
            InitializeComponent();
            //Make the window's border completely transparant

            // ANTI BATTLEYE SIG SCAN ;)
            this.Text = Guid.NewGuid().ToString().Replace("-", "");

            // TRANSPARENCY KEY
            this.BackColor = System.Drawing.Color.Black;

            // SETTINGS
            this.FormBorderStyle = FormBorderStyle.None;
            this.ShowIcon        = false;
            this.ShowInTaskbar   = false;
            this.TopMost         = true;
            this.WindowState     = FormWindowState.Maximized;

            // MAKE WINDOW TRANSPARENT
            Win32.SetWindowLong(this.Handle, Win32.GWL_EXSTYLE, (IntPtr)(Win32.GetWindowLong(this.Handle, Win32.GWL_EXSTYLE) ^ Win32.WS_EX_LAYERED ^ Win32.WS_EX_TRANSPARENT));

            // MAKE WINDOW SOLID
            Win32.SetLayeredWindowAttributes(this.Handle, 0, 255, Win32.LWA_ALPHA);

            var targetProperties = new HwndRenderTargetProperties
            {
                Hwnd           = this.Handle,
                PixelSize      = new Size2(this.Bounds.Right - this.Bounds.Left, this.Bounds.Bottom - this.Bounds.Top),
                PresentOptions = PresentOptions.Immediately
            };

            var prop = new RenderTargetProperties(RenderTargetType.Hardware, new PixelFormat(Format.B8G8R8A8_UNorm, SharpDX.Direct2D1.AlphaMode.Premultiplied), 0, 0, RenderTargetUsage.None, FeatureLevel.Level_DEFAULT);

            var d3dFactory = new SharpDX.Direct2D1.Factory();

            var device = new WindowRenderTarget(d3dFactory, prop, targetProperties)
            {
                TextAntialiasMode = TextAntialiasMode.Cleartype,
                AntialiasMode     = AntialiasMode.Aliased
            };

            var url      = "http://127.0.0.1:8888/api/values/5";
            var dxthread = new Thread(() =>
            {
                var brushWhite  = new SolidColorBrush(device, RawColorFromColor(Color.White));
                var brushBlack  = new SolidColorBrush(device, RawColorFromColor(Color.Black));
                var brushGreen  = new SolidColorBrush(device, RawColorFromColor(Color.Green));
                var brushRed    = new SolidColorBrush(device, RawColorFromColor(Color.Red));
                var brushPurple = new SolidColorBrush(device, RawColorFromColor(Color.Purple));


                var fontFactory = new SharpDX.DirectWrite.Factory();

                var fontConsolas = new SharpDX.DirectWrite.TextFormat(fontFactory, "Consolas", 15);
                var fontESP      = new SharpDX.DirectWrite.TextFormat(fontFactory, "Consolas", 12);

                JSON_DATA json_data = null;

                using (var w = new WebClient())
                {
                    while (!w.IsBusy)
                    {
                        // attempt to download JSON data as a string
                        try
                        {
                            var str   = w.DownloadString(url);
                            json_data = JsonConvert.DeserializeObject <JSON_DATA>(str);
                        }
                        catch (Exception)
                        {
                        }
                        finally
                        {
                            device.BeginDraw();
                            device.Clear(null);

                            #region RADAR

                            int radarX          = 20;
                            int radarY          = 140;
                            int radarSize       = 200;
                            int radarBorder     = 1;
                            Vector2 centerpoint = new Vector2(radarX + radarSize / 2, radarY + radarSize / 2);

                            // TODO: INTEGRATE INTO MINIMAP
                            if (false)
                            {
                                var radarOuterRectangle = new RawRectangleF(radarX, radarY, radarX + radarSize,
                                                                            radarY + radarSize);
                                var radarRectangle = new RawRectangleF(radarX + radarBorder, radarY + radarBorder,
                                                                       radarX + radarSize - radarBorder, radarY + radarSize - radarBorder);

                                var radarCenterRectangle = new RoundedRectangle()
                                {
                                    RadiusX = 4,
                                    RadiusY = 4,
                                    Rect    = new RawRectangleF(centerpoint.X, centerpoint.Y, centerpoint.X + 4,
                                                                centerpoint.Y + 4)
                                };

                                device.FillRectangle(radarRectangle, brushBlack);
                                device.DrawRectangle(radarRectangle, brushWhite);

                                device.FillRoundedRectangle(radarCenterRectangle, brushGreen);
                            }

                            #endregion


                            var vecLocalLocation = new Model.Vector3
                            {
                                X = json_data.camera[1].X,
                                Y = json_data.camera[1].Y,
                                Z = json_data.camera[1].Z
                            };

                            var PlayerCameraManager = new APlayerCameraManager
                            {
                                CameraCache = new FCameraCacheEntry
                                {
                                    POV = new FMinimalViewInfo
                                    {
                                        Fov      = json_data.camera[2].X,
                                        Location = new Model.Vector3
                                        {
                                            X = json_data.camera[1].X,
                                            Y = json_data.camera[1].Y,
                                            Z = json_data.camera[1].Z
                                        },
                                        Rotation = new Model.FRotator
                                        {
                                            Pitch = json_data.camera[0].X,
                                            Yaw   = json_data.camera[0].Y,
                                            Roll  = json_data.camera[0].Z
                                        }
                                    }
                                }
                            };

                            #region 车

                            if (false)
                            {
                                foreach (var v in json_data.vehicles)
                                {
                                    var vecActorLocation = new Vector3 {
                                        X = v.rx, Y = v.ry, Z = v.rz
                                    };
                                    var vecRelativePos = vecLocalLocation - vecActorLocation;
                                    var lDeltaInMeters = vecRelativePos.Length / 100;


                                    Vector2 screenlocation;
                                    WorldToScreen(vecActorLocation, PlayerCameraManager, out screenlocation);

                                    DrawText($"[{v.v}] {(int)lDeltaInMeters}m", (int)screenlocation.X,
                                             (int)screenlocation.Y, brushRed, fontFactory, fontESP, device);
                                }
                            }

                            #endregion


                            #region 物品

                            if (false)
                            {
                                foreach (var v in json_data.items)
                                {
                                    var vecActorLocation = new Vector3 {
                                        X = v.rx, Y = v.ry, Z = v.rz
                                    };
                                    var vecRelativePos = vecLocalLocation - vecActorLocation;
                                    var lDeltaInMeters = vecRelativePos.Length / 100;

                                    Vector2 screenlocation;
                                    WorldToScreen(vecActorLocation, PlayerCameraManager, out screenlocation);

                                    DrawText($"{v.n}", (int)screenlocation.X,
                                             (int)screenlocation.Y, brushPurple, fontFactory, fontESP, device);
                                }
                            }

                            #endregion

                            #region 人物
                            var playerList  = json_data.players.OrderBy(z => z.id).ToList();
                            var localPlayer = playerList[0];
                            foreach (var player in playerList)
                            {
                                if (player.health > 0 && player.id != 0 && localPlayer.t != player.t)
                                {
                                    var vecPlayerLocation =
                                        new Vector3 {
                                        X = player.rx, Y = player.ry, Z = player.rz
                                    };
                                    var vecRelativePos = vecLocalLocation - vecPlayerLocation;
                                    var lDeltaInMeters = vecRelativePos.Length / 100;

                                    #region Line ESP

                                    // 线
                                    if (lDeltaInMeters <= 200 && lDeltaInMeters > 5 &&
                                        json_data.players.Count <= 50)
                                    {
                                        Vector2 screenlocation;
                                        WorldToScreen(vecPlayerLocation, PlayerCameraManager, out screenlocation);

                                        device.DrawLine(new RawVector2(2560 / 2, 1440),
                                                        new RawVector2(screenlocation.X, screenlocation.Y), brushWhite);
                                    }
                                    #endregion

                                    #region Distance ESP

                                    // if (CheatSettings.DistanceESP)
                                    if (lDeltaInMeters > 5)
                                    {
                                        Vector2 screenlocation;
                                        WorldToScreen(vecPlayerLocation, PlayerCameraManager, out screenlocation);

                                        DrawText($"HP:{(int)player.health} {(int)lDeltaInMeters}m",
                                                 (int)screenlocation.X,
                                                 (int)screenlocation.Y, lDeltaInMeters >= 200 ? brushGreen : brushRed,
                                                 fontFactory, fontESP, device);
                                    }

                                    #endregion

                                    #region Radar

                                    if (false)
                                    {
                                        if (lDeltaInMeters <= radarSize / 2 /*DISTANCE FROM CENTER TO EDGE*/)
                                        {
                                            Vector2 screenpos = centerpoint + vecRelativePos.To2D() / 100;

                                            var radarPlayerRectangle = new RoundedRectangle()
                                            {
                                                RadiusX = 4,
                                                RadiusY = 4,
                                                Rect    = new RawRectangleF(screenpos.X, screenpos.Y, screenpos.X + 5,
                                                                            screenpos.Y + 5)
                                            };

                                            // DRAW ENEMY
                                            device.FillRoundedRectangle(radarPlayerRectangle, brushRed);
                                        }
                                    }

                                    #endregion
                                }
                            }
                        }

                        #endregion



                        // DRAW END
                        device.EndDraw();

                        Thread.Sleep(1000 / 60);
                    }
                }
            });

            dxthread.IsBackground = true;
            dxthread.Start();

            var marg = new Win32.Margins();

            marg.Left   = 0;
            marg.Top    = 0;
            marg.Right  = this.Width;
            marg.Bottom = this.Height;
            Win32.DwmExtendFrameIntoClientArea(this.Handle, ref marg);
        }
コード例 #2
0
ファイル: DoGame.cs プロジェクト: xzfdsf21/helloworld
        public static JSON_DATA getGameDate()
        {
            if (baseAdd == 0)
            {
                return(null);
            }
            var json = new JSON_DATA();

            if (Setting.模式 == 模式.模式一)
            {
                #region mode1
                var pubg           = new Pubg(baseAdd + Setting.UWorldOffset);
                var uworld         = pubg.UWorld;
                var gameInstance   = uworld.OwningGameInstance;
                var localPlayers   = gameInstance.LocalPlayers;
                var localPlayer    = localPlayers[0];
                var viewportClient = localPlayer.ViewportClient;
                var pWorld         = viewportClient.UWorld;

                for (int i = 0; i < pWorld.PersistentLevel.PlayerCount; i++)
                {
                    var actor         = pWorld.PersistentLevel.AActors[i];
                    var actorId       = actor.ActorID;
                    var actorGName    = Cache.GetGName(actorId);// KReader.getGNameFromId(actorId);
                    var rootComponent = actor.RootComponent;
                    var actorLocation = rootComponent.Location;
                    //玩家
                    if (actor.isPlayer)
                    {
                        var playerState    = actor.PlayerState;
                        var _actorLocation = actorLocation + pWorld.WorldLocation;

                        json.players.Add(new Players
                        {
                            //AName = actorGName,
                            AName      = playerState.PlayerName,
                            AID        = actorId,
                            x          = _actorLocation.X,
                            y          = _actorLocation.Y,
                            z          = _actorLocation.Z,
                            health     = actor.Health,
                            id         = playerState.PlayerId,
                            rotator    = rootComponent.RelativeRotation.Y,
                            t          = playerState.TeamNumber,
                            isInactive = playerState.bIsInactive,
                            rx         = rootComponent.RelativeLocation.X,
                            ry         = rootComponent.RelativeLocation.Y,
                            rz         = rootComponent.RelativeLocation.Z,
                            mesh       = actor.Mesh.mesh
                        });
                    }
                    //车辆
                    else if (actor.isVehicle)
                    {
                        var _actorLocation = actorLocation + pWorld.WorldLocation;
                        json.vehicles.Add(new Vehicle
                        {
                            v  = actorGName.Substring(0, 4),
                            x  = _actorLocation.X,
                            y  = _actorLocation.Y,
                            z  = _actorLocation.Z,
                            rx = rootComponent.RelativeLocation.X,
                            ry = rootComponent.RelativeLocation.Y,
                            rz = rootComponent.RelativeLocation.Z,
                        });
                    }
                    //物品
                    else if (actor.isDropItems)
                    {
                        var droppedItemArray = actor.DropItems;
                        var droppedItemCount = actor.DropItemsCount;
                        for (var j = 0; j < droppedItemCount; j++)
                        {
                            var aDroppedItem = droppedItemArray[j];
                            var UItem        = aDroppedItem.UItem;
                            //var UItemID = UItem.ItemId;
                            var itemName = UItem.ItemName;
                            if (string.IsNullOrEmpty(InCareList(itemName)))
                            {
                                continue;
                            }
                            var droppedLocation  = aDroppedItem.Location;
                            var relativeLocation = droppedLocation + actorLocation;
                            droppedLocation += actorLocation + pWorld.WorldLocation;
                            //a.Add(itemName);
                            json.items.Add(new Item
                            {
                                n  = InCareList(itemName),
                                x  = droppedLocation.X,
                                y  = droppedLocation.Y,
                                z  = droppedLocation.Z,
                                rx = relativeLocation.X,
                                ry = relativeLocation.Y,
                                rz = relativeLocation.Z
                            });
                        }
                    }
                    else if (actor.isAirdropOrDeathdrop)
                    {
                        //var droppedItemArray = actor.AItemPackages;
                        //var droppedItemCount = actor.AItemPackagesCount;
                        //for (var j = 0; j < droppedItemCount; j++)
                        //{
                        //    var dropItem = droppedItemArray[j];
                        var _actorLocation = actorLocation + pWorld.WorldLocation;

                        json.vehicles.Add(new Vehicle
                        {
                            v  = actor.ActorName.Substring(0, 4),
                            x  = _actorLocation.X,
                            y  = _actorLocation.Y,
                            z  = _actorLocation.Z,
                            rx = rootComponent.RelativeLocation.X,
                            ry = rootComponent.RelativeLocation.Y,
                            rz = rootComponent.RelativeLocation.Z
                        });
                        //}
                    }
                }

                var povRotation = localPlayer.PlayerController.PlayerCameraManager.povRotation;
                var povLocation = localPlayer.PlayerController.PlayerCameraManager.povLocation;
                //get zone info
                json.camera.Add(new Camera {
                    n = "Rotation", X = povRotation.X, Y = povRotation.Y, Z = povRotation.Z
                });
                json.camera.Add(new Camera {
                    n = "Location", X = povLocation.X, Y = povLocation.Y, Z = povLocation.Z
                });
                json.camera.Add(new Camera {
                    n = "Fov", X = localPlayer.PlayerController.PlayerCameraManager.Fov, Y = 0, Z = 0
                });
                json.zone.Add(new Zone {
                    r = pWorld.GameState.blueR, x = pWorld.GameState.blue.X, y = pWorld.GameState.blue.Y
                });
                json.zone.Add(new Zone {
                    r = pWorld.GameState.whiteR, x = pWorld.GameState.white.X, y = pWorld.GameState.white.Y
                });
                #endregion
            }
            else
            {
                var m_UWorld         = KReader.readUlong(KReader.m_PUBase + Setting.UWorldOffset);
                var m_gameInstance   = KReader.readUlong(m_UWorld + 0x140);
                var m_ULocalPlayer   = KReader.readUlong(m_gameInstance + 0x38);
                var m_localPlayer    = KReader.readUlong(m_ULocalPlayer + 0x0);
                var m_viewportclient = KReader.readUlong(m_localPlayer + 0x58);
                var m_localPawn      = KReader.readUlong(m_localPlayer + 0x3A8);
                //var m_localPlayerState = KReader.readUlong(m_localPawn + 0x03C0);
                var m_PWorld      = KReader.readUlong(m_viewportclient + 0x80);
                var m_ULevel      = KReader.readUlong(m_PWorld + 0x30);
                var m_playerCount = KReader.readInt32(m_ULevel + 0xA8);

                var m_localPlayerControl      = KReader.readUlong(m_localPlayer + 0x30);
                var m_localPlayerCamerManager = KReader.readUlong(m_localPlayerControl + 0x438);

                var ATslGameState = KReader.readUlong(m_PWorld + 0x00F8);
                var m_AActorPtr   = KReader.readUlong(m_ULevel + 0xA0);


                var povRotation = KReader.readVec(m_localPlayerCamerManager + 0x42C);
                var povLocation = KReader.readVec(m_localPlayerCamerManager + 0x420);
                var Fov         = KReader.readFloat(m_localPlayerCamerManager + 0x438);


                //get zone info
                Vector3 blue  = KReader.readVec(ATslGameState + 0x440);
                float   blueR = KReader.readFloat(ATslGameState + 0x44C);

                Vector3 white  = KReader.readVec(ATslGameState + 0x450);
                float   whiteR = KReader.readFloat(ATslGameState + 0x45C);


                json.camera.Add(new Camera {
                    n = "Rotation", X = povRotation.X, Y = povRotation.Y, Z = povRotation.Z
                });
                json.camera.Add(new Camera {
                    n = "Location", X = povLocation.X, Y = povLocation.Y, Z = povLocation.Z
                });
                json.camera.Add(new Camera {
                    n = "Fov", X = Fov, Y = 0, Z = 0
                });
                json.zone.Add(new Zone {
                    r = blueR, x = blue.X, y = blue.Y
                });
                json.zone.Add(new Zone {
                    r = whiteR, x = white.X, y = white.Y
                });

                var worldLocation = new Vector3
                {
                    X = KReader.readInt32(m_PWorld + 0x918),
                    Y = KReader.readInt32(m_PWorld + 0x91C),
                    Z = KReader.readInt32(m_PWorld + 0x920)
                };
                //this just for test
                //List<string> a = new List<string>();

                for (int i = 0; i < m_playerCount; i++)
                {
                    var curActor         = KReader.readUlong(m_AActorPtr + (ulong)(i * 0x8));
                    var curActorID       = KReader.readInt32(curActor + 0x0018);
                    var actorGName       = Cache.GetGName(curActorID);// KReader.getGNameFromId(curActorID);
                    var rootCmpPtr       = KReader.readUlong(curActor + 0x0180);
                    var actorLocation    = KReader.readVec(rootCmpPtr + 0x1A0);
                    var relativeLocation = KReader.readVec(rootCmpPtr + 0x01E0);
                    //玩家
                    if (isPlayer(actorGName))
                    {
                        var   playerState      = KReader.readUlong(curActor + 0x03C0);
                        var   actorTeam        = KReader.readInt32(playerState + 0x0444);
                        var   _actorLocation   = actorLocation + worldLocation;
                        var   Health           = KReader.readFloat(curActor + 0x107C);
                        ulong mesh             = KReader.readUlong(curActor + 0x0400);
                        var   RelativeRotation = KReader.readVec(rootCmpPtr + 0x01EC);
                        var   playerId         = KReader.readInt32(playerState + 0x03C8);
                        var   isInactive       = KReader.readChar(playerState + 0x03CC);

                        json.players.Add(new Players
                        {
                            x          = _actorLocation.X,
                            y          = _actorLocation.Y,
                            z          = _actorLocation.Z,
                            health     = Health,
                            id         = playerId,
                            rotator    = RelativeRotation.Y,
                            t          = actorTeam,
                            isInactive = isInactive,
                            rx         = relativeLocation.X,
                            ry         = relativeLocation.Y,
                            rz         = relativeLocation.Z,
                            mesh       = mesh
                        });
                    }
                    //车辆
                    else if (isVehicle(actorGName))
                    {
                        var _actorLocation = actorLocation + worldLocation;

                        json.vehicles.Add(new Vehicle
                        {
                            v  = actorGName.Substring(0, 4),
                            x  = _actorLocation.X,
                            y  = _actorLocation.Y,
                            z  = _actorLocation.Z,
                            rx = relativeLocation.X,
                            ry = relativeLocation.Y,
                            rz = relativeLocation.Z,
                        });
                    }
                    //物品
                    else if (isDropItems(actorGName))
                    {
                        var DroppedItemArray = KReader.readUlong(curActor + 0x02D8);
                        var DroppedItemCount = KReader.readInt32(curActor + 0x02E0);

                        for (var j = 0; j < DroppedItemCount; j++)
                        {
                            var ADroppedItem = KReader.readUlong(DroppedItemArray + (ulong)(j * 0x10));
                            var UItem        = KReader.readUlong(ADroppedItem + 0x0448);
                            var UItemID      = KReader.readInt32(UItem + 0x18);
                            var itemName     = Cache.GetGName(UItemID);// KReader.getGNameFromId(UItemID);

                            if (string.IsNullOrEmpty(InCareList(itemName)))
                            {
                                continue;
                            }
                            var droppedLocation   = KReader.readVec(ADroppedItem + 0x01E0);
                            var _relativeLocation = droppedLocation + actorLocation;
                            droppedLocation = droppedLocation + actorLocation + worldLocation;

                            //a.Add(itemName);
                            json.items.Add(new Item
                            {
                                n  = InCareList(itemName),
                                x  = droppedLocation.X,
                                y  = droppedLocation.Y,
                                z  = droppedLocation.Z,
                                rx = _relativeLocation.X,
                                ry = _relativeLocation.Y,
                                rz = _relativeLocation.Z
                            });
                        }
                    }
                    else if (isAirdropOrDeathdrop(actorGName))
                    {
                        //var droppedItemArray = actor.AItemPackages;
                        //var droppedItemCount = actor.AItemPackagesCount;
                        //for (var j = 0; j < droppedItemCount; j++)
                        //{
                        //    var dropItem = droppedItemArray[j];
                        var _actorLocation = actorLocation + worldLocation;
                        json.vehicles.Add(new Vehicle
                        {
                            v  = actorGName.Substring(0, 3),
                            x  = _actorLocation.X,
                            y  = _actorLocation.Y,
                            z  = _actorLocation.Z,
                            rx = relativeLocation.X,
                            ry = relativeLocation.Y,
                            rz = relativeLocation.Z
                        });
                        //}
                    }
                }
            }
            return(json);
        }
コード例 #3
0
ファイル: CPUZ.cs プロジェクト: xzfdsf21/helloworld
        public Cpuz()
        {
            InitializeComponent();
            //Make the window's border completely transparant

            #region D3D初始化
            // ANTI BATTLEYE SIG SCAN ;)
            this.Text = Guid.NewGuid().ToString().Replace("-", "");

            // TRANSPARENCY KEY
            this.BackColor = System.Drawing.Color.Black;

            // SETTINGS
            this.FormBorderStyle = FormBorderStyle.None;
            this.ShowIcon        = false;
            this.ShowInTaskbar   = false;
            this.TopMost         = true;
            this.WindowState     = FormWindowState.Maximized;

            // MAKE WINDOW TRANSPARENT
            Win32.SetWindowLong(this.Handle, Win32.GWL_EXSTYLE, (IntPtr)(Win32.GetWindowLong(this.Handle, Win32.GWL_EXSTYLE) ^ Win32.WS_EX_LAYERED ^ Win32.WS_EX_TRANSPARENT));

            // MAKE WINDOW SOLID
            Win32.SetLayeredWindowAttributes(this.Handle, 0, 255, Win32.LWA_ALPHA);

            var targetProperties = new HwndRenderTargetProperties
            {
                Hwnd           = this.Handle,
                PixelSize      = new Size2(this.Bounds.Right - this.Bounds.Left, this.Bounds.Bottom - this.Bounds.Top),
                PresentOptions = PresentOptions.Immediately
            };

            var prop = new RenderTargetProperties(RenderTargetType.Hardware, new PixelFormat(Format.B8G8R8A8_UNorm, SharpDX.Direct2D1.AlphaMode.Premultiplied), 0, 0, RenderTargetUsage.None, FeatureLevel.Level_DEFAULT);

            var d3dFactory = new SharpDX.Direct2D1.Factory();

            var device = new WindowRenderTarget(d3dFactory, prop, targetProperties)
            {
                TextAntialiasMode = TextAntialiasMode.Cleartype,
                AntialiasMode     = AntialiasMode.Aliased
            };

            #endregion

            var       k         = KReader.readPuBase();
            JSON_DATA json_data = null;
            var       dxthread  = new Thread(() =>
            {
                var brushWhite   = new SolidColorBrush(device, RawColorFromColor(Color.White));
                var brushBlack   = new SolidColorBrush(device, RawColorFromColor(Color.Black));
                var brushGreen   = new SolidColorBrush(device, RawColorFromColor(Color.Green));
                var brushRed     = new SolidColorBrush(device, RawColorFromColor(Color.Red));
                var brushPurple  = new SolidColorBrush(device, RawColorFromColor(Color.Purple));
                var fontFactory  = new SharpDX.DirectWrite.Factory();
                var fontConsolas = new SharpDX.DirectWrite.TextFormat(fontFactory, "Consolas", 15);
                var fontESP      = new SharpDX.DirectWrite.TextFormat(fontFactory, "Consolas", 12);

                while (true)
                {
                    // attempt to download JSON data as a string
                    try
                    {
                        json_data = DoGame.getGameDate();

                        if (json_data != null && json_data.players.Count > 0)
                        {
                            mainFrom.STATE = true;
                            device.BeginDraw();
                            device.Clear(null);

                            #region RADAR

                            int radarSize       = 600;
                            Vector2 centerpoint = new Vector2(2356, 1210);

                            if (Setting.雷达)
                            {
                                Ellipse el3 = new Ellipse(new RawVector2(2356, 1210), 1, 1);
                                device.DrawEllipse(el3, brushRed);
                                device.FillEllipse(el3, brushRed);

                                // TODO: INTEGRATE INTO MINIMAP
                                //if (Setting.雷达)
                                //{
                                //    var radarOuterRectangle = new RawRectangleF(radarX, radarY, radarX + radarSize,
                                //        radarY + radarSize);
                                //    var radarRectangle = new RawRectangleF(radarX + radarBorder, radarY + radarBorder,
                                //        radarX + radarSize - radarBorder, radarY + radarSize - radarBorder);

                                //    var radarCenterRectangle = new RoundedRectangle()
                                //    {
                                //        RadiusX = 4,
                                //        RadiusY = 4,
                                //        Rect = new RawRectangleF(centerpoint.X, centerpoint.Y, centerpoint.X + 4,
                                //            centerpoint.Y + 4)
                                //    };

                                //    device.FillRectangle(radarRectangle, brushBlack);
                                //    device.DrawRectangle(radarRectangle, brushWhite);

                                //    device.FillRoundedRectangle(radarCenterRectangle, brushGreen);

                                //}
                            }

                            #endregion


                            var vecLocalLocation = new Model.Vector3
                            {
                                X = json_data.camera[1].X,
                                Y = json_data.camera[1].Y,
                                Z = json_data.camera[1].Z
                            };

                            var PlayerCameraManager = new PlayerCameraManager
                            {
                                CameraCache = new FCameraCacheEntry
                                {
                                    POV = new FMinimalViewInfo
                                    {
                                        Fov      = json_data.camera[2].X,
                                        Location = new Model.Vector3
                                        {
                                            X = json_data.camera[1].X,
                                            Y = json_data.camera[1].Y,
                                            Z = json_data.camera[1].Z
                                        },
                                        Rotation = new Model.FRotator
                                        {
                                            Pitch = json_data.camera[0].X,
                                            Yaw   = json_data.camera[0].Y,
                                            Roll  = json_data.camera[0].Z
                                        }
                                    }
                                }
                            };

                            #region 车

                            if (Setting.车辆显示)
                            {
                                foreach (var v in json_data.vehicles)
                                {
                                    var vecActorLocation = new Vector3 {
                                        X = v.rx, Y = v.ry, Z = v.rz
                                    };
                                    var vecRelativePos = vecLocalLocation - vecActorLocation;
                                    var lDeltaInMeters = vecRelativePos.Length / 100;
                                    if (lDeltaInMeters <= 400)
                                    {
                                        Vector2 screenlocation;
                                        if (WorldToScreen(vecActorLocation, PlayerCameraManager, out screenlocation))
                                        {
                                            DrawText($"[{v.v}] {(int)lDeltaInMeters}m", (int)screenlocation.X,
                                                     (int)screenlocation.Y, v.v == "Deat" ? brushBlack : brushGreen,
                                                     fontFactory, fontESP, device);
                                        }
                                    }
                                }
                            }

                            #endregion

                            #region 物品

                            //todo:有BUG
                            if (Setting.物品显示)
                            {
                                foreach (var v in json_data.items)
                                {
                                    var vecActorLocation = new Vector3 {
                                        X = v.rx, Y = v.ry, Z = v.rz
                                    };
                                    var vecRelativePos = vecLocalLocation - vecActorLocation;
                                    var lDeltaInMeters = vecRelativePos.Length / 100;

                                    Vector2 screenlocation;
                                    if (WorldToScreen(vecActorLocation, PlayerCameraManager, out screenlocation))
                                    {
                                        DrawText($"{v.n}", (int)screenlocation.X,
                                                 (int)screenlocation.Y, brushWhite, fontFactory, fontESP, device);
                                    }
                                }
                            }

                            #endregion

                            #region 人物

                            var playerList  = json_data.players.OrderBy(z => z.id).ToList();
                            var localPlayer = playerList[0];
                            foreach (var player in playerList)
                            {
                                if (player.health > 0 && player.isInactive > 0 && player.id != 0)
                                {
                                    var vecPlayerLocation = new Vector3 {
                                        X = player.rx, Y = player.ry, Z = player.rz
                                    };
                                    var vecRelativePos = vecLocalLocation - vecPlayerLocation;
                                    //距离
                                    var lDeltaInMeters = vecRelativePos.Length / 100.0f;


                                    if (lDeltaInMeters >= 750)
                                    {
                                        continue;
                                    }
                                    #region 线条
                                    if (Setting.线条)
                                    {
                                        if (lDeltaInMeters > 3)
                                        {
                                            if (
                                                //超过200米不显示线
                                                lDeltaInMeters <= 200
                                                //超过40人不显示线
                                                && json_data.players.Count <= 40
                                                //队友不显示
                                                && player.t != localPlayer.t
                                                )
                                            {
                                                if (WorldToScreen(vecPlayerLocation, PlayerCameraManager,
                                                                  out var screenlocation))
                                                {
                                                    device.DrawLine(new RawVector2(Setting.Screen.Width / 2f, Setting.Screen.Height),
                                                                    new RawVector2(screenlocation.X, screenlocation.Y), lDeltaInMeters <= 100 ? brushRed : brushWhite);
                                                }
                                            }
                                        }
                                    }
                                    #endregion

                                    #region Distance ESP
                                    if (lDeltaInMeters > 3)
                                    {
                                        if (Setting.距离和血量)
                                        {
                                            if (WorldToScreen(vecPlayerLocation, PlayerCameraManager,
                                                              out var screenlocation))
                                            {
                                                SolidColorBrush brush = brushRed;

                                                if (lDeltaInMeters >= 250)
                                                {
                                                    brush = brushPurple;
                                                }
                                                if (lDeltaInMeters >= 500)
                                                {
                                                    brush = brushGreen;
                                                }
                                                if (player.t == localPlayer.t)
                                                {
                                                    brush = brushGreen;
                                                }

                                                DrawText($"[{player.id}]{(int)player.health} {(int)lDeltaInMeters}m",
                                                         (int)screenlocation.X,
                                                         (int)screenlocation.Y,
                                                         brush,
                                                         fontFactory, fontESP, device);
                                            }
                                        }
                                    }

                                    #endregion

                                    #region Radar
                                    if (Setting.雷达)
                                    {
                                        var loclalLocation = new Vector3 {
                                            X = playerList[0].x, Y = playerList[0].y, Z = playerList[0].z
                                        };
                                        var currentActorLocation = new Vector3 {
                                            X = player.x, Y = player.y, Z = player.z
                                        };

                                        var relativePos = loclalLocation - currentActorLocation;

                                        if (relativePos.Length / 100.0f <= radarSize / 2 /*DISTANCE FROM CENTER TO EDGE*/)
                                        {
                                            Vector2 screenpos = centerpoint - relativePos.To2D() / 118f;

                                            Ellipse el22 = new Ellipse(new RawVector2(screenpos.X, screenpos.Y), 3, 3);
                                            device.DrawEllipse(el22, brushRed);
                                            device.FillEllipse(el22, brushRed);
                                        }
                                    }
                                    #endregion

                                    #region 骨骼

                                    if (lDeltaInMeters < 250 && lDeltaInMeters > 5)
                                    {
                                        DrawSkeleton(player.mesh, PlayerCameraManager, device, brushRed, fontESP);
                                    }
                                    #endregion
                                }
                            }
                            #endregion
                            // DRAW END
                            device.EndDraw();
                        }
                        else
                        {
                            mainFrom.STATE = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        System.IO.File.WriteAllText("c:\\log\\bug_json.txt", JsonConvert.SerializeObject(json_data));
                    }
                    Thread.Sleep(10);
                }
            })
            {
                IsBackground = true
            };
            dxthread.Start();

            #region Web端
            var webThread = new Thread(() =>
            {
                while (true)
                {
                    using (var webClient = new WebClient())
                    {
                        if (Setting.Web端 && json_data.players.Count > 0 && !webClient.IsBusy)
                        {
                            try
                            {
                                // 指定 WebClient 編碼
                                webClient.Encoding = Encoding.UTF8;
                                // 指定 WebClient 的 Content-Type header
                                webClient.Headers.Add(HttpRequestHeader.ContentType, "application/json");
                                // 指定 WebClient 的 authorization header
                                //webClient.Headers.Add("authorization", "token {apitoken}");
                                // 執行 PUT 動作
                                var result = webClient.UploadString("http://127.0.0.1:3000/api/5", "PUT", JsonConvert.SerializeObject(json_data));
                            }
                            catch (Exception e)
                            {
                                continue;
                            }
                        }
                    }
                    Thread.Sleep(500);
                }
            });

            webThread.IsBackground = true;
            webThread.Start();
            #endregion


            var marg = new Win32.Margins {
                Left = 0, Top = 0, Right = this.Width, Bottom = this.Height
            };
            Win32.DwmExtendFrameIntoClientArea(this.Handle, ref marg);
        }
コード例 #4
0
        public static JSON_DATA getGameDate()
        {
            if (baseAdd == 0)
            {
                return(null);
            }
            var json           = new JSON_DATA();
            var pubg           = new Pubg(baseAdd + Setting.UWorldOffset);
            var uworld         = pubg.UWorld;
            var gameInstance   = uworld.OwningGameInstance;
            var localPlayers   = gameInstance.LocalPlayers;
            var localPlayer    = localPlayers[0];
            var viewportClient = localPlayers[0].ViewportClient;
            var pWorld         = viewportClient.UWorld;

            for (int i = 0; i < pWorld.PersistentLevel.PlayerCount; i++)
            {
                var actor         = pWorld.PersistentLevel.AActors[i];
                var actorId       = actor.ActorID;
                var actorGName    = KReader.getGNameFromId(actorId);
                var rootComponent = actor.RootComponent;
                var actorLocation = rootComponent.Location;
                //玩家
                if (actor.isPlayer)
                {
                    var playerState    = actor.PlayerState;
                    var _actorLocation = actorLocation + pWorld.WorldLocation;

                    json.players.Add(new Players
                    {
                        //AName = actorGName,
                        AName      = playerState.PlayerName,
                        AID        = actorId,
                        x          = _actorLocation.X,
                        y          = _actorLocation.Y,
                        z          = _actorLocation.Z,
                        health     = actor.Health,
                        id         = playerState.PlayerId,
                        rotator    = rootComponent.RelativeRotation.Y,
                        t          = playerState.TeamNumber,
                        isInactive = playerState.bIsInactive,
                        rx         = rootComponent.RelativeLocation.X,
                        ry         = rootComponent.RelativeLocation.Y,
                        rz         = rootComponent.RelativeLocation.Z,
                        mesh       = actor.Mesh.mesh
                    });
                }
                //车辆
                else if (actor.isVehicle)
                {
                    var _actorLocation = actorLocation + pWorld.WorldLocation;
                    json.vehicles.Add(new Vehicle
                    {
                        v  = actorGName.Substring(0, 4),
                        x  = _actorLocation.X,
                        y  = _actorLocation.Y,
                        z  = _actorLocation.Z,
                        rx = rootComponent.RelativeLocation.X,
                        ry = rootComponent.RelativeLocation.Y,
                        rz = rootComponent.RelativeLocation.Z,
                    });
                }
                //物品
                else if (actor.isDropItems)
                {
                    var droppedItemArray = actor.DropItems;
                    var droppedItemCount = actor.DropItemsCount;
                    for (var j = 0; j < droppedItemCount; j++)
                    {
                        var aDroppedItem = droppedItemArray[j];
                        var UItem        = aDroppedItem.UItem;
                        //var UItemID = UItem.ItemId;
                        var itemName = UItem.ItemName;
                        if (string.IsNullOrEmpty(InCareList(itemName)))
                        {
                            continue;
                        }
                        var droppedLocation  = aDroppedItem.Location;
                        var relativeLocation = droppedLocation + actorLocation;
                        droppedLocation += actorLocation + pWorld.WorldLocation;
                        //a.Add(itemName);
                        json.items.Add(new Item
                        {
                            n  = InCareList(itemName),
                            x  = droppedLocation.X,
                            y  = droppedLocation.Y,
                            z  = droppedLocation.Z,
                            rx = relativeLocation.X,
                            ry = relativeLocation.Y,
                            rz = relativeLocation.Z
                        });
                    }
                }
                else if (actor.isAirdropOrDeathdrop)
                {
                    //var droppedItemArray = actor.AItemPackages;
                    //var droppedItemCount = actor.AItemPackagesCount;
                    //for (var j = 0; j < droppedItemCount; j++)
                    //{
                    //    var dropItem = droppedItemArray[j];
                    var _actorLocation = actorLocation + pWorld.WorldLocation;

                    json.vehicles.Add(new Vehicle
                    {
                        v  = actor.ActorName.Substring(0, 4),
                        x  = _actorLocation.X,
                        y  = _actorLocation.Y,
                        z  = _actorLocation.Z,
                        rx = rootComponent.RelativeLocation.X,
                        ry = rootComponent.RelativeLocation.Y,
                        rz = rootComponent.RelativeLocation.Z
                    });
                    //}
                }
            }

            var povRotation = localPlayer.PlayerController.PlayerCameraManager.povRotation;
            var povLocation = localPlayer.PlayerController.PlayerCameraManager.povLocation;

            //get zone info
            json.camera.Add(new Camera {
                n = "Rotation", X = povRotation.X, Y = povRotation.Y, Z = povRotation.Z
            });
            json.camera.Add(new Camera {
                n = "Location", X = povLocation.X, Y = povLocation.Y, Z = povLocation.Z
            });
            json.camera.Add(new Camera {
                n = "Fov", X = localPlayer.PlayerController.PlayerCameraManager.Fov, Y = 0, Z = 0
            });
            json.zone.Add(new Zone {
                r = pWorld.GameState.blueR, x = pWorld.GameState.blue.X, y = pWorld.GameState.blue.Y
            });
            json.zone.Add(new Zone {
                r = pWorld.GameState.whiteR, x = pWorld.GameState.white.X, y = pWorld.GameState.white.Y
            });


            //var m_UWorld = KReader.readUlong(KReader.m_PUBase + 0x37E5988);
            //var m_gameInstance = KReader.readUlong(m_UWorld + 0x140);
            //var m_ULocalPlayer = KReader.readUlong(m_gameInstance + 0x38);
            //var m_localPlayer = KReader.readUlong(m_ULocalPlayer + 0x0);
            //var m_viewportclient = KReader.readUlong(m_localPlayer + 0x58);
            //var m_localPawn = KReader.readUlong(m_localPlayer + 0x3A8);
            //var m_localPlayerState = KReader.readUlong(m_localPawn + 0x03C0);
            //var m_PWorld = KReader.readUlong(m_viewportclient + 0x80);
            //var m_ULevel = KReader.readUlong(m_PWorld + 0x30);
            //var m_playerCount = KReader.readInt32(m_ULevel + 0xA8);

            //var m_localPlayerControl = KReader.readUlong(m_localPlayer + 0x30, PROTO_NORMAL_READ);
            //var m_localPlayerCamerManager = KReader.readUlong(m_localPlayerControl + 0x438, PROTO_NORMAL_READ);

            //var ATslGameState = KReader.readUlong(m_PWorld + 0x00F8, PROTO_NORMAL_READ);
            ////var m_localPlayerPosition = KReader.readVec(m_localPlayer + 0x70, PROTO_NORMAL_READ);
            ////var m_localPlayerBasePointer = KReader.readUlong(m_localPlayer, PROTO_NORMAL_READ);
            ////var m_localTeam = KReader.readUlong(m_localPlayerState + 0x0444, PROTO_NORMAL_READ);
            //var m_AActorPtr = KReader.readUlong(m_ULevel + 0xA0, PROTO_NORMAL_READ);


            //var povRotation = KReader.readVec(m_localPlayerCamerManager + 0x42C, PROTO_NORMAL_READ);
            //var povLocation = KReader.readVec(m_localPlayerCamerManager + 0x420, PROTO_NORMAL_READ);
            //var Fov = KReader.readFloat(m_localPlayerCamerManager + 0x438, PROTO_NORMAL_READ);


            ////get zone info
            //Vector3 blue = KReader.readVec(ATslGameState + 0x440, PROTO_NORMAL_READ);
            //float blueR = KReader.readFloat(ATslGameState + 0x44C, PROTO_NORMAL_READ);

            //Vector3 white = KReader.readVec(ATslGameState + 0x450, PROTO_NORMAL_READ);
            //float whiteR = KReader.readFloat(ATslGameState + 0x45C, PROTO_NORMAL_READ);


            //json.camera.Add(new Camera { n = "Rotation", X = povRotation.X, Y = povRotation.Y, Z = povRotation.Z });
            //json.camera.Add(new Camera { n = "Location", X = povLocation.X, Y = povLocation.Y, Z = povLocation.Z });
            //json.camera.Add(new Camera { n = "Fov", X = Fov, Y = 0, Z = 0 });
            //json.zone.Add(new Zone { r = blueR, x = blue.X, y = blue.Y });
            //json.zone.Add(new Zone { r = whiteR, x = white.X, y = white.Y });

            ////this just for test
            //List<string> a = new List<string>();

            //for (int i = 0; i < m_playerCount; i++)
            //{
            //    var curActor = KReader.readUlong(m_AActorPtr + (ulong)(i * 0x8), PROTO_NORMAL_READ);
            //    var curActorID = KReader.readInt32(curActor + 0x0018, PROTO_NORMAL_READ);

            //    var actorGName = KReader.getGNameFromId(curActorID);


            //    //玩家
            //    if (curActorID == 66943 || curActorID == 66948)
            //    {
            //        var rootCmpPtr = KReader.readUlong(curActor + 0x0180, PROTO_NORMAL_READ);
            //        var playerState = KReader.readUlong(curActor + 0x03C0, PROTO_NORMAL_READ);
            //        Vector3 actorLocation = KReader.readVec(rootCmpPtr + 0x1A0, PROTO_NORMAL_READ);

            //        var actorTeam = KReader.readInt32(playerState + 0x0444, PROTO_NORMAL_READ);

            //        actorLocation.X += KReader.readInt32(m_PWorld + 0x918, PROTO_NORMAL_READ);
            //        actorLocation.Y += KReader.readInt32(m_PWorld + 0x91C, PROTO_NORMAL_READ);
            //        actorLocation.Z += KReader.readInt32(m_PWorld + 0x920, PROTO_NORMAL_READ);

            //        var Health = KReader.readFloat(curActor + 0x107C, PROTO_NORMAL_READ);
            //        ulong mesh = KReader.readUlong(curActor + 0x0400, PROTO_NORMAL_READ);


            //        var relativeLocation = KReader.readVec(rootCmpPtr + 0x01E0, PROTO_NORMAL_READ);
            //        var RelativeRotation = KReader.readVec(rootCmpPtr + 0x01EC, PROTO_NORMAL_READ);
            //        var playerId = KReader.readInt32(playerState + 0x03C8, PROTO_NORMAL_READ);
            //        var isInactive = KReader.readChar(playerState + 0x03CC, PROTO_NORMAL_READ);

            //        json.players.Add(new Players
            //        {
            //            //AName = actorGName,
            //            //AID = curActorID,
            //            x = actorLocation.X,
            //            y = actorLocation.Y,
            //            z = actorLocation.Z,
            //            health = Health,
            //            id = playerId,
            //            rotator = RelativeRotation.Y,
            //            t = actorTeam,
            //            isInactive = isInactive,
            //            rx = relativeLocation.X,
            //            ry = relativeLocation.Y,
            //            rz = relativeLocation.Z,
            //            mesh = mesh
            //        });
            //    }
            //    //车辆
            //    else if (!string.IsNullOrEmpty(IsVehicle(actorGName)))
            //    {
            //        var rootCmpPtr = KReader.readUlong(curActor + 0x180, PROTO_NORMAL_READ);
            //        Vector3 actorLocation = KReader.readVec(rootCmpPtr + 0x1A0, PROTO_NORMAL_READ);

            //        actorLocation.X += KReader.readInt32(m_PWorld + 0x918, PROTO_NORMAL_READ);
            //        actorLocation.Y += KReader.readInt32(m_PWorld + 0x91C, PROTO_NORMAL_READ);
            //        actorLocation.Z += KReader.readInt32(m_PWorld + 0x920, PROTO_NORMAL_READ);
            //        Vector3 relativeLocation = KReader.readVec(rootCmpPtr + 0x01E0, PROTO_NORMAL_READ);

            //        json.vehicles.Add(new Vehicle
            //        {
            //            v = actorGName.Substring(0, 4),
            //            x = actorLocation.X,
            //            y = actorLocation.Y,
            //            z = actorLocation.Z,
            //            rx = relativeLocation.X,
            //            ry = relativeLocation.Y,
            //            rz = relativeLocation.Z,
            //        });
            //    }
            //    //物品
            //    else if (IsDropGroup(actorGName))
            //    {
            //        var rootCmpPtr = KReader.readUlong(curActor + 0x180, PROTO_NORMAL_READ);
            //        Vector3 actorLocation = KReader.readVec(rootCmpPtr + 0x1A0, PROTO_NORMAL_READ);

            //        var DroppedItemArray = KReader.readUlong(curActor + 0x02D8, PROTO_NORMAL_READ);
            //        var DroppedItemCount = KReader.readInt32(curActor + 0x02E0, PROTO_NORMAL_READ);

            //        for (int j = 0; j < DroppedItemCount; j++)
            //        {
            //            var ADroppedItem = KReader.readUlong(DroppedItemArray + (ulong)(j * 0x10), PROTO_NORMAL_READ);
            //            var UItem = KReader.readUlong(ADroppedItem + 0x0448, PROTO_NORMAL_READ);
            //            var UItemID = KReader.readInt32(UItem + 0x18, PROTO_NORMAL_READ);
            //            var itemName = KReader.getGNameFromId(UItemID);

            //            if (!string.IsNullOrEmpty(InCareList(itemName)))
            //            {

            //                Vector3 droppedLocation = KReader.readVec(ADroppedItem + 0x01E0, PROTO_NORMAL_READ);
            //                Vector3 relativeLocation = droppedLocation + actorLocation;
            //                droppedLocation.X = droppedLocation.X + actorLocation.X + KReader.readInt32(m_PWorld + 0x918, PROTO_NORMAL_READ);
            //                droppedLocation.Y = droppedLocation.Y + actorLocation.Y + KReader.readInt32(m_PWorld + 0x91C, PROTO_NORMAL_READ);
            //                droppedLocation.Z = droppedLocation.Z + actorLocation.Z + KReader.readInt32(m_PWorld + 0x920, PROTO_NORMAL_READ);

            //                a.Add(itemName);
            //                json.items.Add(new Item
            //                {
            //                    n = InCareList(itemName),
            //                    x = droppedLocation.X,
            //                    y = droppedLocation.Y,
            //                    z = droppedLocation.Z,
            //                    rx = relativeLocation.X,
            //                    ry = relativeLocation.Y,
            //                    rz = relativeLocation.Z
            //                });
            //            }



            //        }


            //    }
            //}
            return(json);
        }