summaryrefslogtreecommitdiffhomepage
path: root/include/ntapi/nt_argv.h
blob: db52e9515581320a62a9080386408c84aefc5a57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#ifndef _NT_ARGV_H_
#define _NT_ARGV_H_

/******************************************************
 *                                                    *
 *   this header is REALLY NOT what you are looking   *
 *   for, however if you are into writing your apps   *
 *   using the Native API only, then you might find   *
 *   the below interfaces somehow useful.             *
 *                                                    *
 *****************************************************/

#include "nt_abi.h"

/* ntapi_tt_get_argv_envp_utf16 flag bits */
#define NT_GET_ARGV_ENVP_USE_INTERNAL_BUFFER	(0x0000)
#define NT_GET_ARGV_ENVP_USE_CALLER_BUFFER	(0x0001)
#define NT_GET_ARGV_ENVP_COPY_ENVIRONMENT	(0x0002)
#define NT_GET_ARGV_ENVP_VALIDATE_UTF16		(0x0004)

/* ntapi_tt_program_option flag bits */
#define NT_OPTION_SHORT			(0x0001)
#define NT_OPTION_LONG			(0x0002)
#define NT_OPTION_ALLOWED_ONCE		(0x0100)
#define NT_OPTION_ALLOWED_MANY		(0x0200)
#define NT_OPTION_REQUIRED		(0x0400)
#define NT_OPTION_VALUE_REQUIRED	(0x1000)

typedef struct _nt_program_option {
	int		option_count;
	wchar16_t	short_name_code;
	wchar16_t *	long_name;
	wchar16_t *	value;
	uint32_t	flags;
} nt_program_option;


typedef struct _nt_program_options_meta {
	int	idx_next_argument;
	int	idx_invalid_short_name;
	int	idx_invalid_long_name;
	int	idx_invalid_argument;
	int	idx_missing_option_value;
} nt_program_options_meta;


typedef struct _nt_env_var_meta_utf16 {
	wchar16_t *	name;
	wchar16_t *	value;
	int		envp_index;
	uint32_t	flags;
} nt_env_var_meta_utf16;


typedef struct _nt_cmd_option_meta_utf16 {
	wchar16_t *	short_name;
	uint32_t	short_name_code;
	wchar16_t *	long_name;
	wchar16_t *	value;
	int		argv_index;
	uint32_t	flags;
} nt_cmd_option_meta_utf16;


typedef struct _nt_argv_envp_block_info {
	wchar16_t *	cmd_line;
	wchar16_t **	wargv_buffer;
	size_t		wargv_buffer_len;
	wchar16_t *	wargs_buffer;
	size_t		wargs_buffer_len;
	size_t		wargs_bytes_written;
	wchar16_t **	wenvp_buffer;
	size_t		wenvp_buffer_len;
	wchar16_t *	wenvs_buffer;
	size_t		wenvs_buffer_len;
	size_t		wenvs_bytes_used;
	char *		args_buffer;
	size_t		args_buffer_len;
	size_t		args_bytes_written;
	char *		envs_buffer;
	size_t		envs_buffer_len;
	size_t		envs_bytes_used;
	uint32_t	arg_flags;
	uint32_t	env_flags;
	uint32_t	psx_flags;
	uint32_t	psx_padding;
	uint32_t	argv_envp_ptr_total;
	int		envc;

	int		argc;
	char **		argv;
	char **		envp;
} nt_argv_envp_block_info;


typedef struct _nt_get_argv_envp_ext_params {
	nt_argv_envp_block_info	argv_envp_block_info;
} nt_get_argv_envp_ext_params;


typedef wchar16_t * __stdcall	ntapi_tt_get_cmd_line_utf16(void);


typedef wchar16_t * __stdcall	ntapi_tt_get_peb_env_block_utf16(void);


typedef int32_t __stdcall 	ntapi_tt_parse_cmd_line_args_utf16(
	__in	wchar16_t *	cmd_line,
	__out	int *		arg_count,
	__in	wchar16_t *	args_buffer,
	__in	size_t		args_buffer_len,
	__out	size_t *	args_bytes_written __optional,
	__in	wchar16_t **	argv_buffer,
	__in	size_t		argv_buffer_len,
	__in	uint32_t	arg_flags);


typedef int32_t __stdcall 	ntapi_tt_get_argv_envp_utf8(
	__out	int *		argc,
	__out	char ***	argv,
	__out	char ***	envp,
	__in	uint32_t	flags,
	__in	void *		ext_params	__optional,
	__out	void *		reserved	__optional);


typedef int32_t __stdcall 	ntapi_tt_get_argv_envp_utf16(
	__out	int *		argc,
	__out	wchar16_t ***	wargv,
	__out	wchar16_t ***	wenvp,
	__in	uint32_t	flags,
	__in	void *		ext_params	__optional,
	__out	void *		reserved	__optional);


typedef int32_t __stdcall 	ntapi_tt_get_env_var_meta_utf16(
	__in	wchar16_t *		env_var_name,
	__in	wchar16_t **		envp,
	__out	nt_env_var_meta_utf16 *	env_var_meta);


typedef int32_t __stdcall	ntapi_tt_array_copy_utf8(
	__out	int *			argc,
	__in	const char **		argv,
	__in	const char **		wenvp,
	__in	const char *		image_name	__optional,
	__in	const char *		interpreter	__optional,
	__in	const char *		optarg		__optional,
	__in	void *			base,
	__out	void *			buffer,
	__in	size_t			buflen,
	__out	size_t *		blklen);

typedef int32_t __stdcall	ntapi_tt_array_copy_utf16(
	__out	int *			argc,
	__in	const wchar16_t **	wargv,
	__in	const wchar16_t **	wenvp,
	__in	const wchar16_t *	image_name	__optional,
	__in	const wchar16_t *	interpreter	__optional,
	__in	const wchar16_t *	optarg		__optional,
	__in	void *			base,
	__out	void *			buffer,
	__in	size_t			buflen,
	__out	size_t *		blklen);

typedef int32_t __stdcall	ntapi_tt_array_convert_utf8_to_utf16(
	__in		char **		arrv,
	__in		wchar16_t **	arra,
	__in		void *		base,
	__in		wchar16_t *	buffer,
	__in		size_t		buffer_len,
	__out		size_t *	bytes_written);

typedef int32_t __stdcall	ntapi_tt_array_convert_utf16_to_utf8(
	__in		wchar16_t **	warrv,
	__in		char **		arra,
	__in		void *		base,
	__in		char *		buffer,
	__in		size_t		buffer_len,
	__out		size_t *	bytes_written);

#endif