Jump to content

_D2Mem


tlokz
 Share

Recommended Posts

Me and a friend actually got memory reading in autoit to work well with Diablo II :)

I know this isn't going to be useful to most of you but it might. Well here it is!

; #INDEX# ======================================================================
; Title .........: _D2Mem
; Version .......: 1.0.0.0
; AutoIt Version : 3.2 or better
; Language ......: English
; Description ...: Diablo II memory reading
; Author ........: TK_Incorperate & T_LOKZz
;===============================================================================

; #CURRENT# ====================================================================
; _D2Mem_GetStat
; _D2Mem_IsInGame
;===============================================================================

; #FUNCTION# ===================================================================
; Name ..........: _D2Mem_GetStat
; Description ...: The reading of the memory part
; Syntax ........: _InetFile_VersionCheck($PStat, $window)
; Parameters ....: $PStat           - Stat to check
;                  $window          - Diablo II window to check
; Stats .........: 6    = current life
;                  22   = current mana
;                  38   = current stamina
;                  53   = current level
;                  61   = current experience
;                  -27  = (naked) strength
;                  -19  = (naked) energy
;                  -11  = (naked) dexterity
;                  -3   = (naked) vitality
; Return values .: Success - Returns the value of the stat checked 
;                  (If out of game all stats will return 0)
;                  Failure - Will set an error
; Errors ........: @error = 1   - Window didn't exist
; Author ........: TK_Incorperate
; Modified ......: 9/28/08
; Remarks .......: Naked means it wont add what's added from gear,
;                  so if you have 15 base str and 45 added, it will
;                  only show up as 15
; Related .......: _D2Mem_IsInGame
; Link ..........:
; Examples ......:
;===============================================================================
Global $GlobalPlayerUnit = 0x6FBCC3D0

Func _D2Mem_GetStat($PStat, $window)
    $pid = WinGetProcess($window, "")
    If $pid = -1 Then 
        SetError(1)
    Else
        Local $Buffer = DllStructCreate('dword')
        Local $dll[2] = [DllOpen('kernel32.dll')]
        Local $Open = DllCall($dll[0], 'int', 'OpenProcess', 'int', 0x1F0FFF, 'int', 0, 'int', $pid)
        $dll[1] = $Open[0]
        DllCall($dll[0], 'int', 'ReadProcessMemory', 'int', $dll[1], 'int', $GlobalPlayerUnit, 'ptr', DllStructGetPtr($Buffer), 'int', 4, 'int', '')
        $Pointer1 = '0x' & Hex(DllStructGetData($Buffer, 1) + 92)
        DllCall($dll[0], 'int', 'ReadProcessMemory', 'int', $dll[1], 'int', $Pointer1, 'ptr', DllStructGetPtr($Buffer), 'int', 4, 'int', '')
        $Pointer2 = '0x' & Hex(DllStructGetData($Buffer, 1) + 36)
        DllCall($dll[0], 'int', 'ReadProcessMemory', 'int', $dll[1], 'int', $Pointer2, 'ptr', DllStructGetPtr($Buffer), 'int', 4, 'int', '')
        $Pointer3 = '0x' & Hex(DllStructGetData($Buffer, 1) + $PStat + 31)
        DllCall($dll[0], 'int', 'ReadProcessMemory', 'int', $dll[1], 'int', $Pointer3, 'ptr', DllStructGetPtr($Buffer), 'int', 4, 'int', '')
        $Value = DllStructGetData($Buffer, 1)
        DllClose($dll[0])
        Return $Value
    EndIf
EndFunc   ;==>GetStat

; #FUNCTION# ===================================================================
; Name ..........: _D2Mem_IsInGame
; Description ...: Series of checks to acurately check if your in game or not
; Syntax ........: _D2Mem_IsInGame($window)
; Parameters ....: $window          - Diablo II window to check
; Return values .: Success - Returns 1 (Your in game)
;                  Failure - Returns 0 (Your not in game)
; Errors ........: @error = 1   - Window didn't exist
; Author ........: T_LOKZz
; Modified ......: 9/28/08
; Remarks .......: 
; Related .......: _D2Mem_GetStat
; Link ..........:
; Examples ......:
;===============================================================================
Func _D2Mem_IsInGame($window)
    If WinExists($window, "") Then
        If _D2Mem_GetStat(46, $window) > 0 Or _D2Mem_GetStat(38, $window) > 0 Or _D2Mem_GetStat(61, $window) > 0 Then
            Return 1
        Else
            Return 0
        EndIf
    Else
        SetError(1)
    EndIf
EndFunc   ;==>_IsInGame

This is used in Auto-Awesom my lil program to keep Awesom-O running (Best Diablo II bot) if anybody is further interested they can PM me or head over to AOBot

Edited by tlokz
Link to comment
Share on other sites

Pretty cool stuff. Could have it's uses. Although, the game is quite old now.

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Link to comment
Share on other sites

  • 4 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...