Exemple #1
0
        //将值写入指定内存地址中
        public void WriteMemoryValue(int baseAddress, string processName, int value)
        {
            IntPtr hProcess = Windows32API.OpenProcess(0x1F0FFF, false, GetPid(processName)); //0x1F0FFF 最高权限

            Windows32API.WriteProcessMemory(hProcess, (IntPtr)baseAddress, new int[] { value }, 4, IntPtr.Zero);
            Windows32API.CloseHandle(hProcess);
        }
Exemple #2
0
        public int GetHandleByProcessName(string processName)
        {
            var processes = Process.GetProcessesByName(processName);
            var process   = processes.FirstOrDefault();

            if (process == null)
            {
                throw new Exception($"Process whose name is {processName} is not found.");
            }
            return(Windows32API.OpenProcess(0x1F0FFF, 0, process.Id));
        }