Skript fr Code Generierung angepasst so dass die explizite Definition der Variablen im c File steht und im Header File die Deklaration fr externes

dev_vlr
Valentin Lechner 5 years ago
parent bbf48681e0
commit 04f29d2e03

@ -1,19 +1,32 @@
#!/usr/bin/env bash
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
SRCS_H="$SCRIPTPATH""/headers"
SGENS="$SCRIPTPATH""/5y563n.c"
SGENH="$SRCS_H""/5y563n.h"
smap="/boot/System.map-$(uname -r)"
echo -e '#include "5y563n.h"' > "$SGENS"
echo -e "#pragma once" > "$SGENH"
echo -e "#include <linux/fs.h>" >> "$SGENH"
symbline=$(cat $smap | grep '\Wsys_call_table$')
set $symbline
[ -z "$symbline" ] && echo "No SysCall Table Value from System.map found" && exit 2;
echo -e "void** sys_call_table = (void**)0x$1;" >> "$SGENH"
echo -e "extern void** sys_call_table;" >> "$SGENH"
echo -e "void** sys_call_table = (void**)0x$1;" >> "$SGENS"
procline=$(cat $smap | grep '\Wproc_modules_operations$')
set $procline
echo -e "struct file_operations* proc_modules_operations = (struct file_operations*)0x$1;" >> "$SGENH"
echo -e "extern struct file_operations* proc_modules_operations;">> "$SGENH"
echo -e "struct file_operations* proc_modules_operations = (struct file_operations*)0x$1;" >> "$SGENS"
Loading…
Cancel
Save