aboutsummaryrefslogtreecommitdiff
path: root/src/harness_adapter.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/harness_adapter.c')
-rw-r--r--src/harness_adapter.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/harness_adapter.c b/src/harness_adapter.c
index 5a9b9a4..6ae8c66 100644
--- a/src/harness_adapter.c
+++ b/src/harness_adapter.c
@@ -5,8 +5,43 @@
#include "HsFFI.h"
#include "plugin_interface.h"
+#include <stdio.h>
const char *plugin_name = "Wetterhorn";
void plugin_load(int argc, char **argv) { hs_init(&argc, &argv); }
void plugin_teardown(opqst_t st) { hs_exit(); }
+
+const char msg[] =
+ "Wetterhorn Plugin v 0.01\n"
+ " This is a mere shared object file, meant to be a plugin for the "
+ "Wetterhorn"
+ " Compositor. To use this, please run 'wtr_harness -p [this_file]' to"
+ " use this plugin.\n";
+const int msg_sz = sizeof(msg);
+
+
+__attribute__((naked)) void _start() {
+
+ // Make system call to print the message
+ asm(
+ // Load the address of the string into rsi
+ "mov %0, %%rsi\n"
+ // Load the string length into edx
+ "mov %1, %%edx\n"
+ // Load the file descriptor for stdout into edi
+ "mov $1, %%edi\n"
+ // Load the syscall number for sys_write into eax
+ "mov $1, %%eax\n"
+ // Make the syscall
+ "syscall\n"
+
+ // Exit the program.
+ "mov $0, %%rdi\n"
+ "mov $60, %%rax\n"
+ "syscall\n"
+ :
+ : "r"(msg), "r"(msg_sz) // Input: address of msg
+ : "%rsi", "%edx", "%edi" // Clobbered registers
+ );
+}