本文介绍了如何在另一个进程内存上写入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个地址要修改.我有流程.我有了新的价值.那么现在怎么办?
I have an address that I would like to modify. I have the process. I have the new value. So now what?
// My Process
var p = Process.GetProcessesByName("ePSXe").FirstOrDefault();
// Address
var addr = 0x00A66E11;
// Value
var val = 0x63;
如何将 0x63
(99) 写入另一个进程内存中的这个地址?
How can I write 0x63
(99) to this address on another process memory?
推荐答案
@Harvey,从你的回答中我发现了很多:
@Harvey, from your answer I dug up and found a lot:
打开、关闭和写入签名:
Open, Close and Write signatures:
[DllImport("kernel32.dll")]
static extern IntPtr OpenProcess(ProcessAccessFlags dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, int dwProcessId);
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, uint nSize, out int lpNumberOfBytesWritten);
[DllImport("kernel32.dll")]
public static extern Int32 CloseHandle(IntPtr hProcess);
标志:
[Flags]
public enum ProcessAccessFlags : uint
{
All = 0x001F0FFF,
Terminate = 0x00000001,
CreateThread = 0x00000002,
VMOperation = 0x00000008,
VMRead = 0x00000010,
VMWrite = 0x00000020,
DupHandle = 0x00000040,
SetInformation = 0x00000200,
QueryInformation = 0x00000400,
Synchronize = 0x00100000
}
让我的生活更轻松的方法:
Make my life easier method:
public static void WriteMem(Process p, int address, long v)
{
var hProc = OpenProcess(ProcessAccessFlags.All, false, (int)p.Id);
var val = new byte[] { (byte)v };
int wtf = 0;
WriteProcessMemory(hProc, new IntPtr(address), val, (UInt32)val.LongLength, out wtf);
CloseHandle(hProc);
}
写入另一个进程内存:
static void Main(string[] args)
{
var p = Process.GetProcessesByName("ePSXe").FirstOrDefault();
WriteMem(p, 0x00A66DB9, 99);
}
这篇关于如何在另一个进程内存上写入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!