当前位置: 技术问答>linux和unix
64位linux 对cr0位进行清零操作,出错
来源: 互联网 发布时间:2016-11-25
本文导语: 本帖最后由 whoisthisman 于 2011-04-28 15:30:02 编辑 想获取sys_call_table,首先要先将cr0清零,从网上看了用如下方式unsigned int clear_and_return_cr0(void) #include #include #include #include #include #include ...
#include
#include
#include
#include
#include
#include
#include
#include
#include
unsigned long *sys_table = NULL;
MODULE_DESCRIPTION("G kernel module");
MODULE_AUTHOR("root (iii@iiiiom)");
MODULE_LICENSE("$LICENSE$");
static void *memmem(const void *haystack, size_t haystack_len,
const void *needle, size_t needle_len);
static unsigned long get_syscall_table_long(void)
{
#define OFFSET_SYSCALL 200
unsigned long syscall_long, retval;
char sc_asm[OFFSET_SYSCALL];
rdmsrl(MSR_LSTAR, syscall_long);
memcpy(sc_asm, (char *)syscall_long, OFFSET_SYSCALL);
retval = (unsigned long) memmem(sc_asm, OFFSET_SYSCALL, "xffx14xc5", 3);
if ( retval != 0 ) {
retval = (unsigned long) ( * (unsigned long *)(retval+3) );
} else {
printk("long mode : memmem found nothing, returning NULL:(");
retval = 0;
}
#undef OFFSET_SYSCALL
return retval;
}
static void *memmem(const void *haystack, size_t haystack_len,
const void *needle, size_t needle_len)
{
const char *begin;
const char *const last_possible = (const char *) haystack + haystack_len - needle_len;
if (needle_len == 0){
/* The first occurrence of the empty string is deemed to occur at
the beginning of the string. */
return (void *) haystack;
}
if (__builtin_expect(haystack_len