我的 HTC Sensation XL 有一个 Android LKM,如下所示,它会在调用 sys_open 之前打印一条调试消息。我的操作系统是 Ubuntu 11.10 64 位。Android Kernel 是从http://www.htcdev.com/devcenter/downloads下载的 runnymede-crc-2.6.35 。
/*
* mydebug.c
* 系统调用 sys_open 调试
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <asm/unistd.h>
asmlinkage ssize_t (*orig_open)(const char *pathname, int flags);
asmlinkage ssize_t hooked_open(const char *pathname, int flags)
{
printk(KERN_INFO "SYS_OPEN: %s\n", pathname);
return orig_open(pathname, flags);
}
static int __init root_start(void)
{
unsigned long sys_addr = 0xc003b104; /* System.map */
unsigned long *sys_call_table= (unsigned long *)sys_addr;
orig_open = sys_call_table[__NR_open];
sys_call_table[__NR_open] = hooked_open;
return 0;
}
static void __exit root_stop(void)
{
unsigned long sys_addr = 0xc003b104;
unsigned long *sys_call_table= (unsigned long *)sys_addr;
sys_call_table[__NR_open] = &orig_open;
}
module_init(root_start);
module_exit(root_stop);
但它在编译过程中显示错误,
make -C /home/scott/runnymede-crc-2.6.35/ M=$(PWD) ARCH=arm CROSS_COMPILE=~/android-ndk-r7b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi- modules
make[1]: Entering directory '/home/scott/runnymede-crc-2.6.35'
CC [M] /home/scott/workspace/debugkit/mydebug.o
cc1: warnings being treated as errors
/home/scott/workspace/debugkit/mydebug.c: In function 'root_start':
/home/scott/workspace/debugkit/mydebug.c:23: error: assignment makes pointer from integer without a cast
/home/scott/workspace/debugkit/mydebug.c:24: error: assignment makes integer from pointer without a cast
/home/scott/workspace/debugkit/mydebug.c: In function 'root_stop':
/home/scott/workspace/debugkit/mydebug.c:34: error: assignment makes integer from pointer without a cast
make[2]: [/home/scott/workspace/debugkit/mydebug.o] Error 1
make[1]: [_module_/home/scott/workspace/debugkit] Error 2
make[1]: Leaving directory '/home/scott/runnymede-crc-2.6.35'
make: [default] Error 2
任何人都可以帮助我吗?