Created
September 7, 2020 16:07
-
-
Save linuxthor/fc43ef97d48e70303ae4607454168c30 to your computer and use it in GitHub Desktop.
Find some task struct by iterating
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <linux/module.h> | |
#include <linux/init.h> | |
#include <linux/kernel.h> | |
#include <linux/fs.h> | |
#include <linux/mm.h> | |
#include <linux/slab.h> | |
#include <linux/vmalloc.h> | |
#include <linux/uaccess.h> | |
int init_module(void) | |
{ | |
int x; | |
int pmd = PID_MAX_DEFAULT; | |
struct task_struct *ts; | |
char tsk[TASK_COMM_LEN]; | |
for(x = 2; x < pmd; x++) | |
{ | |
ts = pid_task(find_vpid(x), PIDTYPE_PID); | |
if(ts != 0) | |
{ | |
get_task_comm(tsk, ts); | |
if(strcmp(tsk, "bash") == 0) | |
{ | |
printk("Bash process found\n"); | |
} | |
} | |
} | |
return 0; | |
} | |
void cleanup_module(void) | |
{ | |
} | |
MODULE_AUTHOR("linuxthor"); | |
MODULE_LICENSE("GPL"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment