Why do these mprotect always fail?
w6b7rk5yu4mt25v3
w6b7rk5yu4mt25v3@protonmail.com
Wed Feb 15 09:38:04 GMT 2023
mprotect 1:
unsigned char* buffer;
int32_t available, size;
if(size > PAGE_SIZE) {
factor = size / PAGE_SIZE + 1;
}
available = factor * PAGE_SIZE;
if(posix_memalign((void**)&buffer, PAGE_SIZE, available)) {
std::wcerr << L"Unable to allocate JIT memory!" << std::endl;
exit(1);
}
if(mprotect(buffer, available, PROT_READ | PROT_WRITE | PROT_EXEC) < 0) {
std::wcerr << L"Unable to mprotect" << std::endl;
exit(1);
}
mprotect 2:
if(posix_memalign((void**)& buffer, PAGE_SIZE, PAGE_SIZE)) {
std::wcerr << L"Unable to allocate JIT memory!" << std::endl;
exit(1);
}
if(mprotect(buffer, PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC) < 0) {
std::wcerr << L"Unable to mprotect" << std::endl;
exit(1);
}
Sent with Proton Mail secure email.
More information about the Cygwin-developers
mailing list