2012年11月10日 星期六

[VB .NET] 楓之谷 外掛 筆記

偵測遊戲是否開啟:

Dim found_process = 0

        For Each app In Process.GetProcesses
            If app.ProcessName = "MapleStory" Then
                hprocess = Process.GetProcessesByName("MapleStory")(0)
                found_process = 1
            End If
        Next

        If found_process Then
            lbl_found.Text = "偵測成功"
        Else
            lbl_found.Text = "偵測失敗"
        End If 


寫入記憶體:

調用API:
Public Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByVal lpBuffer As Byte(), ByVal nSize As System.UInt32, ByRef lpNumberOfBytesWritten As Int32) As Boolean

舉例:
Dim bless_enable As Byte() = {&H1C, &HAB, &HC1, &H6C, &H58, &HD, &H66, &H9B, &H30, &H70, &H19, &H2A, &H69, &H1B, &H8D, &H87, &H39, &H70, &H3D, &H2C, &H94, &H77, &H26, &H4E, &HDD, &HAC, &HD, &H1, &H8C, &H6B, &H9, &H68, &H72, &H6E, &HE6, &HED}
        Dim bless_disable As Byte() = {&H61, &HA1, &H4C, &HCC, &HB, &H65, &H62, &HE, &H96, &H6F, &H19, &H72, &HB3, &HF0, &HD0, &H62, &H85, &H87, &H16, &H9B, &H8A, &H6F, &HDA, &H91}

        If checkbox_bless.Checked = True Then
            WriteProcessMemory(hprocess.Handle, &HE2E364, bless_enable, bless_enable.Length, 0&)
        Else
            WriteProcessMemory(hprocess.Handle, &HE2E364, bless_disable, bless_disable.Length, 0&)
        End If