From 50d94d52998ba361c5d89d1b21f7eafd972f3f4e Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Sat, 8 Jun 2024 04:34:20 -0400 Subject: [PATCH] Speed! --- include/trampoline/types.h | 1 - native/src/pipe/pipe.cpp | 14 +++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/trampoline/types.h b/include/trampoline/types.h index 978d5ee..55c1dad 100644 --- a/include/trampoline/types.h +++ b/include/trampoline/types.h @@ -16,7 +16,6 @@ struct trampoline_pipe_arguments { uint32_t id; uint32_t allow_early_return; uint32_t length; - uint32_t args_addr; }; // Function Types diff --git a/native/src/pipe/pipe.cpp b/native/src/pipe/pipe.cpp index 199f68b..f348ec6 100644 --- a/native/src/pipe/pipe.cpp +++ b/native/src/pipe/pipe.cpp @@ -47,12 +47,16 @@ void init_pipe_host(pid_t guest_pid) { trampoline_pipe_arguments cmd = {}; while (read(arguments_pipe[PIPE_READ], &cmd, sizeof(trampoline_pipe_arguments)) > 0) { static unsigned char args[MAX_TRAMPOLINE_ARGS_SIZE]; - memory_reader(cmd.args_addr, args, cmd.length); - uint32_t ret = 0; - if (cmd.allow_early_return && cmd.length > 0) { - write(return_value_pipe[PIPE_WRITE], &ret, sizeof(uint32_t)); + size_t position = 0; + while (position < cmd.length) { + ssize_t ret = read(arguments_pipe[PIPE_READ], args + position, cmd.length - position); + if (ret == -1) { + ERR("Unable To Read Trampoline Arguments"); + } else { + position += ret; + } } - ret = trampoline(cmd.id, args); + uint32_t ret = trampoline(cmd.id, args); if (!cmd.allow_early_return) { write(return_value_pipe[PIPE_WRITE], &ret, sizeof(uint32_t)); }