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 "kkkO&:CreateFileMapping",
199 &file_handle, &security_attributes, &protect, &max_size_high, &max_size_low, _PyUnicode_WideCharString_Converter, &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 /* Cleanup for name */
213 #if !USE_UNICODE_WCHAR_CACHE
214 PyMem_Free((void *)name);
215 #endif /* USE_UNICODE_WCHAR_CACHE */
216
217 return return_value;
218 }
219
220 PyDoc_STRVAR(_winapi_CreateJunction__doc__,
221 "CreateJunction($module, src_path, dst_path, /)\n"
222 "--\n"
223 "\n");
224
225 #define _WINAPI_CREATEJUNCTION_METHODDEF \
226 {"CreateJunction", (PyCFunction)(void(*)(void))_winapi_CreateJunction, METH_FASTCALL, _winapi_CreateJunction__doc__},
227
228 static PyObject *
229 _winapi_CreateJunction_impl(PyObject *module, LPCWSTR src_path,
230 LPCWSTR dst_path);
231
232 static PyObject *
_winapi_CreateJunction(PyObject * module,PyObject * const * args,Py_ssize_t nargs)233 _winapi_CreateJunction(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
234 {
235 PyObject *return_value = NULL;
236 LPCWSTR src_path;
237 LPCWSTR dst_path;
238
239 if (!_PyArg_CheckPositional("CreateJunction", nargs, 2, 2)) {
240 goto exit;
241 }
242 if (!PyUnicode_Check(args[0])) {
243 _PyArg_BadArgument("CreateJunction", "argument 1", "str", args[0]);
244 goto exit;
245 }
246 #if USE_UNICODE_WCHAR_CACHE
247 src_path = _PyUnicode_AsUnicode(args[0]);
248 #else /* USE_UNICODE_WCHAR_CACHE */
249 src_path = PyUnicode_AsWideCharString(args[0], NULL);
250 #endif /* USE_UNICODE_WCHAR_CACHE */
251 if (src_path == NULL) {
252 goto exit;
253 }
254 if (!PyUnicode_Check(args[1])) {
255 _PyArg_BadArgument("CreateJunction", "argument 2", "str", args[1]);
256 goto exit;
257 }
258 #if USE_UNICODE_WCHAR_CACHE
259 dst_path = _PyUnicode_AsUnicode(args[1]);
260 #else /* USE_UNICODE_WCHAR_CACHE */
261 dst_path = PyUnicode_AsWideCharString(args[1], NULL);
262 #endif /* USE_UNICODE_WCHAR_CACHE */
263 if (dst_path == NULL) {
264 goto exit;
265 }
266 return_value = _winapi_CreateJunction_impl(module, src_path, dst_path);
267
268 exit:
269 /* Cleanup for src_path */
270 #if !USE_UNICODE_WCHAR_CACHE
271 PyMem_Free((void *)src_path);
272 #endif /* USE_UNICODE_WCHAR_CACHE */
273 /* Cleanup for dst_path */
274 #if !USE_UNICODE_WCHAR_CACHE
275 PyMem_Free((void *)dst_path);
276 #endif /* USE_UNICODE_WCHAR_CACHE */
277
278 return return_value;
279 }
280
281 PyDoc_STRVAR(_winapi_CreateNamedPipe__doc__,
282 "CreateNamedPipe($module, name, open_mode, pipe_mode, max_instances,\n"
283 " out_buffer_size, in_buffer_size, default_timeout,\n"
284 " security_attributes, /)\n"
285 "--\n"
286 "\n");
287
288 #define _WINAPI_CREATENAMEDPIPE_METHODDEF \
289 {"CreateNamedPipe", (PyCFunction)(void(*)(void))_winapi_CreateNamedPipe, METH_FASTCALL, _winapi_CreateNamedPipe__doc__},
290
291 static HANDLE
292 _winapi_CreateNamedPipe_impl(PyObject *module, LPCTSTR name, DWORD open_mode,
293 DWORD pipe_mode, DWORD max_instances,
294 DWORD out_buffer_size, DWORD in_buffer_size,
295 DWORD default_timeout,
296 LPSECURITY_ATTRIBUTES security_attributes);
297
298 static PyObject *
_winapi_CreateNamedPipe(PyObject * module,PyObject * const * args,Py_ssize_t nargs)299 _winapi_CreateNamedPipe(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
300 {
301 PyObject *return_value = NULL;
302 LPCTSTR name;
303 DWORD open_mode;
304 DWORD pipe_mode;
305 DWORD max_instances;
306 DWORD out_buffer_size;
307 DWORD in_buffer_size;
308 DWORD default_timeout;
309 LPSECURITY_ATTRIBUTES security_attributes;
310 HANDLE _return_value;
311
312 if (!_PyArg_ParseStack(args, nargs, "skkkkkk" F_POINTER ":CreateNamedPipe",
313 &name, &open_mode, &pipe_mode, &max_instances, &out_buffer_size, &in_buffer_size, &default_timeout, &security_attributes)) {
314 goto exit;
315 }
316 _return_value = _winapi_CreateNamedPipe_impl(module, name, open_mode, pipe_mode, max_instances, out_buffer_size, in_buffer_size, default_timeout, security_attributes);
317 if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
318 goto exit;
319 }
320 if (_return_value == NULL) {
321 Py_RETURN_NONE;
322 }
323 return_value = HANDLE_TO_PYNUM(_return_value);
324
325 exit:
326 return return_value;
327 }
328
329 PyDoc_STRVAR(_winapi_CreatePipe__doc__,
330 "CreatePipe($module, pipe_attrs, size, /)\n"
331 "--\n"
332 "\n"
333 "Create an anonymous pipe.\n"
334 "\n"
335 " pipe_attrs\n"
336 " Ignored internally, can be None.\n"
337 "\n"
338 "Returns a 2-tuple of handles, to the read and write ends of the pipe.");
339
340 #define _WINAPI_CREATEPIPE_METHODDEF \
341 {"CreatePipe", (PyCFunction)(void(*)(void))_winapi_CreatePipe, METH_FASTCALL, _winapi_CreatePipe__doc__},
342
343 static PyObject *
344 _winapi_CreatePipe_impl(PyObject *module, PyObject *pipe_attrs, DWORD size);
345
346 static PyObject *
_winapi_CreatePipe(PyObject * module,PyObject * const * args,Py_ssize_t nargs)347 _winapi_CreatePipe(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
348 {
349 PyObject *return_value = NULL;
350 PyObject *pipe_attrs;
351 DWORD size;
352
353 if (!_PyArg_ParseStack(args, nargs, "Ok:CreatePipe",
354 &pipe_attrs, &size)) {
355 goto exit;
356 }
357 return_value = _winapi_CreatePipe_impl(module, pipe_attrs, size);
358
359 exit:
360 return return_value;
361 }
362
363 PyDoc_STRVAR(_winapi_CreateProcess__doc__,
364 "CreateProcess($module, application_name, command_line, proc_attrs,\n"
365 " thread_attrs, inherit_handles, creation_flags,\n"
366 " env_mapping, current_directory, startup_info, /)\n"
367 "--\n"
368 "\n"
369 "Create a new process and its primary thread.\n"
370 "\n"
371 " command_line\n"
372 " Can be str or None\n"
373 " proc_attrs\n"
374 " Ignored internally, can be None.\n"
375 " thread_attrs\n"
376 " Ignored internally, can be None.\n"
377 "\n"
378 "The return value is a tuple of the process handle, thread handle,\n"
379 "process ID, and thread ID.");
380
381 #define _WINAPI_CREATEPROCESS_METHODDEF \
382 {"CreateProcess", (PyCFunction)(void(*)(void))_winapi_CreateProcess, METH_FASTCALL, _winapi_CreateProcess__doc__},
383
384 static PyObject *
385 _winapi_CreateProcess_impl(PyObject *module,
386 const Py_UNICODE *application_name,
387 PyObject *command_line, PyObject *proc_attrs,
388 PyObject *thread_attrs, BOOL inherit_handles,
389 DWORD creation_flags, PyObject *env_mapping,
390 const Py_UNICODE *current_directory,
391 PyObject *startup_info);
392
393 static PyObject *
_winapi_CreateProcess(PyObject * module,PyObject * const * args,Py_ssize_t nargs)394 _winapi_CreateProcess(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
395 {
396 PyObject *return_value = NULL;
397 const Py_UNICODE *application_name;
398 PyObject *command_line;
399 PyObject *proc_attrs;
400 PyObject *thread_attrs;
401 BOOL inherit_handles;
402 DWORD creation_flags;
403 PyObject *env_mapping;
404 const Py_UNICODE *current_directory;
405 PyObject *startup_info;
406
407 if (!_PyArg_ParseStack(args, nargs, "O&OOOikOO&O:CreateProcess",
408 _PyUnicode_WideCharString_Opt_Converter, &application_name, &command_line, &proc_attrs, &thread_attrs, &inherit_handles, &creation_flags, &env_mapping, _PyUnicode_WideCharString_Opt_Converter, ¤t_directory, &startup_info)) {
409 goto exit;
410 }
411 return_value = _winapi_CreateProcess_impl(module, application_name, command_line, proc_attrs, thread_attrs, inherit_handles, creation_flags, env_mapping, current_directory, startup_info);
412
413 exit:
414 /* Cleanup for application_name */
415 #if !USE_UNICODE_WCHAR_CACHE
416 PyMem_Free((void *)application_name);
417 #endif /* USE_UNICODE_WCHAR_CACHE */
418 /* Cleanup for current_directory */
419 #if !USE_UNICODE_WCHAR_CACHE
420 PyMem_Free((void *)current_directory);
421 #endif /* USE_UNICODE_WCHAR_CACHE */
422
423 return return_value;
424 }
425
426 PyDoc_STRVAR(_winapi_DuplicateHandle__doc__,
427 "DuplicateHandle($module, source_process_handle, source_handle,\n"
428 " target_process_handle, desired_access, inherit_handle,\n"
429 " options=0, /)\n"
430 "--\n"
431 "\n"
432 "Return a duplicate handle object.\n"
433 "\n"
434 "The duplicate handle refers to the same object as the original\n"
435 "handle. Therefore, any changes to the object are reflected\n"
436 "through both handles.");
437
438 #define _WINAPI_DUPLICATEHANDLE_METHODDEF \
439 {"DuplicateHandle", (PyCFunction)(void(*)(void))_winapi_DuplicateHandle, METH_FASTCALL, _winapi_DuplicateHandle__doc__},
440
441 static HANDLE
442 _winapi_DuplicateHandle_impl(PyObject *module, HANDLE source_process_handle,
443 HANDLE source_handle,
444 HANDLE target_process_handle,
445 DWORD desired_access, BOOL inherit_handle,
446 DWORD options);
447
448 static PyObject *
_winapi_DuplicateHandle(PyObject * module,PyObject * const * args,Py_ssize_t nargs)449 _winapi_DuplicateHandle(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
450 {
451 PyObject *return_value = NULL;
452 HANDLE source_process_handle;
453 HANDLE source_handle;
454 HANDLE target_process_handle;
455 DWORD desired_access;
456 BOOL inherit_handle;
457 DWORD options = 0;
458 HANDLE _return_value;
459
460 if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "" F_HANDLE "" F_HANDLE "ki|k:DuplicateHandle",
461 &source_process_handle, &source_handle, &target_process_handle, &desired_access, &inherit_handle, &options)) {
462 goto exit;
463 }
464 _return_value = _winapi_DuplicateHandle_impl(module, source_process_handle, source_handle, target_process_handle, desired_access, inherit_handle, options);
465 if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
466 goto exit;
467 }
468 if (_return_value == NULL) {
469 Py_RETURN_NONE;
470 }
471 return_value = HANDLE_TO_PYNUM(_return_value);
472
473 exit:
474 return return_value;
475 }
476
477 PyDoc_STRVAR(_winapi_ExitProcess__doc__,
478 "ExitProcess($module, ExitCode, /)\n"
479 "--\n"
480 "\n");
481
482 #define _WINAPI_EXITPROCESS_METHODDEF \
483 {"ExitProcess", (PyCFunction)_winapi_ExitProcess, METH_O, _winapi_ExitProcess__doc__},
484
485 static PyObject *
486 _winapi_ExitProcess_impl(PyObject *module, UINT ExitCode);
487
488 static PyObject *
_winapi_ExitProcess(PyObject * module,PyObject * arg)489 _winapi_ExitProcess(PyObject *module, PyObject *arg)
490 {
491 PyObject *return_value = NULL;
492 UINT ExitCode;
493
494 if (!PyArg_Parse(arg, "I:ExitProcess", &ExitCode)) {
495 goto exit;
496 }
497 return_value = _winapi_ExitProcess_impl(module, ExitCode);
498
499 exit:
500 return return_value;
501 }
502
503 PyDoc_STRVAR(_winapi_GetCurrentProcess__doc__,
504 "GetCurrentProcess($module, /)\n"
505 "--\n"
506 "\n"
507 "Return a handle object for the current process.");
508
509 #define _WINAPI_GETCURRENTPROCESS_METHODDEF \
510 {"GetCurrentProcess", (PyCFunction)_winapi_GetCurrentProcess, METH_NOARGS, _winapi_GetCurrentProcess__doc__},
511
512 static HANDLE
513 _winapi_GetCurrentProcess_impl(PyObject *module);
514
515 static PyObject *
_winapi_GetCurrentProcess(PyObject * module,PyObject * Py_UNUSED (ignored))516 _winapi_GetCurrentProcess(PyObject *module, PyObject *Py_UNUSED(ignored))
517 {
518 PyObject *return_value = NULL;
519 HANDLE _return_value;
520
521 _return_value = _winapi_GetCurrentProcess_impl(module);
522 if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
523 goto exit;
524 }
525 if (_return_value == NULL) {
526 Py_RETURN_NONE;
527 }
528 return_value = HANDLE_TO_PYNUM(_return_value);
529
530 exit:
531 return return_value;
532 }
533
534 PyDoc_STRVAR(_winapi_GetExitCodeProcess__doc__,
535 "GetExitCodeProcess($module, process, /)\n"
536 "--\n"
537 "\n"
538 "Return the termination status of the specified process.");
539
540 #define _WINAPI_GETEXITCODEPROCESS_METHODDEF \
541 {"GetExitCodeProcess", (PyCFunction)_winapi_GetExitCodeProcess, METH_O, _winapi_GetExitCodeProcess__doc__},
542
543 static DWORD
544 _winapi_GetExitCodeProcess_impl(PyObject *module, HANDLE process);
545
546 static PyObject *
_winapi_GetExitCodeProcess(PyObject * module,PyObject * arg)547 _winapi_GetExitCodeProcess(PyObject *module, PyObject *arg)
548 {
549 PyObject *return_value = NULL;
550 HANDLE process;
551 DWORD _return_value;
552
553 if (!PyArg_Parse(arg, "" F_HANDLE ":GetExitCodeProcess", &process)) {
554 goto exit;
555 }
556 _return_value = _winapi_GetExitCodeProcess_impl(module, process);
557 if ((_return_value == PY_DWORD_MAX) && PyErr_Occurred()) {
558 goto exit;
559 }
560 return_value = Py_BuildValue("k", _return_value);
561
562 exit:
563 return return_value;
564 }
565
566 PyDoc_STRVAR(_winapi_GetLastError__doc__,
567 "GetLastError($module, /)\n"
568 "--\n"
569 "\n");
570
571 #define _WINAPI_GETLASTERROR_METHODDEF \
572 {"GetLastError", (PyCFunction)_winapi_GetLastError, METH_NOARGS, _winapi_GetLastError__doc__},
573
574 static DWORD
575 _winapi_GetLastError_impl(PyObject *module);
576
577 static PyObject *
_winapi_GetLastError(PyObject * module,PyObject * Py_UNUSED (ignored))578 _winapi_GetLastError(PyObject *module, PyObject *Py_UNUSED(ignored))
579 {
580 PyObject *return_value = NULL;
581 DWORD _return_value;
582
583 _return_value = _winapi_GetLastError_impl(module);
584 if ((_return_value == PY_DWORD_MAX) && PyErr_Occurred()) {
585 goto exit;
586 }
587 return_value = Py_BuildValue("k", _return_value);
588
589 exit:
590 return return_value;
591 }
592
593 PyDoc_STRVAR(_winapi_GetModuleFileName__doc__,
594 "GetModuleFileName($module, module_handle, /)\n"
595 "--\n"
596 "\n"
597 "Return the fully-qualified path for the file that contains module.\n"
598 "\n"
599 "The module must have been loaded by the current process.\n"
600 "\n"
601 "The module parameter should be a handle to the loaded module\n"
602 "whose path is being requested. If this parameter is 0,\n"
603 "GetModuleFileName retrieves the path of the executable file\n"
604 "of the current process.");
605
606 #define _WINAPI_GETMODULEFILENAME_METHODDEF \
607 {"GetModuleFileName", (PyCFunction)_winapi_GetModuleFileName, METH_O, _winapi_GetModuleFileName__doc__},
608
609 static PyObject *
610 _winapi_GetModuleFileName_impl(PyObject *module, HMODULE module_handle);
611
612 static PyObject *
_winapi_GetModuleFileName(PyObject * module,PyObject * arg)613 _winapi_GetModuleFileName(PyObject *module, PyObject *arg)
614 {
615 PyObject *return_value = NULL;
616 HMODULE module_handle;
617
618 if (!PyArg_Parse(arg, "" F_HANDLE ":GetModuleFileName", &module_handle)) {
619 goto exit;
620 }
621 return_value = _winapi_GetModuleFileName_impl(module, module_handle);
622
623 exit:
624 return return_value;
625 }
626
627 PyDoc_STRVAR(_winapi_GetStdHandle__doc__,
628 "GetStdHandle($module, std_handle, /)\n"
629 "--\n"
630 "\n"
631 "Return a handle to the specified standard device.\n"
632 "\n"
633 " std_handle\n"
634 " One of STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, or STD_ERROR_HANDLE.\n"
635 "\n"
636 "The integer associated with the handle object is returned.");
637
638 #define _WINAPI_GETSTDHANDLE_METHODDEF \
639 {"GetStdHandle", (PyCFunction)_winapi_GetStdHandle, METH_O, _winapi_GetStdHandle__doc__},
640
641 static HANDLE
642 _winapi_GetStdHandle_impl(PyObject *module, DWORD std_handle);
643
644 static PyObject *
_winapi_GetStdHandle(PyObject * module,PyObject * arg)645 _winapi_GetStdHandle(PyObject *module, PyObject *arg)
646 {
647 PyObject *return_value = NULL;
648 DWORD std_handle;
649 HANDLE _return_value;
650
651 if (!PyArg_Parse(arg, "k:GetStdHandle", &std_handle)) {
652 goto exit;
653 }
654 _return_value = _winapi_GetStdHandle_impl(module, std_handle);
655 if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
656 goto exit;
657 }
658 if (_return_value == NULL) {
659 Py_RETURN_NONE;
660 }
661 return_value = HANDLE_TO_PYNUM(_return_value);
662
663 exit:
664 return return_value;
665 }
666
667 PyDoc_STRVAR(_winapi_GetVersion__doc__,
668 "GetVersion($module, /)\n"
669 "--\n"
670 "\n"
671 "Return the version number of the current operating system.");
672
673 #define _WINAPI_GETVERSION_METHODDEF \
674 {"GetVersion", (PyCFunction)_winapi_GetVersion, METH_NOARGS, _winapi_GetVersion__doc__},
675
676 static long
677 _winapi_GetVersion_impl(PyObject *module);
678
679 static PyObject *
_winapi_GetVersion(PyObject * module,PyObject * Py_UNUSED (ignored))680 _winapi_GetVersion(PyObject *module, PyObject *Py_UNUSED(ignored))
681 {
682 PyObject *return_value = NULL;
683 long _return_value;
684
685 _return_value = _winapi_GetVersion_impl(module);
686 if ((_return_value == -1) && PyErr_Occurred()) {
687 goto exit;
688 }
689 return_value = PyLong_FromLong(_return_value);
690
691 exit:
692 return return_value;
693 }
694
695 PyDoc_STRVAR(_winapi_MapViewOfFile__doc__,
696 "MapViewOfFile($module, file_map, desired_access, file_offset_high,\n"
697 " file_offset_low, number_bytes, /)\n"
698 "--\n"
699 "\n");
700
701 #define _WINAPI_MAPVIEWOFFILE_METHODDEF \
702 {"MapViewOfFile", (PyCFunction)(void(*)(void))_winapi_MapViewOfFile, METH_FASTCALL, _winapi_MapViewOfFile__doc__},
703
704 static LPVOID
705 _winapi_MapViewOfFile_impl(PyObject *module, HANDLE file_map,
706 DWORD desired_access, DWORD file_offset_high,
707 DWORD file_offset_low, size_t number_bytes);
708
709 static PyObject *
_winapi_MapViewOfFile(PyObject * module,PyObject * const * args,Py_ssize_t nargs)710 _winapi_MapViewOfFile(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
711 {
712 PyObject *return_value = NULL;
713 HANDLE file_map;
714 DWORD desired_access;
715 DWORD file_offset_high;
716 DWORD file_offset_low;
717 size_t number_bytes;
718 LPVOID _return_value;
719
720 if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "kkkO&:MapViewOfFile",
721 &file_map, &desired_access, &file_offset_high, &file_offset_low, _PyLong_Size_t_Converter, &number_bytes)) {
722 goto exit;
723 }
724 _return_value = _winapi_MapViewOfFile_impl(module, file_map, desired_access, file_offset_high, file_offset_low, number_bytes);
725 if ((_return_value == NULL) && PyErr_Occurred()) {
726 goto exit;
727 }
728 return_value = HANDLE_TO_PYNUM(_return_value);
729
730 exit:
731 return return_value;
732 }
733
734 PyDoc_STRVAR(_winapi_OpenFileMapping__doc__,
735 "OpenFileMapping($module, desired_access, inherit_handle, name, /)\n"
736 "--\n"
737 "\n");
738
739 #define _WINAPI_OPENFILEMAPPING_METHODDEF \
740 {"OpenFileMapping", (PyCFunction)(void(*)(void))_winapi_OpenFileMapping, METH_FASTCALL, _winapi_OpenFileMapping__doc__},
741
742 static HANDLE
743 _winapi_OpenFileMapping_impl(PyObject *module, DWORD desired_access,
744 BOOL inherit_handle, LPCWSTR name);
745
746 static PyObject *
_winapi_OpenFileMapping(PyObject * module,PyObject * const * args,Py_ssize_t nargs)747 _winapi_OpenFileMapping(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
748 {
749 PyObject *return_value = NULL;
750 DWORD desired_access;
751 BOOL inherit_handle;
752 LPCWSTR name;
753 HANDLE _return_value;
754
755 if (!_PyArg_ParseStack(args, nargs, "kiO&:OpenFileMapping",
756 &desired_access, &inherit_handle, _PyUnicode_WideCharString_Converter, &name)) {
757 goto exit;
758 }
759 _return_value = _winapi_OpenFileMapping_impl(module, desired_access, inherit_handle, name);
760 if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
761 goto exit;
762 }
763 if (_return_value == NULL) {
764 Py_RETURN_NONE;
765 }
766 return_value = HANDLE_TO_PYNUM(_return_value);
767
768 exit:
769 /* Cleanup for name */
770 #if !USE_UNICODE_WCHAR_CACHE
771 PyMem_Free((void *)name);
772 #endif /* USE_UNICODE_WCHAR_CACHE */
773
774 return return_value;
775 }
776
777 PyDoc_STRVAR(_winapi_OpenProcess__doc__,
778 "OpenProcess($module, desired_access, inherit_handle, process_id, /)\n"
779 "--\n"
780 "\n");
781
782 #define _WINAPI_OPENPROCESS_METHODDEF \
783 {"OpenProcess", (PyCFunction)(void(*)(void))_winapi_OpenProcess, METH_FASTCALL, _winapi_OpenProcess__doc__},
784
785 static HANDLE
786 _winapi_OpenProcess_impl(PyObject *module, DWORD desired_access,
787 BOOL inherit_handle, DWORD process_id);
788
789 static PyObject *
_winapi_OpenProcess(PyObject * module,PyObject * const * args,Py_ssize_t nargs)790 _winapi_OpenProcess(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
791 {
792 PyObject *return_value = NULL;
793 DWORD desired_access;
794 BOOL inherit_handle;
795 DWORD process_id;
796 HANDLE _return_value;
797
798 if (!_PyArg_ParseStack(args, nargs, "kik:OpenProcess",
799 &desired_access, &inherit_handle, &process_id)) {
800 goto exit;
801 }
802 _return_value = _winapi_OpenProcess_impl(module, desired_access, inherit_handle, process_id);
803 if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
804 goto exit;
805 }
806 if (_return_value == NULL) {
807 Py_RETURN_NONE;
808 }
809 return_value = HANDLE_TO_PYNUM(_return_value);
810
811 exit:
812 return return_value;
813 }
814
815 PyDoc_STRVAR(_winapi_PeekNamedPipe__doc__,
816 "PeekNamedPipe($module, handle, size=0, /)\n"
817 "--\n"
818 "\n");
819
820 #define _WINAPI_PEEKNAMEDPIPE_METHODDEF \
821 {"PeekNamedPipe", (PyCFunction)(void(*)(void))_winapi_PeekNamedPipe, METH_FASTCALL, _winapi_PeekNamedPipe__doc__},
822
823 static PyObject *
824 _winapi_PeekNamedPipe_impl(PyObject *module, HANDLE handle, int size);
825
826 static PyObject *
_winapi_PeekNamedPipe(PyObject * module,PyObject * const * args,Py_ssize_t nargs)827 _winapi_PeekNamedPipe(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
828 {
829 PyObject *return_value = NULL;
830 HANDLE handle;
831 int size = 0;
832
833 if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "|i:PeekNamedPipe",
834 &handle, &size)) {
835 goto exit;
836 }
837 return_value = _winapi_PeekNamedPipe_impl(module, handle, size);
838
839 exit:
840 return return_value;
841 }
842
843 PyDoc_STRVAR(_winapi_ReadFile__doc__,
844 "ReadFile($module, /, handle, size, overlapped=False)\n"
845 "--\n"
846 "\n");
847
848 #define _WINAPI_READFILE_METHODDEF \
849 {"ReadFile", (PyCFunction)(void(*)(void))_winapi_ReadFile, METH_FASTCALL|METH_KEYWORDS, _winapi_ReadFile__doc__},
850
851 static PyObject *
852 _winapi_ReadFile_impl(PyObject *module, HANDLE handle, DWORD size,
853 int use_overlapped);
854
855 static PyObject *
_winapi_ReadFile(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)856 _winapi_ReadFile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
857 {
858 PyObject *return_value = NULL;
859 static const char * const _keywords[] = {"handle", "size", "overlapped", NULL};
860 static _PyArg_Parser _parser = {"" F_HANDLE "k|i:ReadFile", _keywords, 0};
861 HANDLE handle;
862 DWORD size;
863 int use_overlapped = 0;
864
865 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
866 &handle, &size, &use_overlapped)) {
867 goto exit;
868 }
869 return_value = _winapi_ReadFile_impl(module, handle, size, use_overlapped);
870
871 exit:
872 return return_value;
873 }
874
875 PyDoc_STRVAR(_winapi_SetNamedPipeHandleState__doc__,
876 "SetNamedPipeHandleState($module, named_pipe, mode,\n"
877 " max_collection_count, collect_data_timeout, /)\n"
878 "--\n"
879 "\n");
880
881 #define _WINAPI_SETNAMEDPIPEHANDLESTATE_METHODDEF \
882 {"SetNamedPipeHandleState", (PyCFunction)(void(*)(void))_winapi_SetNamedPipeHandleState, METH_FASTCALL, _winapi_SetNamedPipeHandleState__doc__},
883
884 static PyObject *
885 _winapi_SetNamedPipeHandleState_impl(PyObject *module, HANDLE named_pipe,
886 PyObject *mode,
887 PyObject *max_collection_count,
888 PyObject *collect_data_timeout);
889
890 static PyObject *
_winapi_SetNamedPipeHandleState(PyObject * module,PyObject * const * args,Py_ssize_t nargs)891 _winapi_SetNamedPipeHandleState(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
892 {
893 PyObject *return_value = NULL;
894 HANDLE named_pipe;
895 PyObject *mode;
896 PyObject *max_collection_count;
897 PyObject *collect_data_timeout;
898
899 if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "OOO:SetNamedPipeHandleState",
900 &named_pipe, &mode, &max_collection_count, &collect_data_timeout)) {
901 goto exit;
902 }
903 return_value = _winapi_SetNamedPipeHandleState_impl(module, named_pipe, mode, max_collection_count, collect_data_timeout);
904
905 exit:
906 return return_value;
907 }
908
909 PyDoc_STRVAR(_winapi_TerminateProcess__doc__,
910 "TerminateProcess($module, handle, exit_code, /)\n"
911 "--\n"
912 "\n"
913 "Terminate the specified process and all of its threads.");
914
915 #define _WINAPI_TERMINATEPROCESS_METHODDEF \
916 {"TerminateProcess", (PyCFunction)(void(*)(void))_winapi_TerminateProcess, METH_FASTCALL, _winapi_TerminateProcess__doc__},
917
918 static PyObject *
919 _winapi_TerminateProcess_impl(PyObject *module, HANDLE handle,
920 UINT exit_code);
921
922 static PyObject *
_winapi_TerminateProcess(PyObject * module,PyObject * const * args,Py_ssize_t nargs)923 _winapi_TerminateProcess(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
924 {
925 PyObject *return_value = NULL;
926 HANDLE handle;
927 UINT exit_code;
928
929 if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "I:TerminateProcess",
930 &handle, &exit_code)) {
931 goto exit;
932 }
933 return_value = _winapi_TerminateProcess_impl(module, handle, exit_code);
934
935 exit:
936 return return_value;
937 }
938
939 PyDoc_STRVAR(_winapi_VirtualQuerySize__doc__,
940 "VirtualQuerySize($module, address, /)\n"
941 "--\n"
942 "\n");
943
944 #define _WINAPI_VIRTUALQUERYSIZE_METHODDEF \
945 {"VirtualQuerySize", (PyCFunction)_winapi_VirtualQuerySize, METH_O, _winapi_VirtualQuerySize__doc__},
946
947 static size_t
948 _winapi_VirtualQuerySize_impl(PyObject *module, LPCVOID address);
949
950 static PyObject *
_winapi_VirtualQuerySize(PyObject * module,PyObject * arg)951 _winapi_VirtualQuerySize(PyObject *module, PyObject *arg)
952 {
953 PyObject *return_value = NULL;
954 LPCVOID address;
955 size_t _return_value;
956
957 if (!PyArg_Parse(arg, "" F_POINTER ":VirtualQuerySize", &address)) {
958 goto exit;
959 }
960 _return_value = _winapi_VirtualQuerySize_impl(module, address);
961 if ((_return_value == (size_t)-1) && PyErr_Occurred()) {
962 goto exit;
963 }
964 return_value = PyLong_FromSize_t(_return_value);
965
966 exit:
967 return return_value;
968 }
969
970 PyDoc_STRVAR(_winapi_WaitNamedPipe__doc__,
971 "WaitNamedPipe($module, name, timeout, /)\n"
972 "--\n"
973 "\n");
974
975 #define _WINAPI_WAITNAMEDPIPE_METHODDEF \
976 {"WaitNamedPipe", (PyCFunction)(void(*)(void))_winapi_WaitNamedPipe, METH_FASTCALL, _winapi_WaitNamedPipe__doc__},
977
978 static PyObject *
979 _winapi_WaitNamedPipe_impl(PyObject *module, LPCTSTR name, DWORD timeout);
980
981 static PyObject *
_winapi_WaitNamedPipe(PyObject * module,PyObject * const * args,Py_ssize_t nargs)982 _winapi_WaitNamedPipe(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
983 {
984 PyObject *return_value = NULL;
985 LPCTSTR name;
986 DWORD timeout;
987
988 if (!_PyArg_ParseStack(args, nargs, "sk:WaitNamedPipe",
989 &name, &timeout)) {
990 goto exit;
991 }
992 return_value = _winapi_WaitNamedPipe_impl(module, name, timeout);
993
994 exit:
995 return return_value;
996 }
997
998 PyDoc_STRVAR(_winapi_WaitForMultipleObjects__doc__,
999 "WaitForMultipleObjects($module, handle_seq, wait_flag,\n"
1000 " milliseconds=_winapi.INFINITE, /)\n"
1001 "--\n"
1002 "\n");
1003
1004 #define _WINAPI_WAITFORMULTIPLEOBJECTS_METHODDEF \
1005 {"WaitForMultipleObjects", (PyCFunction)(void(*)(void))_winapi_WaitForMultipleObjects, METH_FASTCALL, _winapi_WaitForMultipleObjects__doc__},
1006
1007 static PyObject *
1008 _winapi_WaitForMultipleObjects_impl(PyObject *module, PyObject *handle_seq,
1009 BOOL wait_flag, DWORD milliseconds);
1010
1011 static PyObject *
_winapi_WaitForMultipleObjects(PyObject * module,PyObject * const * args,Py_ssize_t nargs)1012 _winapi_WaitForMultipleObjects(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1013 {
1014 PyObject *return_value = NULL;
1015 PyObject *handle_seq;
1016 BOOL wait_flag;
1017 DWORD milliseconds = INFINITE;
1018
1019 if (!_PyArg_ParseStack(args, nargs, "Oi|k:WaitForMultipleObjects",
1020 &handle_seq, &wait_flag, &milliseconds)) {
1021 goto exit;
1022 }
1023 return_value = _winapi_WaitForMultipleObjects_impl(module, handle_seq, wait_flag, milliseconds);
1024
1025 exit:
1026 return return_value;
1027 }
1028
1029 PyDoc_STRVAR(_winapi_WaitForSingleObject__doc__,
1030 "WaitForSingleObject($module, handle, milliseconds, /)\n"
1031 "--\n"
1032 "\n"
1033 "Wait for a single object.\n"
1034 "\n"
1035 "Wait until the specified object is in the signaled state or\n"
1036 "the time-out interval elapses. The timeout value is specified\n"
1037 "in milliseconds.");
1038
1039 #define _WINAPI_WAITFORSINGLEOBJECT_METHODDEF \
1040 {"WaitForSingleObject", (PyCFunction)(void(*)(void))_winapi_WaitForSingleObject, METH_FASTCALL, _winapi_WaitForSingleObject__doc__},
1041
1042 static long
1043 _winapi_WaitForSingleObject_impl(PyObject *module, HANDLE handle,
1044 DWORD milliseconds);
1045
1046 static PyObject *
_winapi_WaitForSingleObject(PyObject * module,PyObject * const * args,Py_ssize_t nargs)1047 _winapi_WaitForSingleObject(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1048 {
1049 PyObject *return_value = NULL;
1050 HANDLE handle;
1051 DWORD milliseconds;
1052 long _return_value;
1053
1054 if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "k:WaitForSingleObject",
1055 &handle, &milliseconds)) {
1056 goto exit;
1057 }
1058 _return_value = _winapi_WaitForSingleObject_impl(module, handle, milliseconds);
1059 if ((_return_value == -1) && PyErr_Occurred()) {
1060 goto exit;
1061 }
1062 return_value = PyLong_FromLong(_return_value);
1063
1064 exit:
1065 return return_value;
1066 }
1067
1068 PyDoc_STRVAR(_winapi_WriteFile__doc__,
1069 "WriteFile($module, /, handle, buffer, overlapped=False)\n"
1070 "--\n"
1071 "\n");
1072
1073 #define _WINAPI_WRITEFILE_METHODDEF \
1074 {"WriteFile", (PyCFunction)(void(*)(void))_winapi_WriteFile, METH_FASTCALL|METH_KEYWORDS, _winapi_WriteFile__doc__},
1075
1076 static PyObject *
1077 _winapi_WriteFile_impl(PyObject *module, HANDLE handle, PyObject *buffer,
1078 int use_overlapped);
1079
1080 static PyObject *
_winapi_WriteFile(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)1081 _winapi_WriteFile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1082 {
1083 PyObject *return_value = NULL;
1084 static const char * const _keywords[] = {"handle", "buffer", "overlapped", NULL};
1085 static _PyArg_Parser _parser = {"" F_HANDLE "O|i:WriteFile", _keywords, 0};
1086 HANDLE handle;
1087 PyObject *buffer;
1088 int use_overlapped = 0;
1089
1090 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
1091 &handle, &buffer, &use_overlapped)) {
1092 goto exit;
1093 }
1094 return_value = _winapi_WriteFile_impl(module, handle, buffer, use_overlapped);
1095
1096 exit:
1097 return return_value;
1098 }
1099
1100 PyDoc_STRVAR(_winapi_GetACP__doc__,
1101 "GetACP($module, /)\n"
1102 "--\n"
1103 "\n"
1104 "Get the current Windows ANSI code page identifier.");
1105
1106 #define _WINAPI_GETACP_METHODDEF \
1107 {"GetACP", (PyCFunction)_winapi_GetACP, METH_NOARGS, _winapi_GetACP__doc__},
1108
1109 static PyObject *
1110 _winapi_GetACP_impl(PyObject *module);
1111
1112 static PyObject *
_winapi_GetACP(PyObject * module,PyObject * Py_UNUSED (ignored))1113 _winapi_GetACP(PyObject *module, PyObject *Py_UNUSED(ignored))
1114 {
1115 return _winapi_GetACP_impl(module);
1116 }
1117
1118 PyDoc_STRVAR(_winapi_GetFileType__doc__,
1119 "GetFileType($module, /, handle)\n"
1120 "--\n"
1121 "\n");
1122
1123 #define _WINAPI_GETFILETYPE_METHODDEF \
1124 {"GetFileType", (PyCFunction)(void(*)(void))_winapi_GetFileType, METH_FASTCALL|METH_KEYWORDS, _winapi_GetFileType__doc__},
1125
1126 static DWORD
1127 _winapi_GetFileType_impl(PyObject *module, HANDLE handle);
1128
1129 static PyObject *
_winapi_GetFileType(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)1130 _winapi_GetFileType(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1131 {
1132 PyObject *return_value = NULL;
1133 static const char * const _keywords[] = {"handle", NULL};
1134 static _PyArg_Parser _parser = {"" F_HANDLE ":GetFileType", _keywords, 0};
1135 HANDLE handle;
1136 DWORD _return_value;
1137
1138 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
1139 &handle)) {
1140 goto exit;
1141 }
1142 _return_value = _winapi_GetFileType_impl(module, handle);
1143 if ((_return_value == PY_DWORD_MAX) && PyErr_Occurred()) {
1144 goto exit;
1145 }
1146 return_value = Py_BuildValue("k", _return_value);
1147
1148 exit:
1149 return return_value;
1150 }
1151
1152 PyDoc_STRVAR(_winapi__mimetypes_read_windows_registry__doc__,
1153 "_mimetypes_read_windows_registry($module, /, on_type_read)\n"
1154 "--\n"
1155 "\n"
1156 "Optimized function for reading all known MIME types from the registry.\n"
1157 "\n"
1158 "*on_type_read* is a callable taking *type* and *ext* arguments, as for\n"
1159 "MimeTypes.add_type.");
1160
1161 #define _WINAPI__MIMETYPES_READ_WINDOWS_REGISTRY_METHODDEF \
1162 {"_mimetypes_read_windows_registry", (PyCFunction)(void(*)(void))_winapi__mimetypes_read_windows_registry, METH_FASTCALL|METH_KEYWORDS, _winapi__mimetypes_read_windows_registry__doc__},
1163
1164 static PyObject *
1165 _winapi__mimetypes_read_windows_registry_impl(PyObject *module,
1166 PyObject *on_type_read);
1167
1168 static PyObject *
_winapi__mimetypes_read_windows_registry(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)1169 _winapi__mimetypes_read_windows_registry(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1170 {
1171 PyObject *return_value = NULL;
1172 static const char * const _keywords[] = {"on_type_read", NULL};
1173 static _PyArg_Parser _parser = {NULL, _keywords, "_mimetypes_read_windows_registry", 0};
1174 PyObject *argsbuf[1];
1175 PyObject *on_type_read;
1176
1177 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
1178 if (!args) {
1179 goto exit;
1180 }
1181 on_type_read = args[0];
1182 return_value = _winapi__mimetypes_read_windows_registry_impl(module, on_type_read);
1183
1184 exit:
1185 return return_value;
1186 }
1187 /*[clinic end generated code: output=ac3623be6e42017c input=a9049054013a1b77]*/
1188