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

📄 section.h

📁 该项目主要是将wingdows程序直接运行在linux上
💻 H
字号:
/* * section.h * * 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.h: section syscall functions * Reference to Kernel-win32 code */#ifndef _SECTION_H#define _SECTION_H#include <linux/module.h>#include <linux/sched.h>#include <linux/win32_process.h>#include "object.h"#include "file.h"#ifdef CONFIG_UNIFIED_KERNEL/* * BaseAddress need to aligned to 64k */#define	BASE_ADDRESS_ALIGN	(PAGE_SIZE << 4)#define _PAGE_NOACCESS			0x00000001     #define _PAGE_READONLY			0x00000002     #define _PAGE_READWRITE			0x00000004     #define _PAGE_WRITECOPY			0x00000008     #define _PAGE_EXECUTE			0x00000010     #define _PAGE_EXECUTE_READ		0x00000020     #define _PAGE_EXECUTE_READWRITE		0x00000040     #define _PAGE_EXECUTE_WRITECOPY		0x00000080     #define _PAGE_GUARD			0x00000100     #define _PAGE_NOCACHE			0x00000200     #define _PAGE_WRITECOMBINE		0x00000400     #define _MEM_COMMIT			0x00001000     #define _MEM_RESERVE			0x00002000     #define _MEM_DECOMMIT			0x00004000     #define _MEM_RELEASE			0x00008000     #define _MEM_FREE			0x00010000     #define _MEM_PRIVATE			0x00020000     #define _MEM_MAPPED			0x00040000     #define _MEM_RESET			0x00080000     #define _MEM_TOP_DOWN			0x00100000     #define _SEC_FILE			0x00800000     #define _SEC_IMAGE			0x01000000     #define _SEC_VLM			0x02000000     #define _SEC_RESERVE			0x04000000     #define _SEC_COMMIT			0x08000000     #define _SEC_NOCACHE			0x10000000     #define _MEM_4MB_PAGES			0x80000000     #define _MEM_IMAGE         		_SEC_IMAGE     #define	_MEM_STACK			0x00200000#define _FILE_MAP_COPY			0x00000001#define _FILE_MAP_WRITE			0x00000002#define _FILE_MAP_READ			0x00000004#define _FILE_MAP_ALL_ACCESS		0x000f001f/* for INTEL CPU, only 0x00 and 0x03 is valid */#define	RELOC_TYPE_NO		0x00		/* not fixup */#define	RELOC_TYPE_ALL		0x03		/* fixup 4 bytes */#define WSRF_OVERLAP_PREV	0x0001		/* an entry from previous block overlaps */#define WSRF_OVERLAP_NEXT	0x0002		/* an entry from this block overlaps next */#define WSRF_OVERLAP_NXST	0x0004		/* true if overlap to next page stored */#define WSRO_FIXUP_OLAP		0x0F		/* overlap arrangement mask */#define WSRO_FIXUP_OL11		0x00		/* 1:1 overlap */#define WSRO_FIXUP_OL13		0x01		/* 1:3 overlap */#define WSRO_FIXUP_OL22		0x02		/* 2:2 overlap */#define WSRO_FIXUP_OL31		0x03		/* 3:1 overlap */#define WSRO_FIXUP_TYPE		0xF0		/* overlap type mask (as per fixup table) *//* * args used for section object constructor */struct section_args {	ACCESS_MASK  		DesiredAccess;	POBJECT_ATTRIBUTES	ObjectAttributes;	PLARGE_INTEGER  	MaximumSize;	ULONG			SectionPageProtection;	ULONG			AllocationAttributes;	HANDLE			FileHandle;	struct win32_object	*FileObject;};/* * PE Image File Section * TODO. not implemented in this version */struct win32_image_section{	unsigned long           wis_rva;        /* relative virtual address */	off_t                   wis_fpos;       /* file position */	size_t                  wis_size;       /* section size */	size_t                  wis_rawsize;    /* raw data size */	unsigned long           wis_padrva;     /* padding RVA */	unsigned long           wis_flags;      /* specific flags */	unsigned long           wis_protect;    /* specific protects */	unsigned long           wis_character;  /* characteristics */};/* * memory map section object definition */struct win32_section {	struct win32_object	*ws_obj;	/* my object */	struct win32_object	*ws_fileobj;	/* file object */	struct win32_file	*ws_wfile;	/* the wine file object */	struct file		*ws_file;	/* linux file struct */	unsigned long		ws_alloctype;	/* Allocation type */	unsigned long		ws_protect;	/* page protect */	unsigned long		ws_access;	/* Desired access */	unsigned long		ws_flags;	/* MAP_PRIVATE etc. */	unsigned long		ws_len;		/* section len */	unsigned long		ws_pagelen;	/* page len, aligned to PAGE_SIZE */	int		(*ws_mmap)(struct task_struct *tsk, struct win32_section *,			unsigned long *, unsigned long, unsigned long, unsigned long);	/* mmap func */	/* TODO: this field used for PE Image */	unsigned long		ws_imagebase;	unsigned long		ws_realbase;	int			ws_nsecs;	struct win32_image_section	*ws_sections;	struct win32_image_section	*ws_sectend;	unsigned long		ws_stackresv;	unsigned long		ws_stackcommit;	unsigned short		ws_subsystem;	unsigned short		ws_majorver;	unsigned short		ws_minorver;	unsigned short		ws_executable;	unsigned long		ws_entrypoint;	unsigned short		ws_imagecharacter;	unsigned short		ws_machine;	int			ws_secoff;	int		(*ws_munmap)(struct win32_section *);};typedef struct _SECTION_BASIC_INFORMATION{    PVOID           BaseAddress;    ULONG           Attributes;    LARGE_INTEGER   Size;} SECTION_BASIC_INFORMATION, *PSECTION_BASIC_INFORMATION;typedef struct _SECTION_IMAGE_INFORMATION{    ULONG     EntryPoint;    ULONG     Unknown1;    ULONG_PTR StackReserve;    ULONG_PTR StackCommit;    ULONG     Subsystem;    USHORT    MinorSubsystemVersion;    USHORT    MajorSubsystemVersion;    ULONG     Unknown2;    ULONG     Characteristics;    USHORT    ImageNumber;    BOOLEAN   Executable;    UCHAR     Unknown3;    ULONG     Unknown4[3];} SECTION_IMAGE_INFORMATION, *PSECTION_IMAGE_INFORMATION;extern void SectionClassInit(void);extern struct win32_object_class section_objclass;int data_section_setup(struct win32_section *ws);int image_section_setup(struct win32_section *ws);NTSTATUSSTDCALLNtCreateSection(		OUT PHANDLE  SectionHandle,		IN ACCESS_MASK  DesiredAccess,		IN POBJECT_ATTRIBUTES  ObjectAttributes OPTIONAL,		IN PLARGE_INTEGER  MaximumSize OPTIONAL,		IN ULONG  SectionPageProtection,		IN ULONG  AllocationAttributes,		IN HANDLE  FileHandle OPTIONAL		);NTSTATUSSTDCALLNtMapViewOfSection(		IN HANDLE  SectionHandle,		IN HANDLE  ProcessHandle,		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		);NTSTATUSSTDCALLNtUnmapViewOfSection(		IN HANDLE  ProcessHandle,		IN PVOID  BaseAddress		);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		);#endif /* CONFIG_UNIFIED_KERNEL */#endif

⌨️ 快捷键说明

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