WriteProcessMemory改内存中的值(100分求解) ( 积分: 100 )

  • 主题发起人 主题发起人 |KrisCn|
  • 开始时间 开始时间
K

|KrisCn|

Unregistered / Unconfirmed
GUEST, unregistred user!
我的代码看看&nbsp;&nbsp;&nbsp;哪里错了&nbsp;<br><br>procedure&nbsp;&nbsp;&nbsp;TFrm_Pop.Button2Click(Sender:&nbsp;&nbsp;&nbsp;TObject);&nbsp;<br>var&nbsp;<br>Num:cardinal;&nbsp;<br>CS:integer;&nbsp;<br>begin&nbsp;<br>CS:=1127653747;&nbsp;<br>WriteProcessMemory(PHND,pointer($723304+$140),@CS,4,Num);&nbsp;&nbsp;&nbsp;//改写内存&nbsp;<br>end;<br><br>为什么写不进去&nbsp;请问是写错了还是再加VirtualProtectEx&nbsp;&nbsp;&nbsp;来打开写入权限?
 
PHND是对的吗?WriteProcessMemory好像是不管内存是否有写入属性的
 
PHND没问题
 
ShowMessage(SysErrorMessage(GetLastError))<br>来看看是得到什么样的错误代码
 
首先确定$723304+$140地址是可以访问的<br>根据writeProcessMemory的参数:<br>hProcess<br>Identifies&nbsp;an&nbsp;open&nbsp;handle&nbsp;to&nbsp;a&nbsp;process&nbsp;whose&nbsp;memory&nbsp;is&nbsp;to&nbsp;be&nbsp;written&nbsp;to.&nbsp;The&nbsp;handle&nbsp;must&nbsp;have&nbsp;PROCESS_VM_WRITE&nbsp;and&nbsp;PROCESS_VM_OPERATION&nbsp;access&nbsp;to&nbsp;the&nbsp;process.&nbsp;<br>lpBaseAddress<br>Points&nbsp;to&nbsp;the&nbsp;base&nbsp;address&nbsp;in&nbsp;the&nbsp;specified&nbsp;process&nbsp;to&nbsp;be&nbsp;written&nbsp;to.&nbsp;Before&nbsp;any&nbsp;data&nbsp;transfer&nbsp;occurs,&nbsp;the&nbsp;system&nbsp;verifies&nbsp;that&nbsp;all&nbsp;data&nbsp;in&nbsp;the&nbsp;base&nbsp;address&nbsp;and&nbsp;memory&nbsp;of&nbsp;the&nbsp;specified&nbsp;size&nbsp;is&nbsp;accessible&nbsp;for&nbsp;write&nbsp;access.&nbsp;If&nbsp;this&nbsp;is&nbsp;the&nbsp;case,&nbsp;the&nbsp;function&nbsp;proceeds;&nbsp;otherwise,&nbsp;the&nbsp;function&nbsp;fails.&nbsp;<br>lpBuffer<br>Points&nbsp;to&nbsp;the&nbsp;buffer&nbsp;that&nbsp;supplies&nbsp;data&nbsp;to&nbsp;be&nbsp;written&nbsp;into&nbsp;the&nbsp;address&nbsp;space&nbsp;of&nbsp;the&nbsp;specified&nbsp;process.&nbsp;<br>nSize<br>Specifies&nbsp;the&nbsp;requested&nbsp;number&nbsp;of&nbsp;bytes&nbsp;to&nbsp;write&nbsp;into&nbsp;the&nbsp;specified&nbsp;process.&nbsp;<br><br>lpNumberOfBytesWritten<br>Points&nbsp;to&nbsp;the&nbsp;actual&nbsp;number&nbsp;of&nbsp;bytes&nbsp;transferred&nbsp;into&nbsp;the&nbsp;specified&nbsp;process.&nbsp;This&nbsp;parameter&nbsp;is&nbsp;optional.&nbsp;If&nbsp;lpNumberOfBytesWritten&nbsp;is&nbsp;NULL,&nbsp;the&nbsp;parameter&nbsp;is&nbsp;ignored.&nbsp;<br><br>应该不用我翻译了吧[:D]
 
如果没错的话&nbsp;&nbsp;&nbsp;是不是要加VirtualProtectEx&nbsp;&nbsp;&nbsp;来打开写入权限?
 
PHND&nbsp;和指针都没错&nbsp;&nbsp;请问为什么写不进去?
 
地址是否具有读写保护<br><br>可以先试下读取内容,没问题的话再试下写
 
可以正常的读
 
我听人说要加VirtualProtectEx函数&nbsp;谁会写
 
多人接受答案了。
 
后退
顶部