Hallo! Ich versuche Daten aus dem Spiel Rfactor auszulesen mit Visual Basic 2008. Mit VB6 funktioniert das ganze auch schon aber 2008 wär mir lieber! Mit VB 2008 bekomme ich aber immer nur eine 0 als Variable zurück! Habt ihr vielleicht Codebeispiele um den Ram auszulesen ? danke, philip
Mit so wenig Infos bekommst du keine brauchbaren Antworten.
> Mit VB6 funktioniert das ganze auch schon...
Dann zeig deinen VB6 Code, dann hat man wenigstens was, worauf man
aufbauen und evtl. untersuchen kann, warum's in VS2008 nicht läuft...
Ralf
Modul1 hat folgenden Code:
1 | Public Const PROCESS_ALL_ACCESS = &H1F0FFF |
2 | Dim f1holder As Integer |
3 | Dim timer_pos As Long |
4 | |
5 | 'API Declaration |
6 | Public Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long |
7 | Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long |
8 | Public 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 |
9 | Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long |
10 | Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal Classname As String, ByVal WindowName As String) As Long |
11 | Public Declare Function GetKeyPress Lib "user32" Alias "GetAsyncKeyState" (ByVal key As Long) As Integer |
12 | Public 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 |
13 | |
14 | Public Function WriteAByte(gamewindowtext As String, address As Long, value As Byte) |
15 | Dim hwnd As Long |
16 | Dim pid As Long |
17 | Dim phandle As Long |
18 | hwnd = FindWindow(vbNullString, gamewindowtext) |
19 | If (hwnd = 0) Then |
20 | MsgBox "The Game Is Not Working", vbCritical, "Error" |
21 | End |
22 | Exit Function |
23 | End If |
24 | GetWindowThreadProcessId hwnd, pid |
25 | phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid) |
26 | If (phandle = 0) Then |
27 | MsgBox "Can't get ProcessId", vbCritical, "Error" |
28 | Exit Function |
29 | End If |
30 | WriteProcessMemory phandle, address, value, 1, 0& |
31 | CloseHandle hProcess |
32 | End Function |
33 | |
34 | Public Function WriteAnInt(gamewindowtext As String, address As Long, value As Integer) |
35 | Dim hwnd As Long |
36 | Dim pid As Long |
37 | Dim phandle As Long |
38 | hwnd = FindWindow(vbNullString, gamewindowtext) |
39 | If (hwnd = 0) Then |
40 | MsgBox "The Game Is Not Working", vbCritical, "Error" |
41 | End |
42 | End If |
43 | GetWindowThreadProcessId hwnd, pid |
44 | phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid) |
45 | If (phandle = 0) Then |
46 | MsgBox "Can't get ProcessId", vbCritical, "Error" |
47 | Exit Function |
48 | End If |
49 | WriteProcessMemory phandle, address, value, 2, 0& |
50 | CloseHandle hProcess |
51 | End Function |
52 | |
53 | Public Function WriteALong(gamewindowtext As String, address As Long, value As Long) |
54 | Dim hwnd As Long |
55 | Dim pid As Long |
56 | Dim phandle As Long |
57 | hwnd = FindWindow(vbNullString, gamewindowtext) |
58 | If (hwnd = 0) Then |
59 | MsgBox "The Game Is Not Working", vbCritical, "Error" |
60 | End |
61 | Exit Function |
62 | End If |
63 | GetWindowThreadProcessId hwnd, pid |
64 | phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid) |
65 | If (phandle = 0) Then |
66 | MsgBox "Can't get ProcessId", vbCritical, "Error" |
67 | Exit Function |
68 | End If |
69 | WriteProcessMemory phandle, address, value, 4, 0& |
70 | CloseHandle hProcess |
71 | End Function |
72 | |
73 | Public Function ReadAByte(gamewindowtext As String, address As Long, valbuffer As Byte) |
74 | Dim hwnd As Long |
75 | Dim pid As Long |
76 | Dim phandle As Long |
77 | hwnd = FindWindow(vbNullString, gamewindowtext) |
78 | If (hwnd = 0) Then |
79 | MsgBox "The Game Is Not Working", vbCritical, "Error" |
80 | End |
81 | Exit Function |
82 | End If |
83 | GetWindowThreadProcessId hwnd, pid |
84 | phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid) |
85 | If (phandle = 0) Then |
86 | MsgBox "Can't get ProcessId", vbCritical, "Error" |
87 | Exit Function |
88 | End If |
89 | ReadProcessMem phandle, address, valbuffer, 1, 0& |
90 | CloseHandle hProcess |
91 | End Function |
92 | |
93 | Public Function ReadAnInt(gamewindowtext As String, address As Long, valbuffer As Integer) |
94 | Dim hwnd As Long |
95 | Dim pid As Long |
96 | Dim phandle As Long |
97 | hwnd = FindWindow(vbNullString, gamewindowtext) |
98 | If (hwnd = 0) Then |
99 | MsgBox "The Game Is Not Working", vbCritical, "Error" |
100 | End |
101 | Exit Function |
102 | End If |
103 | GetWindowThreadProcessId hwnd, pid |
104 | phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid) |
105 | If (phandle = 0) Then |
106 | MsgBox "Can't get ProcessId", vbCritical, "Error" |
107 | Exit Function |
108 | End If |
109 | ReadProcessMem phandle, address, valbuffer, 2, 0& |
110 | CloseHandle hProcess |
111 | End Function |
112 | |
113 | Public Function ReadALong(gamewindowtext As String, address As Long, valbuffer As Long) |
114 | Dim hwnd As Long |
115 | Dim pid As Long |
116 | Dim phandle As Long |
117 | hwnd = FindWindow(vbNullString, gamewindowtext) |
118 | If (hwnd = 0) Then |
119 | MsgBox "The Game Is Not Working", vbCritical, "Error" |
120 | End |
121 | Exit Function |
122 | End If |
123 | GetWindowThreadProcessId hwnd, pid |
124 | phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid) |
125 | If (phandle = 0) Then |
126 | MsgBox "Can't get ProcessId", vbCritical, "Error" |
127 | Exit Function |
128 | End If |
129 | ReadProcessMem phandle, address, valbuffer, 4, 0& |
130 | CloseHandle hProcess |
131 | End Function |
und wenn ich einen Wert rausholen will öffne ich:
1 | Dim Gang as Long |
2 | Call ReadALong("rFactor v1.22", &HAdresse, Gang) |
wie gesagt, läuft in VB6 problemlos! Vielleicht hast du ja enien Lösungsansatz mit dem ich probieren kann. Der Code stammt von http://www.elitepvpers.de/forum/gamehacking-tutorials/642368-tutorial-trainer-visual-basic-6-a.html vielen Dank, philip
ich habe das Projekt jetzt von Visual Studio 2008 von VB6 auf VB2008 portieren lassen. Jetzt funktiniert auch das auslesen der Daten bis auf die Float Variablen. Ich definiere eine Variable
1 | Dim vSpeed as Single |
dann hole ich mir die Variable mit dem Aufruf
1 | Call ReadAFloat("rFactor v1.255", "&H" & AdressSpeed.Text, vSpeed) |
und dann weise ich die Variable einem Label zu
1 | lblSpeed.Text = int(vSpeed) |
nur am Label bekomme ich dann irgendwelche Werte angezeigt, die mit der Geschwindigkeit net viel zu tun haben. Die Adresse stimmt sicher, weil mit VB6 funktioniert das ganze auch. Werde denke ich eh wieder auf VB6 gehn, aber der Form Editor ist halt einfacher zu hanhaben beim 2008er.... Habt ihr eine Idee was ich falsch mache?
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.