public static State ReadState() { var processes = Process.GetProcessesByName("dungeons of dredmor"); if (processes.Length == 0) { return(null); } using (var memory = new ProcessMemory()) { if (memory.Open(processes[0]) == false) { return(null); } if (memory.MainModuleAddress != 0x00400000) { throw new InvalidOperationException("main module address is not 0x00400000 (ASLR is on?)"); } var state = new State(); var playerAddress = memory.ReadU32(PlayerAddress); state.Player = playerAddress == 0 ? null : Player.Read(memory, playerAddress); var levelAddress = memory.ReadU32(LevelAddress); state.CurrentLevel = levelAddress == 0 ? null : Level.Read(memory, levelAddress); return(state); } }
public static bool Init() { bool state = mem.OpenProcess("Among Us"); if (state) { Methods.Init(); Process proc = Process.GetProcessesByName("Among Us")[0]; ProcessMemory = new ProcessMemory(proc); ProcessMemory.Open(ProcessAccess.AllAccess); } return(state); }
static bool OpenProcess(string processName) { var state = mem.OpenProcess(processName); if (state) { Process proc = Process.GetProcessesByName(processName)[0]; process = proc; ProcessMemory = new ProcessMemory(proc); ProcessMemory.Open(ProcessAccess.AllAccess); return(true); } return(false); }
static void Main(string[] args) { while (true) { Console.WriteLine("Enter process name:"); var processName = Console.ReadLine(); if (processName == "exit" || processName == "q") { break; } var process = Process.GetProcessesByName(processName).FirstOrDefault(); if (process == null) { Console.WriteLine("Process not found."); continue; } using (var procmem = new ProcessMemory(process)) { procmem.Open(); Console.WriteLine(procmem.GetCommandLine()); } } }