private static void WriteMacroLine(IntPtr process, MemoryPattern pattern, IntPtr basePtr, int line, byte[] data, int len) { var ptr = NativeMethods.ReadPointer(process, pattern.IsX64, basePtr + pattern.MacroLineSize * line + pattern.MacroLineAddress); if (ptr == IntPtr.Zero) { return; } IntPtr written = IntPtr.Zero; NativeMethods.WriteProcessMemory(process, ptr, data, new IntPtr(len), out written); }
private void SetFFXIVProcess(string client) { this.Clear(false); var result = false; try { this.m_ffxiv = Process.GetProcessById(int.Parse(client.Substring(client.IndexOf(':') + 1))); this.m_ffxiv.EnableRaisingEvents = true; this.m_ffxiv.Exited += (s, e) => this.Clear(true); this.m_ffxivHandle = NativeMethods.OpenProcess(NativeMethods.ProcessAccessFlags.All, false, m_ffxiv.Id); this.m_isX64 = !NativeMethods.IsX86Process(this.m_ffxivHandle); this.m_ffxivMainWnd = NativeMethods.FindWindow("FFXIVGAME", null, m_ffxiv.Id); if (this.m_ffxivMainWnd != IntPtr.Zero) { this.m_pattern = this.m_isX64 ? MemoryPattern.X64 : MemoryPattern.X86; try { this.m_baseModulePtr = this.m_ffxiv.MainModule.BaseAddress; this.m_chatLog = NativeMethods.ScanFromBytes(this.m_baseModulePtr, this.m_ffxiv.MainModule.ModuleMemorySize, this.m_ffxivHandle, this.m_pattern.ChatPattern, this.m_isX64); } catch { this.m_chatLog = IntPtr.Zero; } if (this.m_chatLog != IntPtr.Zero) { result = true; this.m_readChat.Set(); this.m_readChatTask = Task.Factory.StartNew(this.ReadChatWorker); } } } catch { } if (this.OnClientSelected != null) { this.OnClientSelected.Invoke(client, result); } }
private static int GetMacroLineLength(IntPtr process, MemoryPattern pattern, IntPtr basePtr, int line) { return(NativeMethods.ReadBytes(process, basePtr + pattern.MacroLineSize * line + pattern.MacroLineLength, 1)[0] - 1); }