#include <_NomadMemory.au3>
Global Const $MEM_ASCII = 0x08
Global Const $MEM_UNICODE = 0x09
Local $sProcess = "IEXPLORE.EXE"
Local $sDll = "Memory.dll"
Local $iID = ProcessExists($sProcess)
If (Not $iID) Then Exit
_SetPrivilege("SeDebugPrivilege", 1)
Local $hProc = _MemoryOpen($iID)
Local $hWnd = _ProcessGetWindow($iID)
Local $sStr = "&hp="
Local $sDelim = "&"
Local $iTimer = TimerInit()
Local $sRes = _GetString($sDll, $hWnd, $hProc, $sStr, $sDelim)
ConsoleWrite(TimerDiff($iTimer)&@CRLF)
ConsoleWrite($sStr&$sRes&@CRLF)
_MemoryClose($hProc)
Func _GetString($sDll, $hWnd, $hProc, $sStr, $sDelim = "")
Local $iStrLen = StringLen($sStr)*2
Local $aRes = _ScanMemory($sDll, $hWnd, $sStr, $MEM_UNICODE)
If ($aRes[1] = 0x00000000) Then Return 0
Local $sRes, $sString
If $sDelim Then
Local $i
Do
$sString &= $sRes
$sRes = _MemoryRead($aRes[1]+$iStrLen+$i, $hProc, 'char[1]')
$i +=1
Until $sRes = $sDelim
Else
$sString = _MemoryRead($aRes[1], $hProc, 'char['&$iStrLen&']')
EndIf
Return $sString
EndFunc
Func _ProcessGetWindow($iPID, $iRet=1)
Local $aWinList = WinList()
Local $aRet[2]
If IsString($iPID) Then $iPID = ProcessExists($iPID)
For $i = 1 To UBound($aWinList)-1
If WinGetProcess($aWinList[$i][1]) = $iPID Then
$aRet[0] = $aWinList[$i][0]
$aRet[1] = $aWinList[$i][1]
If $iRet = 0 Then Return $aRet[0]
If $iRet = 1 Then Return $aRet[1]
Return $aRet
EndIf
Next
Return SetError(1, 0, $aRet)
EndFunc
Func _ScanMemory($sDll, $hWnd, $sStr, $iMode, $iMinAddr = 0, $iMaxAddr = 0x7FFFFFFF)
$hDll = DllOpen($sDll)
Dim $aArray[2]
Local $aRes = DllCall($hDll, 'str', 'ScanMemory', 'hwnd', $hWnd, 'str', $sStr, 'int', $iMode, 'int', $iMinAddr, 'int', $iMaxAddr)
If Not IsArray($aRes) Then Return 0
Local $aSplit = StringSplit($aRes[0], "|")
$aArray[0] = $aSplit[0]
For $i = 1 To $aSplit[0]
ReDim $aArray[$aArray[0] + 1]
$aArray[$i] = '0x' & Hex($aSplit[$i], 8)
Next
DllClose($hDll)
Return $aArray
EndFunc