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