Fix some bornheads
This commit is contained in:
parent
9790f54bff
commit
4e007d705c
@ -813,18 +813,7 @@ extern int rb_w32_mprotect(void *, size_t, int);
|
|||||||
|
|
||||||
#define mmap(a, l, p, f, d, o) rb_w32_mmap(a, l, p, f, d, o)
|
#define mmap(a, l, p, f, d, o) rb_w32_mmap(a, l, p, f, d, o)
|
||||||
#define munmap(a, l) rb_w32_munmap(a, l)
|
#define munmap(a, l) rb_w32_munmap(a, l)
|
||||||
|
#define mprotect(a, l, prot) rb_w32_mprotect(a, l, prot)
|
||||||
static inline int
|
|
||||||
mprotect(void *addr, size_t len, int prot)
|
|
||||||
{
|
|
||||||
if (prot | PROT_EXEC) {
|
|
||||||
if (!FlushInstructionCache(GetCurrentProcess(), addr, len)) {
|
|
||||||
errno = rb_w32_map_errno(GetLastError());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -8209,6 +8209,8 @@ void *
|
|||||||
rb_w32_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset)
|
rb_w32_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset)
|
||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
//DWORD protect = 0;
|
||||||
|
DWORD protect = PAGE_EXECUTE_READWRITE;
|
||||||
|
|
||||||
if (fd > 0 || offset) {
|
if (fd > 0 || offset) {
|
||||||
/* not supported */
|
/* not supported */
|
||||||
@ -8216,7 +8218,16 @@ rb_w32_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset)
|
|||||||
return MAP_FAILED;
|
return MAP_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr = VirtualAlloc(addr, len, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
/*
|
||||||
|
if (prot & PROT_EXEC) {
|
||||||
|
if (prot & PROT_WRITE) protect = PAGE_EXECUTE_READWRITE;
|
||||||
|
else if (prot & PROT_READ) protect = PAGE_EXECUTE_READ;
|
||||||
|
else protect = PAGE_EXECUTE;
|
||||||
|
}
|
||||||
|
else if (prot & PROT_WRITE) protect = PAGE_READWRITE;
|
||||||
|
else if (prot & PROT_READ) protect = PAGE_READONLY;
|
||||||
|
*/
|
||||||
|
ptr = VirtualAlloc(addr, len, MEM_RESERVE | MEM_COMMIT, protect);
|
||||||
if (!ptr) {
|
if (!ptr) {
|
||||||
errno = rb_w32_map_errno(GetLastError());
|
errno = rb_w32_map_errno(GetLastError());
|
||||||
return MAP_FAILED;
|
return MAP_FAILED;
|
||||||
@ -8235,3 +8246,29 @@ rb_w32_munmap(void *addr, size_t len)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline int
|
||||||
|
rb_w32_mprotect(void *addr, size_t len, int prot)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
DWORD protect = 0;
|
||||||
|
if (prot & PROT_EXEC) {
|
||||||
|
if (prot & PROT_WRITE) protect = PAGE_EXECUTE_READWRITE;
|
||||||
|
else if (prot & PROT_READ) protect = PAGE_EXECUTE_READ;
|
||||||
|
else protect = PAGE_EXECUTE;
|
||||||
|
}
|
||||||
|
else if (prot & PROT_WRITE) protect = PAGE_READWRITE;
|
||||||
|
else if (prot & PROT_READ) protect = PAGE_READONLY;
|
||||||
|
if (!VirtualProtect(addr, len, protect, NULL)) {
|
||||||
|
errno = rb_w32_map_errno(GetLastError());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
if (prot | PROT_EXEC) {
|
||||||
|
if (!FlushInstructionCache(GetCurrentProcess(), addr, len)) {
|
||||||
|
errno = rb_w32_map_errno(GetLastError());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user