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 * 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 * 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 * 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 * 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, _winapi_ConnectNamedPipe__doc__}, 99 100 static PyObject * 101 _winapi_ConnectNamedPipe_impl(PyObject *module, HANDLE handle, 102 int use_overlapped); 103 104 static PyObject * 105 _winapi_ConnectNamedPipe(PyObject *module, PyObject **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_ParseStack(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_VARARGS, _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 * 141 _winapi_CreateFile(PyObject *module, PyObject *args) 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_ParseTuple(args, "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_VARARGS, _winapi_CreateJunction__doc__}, 177 178 static PyObject * 179 _winapi_CreateJunction_impl(PyObject *module, LPWSTR src_path, 180 LPWSTR dst_path); 181 182 static PyObject * 183 _winapi_CreateJunction(PyObject *module, PyObject *args) 184 { 185 PyObject *return_value = NULL; 186 LPWSTR src_path; 187 LPWSTR dst_path; 188 189 if (!PyArg_ParseTuple(args, "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_VARARGS, _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 * 217 _winapi_CreateNamedPipe(PyObject *module, PyObject *args) 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_ParseTuple(args, "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_VARARGS, _winapi_CreatePipe__doc__}, 260 261 static PyObject * 262 _winapi_CreatePipe_impl(PyObject *module, PyObject *pipe_attrs, DWORD size); 263 264 static PyObject * 265 _winapi_CreatePipe(PyObject *module, PyObject *args) 266 { 267 PyObject *return_value = NULL; 268 PyObject *pipe_attrs; 269 DWORD size; 270 271 if (!PyArg_ParseTuple(args, "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 " proc_attrs\n" 290 " Ignored internally, can be None.\n" 291 " thread_attrs\n" 292 " Ignored internally, can be None.\n" 293 "\n" 294 "The return value is a tuple of the process handle, thread handle,\n" 295 "process ID, and thread ID."); 296 297 #define _WINAPI_CREATEPROCESS_METHODDEF \ 298 {"CreateProcess", (PyCFunction)_winapi_CreateProcess, METH_VARARGS, _winapi_CreateProcess__doc__}, 299 300 static PyObject * 301 _winapi_CreateProcess_impl(PyObject *module, Py_UNICODE *application_name, 302 Py_UNICODE *command_line, PyObject *proc_attrs, 303 PyObject *thread_attrs, BOOL inherit_handles, 304 DWORD creation_flags, PyObject *env_mapping, 305 Py_UNICODE *current_directory, 306 PyObject *startup_info); 307 308 static PyObject * 309 _winapi_CreateProcess(PyObject *module, PyObject *args) 310 { 311 PyObject *return_value = NULL; 312 Py_UNICODE *application_name; 313 Py_UNICODE *command_line; 314 PyObject *proc_attrs; 315 PyObject *thread_attrs; 316 BOOL inherit_handles; 317 DWORD creation_flags; 318 PyObject *env_mapping; 319 Py_UNICODE *current_directory; 320 PyObject *startup_info; 321 322 if (!PyArg_ParseTuple(args, "ZZOOikOZO:CreateProcess", 323 &application_name, &command_line, &proc_attrs, &thread_attrs, &inherit_handles, &creation_flags, &env_mapping, ¤t_directory, &startup_info)) { 324 goto exit; 325 } 326 return_value = _winapi_CreateProcess_impl(module, application_name, command_line, proc_attrs, thread_attrs, inherit_handles, creation_flags, env_mapping, current_directory, startup_info); 327 328 exit: 329 return return_value; 330 } 331 332 PyDoc_STRVAR(_winapi_DuplicateHandle__doc__, 333 "DuplicateHandle($module, source_process_handle, source_handle,\n" 334 " target_process_handle, desired_access, inherit_handle,\n" 335 " options=0, /)\n" 336 "--\n" 337 "\n" 338 "Return a duplicate handle object.\n" 339 "\n" 340 "The duplicate handle refers to the same object as the original\n" 341 "handle. Therefore, any changes to the object are reflected\n" 342 "through both handles."); 343 344 #define _WINAPI_DUPLICATEHANDLE_METHODDEF \ 345 {"DuplicateHandle", (PyCFunction)_winapi_DuplicateHandle, METH_VARARGS, _winapi_DuplicateHandle__doc__}, 346 347 static HANDLE 348 _winapi_DuplicateHandle_impl(PyObject *module, HANDLE source_process_handle, 349 HANDLE source_handle, 350 HANDLE target_process_handle, 351 DWORD desired_access, BOOL inherit_handle, 352 DWORD options); 353 354 static PyObject * 355 _winapi_DuplicateHandle(PyObject *module, PyObject *args) 356 { 357 PyObject *return_value = NULL; 358 HANDLE source_process_handle; 359 HANDLE source_handle; 360 HANDLE target_process_handle; 361 DWORD desired_access; 362 BOOL inherit_handle; 363 DWORD options = 0; 364 HANDLE _return_value; 365 366 if (!PyArg_ParseTuple(args, "" F_HANDLE "" F_HANDLE "" F_HANDLE "ki|k:DuplicateHandle", 367 &source_process_handle, &source_handle, &target_process_handle, &desired_access, &inherit_handle, &options)) { 368 goto exit; 369 } 370 _return_value = _winapi_DuplicateHandle_impl(module, source_process_handle, source_handle, target_process_handle, desired_access, inherit_handle, options); 371 if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) { 372 goto exit; 373 } 374 if (_return_value == NULL) { 375 Py_RETURN_NONE; 376 } 377 return_value = HANDLE_TO_PYNUM(_return_value); 378 379 exit: 380 return return_value; 381 } 382 383 PyDoc_STRVAR(_winapi_ExitProcess__doc__, 384 "ExitProcess($module, ExitCode, /)\n" 385 "--\n" 386 "\n"); 387 388 #define _WINAPI_EXITPROCESS_METHODDEF \ 389 {"ExitProcess", (PyCFunction)_winapi_ExitProcess, METH_O, _winapi_ExitProcess__doc__}, 390 391 static PyObject * 392 _winapi_ExitProcess_impl(PyObject *module, UINT ExitCode); 393 394 static PyObject * 395 _winapi_ExitProcess(PyObject *module, PyObject *arg) 396 { 397 PyObject *return_value = NULL; 398 UINT ExitCode; 399 400 if (!PyArg_Parse(arg, "I:ExitProcess", &ExitCode)) { 401 goto exit; 402 } 403 return_value = _winapi_ExitProcess_impl(module, ExitCode); 404 405 exit: 406 return return_value; 407 } 408 409 PyDoc_STRVAR(_winapi_GetCurrentProcess__doc__, 410 "GetCurrentProcess($module, /)\n" 411 "--\n" 412 "\n" 413 "Return a handle object for the current process."); 414 415 #define _WINAPI_GETCURRENTPROCESS_METHODDEF \ 416 {"GetCurrentProcess", (PyCFunction)_winapi_GetCurrentProcess, METH_NOARGS, _winapi_GetCurrentProcess__doc__}, 417 418 static HANDLE 419 _winapi_GetCurrentProcess_impl(PyObject *module); 420 421 static PyObject * 422 _winapi_GetCurrentProcess(PyObject *module, PyObject *Py_UNUSED(ignored)) 423 { 424 PyObject *return_value = NULL; 425 HANDLE _return_value; 426 427 _return_value = _winapi_GetCurrentProcess_impl(module); 428 if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) { 429 goto exit; 430 } 431 if (_return_value == NULL) { 432 Py_RETURN_NONE; 433 } 434 return_value = HANDLE_TO_PYNUM(_return_value); 435 436 exit: 437 return return_value; 438 } 439 440 PyDoc_STRVAR(_winapi_GetExitCodeProcess__doc__, 441 "GetExitCodeProcess($module, process, /)\n" 442 "--\n" 443 "\n" 444 "Return the termination status of the specified process."); 445 446 #define _WINAPI_GETEXITCODEPROCESS_METHODDEF \ 447 {"GetExitCodeProcess", (PyCFunction)_winapi_GetExitCodeProcess, METH_O, _winapi_GetExitCodeProcess__doc__}, 448 449 static DWORD 450 _winapi_GetExitCodeProcess_impl(PyObject *module, HANDLE process); 451 452 static PyObject * 453 _winapi_GetExitCodeProcess(PyObject *module, PyObject *arg) 454 { 455 PyObject *return_value = NULL; 456 HANDLE process; 457 DWORD _return_value; 458 459 if (!PyArg_Parse(arg, "" F_HANDLE ":GetExitCodeProcess", &process)) { 460 goto exit; 461 } 462 _return_value = _winapi_GetExitCodeProcess_impl(module, process); 463 if ((_return_value == DWORD_MAX) && PyErr_Occurred()) { 464 goto exit; 465 } 466 return_value = Py_BuildValue("k", _return_value); 467 468 exit: 469 return return_value; 470 } 471 472 PyDoc_STRVAR(_winapi_GetLastError__doc__, 473 "GetLastError($module, /)\n" 474 "--\n" 475 "\n"); 476 477 #define _WINAPI_GETLASTERROR_METHODDEF \ 478 {"GetLastError", (PyCFunction)_winapi_GetLastError, METH_NOARGS, _winapi_GetLastError__doc__}, 479 480 static DWORD 481 _winapi_GetLastError_impl(PyObject *module); 482 483 static PyObject * 484 _winapi_GetLastError(PyObject *module, PyObject *Py_UNUSED(ignored)) 485 { 486 PyObject *return_value = NULL; 487 DWORD _return_value; 488 489 _return_value = _winapi_GetLastError_impl(module); 490 if ((_return_value == DWORD_MAX) && PyErr_Occurred()) { 491 goto exit; 492 } 493 return_value = Py_BuildValue("k", _return_value); 494 495 exit: 496 return return_value; 497 } 498 499 PyDoc_STRVAR(_winapi_GetModuleFileName__doc__, 500 "GetModuleFileName($module, module_handle, /)\n" 501 "--\n" 502 "\n" 503 "Return the fully-qualified path for the file that contains module.\n" 504 "\n" 505 "The module must have been loaded by the current process.\n" 506 "\n" 507 "The module parameter should be a handle to the loaded module\n" 508 "whose path is being requested. If this parameter is 0,\n" 509 "GetModuleFileName retrieves the path of the executable file\n" 510 "of the current process."); 511 512 #define _WINAPI_GETMODULEFILENAME_METHODDEF \ 513 {"GetModuleFileName", (PyCFunction)_winapi_GetModuleFileName, METH_O, _winapi_GetModuleFileName__doc__}, 514 515 static PyObject * 516 _winapi_GetModuleFileName_impl(PyObject *module, HMODULE module_handle); 517 518 static PyObject * 519 _winapi_GetModuleFileName(PyObject *module, PyObject *arg) 520 { 521 PyObject *return_value = NULL; 522 HMODULE module_handle; 523 524 if (!PyArg_Parse(arg, "" F_HANDLE ":GetModuleFileName", &module_handle)) { 525 goto exit; 526 } 527 return_value = _winapi_GetModuleFileName_impl(module, module_handle); 528 529 exit: 530 return return_value; 531 } 532 533 PyDoc_STRVAR(_winapi_GetStdHandle__doc__, 534 "GetStdHandle($module, std_handle, /)\n" 535 "--\n" 536 "\n" 537 "Return a handle to the specified standard device.\n" 538 "\n" 539 " std_handle\n" 540 " One of STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, or STD_ERROR_HANDLE.\n" 541 "\n" 542 "The integer associated with the handle object is returned."); 543 544 #define _WINAPI_GETSTDHANDLE_METHODDEF \ 545 {"GetStdHandle", (PyCFunction)_winapi_GetStdHandle, METH_O, _winapi_GetStdHandle__doc__}, 546 547 static HANDLE 548 _winapi_GetStdHandle_impl(PyObject *module, DWORD std_handle); 549 550 static PyObject * 551 _winapi_GetStdHandle(PyObject *module, PyObject *arg) 552 { 553 PyObject *return_value = NULL; 554 DWORD std_handle; 555 HANDLE _return_value; 556 557 if (!PyArg_Parse(arg, "k:GetStdHandle", &std_handle)) { 558 goto exit; 559 } 560 _return_value = _winapi_GetStdHandle_impl(module, std_handle); 561 if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) { 562 goto exit; 563 } 564 if (_return_value == NULL) { 565 Py_RETURN_NONE; 566 } 567 return_value = HANDLE_TO_PYNUM(_return_value); 568 569 exit: 570 return return_value; 571 } 572 573 PyDoc_STRVAR(_winapi_GetVersion__doc__, 574 "GetVersion($module, /)\n" 575 "--\n" 576 "\n" 577 "Return the version number of the current operating system."); 578 579 #define _WINAPI_GETVERSION_METHODDEF \ 580 {"GetVersion", (PyCFunction)_winapi_GetVersion, METH_NOARGS, _winapi_GetVersion__doc__}, 581 582 static long 583 _winapi_GetVersion_impl(PyObject *module); 584 585 static PyObject * 586 _winapi_GetVersion(PyObject *module, PyObject *Py_UNUSED(ignored)) 587 { 588 PyObject *return_value = NULL; 589 long _return_value; 590 591 _return_value = _winapi_GetVersion_impl(module); 592 if ((_return_value == -1) && PyErr_Occurred()) { 593 goto exit; 594 } 595 return_value = PyLong_FromLong(_return_value); 596 597 exit: 598 return return_value; 599 } 600 601 PyDoc_STRVAR(_winapi_OpenProcess__doc__, 602 "OpenProcess($module, desired_access, inherit_handle, process_id, /)\n" 603 "--\n" 604 "\n"); 605 606 #define _WINAPI_OPENPROCESS_METHODDEF \ 607 {"OpenProcess", (PyCFunction)_winapi_OpenProcess, METH_VARARGS, _winapi_OpenProcess__doc__}, 608 609 static HANDLE 610 _winapi_OpenProcess_impl(PyObject *module, DWORD desired_access, 611 BOOL inherit_handle, DWORD process_id); 612 613 static PyObject * 614 _winapi_OpenProcess(PyObject *module, PyObject *args) 615 { 616 PyObject *return_value = NULL; 617 DWORD desired_access; 618 BOOL inherit_handle; 619 DWORD process_id; 620 HANDLE _return_value; 621 622 if (!PyArg_ParseTuple(args, "kik:OpenProcess", 623 &desired_access, &inherit_handle, &process_id)) { 624 goto exit; 625 } 626 _return_value = _winapi_OpenProcess_impl(module, desired_access, inherit_handle, process_id); 627 if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) { 628 goto exit; 629 } 630 if (_return_value == NULL) { 631 Py_RETURN_NONE; 632 } 633 return_value = HANDLE_TO_PYNUM(_return_value); 634 635 exit: 636 return return_value; 637 } 638 639 PyDoc_STRVAR(_winapi_PeekNamedPipe__doc__, 640 "PeekNamedPipe($module, handle, size=0, /)\n" 641 "--\n" 642 "\n"); 643 644 #define _WINAPI_PEEKNAMEDPIPE_METHODDEF \ 645 {"PeekNamedPipe", (PyCFunction)_winapi_PeekNamedPipe, METH_VARARGS, _winapi_PeekNamedPipe__doc__}, 646 647 static PyObject * 648 _winapi_PeekNamedPipe_impl(PyObject *module, HANDLE handle, int size); 649 650 static PyObject * 651 _winapi_PeekNamedPipe(PyObject *module, PyObject *args) 652 { 653 PyObject *return_value = NULL; 654 HANDLE handle; 655 int size = 0; 656 657 if (!PyArg_ParseTuple(args, "" F_HANDLE "|i:PeekNamedPipe", 658 &handle, &size)) { 659 goto exit; 660 } 661 return_value = _winapi_PeekNamedPipe_impl(module, handle, size); 662 663 exit: 664 return return_value; 665 } 666 667 PyDoc_STRVAR(_winapi_ReadFile__doc__, 668 "ReadFile($module, /, handle, size, overlapped=False)\n" 669 "--\n" 670 "\n"); 671 672 #define _WINAPI_READFILE_METHODDEF \ 673 {"ReadFile", (PyCFunction)_winapi_ReadFile, METH_FASTCALL, _winapi_ReadFile__doc__}, 674 675 static PyObject * 676 _winapi_ReadFile_impl(PyObject *module, HANDLE handle, int size, 677 int use_overlapped); 678 679 static PyObject * 680 _winapi_ReadFile(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) 681 { 682 PyObject *return_value = NULL; 683 static const char * const _keywords[] = {"handle", "size", "overlapped", NULL}; 684 static _PyArg_Parser _parser = {"" F_HANDLE "i|i:ReadFile", _keywords, 0}; 685 HANDLE handle; 686 int size; 687 int use_overlapped = 0; 688 689 if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, 690 &handle, &size, &use_overlapped)) { 691 goto exit; 692 } 693 return_value = _winapi_ReadFile_impl(module, handle, size, use_overlapped); 694 695 exit: 696 return return_value; 697 } 698 699 PyDoc_STRVAR(_winapi_SetNamedPipeHandleState__doc__, 700 "SetNamedPipeHandleState($module, named_pipe, mode,\n" 701 " max_collection_count, collect_data_timeout, /)\n" 702 "--\n" 703 "\n"); 704 705 #define _WINAPI_SETNAMEDPIPEHANDLESTATE_METHODDEF \ 706 {"SetNamedPipeHandleState", (PyCFunction)_winapi_SetNamedPipeHandleState, METH_VARARGS, _winapi_SetNamedPipeHandleState__doc__}, 707 708 static PyObject * 709 _winapi_SetNamedPipeHandleState_impl(PyObject *module, HANDLE named_pipe, 710 PyObject *mode, 711 PyObject *max_collection_count, 712 PyObject *collect_data_timeout); 713 714 static PyObject * 715 _winapi_SetNamedPipeHandleState(PyObject *module, PyObject *args) 716 { 717 PyObject *return_value = NULL; 718 HANDLE named_pipe; 719 PyObject *mode; 720 PyObject *max_collection_count; 721 PyObject *collect_data_timeout; 722 723 if (!PyArg_ParseTuple(args, "" F_HANDLE "OOO:SetNamedPipeHandleState", 724 &named_pipe, &mode, &max_collection_count, &collect_data_timeout)) { 725 goto exit; 726 } 727 return_value = _winapi_SetNamedPipeHandleState_impl(module, named_pipe, mode, max_collection_count, collect_data_timeout); 728 729 exit: 730 return return_value; 731 } 732 733 PyDoc_STRVAR(_winapi_TerminateProcess__doc__, 734 "TerminateProcess($module, handle, exit_code, /)\n" 735 "--\n" 736 "\n" 737 "Terminate the specified process and all of its threads."); 738 739 #define _WINAPI_TERMINATEPROCESS_METHODDEF \ 740 {"TerminateProcess", (PyCFunction)_winapi_TerminateProcess, METH_VARARGS, _winapi_TerminateProcess__doc__}, 741 742 static PyObject * 743 _winapi_TerminateProcess_impl(PyObject *module, HANDLE handle, 744 UINT exit_code); 745 746 static PyObject * 747 _winapi_TerminateProcess(PyObject *module, PyObject *args) 748 { 749 PyObject *return_value = NULL; 750 HANDLE handle; 751 UINT exit_code; 752 753 if (!PyArg_ParseTuple(args, "" F_HANDLE "I:TerminateProcess", 754 &handle, &exit_code)) { 755 goto exit; 756 } 757 return_value = _winapi_TerminateProcess_impl(module, handle, exit_code); 758 759 exit: 760 return return_value; 761 } 762 763 PyDoc_STRVAR(_winapi_WaitNamedPipe__doc__, 764 "WaitNamedPipe($module, name, timeout, /)\n" 765 "--\n" 766 "\n"); 767 768 #define _WINAPI_WAITNAMEDPIPE_METHODDEF \ 769 {"WaitNamedPipe", (PyCFunction)_winapi_WaitNamedPipe, METH_VARARGS, _winapi_WaitNamedPipe__doc__}, 770 771 static PyObject * 772 _winapi_WaitNamedPipe_impl(PyObject *module, LPCTSTR name, DWORD timeout); 773 774 static PyObject * 775 _winapi_WaitNamedPipe(PyObject *module, PyObject *args) 776 { 777 PyObject *return_value = NULL; 778 LPCTSTR name; 779 DWORD timeout; 780 781 if (!PyArg_ParseTuple(args, "sk:WaitNamedPipe", 782 &name, &timeout)) { 783 goto exit; 784 } 785 return_value = _winapi_WaitNamedPipe_impl(module, name, timeout); 786 787 exit: 788 return return_value; 789 } 790 791 PyDoc_STRVAR(_winapi_WaitForMultipleObjects__doc__, 792 "WaitForMultipleObjects($module, handle_seq, wait_flag,\n" 793 " milliseconds=_winapi.INFINITE, /)\n" 794 "--\n" 795 "\n"); 796 797 #define _WINAPI_WAITFORMULTIPLEOBJECTS_METHODDEF \ 798 {"WaitForMultipleObjects", (PyCFunction)_winapi_WaitForMultipleObjects, METH_VARARGS, _winapi_WaitForMultipleObjects__doc__}, 799 800 static PyObject * 801 _winapi_WaitForMultipleObjects_impl(PyObject *module, PyObject *handle_seq, 802 BOOL wait_flag, DWORD milliseconds); 803 804 static PyObject * 805 _winapi_WaitForMultipleObjects(PyObject *module, PyObject *args) 806 { 807 PyObject *return_value = NULL; 808 PyObject *handle_seq; 809 BOOL wait_flag; 810 DWORD milliseconds = INFINITE; 811 812 if (!PyArg_ParseTuple(args, "Oi|k:WaitForMultipleObjects", 813 &handle_seq, &wait_flag, &milliseconds)) { 814 goto exit; 815 } 816 return_value = _winapi_WaitForMultipleObjects_impl(module, handle_seq, wait_flag, milliseconds); 817 818 exit: 819 return return_value; 820 } 821 822 PyDoc_STRVAR(_winapi_WaitForSingleObject__doc__, 823 "WaitForSingleObject($module, handle, milliseconds, /)\n" 824 "--\n" 825 "\n" 826 "Wait for a single object.\n" 827 "\n" 828 "Wait until the specified object is in the signaled state or\n" 829 "the time-out interval elapses. The timeout value is specified\n" 830 "in milliseconds."); 831 832 #define _WINAPI_WAITFORSINGLEOBJECT_METHODDEF \ 833 {"WaitForSingleObject", (PyCFunction)_winapi_WaitForSingleObject, METH_VARARGS, _winapi_WaitForSingleObject__doc__}, 834 835 static long 836 _winapi_WaitForSingleObject_impl(PyObject *module, HANDLE handle, 837 DWORD milliseconds); 838 839 static PyObject * 840 _winapi_WaitForSingleObject(PyObject *module, PyObject *args) 841 { 842 PyObject *return_value = NULL; 843 HANDLE handle; 844 DWORD milliseconds; 845 long _return_value; 846 847 if (!PyArg_ParseTuple(args, "" F_HANDLE "k:WaitForSingleObject", 848 &handle, &milliseconds)) { 849 goto exit; 850 } 851 _return_value = _winapi_WaitForSingleObject_impl(module, handle, milliseconds); 852 if ((_return_value == -1) && PyErr_Occurred()) { 853 goto exit; 854 } 855 return_value = PyLong_FromLong(_return_value); 856 857 exit: 858 return return_value; 859 } 860 861 PyDoc_STRVAR(_winapi_WriteFile__doc__, 862 "WriteFile($module, /, handle, buffer, overlapped=False)\n" 863 "--\n" 864 "\n"); 865 866 #define _WINAPI_WRITEFILE_METHODDEF \ 867 {"WriteFile", (PyCFunction)_winapi_WriteFile, METH_FASTCALL, _winapi_WriteFile__doc__}, 868 869 static PyObject * 870 _winapi_WriteFile_impl(PyObject *module, HANDLE handle, PyObject *buffer, 871 int use_overlapped); 872 873 static PyObject * 874 _winapi_WriteFile(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) 875 { 876 PyObject *return_value = NULL; 877 static const char * const _keywords[] = {"handle", "buffer", "overlapped", NULL}; 878 static _PyArg_Parser _parser = {"" F_HANDLE "O|i:WriteFile", _keywords, 0}; 879 HANDLE handle; 880 PyObject *buffer; 881 int use_overlapped = 0; 882 883 if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, 884 &handle, &buffer, &use_overlapped)) { 885 goto exit; 886 } 887 return_value = _winapi_WriteFile_impl(module, handle, buffer, use_overlapped); 888 889 exit: 890 return return_value; 891 } 892 /*[clinic end generated code: output=46d6382a6662c4a9 input=a9049054013a1b77]*/ 893