看了两个经典源码还是不大懂,编译没法通过
比如我现在知道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;

解决方案 »

  1.   

    自己看看吧:http://www.delphibox.com/article.asp?articleid=992
      

  2.   

    不能直接操作 绝对地址的WriteProcessMemory(hProcessHandle, Pointer(Address), buf, len, lpNumberOfBytes);
    // 这样 可能是可以的
    WriteProcessMemory(
    hProcessHandle,  // 你所要写入进程的handle<IN>
    Pointer(Address),// 写入的首地址 <IN>
    buf,             // 所要写入的内容的首地址<IN>
    len,             // 所要写入的长度 <IN>
    lpNumberOfBytes);// 实际写入的长度 <OUT>
      

  3.   

    真惨,看了源码我更不明为什么我不行了,大侠们帮看看啊,源码里是这样的.WriteMemory(hProc,pointer(strtoint(edit2.text)),strtoint(Edit4.Text));edit4.Text=''//这是源码接收输入的
    edit2.Text:='0x'+Listbox1.Items.Strings[listbox1.itemindex];我的写法是下面WriteProcessMemory(hProcessHandle,pointer(strtoint('0x00452BD4')),strtoint('40'));但老是说我整形给指针型 请问是哪出问题了~~
      

  4.   

    利用我的函数
    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说个题外话,原来玩网游的时候,有个网友跟楼主同名。
      

  5.   

    WriteProcessMemory(hProcessHandle,pointer(strtoint('0x00452BD4')),strtoint('40'));0x**** 这是 C/C++对十六进制的定义方法 而DELPHI是 $00452BD4....
      

  6.   

    同名的应该就是我了....本来用VC的,后来搞影视,去年以来从VC转过D真不习惯,而又没什么时间学习了!!
      

  7.   

    对了,还有 0x 同 $ 我都有试过的....我搞不明的是..WriteProcessMemory(
    hProcessHandle,  // 你所要写入进程的handle<IN>
    Pointer(Address),// 写入的首地址 <IN>
    buf,             // 所要写入的内容的首地址<IN>
    len,             // 所要写入的长度 <IN>
    lpNumberOfBytes);// 实际写入的长度 <OUT>buf,             // 所要写入的内容的首地址??这不是要写入的数据吗!?看来我真的得恶补一下了!
      

  8.   

    呵呵 偶以前也是搞VC呀。。搞DELPHI开始是不太习惯 慢慢就没问题的啦
    相对VC来说 还是1Z很多的。。
      

  9.   

    比如
    chr buf[255];
    memset(buf, 0, 255);buf,             // 所要写入的内容的首地址??这不是要写入的数据吗!?看来我真的得恶补一下了!
    buf就是你要写入的内容的首地址呀 这是C++的基本语法哦。。
    而且是以 LPVOID lpBuffer,  // pointer to buffer to write data to
    所以还需要传入后面的len 不然不知道写多少
      

  10.   

    LPVOID lpBuffer,这里说明他是个地址指针,你学过VC应该对指针有一定的了解阿。楼主就是那个当年给幻灵游侠写宠物成长计算器的江梦痕么?参考 Win32s Programmer's ReferenceThe WriteProcessMemory function writes memory in a specified process. The entire area to be written to must be accessible, or the operation fails. BOOL WriteProcessMemory(    HANDLE hProcess, // handle to process whose memory is written to  
        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.