This commit is contained in:
TheBrokenRail 2024-06-08 04:34:20 -04:00
parent 06e9f4d7c8
commit 50d94d5299
2 changed files with 9 additions and 6 deletions

View File

@ -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

View File

@ -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));
}