I found the pointer that points to the value of the characters HP.
What method in the code can i use to read the pointers value?
[spoiler]
[/spoiler]
Module
[spoiler]
[/spoiler]
In the code it gets the process by window handle, before it checked if the length of the array containg all processes found by the name was 0, if it was the application would exit. I tried to get the process by PID instead and it worked fine so instead of the equal symbol i did less than ( < 0 ). So im not sure if its correctly attaching now, there are more checks after that, code is below.
Code...
[spoiler]
[/spoiler]
The application just crashes.
I have the address of the pointer which points to the current characters hp points. I want to resolve the value of the address the pointer is pointing to.
What method in the code can i use to read the pointers value?
[spoiler]
Code:
<?xml version="1.0"?> <CheatTable CheatEngineTableVersion="12"> <CheatEntries> <CheatEntry> <ID>1</ID> <Description>"PSKO Chr: Current HP"</Description> <Color>80000008</Color> <VariableType>4 Bytes</VariableType> <Address>00818794</Address> <Offsets> <Offset>4A0</Offset> </Offsets> </CheatEntry> </CheatEntries> <UserdefinedSymbols/> </CheatTable>
Code:
Public Function GetCurrentHP() Form1.Label2.Text = KOHack.Module1.ReadLongPointer(818794, "4A0", 4) End Function
[spoiler]
Code:
Module Module1 Public RBuff As Long Public RBuff2 As Single Public RBuff3 As Integer Dim Form1 As KOHack.frmMain Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer Private Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer Private Declare Function WriteFloatMemory Lib "kernel32" Alias "WriteProcessMemory" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Single, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer Private Declare Function ReadFloat Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr, ByRef buffer As Single, ByVal size As Int32, ByRef lpNumberOfBytesRead As Int32) As Boolean Private Declare Function ReadProcessMemory Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Integer) As Integer Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer Public Function Writememory(ByVal Address As Integer, ByVal Value As Long, ByVal Bytes As Integer) Dim LOLLookUp As Process() = Process.GetProcessesByName(Form1.txtWindowName.Text) If LOLLookUp.Length < 0 Then End End If Dim processHandle As IntPtr = OpenProcess(&H1F0FFF, 0, LOLLookUp(0).Id) WriteProcessMemory(processHandle, Address, Value, Bytes, Nothing) CloseHandle(processHandle) End Function Public Function ReadFloat(ByVal Address As Single) Dim KnightOnLineLookUp As Process() = Process.GetProcessesByName(Form1.txtWindowName.Text) If KnightOnLineLookUp.Length < 0 Then End End If Dim processHandle As IntPtr = OpenProcess(&H1F0FFF, 0, KnightOnLineLookUp(0).Id) ReadProcessMemory(processHandle, Address, RBuff, 4, Nothing) CloseHandle(processHandle) Return RBuff End Function Public Function WriteFloat(ByVal Address As Integer, ByVal Value As Single) Dim KnightOnLineLookUp As Process() = Process.GetProcessesByName(Form1.txtWindowName.Text) If KnightOnLineLookUp.Length < 0 Then End End If Dim processHandle As IntPtr = OpenProcess(&H1F0FFF, 0, KnightOnLineLookUp(0).Id) WriteFloatMemory(processHandle, Address, Value, 4, Nothing) CloseHandle(processHandle) End Function Public Function ReadLong(ByVal Address As Integer) Dim KnightOnLineLookUp As Process() = Process.GetProcessesByName(Form1.txtWindowName.Text) If KnightOnLineLookUp.Length < 0 Then End End If Dim processHandle As IntPtr = OpenProcess(&H1F0FFF, 0, KnightOnLineLookUp(0).Id) ReadProcessMemory(processHandle, Address, RBuff, 4, Nothing) CloseHandle(processHandle) Return RBuff End Function Public Function ReadFloatPointer(ByVal Base As Integer, ByVal Offset As Short) Dim fullAddress As Long Dim KnightOnLineLookUp As Process() = Process.GetProcessesByName(Form1.txtWindowName.Text) If KnightOnLineLookUp.Length < 0 Then End End If Dim processHandle As IntPtr = OpenProcess(&H1F0FFF, 0, KnightOnLineLookUp(0).Id) ReadProcessMemory(processHandle, Base, RBuff, 4, Nothing) fullAddress = RBuff + Offset ReadFloat(processHandle, fullAddress, RBuff2, 4, Nothing) Return RBuff2 CloseHandle(processHandle) End Function Public Function ReadLongPointer(ByVal Base As Integer, ByVal Offset As Short, ByVal Bytes As Integer) Dim fullAddress As Long Dim KnightOnLineLookUp As Process() = Process.GetProcessesByName(Form1.txtWindowName.Text) If KnightOnLineLookUp.Length < 0 Then End End If Dim processHandle As IntPtr = OpenProcess(&H1F0FFF, 0, KnightOnLineLookUp(0).Id) ReadProcessMemory(processHandle, Base, RBuff, 4, Nothing) fullAddress = RBuff + Offset ReadProcessMemory(processHandle, fullAddress, RBuff3, Bytes, Nothing) Return RBuff3 CloseHandle(processHandle) End Function Public Function WriteFloatPointer(ByVal Base As Integer, ByVal Offset As Short, ByVal Value As Single) Dim fullAddress As Long Dim KnightOnLineLookUp As Process() = Process.GetProcessesByName(Form1.txtWindowName.Text) If KnightOnLineLookUp.Length < 0 Then End End If Dim processHandle As IntPtr = OpenProcess(&H1F0FFF, 0, KnightOnLineLookUp(0).Id) ReadProcessMemory(processHandle, Base, RBuff, 4, Nothing) fullAddress = RBuff + Offset WriteFloatMemory(processHandle, fullAddress, Value, 4, Nothing) CloseHandle(processHandle) End Function Public Function WriteLongPointer(ByVal Base As Integer, ByVal Offset As Short, ByVal Value As Long, ByVal Bytes As Integer) Dim fullAddress As Long Dim KnightOnLineLookUp As Process() = Process.GetProcessesByName(Form1.txtWindowName.Text) If KnightOnLineLookUp.Length < 0 Then End End If Dim processHandle As IntPtr = OpenProcess(&H1F0FFF, 0, KnightOnLineLookUp(0).Id) ReadProcessMemory(processHandle, Base, RBuff, 4, Nothing) fullAddress = RBuff + Offset WriteProcessMemory(processHandle, fullAddress, Value, Bytes, Nothing) CloseHandle(processHandle) End Function Public Function NOP(ByVal Address As Integer, ByVal value As Integer) Dim KnightOnLineLookUp As Process() = Process.GetProcessesByName(Form1.txtWindowName.Text) If KnightOnLineLookUp.Length < 0 Then End End If Dim processHandle As IntPtr = OpenProcess(&H1F0FFF, 0, KnightOnLineLookUp(0).Id) WriteProcessMemory(processHandle, Address, value, 1, Nothing) CloseHandle(processHandle) End Function End Module
In the code it gets the process by window handle, before it checked if the length of the array containg all processes found by the name was 0, if it was the application would exit. I tried to get the process by PID instead and it worked fine so instead of the equal symbol i did less than ( < 0 ). So im not sure if its correctly attaching now, there are more checks after that, code is below.
Code...
[spoiler]
Code:
Dim KO As Process() = Process.GetProcessesByName(txtWindowName.Text) If KO.Length < 0 Then MsgBox("KnightOnline is not running!", MsgBoxStyle.Critical) Me.Close() Else GameWindowHandle = w32.GetWindowHandle(txtWindowName.Text) If GameWindowHandle = IntPtr.Zero Then Else GamePID = w32.GetPID(GameWindowHandle) If GamePID = 0 Then Else GameProcessHandle = w32.GetProcessHandle(GamePID) If GameProcessHandle = IntPtr.Zero Then MsgBox("Can not attach to the knightonline client.", MsgBoxStyle.Information) Else MsgBox("Succesfully attached!", MsgBoxStyle.Information) btnStart.Enabled = False Panel1.Enabled = True oThread = New Thread(AddressOf cw.GetCurrentHP) oThread.Start() End If End If End If End If
The application just crashes.
I have the address of the pointer which points to the current characters hp points. I want to resolve the value of the address the pointer is pointing to.