MemoryWrite

3.1

  #include <toolhelp.h>    

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

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

Parameters

wSel

Specifies the global heap object to which MemoryWrite will write. 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, MemoryWrite will fail.

dwOffset

Specifies the offset in the object at which to begin writing. 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 from which MemoryWrite will copy the memory to the object. If the application is running under low memory conditions, lpvBuf should be in a fixed object while MemoryWrite copies data from it.

dwcb

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

Return Value

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

Comments

The MemoryWrite function enables developers to modify memory without consideration for selector tiling and aliasing. MemoryWrite writes 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 make alias objects writable or 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

MemoryRead