请高手指点如何读写自身内存,据说用指针可以??? 请高手指点一二,学生感激不尽-_-(200分)

  • 主题发起人 主题发起人 精灵猪
  • 开始时间 开始时间

精灵猪

Unregistered / Unconfirmed
GUEST, unregistred user!
请高手指点如何读写自身内存,小弟找了半天资料,似乎指针可以读,只是忙了1晚上也没成功,比如要读或者写地址 00857485的数据应该如何做 前提是不可以用ReadProcessMemory 和WriteProcessMemory
 
修改内存,基本就是通过指针转换!<br>P := $00857485<br>PInteger(P )^ &nbsp;:= 1234;<br><br>下面是一些示例代码<br>——————————————————————————————<br>var <br> P:Pointer; <br> I:Integer; <br>begin <br> GetMem(P,1000); <br> for I:=0 to 255 do <br> begin <br> &nbsp; Byte(Pointer(LongInt(P)+I)^):=I; &nbsp;//訪問內存區位移為I的單元(字節) <br> end; <br> ShowMessage(IntToStr(Byte(Pointer(LongInt(P)+100)^))); <br> FreeMem(P,1000); <br>end;
 
PInteger(P )^ &nbsp;:= 1234;<br>这里是什么意思 另外如果是读这个位置的内存如何解决 请xiammy说详细一些<br>还有 如果是修改内存的话我要把$00857485 加个跳转比如 jmp xxxxx应该如何操作 小弟delphi比较基础 老哥别见笑
 
ShowMessage(IntToStr(Byte(Pointer(LongInt(P)+100)^)));<br>还有请问这句代码中的 是什么意思 ?
 
可以回答我吗?
 
着急啊 分不够可以加 需要人民币的也可以留下QQ我加你 程序急用 着急啊 那位达人关心一下吧
 
我知道你想干什么了,不就是想改变代码段的内容么?<br>在 Windows 中,代码段受到保护,不能直接改变,必须通过 Windows 的 Api 处理才可以,想通过指针直接改是不行的。
 
你是改变代码内容是改变目标进程的内存 目标进程代码我没有 xiammy给出的代码可以修改内存 不过我不知道如果要修改为汇编代码如何做 比如PInteger(P )^ &nbsp;:= 1234;<br>这里是10进制的 如果是16进制的就方便多了 我不会转换 或者直接可以写汇编代码更好<br>比如jmp xxx 还有就是如何读指定位置的字符串?
 
那串代码就是通过强制转换的方式来修改某地址的内容。<br>别动不动就拿人民币说事嘛。
 
多人接受答案了。
 
我想我可以解决你的问题,<br>你是做一个类似于金山游侠之类的游戏修改器吧?<br>你可以用ReadProcessMemory()来读数据,然后用(read是读然后什么是写,我忘记了,呵呵,好像是W什么什么的我用星号代一下吧,)W**ProcessMemory()来写<br>具体用法如下:<br>SHENGMING: dword = $00857485; //比如红的相对地址是$00857485<br>var<br> &nbsp;hw: HWND;<br> &nbsp;pid: dword;<br> &nbsp;h: THandle;<br> &nbsp;tt: Cardinal;<br> &nbsp;Sm:integer;<br>begin<br> &nbsp; &nbsp;hw:=FindWindow(nil,'你的游戏窗口名'); &nbsp; &nbsp;///<br> &nbsp; &nbsp;if hw = 0 then &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/// &nbsp; &nbsp; &nbsp; 获得句柄ID<br> &nbsp; &nbsp; &nbsp;Exit; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;///<br> &nbsp; &nbsp;GetWindowThreadProcessId(hw, @pid); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;///<br> &nbsp; &nbsp;h := OpenProcess(PROCESS_ALL_ACCESS, false, pid); &nbsp; &nbsp;///<br> &nbsp; &nbsp;if h = 0 then &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;///打开句柄<br> &nbsp; &nbsp; &nbsp;Exit;<br> &nbsp; &nbsp;ReadProcessMemory(h,pointer( SHENGMING), @Sm,sizeof(Sm), tt);<br> &nbsp; &nbsp;//这时变量Sm就是你所要的血量值,<br> &nbsp; &nbsp;//如果你要改变这个值就可以用 <br> &nbsp; //W**ProcessMemory(h,pointer( SHENGMING), @Sm1,sizeof(Sm), tt);<br> &nbsp; //Sm1,就是你想要改成的数据<br>end;<br>差不多就是这样,另外借你的地方问个问题,不好意思,我的帐号不能提问题要二天后<br><br>我要做一个(热血江湖)会加自动加血加蓝的外挂,<br>具体代码如下:<br>unit Mainf;<br><br>interface<br><br>uses<br> &nbsp;Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> &nbsp;Dialogs, ComCtrls,StdCtrls, ExtCtrls;<br><br>type<br> &nbsp;TMainForm = class(TForm)<br> &nbsp; &nbsp;TimerSM: TTimer;<br> &nbsp; &nbsp;TimerNG: TTimer;<br> &nbsp; &nbsp;TimerJN: TTimer;<br> &nbsp; &nbsp;CheckBoxSM: TCheckBox;<br> &nbsp; &nbsp;CheckBoxNG: TCheckBox;<br> &nbsp; &nbsp;EditSM: TEdit;<br> &nbsp; &nbsp;EditNG: TEdit;<br> &nbsp; &nbsp;CheckBoxJN: TCheckBox;<br> &nbsp; &nbsp;Button1: TButton;<br> &nbsp; &nbsp;Button2: TButton;<br> &nbsp; &nbsp;Label1:TLabel;<br> &nbsp; &nbsp;procedure CheckBoxSMClick(Sender: TObject);<br> &nbsp; &nbsp;procedure TimerSMTimer(Sender: TObject);<br> &nbsp; &nbsp;procedure Button2Click(Sender: TObject);<br> &nbsp; &nbsp;procedure Button1Click(Sender: TObject);<br> &nbsp; &nbsp;procedure CheckBoxNGClick(Sender: TObject);<br> &nbsp; &nbsp;procedure TimerNGTimer(Sender: TObject);<br> &nbsp; &nbsp;procedure CheckBoxJNClick(Sender: TObject);<br> &nbsp; &nbsp;procedure TimerJNTimer(Sender: TObject);<br> &nbsp;private<br> &nbsp; &nbsp;{ Private declarations }<br> &nbsp;public<br> &nbsp; &nbsp;{ Public declarations }<br> &nbsp;end;<br>const<br> &nbsp;SHENGMING: dword = $01453318; //红<br> &nbsp;NEIGONG: dword = $0145331C; // 蓝<br><br>var<br> &nbsp;MainForm: TMainForm;<br><br> &nbsp;hw: HWND;<br> &nbsp;pid: dword;//游戏句柄ID<br> &nbsp;h: THandle;//游戏句柄<br> &nbsp;tt: Cardinal;<br> &nbsp;procedure KeyF2;//按键<br> &nbsp;procedure KeyF3;<br> &nbsp;procedure KeyF4;<br><br>implementation<br><br>{$R *.dfm}<br>procedure TMainForm.Button1Click(Sender: TObject);<br>begin<br> &nbsp;if &nbsp;h = 0 then //如果句柄没打开<br> &nbsp; begin<br> &nbsp; &nbsp;hw:=FindWindow(nil,'YB_OnlineClient'); &nbsp; &nbsp;///<br> &nbsp; &nbsp;if hw = 0 then &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/// &nbsp; &nbsp; &nbsp; 获得句柄ID<br> &nbsp; &nbsp; &nbsp;Exit; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;///<br> &nbsp; &nbsp;GetWindowThreadProcessId(hw, @pid); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;///<br> &nbsp; &nbsp;h := OpenProcess(PROCESS_ALL_ACCESS, false, pid); &nbsp; &nbsp;///<br> &nbsp; &nbsp;if h = 0 then &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;///打开句柄<br> &nbsp; &nbsp; &nbsp;Exit;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;///<br> &nbsp; end;<br> &nbsp;TimerNG.Interval := 1000 div trunc(5);<br> &nbsp;TimerSM.Interval := 1000 div trunc(5);<br> &nbsp;TimerJN.Interval := 1000 div trunc(2);///每秒钟运行次数<br>end;<br>procedure TMainForm.CheckBoxSMClick(Sender: TObject);<br>begin<br> &nbsp; if CheckBoxSM.Checked then &nbsp;//控制Timer是否运行<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; EditSM.Enabled := false;<br> &nbsp; &nbsp; TimerSM.Enabled := true;<br> &nbsp; &nbsp;end<br> &nbsp; else<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; EditSM.Enabled := true;<br> &nbsp; &nbsp; TimerSM.Enabled := false;<br> &nbsp;end;<br>end;<br><br>procedure TMainForm.TimerSMTimer(Sender: TObject);<br>var<br> &nbsp;Sm: integer;<br> // tt: DWORD;<br>begin<br> &nbsp;ReadProcessMemory(h,pointer( SHENGMING), @Sm,sizeof(Sm), tt);<br>//扫描内存数据<br> &nbsp;<br> &nbsp;if ((Sm &lt;= StrToInt(EditSM.Text))and(Sm&lt;&gt;0)) and (h&lt;&gt;0) then<br>//如果血量值少于设定值并且不等于0<br> &nbsp; &nbsp; begin<br> &nbsp; &nbsp; &nbsp; &nbsp;KeyF3;<br> &nbsp; &nbsp; //按F3键<br> &nbsp; &nbsp; Label1.Caption :='F3运行中';<br> &nbsp; &nbsp; end;<br><br>end;<br><br>procedure KeyF2;<br>begin<br> &nbsp; keybd_event(VK_F2,mapvirtualkey(VK_F2,0),0,0);<br> &nbsp; keybd_event(VK_F2,mapvirtualkey(VK_F2,0),keyeventf_keyup,0);//按F2键<br>end;<br>procedure KeyF3;<br>begin<br> &nbsp; keybd_event(VK_F3,mapvirtualkey(VK_F3,0),0,0);<br> &nbsp; keybd_event(VK_F3,mapvirtualkey(VK_F3,0),keyeventf_keyup,0);//按F3键<br>end;<br>procedure KeyF4;<br>begin<br> &nbsp; keybd_event(VK_F4,mapvirtualkey(VK_F4,0),0,0);<br> &nbsp; keybd_event(VK_F4,mapvirtualkey(VK_F4,0),keyeventf_keyup,0);//按F4键<br>end;<br>procedure TMainForm.Button2Click(Sender: TObject);<br>begin<br> &nbsp;if h &lt;&gt; 0 then<br> &nbsp; begin<br> &nbsp; &nbsp;MessageBeep(0);<br> &nbsp; &nbsp;CloseHandle(h);<br> &nbsp; end;<br> &nbsp; close;<br>end;<br>end.<br><br>没有进游戏时,Label没有反应,<br>进入游戏了,按下按钮,当血量少于设定值时Label改变,说明Timer在运行,<br>可是游戏里不会自动加血,于是我改变了一下按键,把F3改成了F4,<br>游戏里还是没有反应,但我切到外挂窗口,按一下Alt键,外挂窗口关闭,<br>由此证明模拟键盘F4键一直进行中<br>后来我又换了一个模拟键盘的方法,<br>改变如下:<br>procedure KeyF3;<br>begin<br> &nbsp; PostMessage(Application.Handle, WM_KEYDOWN, VK_F4, 0);<br> &nbsp; PostMessage(Application.Handle, WM_KEYUP, VK_F4, 0);<br>end;<br>和<br>procedure KeyF3;<br>begin<br> &nbsp; PostMessage(h, WM_KEYDOWN, VK_F4, 0);<br> &nbsp; PostMessage(h, WM_KEYUP, VK_F4, 0);<br>end;<br>在游戏里还是没有反应,并且外挂窗口也没有反应了,但是Label标签改变<br>由是我再改成<br>procedure KeyF3;<br>begin<br> &nbsp; PostMessage(h, WM_KEYDOWN, VK_F4, 0);<br> &nbsp; PostMessage(h, WM_KEYUP, VK_F4, 0);<br> &nbsp; setcursorpos(500,400);<br> &nbsp; mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);<br> &nbsp; mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);<br>end;<br>这时鼠标在游戏里点击正常,键盘没有反应<br><br>在此麻烦大侠帮下忙,找下问题所在,<br>或再给几个模拟键盘的方法<br>非常感谢!!!!!
 
呵呵,不好意思,我弄错了,没看清问题,不好意思,<br>刚刚才看到,你说不能用<br>前提是不可以用ReadProcessMemory 和WriteProcessMemory
 
后退
顶部