public void Rebuff() { bool drinking = false; bool eating = Eat(); if (objectManager.GetPlayer().MaxMana > 0) { drinking = Drink(); } if (eating && !drinking) { while (!halt && (objectManager.GetPlayer().Health < objectManager.GetPlayer().MaxHealth&& magic.ReadUInt(magic.ReadUInt((uint)TbcOffsets.General.PlayerBase) + (uint)TbcOffsets.General.CombatStateOffset) != (int)TbcOffsets.CombatState.InCombat)) { //We wait. } } else if (drinking && !eating) { while (!halt && (objectManager.GetPlayer().Mana < objectManager.GetPlayer().MaxMana&& magic.ReadUInt(magic.ReadUInt((uint)TbcOffsets.General.PlayerBase) + (uint)TbcOffsets.General.CombatStateOffset) != (int)TbcOffsets.CombatState.InCombat)) { //Again, we wait. } } else if (eating && drinking) { while (magic.ReadUInt(magic.ReadUInt((uint)TbcOffsets.General.PlayerBase) + (uint)TbcOffsets.General.CombatStateOffset) != (int)TbcOffsets.CombatState.InCombat && !halt && (objectManager.GetPlayer().Mana < objectManager.GetPlayer().MaxMana || objectManager.GetPlayer().Health < objectManager.GetPlayer().MaxHealth)) { //Again, we wait. } } bot.GetCombat.afterCombatSpells(0, "aftercombat"); }
static void Main(string[] args) { uint dwCodeLoc; wow = new BlackMagic(); if (wow.OpenProcessAndThread(SProcess.GetProcessFromProcessName("wow"))) { Console.WriteLine(wow.GetModuleFilePath()); DateTime dt = DateTime.Now; //dwCodeLoc = SPattern.FindPattern(wow.ProcessHandle, wow.MainModule, PATTERN_CLIENT_CONNECTION, MASK_CLIENT_CONNECTION, ' '); dwCodeLoc = wow.FindPattern(PATTERN_CLIENT_CONNECTION, MASK_CLIENT_CONNECTION); Console.WriteLine("Pattern found in {0}ms", DateTime.Now.Subtract(dt).TotalMilliseconds); Console.WriteLine("Code loc: 0x{0:X08}", dwCodeLoc); Console.WriteLine("CLIENT_CONNECTION: 0x{0:X08}", wow.ReadUInt(dwCodeLoc + 0x16)); Console.WriteLine("CURMGR_OFFSET: 0x{0:X08}", wow.ReadUInt(dwCodeLoc + 0x1C)); } else { Console.WriteLine("World of Warcraft could not be opened for read/write."); } Console.ReadLine(); }
private static bool InitializeConnectionManager() { try { Globals.ClientConnectionPointer = wowProcess.ReadUInt(TLS + 0x16); Globals.ClientConnection = wowProcess.ReadUInt(Globals.ClientConnectionPointer); if (Globals.ClientConnection == 0) { Debug("char", "ClientConnection not yet available"); return(false); } Globals.ClientConnectionOffset = wowProcess.ReadUInt(TLS + 0x1C); if (Globals.ClientConnectionOffset == 0) { Debug("char", "ClientConnectionOffset not yet available"); return(false); } Globals.CurMgr = wowProcess.ReadUInt(Globals.ClientConnection + Globals.ClientConnectionOffset); if (Globals.CurMgr == 0) { Debug("char", "ConnectionManager not yet available"); return(false); } //ObjectManager = new ObjectManager(); //Player = new WowPlayer(ObjectManager.GetLocalPlayerObject()); Debug("char", "Found ConnectionManager"); return(true); } catch (Exception) { Debug("char", "ConnectionManager not found"); return(false); } }
static void Main(string[] args) { //Open the proccess wow = new BlackMagic(); wow.OpenProcessAndThread(SProcess.GetProcessFromWindowTitle(PROCESS_WINDOW_TITLE)); //Setup Object Manager and First object base address ObjMgrAddr = wow.ReadUInt(wow.ReadUInt((uint)wow.MainModule.BaseAddress + (uint)Constants.Const.ObjectManager.CurMgrPointer) + (uint)Constants.Const.ObjectManager.CurMgrOffset); FirstObject = new GameObject(wow.ReadUInt(ObjMgrAddr + (uint)Constants.Const.ObjectManager.FirstObject)); //Read TargetGUID from globals and find in the Object Manager //UInt64 CurrTargetGUID = wow.ReadUInt64((uint)wow.MainModule.BaseAddress + (uint)Const.Globals.CurrentTargetGUID); UInt64 CurrTargetGUID = wow.ReadUInt64((uint)wow.MainModule.BaseAddress + (uint)Constants.Const.Globals.CurrentTargetGUID); PlayerObject = new GameObject(wow.ReadUInt64((uint)wow.MainModule.BaseAddress + (uint)Constants.Const.Globals.PlayerGUID)); TargetObject = new GameObject(CurrTargetGUID); PlayerObject.Wowclass = wow.ReadByte(PlayerObject.DescriptorArrayAddress + (uint)Const.descriptors.Class8); System.Timers.Timer aTimer = new System.Timers.Timer(); aTimer.Interval = 100; if (PlayerObject.Wowclass == 9) { Console.WriteLine("Initiate Affliction Warlock DPS BOT v1.0"); aTimer.Elapsed += WarlockDPS.DpsEvent; } else if (PlayerObject.Wowclass == 11) { Console.WriteLine("Initiate Feral Druid DPS BOT v0.1"); aTimer.Elapsed += DruidDPS.DpsEvent; } aTimer.AutoReset = true; aTimer.Enabled = true; while (true) { switch (Console.ReadLine()) { case "stop": Console.WriteLine("STOP"); aTimer.Elapsed -= DruidDPS.DpsEvent; aTimer.Elapsed -= WarlockDPS.DpsEvent; aTimer.Elapsed -= PrinterEvent; break; case "printer": aTimer.Elapsed += PrinterEvent; break; case "start": if (PlayerObject.Wowclass == 9) { Console.WriteLine("Initiate Affliction Warlock DPS BOT v1.0"); aTimer.Elapsed += WarlockDPS.DpsEvent; } else if (PlayerObject.Wowclass == 11) { Console.WriteLine("Initiate Feral Druid DPS BOT v0.1"); aTimer.Elapsed += DruidDPS.DpsEvent; } break; } } }
//---------- Private functions ------------ private uint getFirstObject() { try { return(Memory.ReadUInt(curMgr + FirstObject)); } catch { return(0); } }
/// <summary> /// Reads all WoWObject out of WoW's ObjectManager /// </summary> /// <returns>all WoWObjects in WoW Manager</returns> public static List <WowObject> GetAllWoWObjects() { List <WowObject> objects = new List <WowObject>(); uint currentObjectManager = BlackMagic.ReadUInt(Offsets.currentClientConnection); currentObjectManager = BlackMagic.ReadUInt(currentObjectManager + Offsets.currentManagerOffset); uint activeObject = BlackMagic.ReadUInt(currentObjectManager + Offsets.firstObjectOffset); uint objectType = BlackMagic.ReadUInt(activeObject + Offsets.gameobjectTypeOffset); ulong myGUID = ReadPlayerGUID(); // loop through the objects until an object is bigger than 7 or lower than 1 to get all // Objects from manager while (objectType <= 7 && objectType > 0) { WowObject wowObject = ReadWoWObjectFromWoW(activeObject, (WowObjectType)objectType); wowObject.MapID = GetMapID(); wowObject.ZoneID = GetZoneID(); objects.Add(wowObject); activeObject = BlackMagic.ReadUInt(activeObject + Offsets.nextObjectOffset); objectType = BlackMagic.ReadUInt(activeObject + Offsets.gameobjectTypeOffset); } return(objects); }
/// <summary> /// Lit la liste des objets du jeu /// </summary> private static void ReadObjectList() { var currentObject = new PObject(FirstObject); //var currentObject = FirstObject; //var nextObject = FirstObject; while (currentObject.BaseAddress != uint.MinValue && currentObject.BaseAddress % 2 == uint.MinValue) { if (currentObject.GUID == LocalGUID) { MyPlayer.BaseAddress = currentObject.BaseAddress; } if (!ObjectDictionary.ContainsKey(currentObject.GUID)) { PObject obj = null; // Add the object based on it's *actual* type. Note: WoW's Object descriptors for OBJECT_FIELD_TYPE // is a bitmask. We want to use the type at 0x14, as it's an 'absolute' type. /* switch (currentObject.Type) * { * // Belive it or not, the base Object class is hardly used in WoW. * case (int)Constants.ObjectType.Object: * obj = new PObject(currentObject.BaseAddress); * break; * case (int)Constants.ObjectType.Unit: * obj = new PUnit(currentObject.BaseAddress); * break; * case (int)Constants.ObjectType.Player: * obj = new PPlayer(currentObject.BaseAddress); * break; * case (int)Constants.ObjectType.GameObject: * obj = new PGameObject(currentObject.BaseAddress); * break; * case (int)Constants.ObjectType.Item: * obj = new PItem(currentObject.BaseAddress); * break; * case (int)Constants.ObjectType.Container: * obj = new PContainer(currentObject.BaseAddress); * break; * // These two aren't used in most bots, as they're fairly pointless. * // They are AI and area triggers for NPCs handled by the client itself. * case (int)Constants.ObjectType.AiGroup: * case (int)Constants.ObjectType.AreaTrigger: * break; * } */ if (obj != null) { ObjectDictionary.Add(currentObject.GUID, obj); } } else { ObjectDictionary[currentObject.GUID].BaseAddress = currentObject.BaseAddress; } currentObject.BaseAddress = Wow.ReadUInt(currentObject.BaseAddress + (uint)Common.Offsets.ObjectManager.NextObject); } }
public WowObject(uint baseAddress, BlackMagic blackMagic) { BaseAddress = baseAddress; BlackMagicInstance = blackMagic; Descriptor = BlackMagicInstance.ReadUInt(BaseAddress + 0x8); Guid = BlackMagicInstance.ReadUInt64(BaseAddress + 0x30); }
public uint InjectAndExecute(string[] asm, bool allowOffline = false) { lock (Locker) { if (!allowOffline && (!Helpers.Usefuls.InGame || Helpers.Usefuls.IsLoading)) { return(0); } /*List<string> asmCode = new List<string>(); * foreach (string s in asm) * { * asmCode.Add(s); * if (Others.Random(0, 100) > 50) * { * int nR = Others.Random(1, 3); * for (int i = nR; i >= 1; i--) * { * asmCode.Add(ProtectHook()); * } * } * } * return (uint) Wow.Memory.WowProcess.Executor.Call(asmCode.ToArray());*/ if (!ThreadHooked) { return(0); } var fasm = new ManagedFasm(Memory.ProcessHandle); fasm.SetMemorySize(0x1000); fasm.SetPassLimit(100); foreach (string s in asm) { fasm.AddLine(s); } fasm.Inject(_mInjectionCode); Memory.WriteByte(_mExecuteRequested, 1); Timer injectTimer = new Timer(2000); injectTimer.Reset(); while (Memory.ReadByte(_mExecuteRequested) == 1 && !injectTimer.IsReady) { Thread.Sleep(1); } if (injectTimer.IsReady) { Logging.WriteError("Injection have been aborted, execution too long from " + CurrentCallStack); return(0); } Memory.WriteBytes(_mInjectionCode, _mZeroBytesInjectionCodes); uint returnValue = Memory.ReadUInt(_mResult); return(returnValue); } }
public static uint D3D9Adresse(int processId) { BlackMagic memory = new BlackMagic(processId); System.Diagnostics.Process processById = System.Diagnostics.Process.GetProcessById(processId); uint pDevice = memory.ReadUInt((uint)memory.GetModule(processById.ProcessName + ".exe").BaseAddress + (uint)Patchables.Addresses.Hooking.DX_DEVICE); uint pEnd = memory.ReadUInt(pDevice + (uint)Patchables.Addresses.Hooking.DX_DEVICE_IDX); if (pEnd == 0) { return(0); } uint pScene = memory.ReadUInt(pEnd); d3d9Adresse = memory.ReadUInt(pScene + (uint)Patchables.Addresses.Hooking.ENDSCENE_IDX); return(d3d9Adresse); }
private void bScanForProcess_Click(object sender, EventArgs e) { dataGridView1.Rows.Clear(); Process[] pWowProcesses = Process.GetProcessesByName("WoW"); foreach (Process p in pWowProcesses) { wow.Open(p.Id); dataGridView1.Rows.Add(wow.ReadUInt(0x00C7B2A4) == 0 ? true : false, p.Id.ToString(), wow.ReadASCIIString((uint)0x827D88 + (uint)wow.MainModule.BaseAddress, 10).Trim()); } }
/// <summary> /// Get Localized Text for command /// </summary> /// <param name="command">lua command to run</param> /// <param name="variable">variable to read</param> /// <returns>localized text for the executed functions return value</returns> public static string GetLocalizedText(string command, string variable) { if (command.Length > 0 && variable.Length > 0) { uint argCCCommand = BlackMagic.AllocateMemory(Encoding.UTF8.GetBytes(command).Length + 1); BlackMagic.WriteBytes(argCCCommand, Encoding.UTF8.GetBytes(command)); string[] asmDoString = new string[] { $"MOV EAX, {(argCCCommand) }", "PUSH 0", "PUSH EAX", "PUSH EAX", $"CALL {(Offsets.luaDoString)}", "ADD ESP, 0xC", "RETN", }; uint argCC = BlackMagic.AllocateMemory(Encoding.UTF8.GetBytes(variable).Length + 1); BlackMagic.WriteBytes(argCC, Encoding.UTF8.GetBytes(variable)); uint playerBase = BlackMagic.ReadUInt(Offsets.playerBase); playerBase = BlackMagic.ReadUInt(playerBase + 0x34); playerBase = BlackMagic.ReadUInt(playerBase + 0x24); string[] asmLocalText = new string[] { $"CALL {(Offsets.clientObjectManagerGetActivePlayerObject)}", "MOV ECX, EAX", "PUSH -1", $"PUSH {(argCC)}", $"CALL {(Offsets.luaGetLocalizedText)}", "RETN", }; HookJob hookJobLocaltext = new HookJob(asmLocalText, true); ReturnHookJob hookJobDoString = new ReturnHookJob(asmDoString, false, hookJobLocaltext); AmeisenHook.AddHookJob(ref hookJobDoString); while (!hookJobDoString.IsFinished || !hookJobDoString.IsFinished) { Thread.Sleep(5); } string result = Encoding.UTF8.GetString((byte[])hookJobDoString.ReturnValue); AmeisenLogger.Instance.Log(LogLevel.VERBOSE, "DoString(" + command + "); => " + variable + " = " + result, "AmeisenCore"); BlackMagic.FreeMemory(argCCCommand); BlackMagic.FreeMemory(argCC); return(result); } return(""); }
public GObject(GObjectList objectList, uint ObjectPointer) { this.objectList = objectList; curMgr = objectList.getCurMgr(); Memory = objectList.getMemory(); this.ObjectPointer = ObjectPointer; if (ObjectPointer != 0) { try { Descriptor = Memory.ReadUInt(ObjectPointer + DescriptorOffset); ObjectGUID = Memory.ReadUInt64(ObjectPointer + GuidOffset); VirtualMethodTable = Memory.ReadUInt(ObjectPointer); } catch { } } }
/// <summary> /// Initialized the ObjectManager, and attaches it to the selected process ID. /// </summary> /// <param name="wowProc">The wow proc.</param> public static void Initialize(Process wowProc) { if (Initialized) // Nothing to do if we're already initialized. { return; } WowProcess = wowProc; Memory = new BlackMagic(wowProc.Id); try { CurrentManager = Memory.ReadUInt(Memory.ReadUInt(WowBaseAddress + (uint)Offsets.ObjectManager.Tls) + (uint)Offsets.ObjectManager.CurMgr); PlayerGUID = Memory.ReadUInt64(CurrentManager + (uint)Offsets.ObjectManager.LocalGuid); } catch (Exception ex) { Logging.WriteException(Color.Red, ex); } }
public GObjectList(int ProcessIdOfWoW) { bool didit = false; this.ProcessIdOfWoW = ProcessIdOfWoW; while (didit == false) { Memory = new BlackMagic(); //this.form = form; //Lets Open wow for manipulation Memory.OpenProcessAndThread(ProcessIdOfWoW); //Lets find the Pattern - Shynd dwCodeLoc = SPattern.FindPattern(Memory.ProcessHandle, Memory.MainModule, PatternClientConnection, MaskClientConnection, ' '); //Lets find the s_curMgr try { g_clientConnection = Memory.ReadUInt(dwCodeLoc + 0x16); clientConnection = Memory.ReadUInt(g_clientConnection); curMgrOffset = Memory.ReadUInt(dwCodeLoc + 0x1C); //Lets find the CurMgr Offset curMgr = Memory.ReadUInt(clientConnection + curMgrOffset); //clientConnection + CurMgrOffest = Win LocalGUIDVariable = Memory.ReadUInt64(curMgr + LocalGuidOffset); localPlayerObject = getObjectByGUID(LocalGUIDVariable); localPlayer = new GPlayerSelf(this, localPlayerObject); } catch { } Descriptor = new Descriptors(Memory); //Lets start the object refresher objectRefresher = new Refresher(ProcessIdOfWoW); objectRefresher.GameObjectCreated += new EventHandler <GameObjectEventArgs>(addToLists); objectRefresher.GameObjectReleased += new EventHandler <GameObjectEventArgs>(removeFromLists); didit = true; } }
public bool tryAttach(int dwProcessId) { try { //Lets Open wow for manipulation tempMem.OpenProcessAndThread(dwProcessId); //Lets find the Pattern - Shynd dwCodeLoc = SPattern.FindPattern(tempMem.ProcessHandle, tempMem.MainModule, PatternClientConnection, MaskClientConnection, ' '); //Lets find the s_curMgr g_clientConnection = tempMem.ReadUInt(dwCodeLoc + 0x16); clientConnection = tempMem.ReadUInt(g_clientConnection); curMgrOffset = tempMem.ReadUInt(dwCodeLoc + 0x1C); //Lets find the CurMgr Offset curMgr = tempMem.ReadUInt(clientConnection + curMgrOffset); //clientConnection + CurMgrOffest = Win getDescriptors = new Descriptors(tempMem); localPlayerObject = getObjectByGUID(tempMem.ReadUInt64(curMgr + LocalGuidOffset)); if (XP != -10) { return(true); } } catch { return(false); } return(false); }
/// <summary> /// Retourne l'empalecement mémoire du GUID fournis /// </summary> /// <param name="guid">GUID de l'objet</param> /// <returns>Adresse mémoire de l'objet</returns> public static uint getMemoryLocationByGuid(uint guid) { if (!processOpen) { return(0); } uint curObj = firstObj; uint objType = Wow.ReadUInt(curObj + (uint)Offsets.Object.type); while (objType <= 7 && objType > 0) { uint curGuid = Wow.ReadUInt(curObj + (uint)Offsets.Object.guid); if (curGuid == guid) { return(curObj); } else { uint nextObj = Wow.ReadUInt(curObj + (uint)Offsets.ObjectManager.nextObject); curObj = nextObj; } } return(0); }
public void PopulateList() { var clientConnection = _magic.ReadUInt((uint)TbcOffsets.General.ClientConnection); clientConnection = _magic.ReadUInt(clientConnection + (uint)TbcOffsets.ObjectManagerOffsets.ObjectManagerOffset); var nextObject = _magic.ReadUInt(clientConnection + (uint)TbcOffsets.ObjectManagerOffsets.FirstObject); _objects.Clear(); _isPlayer = false; while ((nextObject != 0) && ((nextObject & 1) == 0)) { var obj = new Object(nextObject, _magic); _objects.Add(obj); nextObject = _magic.ReadUInt(nextObject + (uint)TbcOffsets.ObjectManagerOffsets.NextObject); if (obj.Type != 4 || _isPlayer) { continue; } _player = obj; _isPlayer = true; } }
/// <summary> /// Returns the running WoW's in a WoWExe List containing the /// logged in playername and Process object. /// </summary> /// <returns>A list containing all the runnign WoW processes</returns> public static List <WowExe> GetRunningWows() { List <WowExe> wows = new List <WowExe>(); List <Process> processList = new List <Process>(Process.GetProcessesByName("Wow")); foreach (Process p in processList) { AmeisenLogger.Instance.Log(LogLevel.DEBUG, $"Found WoW Process! PID: {p.Id}", "AmeisenCore"); BlackMagic blackmagic = new BlackMagic(p.Id); uint pDevice = blackmagic.ReadUInt(Offsets.devicePtr1); uint pEnd = blackmagic.ReadUInt(pDevice + Offsets.devicePtr2); uint pScene = blackmagic.ReadUInt(pEnd); uint endscene = blackmagic.ReadUInt(pScene + Offsets.endScene); bool isAlreadyHooked = false; try { isAlreadyHooked = BlackMagic.ReadByte(endscene + 0x2) == 0xE9; } catch { } string name = blackmagic.ReadASCIIString(Offsets.playerName, 12); if (name == "") { name = "not logged in"; } wows.Add(new WowExe { characterName = name, process = p, alreadyHooked = isAlreadyHooked }); blackmagic.Close(); } return(wows); }
public void InteractGameObject(uint baseAddress) { uint InteractVMT = 45; if (baseAddress > 0) { uint VMT44 = process.ReadUInt(process.ReadUInt(baseAddress) + ((uint)InteractVMT * 4)); var objectManagerBase = 0x463C; string[] asm = new string[] { "fs mov eax, [0x2C]", "mov eax, [eax]", "add eax, 0x10", "mov dword [eax], " + objectManagerBase, "mov ecx, " + baseAddress, "call " + VMT44, "retn", }; aHook.InjectAndExecute(asm); } }
public MemoryFunctions(int ProcessIdOfWoW) { this.ProcessIdOfWoW = ProcessIdOfWoW; //Lets Open wow for manipulation Memory.OpenProcessAndThread(ProcessIdOfWoW); //Lets find the Pattern - Shynd dwCodeLoc = SPattern.FindPattern(Memory.ProcessHandle, Memory.MainModule, PatternClientConnection, MaskClientConnection, ' '); //Lets find the s_curMgr try { g_clientConnection = Memory.ReadUInt(dwCodeLoc + 0x16); clientConnection = Memory.ReadUInt(g_clientConnection); curMgrOffset = Memory.ReadUInt(dwCodeLoc + 0x1C); //Lets find the CurMgr Offset curMgr = Memory.ReadUInt(clientConnection + curMgrOffset); //clientConnection + CurMgrOffest = Win } catch { } }
private void HookApplication() { if (!process.IsProcessOpen) { throw new Exception("Process is not open"); } uint baseAddress = (uint)process.MainModule.BaseAddress; uint pDevice = process.ReadUInt(baseAddress + Offsets.Direct3D.Direct3D9__Device); uint pEnd = process.ReadUInt(pDevice + Offsets.Direct3D.Direct3D9__Device__OffsetA); uint pScene = process.ReadUInt(pEnd); uint pEndScene = process.ReadUInt(pScene + Offsets.Direct3D.Direct3D9__Device__OffsetB); if (process.ReadUInt(pEndScene) == 0xE9 && (codeCave == 0 || injectionAddress == 0)) { DisposeOfHook(); } if (process.ReadUInt(pEndScene) != 0xE9) { try { mainThreadHooked = false; codeCave = process.AllocateMemory(2048); injectionAddress = process.AllocateMemory(0x4); process.WriteInt(injectionAddress, 0); returnAddress = process.AllocateMemory(0x4); process.WriteInt(returnAddress, 0); process.Asm.Clear(); process.Asm.AddLine("mov edi, edi"); process.Asm.AddLine("push ebp"); process.Asm.AddLine("mov ebp, esp"); process.Asm.AddLine("pushfd"); process.Asm.AddLine("pushad"); process.Asm.AddLine("mov eax, [" + injectionAddress + "]"); process.Asm.AddLine("test eax, eax"); process.Asm.AddLine("je @out"); process.Asm.AddLine("mov eax, [" + injectionAddress + "]"); process.Asm.AddLine("call eax"); process.Asm.AddLine("mov [" + returnAddress + "], eax"); process.Asm.AddLine("mov edx, " + injectionAddress); process.Asm.AddLine("mov ecx, 0"); process.Asm.AddLine("mov [edx], ecx"); process.Asm.AddLine("@out:"); uint sizeAsm = (uint)(process.Asm.Assemble().Length); process.Asm.Inject(codeCave); int sizeJumpBack = 5; process.Asm.Clear(); process.Asm.AddLine("jmp " + (pEndScene + sizeJumpBack)); process.Asm.Inject(codeCave + sizeAsm); // + (uint)sizeJumpBack); process.Asm.Clear(); // $jmpto process.Asm.AddLine("jmp " + (codeCave)); process.Asm.Inject(pEndScene); } catch { mainThreadHooked = false; return; } mainThreadHooked = true; } }
public bool WalkToPoint(float targetX, float targetY, float targetZ, bool value, float currentX, float currentY, float currentZ) { float bodyx = magic.ReadFloat((uint)TbcOffsets.General.PlayerCorpseX); float bodyy = 0; float bodyz = 0; dead = false; if (bodyx != 0) { bodyy = magic.ReadFloat((uint)TbcOffsets.General.PlayerCorpseY); bodyz = magic.ReadFloat((uint)TbcOffsets.General.PlayerCorpseZ); dead = true; } float startingX = currentX; float startingY = currentY; float startingZ = currentZ; bool inCombat = value; float dX = targetX - startingX; float dY = targetY - startingY; float dZ = targetZ - startingZ; float rotation = (float)Math.Atan2(targetY - startingY, targetX - startingX); if (rotation < 0) { rotation = rotation + (2f * (float)Math.PI); } float myRotation = magic.ReadFloat((uint)TbcOffsets.General.PlayerRotation); myRotation = float.Parse(myRotation.ToString("0.0")); rotation = float.Parse(rotation.ToString("0.0")); float angle1; float angle2; float distance = (float)Math.Sqrt(dX * dX + dY * dY + dZ * dZ); while ((distance > 3f && distance <= 100f) && !halt) { if ((!settings.IgnoreMobs || !settings.IgnorePlayers) && (!inCombat || magic.ReadUInt(magic.ReadUInt((uint)TbcOffsets.General.PlayerBase) + (uint)TbcOffsets.General.CombatStateOffset) == (int)TbcOffsets.CombatState.InCombat && magic.ReadUInt64((uint)TbcOffsets.General.TargetGuid) != 0)) { if (inCombat) { inCombat = bot.GetCombat.CombatMode(); } else { inCombat = bot.GetCombat.CombatMode(); if (inCombat) { return(true); } } } int playerHealth = objectManager.GetPlayer().Health; if (playerHealth <= 0 && profile.IsGhostSet) { bot.GetOther.ReleaseScript(); dead = true; Thread.Sleep(1000); return(true); } else if (playerHealth <= 0 && !profile.IsGhostSet) { bot.Halt(); } if (dead) { float gX = bodyx - startingX; float gY = bodyy - startingY; float gZ = bodyz - startingZ; if ((float)Math.Sqrt(gX * gX + gY * gY + gZ * gZ) < 30) { keyboardSim.KeyUp(walk); keyboardSim.KeyUp(turnleft); keyboardSim.KeyUp(turnright); while (magic.ReadFloat((uint)TbcOffsets.General.PlayerCorpseX) != 0) { bot.GetOther.RetrieveScript(); } bot.GetOther.Rebuff(); dead = false; break; } } if (!profile.IgnoreZ && startingZ > targetZ) { if (startingZ - targetZ > 0.3f) { keyboardSim.KeyDown(godown); } else { keyboardSim.KeyUp(godown); } } else if (!profile.IgnoreZ && startingZ < targetZ) { if (targetZ - startingZ > 0.3f) { keyboardSim.KeyDown(goup); } else { keyboardSim.KeyUp(goup); } } if (myRotation != rotation) { if (myRotation >= rotation) { angle1 = myRotation - rotation; angle2 = rotation + (2 * (float)Math.PI - myRotation); if (angle1 < angle2) { if (angle1 > 0.3) { keyboardSim.KeyDown(turnright); keyboardSim.KeyUp(turnleft); } else { keyboardSim.KeyUp(turnleft); keyboardSim.KeyUp(turnright); } if (angle1 < Math.PI / 2 && distance > 3) { keyboardSim.KeyDown(walk); } } else { if (angle2 > 0.3) { keyboardSim.KeyDown(turnleft); keyboardSim.KeyUp(turnright); } else { keyboardSim.KeyUp(turnleft); keyboardSim.KeyUp(turnright); } if (angle2 < Math.PI / 2 && distance > 3) { keyboardSim.KeyDown(walk); } } } else if (myRotation < rotation) { angle1 = rotation - myRotation; angle2 = myRotation + (2 * (float)Math.PI - rotation); if (angle1 < angle2) { if (angle1 > 0.3) { keyboardSim.KeyDown(turnleft); keyboardSim.KeyUp(turnright); } else { keyboardSim.KeyUp(turnleft); keyboardSim.KeyUp(turnright); } if (angle1 < Math.PI / 2 && distance > 3) { keyboardSim.KeyDown(walk); } } else { if (angle2 > 0.3) { keyboardSim.KeyDown(turnright); keyboardSim.KeyUp(turnleft); } else { keyboardSim.KeyUp(turnleft); keyboardSim.KeyUp(turnright); } if (angle2 < Math.PI / 2 && distance > 3) { keyboardSim.KeyDown(walk); } } } } else { keyboardSim.KeyDown(walk); keyboardSim.KeyUp(turnleft); keyboardSim.KeyUp(turnright); Random random = new Random(); if (random.Next(10) == 0) { keyboardSim.KeyDown(goup); keyboardSim.KeyUp(goup); } } startingX = magic.ReadFloat((uint)TbcOffsets.General.PlayerX); startingY = magic.ReadFloat((uint)TbcOffsets.General.PlayerY); startingZ = magic.ReadFloat((uint)TbcOffsets.General.PlayerZ); dX = targetX - startingX; dY = targetY - startingY; dZ = targetZ - startingZ; myRotation = magic.ReadFloat((uint)TbcOffsets.General.PlayerRotation); rotation = (float)Math.Atan2(targetY - startingY, targetX - startingX); if (rotation < 0) { rotation = rotation + (2f * (float)Math.PI); } myRotation = float.Parse(myRotation.ToString("0.0")); rotation = float.Parse(rotation.ToString("0.0")); float temp = distance; distance = (float)Math.Sqrt(dX * dX + dY * dY + dZ * dZ); if (temp - distance == 0) { Antistuck(); } } keyboardSim.KeyUp(walk); keyboardSim.KeyUp(turnleft); keyboardSim.KeyUp(turnright); return(false); }
public uint ReadUInt(uint dwAddress) { return(D3.ReadUInt(dwAddress, false, buffer)); }
public void Hooking() { // Offset: uint DX_DEVICE = 0xAD773C + baseAdress; uint DX_DEVICE_IDX = 0x27F8; uint ENDSCENE_IDX = 0xA8; // Process Connect: if (!Memory.IsProcessOpen) { Memory = new BlackMagic((int)_processId); } if (Memory.IsProcessOpen) { // Get address of EndScene uint pDevice = Memory.ReadUInt(DX_DEVICE); uint pEnd = Memory.ReadUInt(pDevice + DX_DEVICE_IDX); uint pScene = Memory.ReadUInt(pEnd); uint pEndScene = Memory.ReadUInt(pScene + ENDSCENE_IDX); if (Memory.ReadByte(pEndScene) == 0xE9 && (injected_code == 0 || addresseInjection == 0)) // check if wow is already hooked and dispose Hook { DisposeHooking(); } if (Memory.ReadByte(pEndScene) != 0xE9) // check if wow is already hooked { try { threadHooked = false; // allocate memory to store injected code: injected_code = Memory.AllocateMemory(2048); // allocate memory the new injection code pointer: addresseInjection = Memory.AllocateMemory(0x4); Memory.WriteInt(addresseInjection, 0); // allocate memory the pointer return value: retnInjectionAsm = Memory.AllocateMemory(0x4); Memory.WriteInt(retnInjectionAsm, 0); Memory.Asm.Clear(); Memory.Asm.AddLine("mov edi, edi"); Memory.Asm.AddLine("push ebp"); Memory.Asm.AddLine("mov ebp, esp"); Memory.Asm.AddLine("pushfd"); Memory.Asm.AddLine("pushad"); //Test for waiting code Memory.Asm.AddLine("mov eax, [" + addresseInjection + "]"); Memory.Asm.AddLine("test eax, ebx"); Memory.Asm.AddLine("je @out"); //Execute waiting code Memory.Asm.AddLine("mov eax, [" + addresseInjection + "]"); Memory.Asm.AddLine("call eax"); //Copy pointer to return value Memory.Asm.AddLine("mov [" + retnInjectionAsm + "], eax"); Memory.Asm.AddLine("mov edx, " + addresseInjection); Memory.Asm.AddLine("mov ecx, 0"); Memory.Asm.AddLine("mov [edx], ecx"); //Close Function Memory.Asm.AddLine("@out:"); //Inject Code uint sizeAsm = (uint)(Memory.Asm.Assemble().Length); Memory.Asm.Inject(injected_code); int sizeJumpBack = 5; // create jump back stub Memory.Asm.Clear(); Memory.Asm.AddLine("jmp " + (pEndScene + sizeJumpBack)); Memory.Asm.Inject(injected_code + sizeAsm);// + (uint)sizeJumpBack); // create hook jump Memory.Asm.Clear(); // $jmpto Memory.Asm.AddLine("jmp " + (injected_code)); Memory.Asm.Inject(pEndScene); } catch { threadHooked = false; return; } } threadHooked = true; } }
public List <AURA> getAuras(uint unit) { List <AURA> result = new List <AURA>(); AURA A = new AURA(); uint auraTable = unit + AURA_TABLE_1; //aura list & count has 2 possible locations uint auraCount = wow.ReadUInt(unit + AURA_COUNT_1); if (auraCount > 80) { auraTable = wow.ReadUInt(unit + AURA_TABLE_2); //and the second one auraCount = wow.ReadUInt(unit + AURA_COUNT_2); } for (uint i = 0; i < auraCount; i++) { uint spellId = wow.ReadUInt(auraTable + AURA_SIZE * i + AURA_SPELL_ID); if (spellId > 0) { UInt64 creatorGUID = wow.ReadUInt64(auraTable + AURA_SIZE * i); A.auraId = spellId; A.creatorGuid = creatorGUID; result.Add(A); } } return(result); }
public void Search(float startingX, float startingY, float startingZ) { float targetX, targetY, targetZ, dX, dY, dZ, distance; if (settings.Mining || settings.Herbing) { objectManager.PopulateList(); foreach (WorkWork.Memory.Object obj in objectManager.GetObjects()) { if (obj.Type == 5) { string name = magic.ReadASCIIString(magic.ReadUInt(magic.ReadUInt(obj.BaseAddress + (uint)TbcOffsets.ObjectOffsets.GameObjectNameOffset1) + (uint)TbcOffsets.ObjectOffsets.GameObjectNameOffset2), 40); if (settings.Herbing) { foreach (string herb in Herbs) { if (name.ToLower().Contains(herb)) { targetX = magic.ReadFloat(magic.ReadUInt(obj.BaseAddress + (uint)TbcOffsets.ObjectOffsets.GameObjectOffset) + (uint)TbcOffsets.ObjectOffsets.GameObjectOffsetX); targetY = magic.ReadFloat(magic.ReadUInt(obj.BaseAddress + (uint)TbcOffsets.ObjectOffsets.GameObjectOffset) + (uint)TbcOffsets.ObjectOffsets.GameObjectOffsetY); targetZ = magic.ReadFloat(magic.ReadUInt(obj.BaseAddress + (uint)TbcOffsets.ObjectOffsets.GameObjectOffset) + (uint)TbcOffsets.ObjectOffsets.GameObjectOffsetZ); dX = targetX - startingX; dY = targetY - startingY; dZ = targetZ - startingZ; distance = (float)Math.Sqrt(dX * dX + dY * dY + dZ * dZ); if (distance <= 30) { bot.GetPathing.WalkToPoint(targetX, targetY, targetZ, true, startingX, startingY, startingZ); bot.GetOther.Interact(); bot.GetPathing.WalkToPoint(startingX, startingY, startingZ, true, targetX, targetY, targetZ); return; } } } } if (settings.Mining) { foreach (string node in Nodes) { if (name.Contains(node)) { targetX = magic.ReadFloat(magic.ReadUInt(obj.BaseAddress + (uint)TbcOffsets.ObjectOffsets.GameObjectOffset) + (uint)TbcOffsets.ObjectOffsets.GameObjectOffsetX); targetY = magic.ReadFloat(magic.ReadUInt(obj.BaseAddress + (uint)TbcOffsets.ObjectOffsets.GameObjectOffset) + (uint)TbcOffsets.ObjectOffsets.GameObjectOffsetY); targetZ = magic.ReadFloat(magic.ReadUInt(obj.BaseAddress + (uint)TbcOffsets.ObjectOffsets.GameObjectOffset) + (uint)TbcOffsets.ObjectOffsets.GameObjectOffsetZ); dX = targetX - startingX; dY = targetY - startingY; dZ = targetZ - startingZ; distance = (float)Math.Sqrt(dX * dX + dY * dY + dZ * dZ); if (distance <= 30) { bot.GetPathing.WalkToPoint(targetX, targetY, targetZ, true, startingX, startingY, startingZ); bot.GetOther.Interact(); bot.GetPathing.WalkToPoint(startingX, startingY, startingZ, true, targetX, targetY, targetZ); return; } } } } } } } }
public bool CombatMode() { ulong target = magic.ReadUInt64((uint)TbcOffsets.General.TargetGuid); bool stuck = false; //Investigate bool combatSuccessful = false; if (target == 0) { keyboardSim.KeyDown(targetKey); keyboardSim.KeyUp(targetKey); } else { objectManager.PopulateList(); List <WorkWork.Memory.Object> objs = objectManager.GetObjects(); for (int i = 0; i < objs.Count; i++) { WorkWork.Memory.Object obj = objs[i]; int type = obj.Type; if ((type == 4 && !settings.IgnorePlayers) || (type == 3 && !settings.IgnoreMobs)) { ulong guid = obj.Guid; if (target == guid && obj.Health > 0 && !stuck) { if (type == 3) { string name = obj.Name; foreach (String ignoredMob in profile.GetIgnoredMobs()) { if (name == ignoredMob) { stuck = true; keyboardSim.KeyDown(targetKey); keyboardSim.KeyUp(targetKey); } } } foreach (WorkWork.Memory.Object ignoredObjects in ignoredMobs) { if (ignoredObjects.Guid == guid) { stuck = true; keyboardSim.KeyDown(targetKey); keyboardSim.KeyUp(targetKey); } else { foreach (ulong ignoredMobGuid in profile.getIgnoredMobsGuid) { if (guid == ignoredMobGuid) { stuck = true; keyboardSim.KeyDown(targetKey); keyboardSim.KeyUp(targetKey); } } } } var watch = Stopwatch.StartNew(); int startingHP = objectManager.GetPlayer().Health; int startingMP = objectManager.GetPlayer().Mana; int currentCombo = 0; while (obj.Health > 0 && !halt && !stuck) { currentCombo = DpsRotation(obj, currentCombo); if (AutoAttack() && objectManager.GetPlayer().Health > 0) { bot.GetPathing.WalkToMob(obj, 5); } if (watch.ElapsedMilliseconds > averageTime * 3 && averageTime > 0) { ignoredMobs.Add(obj); stuck = true; } if (halt || (objectManager.GetPlayer().Health <= 0) || bot.GetPathing.Dead || magic.ReadFloat((uint)TbcOffsets.General.PlayerCorpseX) != 0) { stuck = true; } } watch.Stop(); if (!stuck) { int counter; int endingHP = objectManager.GetPlayer().Health; if (endingHP < startingHP) { endingHP = startingHP - endingHP; endingHP += endingHP / 2; healthPerMob[hpCounter] = endingHP; hpCounter++; if (hpCounter == 10) { hpCounter = 0; } counter = 0; bot.AverageHealth = 0; foreach (int hp in healthPerMob) { if (hp > 0) { counter++; bot.AverageHealth += hp; } } if (counter > 0) { bot.AverageHealth /= counter; } } if (objectManager.GetPlayer().MaxMana > 0) { int endingMP = objectManager.GetPlayer().Mana; if (endingMP < startingMP) { endingMP = startingMP - endingMP; endingMP += endingMP / 2; manaPerMob[mpCounter] = endingMP; mpCounter++; if (mpCounter == 10) { mpCounter = 0; } counter = 0; bot.AverageMana = 0; foreach (int mp in manaPerMob) { if (mp > 0) { counter++; bot.AverageMana += mp; } } if (counter > 0) { bot.AverageMana /= counter; } } } if (magic.ReadUInt(magic.ReadUInt((uint)TbcOffsets.General.PlayerBase) + (uint)TbcOffsets.General.CombatStateOffset) == (int)TbcOffsets.CombatState.InCombat && magic.ReadUInt64((uint)TbcOffsets.General.TargetGuid) != 0) { CombatMode(); } timePerMob[timeCounter] = watch.ElapsedMilliseconds; timeCounter++; if (timeCounter == 10) { timeCounter = 0; } averageTime = 0; counter = 0; foreach (long temp in timePerMob) { if (temp > 0) { counter++; averageTime += temp; } } if (counter > 0) { averageTime /= counter; } if (objectManager.GetPlayer().Health > 0) { if (settings.Looting) { bot.GetPathing.WalkToMob(obj, 3); bot.GetOther.Interact(); if (settings.Skinning) { bot.GetOther.Interact(); } } combatSuccessful = true; bot.MobsKilled++; statistics.Changed = true; bot.GetOther.Regen(); afterCombatSpells(currentCombo, "aftercombat"); } } break; } else if (target == guid && obj.Health <= 0) { keyboardSim.KeyDown(targetKey); keyboardSim.KeyUp(targetKey); break; } } } } return(combatSuccessful); }
public static Structs.PatternList FindPatternList(Structs.PatternList patternList) { Structs.PatternList newPatternList = new Structs.PatternList(); newPatternList.processName = patternList.processName; uint baseModule = 0; BlackMagic memread = new BlackMagic(); if (memread.OpenProcessAndThread(SProcess.GetProcessFromProcessName(patternList.processName))) { try { // Dump module ProcessModuleCollection modules = Process.GetProcessById(memread.ProcessId).Modules; foreach (ProcessModule o in modules) { Structs.ModuleList m = new Structs.ModuleList(); m.Name = o.ModuleName; m.baseAddressDec = (int)o.BaseAddress; m.baseAddressHex = (o.BaseAddress).ToString("X"); patternList.Modules.Add(m); // Check module base if exist. if (patternList.baseModuleName != "") { if (patternList.baseModuleName.ToLower() == o.ModuleName.ToLower()) { baseModule = (uint)o.BaseAddress; } } } } catch { } foreach (Structs.Pattern p in patternList.Patterns) { try { uint dwCodeLoc = memread.FindPattern(p.pattern, p.mask); uint offset = memread.ReadUInt((uint)((int)dwCodeLoc + p.offsetLocation)); if (offset > 0) { offset = offset - baseModule; dwCodeLoc = dwCodeLoc - baseModule; } if (offset > 0) { // Dump offset p.offset = offset.ToString("X"); p.offsetDec = offset; p.offsetUsedAtDec = (uint)((int)dwCodeLoc + p.offsetLocation); p.offsetUsedAt = ((int)dwCodeLoc + p.offsetLocation).ToString("X"); try { switch (p.type) { case "int64": p.value = Convert.ToString(memread.ReadUInt64(p.offsetDec)); break; case "int": p.value = Convert.ToString(memread.ReadInt(p.offsetDec)); break; case "float": p.value = Convert.ToString(memread.ReadFloat(p.offsetDec)); break; case "string": p.value = Convert.ToString(memread.ReadASCIIString(p.offsetDec, 30)); break; } } catch { p.value = "No Found"; } } else { p.offset = "No Found"; } } catch { p.offset = "No Found"; } newPatternList.Patterns.Add(p); } memread.Close(); } else { MessageBox.Show("Process no found."); } return(patternList); }
private Boolean LoadAddresses() { ClientConnection = WowReader.ReadUInt((uint)ClientOffsets.StaticClientConnection); ObjectManager = WowReader.ReadUInt((uint)(ClientConnection + ClientOffsets.ObjectManagerOffset)); FirstObject = WowReader.ReadUInt((uint)(ObjectManager + ClientOffsets.FirstObjectOffset)); LocalTarget.Guid = WowReader.ReadUInt64((uint)(ClientOffsets.LocalTargetGUID)); LocalPlayer.Guid = WowReader.ReadUInt64((uint)(ObjectManager + ClientOffsets.LocalGuidOffset)); // if the local guid is zero it means that something failed. if (LocalPlayer.Guid == 0) { return(false); } else { return(true); } }