8000 GitHub - cooboos/kxchg: exchange a kernel function when it run · GitHub
[go: up one dir, main page]

Skip to content
cooboosPublic

About

exchange a kernel function when it run

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

usage: patch -p0 < kxchg.patch.xxxxxxx

kxchg.patch.20130204  for linux 2.6.38

example:
#include <linux/types.h>
#include <linux/init.h>
#include <linux/string.h>
#include <linux/in.h>
#include <linux/types.h>
#include <linux/netdevice.h>
#include <linux/netfilter.h>
#
4E39
include <linux/list.h>
#include <linux/kxchg.h>

static struct kxchg test;
extern int kxchg_register(struct kxchg *ptr);
extern int kxchg_unregister(struct kxchg *kxchg);
/*
 * if there is a function named "do_rule_add"
 *	and if you want to exchange it by do_rule_add_test
 *
 * then 
 *	declear the function as follows... this function args is same as the old functions ( do_rule_add)
 *
 *
 */
int do_rule_add_test(SG_RULE * r, int vsysid, struct rule_set *set)
{
	printk("do_rule_test ... ok");
	return 0;
}

int __init test_init(void)
{
	memset(&test, 0x00, sizeof(test));

	test.symbol_name="do_rule_add";
	test.symbol_name_rep="do_rule_add_test";

	kxchg_register(&test);
	return 0;
}

void __exit test_exit(void)
{
	kxchg_unregister(&test);
	return;
}

module_init(test_init);
module_exit(test_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("cooboos");

About

exchange a kernel function when it run

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

0