Hi% username%! So, let's continue writing our bot. From past articles, we learned how to find the address of the intercepted function for DirectX 9 and 11, execute arbitrary assembly code in the main thread of the game by hiding it from various methods of protection and receive information about the world. In other words, we can perform deliberate actions in the game. And for starters, I propose to learn how to move! public enum FunctionWow { ClntObjMgrGetActivePlayer = 0x39B615, ClntObjMgrGetActivePlayerObj = 0x4FC6, FrameScript_ExecuteBuffer = 0x4fd12, Spell_C_HandleTerrainClick = 0x38f129, FrameScript__GetLocalizedText = 0x414267, IsOutdoors = 0x414b53, UnitCanAttack = 0x41ad3c, CGUnit_C__InitializeTrackingState = 0x41fb57, CGWorldFrame__Intersect = 0x5eef7b, CGUnit_C__Interact = 0x8D01D0, } public enum ClickToMove { CTM = 0x420543, CTM_PUSH = 0xD0EEBC, CTM_X = 0xD0EF2C, CTM_Y = CTM_X+4, CTM_Z = CTM_Y+4, } public enum ClickType { FaceTarget = 0x1, Face = 0x2, StopThrowsException = 0x3, Move = 0x4, NpcInteract = 0x5, Loot = 0x6, ObjInteract = 0x7, FaceOther = 0x8, Skin = 0x9, AttackPosition = 0xa, AttackGuid = 0xb, ConstantFace = 0xc, None = 0xd, Attack = 0x10, Idle = 0x13, } public static class WorldClick { public static void ClickTo(float x, float y, float z, ulong guid, ClickType action, float precision) { if (Mathf.Abs(x) < 0.1 && Mathf.Abs(y) < 0.1 && (Mathf.Abs(z) < 0.1 && (long)guid == 0L)) return; // 3 var positionAddress = Memory.Process.AllocateMemory(3 * sizeof(float)); //guid ulong 8 var guidAddress = Memory.Process.AllocateMemory(sizeof(ulong)); // , , 0.5f var precisionAddress = Memory.Process.AllocateMemory(sizeof(float)); if (positionAddress <= 0U || guidAddress <= 0U || precisionAddress <= 0U) return; Memory.Process.Write<ulong>(guidAddress, guid); Memory.Process.Write<float>(precisionAddress, precision); Memory.Process.Write<float>(positionAddress, x); Memory.Process.Write<float>(positionAddress + IntPtr.Size, y); Memory.Process.Write<float>(positionAddress + IntPtr.Size * 2, z); var asm = new[] { "call " + Memory.Process.GetAbsolute(FunctionWow.ClntObjMgrGetActivePlayer ), // "test eax, eax", "je @out", // - "call " + Memory.Process.GetAbsolute(FunctionWow.ClntObjMgrGetActivePlayerObjAddress), "test eax, eax", "je @out", "mov edx, [" + precisionAddress + "]", "push edx", "push " + positionAddress, "push " + guidAddress, "push " + (int)action, "mov ecx, eax", // ClickToMove() "call " + Memory.Process.GetAbsolute((int)ClickToMove.CTM), "@out:", "retn" }; Memory.Hook.InjectAndExecute(asm); Memory.Process.FreeMemory(positionAddress); Memory.Process.FreeMemory(guidAddress); Memory.Process.FreeMemory(precisionAddress); } public static ClickType GetClickTypePush() { return (ClickToMoveType)Memory.Process.Read<int>((int)ClickToMove.CTM_PUSH, true); } public static Vector3 GetClickPosition() { return new Vector3( Memory.Process.Read<float>((int)ClickToMove.CTM_X, true), Memory.Process.Read<float>((int)ClickToMove.CTM_Y, true), Memory.Process.Read<float>((int)ClickToMove.CTM_Z, true)); } } WorldClick.ClickTo(x,y,z, 0, ClickType.Move, 0.5f); Source: https://habr.com/ru/post/251479/
All Articles