From: "Steve Graegert" <graegerts@gmail.com>
To: linux-c-programming@vger.kernel.org
Subject: Re: Read /dev/kmem failed
Date: Sun, 26 Mar 2006 19:50:42 +0200 [thread overview]
Message-ID: <6a00c8d50603260950v3d199cbbm2f9716e9a87adf17@mail.gmail.com> (raw)
In-Reply-To: <4426D035.8050608@gmail.com>
On 3/26/06, Mikado <mikado4vn@gmail.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> > struct descriptor_idt {
> > unsigned short offset_low, seg_selector;
> > unsigned char reserved, flag;
> > unsigned short offset_high;
> > };
> >
> > .......
> >
> > struct descriptor_idt *descriptor;
> > .......
> >
> > fd_kmem = open("/dev/kmem", O_RDWR);
> > ptr_idt = get_addr_idt();
> > descriptor = (struct descriptor_idt *) malloc(sizeof(struct
> > descriptor_idt));
> > ......
> > readkmem(descriptor, ptr_idt + 8 * x, sizeof(struct descriptor_idt));
> >
> > ......
> >
> > void readkmem(void *m, unsigned off, int size)
> > {
> > int i;
> > if (lseek(fd_kmem, off, SEEK_SET) != off) {
> > fprintf(stderr, "Error lseek. Are you root? \n");
> > exit(-1);
> > }
> > if ((i = read(fd_kmem, m, size)) != size) {
> > fprintf(stderr, "Error read kmem, only read %d bytes\n",i);
> > perror("read");
> > exit(-1);
> > }
> > }
> >
> > unsigned long get_addr_idt(void)
> > {
> > unsigned char idtr[6];
> > unsigned long idt;
> > __asm__ volatile ("sidt %0":"=m" (idtr));
> > idt = *((unsigned long *) &idtr[2]);
> > return (idt);
> > }
> > ----------------------------------------------------------------------
> > When run it, the output is:
> >
> > Error read kmem, only read 0 bytes
> > read: Success
> >
> >
> > I don't know why read error?
>
> finding sys_call_table, system calls' addresses and patching kernel
> on-the-fly, isn't it?
Yes, Phrack 58 <http://www.phrack.org/phrack/58/p58-0x07>
\Steve
prev parent reply other threads:[~2006-03-26 17:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-22 1:29 Read /dev/kmem failed openbsd shen
2006-03-22 16:04 ` Glynn Clements
2006-03-26 17:32 ` Mikado
2006-03-26 17:50 ` Steve Graegert [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6a00c8d50603260950v3d199cbbm2f9716e9a87adf17@mail.gmail.com \
--to=graegerts@gmail.com \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).