📄 w32init.c
字号:
/* * w32init.c * * Copyright (C) 2006 Insigme Co., Ltd * * Authors: * - Decao Mao, Chenzhan Hu, Lixing Chu, Limin Jin, Liwei Zhou, Zhiqiang Jiao * * This software has been developed while working on the Linux Unified Kernel * project (http://linux.insigma.com.cn) in the Insigma Reaserch Institute, * which is a subdivision of Insigma Co., Ltd (http://www.insigma.com.cn). * * The project is sponsored by Insigma Co., Ltd. * * The authors can be reached at linux@insigma.com.cn. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * Revision History: * Jan 2006 - Created. */ /* * w32init.c: initiliase w32systemcall and some object classes *///#define kdebug(fmt ... )//#define ktrace(fmt ... )#include <linux/init.h>#include <linux/module.h>#include <linux/kernel.h>#include <linux/proc_fs.h>#include "mutex.h"#include "event.h"#include "semaphore.h"#include "section.h"#include "file.h"#include "thread.h"#include "process.h"#include "apc.h"#ifdef CONFIG_UNIFIED_KERNEL#define TIF_APC 13asmlinkage int w32system_call(void);int set_w32system_gate(unsigned int, void *);int backup_idt_entry(unsigned int n, unsigned long *a, unsigned long *b);int restore_idt_entry(unsigned int n, unsigned long a, unsigned long b);unsigned long orig_idt_2e_a, orig_idt_2e_b;int __init init_pe_binfmt(void);void __exit exit_pe_binfmt(void);struct proc_dir_entry *unifiedkernel_proc;struct list_head object_class_list;/* do_apc */__attribute__((regparm(3)))void do_apc(struct pt_regs *regs, sigset_t *oldset, __u32 thread_info_flags){ struct ethread *thread; ktrace("Do Apc\n"); /* Get the Current Thread */ if (!(thread = thread_find())) { kdebug("***error find thread\n"); clear_tsk_thread_flag(thread->et_task, TIF_APC); return; } KiDeliverApc(0, 0, regs); /* first parament is kernelMode or UserMode or 0 for both*/}/* end do_apc *//* w32_init */static int w32_init(void){ /* store the original address that the 0x2E points */ if (backup_idt_entry(0x2E, &orig_idt_2e_a, &orig_idt_2e_b) == -1) { kdebug("Module not loaded. backup_idt_entry error: bad idt entry\n"); return -1; } /* initialize 0x2E */ if (set_w32system_gate(0x2E, &w32system_call) == -1) { kdebug("Module not loaded. set_w32system_gate error: bad idt entry\n"); return -1; } ktrace("Module w32 On! vector 0x2E initialized for w32 syscall!\n"); ktrace("Unifiedkernel loading...\n"); /* initialise the internal bits */ INIT_LIST_HEAD(&object_class_list); FileClassInit(); SectionClassInit(); ThreadClassInit(); ProcessClassInit(); init_pe_binfmt(); ktrace("Initialised successfully!\n"); return 0; } /* end w32_exit */ /* w32_exit */static void w32_exit(void){ exit_pe_binfmt(); /* restore 0x2E */ restore_idt_entry(0x2E, orig_idt_2e_a, orig_idt_2e_b); ktrace("Module w32 Off!\n");} /*end w32_exit */ module_init(w32_init);module_exit(w32_exit);MODULE_LICENSE("GPL");#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -