MemoryRead

3.1

  #include <toolhelp.h>    

  DWORD MemoryRead(wSel, dwOffset, lpvBuf, dwcb)    
  WORD wSel; /* selector of global heap object */
  DWORD dwOffset; /* offset to object, */  
  void FAR* lpvBuf; /* address of buffer to read to */
  DWORD dwcb; /* number of bytes to read */

The MemoryRead function copies memory from the specified global heap object to the specified buffer.

Parameters

wSel

Specifies the global heap object from which to read. This value must be a selector on the global heap; if the value is an alias selector or a selector in a tiled selector array, MemoryRead will fail.

dwOffset

Specifies the offset in the object specified in the wSel parameter at which to begin reading. The dwOffset value may point anywhere within the object; it may be greater than 64K if the object is larger than 64K.

lpvBuf

Points to the buffer to which MemoryRead will copy the memory from the object. This buffer must be large enough to contain the entire amount of memory copied to it. If the application is running under low memory conditions, lpvBuf should be in a fixed object while MemoryRead copies data to it.

dwcb

Specifies the number of bytes to copy from the object to the buffer pointed to by lpvBuf.

Return Value

The return value is the number of bytes copied from wSel to lpvBuf. If wSel is invalid or if dwOffset is out of the selector's range, the return value is zero.

Comments

The MemoryRead function enables developers to examine memory without
consideration for selector tiling and aliasing. MemoryRead reads memory in
read-write or read-only objects. This function can be used in any size object owned by any task. It is not necessary to compute selector array offsets.

The MemoryRead and MemoryWrite functions are designed to read and write objects loaded by the LoadModule function or allocated by the GlobalAlloc function. Developers should not split off the selector portion of a far pointer and use this as the value for wSel, unless the selector is known to be on the global heap.

See Also

MemoryWrite