Skip to content

Instantly share code, notes, and snippets.

@pellaeon
Created October 26, 2013 14:43
Show Gist options
  • Save pellaeon/7170193 to your computer and use it in GitHub Desktop.
Save pellaeon/7170193 to your computer and use it in GitHub Desktop.
#include <linux/module.h>
#include <linux/kallsyms.h>
#include <linux/mmc/card.h>
#define DRIVER_AUTHOR "Pellaeon Lin <[email protected]>"
#define DRIVER_DESCRIPTION "Modify write protected partition number to nonexistent partition"
#define DRIVER_VERSION "1.0"
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESCRIPTION);
MODULE_VERSION(DRIVER_VERSION);
MODULE_LICENSE("GPL");
int __init init_feng(void)
{
char wp_prevention_partno[256];
mmc_blk_get_wp_prevention_partno(&wp_prevention_partno[0]);
printk(KERN_INFO "feng: %s version %s\n", DRIVER_DESCRIPTION,
DRIVER_VERSION);
printk(KERN_INFO "feng: by %s\n", DRIVER_AUTHOR);
printk("feng installed, old wp_prevention_partno=%s \n", wp_prevention_partno);
mmc_blk_set_wp_prevention_partno(99);
mmc_blk_get_wp_prevention_partno(&wp_prevention_partno[0]);
printk("feng: NEW wp_prevention_partno=%s \n", wp_prevention_partno);
return 0;
}
static void __exit exit_feng(void)
{
}
module_init(init_feng);
module_exit(exit_feng);
obj-m +=feng.o
KERNELDIR ?= ~/android/kernel/k2u-jb-3.4.10-cl157896-1-built
PWD := $(shell pwd)
CROSS_COMPILE=/home/pellaeon/toolchains/arm-eabi-4.6/bin/arm-eabi-
ARCH=arm
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) modules
clean:
$(MAKE) -C $(KERNELDIR) M=$(PWD) clean
#include <linux/module.h>
#include <linux/kallsyms.h>
#include <linux/mmc/card.h>
#define DRIVER_AUTHOR "Pellaeon Lin <[email protected]>"
#define DRIVER_DESCRIPTION "Defeat system write protect"
#define DRIVER_VERSION "1.0"
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESCRIPTION);
MODULE_VERSION(DRIVER_VERSION);
MODULE_LICENSE("GPL");
int __init init_wp_mod(void)
{
printk(KERN_INFO "wp_mod: %s version %s\n", DRIVER_DESCRIPTION,
DRIVER_VERSION);
printk(KERN_INFO "wp_mod: by %s\n", DRIVER_AUTHOR);
set_mmc0_write_protection_type(0);
printk("wp_mod installed, mmc0_write_prot_type=%d \n", get_mmc0_write_protection_type());
return 0;
}
static void __exit exit_wp_mod(void)
{
}
module_init(init_wp_mod);
module_exit(exit_wp_mod);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment