Code:
Public Shared Sub interactWith(ByVal ProcessID As Integer, ByVal objectId As Integer, ByVal interactionType As Integer, ByVal skillPointer As Integer)
Dim ECXI, ECXI1, eax As Integer
Dim hProcess As Integer = OpenProcess(PROCESS_ALL_ACCESS, False, ProcessID)
If hProcess = 0 Then Return
Try
Dim actionStruct, actionList, interactWithAction As Integer
' Get Char Base :
ReadProcessMemory(hProcess, &HA5B90C, ECXI1, 4, 0)
ReadProcessMemory(hProcess, ECXI1 + &H1C, ECXI, 4, 0)
ReadProcessMemory(hProcess, ECXI + &H8, eax, 4, 0)
ReadProcessMemory(hProcess, eax + &HFF4, actionStruct, 4, 0)
ReadProcessMemory(hProcess, actionStruct + &H30, actionList, 4, 0)
ReadProcessMemory(hProcess, actionList + &H8, interactWithAction, 4, 0)
MemWriteInt(hProcess, interactWithAction + &H8, 0)
'action finished = 0
MemWriteInt(hProcess, interactWithAction + &H14, 1)
'Action start = 1
MemWriteInt(hProcess, interactWithAction + &H24, 0)
' Action not start = 0
MemWriteInt(hProcess, interactWithAction + &H20, objectId)
' Set object id to interact with
MemWriteInt(hProcess, interactWithAction + &H38, 4)
' Set the type of interaction, 0 = regAtk, 1 = pick item, 2 = talk to NPC,3 = useSkill, 4 = gatherResources
'WriteProcessMemory(hProcess, interactWithAction + off_player_actStruct_list_interact_error1, 0)
' Set error = 0
'WriteProcessMemory(hProcess, interactWithAction + off_player_actStruct_list_interact_error2, 0)
' Set error = 0
MemWriteInt(hProcess, interactWithAction + &H34, 0)
MemWriteInt(hProcess, interactWithAction + &H4C, 0)
' Set skillPointer
MemWriteInt(hProcess, interactWithAction + &H50, 0)
' Set new actionType
MemWriteInt(hProcess, actionStruct + &HC, interactWithAction)
' Set new actionType
MemWriteInt(hProcess, actionStruct + &H18, 1)
' Set next action position to 1
MemWriteInt(hProcess, actionStruct + &H14, interactWithAction)
' Set new actionType
Catch ex As Exception
WriteLog(ex.ToString, "PickOre", "System")
End Try
End Sub
Public Shared Sub MemWriteInt(ByVal processHandle As IntPtr, ByVal address As Integer, ByVal value As Integer)
Dim success As Boolean
Dim buffer As Byte() = BitConverter.GetBytes(value)
Dim nBytesRead As UInt32 = 0
Dim temp = New IntPtr(address)
success = WriteProcessMemory(processHandle, address, buffer, 4, nBytesRead)
If (success = False) Then
MsgBox("WriteProcessMemory failed with error " & Marshal.GetLastWin32Error)
End If
'MsgBox(success)
End Sub