public static (int, float) TryGetInfo(long hwnd, long addr) { var data = new byte[16]; NativeFunctions.ReadProcessMemory(hwnd, addr - 0x44, data, 16, 0); return(BitConverter.ToInt32(data, 0), BitConverter.ToSingle(data, 8)); }
/// <summary> /// 失败返回-1 /// </summary> /// <param name="ctx"></param> /// <param name="aob"></param> /// <returns></returns> public static (long, long) Aobscan(long handle, byte[] aob, Func <long, bool> matchValidator, long blockToStart = 0) { long i = blockToStart; while (i < long.MaxValue) { int flag = NativeFunctions.VirtualQueryEx(handle, i, out NativeFunctions.MEMORY_BASIC_INFORMATION mbi, NativeFunctions.MEMORY_BASIC_INFORMATION_SIZE); if (flag != NativeFunctions.MEMORY_BASIC_INFORMATION_SIZE) { break; } if (mbi.RegionSize <= 0) { break; } if (mbi.State != (int)NativeFunctions.AllocationType.Commit) { i = mbi.BaseAddress + mbi.RegionSize; continue; } Console.Write($"\rscanning {mbi.BaseAddress:x}..."); byte[] va = new byte[mbi.RegionSize]; NativeFunctions.ReadProcessMemory(handle, mbi.BaseAddress, va, mbi.RegionSize, 0); long r = Memmem(va, mbi.RegionSize, aob, aob.Length, r => matchValidator(mbi.BaseAddress + r)); //long r = KMP.IndexOf(va, aob); if (r >= 0) { return(mbi.BaseAddress + r, i); } i = mbi.BaseAddress + mbi.RegionSize; } return(-1, -1); }
//private static long bossaddr; public void Refresh(int frame, float time) { //if (bossaddr == 0) bossaddr = Autopcr.getBossAddr(401041501); NativeFunctions.ReadProcessMemory(Program.hwnd, handle + 0x18C, out int state); if (curaction != null) { foreach (var action in curaction.Where(x => exectime[x] == framesince)) { // Console.WriteLine($"{prefab} action executed {action}@{frame} {Autopcr.getDef(bossaddr)}"); ActionExec?.Invoke((int)action); } } ActionState cur = (ActionState)state; if (cur != this.state) { curaction = null; if (cur == ActionState.SKILL || cur == ActionState.SKILL_1) { NativeFunctions.ReadProcessMemory(Program.hwnd, handle + 0x110, out skillid); curaction = actions[skillid]; framesince = Autopcr.frameoff; } else { skillid = cur == ActionState.ATK ? 1 : 0; } this.frame = frame; this.time = time; //Console.WriteLine($"{prefab} action changed state={cur}/{skillid}@{frame}"); } else { ++framesince; } this.state = cur; last = time; }
public void Refresh(int frame, float time) { NativeFunctions.ReadProcessMemory(Program.hwnd, handle + 0x18C, out int state); if (curaction != null) { foreach (var action in curaction) { var exec = exectime[action] + lastskill; if (exec <= time && exec > last) { ActionExec?.Invoke((int)action); } } } ActionState cur = (ActionState)state; if (cur != this.state) { curaction = null; if (cur == ActionState.SKILL || cur == ActionState.SKILL_1) { NativeFunctions.ReadProcessMemory(Program.hwnd, handle + 0x110, out skillid); curaction = actions[skillid]; lastskill = time; } else { skillid = cur == ActionState.ATK ? 1 : 0; } this.frame = frame; this.time = time; //Console.WriteLine($"{prefab} action changed state={cur}/{skillid}@{frame}"); } this.state = cur; last = time; }