LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-19-2005, 10:18 PM   #1
qqrilxk
LQ Newbie
 
Registered: Oct 2004
Posts: 13

Rep: Reputation: 0
Question look at how i modify the system call interrupt vector


i want to modify the int 80 vector ,and i code it like this
#define MODULE
#define KERNEL
#define GFP_KERNEL 0
#define SYSCALL_VECTOR 0x80
#define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
#define GDT_ENTRY_KERNEL_BASE 12
#define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/config.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/types.h>
struct desc_struct {
unsigned long a,b;
};
void *kmalloc(ssize_t size,int flags);


int system_call(void);
int printk(const char *fmt,...);
void myvector(void)
{

char *save=(char *)kmalloc(30,GFP_KERNEL);
__asm__("movl %eax save \n\t"
"movl %ebx,save+1 \n\t"
"movl %ecx,save+2 \n\t"
"movl %edx,save+3 \n\t"
"movl %esi,save+4 \n\t"
"movl %edi,save+5");

printk("%s\n",*save);
__asm__ __volatile__("call *system_call");
//__asm__ __volatile__("movl $system_call,%eip");
}


void init_module(void)
{
extern struct desc_struct idt_table[256];
#define _set_gate(gate_addr,type,dpl,addr,seg) \
do { \
int __d0, __d1; \
__asm__ __volatile__ ("movw %%dx,%%ax\n\t" \
"movw %4,%%dx\n\t" \
"movl %%eax,%0\n\t" \
"movl %%edx,%1" \
:"=m" (*((long *) (gate_addr))), \
"=m" (*(1+(long *) (gate_addr))), "=&a" (__d0), "=&d" (__d1) \
:"i" ((short) (0x8000+(dpl<<13)+(type<<8))), \
"3" ((char *) (addr)),"2" ((seg) << 16)); \
} while (0)


static void set_system_gate(unsigned int n, void *addr)
{
_set_gate(idt_table+n,15,3,addr,__KERNEL_CS);
}


set_system_gate(SYSCALL_VECTOR,&myvector);

}


void cleanup_module(void)
{

extern struct desc_struct idt_table[256];
#define _set_gate(gate_addr,type,dpl,addr,seg) \
do { \
int __d0, __d1; \
__asm__ __volatile__ ("movw %%dx,%%ax\n\t" \
"movw %4,%%dx\n\t" \
"movl %%eax,%0\n\t" \
"movl %%edx,%1" \
:"=m" (*((long *) (gate_addr))), \
"=m" (*(1+(long *) (gate_addr))), "=&a" (__d0), "=&d" (__d1) \
:"i" ((short) (0x8000+(dpl<<13)+(type<<8))), \
"3" ((char *) (addr)),"2" ((seg) << 16)); \
} while (0)


static void set_system_gate(unsigned int n, void *addr)
{
_set_gate(idt_table+n,15,3,addr,__KERNEL_CS);
}


set_system_gate(SYSCALL_VECTOR,&system_call);

}


but when i compile it ,it say :myproject.c in function "myvector":
myproject.c:24:error:can't find a register in class "GENERAL_REGS" while reloading "asm"
what does this means?
i need your help,thanks!
 
Old 03-20-2005, 03:37 PM   #2
t3gah
Member
 
Registered: Dec 2004
Distribution: SuSE, RedHat, ubuntu, Debian
Posts: 734

Rep: Reputation: 30
What 'exactly' are you trying to accomplish?
 
Old 03-21-2005, 12:54 AM   #3
qqrilxk
LQ Newbie
 
Registered: Oct 2004
Posts: 13

Original Poster
Rep: Reputation: 0
thanks

i only want to modify the system call interrupt vector to self-defined vector function ,in the self-defined vector functions i can get all the system call arguments .then i call the original interrupt vector in the self-defined vector.that is all what i want to do.thanks!
 
Old 03-21-2005, 01:13 AM   #4
t3gah
Member
 
Registered: Dec 2004
Distribution: SuSE, RedHat, ubuntu, Debian
Posts: 734

Rep: Reputation: 30
Re: thanks

Quote:
Originally posted by qqrilxk
i only want to modify the system call interrupt vector to self-defined vector function ,in the self-defined vector functions i can get all the system call arguments .then i call the original interrupt vector in the self-defined vector.that is all what i want to do.thanks!
Are you following the guidelines from this faq http://www.tldp.org/LDP/khg/HyperNew...syscall86.html ?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
when modify the int 80 interrupt vector i run into some questions qqrilxk Programming 1 04-18-2005 01:13 PM
problem with vector and push_back call kris55 Linux - Software 2 03-24-2005 08:10 PM
can i modify int 80 vector to a user-defined vector qqrilxk Linux - Security 1 03-03-2005 08:46 PM
new system call, modify Makefile for .o feetyouwell Programming 0 11-16-2004 09:58 AM
can interrupt handler call user space function? pot_po Programming 0 11-07-2002 09:32 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration