rechercher un texte comme cheat engine

    Publicités

Users Who Are Viewing This Thread (Total: 0, Members: 0, Guests: 0)

debutent

Membre
Dec 30, 2015
10
0
21
39
bonsoir,
Je veux savoir comment rechercher un texte en unicode en vb.net?
j'ai recopier ce code dans ce lien : http://www.cheat-gam3.com/showthread.php?p=1471414
voici le code :
Code:
Imports System.Runtime.InteropServices
Public Class Form1
    Private Declare Function CloseHandle Lib "kernel32" (tHandle As IntPtr)
    Private Declare Function OpenProcess Lib "kernel32" (dwDesiredAccess As Integer, bInheritHandle As Boolean, dwProcessId As Integer) As IntPtr
    Private Declare Function ReadProcessMemory Lib "kernel32" Alias "ReadProcessMemory" (hProcess As IntPtr, lpBaseAddress As Integer, <Out()> lpBuffer As Byte(), nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Byte
    Private Const PROCESS_VM_READ = &H10

    Public Function ReadByte(hProcess As IntPtr, Address As Integer, Optional ByVal nsize As Integer = 4) As Byte()
        Dim vBuffer(nsize - 1) As Byte
        Dim lpNumberOfBytesWritten As Integer
        ReadProcessMemory(hProcess, Address, vBuffer, nsize, lpNumberOfBytesWritten)
        Return vBuffer
    End Function

    Public Function Compare(hProcess As IntPtr, Address As Long, Pattern As Byte(), Mask As String) As Boolean
        Dim pTemp As Byte
        For i = 0 To Mask.Length - 1 Step 1
            If Mask(i) = "x" Then
                Continue For
            End If
            pTemp = ReadByte(hProcess, (Address + i), 1)(0)
            If pTemp = Nothing Then
                Return False
            End If
            If pTemp <> Pattern(i) Then
                Return False
            End If
        Next
        Return True
    End Function

    Public Function FindPattern(AProcess As String, Pattern As Byte(), Mask As String) As Long
        Dim proc = Process.GetProcessesByName(AProcess).FirstOrDefault()
        If proc Is Nothing Then
            Return -1
        End If
        Dim hProc = OpenProcess(PROCESS_VM_READ, False, proc.Id)
        If hProc = IntPtr.Zero Then
            Return -1
        End If
        Try
            For dwCurrentAddress As Long = &H3000000 To &H7FFFFFFFF Step 1
                If Compare(hProc, dwCurrentAddress, Pattern, Mask) Then
                    Return dwCurrentAddress
                End If
            Next
            Return -1
        Finally
            CloseHandle(hProc)
        End Try
    End Function

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim Pattern As Byte() = Array.ConvertAll("vaultLevel91".ToCharArray(), Function(c) CType(Asc(c), Byte))
        Dim MonAddress As Long = FindPattern("Template.exe", Pattern, "xxxxxxxxxxxx")
        If MonAddress Then
            TextBox1.Text = "0X" & MonAddress.ToString("X8")
        Else
            MessageBox.Show("No Found!")
        End If
    End Sub
avez-vous une autre solution pour rechercher offset de "vaultLevel91"?
voici en image en dessous.
Merci d'avance de votre réponse,
 

Attachments

  • cheat.jpg
    cheat.jpg
    88.3 KB · Views: 9

debutent

Membre
Dec 30, 2015
10
0
21
39
voici mon code pour rechercher le texte par rapport a l'adresse :
Public Class Form1
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Int32, ByVal bInheritHandle As Int32, ByVal dwProcessId As Int32) As Int32
Private Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Int32, ByVal lpBaseAddress As Int32, ByRef lpBuffer As Int32, ByVal nSize As Int32, ByRef lpNumberOfBytesWritten As Int32) As Int32
Private Declare Function ReadProcessMemory Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Int32, ByVal lpBaseAddress As Int32, ByRef lpBuffer As Int32, ByVal nSize As Int32, ByRef lpNumberOfBytesWritten As Int32) As Int32
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Int32) As Int32
Public Const PROCESS_VM_READ = &H10
Public Const PROCESS_VM_WRITE = (&H20)
Public Const PROCESS_VM_OPERATION = (&H8)
Public Const PROCESS_QUERY_INFORMATION = (&H400)
Public Const PROCESS_READ_WRITE_QUERY = PROCESS_VM_READ + PROCESS_VM_WRITE + PROCESS_VM_OPERATION + PROCESS_QUERY_INFORMATION
Public Const PROCESS_ALL_ACCESS = &H1F0FFF
Public Function Tibia_Hwnd() As Long
Dim TibiaWindows As Process() = Process.GetProcessesByName("Template")
If TibiaWindows.Length = 0 Then
Return 0
Exit Function
End If
Return TibiaWindows(0).Id
End Function

Private Function Memory_ReadLong(ByVal Address As Int32) As Long
Dim vBuffer As Long
Dim processHandle As IntPtr = OpenProcess(PROCESS_VM_READ, 0, Tibia_Hwnd)
ReadProcessMemory(processHandle, Address, vBuffer, 4, 0)
Return vBuffer
CloseHandle(processHandle)
End Function

Private Function Memory_WriteLong(ByVal Address As Int32, ByVal vBuffer As Long) As Long
Dim processHandle As IntPtr = OpenProcess(PROCESS_READ_WRITE_QUERY, 0, Tibia_Hwnd)
WriteProcessMemory(processHandle, Address, vBuffer, 4, 0)
Return vBuffer
CloseHandle(processHandle)
End Function

Public Function Memory_ReadString(ByVal Address As Long, ByVal CharCount As Int32) As String
Dim ret As Byte() = Nothing
Dim vBuffer As Long

Dim processHandle As IntPtr = OpenProcess(PROCESS_VM_READ, 0, Tibia_Hwnd)
Dim tStr(CharCount) As Char
Dim retStr As String = ""
For i As Int32 = 0 To CharCount Step 2
ReadProcessMemory(processHandle, Address + i, vBuffer, 1, 0)
ret = BitConverter.GetBytes(vBuffer)
tStr(i) = System.Text.Encoding.Unicode.GetString(ret) : retStr += tStr(i)

Next i
Return retStr
CloseHandle(processHandle)
End Function

Public Function WriteString(ByVal address As Long, ByVal str As String) As Boolean
Dim processHandle As IntPtr = OpenProcess(PROCESS_READ_WRITE_QUERY, 0, Tibia_Hwnd)
For i As Integer = 0 To Len(str) - 1
WriteProcessMemory(processHandle, address + i, Asc(Mid(str, i + 1, 1)), 1, 0)
Next i
Return 0
End Function

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
TextBox1.Text = Memory_ReadString(&H34B94F4, 23).ToString
End Sub
End Class

je voudrais savoir comment rechercher l'adresse par rapport avec ce mot ("exemple : vaultLevel91") car l'adresse change au redémarre le jeu.
avez-vous une solution a mon problème?
Merci d'avance