制作自己的修改器.

 1  Option   Explicit  
 2  Private  Declare  Function  FindWindow Lib  " user32 "  Alias  " FindWindowA "  (ByVal lpClassName  As   String , ByVal lpWindowName  As   String As   Long  
 3  Private  Declare  Function  GetWindowThreadProcessId Lib  " user32 "  (ByVal hWnd  As   Long , lpdwProcessId  As   Long As   Long  
 4  Private  Declare  Function  OpenProcess Lib  " kernel32 "  (ByVal dwDesiredAccess  As   Long , ByVal bInheritHandle  As   Long , ByVal dwProcessId  As   Long As   Long  
 5  Private  Declare  Function  WriteProcessMemory Lib  " kernel32 "  (ByVal hProcess  As   Long , ByVal lpBaseAddress  As  Any, lpBuffer  As  Any, ByVal nSize  As   Long , lpNumberOfBytesWritten  As   Long As   Long  
 6  Private  Declare  Function  ReadProcessMemory Lib  " kernel32 "  (ByVal hProcess  As   Long , ByVal lpBaseAddress  As  Any, lpBuffer  As  Any, ByVal nSize  As   Long , lpNumberOfBytesWritten  As   Long As   Long  
 7  Private  Declare  Function  CloseHandle Lib  " kernel32 "  (ByVal hObject  As   Long As   Long  
 8  Private   Const  PROCESS_ALL_ACCESS  =   & H1F0FFF 
 9  Private  hProcess  As   Long  
10  ' 下面的函数用于查找游戏 
11  Function  FindGame()  As   Boolean  
12  Dim  PID  As   Long , Gamehwnd  As   Long  
13  FindGame  =   False  
14  Gamehwnd  =  FindWindow(vbNullString,  " 蜘蛛 " ' 查找游戏的句柄 
15  If  (Gamehwnd  =   0 Then   ' 如果找不到(例如游戏未运行)就退出函数 
16  MsgBox   " 没有找到蜘蛛游戏 "  
17  Exit   Function  
18  End   If  
19  GetWindowThreadProcessId Gamehwnd, PID  ' 取得进程ID 
20  hProcess  =  OpenProcess(PROCESS_ALL_ACCESS,  False , PID)  ' 以全部权力打开进程 
21  If  (hProcess  =   0 Then   ' 打开进程失败 
22  MsgBox   " 没有打开进程 "  
23  Exit   Function  
24  End   If  
25  FindGame  =   True   ' 成功!! 
26  End Function  
27  ' 回到VB的窗口设计模式,在窗体上放上两个按钮和一个文本框 
28  ' 一个按钮为"读取"一个为"写入",分别用于读取和写入数据 
29  ' 把Text1的Text设为空白 
30  Private   Sub  Command1_Click() 
31  Dim  retV%, r &  
32  ' Dim retV%, r&=Dim retV As Integer, r As Long 
33  If  FindGame  Then  
34  =  ReadProcessMemory(hProcess,  & H1011F20, retV,  2 0 ' 这里重要,&H1011F20为内存地址. 
35  If  r  =   0   Then  
36  MsgBox   " 读取内存不成功! "  
37  Else  
38  Text1  =  retV 
39  End   If  
40  End   If  
41  End Sub  
42 
43  Private   Sub  Command2_Click() 
44  Dim  r &  
45  If  FindGame  Then  
46  =  WriteProcessMemory(hProcess,  & H1011F20,  CInt (Val(Text1)),  2 0
47  ' 参数与上面的基本相同 
48  ' cInt(Val(Text1))是防止输入的过程有误,,例如,输入了字母,,如果不处理程序就会出错 
49  If  r  =   0   Then  
50  MsgBox   " 写内存不成功! "  
51  Else  
52  MsgBox   " OK "  
53  End   If  
54  End   If  
55  End Sub
56 

 

转载于:https://www.cnblogs.com/xxaxx/archive/2010/01/24/1655472.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值