diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2024-11-30 15:07:01 +0100 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2024-11-30 15:07:01 +0100 |
| commit | 2971e9729c3b2ef61ea9568d76ce7064f5c36cac (patch) | |
| tree | 7e112bbfad7499b5198f5cba80012d5e4de71825 /src | |
| parent | 6b2d92304199ac648cc9f1c275fa79795662ba57 (diff) | |
| download | box64-2971e9729c3b2ef61ea9568d76ce7064f5c36cac.tar.gz box64-2971e9729c3b2ef61ea9568d76ce7064f5c36cac.zip | |
[BOX32][WRAPPER] This should fix the build
Diffstat (limited to 'src')
| -rw-r--r-- | src/emu/x86syscall_32.c | 91 | ||||
| -rw-r--r-- | src/wrapped32/generated/functions_list.txt | 4 | ||||
| -rw-r--r-- | src/wrapped32/generated/wrappedlibctypes32.h | 2 | ||||
| -rw-r--r-- | src/wrapped32/generated/wrapper32.c | 4 | ||||
| -rw-r--r-- | src/wrapped32/generated/wrapper32.h | 2 | ||||
| -rwxr-xr-x | src/wrapped32/wrappedlibc_private.h | 2 |
6 files changed, 52 insertions, 53 deletions
diff --git a/src/emu/x86syscall_32.c b/src/emu/x86syscall_32.c index 439a9355..bdf8acbe 100644 --- a/src/emu/x86syscall_32.c +++ b/src/emu/x86syscall_32.c @@ -420,11 +420,10 @@ void EXPORT x86Syscall(x64emu_t *emu) #define u32(n) (uint32_t)stack(n) #define p(n) from_ptrv(stack(n)) -uint32_t EXPORT my32_syscall(x64emu_t *emu, ptr_t* b) +uint32_t EXPORT my32_syscall(x64emu_t *emu, uint32_t s, ptr_t* b) { static uint64_t warned[10] = {0}; - uint32_t s = u32(0); - printf_log(LOG_DEBUG, "%p: Calling libc syscall 0x%02X (%d) %p %p %p %p %p\n", from_ptrv(R_EIP), s, s, from_ptrv(u32(4)), from_ptrv(u32(8)), from_ptrv(u32(12)), from_ptrv(u32(16)), from_ptrv(u32(20))); + printf_log(LOG_DEBUG, "%p: Calling libc syscall 0x%02X (%d) %p %p %p %p %p\n", from_ptrv(R_EIP), s, s, from_ptrv(u32(0)), from_ptrv(u32(4)), from_ptrv(u32(8)), from_ptrv(u32(12)), from_ptrv(u32(16))); // check wrapper first int cnt = sizeof(syscallwrap) / sizeof(scwrap_t); size_t tmps; @@ -435,12 +434,12 @@ uint32_t EXPORT my32_syscall(x64emu_t *emu, ptr_t* b) int sc = syscallwrap[i].nats; switch(syscallwrap[i].nbpars) { case 0: return syscall(sc); - case 1: return syscall(sc, u32(4)); - case 2: return syscall(sc, u32(4), u32(8)); - case 3: return syscall(sc, u32(4), u32(8), u32(12)); - case 4: return syscall(sc, u32(4), u32(8), u32(12), u32(16)); - case 5: return syscall(sc, u32(4), u32(8), u32(12), u32(16), u32(20)); - case 6: return syscall(sc, u32(4), u32(8), u32(12), u32(16), u32(20), u32(24)); + case 1: return syscall(sc, u32(0)); + case 2: return syscall(sc, u32(0), u32(4)); + case 3: return syscall(sc, u32(0), u32(4), u32(8)); + case 4: return syscall(sc, u32(0), u32(4), u32(8), u32(12)); + case 5: return syscall(sc, u32(0), u32(4), u32(8), u32(12), u32(16)); + case 6: return syscall(sc, u32(0), u32(4), u32(8), u32(12), u32(16), u32(20)); default: printf_log(LOG_NONE, "ERROR, Unimplemented syscall wrapper (%d, %d)\n", s, syscallwrap[i].nbpars); emu->quit = 1; @@ -451,30 +450,30 @@ uint32_t EXPORT my32_syscall(x64emu_t *emu, ptr_t* b) switch (s) { case 1: // __NR_exit emu->quit = 1; - return u32(4); // faking the syscall here, we don't want to really terminate the program now + return u32(0); // faking the syscall here, we don't want to really terminate the program now #ifndef __NR_fork case 2: return fork(); #endif case 3: // sys_read - return (uint32_t)to_long(my32_read(i32(4), p(8), u32(12))); + return (uint32_t)to_long(my32_read(i32(0), p(4), u32(8))); case 4: // sys_write - return (uint32_t)to_long(write(i32(4), p(8), u32(12))); + return (uint32_t)to_long(write(i32(0), p(4), u32(8))); case 5: // sys_open - return my_open(emu, p(4), of_convert32(u32(8)), u32(12)); + return my_open(emu, p(0), of_convert32(u32(4)), u32(8)); case 6: // sys_close - return (uint32_t)close(i32(4)); + return (uint32_t)close(i32(0)); case 11: // execve - return (uint32_t)my32_execve(emu, p(4), p(8), p(12)); + return (uint32_t)my32_execve(emu, p(0), p(4), p(8)); case 91: // munmap - return (uint32_t)my32_munmap(emu, p(4), u32(8)); + return (uint32_t)my32_munmap(emu, p(0), u32(4)); #if 0 case 120: // clone // x86 raw syscall is long clone(unsigned long flags, void *stack, int *parent_tid, unsigned long tls, int *child_tid); - // so flags=u(4), stack=p(8), parent_tid=p(12), tls=p(16), child_tid=p(20) - if(p(8)) + // so flags=u(0), stack=p(4), parent_tid=p(8), tls=p(12), child_tid=p(16) + if(p(4)) { - void* stack_base = p(8); + void* stack_base = p(4); int stack_size = 0; if(!stack_base) { // allocate a new stack... @@ -491,7 +490,7 @@ uint32_t EXPORT my32_syscall(x64emu_t *emu, ptr_t* b) memcpy(stack_base+stack_size-size_to_copy, (void*)R_ESP, size_to_copy); } } - x64emu_t * newemu = NewX86Emu(emu->context, R_EIP, (uintptr_t)stack_base, stack_size, (p(8))?0:1); + x64emu_t * newemu = NewX86Emu(emu->context, R_EIP, (uintptr_t)stack_base, stack_size, (p(4))?0:1); SetupX86Emu(newemu); CloneEmu(newemu, emu); Push32(newemu, 0); @@ -506,28 +505,28 @@ uint32_t EXPORT my32_syscall(x64emu_t *emu, ptr_t* b) my32_context->stack_clone_used = 1; } // x86_64 raw clone is long clone(unsigned long flags, void *stack, int *parent_tid, int *child_tid, unsigned long tls); - long ret = clone(clone_fn, (void*)((uintptr_t)mystack+1024*1024), u32(4), newemu, p(12), p(16), p(20)); + long ret = clone(clone_fn, (void*)((uintptr_t)mystack+1024*1024), u32(0), newemu, p(8), p(12), p(16)); return (uint32_t)ret; } else - return (uint32_t)syscall(__NR_clone, u32(4), p(8), p(12), p(16), p(20)); + return (uint32_t)syscall(__NR_clone, u32(0), p(4), p(8), p(12), p(16)); break; case 123: // SYS_modify_ldt - return my32_modify_ldt(emu, i32(4), (thread_area_t*)p(8), i32(12)); + return my32_modify_ldt(emu, i32(0), (thread_area_t*)p(4), i32(8)); case 125: // mprotect - return (uint32_t)my32_mprotect(emu, p(4), u32(8), i32(12)); + return (uint32_t)my32_mprotect(emu, p(0), u32(4), i32(8)); case 174: // sys_rt_sigaction - return (uint32_t)my32_sigaction(emu, i32(4), (x86_sigaction_t*)p(8), (x86_sigaction_t*)p(12)); + return (uint32_t)my32_sigaction(emu, i32(0), (x86_sigaction_t*)p(4), (x86_sigaction_t*)p(8)); #endif case 186: // sigaltstack - return my32_sigaltstack(emu, p(4), p(8)); + return my32_sigaltstack(emu, p(0), p(4)); case 192: // mmap2 - return to_ptrv(my32_mmap64(emu, p(4), u32(8), i32(12), i32(16), i32(20), u32(24))); + return to_ptrv(my32_mmap64(emu, p(0), u32(4), i32(8), i32(12), i32(16), u32(20))); case 240: // futex { struct_LL_t tspec; int need_tspec = 1; - switch(u32(8)&FUTEX_CMD_MASK) { + switch(u32(4)&FUTEX_CMD_MASK) { case FUTEX_WAIT: case FUTEX_WAIT_BITSET: case FUTEX_LOCK_PI: @@ -546,30 +545,30 @@ uint32_t EXPORT my32_syscall(x64emu_t *emu, ptr_t* b) case FUTEX_WAKE: default: need_tspec = 0; } - if(need_tspec && u32(16)) - from_struct_LL(&tspec, u32(16)); + if(need_tspec && u32(12)) + from_struct_LL(&tspec, u32(12)); else need_tspec = 0; - return syscall(__NR_futex, p(4), i32(8), u32(12), need_tspec?(&tspec):p(16), p(20), u32(24)); + return syscall(__NR_futex, p(0), i32(4), u32(8), need_tspec?(&tspec):p(12), p(16), u32(20)); } break; case 243: // set_thread_area - return my_set_thread_area_32(emu, (thread_area_32_t*)p(4)); + return my_set_thread_area_32(emu, (thread_area_32_t*)p(0)); #if 0 case 254: // epoll_create - return my32_epoll_create(emu, i32(4)); + return my32_epoll_create(emu, i32(0)); case 255: // epoll_ctl - return my32_epoll_ctl(emu, i32(4), i32(8), i32(12), p(16)); + return my32_epoll_ctl(emu, i32(0), i32(4), i32(8), p(12)); case 256: // epoll_wait - return my32_epoll_wait(emu, i32(4), p(8), i32(12), i32(16)); + return my32_epoll_wait(emu, i32(0), p(4), i32(8), i32(12)); case 270: //_NR_tgkill - /*if(!u32(12))*/ { - //printf("tgkill(%u, %u, %u) => ", u32(4), u32(8), u32(12)); - uint32_t ret = (uint32_t)syscall(__NR_tgkill, u32(4), u32(8), u32(12)); + /*if(!u32(8))*/ { + //printf("tgkill(%u, %u, %u) => ", u32(0), u32(4), u32(8)); + uint32_t ret = (uint32_t)syscall(__NR_tgkill, u32(0), u32(4), u32(8)); //printf("%u (errno=%d)\n", ret, (ret==(uint32_t)-1)?errno:0); return ret; }/* else { - printf_log(LOG_INFO, "Warning: ignoring libc Syscall tgkill (%u, %u, %u)\n", u32(4), u32(8), u32(12)); + printf_log(LOG_INFO, "Warning: ignoring libc Syscall tgkill (%u, %u, %u)\n", u32(0), u32(4), u32(8)); }*/ return 0; #endif @@ -578,11 +577,11 @@ uint32_t EXPORT my32_syscall(x64emu_t *emu, ptr_t* b) // will wrap only head for now static uint8_t i386_nothing[0x14] = {0}; // for faking steamcmd use of get_robust_list static struct i386_robust_list_head h; - ulong_t *arg2 = p(12); - ptr_t* arg1 = p(8); + ulong_t *arg2 = p(8); + ptr_t* arg1 = p(4); tmp = arg1?(from_ptrv(*arg1)):NULL; tmps = arg2?(from_ulong(*arg2)):0; - ret = syscall(__NR_get_robust_list, u32(4), arg1?(&tmp):NULL, arg2?(&tmps):NULL); + ret = syscall(__NR_get_robust_list, u32(0), arg1?(&tmp):NULL, arg2?(&tmps):NULL); if(!ret) { if(box64_steamcmd || 1) { h.list.next = to_ptrv(&h); @@ -605,21 +604,21 @@ uint32_t EXPORT my32_syscall(x64emu_t *emu, ptr_t* b) #if 0 #ifndef NOALIGN case 329: // epoll_create1 - return my32_epoll_create1(emu, of_convert32(i32(4))); + return my32_epoll_create1(emu, of_convert32(i32(0))); #endif #ifndef __NR_getrandom case 355: // getrandom - return (uint32_t)my32_getrandom(emu, p(4), u32(8), u32(12)); + return (uint32_t)my32_getrandom(emu, p(0), u32(4), u32(8)); #endif #ifndef __NR_memfd_create case 356: // memfd_create - return (uint32_t)my32_memfd_create(emu, p(4), u32(8)); + return (uint32_t)my32_memfd_create(emu, p(0), u32(4)); #endif #endif case 449: #ifdef __NR_futex_waitv if(box64_futex_waitv) - return syscall(__NR_futex_waitv, u32(4), u32(8), u32(12), u32(16), u32(20)); + return syscall(__NR_futex_waitv, u32(0), u32(4), u32(8), u32(12), u32(16)); else #endif { diff --git a/src/wrapped32/generated/functions_list.txt b/src/wrapped32/generated/functions_list.txt index 334bc9d2..06ae1193 100644 --- a/src/wrapped32/generated/functions_list.txt +++ b/src/wrapped32/generated/functions_list.txt @@ -274,7 +274,6 @@ #() dEll -> dEll #() dFpp -> dFpp #() lEEi -> lEEi -#() lEEV -> lEEV #() lEES -> lEES #() lEii -> lEii #() lFiL -> lFiL @@ -570,6 +569,7 @@ #() fEffp -> fEffp #() dEddd -> dEddd #() dEddp -> dEddp +#() lEEuV -> lEEuV #() lEili -> lEili #() lEipL -> lEipL #() lFlll -> lFlll @@ -1743,7 +1743,6 @@ wrappedlibc: - sysconf - lEp: - atol -- lEV: - lES: - ftell - LEL: @@ -1808,6 +1807,7 @@ wrappedlibc: - ldexpl - KFKp: - frexpl +- lEuV: - pEip: - signal - pELL: diff --git a/src/wrapped32/generated/wrappedlibctypes32.h b/src/wrapped32/generated/wrappedlibctypes32.h index 97cbd7bb..61534ccc 100644 --- a/src/wrapped32/generated/wrappedlibctypes32.h +++ b/src/wrapped32/generated/wrappedlibctypes32.h @@ -24,7 +24,6 @@ typedef uint32_t (*uES_t)(void*); typedef uint64_t (*UEp_t)(void*); typedef intptr_t (*lEi_t)(int32_t); typedef intptr_t (*lEp_t)(void*); -typedef intptr_t (*lEV_t)(...); typedef intptr_t (*lES_t)(void*); typedef uintptr_t (*LEL_t)(uintptr_t); typedef void* (*pEv_t)(void); @@ -53,6 +52,7 @@ typedef int64_t (*IEII_t)(int64_t, int64_t); typedef uint64_t (*UEUU_t)(uint64_t, uint64_t); typedef double (*KFKi_t)(double, int32_t); typedef double (*KFKp_t)(double, void*); +typedef intptr_t (*lEuV_t)(uint32_t, ...); typedef void* (*pEip_t)(int32_t, void*); typedef void* (*pELL_t)(uintptr_t, uintptr_t); typedef void* (*pEpi_t)(void*, int32_t); diff --git a/src/wrapped32/generated/wrapper32.c b/src/wrapped32/generated/wrapper32.c index 71201273..9637a55c 100644 --- a/src/wrapped32/generated/wrapper32.c +++ b/src/wrapped32/generated/wrapper32.c @@ -365,7 +365,6 @@ typedef double (*dEdp_t)(double, void*); typedef double (*dEll_t)(intptr_t, intptr_t); typedef double (*dFpp_t)(void*, void*); typedef intptr_t (*lEEi_t)(x64emu_t*, int32_t); -typedef intptr_t (*lEEV_t)(x64emu_t*, void*); typedef intptr_t (*lEES_t)(x64emu_t*, void*); typedef intptr_t (*lEii_t)(int32_t, int32_t); typedef intptr_t (*lFiL_t)(int32_t, uintptr_t); @@ -661,6 +660,7 @@ typedef float (*fEfff_t)(float, float, float); typedef float (*fEffp_t)(float, float, void*); typedef double (*dEddd_t)(double, double, double); typedef double (*dEddp_t)(double, double, void*); +typedef intptr_t (*lEEuV_t)(x64emu_t*, uint32_t, void*); typedef intptr_t (*lEili_t)(int32_t, intptr_t, int32_t); typedef intptr_t (*lEipL_t)(int32_t, void*, uintptr_t); typedef intptr_t (*lFlll_t)(intptr_t, intptr_t, intptr_t); @@ -2004,7 +2004,6 @@ void dEdp_32(x64emu_t *emu, uintptr_t fcn) { dEdp_t fn = (dEdp_t)fcn; errno = em void dEll_32(x64emu_t *emu, uintptr_t fcn) { dEll_t fn = (dEll_t)fcn; errno = emu->libc_err; double db = fn(from_long(from_ptri(long_t, R_ESP + 4)), from_long(from_ptri(long_t, R_ESP + 8))); fpu_do_push(emu); ST0val = db; emu->libc_err = errno; } void dFpp_32(x64emu_t *emu, uintptr_t fcn) { dFpp_t fn = (dFpp_t)fcn; double db = fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8)); fpu_do_push(emu); ST0val = db; } void lEEi_32(x64emu_t *emu, uintptr_t fcn) { lEEi_t fn = (lEEi_t)fcn; errno = emu->libc_err; R_EAX = to_long(fn(emu, from_ptri(int32_t, R_ESP + 4))); emu->libc_err = errno; } -void lEEV_32(x64emu_t *emu, uintptr_t fcn) { lEEV_t fn = (lEEV_t)fcn; errno = emu->libc_err; R_EAX = to_long(fn(emu, from_ptrv(R_ESP + 4))); emu->libc_err = errno; } void lEES_32(x64emu_t *emu, uintptr_t fcn) { lEES_t fn = (lEES_t)fcn; errno = emu->libc_err; R_EAX = to_long(fn(emu, io_convert32(from_ptriv(R_ESP + 4)))); emu->libc_err = errno; } void lEii_32(x64emu_t *emu, uintptr_t fcn) { lEii_t fn = (lEii_t)fcn; errno = emu->libc_err; R_EAX = to_long(fn(from_ptri(int32_t, R_ESP + 4), from_ptri(int32_t, R_ESP + 8))); emu->libc_err = errno; } void lFiL_32(x64emu_t *emu, uintptr_t fcn) { lFiL_t fn = (lFiL_t)fcn; R_EAX = to_long(fn(from_ptri(int32_t, R_ESP + 4), from_ulong(from_ptri(ulong_t, R_ESP + 8)))); } @@ -2300,6 +2299,7 @@ void fEfff_32(x64emu_t *emu, uintptr_t fcn) { fEfff_t fn = (fEfff_t)fcn; errno = void fEffp_32(x64emu_t *emu, uintptr_t fcn) { fEffp_t fn = (fEffp_t)fcn; errno = emu->libc_err; float fl = fn(from_ptri(float, R_ESP + 4), from_ptri(float, R_ESP + 8), from_ptriv(R_ESP + 12)); fpu_do_push(emu); ST0val = fl; emu->libc_err = errno; } void dEddd_32(x64emu_t *emu, uintptr_t fcn) { dEddd_t fn = (dEddd_t)fcn; errno = emu->libc_err; double db = fn(from_ptri(double, R_ESP + 4), from_ptri(double, R_ESP + 12), from_ptri(double, R_ESP + 20)); fpu_do_push(emu); ST0val = db; emu->libc_err = errno; } void dEddp_32(x64emu_t *emu, uintptr_t fcn) { dEddp_t fn = (dEddp_t)fcn; errno = emu->libc_err; double db = fn(from_ptri(double, R_ESP + 4), from_ptri(double, R_ESP + 12), from_ptriv(R_ESP + 20)); fpu_do_push(emu); ST0val = db; emu->libc_err = errno; } +void lEEuV_32(x64emu_t *emu, uintptr_t fcn) { lEEuV_t fn = (lEEuV_t)fcn; errno = emu->libc_err; R_EAX = to_long(fn(emu, from_ptri(uint32_t, R_ESP + 4), from_ptrv(R_ESP + 8))); emu->libc_err = errno; } void lEili_32(x64emu_t *emu, uintptr_t fcn) { lEili_t fn = (lEili_t)fcn; errno = emu->libc_err; R_EAX = to_long(fn(from_ptri(int32_t, R_ESP + 4), from_long(from_ptri(long_t, R_ESP + 8)), from_ptri(int32_t, R_ESP + 12))); emu->libc_err = errno; } void lEipL_32(x64emu_t *emu, uintptr_t fcn) { lEipL_t fn = (lEipL_t)fcn; errno = emu->libc_err; R_EAX = to_long(fn(from_ptri(int32_t, R_ESP + 4), from_ptriv(R_ESP + 8), from_ulong(from_ptri(ulong_t, R_ESP + 12)))); emu->libc_err = errno; } void lFlll_32(x64emu_t *emu, uintptr_t fcn) { lFlll_t fn = (lFlll_t)fcn; R_EAX = to_long(fn(from_long(from_ptri(long_t, R_ESP + 4)), from_long(from_ptri(long_t, R_ESP + 8)), from_long(from_ptri(long_t, R_ESP + 12)))); } diff --git a/src/wrapped32/generated/wrapper32.h b/src/wrapped32/generated/wrapper32.h index 650d4791..51252ca4 100644 --- a/src/wrapped32/generated/wrapper32.h +++ b/src/wrapped32/generated/wrapper32.h @@ -315,7 +315,6 @@ void dEdp_32(x64emu_t *emu, uintptr_t fnc); void dEll_32(x64emu_t *emu, uintptr_t fnc); void dFpp_32(x64emu_t *emu, uintptr_t fnc); void lEEi_32(x64emu_t *emu, uintptr_t fnc); -void lEEV_32(x64emu_t *emu, uintptr_t fnc); void lEES_32(x64emu_t *emu, uintptr_t fnc); void lEii_32(x64emu_t *emu, uintptr_t fnc); void lFiL_32(x64emu_t *emu, uintptr_t fnc); @@ -611,6 +610,7 @@ void fEfff_32(x64emu_t *emu, uintptr_t fnc); void fEffp_32(x64emu_t *emu, uintptr_t fnc); void dEddd_32(x64emu_t *emu, uintptr_t fnc); void dEddp_32(x64emu_t *emu, uintptr_t fnc); +void lEEuV_32(x64emu_t *emu, uintptr_t fnc); void lEili_32(x64emu_t *emu, uintptr_t fnc); void lEipL_32(x64emu_t *emu, uintptr_t fnc); void lFlll_32(x64emu_t *emu, uintptr_t fnc); diff --git a/src/wrapped32/wrappedlibc_private.h b/src/wrapped32/wrappedlibc_private.h index a74f57c4..6b0fac79 100755 --- a/src/wrapped32/wrappedlibc_private.h +++ b/src/wrapped32/wrappedlibc_private.h @@ -1781,7 +1781,7 @@ GO(symlinkat, iEpip) GO(sync, vEv) GO(syncfs, iEi) // sync_file_range -GOM(syscall, lEEV) //%% +GOM(syscall, lEEuV) //%% GOW2(sysconf, lEEi, my_sysconf) GO2(__sysconf, lEEi, my_sysconf) // sysctl // Weak |