public CharacterData(MemSharp memory) { Memory = memory; }
private async void FrmMain_Shown(object sender, EventArgs e) { var processes = Process.GetProcessesByName("Gw2-64"); if (processes.Length == 0) { #if !DEBUG MessageBox.Show("Guild Wars 2 (64 Bit) seems not to be running, please launch Guild Wars 2 first.", "Game client missing", MessageBoxButtons.OK, MessageBoxIcon.Warning); Close(); #endif } else { TargetProcess = processes[0]; Memory = new MemSharp(TargetProcess); MemoryData.RemoteTradingPostAddress = await Task.Factory.StartNew(() => { return(Memory.Pattern(Memory.TargetProcess.MainModule, MemoryData.RemoteTradingPostPattern)); }); if (MemoryData.RemoteTradingPostAddress == IntPtr.Zero) { btnRemoteTP.Enabled = false; } MemoryData.SetFOVAddress = await Task.Factory.StartNew(() => { return(Memory.Pattern(Memory.TargetProcess.MainModule, MemoryData.SetFOVPattern)); }); if (MemoryData.SetFOVAddress == IntPtr.Zero) { cbFOV.Enabled = false; } MemoryData.ContextPtr = await Task.Factory.StartNew(() => { var contextPtr = IntPtr.Zero; var contextCalcPtr = Memory.Pattern(Memory.TargetProcess.MainModule, MemoryData.ContextCalcPattern); if (contextCalcPtr != IntPtr.Zero) { var jumpSize = (uint)MemoryData.ContextCalcJumpPatch(IntPtr.Zero).Length; IntPtr jumpLocation = Native.VirtualAllocEx(Memory.TargetProcess.Handle, IntPtr.Zero, jumpSize, Native.AllocationTypeFlags.MEM_COMMIT, Native.MemoryProtectionFlags.PAGE_EXECUTE_READ_WRITE); IntPtr pointerLocation = Native.VirtualAllocEx(Memory.TargetProcess.Handle, IntPtr.Zero, (uint)IntPtr.Size, Native.AllocationTypeFlags.MEM_COMMIT, Native.MemoryProtectionFlags.PAGE_READ_WRITE); if (jumpLocation != IntPtr.Zero && pointerLocation != IntPtr.Zero) { Memory.Write(jumpLocation, MemoryData.ContextCalcJumpShellCode(pointerLocation, contextCalcPtr + MemoryData.ContextCalcJumpPatchOffset + 13)); Memory.Write(contextCalcPtr + MemoryData.ContextCalcJumpPatchOffset, MemoryData.ContextCalcJumpPatch(jumpLocation)); while (contextPtr == IntPtr.Zero) { contextPtr = new IntPtr(Memory.Read <long>(pointerLocation)); } Memory.Write(contextCalcPtr + MemoryData.ContextCalcJumpPatchOffset, MemoryData.ContextCalcRestore); } } return(contextPtr); }); if (MemoryData.ContextPtr != IntPtr.Zero) { await InitialTick(); } else { MessageBox.Show("Unable to find Context Pointer, please contact the administrator.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Close(); } } }