updating oE allocate_protect


include machine.e 
namespace machine 
public function allocate_protect(object data, memconst :valid_wordsize wordsize = 1, 
        valid_memory_protection_constant protection) 

Allocates and copies data into memory and gives it protection using Standard Library Memory Protection Constants or Microsoft Windows Memory Protection Constants. The user may only pass in one of these constants. If you only wish to execute a sequence as machine code use allocate_code. If you only want to read and write data into memory use allocate.

See MSDN: Microsoft's Memory Protection Constants

  1. data : is the machine code to be put into memory.
  2. wordsize : is the size each element of data will take in memory. Are they 1-byte, 2-bytes, 4-bytes or 8-bytes long? Specify here. The default is 1.
  3. protection : is the particular Windows protection.

An address, The function returns the address to the required memory or 0 if it fails. This function is guaranteed to return memory on the 8 byte boundary. It also guarantees that the memory returned with at least the protection given (but you may get more).

If you want to call allocate_protect( data, PAGE_READWRITE ), you can use allocate instead. It is more efficient and simpler.

If you want to call allocate_protect( data, PAGE_EXECUTE ), you can use allocate_code instead. It is simpler.

You must not use free on memory returned from this function, instead use free_code.

See Also:

Executable Memory

Not Categorized, Please Help


Quick Links

User menu

Not signed in.

Misc Menu