public static IntPtr AllocMem(int size) { Int32 pid = FindProcess(Constants.ProcessName); IntPtr hProcess = OpenProcess(ProcessAccessFlags.All, false, pid); if (hProcess == IntPtr.Zero) { return(IntPtr.Zero); } IntPtr caveAddress = WinAPIWrapper.VirtualAllocEx(hProcess, IntPtr.Zero, (uint)size, WinAPIWrapper.AllocationType.Commit, WinAPIWrapper.MemoryProtection.ExecuteReadWrite); WinAPIWrapper.CloseHandle(hProcess); return(caveAddress); }
public static Int32 FindProcess(String processName) { return(WinAPIWrapper.GetProcessIdByName(processName)); }