diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2021-10-26 19:03:03 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2021-10-26 19:03:03 +0200 |
| commit | da81ba5be8fbc1231a47d7dcc7bea2d467c1a80e (patch) | |
| tree | d1c295ddf9a0d7b8b95292cc6bd35b7ba15f7ba1 /src | |
| parent | f81874277c11938ae049daf9fd7e25fd21765c11 (diff) | |
| download | box64-da81ba5be8fbc1231a47d7dcc7bea2d467c1a80e.tar.gz box64-da81ba5be8fbc1231a47d7dcc7bea2d467c1a80e.zip | |
Fixed some program (like the one made in rust) that was getting the command line properly
Diffstat (limited to 'src')
| -rwxr-xr-x | src/emu/x64run_private.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/emu/x64run_private.c b/src/emu/x64run_private.c index 1939807f..6c2e5bc1 100755 --- a/src/emu/x64run_private.c +++ b/src/emu/x64run_private.c @@ -32,14 +32,21 @@ int32_t EXPORT my___libc_start_main(x64emu_t* emu, int *(main) (int, char * *, c { (void)argc; (void)ubp_av; (void)fini; (void)rtld_fini; (void)stack_end; - // let's cheat and set all args... if(init) { + Push64(emu, GetRBP(emu)); // set frame pointer + SetRBP(emu, GetRSP(emu)); // save RSP + SetRSP(emu, GetRSP(emu)&~0xFLL); // Align RSP PushExit(emu); + SetRDX(emu, (uint64_t)my_context->envv); + SetRSI(emu, (uint64_t)my_context->argv); + SetRDI(emu, (uint64_t)my_context->argc); R_RIP=(uint64_t)*init; printf_log(LOG_DEBUG, "Calling init(%p) from __libc_start_main\n", *init); DynaRun(emu); if(emu->error) // any error, don't bother with more return 0; + SetRSP(emu, GetRBP(emu)); // restore RSP + SetRBP(emu, Pop64(emu)); // restore RBP emu->quit = 0; } printf_log(LOG_DEBUG, "Transfert to main(%d, %p, %p)=>%p from __libc_start_main\n", my_context->argc, my_context->argv, my_context->envv, main); |