Форум программистов, компьютерный форум, киберфорум
Visual Basic .NET
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.88/8: Рейтинг темы: голосов - 8, средняя оценка - 4.88
525 / 487 / 98
Регистрация: 25.12.2011
Сообщений: 1,176
1

Изменить код VB6 - VB.NET (и помочь исправить)

25.04.2012, 13:07. Показов 1499. Ответов 7
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
Нашел код:
Visual Basic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Private Sub Command1_Click()
Dim hwnd As Long
Dim pid As Long
Dim pHandle As Long
hwnd = FindWindow(vbNullString, "Assassin's Creed Revelations")
If (hwnd = 0) Then
MsgBox "Window not found!"
Exit Sub
End If
GetWindowThreadProcessId hwnd, pid
pHandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
If (pHandle = 0) Then
MsgBox "Couldn 't get a process handle!"
Exit Sub
End If
WriteProcessMemory pHandle, &H719403C4, “Beans”, 5, 0&
CloseHandle hProcess
End Sub
 
Private Sub Timer1_Timer()
    Dim hwnd As Long
    Dim pid As Long
    Dim pHandle As Long
    Dim str As String * 20
    hwnd = FindWindow(vbNullString, "Assassin's Creed Revelations")
    If (hwnd = 0) Then
    Exit Sub
    End If
    GetWindowThreadProcessId hwnd, pid
    pHandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
    If (pHandle = 0) Then
    Exit Sub
    End If
    ReadProcessMemory pHandle, &H719403C4, str, 20, 0&
    txtDisplay = str
    CloseHandle hProcess
End Sub
Помогите изменить его на VB.net. И еще подскажите поч. он не работает).
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
25.04.2012, 13:07
Ответы с готовыми решениями:

Перевести код с VB6 на VB .NET
Dim dig_cyr() Dim dig_cyr_4, dig_10 Private Sub Form_Load() ReDim dig_cyr(1 To 3, 0 To 9) ...

Изменить код на код PascalABC.NET (roguelike)
Всем привет.Есть проблема. Сам давно мечтаю написать свой рогалик. После многомесячных поисков...

Исправить код для PascalABC.net
как минимум, первое место которое ему не нравиться это как я обьявляю тип объект const size=10; ...

Помочь исправить
Здравствуйте, в с++ я новичок, программирую 2 день, дошел до одномерных массивов, помогите...

7
Крутой форумчанин
154 / 154 / 8
Регистрация: 09.01.2011
Сообщений: 298
26.04.2012, 15:21 2
Код ты привёл не полностью. Сверху ещё должны быть "декларации" этих API функций. Не работает в VB6 возможно из-за кавычек возле Beans
0
525 / 487 / 98
Регистрация: 25.12.2011
Сообщений: 1,176
26.04.2012, 15:42  [ТС] 3
С кавычками все норм и декларацией, у меня всегда выдает сообщение "Couldn't get a process handle!", почему?
0
Крутой форумчанин
154 / 154 / 8
Регистрация: 09.01.2011
Сообщений: 298
27.04.2012, 17:28 4
Цитата Сообщение от Hennasy Посмотреть сообщение
всегда выдает сообщение "Couldn't get a process handle!", почему?
Потому что:
VB.NET
1
2
3
pHandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
If (pHandle = 0) Then
MsgBox "Couldn 't get a process handle!"
Версия Windows какая?

Цитата Сообщение от Hennasy Посмотреть сообщение
С кавычками все норм и декларацией
Да ну? Так кинь их сюда, все эти Declare Function.
0
525 / 487 / 98
Регистрация: 25.12.2011
Сообщений: 1,176
27.04.2012, 18:48  [ТС] 5
Цитата Сообщение от cergew Посмотреть сообщение
Да ну? Так кинь их сюда, все эти Declare Function.
Visual Basic
1
2
3
4
5
6
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAcess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAdress As Any, ByVal lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddess As Any, ByVal lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWriten As Long) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Цитата Сообщение от cergew Посмотреть сообщение
Версия Windows какая?
XP SP3 (2002)
0
1568 / 1447 / 303
Регистрация: 01.10.2011
Сообщений: 2,636
27.04.2012, 22:32 6
VB.NET
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
'VB.NET Module 
 'Author : Cless 
 'How to use Read/Write Pointer 
 'Example Read 
 '       Me.Text = ReadPointerInteger(Game exe name, &HPointer,&HOffset).ToString() 
 ' 
 '       Me.Text = ReadPointerInteger("gta_sa", &HB71A38,&H540).ToString() 
 '       Or 
 '       Me.Text = ReadPointerInteger("gta_sa", &HB71A38,&H540,&H544).ToString() 
 'Example Write 
 '       WritePointerInteger(Game exe name,&HPointer,Value,&HOffset) 
 ' 
 '       WritePointerInteger("gta_sa",&HB71A38,1000,&H540) 
 '       Or 
 '       WritePointerInteger("gta_sa",&HB71A38,1000,&H540, &H544) 
 
 Module Trainer 
     Private Declare Function ReadMemoryByte Lib "kernel32" Alias "ReadProcessMemory" (ByVal Handle As Integer, ByVal Address As Integer, ByRef Value As Byte, Optional ByVal Size As Integer = 2, Optional ByRef Bytes As Integer = 0) As Byte 
     Private Declare Function ReadMemoryInteger Lib "kernel32" Alias "ReadProcessMemory" (ByVal Handle As Integer, ByVal Address As Integer, ByRef Value As Integer, Optional ByVal Size As Integer = 4, Optional ByRef Bytes As Integer = 0) As Integer 
     Private Declare Function ReadMemoryFloat Lib "kernel32" Alias "ReadProcessMemory" (ByVal Handle As Integer, ByVal Address As Integer, ByRef Value As Single, Optional ByVal Size As Integer = 4, Optional ByRef Bytes As Integer = 0) As Single 
     Private Declare Function ReadMemoryDouble Lib "kernel32" Alias "ReadProcessMemory" (ByVal Handle As Integer, ByVal Address As Integer, ByRef Value As Double, Optional ByVal Size As Integer = 8, Optional ByRef Bytes As Integer = 0) As Double 
 
     Private Declare Function WriteMemoryByte Lib "kernel32" Alias "WriteProcessMemory" (ByVal Handle As Integer, ByVal Address As Integer, ByRef Value As Byte, Optional ByVal Size As Integer = 2, Optional ByRef Bytes As Integer = 0) As Byte 
     Private Declare Function WriteMemoryInteger Lib "kernel32" Alias "WriteProcessMemory" (ByVal Handle As Integer, ByVal Address As Integer, ByRef Value As Integer, Optional ByVal Size As Integer = 4, Optional ByRef Bytes As Integer = 0) As Integer 
     Private Declare Function WriteMemoryFloat Lib "kernel32" Alias "WriteProcessMemory" (ByVal Handle As Integer, ByVal Address As Integer, ByRef Value As Single, Optional ByVal Size As Integer = 2, Optional ByRef Bytes As Integer = 0) As Single 
     Private Declare Function WriteMemoryDouble Lib "kernel32" Alias "WriteProcessMemory" (ByVal Handle As Integer, ByVal Address As Integer, ByRef Value As Double, Optional ByVal Size As Integer = 2, Optional ByRef Bytes As Integer = 0) As Double 
 
     Public Function ReadByte(ByVal EXENAME As String, ByVal Address As Integer) As Byte 
         Dim Value As Byte 
         If Process.GetProcessesByName(EXENAME).Length <> 0 Then 
             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle 
             If Handle <> 0 Then 
                 ReadMemoryByte(Handle, Address, Value) 
             End If 
         End If 
         Return Value 
     End Function 
 
     Public Function ReadInteger(ByVal EXENAME As String, ByVal Address As Integer) As Integer 
         Dim Value As Integer 
         If Process.GetProcessesByName(EXENAME).Length <> 0 Then 
             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle 
             If Handle <> 0 Then 
                 ReadMemoryInteger(Handle, Address, Value) 
             End If 
         End If 
         Return Value 
     End Function 
 
     Public Function ReadFloat(ByVal EXENAME As String, ByVal Address As Integer) As Single 
         Dim Value As Single 
         If Process.GetProcessesByName(EXENAME).Length <> 0 Then 
             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle 
             If Handle <> 0 Then 
                 ReadMemoryFloat(Handle, Address, Value) 
             End If 
         End If 
         Return Value 
     End Function 
 
     Public Function ReadDouble(ByVal EXENAME As String, ByVal Address As Integer) As Double 
         Dim Value As Double 
         If Process.GetProcessesByName(EXENAME).Length <> 0 Then 
             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle 
             If Handle <> 0 Then 
                 ReadMemoryByte(Handle, Address, Value) 
             End If 
         End If 
         Return Value 
     End Function 
 
     Public Function ReadPointerByte(ByVal EXENAME As String, ByVal Pointer As Integer, ByVal ParamArray Offset As Integer()) As Byte 
         Dim Value As Byte 
         If Process.GetProcessesByName(EXENAME).Length <> 0 Then 
             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle 
             If Handle <> 0 Then 
                 For Each I As Integer In Offset 
                     ReadMemoryInteger(Handle, Pointer, Pointer) 
                     Pointer += I 
                 Next 
                 ReadMemoryByte(Handle, Pointer, Value) 
             End If 
         End If 
         Return Value 
     End Function 
 
     Public Function ReadPointerInteger(ByVal EXENAME As String, ByVal Pointer As Integer, ByVal ParamArray Offset As Integer()) As Integer 
         Dim Value As Integer 
         If Process.GetProcessesByName(EXENAME).Length <> 0 Then 
             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle 
             If Handle <> 0 Then 
                 For Each I As Integer In Offset 
                     ReadMemoryInteger(Handle, Pointer, Pointer) 
                     Pointer += I 
                 Next 
                 ReadMemoryInteger(Handle, Pointer, Value) 
             End If 
         End If 
         Return Value 
     End Function 
 
     Public Function ReadPointerFloat(ByVal EXENAME As String, ByVal Pointer As Integer, ByVal ParamArray Offset As Integer()) As Single 
         Dim Value As Single 
         If Process.GetProcessesByName(EXENAME).Length <> 0 Then 
             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle 
             If Handle <> 0 Then 
                 For Each I As Integer In Offset 
                     ReadMemoryInteger(Handle, Pointer, Pointer) 
                     Pointer += I 
                 Next 
                 ReadMemoryFloat(Handle, Pointer, Value) 
             End If 
         End If 
         Return Value 
     End Function 
 
     Public Function ReadPointerDouble(ByVal EXENAME As String, ByVal Pointer As Integer, ByVal ParamArray Offset As Integer()) As Double 
         Dim Value As Double 
         If Process.GetProcessesByName(EXENAME).Length <> 0 Then 
             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle 
             If Handle <> 0 Then 
                 For Each I As Integer In Offset 
                     ReadMemoryInteger(Handle, Pointer, Pointer) 
                     Pointer += I 
                 Next 
                 ReadMemoryDouble(Handle, Pointer, Value) 
             End If 
         End If 
         Return Value 
     End Function 
 
     Public Sub WriteByte(ByVal EXENAME As String, ByVal Address As Integer, ByVal Value As Byte) 
         If Process.GetProcessesByName(EXENAME).Length <> 0 Then 
             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle 
             If Handle <> 0 Then 
                 WriteMemoryByte(Handle, Address, Value) 
             End If 
         End If 
     End Sub 
 
     Public Sub WriteInteger(ByVal EXENAME As String, ByVal Address As Integer, ByVal Value As Integer) 
         If Process.GetProcessesByName(EXENAME).Length <> 0 Then 
             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle 
             If Handle <> 0 Then 
                 WriteMemoryInteger(Handle, Address, Value) 
             End If 
         End If 
     End Sub 
 
     Public Sub WriteFloat(ByVal EXENAME As String, ByVal Address As Integer, ByVal Value As Single) 
         If Process.GetProcessesByName(EXENAME).Length <> 0 Then 
             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle 
             If Handle <> 0 Then 
                 WriteMemoryFloat(Handle, Address, Value) 
             End If 
         End If 
     End Sub 
 
     Public Sub WriteDouble(ByVal EXENAME As String, ByVal Address As Integer, ByVal Value As Double) 
         If Process.GetProcessesByName(EXENAME).Length <> 0 Then 
             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle 
             If Handle <> 0 Then 
                 WriteMemoryDouble(Handle, Address, Value) 
             End If 
         End If 
     End Sub 
 
     Public Sub WritePointerByte(ByVal EXENAME As String, ByVal Pointer As Integer, ByVal Value As Byte, ByVal ParamArray Offset As Integer()) 
         If Process.GetProcessesByName(EXENAME).Length <> 0 Then 
             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle 
             If Handle <> 0 Then 
                 For Each I As Integer In Offset 
                     ReadMemoryInteger(Handle, Pointer, Pointer) 
                     Pointer += I 
                 Next 
                 WriteMemoryByte(Handle, Pointer, Value) 
             End If 
         End If 
     End Sub 
 
     Public Sub WritePointerInteger(ByVal EXENAME As String, ByVal Pointer As Integer, ByVal Value As Integer, ByVal ParamArray Offset As Integer()) 
         If Process.GetProcessesByName(EXENAME).Length <> 0 Then 
             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle 
             If Handle <> 0 Then 
                 For Each I As Integer In Offset 
                     ReadMemoryInteger(Handle, Pointer, Pointer) 
                     Pointer += I 
                 Next 
                 WriteMemoryInteger(Handle, Pointer, Value) 
             End If 
         End If 
     End Sub 
 
     Public Sub WritePointerFloat(ByVal EXENAME As String, ByVal Pointer As Integer, ByVal Value As Single, ByVal ParamArray Offset As Integer()) 
         If Process.GetProcessesByName(EXENAME).Length <> 0 Then 
             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle 
             If Handle <> 0 Then 
                 For Each I As Integer In Offset 
                     ReadMemoryInteger(Handle, Pointer, Pointer) 
                     Pointer += I 
                 Next 
                 WriteMemoryFloat(Handle, Pointer, Value) 
             End If 
         End If 
     End Sub 
 
     Public Sub WritePointerDouble(ByVal EXENAME As String, ByVal Pointer As Integer, ByVal Value As Double, ByVal ParamArray Offset As Integer()) 
         If Process.GetProcessesByName(EXENAME).Length <> 0 Then 
             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle 
             If Handle <> 0 Then 
                 For Each I As Integer In Offset 
                     ReadMemoryInteger(Handle, Pointer, Pointer) 
                     Pointer += I 
                 Next 
                 WriteMemoryDouble(Handle, Pointer, Value) 
             End If 
         End If 
     End Sub 
 End Module
1
525 / 487 / 98
Регистрация: 25.12.2011
Сообщений: 1,176
28.04.2012, 00:30  [ТС] 7
edward_freedom, можно чуть объяснить?)
0
1568 / 1447 / 303
Регистрация: 01.10.2011
Сообщений: 2,636
28.04.2012, 14:04 8
Цитата Сообщение от Hennasy Посмотреть сообщение
edward_freedom, можно чуть объяснить?)
Ну все же есть
VB.NET
1
2
3
4
5
6
7
8
9
10
11
12
'Example Read 
 '       Me.Text = ReadPointerInteger(Game exe name, &HPointer,&HOffset).ToString() 
 ' 
 '       Me.Text = ReadPointerInteger("gta_sa", &HB71A38,&H540).ToString() 
 '       Or 
 '       Me.Text = ReadPointerInteger("gta_sa", &HB71A38,&H540,&H544).ToString() 
 'Example Write 
 '       WritePointerInteger(Game exe name,&HPointer,Value,&HOffset) 
 ' 
 '       WritePointerInteger("gta_sa",&HB71A38,1000,&H540) 
 '       Or 
 '       WritePointerInteger("gta_sa",&HB71A38,1000,&H540, &H544)
Добавлено через 11 минут
И уже поздно, некогда обьяснять, там по названиям функций все понятно

Добавлено через 13 часов 15 минут
Цитата Сообщение от edward_freedom Посмотреть сообщение
Последний раз редактировалось Памирыч; Сегодня в 05:58. Причина: Используйте специальные теги форматирования программного кода
Та что ж я, все время тегами промахиваюсь
1
28.04.2012, 14:04
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
28.04.2012, 14:04
Помогаю со студенческими работами здесь

С++ Помочь исправить программы.
Написать программу, которая выводит пример на вычитание (в пределах 100), запрашивает ответ...

VB.NET vs VB6
Кто вам лично больше нравится? :p

С просьбой помочь с установкой VS.NET
Пытаюсь поставить VS.NET на win2000pro sp3... На сетап визарде мне доступен только пункт 1 Windows...

Vb6 или vb.net?
Приветствую всех. Интересует, что лучше на данный момент. VB6 или VB.net. Программировать нужно...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
8
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru