diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2024-09-14 17:36:45 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2024-09-14 17:36:45 +0200 |
| commit | 9fa43f2386b6ee9370e69eda7f8023cf857f0bb9 (patch) | |
| tree | dbb81791df55192dea635e4e7b26b37c1949c8ba | |
| parent | f2397256e2942500f6a7577c103bdb6fb3a98ac7 (diff) | |
| download | box64-9fa43f2386b6ee9370e69eda7f8023cf857f0bb9.tar.gz box64-9fa43f2386b6ee9370e69eda7f8023cf857f0bb9.zip | |
Added a hack so program that wprintf to the console actualy work if box64 already printed something
| -rw-r--r-- | src/core.c | 7 | ||||
| -rw-r--r-- | src/wrapped/wrappedlibc.c | 7 | ||||
| -rwxr-xr-x | src/wrapped32/wrappedlibc.c | 7 |
3 files changed, 20 insertions, 1 deletions
diff --git a/src/core.c b/src/core.c index 91223596..2e91eef2 100644 --- a/src/core.c +++ b/src/core.c @@ -46,6 +46,7 @@ int box64_exit_code = 0; int box64_log = LOG_INFO; //LOG_NONE; int box64_dump = 0; int box64_nobanner = 0; +int box64_stdout_no_w = 0; int box64_dynarec_log = LOG_NONE; uintptr_t box64_pagesize; uintptr_t box64_load_addr = 0; @@ -252,8 +253,10 @@ void openFTrace(const char* newtrace) ftrace_name = strdup(p); /*fclose(ftrace); ftrace = NULL;*/ - if(!box64_nobanner) + if(!box64_nobanner) { printf("BOX64 Trace %s to \"%s\"\n", append?"appended":"redirected", p); + box64_stdout_no_w = 1; + } PrintBox64Version(); } } @@ -611,6 +614,8 @@ void LoadLogEnv() if(!box64_nobanner) printf_log(LOG_INFO, "Debug level is %d\n", box64_log); } + if((box64_nobanner || box64_log) && ftrace==stdout) + box64_stdout_no_w = 1; #if !defined(DYNAREC) && (defined(ARM64) || defined(RV64) || defined(LA64)) printf_log(LOG_INFO, "Warning: DynaRec is available on this host architecture, an interpreter-only build is probably not intended.\n"); diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c index 72de9c7d..cd95351f 100644 --- a/src/wrapped/wrappedlibc.c +++ b/src/wrapped/wrappedlibc.c @@ -695,9 +695,16 @@ EXPORT int my___printf_chk(x64emu_t *emu, int chk, void* fmt, void* b) PREPARE_VALIST; return vprintf((const char*)fmt, VARARGS); } +extern int box64_stdout_no_w; EXPORT int my_wprintf(x64emu_t *emu, void* fmt, void* b) { myStackAlignW(emu, (const char*)fmt, b, emu->scratch, R_EAX, 1); PREPARE_VALIST; + if(box64_stdout_no_w) { + wchar_t buff[2048]; + int ret = vswprintf(buff, 2047, fmt, VARARGS); + printf("%S", buff); + return ret; + } return vwprintf((const wchar_t*)fmt, VARARGS); } EXPORT int my___wprintf_chk(x64emu_t *emu, int chk, void* fmt, void* b) diff --git a/src/wrapped32/wrappedlibc.c b/src/wrapped32/wrappedlibc.c index e4b1ed82..8d387f91 100755 --- a/src/wrapped32/wrappedlibc.c +++ b/src/wrapped32/wrappedlibc.c @@ -728,10 +728,17 @@ EXPORT int my32_fprintf(x64emu_t *emu, void* F, void* fmt, void* V) { return vfprintf(F, fmt, VARARGS_32); } EXPORT int my32___fprintf_chk(x64emu_t *emu, void* F, void* fmt, void* V) __attribute__((alias("my32_fprintf"))); +extern int box64_stdout_no_w; EXPORT int my32_wprintf(x64emu_t *emu, void* fmt, void* V) { // need to align on arm myStackAlignW32((const char*)fmt, V, emu->scratch); PREPARE_VALIST_32; + if(box64_stdout_no_w) { + wchar_t buff[2048]; + int ret = vswprintf(buff, 2047, fmt, VARARGS_32); + printf("%S", buff); + return ret; + } return vwprintf(fmt, VARARGS_32); } #if 0 |