More Fixes
All checks were successful
CI / Test (AMD64) (push) Successful in 2m5s
CI / Test (ARM64) (push) Successful in 6m18s

This commit is contained in:
TheBrokenRail 2025-02-15 00:36:44 -05:00
parent 5f0cfcb7af
commit c3ba1f0bc7
3 changed files with 15 additions and 7 deletions

View File

@ -3,13 +3,21 @@
#include <trampoline/types.h>
// Error-Checking
static void safe_trampoline(const uint32_t id, uint32_t *ret, const uint32_t length, const unsigned char *args) {
const uint32_t err = raw_trampoline(id, ret, length, args);
if (err != 0) {
fprintf(stderr, "Error: %u\n", err);
}
}
// Call Trampoline With String
void run(uint32_t cmd, const char *str) {
unsigned char *args = (unsigned char *) str;
void run(const uint32_t cmd, const char *str) {
const unsigned char *args = (const unsigned char *) str;
// Send Command
fprintf(stderr, "Guest Is Sending: %u: %s\n", cmd, str);
uint32_t ret;
raw_trampoline(cmd, &ret, strlen(str) + 1, args);
safe_trampoline(cmd, &ret, strlen(str) + 1, args);
fprintf(stderr, "Guest Has Received: %u\n", ret);
}
@ -25,6 +33,6 @@ int main() {
// Calls without a return value *may* return control
// to guest code before the call has finished.
INFO("Testing Trampoline Call That May Return Early");
raw_trampoline(100, NULL, 0, NULL);
safe_trampoline(100, NULL, 0, NULL);
fprintf(stderr, "Control Returned To Guest\n");
}

View File

@ -7,8 +7,8 @@
// writer: Function That Can Write To Guest Memory
// id: Command ID
// args: Pointer To Command Arguments
// Return Value: Returned To The Guest (Unless Early Return Is Enabled)
uint32_t trampoline(trampoline_writer_t writer, uint32_t id, const unsigned char *args) {
// Return Value: Returned To The Guest
uint32_t trampoline(trampoline_writer_t writer, const uint32_t id, const unsigned char *args) {
if (id == 100 /* Defined In ../../guest/src/example.c */) {
// Early Return Allowed
fprintf(stderr, "Early Return Call Started\n");

View File

@ -10,4 +10,4 @@ apt-get install -y --no-install-recommends \
ninja-build \
gcc g++ \
gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf \
libc6:armhf
libc6:armhf libstdc++6:armhf