看了两个经典源码还是不大懂,编译没法通过
比如我现在知道XX程序的内存地址中00452BD4中存放的数据是4,我想改成8我得怎么办??如:function SetProcessMemoryForID(ProcessID: THandle; Address: LongWord; Buf: Pointer; Len: LongWord): boolean;
var
lpNumberOfBytes: LongWord;
hProcessHandle: THandle;
begin
Result := false;
if ProcessID = 0 then exit;
hProcessHandle := OpenProcess(PROCESS_VM_READ or PROCESS_VM_WRITE or PROCESS_VM_OPERATION, false, ProcessID);
if hProcessHandle = 0 then exit;
try
是不是得在这里操作?写上代码,具体应该怎么做!?
WriteProcessMemory(hProcessHandle, Pointer(Address), buf, len, lpNumberOfBytes);finally
CloseHandle(hProcessHandle);
end;
Result := True;
end;
比如我现在知道XX程序的内存地址中00452BD4中存放的数据是4,我想改成8我得怎么办??如:function SetProcessMemoryForID(ProcessID: THandle; Address: LongWord; Buf: Pointer; Len: LongWord): boolean;
var
lpNumberOfBytes: LongWord;
hProcessHandle: THandle;
begin
Result := false;
if ProcessID = 0 then exit;
hProcessHandle := OpenProcess(PROCESS_VM_READ or PROCESS_VM_WRITE or PROCESS_VM_OPERATION, false, ProcessID);
if hProcessHandle = 0 then exit;
try
是不是得在这里操作?写上代码,具体应该怎么做!?
WriteProcessMemory(hProcessHandle, Pointer(Address), buf, len, lpNumberOfBytes);finally
CloseHandle(hProcessHandle);
end;
Result := True;
end;
解决方案 »
- 能不能谈谈delphi2006在delphi7上的改动呢?谢谢
- 托盘图标的问题
- 如何以事务的概念操作SQL server和Oracle?
- <高分相送>小弟是菜鸟,谁能给个delphi7 socket通讯的例子?最好是源码
- 请问连接SQL SERVER2000的问题。
- 已知一个三角形的三个顶点,现将三角形放大、缩小,求放大、缩小后三角形的顶点坐标。
- 求:一个sql语句?
- 大家好:请问如何用StringGrid1这组件。谢意!
- 请问有没有同VB中 for i=0 to 100 step .5 一样的语句?
- 检测软区内是否有盘用什么函数?
- 高分求像MSN和QQ那样带Image的PageControl
- CSDN.NET社区 QQ群
// 这样 可能是可以的
WriteProcessMemory(
hProcessHandle, // 你所要写入进程的handle<IN>
Pointer(Address),// 写入的首地址 <IN>
buf, // 所要写入的内容的首地址<IN>
len, // 所要写入的长度 <IN>
lpNumberOfBytes);// 实际写入的长度 <OUT>
edit2.Text:='0x'+Listbox1.Items.Strings[listbox1.itemindex];我的写法是下面WriteProcessMemory(hProcessHandle,pointer(strtoint('0x00452BD4')),strtoint('40'));但老是说我整形给指针型 请问是哪出问题了~~
http://community.csdn.net/Expert/topic/3427/3427876.xml?temp=.8115045
例子代码如下:const
CProcessName = 'abc.exe'; //要修改的进程文件名称,你可以改成自己的,也可以用变量
var
mProcessID: THandle; //用于保存进程标识的变量
mAddress: LongWord; //用于保存要修改的进程地址
byBuf: Byte; //用于修改进程的数据空间,可以是任何有效类型,包括结构
begin
mAddress := $00452BD4; //这里是一个固定地址,你可以使用表达式计算出一个地址,比如基准地址加一个偏移量(偏移量一般是一个结构大小与结构编号的乘积)
byBuf := 8; //设置写入缓冲区
mProcessID := GetProcessID(PCHAR(CProcessName)); //获得进程标识
if not SetProcessMemoryForID(mProcessID, mAddress, @byBuf, SizeOf(byBuf)) then //对目标进程也能够写入新的信息,若出错,则提示。
application.Messagebox(........);
end;//@byBuf 用于获得 byBuf 的地址指针
//SizeOf(byBuf) 用于获得 byBuf 的空间大小楼主需要看一些基本教程了,函数都提供给你了,还没看明白。ft说个题外话,原来玩网游的时候,有个网友跟楼主同名。
hProcessHandle, // 你所要写入进程的handle<IN>
Pointer(Address),// 写入的首地址 <IN>
buf, // 所要写入的内容的首地址<IN>
len, // 所要写入的长度 <IN>
lpNumberOfBytes);// 实际写入的长度 <OUT>buf, // 所要写入的内容的首地址??这不是要写入的数据吗!?看来我真的得恶补一下了!
相对VC来说 还是1Z很多的。。
chr buf[255];
memset(buf, 0, 255);buf, // 所要写入的内容的首地址??这不是要写入的数据吗!?看来我真的得恶补一下了!
buf就是你要写入的内容的首地址呀 这是C++的基本语法哦。。
而且是以 LPVOID lpBuffer, // pointer to buffer to write data to
所以还需要传入后面的len 不然不知道写多少
LPVOID lpBaseAddress, // address to start writing to
LPVOID lpBuffer, // pointer to buffer to write data to
DWORD nSize, // number of bytes to write
LPDWORD lpNumberOfBytesWritten // actual number of bytes written
);
ParametershProcessIdentifies an open handle to a process whose memory is to be written to. The handle must have PROCESS_VM_WRITE and PROCESS_VM_OPERATION access to the process. lpBaseAddressPoints to the base address in the specified process to be written to. Before any data transfer occurs, the system verifies that all data in the base address and memory of the specified size is accessible for write access. If this is the case, the function proceeds; otherwise, the function fails. lpBufferPoints to the buffer that supplies data to be written into the address space of the specified process. nSizeSpecifies the requested number of bytes to write into the specified process. lpNumberOfBytesWrittenPoints to the actual number of bytes transferred into the specified process. This parameter is optional. If lpNumberOfBytesWritten is NULL, the parameter is ignored. Return ValuesIf the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError. The function will fail if the requested write operation crosses into an area of the process that is inaccessible. ResWriteProcessMemory copies the data from the specified buffer in the current process to the address range of the specified process. Any process that has a handle with PROCESS_VM_WRITE and PROCESS_VM_OPERATION access to the process to be written to can call the function. The process whose address space is being written to is typically, but not necessarily, being debugged.
The entire area to be written to must be accessible. If it is not, the function fails as noted previously.