0/5 (6 avis)
Snippet vu 4 082 fois - Téléchargée 34 fois
'Mettez tout dans votre Form '---------------- Déclaration des divers fonction necessaire pour lire la mémoire-------------- Private Const PROCESS_ALL_ACCESS = &H1F0FFF Private Declare Function Sleep Lib "kernel32" (ByVal DureeMS As Long) Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long 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 Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal Classname As String, ByVal WindowName As String) As Long Private Declare Function ReadProcessMem Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByRef lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long Private Function WriteAByte(gamewindowtext As String, address As Long, value As Byte) Dim hwnd As Long Dim pid As Long Dim phandle As Long hwnd = FindWindow(vbNullString, gamewindowtext) If (hwnd = 0) Then Exit Function End If GetWindowThreadProcessId hwnd, pid phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid) If (phandle = 0) Then Exit Function End If WriteProcessMemory phandle, address, value, 1, 0& CloseHandle hProcess End Function Private Function WriteAnInt(gamewindowtext As String, address As Long, value As Integer) Dim hwnd As Long Dim pid As Long Dim phandle As Long hwnd = FindWindow(vbNullString, gamewindowtext) If (hwnd = 0) Then Exit Function End If GetWindowThreadProcessId hwnd, pid phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid) If (phandle = 0) Then Exit Function End If WriteProcessMemory phandle, address, value, 2, 0& CloseHandle hProcess End Function Private Function WriteALong(gamewindowtext As String, address As Long, value As Long) Dim hwnd As Long Dim pid As Long Dim phandle As Long hwnd = FindWindow(vbNullString, gamewindowtext) If (hwnd = 0) Then Exit Function End If GetWindowThreadProcessId hwnd, pid phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid) If (phandle = 0) Then Exit Function End If WriteProcessMemory phandle, address, value, 4, 0& CloseHandle hProcess End Function Private Function ReadAByte(gamewindowtext As String, address As Long, valbuffer As Byte) Dim hwnd As Long Dim pid As Long Dim phandle As Long hwnd = FindWindow(vbNullString, gamewindowtext) If (hwnd = 0) Then Exit Function End If GetWindowThreadProcessId hwnd, pid phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid) If (phandle = 0) Then Exit Function End If ReadProcessMem phandle, address, valbuffer, 1, 0& CloseHandle hProcess End Function Private Function ReadAnInt(gamewindowtext As String, address As Long, valbuffer As Integer) Dim hwnd As Long Dim pid As Long Dim phandle As Long hwnd = FindWindow(vbNullString, gamewindowtext) If (hwnd = 0) Then Exit Function End If GetWindowThreadProcessId hwnd, pid phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid) If (phandle = 0) Then Exit Function End If ReadProcessMem phandle, address, valbuffer, 2, 0& CloseHandle hProcess End Function Private Function ReadAShort(gamewindowtext As String, address As Long, valbuffer As Integer) Dim hwnd As Long Dim pid As Long Dim phandle As Long hwnd = FindWindow(vbNullString, gamewindowtext) If (hwnd = 0) Then Exit Function End If GetWindowThreadProcessId hwnd, pid phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid) If (phandle = 0) Then Exit Function End If ReadProcessMem phandle, address, valbuffer, 2, 0& CloseHandle hProcess End Function Private Function ReadALong(gamewindowtext As String, address As Long, valbuffer As Long) Dim hwnd As Long Dim pid As Long Dim phandle As Long hwnd = FindWindow(vbNullString, gamewindowtext) If (hwnd = 0) Then Exit Function End If GetWindowThreadProcessId hwnd, pid phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid) If (phandle = 0) Then Exit Function End If ReadProcessMem phandle, address, valbuffer, 4, 0& CloseHandle hProcess End Function 'Là on va commencer à s'attaquer à lire la mémoire et à changer l'offset à chaque fois '(attention si jamais votre plage de scan est trop grande vous allez ramer...) Private Sub Command1_Click() Dim valeurhex1, valeurhex2, valeurhex3, valeurhex4, valeurhex5, valeurhex6, valeurhex7, value, offsettemp As Variant offsettemp = "00000021" 'Offset de départ, vous pouvez le changer à votre guise While offsettemp <> "000FFFFF" 'On arrête de scanner à cet offset Call ReadAnInt("NomDeL'application", offsettemp, value) Sleep 1& 'permet de libérer offsettemp, sinon il ne peut pas actualiser la valeur étant 'donné qu'il est en cours d'utilisation. 'Notez bien que j'ai rajouté Private Declare Function Sleep Lib "kernel32" (ByVal DureeMS 'As Long) dans les déclarations 'Remplacez NomDeL'application par le nom de votre application (logique), laissez 'Laissez offsettemp, value comme ils sont. Offsettemp est l'offset (qui augmente à chaque 'fois grace au code çi-dessous) et value est la valeur de l'offset actuel. Open App.Path & "resultat.txt" For Append As #1 Print #1, offsettemp & " : " & value Close #1 valeurhex1 = Mid$(offsettemp, 8, 1) 'Récupère la dernier chiffre de offsettemp (1) valeurhex2 = Mid$(offsettemp, 7, 1) 'Récupère la dernier chiffre de offsettemp (2) valeurhex3 = Mid$(offsettemp, 6, 1) 'Récupère la dernier chiffre de offsettemp (0) valeurhex4 = Mid$(offsettemp, 5, 1) '... valeurhex5 = Mid$(offsettemp, 4, 1) valeurhex6 = Mid$(offsettemp, 3, 1) valeurhex7 = Mid$(offsettemp, 2, 1) 'On commence à changer d'offsets, ici c'est le dernier chiffre (1 au départ) If valeurhex1 = "F" Then valeurhex1 = "G" If valeurhex1 = "E" Then valeurhex1 = "F" If valeurhex1 = "D" Then valeurhex1 = "E" If valeurhex1 = "C" Then valeurhex1 = "D" If valeurhex1 = "B" Then valeurhex1 = "C" If valeurhex1 = "A" Then valeurhex1 = "B" If valeurhex1 = "9" Then valeurhex1 = "A" If IsNumeric(valeurhex1) Then valeurhex1 = valeurhex1 + 1 If valeurhex1 = "G" Then valeurhex1 = 0 'Avant dernier chiffre (2 au départ) If valeurhex2 = "F" Then valeurhex2 = "G" If valeurhex2 = "E" Then valeurhex2 = "F" If valeurhex2 = "D" Then valeurhex2 = "E" If valeurhex2 = "C" Then valeurhex2 = "D" If valeurhex2 = "B" Then valeurhex2 = "C" If valeurhex2 = "A" Then valeurhex2 = "B" If valeurhex2 = "9" Then valeurhex2 = "A" If IsNumeric(valeurhex2) Then valeurhex2 = valeurhex2 + 1 If valeurhex2 = "G" Then valeurhex2 = 0 'Ainsi de suite ... If valeurhex3 = "F" Then valeurhex3 = "G" If valeurhex3 = "E" Then valeurhex3 = "F" If valeurhex3 = "D" Then valeurhex3 = "E" If valeurhex3 = "C" Then valeurhex3 = "D" If valeurhex3 = "B" Then valeurhex3 = "C" If valeurhex3 = "A" Then valeurhex3 = "B" If valeurhex3 = "9" Then valeurhex3 = "A" If IsNumeric(valeurhex3) Then valeurhex3 = valeurhex3 + 1 If valeurhex3 = "G" Then valeurhex3 = 0 If valeurhex4 = "F" Then valeurhex4 = "G" If valeurhex4 = "E" Then valeurhex4 = "F" If valeurhex4 = "D" Then valeurhex4 = "E" If valeurhex4 = "C" Then valeurhex4 = "D" If valeurhex4 = "B" Then valeurhex4 = "C" If valeurhex4 = "A" Then valeurhex4 = "B" If valeurhex4 = "9" Then valeurhex4 = "A" If IsNumeric(valeurhex4) Then valeurhex4 = valeurhex4 + 1 If valeurhex4 = "G" Then valeurhex4 = 0 If valeurhex5 = "F" Then valeurhex5 = "G" If valeurhex5 = "E" Then valeurhex5 = "F" If valeurhex5 = "D" Then valeurhex5 = "E" If valeurhex5 = "C" Then valeurhex5 = "D" If valeurhex5 = "B" Then valeurhex5 = "C" If valeurhex5 = "A" Then valeurhex5 = "B" If valeurhex5 = 9 Then valeurhex5 = "A" If IsNumeric(valeurhex5) Then valeurhex5 = valeurhex5 + 1 If valeurhex5 = "G" Then valeurhex5 = 0 MsgBox "blabl" Exit Sub If valeurhex6 = "F" Then valeurhex6 = "G" If valeurhex6 = "E" Then valeurhex6 = "F" If valeurhex6 = "D" Then valeurhex6 = "E" If valeurhex6 = "C" Then valeurhex6 = "D" If valeurhex6 = "B" Then valeurhex6 = "C" If valeurhex6 = "A" Then valeurhex6 = "B" If valeurhex6 = 9 Then valeurhex6 = "A" If IsNumeric(valeurhex6) Then valeurhex6 = valeurhex6 + 1 If valeurhex6 = "G" Then valeurhex6 = 0 If valeurhex7 = "F" Then valeurhex7 = "G" If valeurhex7 = "E" Then valeurhex7 = "F" If valeurhex7 = "D" Then valeurhex7 = "E" If valeurhex7 = "C" Then valeurhex7 = "D" If valeurhex7 = "B" Then valeurhex7 = "C" If valeurhex7 = "A" Then valeurhex7 = "B" If valeurhex7 = 9 Then valeurhex7 = "A" If IsNumeric(valeurhex7) Then valeurhex7 = valeurhex7 + 1 If valeurhex7 = "G" Then valeurhex7 = 0 valeurhex6 = 0 valeurhex5 = 0 valeurhex4 = 0 valeurhex3 = 0 valeurhex2 = 0 valeurhex1 = 0 Exit Sub End If End If End If End If End If End If End If offsettemp = "1" & valeurhex7 & valeurhex6 & valeurhex5 & valeurhex4 & valeurhex3 & valeurhex2 & valeurhex1 Wend
4 sept. 2004 à 09:44
------ HEX -> DECIMAL
? clng("&HAA")
170
------ DECIMAL -> HEX
? hex(170)
AA
Tu gardes offset en tant que long ou double et tu l'incremente avec offset=offset+1 et tu convertit avec valeurhex=hex(offset) !
3 sept. 2004 à 18:14
3 sept. 2004 à 15:00
il ne doit même pas entrer dans ta boucle car le curseur est positionné d'office a la fin.... (EOF = True)
3 sept. 2004 à 14:50
Line Input #1, recup <
Print #1, recup <
C'est pour pas qu'il écrase à chaque fois les anciennes valeurs qu'il a écritent.
Si tu as d'autres suggestions pour optimiser le code, hésite pas, merci. :-)
3 sept. 2004 à 14:47
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.