summaryrefslogtreecommitdiffhomepage
path: root/include/ntapi/nt_sync.h
blob: 700be38ce14f4145135e3a9fc0b8b146b3568d28 (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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
#ifndef _NT_SYNC_H_
#define _NT_SYNC_H_

#include "nt_abi.h"
#include "nt_compiler.h"
#include "nt_object.h"

typedef enum _nt_wait_type {
	NT_WAIT_ALL,
	NT_WAIT_ANY
} nt_wait_type;


typedef enum _nt_timer_type {
	NT_NOTIFICATION_TIMER,
	NT_SYNCHRONIZATION_TIMER
} nt_timer_type;


typedef enum _nt_timer_info_class {
	NT_TIMER_BASIC_INFORMATION
} nt_timer_info_class;


typedef enum _nt_event_type {
	NT_NOTIFICATION_EVENT,
	NT_SYNCHRONIZATION_EVENT
} nt_event_type;


typedef enum _nt_event_states {
	NT_EVENT_NOT_SIGNALED,
	NT_EVENT_SIGNALED
} nt_event_states;


typedef enum _nt_event_info_class {
	NT_EVENT_BASIC_INFORMATION
} nt_event_info_class;


typedef enum _nt_semaphore_info_class {
	NT_SEMAPHORE_BASIC_INFORMATION
} nt_semaphore_info_class;


typedef enum _nt_mutant_info_class {
	NT_MUTANT_BASIC_INFORMATION
} nt_mutant_info_class;


typedef enum _nt_io_completion_info_class {
	NT_IO_COMPLETION_BASIC_INFORMATION
} nt_io_completion_info_class;


/* timer access bits */
#define NT_TIMER_QUERY_STATE		0x00000001U
#define NT_TIMER_MODIFY_STATE		0x00000002U
#define NT_TIMER_ALL_ACCESS 		0x001F0003U


/* event access bits */
#define NT_EVENT_QUERY_STATE		0x00000001U
#define NT_EVENT_MODIFY_STATE		0x00000002U
#define NT_EVENT_ALL_ACCESS 		0x001F0003U


/* semaphore access bits */
#define NT_SEMAPHORE_QUERY_STATE	0x00000001U
#define NT_SEMAPHORE_MODIFY_STATE	0x00000002U
#define NT_SEMAPHORE_ALL_ACCESS 	0x001F0003U


/* mutant access bits */
#define NT_MUTANT_QUERY_STATE		0x00000001U
#define NT_MUTANT_ALL_ACCESS 		0x001F0001U


/* io completion access bits */
#define NT_IO_COMPLETION_QUERY_STATE	0x00000001U
#define NT_IO_COMPLETION_MODIFY_STATE	0x00000002U
#define NT_IO_COMPLETION_ALL_ACCESS 	0x001F0003U

/* alertable threads */
#define NT_SYNC_NON_ALERTABLE		0x00000000U
#define NT_SYNC_ALERTABLE		0x00000001U

/* sync structures */
typedef struct _nt_timer_basic_information {
	nt_large_integer	timer_remaining;
	int32_t			signal_state;
} nt_timer_basic_information;


typedef struct _nt_event_basic_information {
	nt_event_type		event_type;
	int32_t			signal_state;
} nt_event_basic_information, nt_ebi;


typedef struct _nt_semaphore_basic_information {
	int32_t		current_count;
	int32_t		max_count;
} nt_semaphore_basic_information;


typedef struct _nt_mutant_basic_information {
	int32_t		signal_state;
	int32_t		owned;
	int32_t		abandoned;
} nt_mutant_basic_information;


typedef struct _nt_io_completion_basic_information {
	int32_t		signal_state;
} nt_io_completion_basic_information;


typedef void	__stdcall nt_timer_apc_routine(
	void *		timer_context,
	uint32_t	timer_low_value,
	uint32_t	timer_high_value);


typedef int32_t __stdcall ntapi_zw_wait_for_single_object(
	__in	void *			handle,
	__in 	int32_t			alertable,
	__in	nt_large_integer *	timeout	__optional);


typedef int32_t __stdcall ntapi_zw_signal_and_wait_for_single_object(
	__in	void *			handle_to_signal,
	__in	void *			handle_to_wait,
	__in 	int32_t			alertable,
	__in	nt_large_integer *	timeout	__optional);


typedef int32_t __stdcall ntapi_zw_wait_for_multiple_objects(
	__in	uint32_t		handle_count,
	__in	void **			handles,
	__in	nt_wait_type		wait_type,
	__in 	int32_t			alertable,
	__in	nt_large_integer *	timeout	__optional);


typedef int32_t __stdcall ntapi_zw_create_timer(
	__out	void **			htimer,
	__in 	uint32_t 		desired_access,
	__in 	nt_object_attributes * 	obj_attr,
	__in 	nt_timer_type		timer_type);


typedef int32_t __stdcall ntapi_zw_open_timer(
	__out	void **			htimer,
	__in 	uint32_t 		desired_access,
	__in 	nt_object_attributes * 	obj_attr);


typedef int32_t __stdcall ntapi_zw_cancel_timer(
	__in	void *			htimer,
	__out 	int32_t *		previous_state	__optional);


typedef int32_t __stdcall ntapi_zw_set_timer(
	__in	void *			htimer,
	__in	nt_large_integer *	due_time,
	__in	nt_timer_apc_routine *	timer_apc_routine	__optional,
	__in	void *			timer_context,
	__in	int32_t			resume,
	__in	int32_t			period,
	__out	int32_t *		previous_state		__optional);


typedef int32_t __stdcall ntapi_zw_query_timer(
	__in	void *			htimer,
	__in	nt_timer_info_class	timer_info_class,
	__out	void *			timer_info,
	__in	size_t			timer_info_length,
	__out	size_t *		returned_length		__optional);


typedef int32_t __stdcall ntapi_zw_create_event(
	__out	void * volatile *	hevent,
	__in 	uint32_t 		desired_access,
	__in 	nt_object_attributes * 	obj_attr,
	__in 	nt_event_type		event_type,
	__in 	int32_t			initial_state);


typedef int32_t __stdcall ntapi_zw_open_event(
	__out	void **			hevent,
	__in 	uint32_t 		desired_access,
	__in 	nt_object_attributes * 	obj_attr);


typedef int32_t __stdcall ntapi_zw_set_event(
	__in	void *		hevent,
	__out	int32_t *	previous_state);


typedef int32_t __stdcall ntapi_zw_pulse_event(
	__in	void *		hevent,
	__out	int32_t *	previous_state);


typedef int32_t __stdcall ntapi_zw_reset_event(
	__in	void *		hevent,
	__out	int32_t *	previous_state);


typedef int32_t __stdcall ntapi_zw_clear_event(
	__in	void *		hevent);


typedef int32_t __stdcall ntapi_zw_query_event(
	__in	void *			hevent,
	__in	nt_event_info_class	event_info_class,
	__out	void *			event_info,
	__in	size_t			event_info_length,
	__out	size_t *		returned_length		__optional);


typedef int32_t __stdcall ntapi_zw_create_semaphore(
	__out	void **			hsemaphore,
	__in 	uint32_t 		desired_access,
	__in 	nt_object_attributes * 	obj_attr,
	__in 	int32_t			initial_count,
	__in 	int32_t			max_count);


typedef int32_t __stdcall ntapi_zw_open_semaphore(
	__out	void **			hsemaphore,
	__in 	uint32_t 		desired_access,
	__in 	nt_object_attributes * 	obj_attr);


typedef int32_t __stdcall ntapi_zw_release_semaphore(
	__in	void *		hsemaphore,
	__in	int32_t		release_count,
	__out	int32_t *	previous_count);


typedef int32_t __stdcall ntapi_zw_query_semaphore(
	__in	void *			hsemaphore,
	__in	nt_semaphore_info_class	semaphore_info_class,
	__out	void *			semaphore_info,
	__in	size_t			semaphore_info_length,
	__out	size_t *		returned_length		__optional);


typedef int32_t __stdcall ntapi_zw_create_mutant(
	__out	void **			hmutant,
	__in 	uint32_t 		desired_access,
	__in 	nt_object_attributes * 	obj_attr,
	__in	int32_t			initial_owner);


typedef int32_t __stdcall ntapi_zw_open_mutant(
	__out	void **			hmutant,
	__in 	uint32_t 		desired_access,
	__in 	nt_object_attributes * 	obj_attr);


typedef int32_t __stdcall ntapi_zw_release_mutant(
	__in	void *		hmutant,
	__out	int32_t *	previous_state);


typedef int32_t __stdcall ntapi_zw_query_mutant(
	__in	void *			hmutant,
	__in	nt_mutant_info_class	mutant_info_class,
	__out	void *			mutant_info,
	__in	size_t			mutant_info_length,
	__out	size_t *		returned_length		__optional);


typedef int32_t __stdcall ntapi_zw_create_io_completion(
	__out	void **			hio_completion,
	__in 	uint32_t 		desired_access,
	__in 	nt_object_attributes * 	obj_attr,
	__in	uint32_t		max_concurrent_threads);


typedef int32_t __stdcall ntapi_zw_open_io_completion(
	__out	void **			hio_completion,
	__in 	uint32_t 		desired_access,
	__in 	nt_object_attributes * 	obj_attr);


typedef int32_t __stdcall ntapi_zw_set_io_completion(
	__in	void *		hio_completion,
	__in	uint32_t	completion_key,
	__in	uint32_t	completion_value,
	__in	int32_t		status,
	__in	uint32_t	information);


typedef int32_t __stdcall ntapi_zw_remove_io_completion(
	__in	void *			hio_completion,
	__out	uint32_t *		completion_key,
	__out	uint32_t *		completion_value,
	__out	nt_io_status_block *	io_status_block,
	__in	nt_large_integer *	timeout);


typedef int32_t __stdcall ntapi_zw_query_io_completion(
	__in	void *			hio_completion,
	__in	nt_io_completion_info_class	io_completion_info_class,
	__out	void *			io_completion_info,
	__in	size_t			io_completion_info_length,
	__out	size_t *		returned_length		__optional);


typedef int32_t __stdcall ntapi_zw_create_event_pair(
	__out	void **			hevent_pair,
	__in 	uint32_t 		desired_access,
	__in 	nt_object_attributes * 	obj_attr);


typedef int32_t __stdcall ntapi_zw_open_event_pair(
	__out	void **			hevent_pair,
	__in 	uint32_t 		desired_access,
	__in 	nt_object_attributes * 	obj_attr);


typedef int32_t __stdcall ntapi_zw_wait_low_event_pair(
	__in	void *	hevent_pair);


typedef int32_t __stdcall ntapi_zw_set_low_event_pair(
	__in	void *	hevent_pair);


typedef int32_t __stdcall ntapi_zw_wait_high_event_pair(
	__in	void *	hevent_pair);


typedef int32_t __stdcall ntapi_zw_set_high_event_pair(
	__in	void *	hevent_pair);


typedef int32_t __stdcall ntapi_zw_set_low_wait_high_event_pair(
	__in	void *	hevent_pair);


typedef int32_t __stdcall ntapi_zw_set_high_wait_low_event_pair(
	__in	void *	hevent_pair);


/* extensions */
typedef int32_t __stdcall ntapi_tt_create_inheritable_event(
	__out	void **		hevent,
	__in 	nt_event_type	event_type,
	__in 	int32_t		initial_state);


typedef int32_t __stdcall ntapi_tt_create_private_event(
	__out	void * volatile *	hevent,
	__in 	nt_event_type		event_type,
	__in 	int32_t			initial_state);


typedef int32_t __stdcall ntapi_tt_wait_for_dummy_event(void);

#endif