Blame src/internal/pe_os.h

393c20
#ifndef PE_OS_H
393c20
#define PE_OS_H
393c20
a29a7a
#include <psxtypes/psxtypes.h>
393c20
#include <pemagine/pe_structs.h>
393c20
a29a7a
#define OS_STATUS_SUCCESS			(int32_t)0x00000000
a29a7a
#define OS_STATUS_INVALID_PARAMETER		(int32_t)0xC000000D
a29a7a
#define OS_STATUS_ILLEGAL_CHARACTER		(int32_t)0xC0000161
a29a7a
#define OS_STATUS_NO_MATCH			(int32_t)0xC0000272
a29a7a
#define OS_STATUS_INVALID_ADDRESS		(int32_t)0xC0000141
a29a7a
#define OS_STATUS_CONTEXT_MISMATCH		(int32_t)0xC0000719
a29a7a
#define OS_STATUS_COULD_NOT_INTERPRET		(int32_t)0xC00000B9
482851
#define OS_STATUS_NOT_SUPPORTED			(int32_t)0xC00000BB
a29a7a
#define OS_STATUS_NAME_TOO_LONG			(int32_t)0xC0000106
0cc26d
#define OS_STATUS_BUFFER_TOO_SMALL		(int32_t)0xC0000023
a29a7a
#define OS_STATUS_INTERNAL_ERROR		(int32_t)0xC00000E5
a29a7a
#define OS_STATUS_BAD_FILE_TYPE			(int32_t)0xC0000903
a29a7a
#define OS_STATUS_OBJECT_NAME_NOT_FOUND 	(int32_t)0xC0000034
a29a7a
#define OS_STATUS_OBJECT_PATH_NOT_FOUND		(int32_t)0xC000003A
a29a7a
#define OS_STATUS_MORE_PROCESSING_REQUIRED	(int32_t)0xC0000016
393c20
77cbd4
#define OS_OBJ_INHERIT	 			0x00000002
77cbd4
#define OS_OBJ_CASE_INSENSITIVE			0x00000040
77cbd4
393c20
#define OS_SEC_SYNCHRONIZE			0x00100000
393c20
#define	OS_FILE_READ_ACCESS			0x00000001
393c20
#define	OS_FILE_READ_ATTRIBUTES			0x00000080
393c20
393c20
#define OS_FILE_DIRECTORY_FILE			0x00000001
393c20
#define OS_FILE_NON_DIRECTORY_FILE		0x00000040
0443ad
#define OS_FILE_SYNCHRONOUS_IO_ALERT		0x00000010
393c20
393c20
#define OS_FILE_SHARE_READ			0x00000001
393c20
#define OS_FILE_SHARE_WRITE			0x00000002
393c20
#define OS_FILE_SHARE_DELETE			0x00000004
393c20
6d58d9
#define OS_CURRENT_PROCESS_HANDLE		(void *)(uintptr_t)(-1)
6d58d9
#define OS_CURRENT_THREAD_HANDLE		(void *)(uintptr_t)(-2)
6d58d9
393c20
393c20
enum os_object_info_class {
393c20
	OS_OBJECT_BASIC_INFORMATION	= 0,
393c20
	OS_OBJECT_NAME_INFORMATION	= 1,
393c20
	OS_OBJECT_TYPE_INFORMATION	= 2,
393c20
	OS_OBJECT_ALL_TYPES_INFORMATION	= 3,
393c20
	OS_OBJECT_HANDLE_INFORMATION	= 4
393c20
};
393c20
393c20
6d58d9
enum os_memory_info_class {
6d58d9
	OS_MEMORY_BASIC_INFORMATION,
6d58d9
	OS_MEMORY_WORKING_SET_LIST,
6d58d9
	OS_MEMORY_SECTION_NAME,
6d58d9
	OS_MEMORY_BASIC_VLM_INFORMATION
6d58d9
};
6d58d9
6d58d9
393c20
struct os_oa {
393c20
	uint32_t		len;
393c20
	void *			root_dir;
393c20
	struct pe_unicode_str *	obj_name;
393c20
	uint32_t		obj_attr;
393c20
	void *			sec_desc;
393c20
	void *			sec_qos;
393c20
};
393c20
393c20
393c20
struct os_iosb {
393c20
	union {
393c20
		int32_t		status;
393c20
		void *		pointer;
393c20
	};
393c20
	intptr_t		info;
393c20
};
393c20
393c20
e13223
struct os_proc_params {
e13223
	uint32_t		alloc_size;
e13223
	uint32_t		used_size;
e13223
	uint32_t		flags;
e13223
	uint32_t		reserved;
e13223
	void *			hconsole;
e13223
	uintptr_t		console_flags;
e13223
	void *			hstdin;
e13223
	void *			hstdout;
e13223
	void *			hstderr;
e13223
	struct pe_unicode_str	cwd_name;
e13223
	void *			cwd_handle;
e13223
	struct pe_unicode_str	__attr_ptr_size_aligned__ dll_path;
e13223
	struct pe_unicode_str	__attr_ptr_size_aligned__ image_file_name;
e13223
	struct pe_unicode_str	__attr_ptr_size_aligned__ command_line;
e13223
	wchar16_t *		environment;
e13223
	uint32_t		dwx;
e13223
	uint32_t		dwy;
e13223
	uint32_t		dwx_size;
e13223
	uint32_t		dwy_size;
e13223
	uint32_t		dwx_count_chars;
e13223
	uint32_t		dwy_count_chars;
e13223
	uint32_t		dw_fill_attribute;
e13223
	uint32_t		dw_flags;
e13223
	uint32_t		wnd_show;
e13223
	struct pe_unicode_str	wnd_title;
e13223
	struct pe_unicode_str	__attr_ptr_size_aligned__ desktop;
e13223
	struct pe_unicode_str	__attr_ptr_size_aligned__ shell_info;
e13223
	struct pe_unicode_str	__attr_ptr_size_aligned__ runtime_data;
e13223
};
e13223
e13223
e13223
struct os_peb {
e13223
	unsigned char		reserved_1st[2];
e13223
	unsigned char         	debugged;
e13223
	unsigned char		reserved_2nd[1];
e13223
	void *			reserved_3rd[2];
e13223
	struct pe_peb_ldr_data*	peb_ldr_data;
e13223
	struct os_proc_params *	process_params;
e13223
	unsigned char		reserved_4th[104];
e13223
	void *			reserved_5th[52];
e13223
	void * 			post_process_init_routine;
e13223
	unsigned char		reserved_6th[128];
e13223
	void *			reserved_7th[1];
e13223
	uint32_t		session_id;
e13223
};
e13223
e13223
77cbd4
typedef int32_t __stdcall os_zw_close(
77cbd4
	__in	void *			handle);
77cbd4
77cbd4
393c20
typedef int32_t __stdcall os_zw_query_object(
393c20
	__in	void *			handle,
393c20
	__in	int			obj_info_class,
393c20
	__out	void *			obj_info,
393c20
	__in	size_t			obj_info_length,
393c20
	__out	uint32_t *		returned_length		__optional);
393c20
393c20
7cd411
typedef int32_t __stdcall os_zw_read_virtual_memory(
7cd411
	__in	void *			hprocess,
7cd411
	__in	void *			base_address,
7cd411
	__out	char *			buffer,
7cd411
	__in	size_t			buffer_length,
7cd411
	__out	size_t *		bytes_written);
7cd411
7cd411
393c20
typedef int32_t __stdcall os_zw_open_file(
393c20
	__out	void **			hfile,
393c20
	__in	uint32_t		desired_access,
393c20
	__in	struct os_oa *		obj_attr,
393c20
	__out	struct os_iosb *	io_status_block,
393c20
	__in	uint32_t		share_access,
393c20
	__in	uint32_t		open_options);
393c20
dd1a85
482851
typedef int32_t __stdcall os_ldr_load_dll(
482851
	__in	wchar16_t *		image_path	__optional,
482851
	__in	uint32_t *		image_flags	__optional,
482851
	__in	struct pe_unicode_str *	image_name,
482851
	__out	void **			image_base);
482851
dd1a85
dd1a85
typedef int32_t __stdcall os_zw_terminate_process(
dd1a85
	__in	void *		hprocess,
dd1a85
	__in	int32_t		status);
dd1a85
393c20
#endif