public void FaceUnit(WowPlayer player, WowPosition positionToFace) { float angle = BotMath.GetFacingAngle(player.Position, positionToFace); TrashMem.Write(player.BaseAddress + OffsetList.OffsetPlayerRotation, angle); SendKey(new IntPtr(0x41), 0, 0); // the "S" key to go a bit backwards TODO: find better method 0x53 }
private void WriteInt(uint offset, int value) { try { TrashMem.Write <int>(offset, value); } catch { CheckForGameCrashed(); } }
public void MoveToPosition(WowPosition targetPosition, ClickToMoveType clickToMoveType = ClickToMoveType.Move, float distance = 1.5f) { TrashMem.Write(OffsetList.StaticClickToMoveX, targetPosition.x); TrashMem.Write(OffsetList.StaticClickToMoveY, targetPosition.y); TrashMem.Write(OffsetList.StaticClickToMoveZ, targetPosition.z); TrashMem.Write(OffsetList.StaticClickToMoveDistance, distance); TrashMem.Write(OffsetList.StaticClickToMoveAction, (int)clickToMoveType); }
private void ButtonWriteData_Click(object sender, RoutedEventArgs e) { if (TrashMem != null && listboxAllocations.SelectedItem != null) { uint address = ((MemoryAllocation)listboxAllocations.SelectedItem).Address; int size = ((MemoryAllocation)listboxAllocations.SelectedItem).Size; switch ((string)comboboxDataType.SelectedItem) { case "Bytes": byte[] bytes = Encoding.ASCII.GetBytes(textboxData.Text); if (bytes.Length <= size) { TrashMem.WriteBytes(address, bytes); } break; case "Char": if (char.TryParse(textboxData.Text, out char charValue)) { TrashMem.Write(address, charValue); } break; case "Int16": if (short.TryParse(textboxData.Text, out short shortValue)) { TrashMem.Write(address, shortValue); } break; case "Int32": if (int.TryParse(textboxData.Text, out int intValue)) { TrashMem.Write(address, intValue); } break; case "Int64": if (long.TryParse(textboxData.Text, out long longValue)) { TrashMem.Write(address, longValue); } break; case "Float": if (float.TryParse(textboxData.Text, out float floatValue)) { TrashMem.Write(address, floatValue); } break; case "Double": if (double.TryParse(textboxData.Text, out double doubleValue)) { TrashMem.Write(address, doubleValue); } break; case "ASCII String": TrashMem.WriteString(address, textboxData.Text, Encoding.ASCII); break; } UpdateByteViews(address, size); } }
public void WriteCharTest() { Assert.IsTrue(TrashMem.Write <byte>(STATIC_ADDRESS_CHAR, 0xF)); Assert.AreEqual(0xF, TrashMem.ReadChar(STATIC_ADDRESS_CHAR)); Assert.IsTrue(TrashMem.Write <byte>(STATIC_ADDRESS_CHAR, 0xE)); Assert.AreEqual(0xE, TrashMem.ReadChar(STATIC_ADDRESS_CHAR)); Assert.IsTrue(TrashMem.Write <byte>(STATIC_ADDRESS_CHAR, 0xF)); Assert.AreEqual(0xF, TrashMem.ReadChar(STATIC_ADDRESS_CHAR)); }
public void AttackUnit(WowUnit unit) { TrashMem.Write(OffsetList.StaticClickToMoveGuid, unit.Guid); MoveToPosition(unit.Position, ClickToMoveType.AttackGuid); }
public void AntiAfk() => TrashMem.Write(OffsetList.StaticTickCount, Environment.TickCount);
public byte[] InjectAndExecute(string[] asm, bool readReturnBytes, [CallerMemberName] string callingFunction = "") { AmeisenBotLogger.Instance.Log($"[{ProcessId.ToString("X", CultureInfo.InvariantCulture.NumberFormat)}]\tInjecting ASM into Hook [asm = {JsonConvert.SerializeObject(asm)}, readReturnBytes = {readReturnBytes}, callingFunction = {callingFunction}]", LogLevel.Verbose); List <byte> returnBytes = new List <byte>(); if (!IsWorldLoaded) { return(returnBytes.ToArray()); } try { int timeoutCounter = 0; // wait for the code to be executed while (IsInjectionUsed) { if (timeoutCounter == 500) { return(Array.Empty <byte>()); } timeoutCounter++; Thread.Sleep(1); } IsInjectionUsed = true; // preparing to inject the given ASM TrashMem.Asm.Clear(); // add all lines foreach (string s in asm) { TrashMem.Asm.AddLine(s); } // now there is code to be executed TrashMem.Write(CodeToExecuteAddress.Address, 1); // inject it TrashMem.Asm.Inject(CodecaveForExecution.Address); timeoutCounter = 0; // wait for the code to be executed while (TrashMem.ReadInt32(CodeToExecuteAddress.Address) > 0) { if (timeoutCounter == 500) { return(Array.Empty <byte>()); } timeoutCounter++; IsInjectionUsed = false; Thread.Sleep(1); } // if we want to read the return value do it otherwise we're done if (readReturnBytes) { byte buffer; try { uint dwAddress = TrashMem.ReadUnmanaged <uint>(ReturnValueAddress.Address); // read all parameter-bytes until we the buffer is 0 buffer = TrashMem.ReadChar(dwAddress); while (buffer != 0) { returnBytes.Add(buffer); dwAddress++; buffer = TrashMem.ReadChar(dwAddress); } } catch (Exception e) { AmeisenBotLogger.Instance.Log($"[{ProcessId.ToString("X", CultureInfo.InvariantCulture.NumberFormat)}]\tCrash at reading the return bytes: \n{e}", LogLevel.Error); } } IsInjectionUsed = false; } catch (Exception e) { AmeisenBotLogger.Instance.Log($"[{ProcessId.ToString("X", CultureInfo.InvariantCulture.NumberFormat)}]\tCrash at injecting: \n{e}", LogLevel.Error); // now there is no more code to be executed TrashMem.ReadUnmanaged <uint>(CodeToExecuteAddress.Address, 0); IsInjectionUsed = false; } return(returnBytes.ToArray()); }
private void SetupEndsceneHook() { // first thing thats 5 bytes big is here // we are going to replace this 5 bytes with // our JMP instruction (JMP (1 byte) + Address (4 byte)) EndsceneAddress += ENDSCENE_HOOK_OFFSET; // if WoW is already hooked, unhook it if (IsWoWHooked) { DisposeHook(); } else { originalEndsceneBytes = TrashMem.ReadChars(EndsceneAddress, 5); } // if WoW is now/was unhooked, hook it if (!IsWoWHooked) { AmeisenBotLogger.Instance.Log($"[{ProcessId.ToString("X", CultureInfo.InvariantCulture.NumberFormat)}]\tHooking EndScene at \"0x{EndsceneAddress.ToString("X", CultureInfo.InvariantCulture.NumberFormat)}\"", LogLevel.Verbose); // the address that we will return to after // the jump wer'e going to inject EndsceneReturnAddress = EndsceneAddress + 0x5; // integer to check if there is code waiting to be executed CodeToExecuteAddress = TrashMem.AllocateMemory(4); TrashMem.Write(CodeToExecuteAddress.Address, 0); // integer to save the address of the return value ReturnValueAddress = TrashMem.AllocateMemory(4); TrashMem.Write(ReturnValueAddress.Address, 0); // codecave to check if we need to execute something CodecaveForCheck = TrashMem.AllocateMemory(128); AmeisenBotLogger.Instance.Log($"[{ProcessId.ToString("X", CultureInfo.InvariantCulture.NumberFormat)}]\tCCCheck is at \"0x{CodecaveForCheck.Address.ToString("X", CultureInfo.InvariantCulture.NumberFormat)}\"", LogLevel.Verbose); // codecave for the code we wa't to execute CodecaveForExecution = TrashMem.AllocateMemory(2048); AmeisenBotLogger.Instance.Log($"[{ProcessId.ToString("X", CultureInfo.InvariantCulture.NumberFormat)}]\tCCExecution is at \"0x{CodecaveForExecution.Address.ToString("X", CultureInfo.InvariantCulture.NumberFormat)}\"", LogLevel.Verbose); TrashMem.Asm.Clear(); // save registers TrashMem.Asm.AddLine("PUSHFD"); TrashMem.Asm.AddLine("PUSHAD"); // check for code to be executed TrashMem.Asm.AddLine($"MOV EBX, [0x{CodeToExecuteAddress.Address.ToString("X")}]"); TrashMem.Asm.AddLine("TEST EBX, 1"); TrashMem.Asm.AddLine("JE @out"); // execute our stuff and get return address TrashMem.Asm.AddLine($"MOV EDX, 0x{CodecaveForExecution.Address.ToString("X")}"); TrashMem.Asm.AddLine("CALL EDX"); TrashMem.Asm.AddLine($"MOV [0x{ReturnValueAddress.Address.ToString("X")}], EAX"); // finish up our execution TrashMem.Asm.AddLine("@out:"); TrashMem.Asm.AddLine("MOV EDX, 0"); TrashMem.Asm.AddLine($"MOV [0x{CodeToExecuteAddress.Address.ToString("X")}], EDX"); // restore registers TrashMem.Asm.AddLine("POPAD"); TrashMem.Asm.AddLine("POPFD"); byte[] asmBytes = TrashMem.Asm.Assemble(); // needed to determine the position where the original // asm is going to be placed int asmLenght = asmBytes.Length; // inject the instructions into our codecave TrashMem.Asm.Inject(CodecaveForCheck.Address); // --------------------------------------------------- // End of the code that checks if there is asm to be // executed on our hook // --------------------------------------------------- // Prepare to replace the instructions inside WoW TrashMem.Asm.Clear(); // do the original EndScene stuff after we restored the registers // and insert it after our code TrashMem.WriteBytes(CodecaveForCheck.Address + (uint)asmLenght, originalEndsceneBytes); // return to original function after we're done with our stuff TrashMem.Asm.AddLine($"JMP 0x{EndsceneReturnAddress.ToString("X")}"); TrashMem.Asm.Inject(CodecaveForCheck.Address + (uint)asmLenght + 5); TrashMem.Asm.Clear(); // --------------------------------------------------- // End of doing the original stuff and returning to // the original instruction // --------------------------------------------------- // modify original EndScene instructions to start the hook TrashMem.Asm.AddLine($"JMP 0x{CodecaveForCheck.Address.ToString("X")}"); TrashMem.Asm.Inject(EndsceneAddress); AmeisenBotLogger.Instance.Log($"[{ProcessId.ToString("X", CultureInfo.InvariantCulture.NumberFormat)}]\tInjected Hook [IsWoWHooked = {IsWoWHooked}]", LogLevel.Verbose); // we should've hooked WoW now } }
public void InteractWithGuid(ulong guid, ClickToMoveType clickToMoveType = ClickToMoveType.Interact) { TrashMem.Write(OffsetList.StaticClickToMoveGuid, guid); TrashMem.Write(OffsetList.StaticClickToMoveAction, (int)clickToMoveType); }