private void DisposeHook() { if (IsWoWHooked) { AmeisenBotLogger.Instance.Log($"[{ProcessId.ToString("X", CultureInfo.InvariantCulture.NumberFormat)}]\tDisposing Hook", LogLevel.Verbose); TrashMem.WriteBytes(EndsceneAddress, originalEndsceneBytes); if (CodecaveForCheck != null) { TrashMem.FreeMemory(CodecaveForCheck); } if (CodecaveForExecution != null) { TrashMem.FreeMemory(CodecaveForExecution); } if (CodeToExecuteAddress != null) { TrashMem.FreeMemory(CodeToExecuteAddress); } if (ReturnValueAddress != null) { TrashMem.FreeMemory(ReturnValueAddress); } } }
public void LuaDoString(string command) { AmeisenBotLogger.Instance.Log($"[{ProcessId.ToString("X", CultureInfo.InvariantCulture.NumberFormat)}]\tExecuting Lua \"{command}\"", LogLevel.Verbose); if (command.Length > 0) { byte[] bytes = Encoding.UTF8.GetBytes(command); MemoryAllocation memAlloc = TrashMem.AllocateMemory(bytes.Length + 1); if (memAlloc == null) { return; } TrashMem.WriteBytes(memAlloc.Address, bytes); if (memAlloc.Address == 0) { return; } string[] asm = new string[] { $"MOV EAX, 0x{memAlloc.Address.ToString("X")}", "PUSH 0", "PUSH EAX", "PUSH EAX", $"CALL 0x{OffsetList.FunctionLuaDoString.ToString("X")}", "ADD ESP, 0xC", "RETN", }; InjectAndExecute(asm, false); TrashMem.FreeMemory(memAlloc); } }
public string GetLocalizedText(string variable) { AmeisenBotLogger.Instance.Log($"[{ProcessId.ToString("X", CultureInfo.InvariantCulture.NumberFormat)}]\tReading Lua variable \"{variable}\"", LogLevel.Verbose); if (variable.Length > 0) { byte[] bytes = Encoding.UTF8.GetBytes(variable); MemoryAllocation memAlloc = TrashMem.AllocateMemory(bytes.Length + 1); if (memAlloc == null) { return(""); } TrashMem.WriteBytes(memAlloc.Address, bytes); string[] asmLocalText = new string[] { $"CALL 0x{OffsetList.FunctionGetActivePlayerObject.ToString("X")}", "MOV ECX, EAX", "PUSH -1", $"PUSH 0x{memAlloc.Address.ToString("X")}", $"CALL 0x{OffsetList.FunctionGetLocalizedText.ToString("X")}", "RETN", }; string result = Encoding.UTF8.GetString(InjectAndExecute(asmLocalText, true)); TrashMem.FreeMemory(memAlloc); return(result); } return(""); }
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 HandleLogin(TrashMem trashMem, Process process, WowAccount wowAccount) { AmeisenBotLogger.Instance.Log($"[{process.Id.ToString("X" , CultureInfo.InvariantCulture.NumberFormat)}]\tHandling Login into account: {wowAccount.Username}:{wowAccount.CharacterName}:{wowAccount.CharacterSlot}", LogLevel.Verbose); foreach (char c in wowAccount.Username) { SendKeyToProcess(process, c, char.IsUpper(c)); Thread.Sleep(10); } Thread.Sleep(100); SendKeyToProcess(process, 0x09); Thread.Sleep(100); bool firstTime = true; do { if (!firstTime) { SendKeyToProcess(process, 0x0D); } foreach (char c in wowAccount.Password) { SendKeyToProcess(process, c, char.IsUpper(c)); Thread.Sleep(10); } Thread.Sleep(500); SendKeyToProcess(process, 0x0D); Thread.Sleep(3000); firstTime = false; } while (trashMem.ReadString(OffsetList.StaticGameState, Encoding.ASCII, 10) == "login"); }
private T ReadObject <T>(uint offset) { try { return(TrashMem.ReadStruct <T>(offset)); } catch { CheckForGameCrashed(); return(default); }
private uint ReadUInt(uint offset) { try { return(TrashMem.ReadUnmanaged <uint>(offset)); } catch { CheckForGameCrashed(); return(0); } }
private byte ReadByte(uint offset) { try { return(TrashMem.ReadChar(offset)); } catch { CheckForGameCrashed(); return(0); } }
private uint GetEndScene() { uint pDevice = TrashMem.ReadUInt32(OffsetList.StaticEndSceneDevice); uint pEnd = TrashMem.ReadUInt32(pDevice + OffsetList.EndSceneOffsetDevice); uint pScene = TrashMem.ReadUInt32(pEnd); return(TrashMem.ReadUInt32(pScene + OffsetList.EndSceneOffset)); }
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 string ReadString(uint offset, int lenght) { try { return(TrashMem.ReadString(offset, Encoding.ASCII, lenght)); } catch { CheckForGameCrashed(); return(""); } }
private void WriteInt(uint offset, int value) { try { TrashMem.Write <int>(offset, value); } catch { CheckForGameCrashed(); } }
private int ReadInt(uint offset) { try { return(TrashMem.ReadInt32(offset)); } catch { CheckForGameCrashed(); return(0); } }
private void ButtonDetach_Click(object sender, RoutedEventArgs e) { if (TrashMem != null) { TrashMem.Detach(); } ResetTrashMemViews(); }
private void ButtonCloseHandle_Click(object sender, RoutedEventArgs e) { if (listboxRemoteThreads.SelectedItem != null) { uint handle = ((RemoteThread)listboxRemoteThreads.SelectedItem).Handle; TrashMem.TerminateThread((RemoteThread)listboxRemoteThreads.SelectedItem, 0x1); UpdateAllocationsAndThreads(); } }
public MemoryWowActionExecutor(TrashMem trashMem, IOffsetList offsetList) { originalEndsceneBytes = offsetList.EndSceneBytes; TrashMem = trashMem; OffsetList = offsetList; EndsceneAddress = GetEndScene(); SetupEndsceneHook(); }
private void ButtonResetMemory_Click(object sender, RoutedEventArgs e) { if (TrashMem != null && listboxAllocations.SelectedItem != null) { uint address = ((MemoryAllocation)listboxAllocations.SelectedItem).Address; int size = ((MemoryAllocation)listboxAllocations.SelectedItem).Size; TrashMem.WriteBytes(address, new byte[size]); UpdateByteViews(address, size); } }
private void UpdateByteViews(uint address, int size) { byte[] bytes = TrashMem.ReadChars(address, size); textboxByteView.Text = GenerateByteView(bytes); textboxDecodedByteView.Text = GenerateEncodedByteView(bytes, Encoding.ASCII); labelInt16.Content = $"{BitConverter.ToInt16(bytes, 0)}"; labelInt32.Content = $"{BitConverter.ToInt32(bytes, 0)}"; labelInt64.Content = $"{BitConverter.ToInt64(bytes, 0)}"; labelFloat.Content = $"{BitConverter.ToSingle(bytes, 0)}"; labelDouble.Content = $"{BitConverter.ToDouble(bytes, 0)}"; }
private void ButtonNewAlloc_Click(object sender, RoutedEventArgs e) { if (TrashMem != null) { if (int.TryParse(textboxAllocSize.Text, out int allocSize)) { TrashMem.AllocateMemory(allocSize); } UpdateAllocationsAndThreads(); } }
public AmeisenBot(TrashMem trashMem, IWowDataAdapter wowDataAdapter, IAutologinProvider autologinProvider, Process process) { Attached = false; AutologinProvider = autologinProvider; Process = process; WowDataAdapter = wowDataAdapter; WowDataAdapter.OnGamestateChanged = COnGamestateChanged; TrashMem = trashMem; AmeisenBotLogger.Instance.Log($"[{process?.Id.ToString("X" , CultureInfo.InvariantCulture.NumberFormat)}]\tAmeisenBot initialised [{wowDataAdapter?.AccountName}, {CharacterName}, {RealmName}, {wowDataAdapter?.WowBuild}]"); }
public void Setup() { Process[] testProcesses = Process.GetProcessesByName("ShittyMcUlow"); if (testProcesses.Length > 0) { TrashMem = new TrashMem(testProcesses.ToList().First()); } else { Assert.Fail(); } }
public bool DoLogin(Process process, WowAccount wowAccount, IOffsetList offsetlist, int maxTries = 4) { try { TrashMem trashMem = new TrashMem(process); int count = 0; LoginInProgress = true; LoginInProgressCharactername = wowAccount.CharacterName; OffsetList = offsetlist; while (trashMem.ReadInt32(offsetlist.StaticIsWorldLoaded) != 1) { if (process.HasExited || count >= maxTries) { return(false); } switch (trashMem.ReadString(offsetlist.StaticGameState, Encoding.ASCII, 10)) { case "login": HandleLogin(trashMem, process, wowAccount); count++; break; case "charselect": HandleCharSelect(trashMem, process, wowAccount); break; default: count++; break; } Thread.Sleep(2000); } } catch (Exception e) { AmeisenBotLogger.Instance.Log($"[{process.Id.ToString("X" , CultureInfo.InvariantCulture.NumberFormat)}]\tCrash at Login: \n{e}", LogLevel.Error); return(false); } AmeisenBotLogger.Instance.Log($"[{process.Id.ToString("X" , CultureInfo.InvariantCulture.NumberFormat)}]\tLogin successful...", LogLevel.Verbose); LoginInProgress = false; LoginInProgressCharactername = string.Empty; return(true); }
private void HandleCharSelect(TrashMem trashMem, Process process, WowAccount wowAccount) { AmeisenBotLogger.Instance.Log($"[{process.Id.ToString("X" , CultureInfo.InvariantCulture.NumberFormat)}]\tHandling Characterselection: {wowAccount.Username}:{wowAccount.CharacterName}:{wowAccount.CharacterSlot}", LogLevel.Verbose); int currentSlot = trashMem.ReadInt32(OffsetList.StaticCharacterSlotSelected); while (currentSlot != wowAccount.CharacterSlot) { SendKeyToProcess(process, 0x28); Thread.Sleep(200); currentSlot = trashMem.ReadInt32(OffsetList.StaticCharacterSlotSelected); } SendKeyToProcess(process, 0x0D); }
public MemoryWowDataAdapter(TrashMem trashMem, IOffsetList offsetList) { LastIsWorldLoaded = false; WowObjectList = new List <WowObject>(); TrashMem = trashMem; OffsetList = offsetList; SetupAdapter(); ObjectManager = new WowObjectManager(this); SetupWatchdogs(); EnableAutoloot(); EnableClickToMove(); }
private void ButtonFreeAlloc_Click(object sender, RoutedEventArgs e) { if (TrashMem != null) { if (listboxAllocations.SelectedItem != null) { TrashMem.FreeMemory((MemoryAllocation)listboxAllocations.SelectedItem); } UpdateAllocationsAndThreads(); labelInt16.Content = "n/a"; labelInt32.Content = "n/a"; labelInt64.Content = "n/a"; labelFloat.Content = "n/a"; labelDouble.Content = "n/a"; } }
private void ButtonInjectDll_Click(object sender, RoutedEventArgs e) { if (listboxProcesses.SelectedItem != null) { string dllFolder = Path.GetDirectoryName( ((CProcess)listboxProcesses.SelectedItem).Process.MainModule.FileName); string dllName = Path.GetFileName(DllPath); string dllPath = $"{dllFolder}\\{dllName}"; if (File.Exists(dllPath)) { File.Delete(dllPath); } File.Copy(DllPath, dllPath); TrashMem.InjectDll(DllPath); UpdateAllocationsAndThreads(); } }
private void ButtonAttach_Click(object sender, RoutedEventArgs e) { if (listboxProcesses != null) { if (TrashMem != null) { TrashMem.Detach(); ResetTrashMemViews(); } TrashMem = new TrashMem(((CProcess)listboxProcesses.SelectedItem).Process); labelTrashMemAttachedId.Content = $"{TrashMem.Process.Id} => 0x{TrashMem.Process.Id.ToString("X")}"; labelTrashMemProcessHandle.Content = $"0x{TrashMem.ProcessHandle.ToString("X")}"; labelTrashMemAllocs.Content = $"{TrashMem.MemoryAllocations.Count}"; labelTrashMemCachedSizes.Content = $"{TrashMem.CachedSizeManager.SizeCache.Count}"; labelTrashMemThreads.Content = $"{TrashMem.CachedSizeManager.SizeCache.Count}"; labelKernel32Module.Content = $"0x{TrashMem.Kernel32ModuleHandle.ToString("X")}"; labelLoadLibaryA.Content = $"0x{TrashMem.LoadLibraryAAddress.ToString("X")}"; labelTrashMemThreads.Content = $"{TrashMem.RemoteThreads.Count}"; } }
private void SetupNewAmeisenBot(WowAccount account, WowProcess wowProcess) { WowAccounts[account] = BotStartState.BotIsAttaching; TrashMem trashMem = new TrashMem(wowProcess.Process); MemoryWowDataAdapter memoryWowDataAdapter = new MemoryWowDataAdapter(trashMem, OffsetList); MemoryWowActionExecutor memoryWowActionExecutioner = new MemoryWowActionExecutor(trashMem, OffsetList); AmeisenNavPathfindingClient ameisenNavPathfindingClient = new AmeisenNavPathfindingClient(Settings.AmeisenNavmeshServerIp, Settings.AmeisenNavmeshServerPort, wowProcess.Process.Id); LuaHookWowEventAdapter luaHookWowEventAdapter = new LuaHookWowEventAdapter(memoryWowActionExecutioner); BasicMeleeMovementProvider basicMeleeMovementProvider = new BasicMeleeMovementProvider(); SimpleAutologinProvider simpleAutologinProvider = new SimpleAutologinProvider(); AmeisenBot ameisenBot = new AmeisenBot(trashMem, memoryWowDataAdapter, simpleAutologinProvider, wowProcess.Process); ManagedAmeisenBot managedAmeisenBot = new ManagedAmeisenBot(wowProcess, account, ameisenBot); if (ameisenBot.AutologinProvider.DoLogin(wowProcess.Process, account, OffsetList)) { ameisenBot.Attach(memoryWowActionExecutioner, ameisenNavPathfindingClient, luaHookWowEventAdapter, basicMeleeMovementProvider, null); if (Settings.WowPositions.ContainsKey(account.CharacterName)) { ameisenBot.SetWindowPosition(Settings.WowPositions[account.CharacterName]); } ManagedAmeisenBots.Add(managedAmeisenBot); IAmeisenBotViews.OfType <WowView>().ToList().RemoveAll(v => v.WowProcess.Process.Id == managedAmeisenBot.WowProcess.Process.Id); WowAccounts[account] = BotStartState.BotIsAttached; } else { // we failed to login, restart wow... if (!wowProcess.Process.HasExited) { wowProcess.Process.Kill(); } WowAccounts[account] = BotStartState.None; } }
private static void Main(string[] args) { Console.Title = "TrashMem Benchmark"; Process[] testProcesses = Process.GetProcessesByName("ShittyMcUlow"); if (testProcesses.Length > 0) { TrashMem TrashMem = new TrashMem(testProcesses.ToList().First()); Console.WriteLine($"TrashMem Benchmark doing {TOTAL_RUNS} runs for every function"); Console.WriteLine($">> 1 Byte Char"); PrettyPrintValue("Read<char>", BenchmarkFunction(() => TrashMem.ReadUnmanaged <char>(STATIC_ADDRESS_INT16))); PrettyPrintValue("ReadChar", BenchmarkFunction(() => TrashMem.ReadChar(STATIC_ADDRESS_INT16))); PrettyPrintValue("ReadCharSafe", BenchmarkFunction(() => TrashMem.ReadCharSafe(STATIC_ADDRESS_INT16))); Console.WriteLine($">> 2 Byte Short"); PrettyPrintValue("Read<short>", BenchmarkFunction(() => TrashMem.ReadUnmanaged <short>(STATIC_ADDRESS_INT16))); PrettyPrintValue("ReadInt16", BenchmarkFunction(() => TrashMem.ReadInt16(STATIC_ADDRESS_INT16))); PrettyPrintValue("ReadInt16Safe", BenchmarkFunction(() => TrashMem.ReadInt16Safe(STATIC_ADDRESS_INT16))); Console.WriteLine($">> 4 Byte Integer"); PrettyPrintValue("Read<int>", BenchmarkFunction(() => TrashMem.ReadUnmanaged <int>(STATIC_ADDRESS_INT32))); PrettyPrintValue("ReadInt32", BenchmarkFunction(() => TrashMem.ReadInt32(STATIC_ADDRESS_INT32))); PrettyPrintValue("ReadInt32Safe", BenchmarkFunction(() => TrashMem.ReadInt32Safe(STATIC_ADDRESS_INT32))); Console.WriteLine($">> 8 Byte Long"); PrettyPrintValue("Read<long>", BenchmarkFunction(() => TrashMem.ReadUnmanaged <long>(STATIC_ADDRESS_INT64))); PrettyPrintValue("ReadInt64", BenchmarkFunction(() => TrashMem.ReadInt64(STATIC_ADDRESS_INT64))); PrettyPrintValue("ReadInt64Safe", BenchmarkFunction(() => TrashMem.ReadInt64Safe(STATIC_ADDRESS_INT64))); Console.WriteLine($">> 12 Byte String"); PrettyPrintValue("ReadString", BenchmarkFunction(() => TrashMem.ReadString(STATIC_ADDRESS_STRING, Encoding.ASCII, 12))); Console.WriteLine($">> 16 Byte Struct"); PrettyPrintValue("ReadStruct<TestStruct>", BenchmarkFunction(() => TrashMem.ReadStruct <TestStruct>(STATIC_ADDRESS_INT16))); } else { Console.WriteLine("Error: please make sure a ShittyMcUlow process is running..."); } Console.ReadLine(); }
public static List <WowProcess> GetRunningWows(IOffsetList offsetList) { List <WowProcess> wows = new List <WowProcess>(); List <Process> processList = new List <Process>(Process.GetProcessesByName("Wow")); foreach (Process p in processList) { TrashMem trashMem = new TrashMem(p); uint pDevice = trashMem.ReadUnmanaged <uint>(offsetList.StaticEndSceneDevice); uint pEnd = trashMem.ReadUnmanaged <uint>(pDevice + offsetList.EndSceneOffsetDevice); uint pScene = trashMem.ReadUnmanaged <uint>(pEnd); uint endscene = trashMem.ReadUnmanaged <uint>(pScene + offsetList.EndSceneOffset); bool isAlreadyHooked = false; try { isAlreadyHooked = trashMem.ReadChar(endscene + 0x2) == 0xE9; } catch { } string name = trashMem.ReadString(offsetList.StaticPlayerName, Encoding.ASCII, 12); if (name.Length == 0) { name = ""; } string realm = trashMem.ReadString(offsetList.StaticRealmName, Encoding.ASCII, 12); if (realm.Length == 0) { realm = ""; } wows.Add(new WowProcess(p, name, realm, isAlreadyHooked)); trashMem.Detach(); } return(wows); }