mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Added a new value to AllowUnsafeScripting
* for disabling the memory address check in write_xxx unsafe functions.
This commit is contained in:
@@ -770,6 +770,7 @@ SkipSizeCheck=0
|
||||
DontDeleteProtos=0
|
||||
|
||||
;Set to 1 to give scripts direct access to Fallout's address space, and to make arbitrary calls into Fallout's code
|
||||
;Set to 2 to also disable the memory address check in unsafe script functions
|
||||
;Does not require sfall debugging mode
|
||||
AllowUnsafeScripting=0
|
||||
|
||||
|
||||
@@ -1791,7 +1791,8 @@ void ScriptExtenderInit() {
|
||||
|
||||
SetExtraKillCounter(UsingExtraKillTypes());
|
||||
|
||||
if (iniGetInt("Debugging", "AllowUnsafeScripting", 0, ddrawIniDef)) {
|
||||
if (int unsafe = iniGetInt("Debugging", "AllowUnsafeScripting", 0, ddrawIniDef)) {
|
||||
if (unsafe == 2) checkValidMemAddr = false;
|
||||
dlogr(" Unsafe opcodes enabled.", DL_SCRIPT);
|
||||
opcodes[0x1cf] = WriteByte;
|
||||
opcodes[0x1d0] = WriteShort;
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#define START_VALID_ADDR 0x410000
|
||||
#define END_VALID_ADDR 0x6B403F
|
||||
|
||||
bool checkValidMemAddr = true;
|
||||
|
||||
// memory_reading_funcs
|
||||
static void __declspec(naked) ReadByte() {
|
||||
__asm {
|
||||
@@ -102,10 +104,13 @@ static void __declspec(naked) WriteByte() {
|
||||
cmp cx, VAR_TYPE_INT;
|
||||
jnz end;
|
||||
// check valid addr
|
||||
cmp checkValidMemAddr, 0;
|
||||
jz noCheck;
|
||||
cmp eax, START_VALID_ADDR;
|
||||
jb end;
|
||||
cmp eax, END_VALID_ADDR;
|
||||
ja end;
|
||||
noCheck:
|
||||
and esi, 0xFF;
|
||||
push esi;
|
||||
push eax;
|
||||
@@ -129,10 +134,13 @@ static void __declspec(naked) WriteShort() {
|
||||
cmp cx, VAR_TYPE_INT;
|
||||
jnz end;
|
||||
// check valid addr
|
||||
cmp checkValidMemAddr, 0;
|
||||
jz noCheck;
|
||||
cmp eax, START_VALID_ADDR;
|
||||
jb end;
|
||||
cmp eax, END_VALID_ADDR;
|
||||
ja end;
|
||||
noCheck:
|
||||
and esi, 0xFFFF;
|
||||
push esi;
|
||||
push eax;
|
||||
@@ -156,10 +164,13 @@ static void __declspec(naked) WriteInt() {
|
||||
cmp cx, VAR_TYPE_INT;
|
||||
jnz end;
|
||||
// check valid addr
|
||||
cmp checkValidMemAddr, 0;
|
||||
jz noCheck;
|
||||
cmp eax, START_VALID_ADDR;
|
||||
jb end;
|
||||
cmp eax, END_VALID_ADDR;
|
||||
ja end;
|
||||
noCheck:
|
||||
push esi;
|
||||
push eax;
|
||||
call SafeWrite32;
|
||||
@@ -196,10 +207,13 @@ next:
|
||||
// ecx - type, esi - value
|
||||
// edx - type, eax - addr
|
||||
// check valid address
|
||||
cmp checkValidMemAddr, 0;
|
||||
jz noCheck;
|
||||
cmp eax, START_VALID_ADDR;
|
||||
jb end;
|
||||
cmp eax, END_VALID_ADDR;
|
||||
ja end;
|
||||
noCheck:
|
||||
push ebx; // script
|
||||
push esi; // str value
|
||||
mov edx, ecx; // type
|
||||
|
||||
Reference in New Issue
Block a user