Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: phvckmeh on May 01, 2004, 11:56 PM

Title: Read D2 In-Game Text
Post by: phvckmeh on May 01, 2004, 11:56 PM
I need to learn how to read Diablo 2 ingame text with visual basic.

I hope to create two things, one that logs all in game text.

And the other will be a stats program for pk rooms, that logs kills, deaths etc.

i know i will need to use ReadProcessMemory

Thx Guys!!!
Title: Re:Read D2 In-Game Text
Post by: iago on May 02, 2004, 01:08 AM
I don't think you'll be able to do this with vb.  At least, not easily.  The best way would be to inject code and log chat functions, but vb can't (or can barely) go to that low level.
Title: Re:Read D2 In-Game Text
Post by: phvckmeh on May 02, 2004, 02:34 AM
ive seen it done :D

for example

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
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 ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal 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 Sub Main()
Const PROCESS_ALL_ACCESS = &H1F0FFF
Dim pindIni As New IniEditor

Dim windowname As String
windowname = "Diablo II"
Dim health As Long
Dim diablohwnd As Long
diablohwnd = FindWindow(vbNullString, windowname)
If (diablohwnd = 0) Then
   MsgBox windowname & " must be running"
   Exit Sub
End If
Dim diablopid As Long
GetWindowThreadProcessId diablohwnd, diablopid
Dim pHandle As Long
pHandle = OpenProcess(PROCESS_ALL_ACCESS, False, diablopid)
If (pHandle = 0) Then
   MsgBox "Couldn't get a handle, please ensure that " & windowname & " is running"
   Exit Sub
End If
Dim buf As Long
Dim addy As Long
addy = &H6FBBC200
ReadProcessMemory pHandle, addy, buf, 4, 0&
addy = buf + &H5C
ReadProcessMemory pHandle, addy, buf, 4, 0&
addy = buf + &H10
ReadProcessMemory pHandle, addy, buf, 4, 0&
If buf And &H80000000 Then
addy = addy + &H38
Else
   addy = addy + &H14
End If
ReadProcessMemory pHandle, addy, buf, 4, 0&

health = buf + &H25
ReadProcessMemory pHandle, health, buf, 4, 0&

MsgBox buf

CloseHandle (pHandle)
End Sub


that will grab your life in game, (and save it to INI)
Title: Re:Read D2 In-Game Text
Post by: Dyndrilliac on May 02, 2004, 03:48 AM
You might take a peek at the games Send() winsock function. Hook it and copy the text as the client sends it.
Title: Re:Read D2 In-Game Text
Post by: TheMinistered on May 02, 2004, 05:34 PM
He doesn't want to get the data being sent out by his client.  He wants to get the data received by his client.  Thus, he does not want to hook Send!  Rather, if he chooses to use hooking as his method of choice, Recv!  If not, then he should try to find the function(s) that display text to the screen.
Title: Re:Read D2 In-Game Text
Post by: Dyndrilliac on May 03, 2004, 02:28 PM
Either way you slice it, he's getting half of what he wants done(Logging all text). I was just using the Send() as an example.
Title: Re:Read D2 In-Game Text
Post by: phvckmeh on May 03, 2004, 08:26 PM
how whould i do this!
Title: Re:Read D2 In-Game Text
Post by: Dyndrilliac on May 03, 2004, 09:51 PM
Research hooking.