summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author0xwille2011-07-12 20:51:00 +0200
committer0xwille2011-07-12 20:51:00 +0200
commit389cc1ba8d9e673f1313fd966820c6d9d463525f (patch)
tree77bac88a1faa54c28e8d38bcee7485c742680105
parentc8f116e17b471704abbb3b1508733aa1bddda7da (diff)
downloadlkm-389cc1ba8d9e673f1313fd966820c6d9d463525f.tar.gz
AƱadido pid
-rw-r--r--cr0.c22
-rw-r--r--lists/Makefile (renamed from Makefile)2
-rw-r--r--lists/lists.c (renamed from lists.c)0
-rw-r--r--pid/Makefile7
-rw-r--r--pid/pid.c34
-rw-r--r--syscall/Makefile7
-rw-r--r--syscall/syscall.c (renamed from syscall.c)0
7 files changed, 48 insertions, 24 deletions
diff --git a/cr0.c b/cr0.c
deleted file mode 100644
index 9265d61..0000000
--- a/cr0.c
+++ /dev/null
@@ -1,22 +0,0 @@
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <asm/system.h>
-
-int init_module(void)
-{
- int cr0 = native_read_cr0();
- printk(KERN_INFO "cr0 before: %x\n", cr0);
- cr0 = cr0 >> 1;
- cr0 = cr0 << 1;
- native_write_cr0(cr0);
- cr0 = native_read_cr0();
- printk(KERN_INFO "cr0 after: %x\n", cr0);
- return 0;
-}
-
-void cleanup_module(void)
-{
- printk(KERN_INFO "cr0 unloaded\n");
-}
-
-MODULE_LICENSE("GPL");
diff --git a/Makefile b/lists/Makefile
index f314971..813420c 100644
--- a/Makefile
+++ b/lists/Makefile
@@ -1,5 +1,3 @@
-#obj-m += syscall.o
-#obj-m += cr0.o
obj-m += lists.o
all:
diff --git a/lists.c b/lists/lists.c
index 2eee70c..2eee70c 100644
--- a/lists.c
+++ b/lists/lists.c
diff --git a/pid/Makefile b/pid/Makefile
new file mode 100644
index 0000000..b9e7cfd
--- /dev/null
+++ b/pid/Makefile
@@ -0,0 +1,7 @@
+obj-m += pid.o
+
+all:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+clean:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
diff --git a/pid/pid.c b/pid/pid.c
new file mode 100644
index 0000000..b930fe6
--- /dev/null
+++ b/pid/pid.c
@@ -0,0 +1,34 @@
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+
+static char modname[] = "pid.ko";
+static struct task_struct *mytask;
+static struct task_struct *parent;
+
+static int __init init(void)
+{
+ mytask = current;
+ printk(KERN_ALERT "%s loaded by %s (%d)\n",
+ modname, mytask->comm, mytask->pid);
+ parent = mytask->parent;
+ while (mytask->pid != parent->pid) {
+ printk(KERN_ALERT "current: %s (%d) - parent: %s (%d)\n",
+ mytask->comm, mytask->pid, parent->comm, parent->pid);
+ mytask = mytask->parent;
+ parent = mytask->parent;
+ }
+
+ return 0;
+}
+
+static void __exit exit(void)
+{
+ printk(KERN_ALERT "%s unloaded\n", modname);
+}
+
+module_init(init);
+module_exit(exit);
+
+MODULE_LICENSE("GPL");
diff --git a/syscall/Makefile b/syscall/Makefile
new file mode 100644
index 0000000..332678d
--- /dev/null
+++ b/syscall/Makefile
@@ -0,0 +1,7 @@
+obj-m += syscall.o
+
+all:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+clean:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
diff --git a/syscall.c b/syscall/syscall.c
index 8decf5c..8decf5c 100644
--- a/syscall.c
+++ b/syscall/syscall.c