当前位置: 技术问答>linux和unix
截获系统调用编译出错,求助!!
来源: 互联网 发布时间:2015-10-04
本文导语: Linux内核2.4.20-8 程序如下: #define MODULE #define __KERNEL__ #include "linux/module.h" #include "linux/kernel.h" #include "linux/proc_fs.h" #include "asm/unistd.h" MODULE_LICENSE("GPL"); unsigned long errno; static inline _syscall3(int,write,int,fd,const...
Linux内核2.4.20-8
程序如下:
#define MODULE
#define __KERNEL__
#include "linux/module.h"
#include "linux/kernel.h"
#include "linux/proc_fs.h"
#include "asm/unistd.h"
MODULE_LICENSE("GPL");
unsigned long errno;
static inline _syscall3(int,write,int,fd,const char *,buf,off_t,count);
static inline _syscall3(int,read,int,fd,char*,buf,off_t,count);
static inline _syscall3(off_t,lseek,int,fd,off_t,offset,int,count);
static inline _syscall3(int,open,const char *,file,int,flag,int,mode);
static inline _syscall1(int,close,int,fd);
struct{
unsigned short limit;
unsigned int base;
}__attribute__((packed))idtr;
struct{
unsigned short off1;
unsigned short sel;
unsigned char none,flags;
unsigned short off2;
}__attribute__((packed))idt;
int kmem;
void readkmem(void *m,unsigned off,int sz)
{
unsigned long old_fs_value=get_fs();
set_fs(get_ds());
if(lseek(kmem,off,0)!=off){
printk("kmem lseek error in readn");return;
}
if(read(kmem,m,sz)!=sz){
printk("kmem read error!n");return;
}
set_fs(old_fs_value);
}
#define CALLOFF 100
unsigned getscTable()
{
unsigned sct;
unsigned sys_call_off;
char sc_asm[CALLOFF],*p;
asm("sidt%0":"=m"(idtr));
unsigned long old_fs_value=get_fs();
const char *filename="/dev/kmem";
set_fs(get_ds());
kmem=open(filename,O_RDONLY,0640);
if(kmem
程序如下:
#define MODULE
#define __KERNEL__
#include "linux/module.h"
#include "linux/kernel.h"
#include "linux/proc_fs.h"
#include "asm/unistd.h"
MODULE_LICENSE("GPL");
unsigned long errno;
static inline _syscall3(int,write,int,fd,const char *,buf,off_t,count);
static inline _syscall3(int,read,int,fd,char*,buf,off_t,count);
static inline _syscall3(off_t,lseek,int,fd,off_t,offset,int,count);
static inline _syscall3(int,open,const char *,file,int,flag,int,mode);
static inline _syscall1(int,close,int,fd);
struct{
unsigned short limit;
unsigned int base;
}__attribute__((packed))idtr;
struct{
unsigned short off1;
unsigned short sel;
unsigned char none,flags;
unsigned short off2;
}__attribute__((packed))idt;
int kmem;
void readkmem(void *m,unsigned off,int sz)
{
unsigned long old_fs_value=get_fs();
set_fs(get_ds());
if(lseek(kmem,off,0)!=off){
printk("kmem lseek error in readn");return;
}
if(read(kmem,m,sz)!=sz){
printk("kmem read error!n");return;
}
set_fs(old_fs_value);
}
#define CALLOFF 100
unsigned getscTable()
{
unsigned sct;
unsigned sys_call_off;
char sc_asm[CALLOFF],*p;
asm("sidt%0":"=m"(idtr));
unsigned long old_fs_value=get_fs();
const char *filename="/dev/kmem";
set_fs(get_ds());
kmem=open(filename,O_RDONLY,0640);
if(kmem