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
|
#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 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_UTF8 (0x0004)
#define NT_GET_ARGV_ENVP_VALIDATE_UTF16 (0x0008)
typedef struct _nt_env_var_meta_utf8 {
char * name;
char * value;
int envp_index;
uint32_t flags;
} nt_env_var_meta_utf8;
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_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_utf8(
__in char * env_var_name,
__in char ** envp,
__out nt_env_var_meta_utf8 * env_var_meta);
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 ** envp,
__in const char * interp __optional,
__in const char * optarg __optional,
__in const char * script __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 * interp __optional,
__in const wchar16_t * optarg __optional,
__in const wchar16_t * script __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
|