查看: 363  |  回复: 0
VB6 发一个游戏外挂的代码 API OpenProcess
楼主
发表于 2023年5月14日 17:41

找到个代码,没目标研究,好像挺简单的,可以看下调用的参数,代码:

Dim ecxi As Long, eax As Long
Private Sub Check1_Click()
    If Check1.Value = 1 Then
        GameFormHwnd = FindWindow("ManognkuClient Window", "Manognku Client")
        If GameFormHwnd = 0 Then
            Started = False
            Check1.Value = 0
            Timer2.Enabled = False
            Timer3.Enabled = False
            MsgBox "请确认是否已打开游戏!"
        Else
            hptime = 0
            mptime = 0
            hpused = 0
            mpused = 0
            Started = True
            GetWindowThreadProcessId GameFormHwnd, hProcId
            Timer2.Enabled = True
            Timer3.Enabled = True
        End If
    Else
        Started = False
        Timer2.Enabled = False
        Timer3.Enabled = False
    End If
End Sub

Private Sub ChkTop_Click()
    Dim b As Boolean
    b = ChkTop.Value
    SetFormOnTop Form1, b
End Sub

Private Sub Form_Load()
    App.TaskVisible = False
    Readini
    m_hDllKbdHook = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf LowLevelKeyboardProc, App.hInstance, 0)
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii < Asc(0) Or KeyAscii > Asc(9) Then
        KeyAscii = 0
        'MsgBox "请输入数字"
    End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Writeini
    If m_hDllKbdHook <> 0 Then
        Call UnhookWindowsHookEx(m_hDllKbdHook)
    End If
End Sub

Private Sub TxtHP_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    TxtHP.SelStart = 0
    TxtHP.SelLength = Len(TxtHP.Text)
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)
    If KeyAscii < Asc(0) Or KeyAscii > Asc(9) Then
        KeyAscii = 0
        'MsgBox "请输入数字"
    End If
End Sub

Private Sub TxtMP_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    TxtMP.SelStart = 0
    TxtMP.SelLength = Len(TxtMP.Text)
End Sub

Private Sub Timer2_Timer()
    ProcessID = OpenProcess(PROCESS_ALL_ACCESS Or PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE, False, hProcId)

    ReadProcessMemory ProcessID, ByVal &H13F830, ecxi, 4, 0
    ReadProcessMemory ProcessID, ByVal ecxi + &H20, eax, 4, 0
    ReadProcessMemory ProcessID, ByVal eax + &H450, HP, 4, 0
    ReadProcessMemory ProcessID, ByVal eax + &H454, MP, 4, 0
    ReadProcessMemory ProcessID, ByVal eax + &H478, MAXHP, 4, 0
    ReadProcessMemory ProcessID, ByVal eax + &H47C, MAXMP, 4, 0
    LbHP.Caption = "HP: " & CStr(HP) & " / " & CStr(MAXHP)
    LbMP.Caption = "MP: " & CStr(MP) & " / " & CStr(MAXMP)

    CloseHandle ProcessID
End Sub

Private Sub Timer3_Timer()
    Toph = GetForegroundWindow
    If Toph <> GameFormHwnd Then Exit Sub
    If ChkHP.Value = 1 And HP < CLng(TxtHP.Text) Then
        hptime = hptime + 1
        If hpused = 0 Then
            SendAKey VK_F7
            hpused = 1
        End If
        If hptime > 6 Then
            hptime = 0
            hpused = 0
        End If
    End If
    If ChkMP.Value = 1 And MP < CLng(TxtMP.Text) Then

        mptime = mptime + 1
        If mpused = 0 Then
            SendAKey VK_F8
            mpused = 1
        End If

        If mptime > 6 Then
            mptime = 0
            mpused = 0
        End If
    End If
    If ChkAutoHit.Value = 1 Then SendAKey VK_F1
    If ChkQL.Value = 1 Then SendAKey VK_F6
End Sub

Private Sub Readini()
    Dim sp As String
    sp = App.Path & "/settings.ini"
    Dim mh As String, mm As String
    Dim ml As String, mt As String
    mh = Space$(100): mm = Space$(100)
    ml = Space$(100): mt = Space$(100)
    GetPrivateProfileString& "Info", "HP", "100", mh, 100, sp
    GetPrivateProfileString& "Info", "MP", "100", mm, 100, sp
    TxtHP.Text = Trim(mh)
    TxtMP.Text = Trim(mm)
    GetPrivateProfileString& "Form", "Left", "-1", ml, 100, sp
    GetPrivateProfileString& "Form", "Top", "-1", mt, 100, sp
    If CLng(Trim(ml)) > 0 Then Form1.left = CLng(Trim(ml))
    If CLng(Trim(mt)) > 0 Then Form1.Top = CLng(Trim(mt))
End Sub

Private Sub Writeini()
    Dim sp As String
    sp = App.Path & "/settings.ini"
    WritePrivateProfileString& "Info", "HP", TxtHP.Text, sp
    WritePrivateProfileString& "Info", "MP", TxtMP.Text, sp
    If Form1.WindowState = 0 Then
        WritePrivateProfileString& "Form", "Left", Form1.left, sp
        WritePrivateProfileString& "Form", "Top", Form1.Top, sp
    End If
End Sub

关键在于 OpenProcess 这个API。

您需要登录后才可以回帖 登录 | 立即注册
【本版规则】请勿发表违反国家法律的内容,否则会被冻结账号和删贴。
用户名: 立即注册
密码:
2020-2024 MaNongKu.com