Added BOX64_IGNOREINT3 env. var. to ignore INT3 in the code ([RCFILE] too)

This commit is contained in:
ptitSeb 2024-01-27 20:42:32 +01:00
parent cdffe2388e
commit f9c09293bf
7 changed files with 48 additions and 33 deletions

View File

@ -109,6 +109,11 @@ Will use 32bits address in priority for external MMAP (when 32bits process are d
* 0 : Use regular mmap (default, except for Snapdragron build)
* 1 : Use 32bits address space mmap in priority for external mmap as soon a 32bits process are detected (default for Snapdragon build)
#### BOX64_IGNOREINT3 *
What to do when a CC INT3 opcode is encounter in the code being run
* 0 : Trigger a TRAP signal if a handler is present
* 1 : Just skip silently the opcode
#### BOX64_X11GLX *
Force libX11's GLX extension to be present.
* 0 : Do not force libX11's GLX extension to be present.

View File

@ -2122,23 +2122,21 @@ uintptr_t dynarec64_00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
}
}
} else {
#if 1
INST_NAME("INT 3");
// check if TRAP signal is handled
TABLE64(x1, (uintptr_t)my_context);
MOV32w(x2, offsetof(box64context_t, signals[SIGTRAP]));
LDRx_REG(x3, x1, x2);
//LDRx_U12(x3, x1, offsetof(box64context_t, signals[SIGTRAP]));
CMPSx_U12(x3, 0);
B_NEXT(cEQ);
GETIP(ip);
STORE_XEMU_CALL(xRIP);
CALL(native_int3, -1);
LOAD_XEMU_CALL(xRIP);
if(!box64_ignoreint3) {
// check if TRAP signal is handled
TABLE64(x1, (uintptr_t)my_context);
MOV32w(x2, offsetof(box64context_t, signals[SIGTRAP]));
LDRx_REG(x3, x1, x2);
//LDRx_U12(x3, x1, offsetof(box64context_t, signals[SIGTRAP]));
CMPSx_U12(x3, 0);
B_NEXT(cEQ);
GETIP(ip);
STORE_XEMU_CALL(xRIP);
CALL(native_int3, -1);
LOAD_XEMU_CALL(xRIP);
}
break;
#else
DEFAULT;
#endif
}
break;
case 0xCD:

View File

@ -374,22 +374,20 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int
}
}
} else {
#if 1
INST_NAME("INT 3");
// check if TRAP signal is handled
LD(x1, xEmu, offsetof(x64emu_t, context));
MOV64x(x2, offsetof(box64context_t, signals[SIGTRAP]));
ADD(x2, x2, x1);
LD(x3, x2, 0);
CBZ_NEXT(x3);
GETIP(ip);
STORE_XEMU_CALL(x3);
CALL(native_int3, -1);
LOAD_XEMU_CALL();
if(!box64_ignoreint3) {
INST_NAME("INT 3");
// check if TRAP signal is handled
LD(x1, xEmu, offsetof(x64emu_t, context));
MOV64x(x2, offsetof(box64context_t, signals[SIGTRAP]));
ADD(x2, x2, x1);
LD(x3, x2, 0);
CBZ_NEXT(x3);
GETIP(ip);
STORE_XEMU_CALL(x3);
CALL(native_int3, -1);
LOAD_XEMU_CALL();
}
break;
#else
DEFAULT;
#endif
}
break;
case 0xCD:

View File

@ -358,10 +358,12 @@ void x64Int3(x64emu_t* emu, uintptr_t* addr)
}
return;
}
if(1 && my_context->signals[SIGTRAP])
if(!box64_ignoreint3 && my_context->signals[SIGTRAP])
emit_signal(emu, SIGTRAP, (void*)R_RIP, 128);
else
printf_log(LOG_INFO, "%04d|Warning, ignoring unsupported Int 3 call @%p\n", GetTID(), (void*)R_RIP);
else {
printf_log(LOG_DEBUG, "%04d|Warning, ignoring unsupported Int 3 call @%p\n", GetTID(), (void*)R_RIP);
R_RIP = *addr;
}
//emu->quit = 1;
}

View File

@ -12,6 +12,7 @@ extern uintptr_t box64_load_addr;
extern int box64_dynarec_test;
extern int box64_maxcpu;
extern int box64_mmap32;
extern int box64_ignoreint3;
#ifdef DYNAREC
extern int box64_dynarec_dump;
extern int box64_dynarec_trace;

View File

@ -55,6 +55,7 @@ int box64_maxcpu = 0;
int box64_mmap32 = 1;
#else
int box64_mmap32 = 0;
int box64_ignoreint3 = 0;
#endif
#ifdef DYNAREC
int box64_dynarec = 1;
@ -980,6 +981,15 @@ void LoadLogEnv()
else
printf_log(LOG_INFO, "Will not use 32bits address in priority for external MMAP (when 32bits process are detected)\n");
}
p = getenv("BOX64_IGNOREINT3");
if(p) {
if(strlen(p)==1) {
if(p[0]>='0' && p[0]<='0'+1)
box64_ignoreint3 = p[0]-'0';
}
if(box64_ignoreint3)
printf_log(LOG_INFO, "Will silently ignore INT3 in the code\n");
}
box64_pagesize = sysconf(_SC_PAGESIZE);
if(!box64_pagesize)
box64_pagesize = 4096;

View File

@ -87,6 +87,7 @@ CENTRYBOOL(BOX64_NOSIGILL, no_sigill) \
ENTRYBOOL(BOX64_SHOWSEGV, box64_showsegv) \
ENTRYBOOL(BOX64_SHOWBT, box64_showbt) \
ENTRYBOOL(BOX64_MMAP32, box64_mmap32) \
ENTRYBOOL(BOX64_MMAP32, box64_ignoreint3) \
ENTRYBOOL(BOX64_X11THREADS, box64_x11threads) \
ENTRYBOOL(BOX64_X11GLX, box64_x11glx) \
ENTRYDSTRING(BOX64_LIBGL, box64_libGL) \