c++ - How to allocate a memory with execute permissions? -


i want allocate memory execute permissions. use mprotect change permissions.. page aligned memory use valloc function.

void * temp = (void *) valloc(x); 

and then

if( mprotect(temp, block_size, (prot_read | prot_write |prot_exec))) {    exit(-1); } 

now want add more memory allocated block. hence use realloc function.

void * new_temp = (void *) realloc(temp, 1024); 

will reallocate automatically change permissions of allocated memory ones had set earlier ?? in case realloc moves entire block different location, permissions of allocated memory earlier , newly allocated memory?

should mprotect used again execute permissions memory. , there api realloc on page size boundary valloc. ?

try allocating new region valloc, , copying old contents across. better yet, stop using deprecated valloc, , replace either posix_memalign calls, or directly mmap large allocations. using mremap realloc page-aligned memory regions.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -