1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-22 14:24:33 +01:00

Improve security on OSX and Linux

This commit is contained in:
LRFLEW
2016-01-20 10:11:51 -07:00
parent 414c97ed8c
commit 58d258038f
3 changed files with 19 additions and 7 deletions

View File

@@ -1600,7 +1600,7 @@
"-segprot",
rct2_text,
rwx,
rwx,
rx,
"-sectcreate",
rct2_data,
__data,
@@ -1610,8 +1610,8 @@
0x8a4000,
"-segprot",
rct2_data,
rwx,
rwx,
rw,
rw,
);
PRODUCT_BUNDLE_IDENTIFIER = website.openrct2.OpenRCT2;
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -1646,7 +1646,7 @@
"-segprot",
rct2_text,
rwx,
rwx,
rx,
"-sectcreate",
rct2_data,
__data,
@@ -1656,8 +1656,8 @@
0x8a4000,
"-segprot",
rct2_data,
rwx,
rwx,
rw,
rw,
);
PRODUCT_BUNDLE_IDENTIFIER = website.openrct2.OpenRCT2;
PRODUCT_NAME = "$(TARGET_NAME)";

View File

@@ -242,7 +242,19 @@ void addhook(int address, int newaddress, int stacksize, int registerargs[], int
WriteProcessMemory(GetCurrentProcess(), (LPVOID)address, data, i, 0);
#else
// We own the pages with PROT_WRITE | PROT_EXEC, we can simply just memcpy the data
int err = mprotect((void *)0x401000, 0x8a4000 - 0x401000, PROT_READ | PROT_WRITE);
if (err != 0)
{
perror("mprotect");
}
memcpy((void *)address, data, i);
err = mprotect((void *)0x401000, 0x8a4000 - 0x401000, PROT_READ | PROT_EXEC);
if (err != 0)
{
perror("mprotect");
}
#endif // __WINDOWS__
hookfunc(hookaddress, newaddress, stacksize, registerargs, registersreturned, eaxDestinationRegister);
g_hooktableoffset++;

View File

@@ -548,7 +548,7 @@ bool openrct2_setup_rct2_segment()
log_error("At least one of required pages was not found in memory. This can cause segfaults later on.");
}
// section: text
err = mprotect((void *)0x401000, 0x8a4000 - 0x401000, PROT_READ | PROT_WRITE | PROT_EXEC);
err = mprotect((void *)0x401000, 0x8a4000 - 0x401000, PROT_READ | PROT_EXEC);
if (err != 0)
{
perror("mprotect");