回 帖 发 新 帖 刷新版面

主题:关于游戏修改器的问题

看了一片关于制作游戏修改器的文章,自己照猫画虎用vb写了一个游戏修改器,可是老出现变量没有找到的错误(错误老是指着OpenProcess函数中的PROCESS_ALL_ACCESS参数),即使生成exe文件以后,修改游戏时老时出现“没有打开修改权限”.请求大虾帮忙看一下,找出其中的错误.以下是代码.

 

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Public Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long

Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long

Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Public 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
以上代码是写在模块中的

Option Explicit

Private Sub cmd2_Click()

  
   Dim hOK As Long

   Dim ID As Long

   Dim hwnd As Long
  
    hwnd = FindWindow("SWDMD", vbNullString)
        If hwnd = False Then
             MsgBox ("游戏没有打开")
            
             Exit Sub
        Else
           
            GetWindowThreadProcessId hwnd, ID
           
            hOK = OpenProcess(PROCESS_ALL_ACCESS, False, ID)
                 
                  If hOK = 0 Then
                           MsgBox ("没有打开修改权限")
                            Exit Sub
                  Else
                   Dim a2 As Long  '金钱的内存地址变量

                   Dim b2 As Long   '生命的内存地址变量

                   Dim c2 As Long   '灵力的内存地址变量

                  Dim d2 As Long  '体力的内存地址变量
                  Dim a3 As Long   '金钱
                  Dim b3 As Long   '生命
                  Dim c3 As Long   '灵力
                  Dim d3 As Long
                        a3 = Val(txt1.Text)
                        b3 = Val(txt2.Text)
                        c3 = Val(txt3.Text)
                        d3 = Val(txt4.Text)
                        b2 = &HBCDFF0
                        a2 = &HBCEC84
                        c2 = &HBCDFFC
                        d2 = &HBCE000
                       
                        If txt1.Text <> "" Then
                                
                          WriteProcessMemory hOK, ByVal a2, a3, 2, 0
                         

                        End If   '修改金钱属性
                       
                        If txt2.Text <> "" Then
                          WriteProcessMemory hOK, ByVal b2, b3, 2, 0
                        End If   '修改生命属性
                       
                        If txt3.Text <> "" Then
                          WriteProcessMemory hOK, ByVal c2, c3, 2, 0
                        End If   '修改灵力属性
                        If txt4.Text <> "" Then
                          WriteProcessMemory hOK, ByVal d2, d3, 2, 0
                        End If '修改体力属性
                       
                        MsgBox ("complete")
                     
                  End If
         End If
        
        CloseHandle (hOK)
       
  End Sub

 

 

 

 

 

 


 

回复列表 (共9个回复)

沙发

怎么感觉不是代码的问题,是被修改软件和系统的问题

板凳

可以尝试编译成P-Code,而且编译后执行,不要在VB的IDE调试环境下执行。

3 楼

用了上面的方法啦!不管用.是不是directx的问题,还是别的问题?

 

4 楼

或者,试试提权函数。http://zhidao.baidu.com/link?url=KzeFo-3tJyddocGPMRhzQAQKVAOogf_dINafFNgEt2OTYBdu1miOX3ClCJgcq-GQ-tabVxQj-sdnQy4KPiNWwK

5 楼

还是不行,请问高手还有没有别的方法了。

6 楼

没做过修改内存的工具。我做一个文件索引的工具的时候用过提权函数,效果明确。

7 楼

谢谢孙大侠的指点,我在仔细琢磨琢磨.

8 楼

有新进展就随时发上来。

9 楼

老子也知不道

我来回复

您尚未登录,请登录后再回复。点此登录或注册