Oryginalna strona colobot.cba.pl umarła, gdy cba.pl przestało oferować darmowy hosting. To jest statyczny mirror, pobrany w 2018. ~krzys_h
 
Polski Portal COLOBOTa
COLOBOT Polish Portal

Inne języki programowania - [VB] Wchodzenie w pamiec COLOBOTa. (Funkcje)

DemoLisH - 24-02-2009, 18:21
Temat postu: [VB] Wchodzenie w pamiec COLOBOTa. (Funkcje)
podaje tutaj spis funkcji przydatnych do robienia trainerow, multiplayerow itp.
wszystkie funkcje zostaly napisane przeze mnie

Cytat:
Private Const PROCESS_ALL_ACCESS = &H1F0FFF
Public Const gameClassName = "D3D Window"

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, 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 ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByRef lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long

Public Function SetGameWindowText(text As String) As Boolean
a = FindWindow(gameClassName, vbNullString)
If a = 0 Then
SetGameWindowText = False
Else
SetWindowText a, text
End If
End Function

Public Function WindowExists() As Boolean
hwnd = FindWindow(gameClassName, vbNullString)
If (hwnd <> 0) Then
WindowExists = True
Else
WindowExists = False
End If
End Function

Public Sub WriteInt(Address As Long, Value As Integer)
Dim hwnd As Long, pid As Long, phandle As Long

hwnd = FindWindow(gameClassName, vbNullString)
If (hwnd <> 0) Then
GetWindowThreadProcessId hwnd, pid
phandle = OpenProcess(PROCESS_ALL_ACCESS, True, pid)
If (phandle <> 0) Then
WriteProcessMemory phandle, ByVal Address, Value, 2, 0&
End If
CloseHandle phandle
End If
End Sub

Public Sub WriteBytes(Address As Long, Value As String)
Dim hwnd As Long, pid As Long, phandle As Long, ciag() As String, ciagl(255) As Byte, saas As Long

hwnd = FindWindow(gameClassName, vbNullString)
If (hwnd <> 0) Then
GetWindowThreadProcessId hwnd, pid
phandle = OpenProcess(PROCESS_ALL_ACCESS, True, pid)
If (phandle <> 0) Then

ciag = Split(Value, " ")
For i = LBound(ciag) To UBound(ciag)
saas = Address + i
ciagl(i) = Val("&h" & ciag(i))
WriteProcessMemory phandle, ByVal saas, ciagl(i), 1, 0&
Next i
End If
CloseHandle phandle
End If
End Sub

Public Function ReadInt(Address As Long) As Integer
Dim hwnd As Long, pid As Long, phandle As Long, Value As Integer

hwnd = FindWindow(gameClassName, vbNullString)
If (hwnd <> 0) Then
GetWindowThreadProcessId hwnd, pid
phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
If (phandle <> 0) Then
ReadProcessMemory phandle, Address, Value, 2, 0&
ReadInt = Value
End If
CloseHandle phandle
End If
End Function

Public Function ReadFloat(Address As Long) As Single
Dim hwnd As Long, pid As Long, phandle As Long, Value As Single

hwnd = FindWindow(gameClassName, vbNullString)
If (hwnd <> 0) Then
GetWindowThreadProcessId hwnd, pid
phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
If (phandle <> 0) Then
ReadProcessMemory phandle, Address, Value, 4, 0&
ReadFloat = Value
End If
CloseHandle phandle
End If
End Function

Public Sub WriteByte(Address As Long, Value As Byte)
Dim hwnd As Long, pid As Long, phandle As Long

hwnd = FindWindow(gameClassName, vbNullString)
If (hwnd <> 0) Then
GetWindowThreadProcessId hwnd, pid
phandle = OpenProcess(PROCESS_ALL_ACCESS, True, pid)
If (phandle <> 0) Then
WriteProcessMemory phandle, ByVal Address, Value, 1, 0&
End If
CloseHandle phandle
End If
End Sub

Public Sub WriteFloat(Address As Long, Value As Single)
Dim hwnd As Long, pid As Long, phandle As Long

hwnd = FindWindow(gameClassName, vbNullString)
If (hwnd <> 0) Then
GetWindowThreadProcessId hwnd, pid
phandle = OpenProcess(PROCESS_ALL_ACCESS, True, pid)
If (phandle <> 0) Then
WriteProcessMemory phandle, ByVal Address, Value, 4, 0&
End If
CloseHandle phandle
End If
End Sub





Public Sub WriteFloatTable(Address() As Long, Value() As Single)
Dim hwnd As Long, pid As Long, phandle As Long

hwnd = FindWindow(gameClassName, vbNullString)
If (hwnd <> 0) Then
GetWindowThreadProcessId hwnd, pid
phandle = OpenProcess(PROCESS_ALL_ACCESS, True, pid)
If (phandle <> 0) Then
If UBound(Address) = UBound(Value) Then
For i = LBound(Address) To UBound(Address)

WriteProcessMemory phandle, ByVal Address(i), Value(i), 8, 0&

Next i
End If
End If
CloseHandle phandle
End If
End Sub

Public Function ReadString(Address As Long) As String
Dim hwnd As Long, pid As Long, phandle As Long, Value(255) As Byte, a As String

hwnd = FindWindow(gameClassName, vbNullString)
If (hwnd <> 0) Then
GetWindowThreadProcessId hwnd, pid
phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
If (phandle <> 0) Then
For i = LBound(Value) To UBound(Value)
ReadProcessMemory phandle, Address, Value(i), 1, 0&
Address = Address + 1
If Value(i) = 0 Then Exit For
a = a & Chr(Value(i))
Next i
ReadString = a
End If
CloseHandle phandle
End If
End Function

Public Sub WriteString(Address As Long, Value As String)
Dim hwnd As Long, pid As Long, phandle As Long, litera As Integer, linia As Long

hwnd = FindWindow(gameClassName, vbNullString)
If (hwnd <> 0) Then
GetWindowThreadProcessId hwnd, pid
phandle = OpenProcess(PROCESS_ALL_ACCESS, True, pid)
If (phandle <> 0) Then
linia = Address
For i = 1 To Len(Value)
a = Mid(Value, i, 1)
litera = Asc(a)
WriteProcessMemory phandle, ByVal linia, litera, 2, 0&
linia = Address + i
Next i
'While ReadInt(linia) <> 0
'WriteProcessMemory phandle, ByVal linia, 0, 2, 0&
'linia = linia + 1
'Wend
'WriteProcessMemory phandle, ByVal linia, 0, 2, 0&
End If
CloseHandle phandle
End If
End Sub

Public Function ReadLong(Address As Long) As Long
Dim hwnd As Long, pid As Long, phandle As Long, Value As Long

hwnd = FindWindow(gameClassName, vbNullString)
If (hwnd <> 0) Then
GetWindowThreadProcessId hwnd, pid
phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
If (phandle <> 0) Then
ReadProcessMemory phandle, Address, Value, 4, 0&
ReadLong = Value
End If
CloseHandle phandle
End If
End Function

Public Sub WriteLong(Address As Long, Value As Long)
Dim hwnd As Long, pid As Long, phandle As Long

hwnd = FindWindow(gameClassName, vbNullString)
If (hwnd <> 0) Then
GetWindowThreadProcessId hwnd, pid
phandle = OpenProcess(PROCESS_ALL_ACCESS, True, pid)
If (phandle <> 0) Then
WriteProcessMemory phandle, ByVal Address, Value, 4, 0&
End If
CloseHandle phandle
End If
End Sub


Address - adres w pamieci colobota z ktorego chcemy sczytac lub wprowadzic do niej jakas wartosc
Value - wartosc ktora chcesz przypisac danemu adresowi

Spis funkcji:

Zapisujace:
WriteByte(Address As Long, Value As Byte) // zapisuje wartosci od 0-255 (1bajt)
WriteInt(Address As Long, Value As Integer) // zapisuje wartosci typu int
WriteLong(Address As Long, Value As Long) // zapisuje wartosci typu long
WriteString(Address As Long, Value As String) // zapisuje tekst
WriteBytes(Address As Long, Value As String) // zapisuje po kolei bajty. przyklad: "5B C2 3D"

SetGameWindowText(text As String) As Boolean // zmienia tekst okna (text - to wlasnie nazwa okna)

Sczytujące:
ReadInt(Address As Long) As Integer // sczytuje wartosci typu int
ReadLong(Address As Long) As Long // sczytuje wartosci typu long
ReadString(Address As Long) As String // sczytuje tekst

Sprawdzajace:
WindowExists() As Boolean // sprawdza czy okno istnieje

kod wystarczy wkleić w moduł i zrobić swój projekt :)

adiblol - 24-02-2009, 19:08

Nie możesz podać w jakimś sensownym języku (C)?


///brak polskiego znaku - Abadon

DemoLisH - 26-02-2009, 22:18

a kto będzie w C pisał? kto chce mieć trainera w konsoli otwartego?
chyba, że chcesz mieć trainera w .Net, ale wtedy musisz mieć zainstalowane dodatkowe biblioteki, przez co odciąga mnie to.

lukas_j - 27-02-2009, 09:01

lepiej w c++, da się wtedy zrobić aplikacje okienkowe :) wcale nie trzeba w .net, bo to idiotyzm, trzeba się bawić w instalacje jak chcesz skorzystać itp. Poza tym to można by w jakimś języku w którym programuje większość osób, np: c++ , delphi itp :) wtedy bym się tym zajął :)

///Błędy !!! - DeiDara


///Błąd - DemoLisH

adiblol - 27-02-2009, 13:43

Za pomocą Borland C Builder można tworzyć programy okienkowe w C++.
DemoLisH - 27-02-2009, 13:45

A ja wybrałem Visual Basic, bo jest prosty w obsłudze, nie trzeba zapamiętywać jakiego typu jest dana zmienna. A nie chce mi już się tego tłumaczyć z VB na C++.

Powered by phpBB modified by Przemo & WRIM © 2003 phpBB Group