Einzelnen Beitrag anzeigen

The-Fox

Registriert seit: 11. Dez 2004
15 Beiträge
 
Delphi 6 Personal
 
#1

VB Code erklärung

  Alt 9. Jan 2005, 20:07
Hallöchen!

und ich versuche immer immer noch meinen The Sims Trainer zu schreiben

Mein Problem usw ist in diesem Thread nachzulesen: http://www.delphipraxis.net/internal...=298972#298972

Soo, jetzt bin ich endlich auf die Idee zu kommen, einfach mal einen der sowas schon gemacht hat zu fragen. Bin also auf www.cheats.de geladen, habe mir einen der 100000 Trainer die es für Die Sims gibt runtergeladen, der diesen "Hack" besitzt, und habe den Author um den Code gebeten. Der hat ihn mir auch geschickt. Leider in VB. Auf den ersten Blick scheint er nicht soviel anders zu machen, wie ich mit der normalen Standart WriteProcessmemory Procedure. Allerdings habe ich irgendwie den komplett falschen Ansatz benutzt. Es werden schließlich doch konstante Adressen verwendet. Hier ist der Source.

Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) 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, ByVal lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByVal lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Public Function ConvertNumberToString(Number As Double) As String
Dim b1, b2, b3, b4 
If Number < 256 Then ConvertNumberToString = Chr(Number): Exit Function
If Number < 65536 Then
ConvertNumberToString = Chr(Number And 255) & Chr((Number And 65280) / 256)
Exit Function
End If
b4 = Number And 255: Number = Int(Number / 256)
b3 = Number And 255: Number = Int(Number / 256)
b2 = Number And 255: Number = Int(Number / 256)
b1 = Number And 255: Number = Int(Number / 256)
ConvertNumberToString = Chr(b4) & Chr(b3) & Chr(b2) & Chr(b1)
End Function

Private Sub cmd01_Click()
Dim hwnd As Long, ProcessID As Long, pHandle As Long
hwnd = FindWindow(vbNullString, "SIMS")
If hwnd = 0 Then
lbl01.Caption = "TS not found"
Exit Sub
End If
GetWindowThreadProcessId hwnd, ProcessID
pHandle = OpenProcess(&H1F0FFF, False, ProcessID)
If pHandle = 0 Then
lbl01.Caption = "No process handle found!"
Exit Sub
End If

WriteProcessMemory Handle, &H6F406FCA, ConvertNumberToString(&H33), 1, 0&
WriteProcessMemory Handle, &H6F406FC9, ConvertNumberToString(&H41), 1, 0&
WriteProcessMemory Handle, &H6F406FCE, ConvertNumberToString(&H46), 1, 0&
WriteProcessMemory Handle, &H6F406FCF, ConvertNumberToString(&H33), 1, 0&
WriteProcessMemory Handle, &H6F406FD0, ConvertNumberToString(&HF6), 1, 0&
WriteProcessMemory Handle, &H6F406FCB, ConvertNumberToString(&HC9), 1, 0&
WriteProcessMemory Handle, &H6F2A22A3, ConvertNumberToString(&H40), 1, 0&
WriteProcessMemory Handle, &H6F148E58, ConvertNumberToString(&HEB), 1, 0&
WriteProcessMemory Handle, &H6F2A22A4, ConvertNumberToString(&H33), 1, 0&
WriteProcessMemory Handle, &H6F149D3C, ConvertNumberToString(&HEB), 1, 0&
WriteProcessMemory Handle, &H6F2A22A3, ConvertNumberToString(&H40), 1, 0&
WriteProcessMemory Handle, &H6F2A22A5, ConvertNumberToString(&HC0), 1, 0&
WriteProcessMemory Handle, &H6F2A22A6, ConvertNumberToString(&H42), 1, 0&
WriteProcessMemory Handle, &H6F2A22A7, ConvertNumberToString(&H33), 1, 0&
WriteProcessMemory Handle, &H6F2A22A8, ConvertNumberToString(&HD2), 1, 0&
WriteProcessMemory Handle, &H6F148E58, ConvertNumberToString(&HEB), 1, 0&

Close Handle, pHandle
lbl01.Caption = "Go get her ;-)"
End Sub

Private Sub cmd02_Click()
Dim hwnd As Long, ProcessID As Long, pHandle As Long
hwnd = FindWindow(vbNullString, "SIMS")
If hwnd = 0 Then
lbl01.Caption = "TS not found"
Exit Sub
End If
GetWindowThreadProcessId hwnd, ProcessID
pHandle = OpenProcess(&H1F0FFF, False, ProcessID)
If pHandle = 0 Then
lbl01.Caption = "No process handle found!"
Exit Sub
End If

WriteProcessMemory Handle, &H6F2A22A3, ConvertNumberToString(&H42), 1, 0&
WriteProcessMemory Handle, &H6F406FCE, ConvertNumberToString(&H70), 1, 0&
WriteProcessMemory Handle, &H6F2A22A6, ConvertNumberToString(&H52), 1, 0&
WriteProcessMemory Handle, &H6F148E58, ConvertNumberToString(&H75), 1, 0&
WriteProcessMemory Handle, &H6F406FC9, ConvertNumberToString(&H48), 1, 0&
WriteProcessMemory Handle, &H6F149D3C, ConvertNumberToString(&H75), 1, 0&

CloseHandle pHandle
lbl01.Caption = "Hm, she's hating you again (deactivated)"
End Sub
Also. Was ist nicht verstehe: Warum setzt er ein & vor die Adressen, und nicht ein $ ? Sind das überhaupt Adressen? Die "Adressen" existieren in jedemfall schonmal nicht (wenn ich mit TSearch danach suche, sagt er die Adresse sei nicht vergeben oder so ähnlich). Also was sind die konstanten Werte? Pointer? Und was macht er mit der "ConvertNumberToString" Funktion?

ICh bin über absolut jede Hilfe dankbar, die mir dabei hilft das in Delphi zu übersetzten.
Danke!
  Mit Zitat antworten Zitat