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); }
private int ReadInt(uint offset) { try { return(TrashMem.ReadInt32(offset)); } catch { CheckForGameCrashed(); return(0); } }
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 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 void ReadInt32Test() => Assert.AreEqual(0xFFFF, TrashMem.ReadInt32(STATIC_ADDRESS_INT32));
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()); }