mirror of
https://github.com/gatieme/LDD-LinuxDeviceDrivers.git
synced 2026-09-23 05:03:33 +08:00
增加了kprobe的学习代码...
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
#
|
||||
# Makefile for the LDD-LinuxDeviceDrivers.
|
||||
#
|
||||
# Author: gatieme
|
||||
# Create: 2016-07-29 15:50:46
|
||||
# Last modified: 2016-07-29 16:10:29
|
||||
# Description:
|
||||
# This program is loaded as a kernel(v2.6.18 or later) module.
|
||||
# Use "make install" to load it into kernel.
|
||||
# Use "make remove" to remove the module out of kernel.
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
ROOT=..
|
||||
#PLATFORM=$(shell $(ROOT)/systype.sh)
|
||||
#include $(ROOT)/Make.defines.$(PLATFORM)
|
||||
|
||||
# my driver description
|
||||
DRIVER_VERSION := "1.0.0"
|
||||
DRIVER_AUTHOR := "Gatieme @ AderStep Inc..."
|
||||
DRIVER_DESC := "Linux input module for Elo MultiTouch(MT) devices"
|
||||
DRIVER_LICENSE := "Dual BSD/GPL"
|
||||
|
||||
|
||||
MODULE_NAME := patch
|
||||
|
||||
ifneq ($(KERNELRELEASE),)
|
||||
|
||||
#CFG_FLAGS += -O2 -I./
|
||||
#EXTRA_CFLAGS += $(C_FLAGS) $(CFG_INC) $(CFG_INC)
|
||||
|
||||
|
||||
|
||||
obj-m := $(MODULE_NAME).o #print_vmarea.o
|
||||
|
||||
else
|
||||
|
||||
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
|
||||
|
||||
PWD := $(shell pwd)
|
||||
|
||||
modules:
|
||||
make -C $(KERNELDIR) M=$(PWD) modules
|
||||
|
||||
modules_install:
|
||||
make -C $(KERNELDIR) M=$(PWD) modules_install
|
||||
|
||||
|
||||
|
||||
insmod:
|
||||
sudo insmod $(MODULE_NAME).ko
|
||||
|
||||
reinsmod:
|
||||
sudo rmmod $(MODULE_NAME)
|
||||
sudo insmod $(MODULE_NAME).ko
|
||||
|
||||
github:
|
||||
cd $(ROOT) && make github
|
||||
|
||||
rmmod:
|
||||
sudo rmmod $(MODULE_NAME)
|
||||
|
||||
test :
|
||||
sudo ../injector/memInjector -l stack -m random -t word_0 --time 1 --timeout 3 -p 1
|
||||
|
||||
clean:
|
||||
make -C $(KERNELDIR) M=$(PWD) clean
|
||||
rm -f modules.order Module.symvers Module.markers
|
||||
|
||||
.PHNOY:
|
||||
modules modules_install clean
|
||||
|
||||
|
||||
|
||||
endif
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
// 去掉模块链后,lsmod和rmmod都不起作用了
|
||||
//
|
||||
// http://www.blogbus.com/debug-sai-logs/49461512.html
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/unistd.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/syscalls.h>
|
||||
#include <linux/dirent.h>
|
||||
#include <linux/file.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/kallsyms.h>
|
||||
#include <asm/uaccess.h>
|
||||
|
||||
MODULE_LICENSE("Dual BSD/GPL");
|
||||
#define _DEBUG
|
||||
#ifdef _DEBUG
|
||||
#define kprintk(fmt,args...) printk(KERN_DEBUG fmt,##args)
|
||||
#define kprintf(fmt,args...) printf(fmt,##args)
|
||||
#define kperror(str) perror(str)
|
||||
#else
|
||||
#define kprintk
|
||||
#define kprintf
|
||||
#define kperror
|
||||
#endif
|
||||
|
||||
static int patch_init(void);
|
||||
|
||||
void hidemodule(void)
|
||||
{
|
||||
struct module *head = &__this_module;
|
||||
struct module *next;
|
||||
|
||||
next = head;
|
||||
|
||||
do
|
||||
{
|
||||
if((int)(next->init) == (int)patch_init)
|
||||
{
|
||||
kprintk("find module,hide it\n");
|
||||
list_del(&next->list);
|
||||
break;
|
||||
}else
|
||||
{
|
||||
struct list_head * entry = next->list.next;
|
||||
next = container_of(entry,struct module,list);
|
||||
}
|
||||
|
||||
}while(next != head);
|
||||
}
|
||||
|
||||
static int patch_init(void)
|
||||
{
|
||||
hidemodule( );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void patch_cleanup(void)
|
||||
{
|
||||
}
|
||||
|
||||
module_init(patch_init);
|
||||
module_exit(patch_cleanup);
|
||||
Reference in New Issue
Block a user