1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4
5 PyDoc_STRVAR(_winapi_Overlapped_GetOverlappedResult__doc__,
6 "GetOverlappedResult($self, wait, /)\n"
7 "--\n"
8 "\n");
9
10 #define _WINAPI_OVERLAPPED_GETOVERLAPPEDRESULT_METHODDEF \
11 {"GetOverlappedResult", (PyCFunction)_winapi_Overlapped_GetOverlappedResult, METH_O, _winapi_Overlapped_GetOverlappedResult__doc__},
12
13 static PyObject *
14 _winapi_Overlapped_GetOverlappedResult_impl(OverlappedObject *self, int wait);
15
16 static PyObject *
_winapi_Overlapped_GetOverlappedResult(OverlappedObject * self,PyObject * arg)17 _winapi_Overlapped_GetOverlappedResult(OverlappedObject *self, PyObject *arg)
18 {
19 PyObject *return_value = NULL;
20 int wait;
21
22 if (!PyArg_Parse(arg, "p:GetOverlappedResult", &wait)) {
23 goto exit;
24 }
25 return_value = _winapi_Overlapped_GetOverlappedResult_impl(self, wait);
26
27 exit:
28 return return_value;
29 }
30
31 PyDoc_STRVAR(_winapi_Overlapped_getbuffer__doc__,
32 "getbuffer($self, /)\n"
33 "--\n"
34 "\n");
35
36 #define _WINAPI_OVERLAPPED_GETBUFFER_METHODDEF \
37 {"getbuffer", (PyCFunction)_winapi_Overlapped_getbuffer, METH_NOARGS, _winapi_Overlapped_getbuffer__doc__},
38
39 static PyObject *
40 _winapi_Overlapped_getbuffer_impl(OverlappedObject *self);
41
42 static PyObject *
_winapi_Overlapped_getbuffer(OverlappedObject * self,PyObject * Py_UNUSED (ignored))43 _winapi_Overlapped_getbuffer(OverlappedObject *self, PyObject *Py_UNUSED(ignored))
44 {
45 return _winapi_Overlapped_getbuffer_impl(self);
46 }
47
48 PyDoc_STRVAR(_winapi_Overlapped_cancel__doc__,
49 "cancel($self, /)\n"
50 "--\n"
51 "\n");
52
53 #define _WINAPI_OVERLAPPED_CANCEL_METHODDEF \
54 {"cancel", (PyCFunction)_winapi_Overlapped_cancel, METH_NOARGS, _winapi_Overlapped_cancel__doc__},
55
56 static PyObject *
57 _winapi_Overlapped_cancel_impl(OverlappedObject *self);
58
59 static PyObject *
_winapi_Overlapped_cancel(OverlappedObject * self,PyObject * Py_UNUSED (ignored))60 _winapi_Overlapped_cancel(OverlappedObject *self, PyObject *Py_UNUSED(ignored))
61 {
62 return _winapi_Overlapped_cancel_impl(self);
63 }
64
65 PyDoc_STRVAR(_winapi_CloseHandle__doc__,
66 "CloseHandle($module, handle, /)\n"
67 "--\n"
68 "\n"
69 "Close handle.");
70
71 #define _WINAPI_CLOSEHANDLE_METHODDEF \
72 {"CloseHandle", (PyCFunction)_winapi_CloseHandle, METH_O, _winapi_CloseHandle__doc__},
73
74 static PyObject *
75 _winapi_CloseHandle_impl(PyObject *module, HANDLE handle);
76
77 static PyObject *
_winapi_CloseHandle(PyObject * module,PyObject * arg)78 _winapi_CloseHandle(PyObject *module, PyObject *arg)
79 {
80 PyObject *return_value = NULL;
81 HANDLE handle;
82
83 if (!PyArg_Parse(arg, "" F_HANDLE ":CloseHandle", &handle)) {
84 goto exit;
85 }
86 return_value = _winapi_CloseHandle_impl(module, handle);
87
88 exit:
89 return return_value;
90 }
91
92 PyDoc_STRVAR(_winapi_ConnectNamedPipe__doc__,
93 "ConnectNamedPipe($module, /, handle, overlapped=False)\n"
94 "--\n"
95 "\n");
96
97 #define _WINAPI_CONNECTNAMEDPIPE_METHODDEF \
98 {"ConnectNamedPipe", (PyCFunction)_winapi_ConnectNamedPipe, METH_FASTCALL|METH_KEYWORDS, _winapi_ConnectNamedPipe__doc__},
99
100 static PyObject *
101 _winapi_ConnectNamedPipe_impl(PyObject *module, HANDLE handle,
102 int use_overlapped);
103
104 static PyObject *
_winapi_ConnectNamedPipe(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)105 _winapi_ConnectNamedPipe(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
106 {
107 PyObject *return_value = NULL;
108 static const char * const _keywords[] = {"handle", "overlapped", NULL};
109 static _PyArg_Parser _parser = {"" F_HANDLE "|i:ConnectNamedPipe", _keywords, 0};
110 HANDLE handle;
111 int use_overlapped = 0;
112
113 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
114 &handle, &use_overlapped)) {
115 goto exit;
116 }
117 return_value = _winapi_ConnectNamedPipe_impl(module, handle, use_overlapped);
118
119 exit:
120 return return_value;
121 }
122
123 PyDoc_STRVAR(_winapi_CreateFile__doc__,
124 "CreateFile($module, file_name, desired_access, share_mode,\n"
125 " security_attributes, creation_disposition,\n"
126 " flags_and_attributes, template_file, /)\n"
127 "--\n"
128 "\n");
129
130 #define _WINAPI_CREATEFILE_METHODDEF \
131 {"CreateFile", (PyCFunction)_winapi_CreateFile, METH_FASTCALL, _winapi_CreateFile__doc__},
132
133 static HANDLE
134 _winapi_CreateFile_impl(PyObject *module, LPCTSTR file_name,
135 DWORD desired_access, DWORD share_mode,
136 LPSECURITY_ATTRIBUTES security_attributes,
137 DWORD creation_disposition,
138 DWORD flags_and_attributes, HANDLE template_file);
139
140 static PyObject *
_winapi_CreateFile(PyObject * module,PyObject * const * args,Py_ssize_t nargs)141 _winapi_CreateFile(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
142 {
143 PyObject *return_value = NULL;
144 LPCTSTR file_name;
145 DWORD desired_access;
146 DWORD share_mode;
147 LPSECURITY_ATTRIBUTES security_attributes;
148 DWORD creation_disposition;
149 DWORD flags_and_attributes;
150 HANDLE template_file;
151 HANDLE _return_value;
152
153 if (!_PyArg_ParseStack(args, nargs, "skk" F_POINTER "kk" F_HANDLE ":CreateFile",
154 &file_name, &desired_access, &share_mode, &security_attributes, &creation_disposition, &flags_and_attributes, &template_file)) {
155 goto exit;
156 }
157 _return_value = _winapi_CreateFile_impl(module, file_name, desired_access, share_mode, security_attributes, creation_disposition, flags_and_attributes, template_file);
158 if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
159 goto exit;
160 }
161 if (_return_value == NULL) {
162 Py_RETURN_NONE;
163 }
164 return_value = HANDLE_TO_PYNUM(_return_value);
165
166 exit:
167 return return_value;
168 }
169
170 PyDoc_STRVAR(_winapi_CreateJunction__doc__,
171 "CreateJunction($module, src_path, dst_path, /)\n"
172 "--\n"
173 "\n");
174
175 #define _WINAPI_CREATEJUNCTION_METHODDEF \
176 {"CreateJunction", (PyCFunction)_winapi_CreateJunction, METH_FASTCALL, _winapi_CreateJunction__doc__},
177
178 static PyObject *
179 _winapi_CreateJunction_impl(PyObject *module, LPWSTR src_path,
180 LPWSTR dst_path);
181
182 static PyObject *
_winapi_CreateJunction(PyObject * module,PyObject * const * args,Py_ssize_t nargs)183 _winapi_CreateJunction(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
184 {
185 PyObject *return_value = NULL;
186 LPWSTR src_path;
187 LPWSTR dst_path;
188
189 if (!_PyArg_ParseStack(args, nargs, "uu:CreateJunction",
190 &src_path, &dst_path)) {
191 goto exit;
192 }
193 return_value = _winapi_CreateJunction_impl(module, src_path, dst_path);
194
195 exit:
196 return return_value;
197 }
198
199 PyDoc_STRVAR(_winapi_CreateNamedPipe__doc__,
200 "CreateNamedPipe($module, name, open_mode, pipe_mode, max_instances,\n"
201 " out_buffer_size, in_buffer_size, default_timeout,\n"
202 " security_attributes, /)\n"
203 "--\n"
204 "\n");
205
206 #define _WINAPI_CREATENAMEDPIPE_METHODDEF \
207 {"CreateNamedPipe", (PyCFunction)_winapi_CreateNamedPipe, METH_FASTCALL, _winapi_CreateNamedPipe__doc__},
208
209 static HANDLE
210 _winapi_CreateNamedPipe_impl(PyObject *module, LPCTSTR name, DWORD open_mode,
211 DWORD pipe_mode, DWORD max_instances,
212 DWORD out_buffer_size, DWORD in_buffer_size,
213 DWORD default_timeout,
214 LPSECURITY_ATTRIBUTES security_attributes);
215
216 static PyObject *
_winapi_CreateNamedPipe(PyObject * module,PyObject * const * args,Py_ssize_t nargs)217 _winapi_CreateNamedPipe(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
218 {
219 PyObject *return_value = NULL;
220 LPCTSTR name;
221 DWORD open_mode;
222 DWORD pipe_mode;
223 DWORD max_instances;
224 DWORD out_buffer_size;
225 DWORD in_buffer_size;
226 DWORD default_timeout;
227 LPSECURITY_ATTRIBUTES security_attributes;
228 HANDLE _return_value;
229
230 if (!_PyArg_ParseStack(args, nargs, "skkkkkk" F_POINTER ":CreateNamedPipe",
231 &name, &open_mode, &pipe_mode, &max_instances, &out_buffer_size, &in_buffer_size, &default_timeout, &security_attributes)) {
232 goto exit;
233 }
234 _return_value = _winapi_CreateNamedPipe_impl(module, name, open_mode, pipe_mode, max_instances, out_buffer_size, in_buffer_size, default_timeout, security_attributes);
235 if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
236 goto exit;
237 }
238 if (_return_value == NULL) {
239 Py_RETURN_NONE;
240 }
241 return_value = HANDLE_TO_PYNUM(_return_value);
242
243 exit:
244 return return_value;
245 }
246
247 PyDoc_STRVAR(_winapi_CreatePipe__doc__,
248 "CreatePipe($module, pipe_attrs, size, /)\n"
249 "--\n"
250 "\n"
251 "Create an anonymous pipe.\n"
252 "\n"
253 " pipe_attrs\n"
254 " Ignored internally, can be None.\n"
255 "\n"
256 "Returns a 2-tuple of handles, to the read and write ends of the pipe.");
257
258 #define _WINAPI_CREATEPIPE_METHODDEF \
259 {"CreatePipe", (PyCFunction)_winapi_CreatePipe, METH_FASTCALL, _winapi_CreatePipe__doc__},
260
261 static PyObject *
262 _winapi_CreatePipe_impl(PyObject *module, PyObject *pipe_attrs, DWORD size);
263
264 static PyObject *
_winapi_CreatePipe(PyObject * module,PyObject * const * args,Py_ssize_t nargs)265 _winapi_CreatePipe(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
266 {
267 PyObject *return_value = NULL;
268 PyObject *pipe_attrs;
269 DWORD size;
270
271 if (!_PyArg_ParseStack(args, nargs, "Ok:CreatePipe",
272 &pipe_attrs, &size)) {
273 goto exit;
274 }
275 return_value = _winapi_CreatePipe_impl(module, pipe_attrs, size);
276
277 exit:
278 return return_value;
279 }
280
281 PyDoc_STRVAR(_winapi_CreateProcess__doc__,
282 "CreateProcess($module, application_name, command_line, proc_attrs,\n"
283 " thread_attrs, inherit_handles, creation_flags,\n"
284 " env_mapping, current_directory, startup_info, /)\n"
285 "--\n"
286 "\n"
287 "Create a new process and its primary thread.\n"
288 "\n"
289 " command_line\n"
290 " Can be str or None\n"
291 " proc_attrs\n"
292 " Ignored internally, can be None.\n"
293 " thread_attrs\n"
294 " Ignored internally, can be None.\n"
295 "\n"
296 "The return value is a tuple of the process handle, thread handle,\n"
297 "process ID, and thread ID.");
298
299 #define _WINAPI_CREATEPROCESS_METHODDEF \
300 {"CreateProcess", (PyCFunction)_winapi_CreateProcess, METH_FASTCALL, _winapi_CreateProcess__doc__},
301
302 static PyObject *
303 _winapi_CreateProcess_impl(PyObject *module,
304 const Py_UNICODE *application_name,
305 PyObject *command_line, PyObject *proc_attrs,
306 PyObject *thread_attrs, BOOL inherit_handles,
307 DWORD creation_flags, PyObject *env_mapping,
308 const Py_UNICODE *current_directory,
309 PyObject *startup_info);
310
311 static PyObject *
_winapi_CreateProcess(PyObject * module,PyObject * const * args,Py_ssize_t nargs)312 _winapi_CreateProcess(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
313 {
314 PyObject *return_value = NULL;
315 const Py_UNICODE *application_name;
316 PyObject *command_line;
317 PyObject *proc_attrs;
318 PyObject *thread_attrs;
319 BOOL inherit_handles;
320 DWORD creation_flags;
321 PyObject *env_mapping;
322 const Py_UNICODE *current_directory;
323 PyObject *startup_info;
324
325 if (!_PyArg_ParseStack(args, nargs, "ZOOOikOZO:CreateProcess",
326 &application_name, &command_line, &proc_attrs, &thread_attrs, &inherit_handles, &creation_flags, &env_mapping, ¤t_directory, &startup_info)) {
327 goto exit;
328 }
329 return_value = _winapi_CreateProcess_impl(module, application_name, command_line, proc_attrs, thread_attrs, inherit_handles, creation_flags, env_mapping, current_directory, startup_info);
330
331 exit:
332 return return_value;
333 }
334
335 PyDoc_STRVAR(_winapi_DuplicateHandle__doc__,
336 "DuplicateHandle($module, source_process_handle, source_handle,\n"
337 " target_process_handle, desired_access, inherit_handle,\n"
338 " options=0, /)\n"
339 "--\n"
340 "\n"
341 "Return a duplicate handle object.\n"
342 "\n"
343 "The duplicate handle refers to the same object as the original\n"
344 "handle. Therefore, any changes to the object are reflected\n"
345 "through both handles.");
346
347 #define _WINAPI_DUPLICATEHANDLE_METHODDEF \
348 {"DuplicateHandle", (PyCFunction)_winapi_DuplicateHandle, METH_FASTCALL, _winapi_DuplicateHandle__doc__},
349
350 static HANDLE
351 _winapi_DuplicateHandle_impl(PyObject *module, HANDLE source_process_handle,
352 HANDLE source_handle,
353 HANDLE target_process_handle,
354 DWORD desired_access, BOOL inherit_handle,
355 DWORD options);
356
357 static PyObject *
_winapi_DuplicateHandle(PyObject * module,PyObject * const * args,Py_ssize_t nargs)358 _winapi_DuplicateHandle(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
359 {
360 PyObject *return_value = NULL;
361 HANDLE source_process_handle;
362 HANDLE source_handle;
363 HANDLE target_process_handle;
364 DWORD desired_access;
365 BOOL inherit_handle;
366 DWORD options = 0;
367 HANDLE _return_value;
368
369 if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "" F_HANDLE "" F_HANDLE "ki|k:DuplicateHandle",
370 &source_process_handle, &source_handle, &target_process_handle, &desired_access, &inherit_handle, &options)) {
371 goto exit;
372 }
373 _return_value = _winapi_DuplicateHandle_impl(module, source_process_handle, source_handle, target_process_handle, desired_access, inherit_handle, options);
374 if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
375 goto exit;
376 }
377 if (_return_value == NULL) {
378 Py_RETURN_NONE;
379 }
380 return_value = HANDLE_TO_PYNUM(_return_value);
381
382 exit:
383 return return_value;
384 }
385
386 PyDoc_STRVAR(_winapi_ExitProcess__doc__,
387 "ExitProcess($module, ExitCode, /)\n"
388 "--\n"
389 "\n");
390
391 #define _WINAPI_EXITPROCESS_METHODDEF \
392 {"ExitProcess", (PyCFunction)_winapi_ExitProcess, METH_O, _winapi_ExitProcess__doc__},
393
394 static PyObject *
395 _winapi_ExitProcess_impl(PyObject *module, UINT ExitCode);
396
397 static PyObject *
_winapi_ExitProcess(PyObject * module,PyObject * arg)398 _winapi_ExitProcess(PyObject *module, PyObject *arg)
399 {
400 PyObject *return_value = NULL;
401 UINT ExitCode;
402
403 if (!PyArg_Parse(arg, "I:ExitProcess", &ExitCode)) {
404 goto exit;
405 }
406 return_value = _winapi_ExitProcess_impl(module, ExitCode);
407
408 exit:
409 return return_value;
410 }
411
412 PyDoc_STRVAR(_winapi_GetCurrentProcess__doc__,
413 "GetCurrentProcess($module, /)\n"
414 "--\n"
415 "\n"
416 "Return a handle object for the current process.");
417
418 #define _WINAPI_GETCURRENTPROCESS_METHODDEF \
419 {"GetCurrentProcess", (PyCFunction)_winapi_GetCurrentProcess, METH_NOARGS, _winapi_GetCurrentProcess__doc__},
420
421 static HANDLE
422 _winapi_GetCurrentProcess_impl(PyObject *module);
423
424 static PyObject *
_winapi_GetCurrentProcess(PyObject * module,PyObject * Py_UNUSED (ignored))425 _winapi_GetCurrentProcess(PyObject *module, PyObject *Py_UNUSED(ignored))
426 {
427 PyObject *return_value = NULL;
428 HANDLE _return_value;
429
430 _return_value = _winapi_GetCurrentProcess_impl(module);
431 if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
432 goto exit;
433 }
434 if (_return_value == NULL) {
435 Py_RETURN_NONE;
436 }
437 return_value = HANDLE_TO_PYNUM(_return_value);
438
439 exit:
440 return return_value;
441 }
442
443 PyDoc_STRVAR(_winapi_GetExitCodeProcess__doc__,
444 "GetExitCodeProcess($module, process, /)\n"
445 "--\n"
446 "\n"
447 "Return the termination status of the specified process.");
448
449 #define _WINAPI_GETEXITCODEPROCESS_METHODDEF \
450 {"GetExitCodeProcess", (PyCFunction)_winapi_GetExitCodeProcess, METH_O, _winapi_GetExitCodeProcess__doc__},
451
452 static DWORD
453 _winapi_GetExitCodeProcess_impl(PyObject *module, HANDLE process);
454
455 static PyObject *
_winapi_GetExitCodeProcess(PyObject * module,PyObject * arg)456 _winapi_GetExitCodeProcess(PyObject *module, PyObject *arg)
457 {
458 PyObject *return_value = NULL;
459 HANDLE process;
460 DWORD _return_value;
461
462 if (!PyArg_Parse(arg, "" F_HANDLE ":GetExitCodeProcess", &process)) {
463 goto exit;
464 }
465 _return_value = _winapi_GetExitCodeProcess_impl(module, process);
466 if ((_return_value == PY_DWORD_MAX) && PyErr_Occurred()) {
467 goto exit;
468 }
469 return_value = Py_BuildValue("k", _return_value);
470
471 exit:
472 return return_value;
473 }
474
475 PyDoc_STRVAR(_winapi_GetLastError__doc__,
476 "GetLastError($module, /)\n"
477 "--\n"
478 "\n");
479
480 #define _WINAPI_GETLASTERROR_METHODDEF \
481 {"GetLastError", (PyCFunction)_winapi_GetLastError, METH_NOARGS, _winapi_GetLastError__doc__},
482
483 static DWORD
484 _winapi_GetLastError_impl(PyObject *module);
485
486 static PyObject *
_winapi_GetLastError(PyObject * module,PyObject * Py_UNUSED (ignored))487 _winapi_GetLastError(PyObject *module, PyObject *Py_UNUSED(ignored))
488 {
489 PyObject *return_value = NULL;
490 DWORD _return_value;
491
492 _return_value = _winapi_GetLastError_impl(module);
493 if ((_return_value == PY_DWORD_MAX) && PyErr_Occurred()) {
494 goto exit;
495 }
496 return_value = Py_BuildValue("k", _return_value);
497
498 exit:
499 return return_value;
500 }
501
502 PyDoc_STRVAR(_winapi_GetModuleFileName__doc__,
503 "GetModuleFileName($module, module_handle, /)\n"
504 "--\n"
505 "\n"
506 "Return the fully-qualified path for the file that contains module.\n"
507 "\n"
508 "The module must have been loaded by the current process.\n"
509 "\n"
510 "The module parameter should be a handle to the loaded module\n"
511 "whose path is being requested. If this parameter is 0,\n"
512 "GetModuleFileName retrieves the path of the executable file\n"
513 "of the current process.");
514
515 #define _WINAPI_GETMODULEFILENAME_METHODDEF \
516 {"GetModuleFileName", (PyCFunction)_winapi_GetModuleFileName, METH_O, _winapi_GetModuleFileName__doc__},
517
518 static PyObject *
519 _winapi_GetModuleFileName_impl(PyObject *module, HMODULE module_handle);
520
521 static PyObject *
_winapi_GetModuleFileName(PyObject * module,PyObject * arg)522 _winapi_GetModuleFileName(PyObject *module, PyObject *arg)
523 {
524 PyObject *return_value = NULL;
525 HMODULE module_handle;
526
527 if (!PyArg_Parse(arg, "" F_HANDLE ":GetModuleFileName", &module_handle)) {
528 goto exit;
529 }
530 return_value = _winapi_GetModuleFileName_impl(module, module_handle);
531
532 exit:
533 return return_value;
534 }
535
536 PyDoc_STRVAR(_winapi_GetStdHandle__doc__,
537 "GetStdHandle($module, std_handle, /)\n"
538 "--\n"
539 "\n"
540 "Return a handle to the specified standard device.\n"
541 "\n"
542 " std_handle\n"
543 " One of STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, or STD_ERROR_HANDLE.\n"
544 "\n"
545 "The integer associated with the handle object is returned.");
546
547 #define _WINAPI_GETSTDHANDLE_METHODDEF \
548 {"GetStdHandle", (PyCFunction)_winapi_GetStdHandle, METH_O, _winapi_GetStdHandle__doc__},
549
550 static HANDLE
551 _winapi_GetStdHandle_impl(PyObject *module, DWORD std_handle);
552
553 static PyObject *
_winapi_GetStdHandle(PyObject * module,PyObject * arg)554 _winapi_GetStdHandle(PyObject *module, PyObject *arg)
555 {
556 PyObject *return_value = NULL;
557 DWORD std_handle;
558 HANDLE _return_value;
559
560 if (!PyArg_Parse(arg, "k:GetStdHandle", &std_handle)) {
561 goto exit;
562 }
563 _return_value = _winapi_GetStdHandle_impl(module, std_handle);
564 if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
565 goto exit;
566 }
567 if (_return_value == NULL) {
568 Py_RETURN_NONE;
569 }
570 return_value = HANDLE_TO_PYNUM(_return_value);
571
572 exit:
573 return return_value;
574 }
575
576 PyDoc_STRVAR(_winapi_GetVersion__doc__,
577 "GetVersion($module, /)\n"
578 "--\n"
579 "\n"
580 "Return the version number of the current operating system.");
581
582 #define _WINAPI_GETVERSION_METHODDEF \
583 {"GetVersion", (PyCFunction)_winapi_GetVersion, METH_NOARGS, _winapi_GetVersion__doc__},
584
585 static long
586 _winapi_GetVersion_impl(PyObject *module);
587
588 static PyObject *
_winapi_GetVersion(PyObject * module,PyObject * Py_UNUSED (ignored))589 _winapi_GetVersion(PyObject *module, PyObject *Py_UNUSED(ignored))
590 {
591 PyObject *return_value = NULL;
592 long _return_value;
593
594 _return_value = _winapi_GetVersion_impl(module);
595 if ((_return_value == -1) && PyErr_Occurred()) {
596 goto exit;
597 }
598 return_value = PyLong_FromLong(_return_value);
599
600 exit:
601 return return_value;
602 }
603
604 PyDoc_STRVAR(_winapi_OpenProcess__doc__,
605 "OpenProcess($module, desired_access, inherit_handle, process_id, /)\n"
606 "--\n"
607 "\n");
608
609 #define _WINAPI_OPENPROCESS_METHODDEF \
610 {"OpenProcess", (PyCFunction)_winapi_OpenProcess, METH_FASTCALL, _winapi_OpenProcess__doc__},
611
612 static HANDLE
613 _winapi_OpenProcess_impl(PyObject *module, DWORD desired_access,
614 BOOL inherit_handle, DWORD process_id);
615
616 static PyObject *
_winapi_OpenProcess(PyObject * module,PyObject * const * args,Py_ssize_t nargs)617 _winapi_OpenProcess(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
618 {
619 PyObject *return_value = NULL;
620 DWORD desired_access;
621 BOOL inherit_handle;
622 DWORD process_id;
623 HANDLE _return_value;
624
625 if (!_PyArg_ParseStack(args, nargs, "kik:OpenProcess",
626 &desired_access, &inherit_handle, &process_id)) {
627 goto exit;
628 }
629 _return_value = _winapi_OpenProcess_impl(module, desired_access, inherit_handle, process_id);
630 if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
631 goto exit;
632 }
633 if (_return_value == NULL) {
634 Py_RETURN_NONE;
635 }
636 return_value = HANDLE_TO_PYNUM(_return_value);
637
638 exit:
639 return return_value;
640 }
641
642 PyDoc_STRVAR(_winapi_PeekNamedPipe__doc__,
643 "PeekNamedPipe($module, handle, size=0, /)\n"
644 "--\n"
645 "\n");
646
647 #define _WINAPI_PEEKNAMEDPIPE_METHODDEF \
648 {"PeekNamedPipe", (PyCFunction)_winapi_PeekNamedPipe, METH_FASTCALL, _winapi_PeekNamedPipe__doc__},
649
650 static PyObject *
651 _winapi_PeekNamedPipe_impl(PyObject *module, HANDLE handle, int size);
652
653 static PyObject *
_winapi_PeekNamedPipe(PyObject * module,PyObject * const * args,Py_ssize_t nargs)654 _winapi_PeekNamedPipe(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
655 {
656 PyObject *return_value = NULL;
657 HANDLE handle;
658 int size = 0;
659
660 if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "|i:PeekNamedPipe",
661 &handle, &size)) {
662 goto exit;
663 }
664 return_value = _winapi_PeekNamedPipe_impl(module, handle, size);
665
666 exit:
667 return return_value;
668 }
669
670 PyDoc_STRVAR(_winapi_ReadFile__doc__,
671 "ReadFile($module, /, handle, size, overlapped=False)\n"
672 "--\n"
673 "\n");
674
675 #define _WINAPI_READFILE_METHODDEF \
676 {"ReadFile", (PyCFunction)_winapi_ReadFile, METH_FASTCALL|METH_KEYWORDS, _winapi_ReadFile__doc__},
677
678 static PyObject *
679 _winapi_ReadFile_impl(PyObject *module, HANDLE handle, DWORD size,
680 int use_overlapped);
681
682 static PyObject *
_winapi_ReadFile(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)683 _winapi_ReadFile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
684 {
685 PyObject *return_value = NULL;
686 static const char * const _keywords[] = {"handle", "size", "overlapped", NULL};
687 static _PyArg_Parser _parser = {"" F_HANDLE "k|i:ReadFile", _keywords, 0};
688 HANDLE handle;
689 DWORD size;
690 int use_overlapped = 0;
691
692 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
693 &handle, &size, &use_overlapped)) {
694 goto exit;
695 }
696 return_value = _winapi_ReadFile_impl(module, handle, size, use_overlapped);
697
698 exit:
699 return return_value;
700 }
701
702 PyDoc_STRVAR(_winapi_SetNamedPipeHandleState__doc__,
703 "SetNamedPipeHandleState($module, named_pipe, mode,\n"
704 " max_collection_count, collect_data_timeout, /)\n"
705 "--\n"
706 "\n");
707
708 #define _WINAPI_SETNAMEDPIPEHANDLESTATE_METHODDEF \
709 {"SetNamedPipeHandleState", (PyCFunction)_winapi_SetNamedPipeHandleState, METH_FASTCALL, _winapi_SetNamedPipeHandleState__doc__},
710
711 static PyObject *
712 _winapi_SetNamedPipeHandleState_impl(PyObject *module, HANDLE named_pipe,
713 PyObject *mode,
714 PyObject *max_collection_count,
715 PyObject *collect_data_timeout);
716
717 static PyObject *
_winapi_SetNamedPipeHandleState(PyObject * module,PyObject * const * args,Py_ssize_t nargs)718 _winapi_SetNamedPipeHandleState(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
719 {
720 PyObject *return_value = NULL;
721 HANDLE named_pipe;
722 PyObject *mode;
723 PyObject *max_collection_count;
724 PyObject *collect_data_timeout;
725
726 if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "OOO:SetNamedPipeHandleState",
727 &named_pipe, &mode, &max_collection_count, &collect_data_timeout)) {
728 goto exit;
729 }
730 return_value = _winapi_SetNamedPipeHandleState_impl(module, named_pipe, mode, max_collection_count, collect_data_timeout);
731
732 exit:
733 return return_value;
734 }
735
736 PyDoc_STRVAR(_winapi_TerminateProcess__doc__,
737 "TerminateProcess($module, handle, exit_code, /)\n"
738 "--\n"
739 "\n"
740 "Terminate the specified process and all of its threads.");
741
742 #define _WINAPI_TERMINATEPROCESS_METHODDEF \
743 {"TerminateProcess", (PyCFunction)_winapi_TerminateProcess, METH_FASTCALL, _winapi_TerminateProcess__doc__},
744
745 static PyObject *
746 _winapi_TerminateProcess_impl(PyObject *module, HANDLE handle,
747 UINT exit_code);
748
749 static PyObject *
_winapi_TerminateProcess(PyObject * module,PyObject * const * args,Py_ssize_t nargs)750 _winapi_TerminateProcess(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
751 {
752 PyObject *return_value = NULL;
753 HANDLE handle;
754 UINT exit_code;
755
756 if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "I:TerminateProcess",
757 &handle, &exit_code)) {
758 goto exit;
759 }
760 return_value = _winapi_TerminateProcess_impl(module, handle, exit_code);
761
762 exit:
763 return return_value;
764 }
765
766 PyDoc_STRVAR(_winapi_WaitNamedPipe__doc__,
767 "WaitNamedPipe($module, name, timeout, /)\n"
768 "--\n"
769 "\n");
770
771 #define _WINAPI_WAITNAMEDPIPE_METHODDEF \
772 {"WaitNamedPipe", (PyCFunction)_winapi_WaitNamedPipe, METH_FASTCALL, _winapi_WaitNamedPipe__doc__},
773
774 static PyObject *
775 _winapi_WaitNamedPipe_impl(PyObject *module, LPCTSTR name, DWORD timeout);
776
777 static PyObject *
_winapi_WaitNamedPipe(PyObject * module,PyObject * const * args,Py_ssize_t nargs)778 _winapi_WaitNamedPipe(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
779 {
780 PyObject *return_value = NULL;
781 LPCTSTR name;
782 DWORD timeout;
783
784 if (!_PyArg_ParseStack(args, nargs, "sk:WaitNamedPipe",
785 &name, &timeout)) {
786 goto exit;
787 }
788 return_value = _winapi_WaitNamedPipe_impl(module, name, timeout);
789
790 exit:
791 return return_value;
792 }
793
794 PyDoc_STRVAR(_winapi_WaitForMultipleObjects__doc__,
795 "WaitForMultipleObjects($module, handle_seq, wait_flag,\n"
796 " milliseconds=_winapi.INFINITE, /)\n"
797 "--\n"
798 "\n");
799
800 #define _WINAPI_WAITFORMULTIPLEOBJECTS_METHODDEF \
801 {"WaitForMultipleObjects", (PyCFunction)_winapi_WaitForMultipleObjects, METH_FASTCALL, _winapi_WaitForMultipleObjects__doc__},
802
803 static PyObject *
804 _winapi_WaitForMultipleObjects_impl(PyObject *module, PyObject *handle_seq,
805 BOOL wait_flag, DWORD milliseconds);
806
807 static PyObject *
_winapi_WaitForMultipleObjects(PyObject * module,PyObject * const * args,Py_ssize_t nargs)808 _winapi_WaitForMultipleObjects(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
809 {
810 PyObject *return_value = NULL;
811 PyObject *handle_seq;
812 BOOL wait_flag;
813 DWORD milliseconds = INFINITE;
814
815 if (!_PyArg_ParseStack(args, nargs, "Oi|k:WaitForMultipleObjects",
816 &handle_seq, &wait_flag, &milliseconds)) {
817 goto exit;
818 }
819 return_value = _winapi_WaitForMultipleObjects_impl(module, handle_seq, wait_flag, milliseconds);
820
821 exit:
822 return return_value;
823 }
824
825 PyDoc_STRVAR(_winapi_WaitForSingleObject__doc__,
826 "WaitForSingleObject($module, handle, milliseconds, /)\n"
827 "--\n"
828 "\n"
829 "Wait for a single object.\n"
830 "\n"
831 "Wait until the specified object is in the signaled state or\n"
832 "the time-out interval elapses. The timeout value is specified\n"
833 "in milliseconds.");
834
835 #define _WINAPI_WAITFORSINGLEOBJECT_METHODDEF \
836 {"WaitForSingleObject", (PyCFunction)_winapi_WaitForSingleObject, METH_FASTCALL, _winapi_WaitForSingleObject__doc__},
837
838 static long
839 _winapi_WaitForSingleObject_impl(PyObject *module, HANDLE handle,
840 DWORD milliseconds);
841
842 static PyObject *
_winapi_WaitForSingleObject(PyObject * module,PyObject * const * args,Py_ssize_t nargs)843 _winapi_WaitForSingleObject(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
844 {
845 PyObject *return_value = NULL;
846 HANDLE handle;
847 DWORD milliseconds;
848 long _return_value;
849
850 if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "k:WaitForSingleObject",
851 &handle, &milliseconds)) {
852 goto exit;
853 }
854 _return_value = _winapi_WaitForSingleObject_impl(module, handle, milliseconds);
855 if ((_return_value == -1) && PyErr_Occurred()) {
856 goto exit;
857 }
858 return_value = PyLong_FromLong(_return_value);
859
860 exit:
861 return return_value;
862 }
863
864 PyDoc_STRVAR(_winapi_WriteFile__doc__,
865 "WriteFile($module, /, handle, buffer, overlapped=False)\n"
866 "--\n"
867 "\n");
868
869 #define _WINAPI_WRITEFILE_METHODDEF \
870 {"WriteFile", (PyCFunction)_winapi_WriteFile, METH_FASTCALL|METH_KEYWORDS, _winapi_WriteFile__doc__},
871
872 static PyObject *
873 _winapi_WriteFile_impl(PyObject *module, HANDLE handle, PyObject *buffer,
874 int use_overlapped);
875
876 static PyObject *
_winapi_WriteFile(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)877 _winapi_WriteFile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
878 {
879 PyObject *return_value = NULL;
880 static const char * const _keywords[] = {"handle", "buffer", "overlapped", NULL};
881 static _PyArg_Parser _parser = {"" F_HANDLE "O|i:WriteFile", _keywords, 0};
882 HANDLE handle;
883 PyObject *buffer;
884 int use_overlapped = 0;
885
886 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
887 &handle, &buffer, &use_overlapped)) {
888 goto exit;
889 }
890 return_value = _winapi_WriteFile_impl(module, handle, buffer, use_overlapped);
891
892 exit:
893 return return_value;
894 }
895
896 PyDoc_STRVAR(_winapi_GetACP__doc__,
897 "GetACP($module, /)\n"
898 "--\n"
899 "\n"
900 "Get the current Windows ANSI code page identifier.");
901
902 #define _WINAPI_GETACP_METHODDEF \
903 {"GetACP", (PyCFunction)_winapi_GetACP, METH_NOARGS, _winapi_GetACP__doc__},
904
905 static PyObject *
906 _winapi_GetACP_impl(PyObject *module);
907
908 static PyObject *
_winapi_GetACP(PyObject * module,PyObject * Py_UNUSED (ignored))909 _winapi_GetACP(PyObject *module, PyObject *Py_UNUSED(ignored))
910 {
911 return _winapi_GetACP_impl(module);
912 }
913
914 PyDoc_STRVAR(_winapi_GetFileType__doc__,
915 "GetFileType($module, /, handle)\n"
916 "--\n"
917 "\n");
918
919 #define _WINAPI_GETFILETYPE_METHODDEF \
920 {"GetFileType", (PyCFunction)_winapi_GetFileType, METH_FASTCALL|METH_KEYWORDS, _winapi_GetFileType__doc__},
921
922 static DWORD
923 _winapi_GetFileType_impl(PyObject *module, HANDLE handle);
924
925 static PyObject *
_winapi_GetFileType(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)926 _winapi_GetFileType(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
927 {
928 PyObject *return_value = NULL;
929 static const char * const _keywords[] = {"handle", NULL};
930 static _PyArg_Parser _parser = {"" F_HANDLE ":GetFileType", _keywords, 0};
931 HANDLE handle;
932 DWORD _return_value;
933
934 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
935 &handle)) {
936 goto exit;
937 }
938 _return_value = _winapi_GetFileType_impl(module, handle);
939 if ((_return_value == PY_DWORD_MAX) && PyErr_Occurred()) {
940 goto exit;
941 }
942 return_value = Py_BuildValue("k", _return_value);
943
944 exit:
945 return return_value;
946 }
947 /*[clinic end generated code: output=896d06ce2290aa86 input=a9049054013a1b77]*/
948