###User Defined Function###
_MemoryRead

###Description###
Returns the value located at a specified memory address.

###Syntax###
_MemoryRead($iv_Address, $ah_Handle[, $sv_Type])

###Parameters###
@@ParamTable@@
$iv_Address
	The memory address to read in hex format (0x00000000).
$ah_Handle
	An array containing the Dll handle and the handle of the open process as returned by _MemoryOpen.
$sv_Type
	The "Type" of value to read.  The default type is 'dword'.
@@End@@

###ReturnValue###
@@ReturnTable@@
Success:	The value at the specified address.
Failure:	0.
@Error:		0 = No error.
		1 = Invalid $ah_Handle.
		2 = $sv_Type is not a string.
		3 = $sv_Type is an unknown data type.
		4 = Failed to allocate the memory needed for the DllStructure.
		5 = Error allocating memory for $sv_Type.
		6 = Failed to read from the specified process.
@@End@@


###Remarks###
If the "Type" is of the 'char' type, the value returned is in ASCII format, otherwise the value returned is in Decimal format.  Also, the size ('char[size]') for all 'char' types should be 1 greater than the actual size.

For help on creating "Types", see DllStructCreate.


###Related###
_MemoryOpen, _MemoryClose, _MemoryWrite, _MemoryPointerRead, _MemoryPointerWrite


###Example###
@@IncludeExample@@
;This example creates a sample GUI and shows how to use _MemoryRead
;and _MemoryWrite to read and write to the GUI's memory data.
#include <Memory.au3>

;create the sample GUI
GUICreate("Sample GUI", 170, 85)
GUICtrlCreateLabel('Press "Read" to read the data from memory, or "Write" to write the data to memory.', 5, 5, 160, 55)
$ReadMemory = GUICtrlCreateButton("Read", 5, 60, 50, 20)
$WriteMemory = GUICtrlCreateButton("Write", 60, 60, 50, 20)
$CloseGUI = GUICtrlCreateButton("Close", 115, 60, 50, 20)
GUISetState()

;data to read/write
$DecimalRead = 987654321
$DecimalWrite = 123456789
$ASCIIRead = 'Going Out'
$ASCIIWrite = 'Coming In'

$ProcessID = WinGetProcess("Sample GUI")

While(1)
Sleep(50)
$msg = GUIGetMsg()
Select
	Case $msg = $ReadMemory
		;open the process
		$ProcessInformation = _MemoryOpen($ProcessID)
		
		;read the memory
		$Number = _MemoryRead(0xF13CD8, $ProcessInformation)
		$Text = _MemoryRead(0xF13350, $ProcessInformation, 'char[10]')
		
		;close the process
		_MemoryClose($ProcessInformation)
		
		MsgBox(4096, "Data Read", $Number & @CRLF & $Text)
		
	Case $msg = $WriteMemory
		;open the process
		$ProcessInformation = _MemoryOpen($ProcessID)
		
		;write the memory
		_MemoryWrite(0xF13CD8, $ProcessInformation, $DecimalWrite)
		_MemoryWrite(0xF13350, $ProcessInformation, $ASCIIWrite, 'char[10]')
		
		;read the memory
		$Number = _MemoryRead(0xF13CD8, $ProcessInformation)
		$Text = _MemoryRead(0xF13350, $ProcessInformation, 'char[10]')
		
		;close the process
		_MemoryClose($ProcessInformation)
		
		;reset data to be written
		If $Number = 123456789 Then
			$DecimalWrite = 987654321
		Else
			$DecimalWrite = 123456789
		EndIf
		
		If $Text = 'Coming In' Then
			$ASCIIWrite = 'Going Out'
		Else
			$ASCIIWrite = 'Coming In'
		EndIf
		
	Case $msg = $CloseGUI
		Exit
EndSelect
WEnd
@@End@@