Blame include/ntapi/nt_section.h

dd89bb
#ifndef _NT_SECTION_H_
dd89bb
#define _NT_SECTION_H_
dd89bb
dd89bb
#include <psxtypes/psxtypes.h>
dd89bb
#include "nt_object.h"
dd89bb
#include "nt_memory.h"
dd89bb
dd89bb
typedef enum _nt_section_info_class {
dd89bb
	NT_SECTION_BASIC_INFORMATION,
dd89bb
	NT_SECTION_IMAGE_INFORMATION
dd89bb
} nt_section_info_class;
dd89bb
dd89bb
dd89bb
typedef enum _nt_section_inherit {
dd89bb
	NT_VIEW_SHARE	= 1,
dd89bb
	NT_VIEW_UNMAP	= 2
dd89bb
} nt_section_inherit;
dd89bb
dd89bb
/* section attributes */
dd89bb
#define NT_SEC_BASED			0x00200000
dd89bb
#define NT_SEC_NO_CHANGE		0x00400000
dd89bb
#define NT_SEC_FILE			0x00800000
dd89bb
#define NT_SEC_IMAGE			0x01000000
dd89bb
#define NT_SEC_VLM			0x02000000
dd89bb
#define NT_SEC_RESERVE			0x04000000
dd89bb
#define NT_SEC_COMMIT			0x08000000
dd89bb
#define NT_SEC_NOCACHE			0x10000000
dd89bb
#define NT_SEC_IMAGE_NO_EXECUTE		0x11000000
dd89bb
#define NT_SEC_LARGE_PAGES		0x80000000
dd89bb
#define NT_SEC_WRITECOMBINE		0x40000000
dd89bb
dd89bb
/* section memory allocation attributes */
dd89bb
#define NT_SEC_AT_EXTENDABLE_FILE	0x00002000 /* view may exceed section size */
dd89bb
#define NT_SEC_AT_RESERVED		0x20000000 /* ignored */
dd89bb
#define NT_SEC_AT_ROUND_TO_PAGE		0x40000000 /* adjust address and/or size as necessary */
dd89bb
dd89bb
dd89bb
/* section access bits */
dd89bb
#define NT_SECTION_QUERY        	0x00000001
dd89bb
#define NT_SECTION_MAP_WRITE        	0x00000002
dd89bb
#define NT_SECTION_MAP_READ         	0x00000004
dd89bb
#define NT_SECTION_MAP_EXECUTE      	0x00000008
dd89bb
#define NT_SECTION_EXTEND_SIZE      	0x00000010
dd89bb
#define NT_SECTION_MAP_EXECUTE_EXPLICIT 0x00000020
dd89bb
#define NT_STANDARD_RIGHTS_REQUIRED	0x000F0000
dd89bb
#define NT_SECTION_ALL_ACCESS 		NT_STANDARD_RIGHTS_REQUIRED \
dd89bb
						| NT_SECTION_QUERY \
dd89bb
						| NT_SECTION_MAP_WRITE \
dd89bb
						| NT_SECTION_MAP_READ \
dd89bb
						| NT_SECTION_MAP_EXECUTE \
dd89bb
						| NT_SECTION_EXTEND_SIZE
dd89bb
dd89bb
dd89bb
typedef struct _nt_section_basic_information {
dd89bb
	void *			base_address;
dd89bb
	uint32_t		section_attr;
dd89bb
	nt_large_integer	section_size;
dd89bb
} nt_section_basic_information, nt_sbi;
dd89bb
dd89bb
typedef struct _nt_section_image_information {
dd89bb
	void *			entry_point;
dd89bb
	uint32_t		stack_zero_bits;
dd89bb
	size_t			stack_reserve;
dd89bb
	size_t			stack_commit;
dd89bb
	uint32_t		subsystem;
dd89bb
	uint16_t		subsystem_minor_version;
dd89bb
	uint16_t		subsystem_major_version;
dd89bb
	uint32_t		unknown;
dd89bb
	uint32_t		characteristics;
dd89bb
	uint16_t		image_number;
dd89bb
	unsigned char		executable;
dd89bb
	unsigned char		image_flags;
dd89bb
	uint32_t		loader_flags;
dd89bb
	uint32_t		image_file_size;
dd89bb
	uint32_t		image_checksum;
dd89bb
} nt_section_image_information, nt_sec_img_inf;
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_zw_create_section(
dd89bb
	__out	void **			hsection,
dd89bb
	__in	uint32_t		desired_access,
dd89bb
	__in	nt_object_attributes *	obj_attr,
dd89bb
	__in	nt_large_integer *	section_size	__optional,
dd89bb
	__in	uint32_t		section_protect,
dd89bb
	__in	uint32_t		section_attr,
dd89bb
	__in	void *			hfile);
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_zw_open_section(
dd89bb
	__out	void **			hsection,
dd89bb
	__in	uint32_t		desired_access,
dd89bb
	__in	nt_object_attributes *	obj_attr);
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_zw_query_section(
dd89bb
	__in	void *			hsection,
dd89bb
	__in	nt_section_info_class	sec_info_class,
dd89bb
	__out	void *			sec_info,
dd89bb
	__in	size_t			sec_info_length,
dd89bb
	__out	size_t *		returned_length	__optional);
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_zw_extend_section(
dd89bb
	__in	void *				hsection,
dd89bb
	__in	nt_large_integer *		section_size);
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_zw_map_view_of_section(
dd89bb
	__in		void *			hsection,
dd89bb
	__in		void *			hprocess,
dd89bb
	__in_out	void **			base_address,
dd89bb
	__in		uint32_t		zero_bits,
dd89bb
	__in		size_t			commit_size,
dd89bb
	__in_out	nt_large_integer *	section_offset	__optional,
dd89bb
	__in_out	size_t *		view_size,
dd89bb
	__in		nt_section_inherit	section_inherit_disposition,
dd89bb
	__in		uint32_t		allocation_type,
dd89bb
	__in		uint32_t		protect);
dd89bb
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_zw_unmap_view_of_section(
dd89bb
	__in		void *			hprocess,
dd89bb
	__in		void *			base_address);
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_zw_are_mapped_files_the_same(
dd89bb
	__in		void *			addr_1st,
dd89bb
	__in		void *			addr_2nd);
dd89bb
dd89bb
dd89bb
/* extensions */
dd89bb
typedef int32_t __stdcall ntapi_tt_get_section_name(
dd89bb
	__in	void *			addr,
dd89bb
	__out	nt_mem_sec_name *	buffer,
dd89bb
	__in	uint32_t		buffer_size);
dd89bb
dd89bb
#endif