#include <asm/processor.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/sched.h> #include <linux/mm_types.h> #include <asm/desc.h> #include <asm/unistd.h>
int init_module(void) { unsigned long cr3; struct vm_area_struct *vm; #if 0 __asm__ __volatile__ { "movl %%cr3, %0\n\t" :"=r"(cr3): }; #endif vm = current->mm->mmap;
printk("*****可用下面的方法取出进程的地址空间信息*******\n"); printk("current->comm: %s\n", current->comm); //执行当前进程的命令的名字
printk("current->state: %d\n", current->state); //运行状态
printk("currentr->mm = 0x%x\n", current->mm); printk("currentr->mm->pgd = 0x%x\n", current->mm->pgd); //页目录表的地址(好象与cr3相差0xc0000000)
printk("**********the virtual memory area***************\n"); printk("vm_area: 0x%x - 0x%x\n", current->mm->mmap->vm_start, current->mm->mmap->vm_end); //
vm = vm->vm_next; while((NULL != vm) && (vm != current->mm->mmap)){ printk("vm_area: 0x%x - 0x%x\n", vm->vm_start, vm->vm_end); // vm = vm->vm_next; };
printk("total_vm: 0x%x\t locked_vm: 0x%x\t shared_vm: 0x%x\t exec_vm: 0x%x\n", current->mm->total_vm, //进程地址空间的大小(页) current->mm->locked_vm, //锁住不能换出的页的个数 current->mm->shared_vm, //共亨文件内存映射的页数 current->mm->exec_vm); //可执行内存映射中的页数 printk("start_code - end_code: 0x%x - 0x%x\n", current->mm->start_code, current->mm->end_code); //代码 printk("start_data - end_data: 0x%x - 0x%x\n", current->mm->start_data, current->mm->end_data); //数据 printk("start_brk - brk: 0x%x - 0x%x\n", current->mm->start_brk, current->mm->brk); //堆 printk("start_stack: 0x%x\n", current->mm->start_stack); //用户堆栈的起始地址 printk("stack_vm: 0x%x\n", current->mm->stack_vm); //用户态堆栈中的页数 printk("arg_area: 0x%x - 0x%x\n", current->mm->arg_start, current->mm->arg_end); //命令行参数的起始地址 printk("env_area: 0x%x - 0x%x\n", current->mm->env_start, current->mm->env_end); //环境变量的起始地址
return 0; }
void cleanup_module(void) { return; }
|