⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 section.c

📁 该项目主要是将wingdows程序直接运行在linux上
💻 C
字号:
/* * section.c * * Copyright (C) 2006  Insigme Co., Ltd * * Authors:  * - Chenzhan Hu * * 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. */ /*  * section.c: section syscall functions * Reference to Kernel-win32 code */#include <linux/module.h>#include "../section.h"#include "../thread.h"#include <asm/uaccess.h>#include <linux/file.h>#include <linux/mman.h>#include <linux/win32_process.h>#include <linux/win32_thread.h>#ifdef CONFIG_UNIFIED_KERNEL/* * MmMapViewOfSection * map a view of the section to the process's address space */NTSTATUSSTDCALLMmMapViewOfSection(		IN PVOID  SectionObject,		IN PEPROCESS  Process,		IN OUT PVOID  *BaseAddress,		IN ULONG  ZeroBits,		IN ULONG  CommitSize,		IN OUT PLARGE_INTEGER  SectionOffset  OPTIONAL,		IN OUT PSIZE_T  ViewSize,		IN SECTION_INHERIT  InheritDisposition,		IN ULONG  AllocationType,		IN ULONG  Protect		){	NTSTATUS	status = -EINVAL;	size_t		size;	unsigned long	offset;	unsigned long	addr;	unsigned long	flags = 0;	struct win32_section	*ws;	struct win32_object	*obj = (struct win32_object *)SectionObject;	struct ethread	*thread;	struct task_struct *tsk;	ktrace("MmMapViewOfSection\n");	if (!(thread = get_first_thread(Process)))		return -EINVAL;	if ((addr = BaseAddress ? (unsigned long)*BaseAddress : 0)) {		/* fixed address map, align to 64k */		flags = MAP_FIXED;		addr = (addr + BASE_ADDRESS_ALIGN - 1) & ~(BASE_ADDRESS_ALIGN - 1);	}	/* map offset, aligned to PAGE_SIZE */	if ((offset = SectionOffset ? SectionOffset->u.LowPart : 0))		offset &= PAGE_MASK;	size = ViewSize ? *ViewSize : 0;	tsk = thread->et_task;	/* get the win32_section struct */	ws = obj->o_private;	flags |= ws->ws_flags;	if (offset >= ws->ws_len || offset + size > ws->ws_len)		goto cleanup;	/* map total section len */	if (size == 0)		size = ws->ws_len - offset;	if (ws->ws_mmap) {		/* grab the process's memory mapping semaphore */		down_write(&tsk->mm->mmap_sem);		/* do the mmap operation */		status = ws->ws_mmap(tsk, ws, &addr, size, flags, offset >> PAGE_SHIFT);		/* release the process's memory mapping semaphore */		up_write(&tsk->mm->mmap_sem);	}	/* return the address if sucess */	if (!status)		*BaseAddress = (PVOID)addr;cleanup:	ktrace("*** MmMapViewOfSection(%p) = %d\n", obj, status);	return status;} /* end MmMapViewOfSection() */#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -