From 0f9dac511cd1f6226a83e456bacdb139c3b6041b Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sat, 28 Sep 2024 15:58:29 +0200 Subject: [PATCH] [BOX32][WRAPPER] Added some more 32bits libc functions --- src/wrapped32/generated/functions_list.txt | 4 +++ src/wrapped32/generated/wrappedlibctypes32.h | 2 ++ src/wrapped32/generated/wrapper32.c | 4 +++ src/wrapped32/generated/wrapper32.h | 2 ++ src/wrapped32/wrappedcrashhandler.c | 2 +- src/wrapped32/wrappedlibc.c | 31 ++++++++++++++++++++ src/wrapped32/wrappedlibc_private.h | 12 ++++---- 7 files changed, 50 insertions(+), 7 deletions(-) diff --git a/src/wrapped32/generated/functions_list.txt b/src/wrapped32/generated/functions_list.txt index 098f50156..37cbfa69d 100644 --- a/src/wrapped32/generated/functions_list.txt +++ b/src/wrapped32/generated/functions_list.txt @@ -146,6 +146,7 @@ #() iFhi -> iFhi #() iFhp -> iFhp #() iFhh -> iFhh +#() iFSU -> iFSU #() iFSp -> iFSp #() iFXi -> iFXi #() iFXL -> iFXL @@ -547,6 +548,7 @@ #() iFiill -> iFiill #() iFiuui -> iFiuui #() iFipii -> iFipii +#() iFipui -> iFipui #() iFipup -> iFipup #() iFippi -> iFippi #() iFuiup -> iFuiup @@ -1253,6 +1255,8 @@ wrappedlibc: - iFivpV: - iFiiip: - iFipii: +- iFippi: + - utimensat - iFLLLL: - iFpipp: - iFpupV: diff --git a/src/wrapped32/generated/wrappedlibctypes32.h b/src/wrapped32/generated/wrappedlibctypes32.h index 2c18f2a75..b0c5f5770 100644 --- a/src/wrapped32/generated/wrappedlibctypes32.h +++ b/src/wrapped32/generated/wrappedlibctypes32.h @@ -74,6 +74,7 @@ typedef void (*vFpppp_t)(void*, void*, void*, void*); typedef int32_t (*iFivpV_t)(int32_t, void, void*, ...); typedef int32_t (*iFiiip_t)(int32_t, int32_t, int32_t, void*); typedef int32_t (*iFipii_t)(int32_t, void*, int32_t, int32_t); +typedef int32_t (*iFippi_t)(int32_t, void*, void*, int32_t); typedef int32_t (*iFLLLL_t)(uintptr_t, uintptr_t, uintptr_t, uintptr_t); typedef int32_t (*iFpipp_t)(void*, int32_t, void*, void*); typedef int32_t (*iFpupV_t)(void*, uint32_t, void*, ...); @@ -149,6 +150,7 @@ typedef void* (*pFiiiiiiiiilt_t)(int32_t, int32_t, int32_t, int32_t, int32_t, in GO(writev, lFipi_t) \ GO(__realpath_chk, pFppv_t) \ GO(__libc_init, vFpppp_t) \ + GO(utimensat, iFippi_t) \ GO(getaddrinfo, iFpppp_t) \ GO(getgrgid_r, iFuppup_t) \ GO(getpwuid_r, iFuppLp_t) \ diff --git a/src/wrapped32/generated/wrapper32.c b/src/wrapped32/generated/wrapper32.c index b34d68c11..f34dce59b 100644 --- a/src/wrapped32/generated/wrapper32.c +++ b/src/wrapped32/generated/wrapper32.c @@ -236,6 +236,7 @@ typedef int32_t (*iFpS_t)(void*, void*); typedef int32_t (*iFhi_t)(uintptr_t, int32_t); typedef int32_t (*iFhp_t)(uintptr_t, void*); typedef int32_t (*iFhh_t)(uintptr_t, uintptr_t); +typedef int32_t (*iFSU_t)(void*, uint64_t); typedef int32_t (*iFSp_t)(void*, void*); typedef int32_t (*iFXi_t)(void*, int32_t); typedef int32_t (*iFXL_t)(void*, uintptr_t); @@ -637,6 +638,7 @@ typedef int32_t (*iFiiiN_t)(int32_t, int32_t, int32_t, ...); typedef int32_t (*iFiill_t)(int32_t, int32_t, intptr_t, intptr_t); typedef int32_t (*iFiuui_t)(int32_t, uint32_t, uint32_t, int32_t); typedef int32_t (*iFipii_t)(int32_t, void*, int32_t, int32_t); +typedef int32_t (*iFipui_t)(int32_t, void*, uint32_t, int32_t); typedef int32_t (*iFipup_t)(int32_t, void*, uint32_t, void*); typedef int32_t (*iFippi_t)(int32_t, void*, void*, int32_t); typedef int32_t (*iFuiup_t)(uint32_t, int32_t, uint32_t, void*); @@ -1310,6 +1312,7 @@ void iFpS_32(x64emu_t *emu, uintptr_t fcn) { iFpS_t fn = (iFpS_t)fcn; R_EAX = fn void iFhi_32(x64emu_t *emu, uintptr_t fcn) { iFhi_t fn = (iFhi_t)fcn; R_EAX = fn(from_hash(from_ptri(ptr_t, R_ESP + 4)), from_ptri(int32_t, R_ESP + 8)); } void iFhp_32(x64emu_t *emu, uintptr_t fcn) { iFhp_t fn = (iFhp_t)fcn; R_EAX = fn(from_hash(from_ptri(ptr_t, R_ESP + 4)), from_ptriv(R_ESP + 8)); } void iFhh_32(x64emu_t *emu, uintptr_t fcn) { iFhh_t fn = (iFhh_t)fcn; R_EAX = fn(from_hash(from_ptri(ptr_t, R_ESP + 4)), from_hash(from_ptri(ptr_t, R_ESP + 8))); } +void iFSU_32(x64emu_t *emu, uintptr_t fcn) { iFSU_t fn = (iFSU_t)fcn; R_EAX = fn(io_convert32(from_ptriv(R_ESP + 4)), from_ptri(uint64_t, R_ESP + 8)); } void iFSp_32(x64emu_t *emu, uintptr_t fcn) { iFSp_t fn = (iFSp_t)fcn; R_EAX = fn(io_convert32(from_ptriv(R_ESP + 4)), from_ptriv(R_ESP + 8)); } void iFXi_32(x64emu_t *emu, uintptr_t fcn) { iFXi_t fn = (iFXi_t)fcn; R_EAX = fn(getDisplay(from_ptriv(R_ESP + 4)), from_ptri(int32_t, R_ESP + 8)); } void iFXL_32(x64emu_t *emu, uintptr_t fcn) { iFXL_t fn = (iFXL_t)fcn; R_EAX = fn(getDisplay(from_ptriv(R_ESP + 4)), to_ulong(from_ptri(ulong_t, R_ESP + 8))); } @@ -1711,6 +1714,7 @@ void iFiiiN_32(x64emu_t *emu, uintptr_t fcn) { iFiiiN_t fn = (iFiiiN_t)fcn; R_EA void iFiill_32(x64emu_t *emu, uintptr_t fcn) { iFiill_t fn = (iFiill_t)fcn; R_EAX = fn(from_ptri(int32_t, R_ESP + 4), from_ptri(int32_t, R_ESP + 8), to_long(from_ptri(long_t, R_ESP + 12)), to_long(from_ptri(long_t, R_ESP + 16))); } void iFiuui_32(x64emu_t *emu, uintptr_t fcn) { iFiuui_t fn = (iFiuui_t)fcn; R_EAX = fn(from_ptri(int32_t, R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptri(uint32_t, R_ESP + 12), from_ptri(int32_t, R_ESP + 16)); } void iFipii_32(x64emu_t *emu, uintptr_t fcn) { iFipii_t fn = (iFipii_t)fcn; R_EAX = fn(from_ptri(int32_t, R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(int32_t, R_ESP + 12), from_ptri(int32_t, R_ESP + 16)); } +void iFipui_32(x64emu_t *emu, uintptr_t fcn) { iFipui_t fn = (iFipui_t)fcn; R_EAX = fn(from_ptri(int32_t, R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(uint32_t, R_ESP + 12), from_ptri(int32_t, R_ESP + 16)); } void iFipup_32(x64emu_t *emu, uintptr_t fcn) { iFipup_t fn = (iFipup_t)fcn; R_EAX = fn(from_ptri(int32_t, R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(uint32_t, R_ESP + 12), from_ptriv(R_ESP + 16)); } void iFippi_32(x64emu_t *emu, uintptr_t fcn) { iFippi_t fn = (iFippi_t)fcn; R_EAX = fn(from_ptri(int32_t, R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptri(int32_t, R_ESP + 16)); } void iFuiup_32(x64emu_t *emu, uintptr_t fcn) { iFuiup_t fn = (iFuiup_t)fcn; R_EAX = fn(from_ptri(uint32_t, R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptri(uint32_t, R_ESP + 12), from_ptriv(R_ESP + 16)); } diff --git a/src/wrapped32/generated/wrapper32.h b/src/wrapped32/generated/wrapper32.h index a299aa231..05dafa24f 100644 --- a/src/wrapped32/generated/wrapper32.h +++ b/src/wrapped32/generated/wrapper32.h @@ -187,6 +187,7 @@ void iFpS_32(x64emu_t *emu, uintptr_t fnc); void iFhi_32(x64emu_t *emu, uintptr_t fnc); void iFhp_32(x64emu_t *emu, uintptr_t fnc); void iFhh_32(x64emu_t *emu, uintptr_t fnc); +void iFSU_32(x64emu_t *emu, uintptr_t fnc); void iFSp_32(x64emu_t *emu, uintptr_t fnc); void iFXi_32(x64emu_t *emu, uintptr_t fnc); void iFXL_32(x64emu_t *emu, uintptr_t fnc); @@ -588,6 +589,7 @@ void iFiiiN_32(x64emu_t *emu, uintptr_t fnc); void iFiill_32(x64emu_t *emu, uintptr_t fnc); void iFiuui_32(x64emu_t *emu, uintptr_t fnc); void iFipii_32(x64emu_t *emu, uintptr_t fnc); +void iFipui_32(x64emu_t *emu, uintptr_t fnc); void iFipup_32(x64emu_t *emu, uintptr_t fnc); void iFippi_32(x64emu_t *emu, uintptr_t fnc); void iFuiup_32(x64emu_t *emu, uintptr_t fnc); diff --git a/src/wrapped32/wrappedcrashhandler.c b/src/wrapped32/wrappedcrashhandler.c index 2a2052988..8e8e68fa1 100755 --- a/src/wrapped32/wrappedcrashhandler.c +++ b/src/wrapped32/wrappedcrashhandler.c @@ -21,7 +21,7 @@ static const char* crashhandlerName = "crashhandler.so"; #define LIBNAME crashhandler #define PRE_INIT \ - if(!(box64_steam || box64_steamcmd)) \ + if(!box64_dummy_crashhandler) \ return -1; \ if(1) \ lib->w.lib = dlopen(NULL, RTLD_LAZY | RTLD_GLOBAL);\ diff --git a/src/wrapped32/wrappedlibc.c b/src/wrapped32/wrappedlibc.c index 21381bd83..5691421a5 100755 --- a/src/wrapped32/wrappedlibc.c +++ b/src/wrapped32/wrappedlibc.c @@ -2061,6 +2061,37 @@ EXPORT void* my32_asctime(void* t) return &ret; } +EXPORT int my32_utimensat(int dirfd, void* name, void* times, int flags) +{ + struct timespec times_l[2] = {0}; + from_struct_LL((struct_LL_t*)×_l[0], to_ptrv(times)); + from_struct_LL((struct_LL_t*)×_l[1], to_ptrv(times)+8); + return utimensat(dirfd, name, times_l, flags); +} + + +struct mallinfo { + int arena; + int ordblks; + int smblks; + int hblks; + int hblkhd; + int usmblks; + int fsmblks; + int uordblks; + int fordblks; + int keepcost; +}; +EXPORT void* my32_mallinfo(x86emu_t* emu, void* p) +{ + (void)emu; + static struct mallinfo(*p_mallinfo)() = NULL; + if(!p_mallinfo) p_mallinfo = dlsym(NULL, "mallinfo"); + *((struct mallinfo*)p) = p_mallinfo(); + return p; +} + + #if 0 EXPORT int32_t my32_getrandom(x64emu_t* emu, void* buf, uint32_t buflen, uint32_t flags) { diff --git a/src/wrapped32/wrappedlibc_private.h b/src/wrapped32/wrappedlibc_private.h index 03bc0193f..a4b332719 100755 --- a/src/wrapped32/wrappedlibc_private.h +++ b/src/wrapped32/wrappedlibc_private.h @@ -105,7 +105,7 @@ GOWM(backtrace_symbols, pFEpi) // bdflush GOW(bind, iFipu) // bindresvport -//GOW(bindtextdomain, pFpp) +GOW(bindtextdomain, pFpp) GOW(bind_textdomain_codeset, pFpp) //GOW(brk, iFp) // __bsd_getpgrp @@ -187,7 +187,7 @@ GOM(__cxa_atexit, iFEppp) //%% GOM(atexit, iFEp) //%% just in case GOM(__cxa_finalize, vFEp) //%% DATAM(__cpu_model, 16) -//GOM(__cxa_thread_atexit_impl, iFEppp) //%% +GOM(__cxa_thread_atexit_impl, iFEppp) //%% // __cyg_profile_func_enter // __cyg_profile_func_exit // daemon @@ -302,7 +302,7 @@ GO(faccessat, iFipii) GOW(fchdir, iFi) // fchflags GOW(fchmod, iFiu) -//GO(fchmodat, iFipui) +GO(fchmodat, iFipui) GOW(fchown, iFiuu) //GO(fchownat, iFipuii) GO(fclose, iFS) @@ -527,7 +527,7 @@ GO(getnameinfo, iFpupLpLi) // getnetgrent // getnetgrent_r // Weak // getnetname -//GOW(get_nprocs, iFv) +GOW(get_nprocs, iFv) //GOW(get_nprocs_conf, iFv) //GOM(getopt, iFipp) //%noE //GOM(getopt_long, iFipppp) //%noE @@ -1835,7 +1835,7 @@ GO(__towupper_l, iFia) GOW(towupper_l, iFia) // tr_break //GOW(truncate, iFpu) -//GO(truncate64, iFpU) +GO(truncate64, iFSU) // tsearch // Weak //GO(ttyname, pFi) //GOW(ttyname_r, iFipu) @@ -1870,7 +1870,7 @@ GO(__uselocale, aFa) GO(usleep, iFu) // ustat GO(utime, iFprLL_) -//GO(utimensat, iFippi) +GOM(utimensat, iFippi) //%noE GOWM(utimes, iFEpp) //GOW(utmpname, iFp) // utmpxname