RE: sys_call_table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,

	I tried to understand the code below but could not. Can any one please explain me.

Regards,
Mohan.

#include <linux/syscall.h>
#include <asm/unistd.h>

static void **sys_call_table;

//nearest exported symbol to syscalls in my kernel,
//i hope in others kernels too
//but in other form you can look at your kernel sources

extern void *system_utsname;

....

static int locate_sys_call_table(void) {
    unsigned long *begin;
    int i;

    begin=(unsigned long *) &system_utsname;
    for (i=0;i<1024;i++) {
        if (*(begin+i)==(unsigned long) sys_socketcall) {
            sys_call_table=(void *) (begin+i-__NR_socketcall);
            //are you sure?
            if (sys_call_table[__NR_exit]==(void *) sys_exit) {
                printk("success: located sys_call_table: %X\n",(unsigned
int) sys_call_table);
                return(1);
            }
        }
    }
    return(0);
}


int __init init_exportmodule (void)
{

    if (!locate_sys_call_table()) {
        // ... cry again and return error
    }

    //.....sys_call_table[] works now!!
    //......do something like export symbol
    //.... or intercept any syscall

}
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux