_winapi.c.h 28.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*[clinic input]
preserve
[clinic start generated code]*/

PyDoc_STRVAR(_winapi_Overlapped_GetOverlappedResult__doc__,
"GetOverlappedResult($self, wait, /)\n"
"--\n"
"\n");

#define _WINAPI_OVERLAPPED_GETOVERLAPPEDRESULT_METHODDEF    \
    {"GetOverlappedResult", (PyCFunction)_winapi_Overlapped_GetOverlappedResult, METH_O, _winapi_Overlapped_GetOverlappedResult__doc__},

static PyObject *
_winapi_Overlapped_GetOverlappedResult_impl(OverlappedObject *self, int wait);

static PyObject *
_winapi_Overlapped_GetOverlappedResult(OverlappedObject *self, PyObject *arg)
{
    PyObject *return_value = NULL;
    int wait;

22
    if (!PyArg_Parse(arg, "p:GetOverlappedResult", &wait)) {
23
        goto exit;
24
    }
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
    return_value = _winapi_Overlapped_GetOverlappedResult_impl(self, wait);

exit:
    return return_value;
}

PyDoc_STRVAR(_winapi_Overlapped_getbuffer__doc__,
"getbuffer($self, /)\n"
"--\n"
"\n");

#define _WINAPI_OVERLAPPED_GETBUFFER_METHODDEF    \
    {"getbuffer", (PyCFunction)_winapi_Overlapped_getbuffer, METH_NOARGS, _winapi_Overlapped_getbuffer__doc__},

static PyObject *
_winapi_Overlapped_getbuffer_impl(OverlappedObject *self);

static PyObject *
_winapi_Overlapped_getbuffer(OverlappedObject *self, PyObject *Py_UNUSED(ignored))
{
    return _winapi_Overlapped_getbuffer_impl(self);
}

PyDoc_STRVAR(_winapi_Overlapped_cancel__doc__,
"cancel($self, /)\n"
"--\n"
"\n");

#define _WINAPI_OVERLAPPED_CANCEL_METHODDEF    \
    {"cancel", (PyCFunction)_winapi_Overlapped_cancel, METH_NOARGS, _winapi_Overlapped_cancel__doc__},

static PyObject *
_winapi_Overlapped_cancel_impl(OverlappedObject *self);

static PyObject *
_winapi_Overlapped_cancel(OverlappedObject *self, PyObject *Py_UNUSED(ignored))
{
    return _winapi_Overlapped_cancel_impl(self);
}

PyDoc_STRVAR(_winapi_CloseHandle__doc__,
"CloseHandle($module, handle, /)\n"
"--\n"
"\n"
"Close handle.");

#define _WINAPI_CLOSEHANDLE_METHODDEF    \
    {"CloseHandle", (PyCFunction)_winapi_CloseHandle, METH_O, _winapi_CloseHandle__doc__},

static PyObject *
75
_winapi_CloseHandle_impl(PyObject *module, HANDLE handle);
76 77

static PyObject *
78
_winapi_CloseHandle(PyObject *module, PyObject *arg)
79 80 81 82
{
    PyObject *return_value = NULL;
    HANDLE handle;

83
    if (!PyArg_Parse(arg, "" F_HANDLE ":CloseHandle", &handle)) {
84
        goto exit;
85
    }
86 87 88 89 90 91 92 93 94 95 96 97
    return_value = _winapi_CloseHandle_impl(module, handle);

exit:
    return return_value;
}

PyDoc_STRVAR(_winapi_ConnectNamedPipe__doc__,
"ConnectNamedPipe($module, /, handle, overlapped=False)\n"
"--\n"
"\n");

#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 109
    static const char * const _keywords[] = {"handle", "overlapped", NULL};
    static _PyArg_Parser _parser = {"" F_HANDLE "|i:ConnectNamedPipe", _keywords, 0};
110 111 112
    HANDLE handle;
    int use_overlapped = 0;

113
    if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
114
        &handle, &use_overlapped)) {
115
        goto exit;
116
    }
117 118 119 120 121 122 123 124 125 126 127 128 129 130
    return_value = _winapi_ConnectNamedPipe_impl(module, handle, use_overlapped);

exit:
    return return_value;
}

PyDoc_STRVAR(_winapi_CreateFile__doc__,
"CreateFile($module, file_name, desired_access, share_mode,\n"
"           security_attributes, creation_disposition,\n"
"           flags_and_attributes, template_file, /)\n"
"--\n"
"\n");

#define _WINAPI_CREATEFILE_METHODDEF    \
131
    {"CreateFile", (PyCFunction)_winapi_CreateFile, METH_FASTCALL, _winapi_CreateFile__doc__},
132 133

static HANDLE
134
_winapi_CreateFile_impl(PyObject *module, LPCTSTR file_name,
135 136 137 138
                        DWORD desired_access, DWORD share_mode,
                        LPSECURITY_ATTRIBUTES security_attributes,
                        DWORD creation_disposition,
                        DWORD flags_and_attributes, HANDLE template_file);
139 140

static PyObject *
141
_winapi_CreateFile(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
142 143 144 145 146 147 148 149 150 151 152
{
    PyObject *return_value = NULL;
    LPCTSTR file_name;
    DWORD desired_access;
    DWORD share_mode;
    LPSECURITY_ATTRIBUTES security_attributes;
    DWORD creation_disposition;
    DWORD flags_and_attributes;
    HANDLE template_file;
    HANDLE _return_value;

153
    if (!_PyArg_NoStackKeywords("CreateFile", kwnames)) {
154
        goto exit;
155
    }
156

157 158
    if (!_PyArg_ParseStack(args, nargs, "skk" F_POINTER "kk" F_HANDLE ":CreateFile",
        &file_name, &desired_access, &share_mode, &security_attributes, &creation_disposition, &flags_and_attributes, &template_file)) {
159 160
        goto exit;
    }
161
    _return_value = _winapi_CreateFile_impl(module, file_name, desired_access, share_mode, security_attributes, creation_disposition, flags_and_attributes, template_file);
162
    if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
163
        goto exit;
164 165
    }
    if (_return_value == NULL) {
166
        Py_RETURN_NONE;
167
    }
168 169 170 171 172 173 174 175 176 177 178 179
    return_value = HANDLE_TO_PYNUM(_return_value);

exit:
    return return_value;
}

PyDoc_STRVAR(_winapi_CreateJunction__doc__,
"CreateJunction($module, src_path, dst_path, /)\n"
"--\n"
"\n");

#define _WINAPI_CREATEJUNCTION_METHODDEF    \
180
    {"CreateJunction", (PyCFunction)_winapi_CreateJunction, METH_FASTCALL, _winapi_CreateJunction__doc__},
181 182

static PyObject *
183
_winapi_CreateJunction_impl(PyObject *module, LPWSTR src_path,
184
                            LPWSTR dst_path);
185 186

static PyObject *
187
_winapi_CreateJunction(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
188 189 190 191 192
{
    PyObject *return_value = NULL;
    LPWSTR src_path;
    LPWSTR dst_path;

193
    if (!_PyArg_NoStackKeywords("CreateJunction", kwnames)) {
194
        goto exit;
195
    }
196

197 198
    if (!_PyArg_ParseStack(args, nargs, "uu:CreateJunction",
        &src_path, &dst_path)) {
199 200
        goto exit;
    }
201 202 203 204 205 206 207 208 209 210 211 212 213 214
    return_value = _winapi_CreateJunction_impl(module, src_path, dst_path);

exit:
    return return_value;
}

PyDoc_STRVAR(_winapi_CreateNamedPipe__doc__,
"CreateNamedPipe($module, name, open_mode, pipe_mode, max_instances,\n"
"                out_buffer_size, in_buffer_size, default_timeout,\n"
"                security_attributes, /)\n"
"--\n"
"\n");

#define _WINAPI_CREATENAMEDPIPE_METHODDEF    \
215
    {"CreateNamedPipe", (PyCFunction)_winapi_CreateNamedPipe, METH_FASTCALL, _winapi_CreateNamedPipe__doc__},
216 217

static HANDLE
218 219 220 221
_winapi_CreateNamedPipe_impl(PyObject *module, LPCTSTR name, DWORD open_mode,
                             DWORD pipe_mode, DWORD max_instances,
                             DWORD out_buffer_size, DWORD in_buffer_size,
                             DWORD default_timeout,
222
                             LPSECURITY_ATTRIBUTES security_attributes);
223 224

static PyObject *
225
_winapi_CreateNamedPipe(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
226 227 228 229 230 231 232 233 234 235 236 237
{
    PyObject *return_value = NULL;
    LPCTSTR name;
    DWORD open_mode;
    DWORD pipe_mode;
    DWORD max_instances;
    DWORD out_buffer_size;
    DWORD in_buffer_size;
    DWORD default_timeout;
    LPSECURITY_ATTRIBUTES security_attributes;
    HANDLE _return_value;

238
    if (!_PyArg_NoStackKeywords("CreateNamedPipe", kwnames)) {
239
        goto exit;
240
    }
241

242 243
    if (!_PyArg_ParseStack(args, nargs, "skkkkkk" F_POINTER ":CreateNamedPipe",
        &name, &open_mode, &pipe_mode, &max_instances, &out_buffer_size, &in_buffer_size, &default_timeout, &security_attributes)) {
244 245
        goto exit;
    }
246
    _return_value = _winapi_CreateNamedPipe_impl(module, name, open_mode, pipe_mode, max_instances, out_buffer_size, in_buffer_size, default_timeout, security_attributes);
247
    if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
248
        goto exit;
249 250
    }
    if (_return_value == NULL) {
251
        Py_RETURN_NONE;
252
    }
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
    return_value = HANDLE_TO_PYNUM(_return_value);

exit:
    return return_value;
}

PyDoc_STRVAR(_winapi_CreatePipe__doc__,
"CreatePipe($module, pipe_attrs, size, /)\n"
"--\n"
"\n"
"Create an anonymous pipe.\n"
"\n"
"  pipe_attrs\n"
"    Ignored internally, can be None.\n"
"\n"
"Returns a 2-tuple of handles, to the read and write ends of the pipe.");

#define _WINAPI_CREATEPIPE_METHODDEF    \
271
    {"CreatePipe", (PyCFunction)_winapi_CreatePipe, METH_FASTCALL, _winapi_CreatePipe__doc__},
272 273

static PyObject *
274
_winapi_CreatePipe_impl(PyObject *module, PyObject *pipe_attrs, DWORD size);
275 276

static PyObject *
277
_winapi_CreatePipe(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
278 279 280 281 282
{
    PyObject *return_value = NULL;
    PyObject *pipe_attrs;
    DWORD size;

283
    if (!_PyArg_NoStackKeywords("CreatePipe", kwnames)) {
284
        goto exit;
285
    }
286

287 288
    if (!_PyArg_ParseStack(args, nargs, "Ok:CreatePipe",
        &pipe_attrs, &size)) {
289 290
        goto exit;
    }
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313
    return_value = _winapi_CreatePipe_impl(module, pipe_attrs, size);

exit:
    return return_value;
}

PyDoc_STRVAR(_winapi_CreateProcess__doc__,
"CreateProcess($module, application_name, command_line, proc_attrs,\n"
"              thread_attrs, inherit_handles, creation_flags,\n"
"              env_mapping, current_directory, startup_info, /)\n"
"--\n"
"\n"
"Create a new process and its primary thread.\n"
"\n"
"  proc_attrs\n"
"    Ignored internally, can be None.\n"
"  thread_attrs\n"
"    Ignored internally, can be None.\n"
"\n"
"The return value is a tuple of the process handle, thread handle,\n"
"process ID, and thread ID.");

#define _WINAPI_CREATEPROCESS_METHODDEF    \
314
    {"CreateProcess", (PyCFunction)_winapi_CreateProcess, METH_FASTCALL, _winapi_CreateProcess__doc__},
315 316

static PyObject *
317
_winapi_CreateProcess_impl(PyObject *module, Py_UNICODE *application_name,
318 319 320 321 322
                           Py_UNICODE *command_line, PyObject *proc_attrs,
                           PyObject *thread_attrs, BOOL inherit_handles,
                           DWORD creation_flags, PyObject *env_mapping,
                           Py_UNICODE *current_directory,
                           PyObject *startup_info);
323 324

static PyObject *
325
_winapi_CreateProcess(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
326 327 328 329 330 331 332 333 334 335 336 337
{
    PyObject *return_value = NULL;
    Py_UNICODE *application_name;
    Py_UNICODE *command_line;
    PyObject *proc_attrs;
    PyObject *thread_attrs;
    BOOL inherit_handles;
    DWORD creation_flags;
    PyObject *env_mapping;
    Py_UNICODE *current_directory;
    PyObject *startup_info;

338
    if (!_PyArg_NoStackKeywords("CreateProcess", kwnames)) {
339
        goto exit;
340
    }
341

342 343
    if (!_PyArg_ParseStack(args, nargs, "ZZOOikOZO:CreateProcess",
        &application_name, &command_line, &proc_attrs, &thread_attrs, &inherit_handles, &creation_flags, &env_mapping, &current_directory, &startup_info)) {
344 345
        goto exit;
    }
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364
    return_value = _winapi_CreateProcess_impl(module, application_name, command_line, proc_attrs, thread_attrs, inherit_handles, creation_flags, env_mapping, current_directory, startup_info);

exit:
    return return_value;
}

PyDoc_STRVAR(_winapi_DuplicateHandle__doc__,
"DuplicateHandle($module, source_process_handle, source_handle,\n"
"                target_process_handle, desired_access, inherit_handle,\n"
"                options=0, /)\n"
"--\n"
"\n"
"Return a duplicate handle object.\n"
"\n"
"The duplicate handle refers to the same object as the original\n"
"handle. Therefore, any changes to the object are reflected\n"
"through both handles.");

#define _WINAPI_DUPLICATEHANDLE_METHODDEF    \
365
    {"DuplicateHandle", (PyCFunction)_winapi_DuplicateHandle, METH_FASTCALL, _winapi_DuplicateHandle__doc__},
366 367

static HANDLE
368
_winapi_DuplicateHandle_impl(PyObject *module, HANDLE source_process_handle,
369 370 371 372
                             HANDLE source_handle,
                             HANDLE target_process_handle,
                             DWORD desired_access, BOOL inherit_handle,
                             DWORD options);
373 374

static PyObject *
375
_winapi_DuplicateHandle(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
376 377 378 379 380 381 382 383 384 385
{
    PyObject *return_value = NULL;
    HANDLE source_process_handle;
    HANDLE source_handle;
    HANDLE target_process_handle;
    DWORD desired_access;
    BOOL inherit_handle;
    DWORD options = 0;
    HANDLE _return_value;

386
    if (!_PyArg_NoStackKeywords("DuplicateHandle", kwnames)) {
387
        goto exit;
388
    }
389

390 391
    if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "" F_HANDLE "" F_HANDLE "ki|k:DuplicateHandle",
        &source_process_handle, &source_handle, &target_process_handle, &desired_access, &inherit_handle, &options)) {
392 393
        goto exit;
    }
394
    _return_value = _winapi_DuplicateHandle_impl(module, source_process_handle, source_handle, target_process_handle, desired_access, inherit_handle, options);
395
    if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
396
        goto exit;
397 398
    }
    if (_return_value == NULL) {
399
        Py_RETURN_NONE;
400
    }
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415
    return_value = HANDLE_TO_PYNUM(_return_value);

exit:
    return return_value;
}

PyDoc_STRVAR(_winapi_ExitProcess__doc__,
"ExitProcess($module, ExitCode, /)\n"
"--\n"
"\n");

#define _WINAPI_EXITPROCESS_METHODDEF    \
    {"ExitProcess", (PyCFunction)_winapi_ExitProcess, METH_O, _winapi_ExitProcess__doc__},

static PyObject *
416
_winapi_ExitProcess_impl(PyObject *module, UINT ExitCode);
417 418

static PyObject *
419
_winapi_ExitProcess(PyObject *module, PyObject *arg)
420 421 422 423
{
    PyObject *return_value = NULL;
    UINT ExitCode;

424
    if (!PyArg_Parse(arg, "I:ExitProcess", &ExitCode)) {
425
        goto exit;
426
    }
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442
    return_value = _winapi_ExitProcess_impl(module, ExitCode);

exit:
    return return_value;
}

PyDoc_STRVAR(_winapi_GetCurrentProcess__doc__,
"GetCurrentProcess($module, /)\n"
"--\n"
"\n"
"Return a handle object for the current process.");

#define _WINAPI_GETCURRENTPROCESS_METHODDEF    \
    {"GetCurrentProcess", (PyCFunction)_winapi_GetCurrentProcess, METH_NOARGS, _winapi_GetCurrentProcess__doc__},

static HANDLE
443
_winapi_GetCurrentProcess_impl(PyObject *module);
444 445

static PyObject *
446
_winapi_GetCurrentProcess(PyObject *module, PyObject *Py_UNUSED(ignored))
447 448 449 450 451
{
    PyObject *return_value = NULL;
    HANDLE _return_value;

    _return_value = _winapi_GetCurrentProcess_impl(module);
452
    if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
453
        goto exit;
454 455
    }
    if (_return_value == NULL) {
456
        Py_RETURN_NONE;
457
    }
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473
    return_value = HANDLE_TO_PYNUM(_return_value);

exit:
    return return_value;
}

PyDoc_STRVAR(_winapi_GetExitCodeProcess__doc__,
"GetExitCodeProcess($module, process, /)\n"
"--\n"
"\n"
"Return the termination status of the specified process.");

#define _WINAPI_GETEXITCODEPROCESS_METHODDEF    \
    {"GetExitCodeProcess", (PyCFunction)_winapi_GetExitCodeProcess, METH_O, _winapi_GetExitCodeProcess__doc__},

static DWORD
474
_winapi_GetExitCodeProcess_impl(PyObject *module, HANDLE process);
475 476

static PyObject *
477
_winapi_GetExitCodeProcess(PyObject *module, PyObject *arg)
478 479 480 481 482
{
    PyObject *return_value = NULL;
    HANDLE process;
    DWORD _return_value;

483
    if (!PyArg_Parse(arg, "" F_HANDLE ":GetExitCodeProcess", &process)) {
484
        goto exit;
485
    }
486
    _return_value = _winapi_GetExitCodeProcess_impl(module, process);
487
    if ((_return_value == DWORD_MAX) && PyErr_Occurred()) {
488
        goto exit;
489
    }
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504
    return_value = Py_BuildValue("k", _return_value);

exit:
    return return_value;
}

PyDoc_STRVAR(_winapi_GetLastError__doc__,
"GetLastError($module, /)\n"
"--\n"
"\n");

#define _WINAPI_GETLASTERROR_METHODDEF    \
    {"GetLastError", (PyCFunction)_winapi_GetLastError, METH_NOARGS, _winapi_GetLastError__doc__},

static DWORD
505
_winapi_GetLastError_impl(PyObject *module);
506 507

static PyObject *
508
_winapi_GetLastError(PyObject *module, PyObject *Py_UNUSED(ignored))
509 510 511 512 513
{
    PyObject *return_value = NULL;
    DWORD _return_value;

    _return_value = _winapi_GetLastError_impl(module);
514
    if ((_return_value == DWORD_MAX) && PyErr_Occurred()) {
515
        goto exit;
516
    }
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539
    return_value = Py_BuildValue("k", _return_value);

exit:
    return return_value;
}

PyDoc_STRVAR(_winapi_GetModuleFileName__doc__,
"GetModuleFileName($module, module_handle, /)\n"
"--\n"
"\n"
"Return the fully-qualified path for the file that contains module.\n"
"\n"
"The module must have been loaded by the current process.\n"
"\n"
"The module parameter should be a handle to the loaded module\n"
"whose path is being requested. If this parameter is 0,\n"
"GetModuleFileName retrieves the path of the executable file\n"
"of the current process.");

#define _WINAPI_GETMODULEFILENAME_METHODDEF    \
    {"GetModuleFileName", (PyCFunction)_winapi_GetModuleFileName, METH_O, _winapi_GetModuleFileName__doc__},

static PyObject *
540
_winapi_GetModuleFileName_impl(PyObject *module, HMODULE module_handle);
541 542

static PyObject *
543
_winapi_GetModuleFileName(PyObject *module, PyObject *arg)
544 545 546 547
{
    PyObject *return_value = NULL;
    HMODULE module_handle;

548
    if (!PyArg_Parse(arg, "" F_HANDLE ":GetModuleFileName", &module_handle)) {
549
        goto exit;
550
    }
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571
    return_value = _winapi_GetModuleFileName_impl(module, module_handle);

exit:
    return return_value;
}

PyDoc_STRVAR(_winapi_GetStdHandle__doc__,
"GetStdHandle($module, std_handle, /)\n"
"--\n"
"\n"
"Return a handle to the specified standard device.\n"
"\n"
"  std_handle\n"
"    One of STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, or STD_ERROR_HANDLE.\n"
"\n"
"The integer associated with the handle object is returned.");

#define _WINAPI_GETSTDHANDLE_METHODDEF    \
    {"GetStdHandle", (PyCFunction)_winapi_GetStdHandle, METH_O, _winapi_GetStdHandle__doc__},

static HANDLE
572
_winapi_GetStdHandle_impl(PyObject *module, DWORD std_handle);
573 574

static PyObject *
575
_winapi_GetStdHandle(PyObject *module, PyObject *arg)
576 577 578 579 580
{
    PyObject *return_value = NULL;
    DWORD std_handle;
    HANDLE _return_value;

581
    if (!PyArg_Parse(arg, "k:GetStdHandle", &std_handle)) {
582
        goto exit;
583
    }
584
    _return_value = _winapi_GetStdHandle_impl(module, std_handle);
585
    if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
586
        goto exit;
587 588
    }
    if (_return_value == NULL) {
589
        Py_RETURN_NONE;
590
    }
591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606
    return_value = HANDLE_TO_PYNUM(_return_value);

exit:
    return return_value;
}

PyDoc_STRVAR(_winapi_GetVersion__doc__,
"GetVersion($module, /)\n"
"--\n"
"\n"
"Return the version number of the current operating system.");

#define _WINAPI_GETVERSION_METHODDEF    \
    {"GetVersion", (PyCFunction)_winapi_GetVersion, METH_NOARGS, _winapi_GetVersion__doc__},

static long
607
_winapi_GetVersion_impl(PyObject *module);
608 609

static PyObject *
610
_winapi_GetVersion(PyObject *module, PyObject *Py_UNUSED(ignored))
611 612 613 614 615
{
    PyObject *return_value = NULL;
    long _return_value;

    _return_value = _winapi_GetVersion_impl(module);
616
    if ((_return_value == -1) && PyErr_Occurred()) {
617
        goto exit;
618
    }
619 620 621 622 623 624 625 626 627 628 629 630
    return_value = PyLong_FromLong(_return_value);

exit:
    return return_value;
}

PyDoc_STRVAR(_winapi_OpenProcess__doc__,
"OpenProcess($module, desired_access, inherit_handle, process_id, /)\n"
"--\n"
"\n");

#define _WINAPI_OPENPROCESS_METHODDEF    \
631
    {"OpenProcess", (PyCFunction)_winapi_OpenProcess, METH_FASTCALL, _winapi_OpenProcess__doc__},
632 633

static HANDLE
634
_winapi_OpenProcess_impl(PyObject *module, DWORD desired_access,
635
                         BOOL inherit_handle, DWORD process_id);
636 637

static PyObject *
638
_winapi_OpenProcess(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
639 640 641 642 643 644 645
{
    PyObject *return_value = NULL;
    DWORD desired_access;
    BOOL inherit_handle;
    DWORD process_id;
    HANDLE _return_value;

646
    if (!_PyArg_NoStackKeywords("OpenProcess", kwnames)) {
647
        goto exit;
648
    }
649

650 651
    if (!_PyArg_ParseStack(args, nargs, "kik:OpenProcess",
        &desired_access, &inherit_handle, &process_id)) {
652 653
        goto exit;
    }
654
    _return_value = _winapi_OpenProcess_impl(module, desired_access, inherit_handle, process_id);
655
    if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
656
        goto exit;
657 658
    }
    if (_return_value == NULL) {
659
        Py_RETURN_NONE;
660
    }
661 662 663 664 665 666 667 668 669 670 671 672
    return_value = HANDLE_TO_PYNUM(_return_value);

exit:
    return return_value;
}

PyDoc_STRVAR(_winapi_PeekNamedPipe__doc__,
"PeekNamedPipe($module, handle, size=0, /)\n"
"--\n"
"\n");

#define _WINAPI_PEEKNAMEDPIPE_METHODDEF    \
673
    {"PeekNamedPipe", (PyCFunction)_winapi_PeekNamedPipe, METH_FASTCALL, _winapi_PeekNamedPipe__doc__},
674 675

static PyObject *
676
_winapi_PeekNamedPipe_impl(PyObject *module, HANDLE handle, int size);
677 678

static PyObject *
679
_winapi_PeekNamedPipe(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
680 681 682 683 684
{
    PyObject *return_value = NULL;
    HANDLE handle;
    int size = 0;

685
    if (!_PyArg_NoStackKeywords("PeekNamedPipe", kwnames)) {
686
        goto exit;
687
    }
688

689 690
    if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "|i:PeekNamedPipe",
        &handle, &size)) {
691 692
        goto exit;
    }
693 694 695 696 697 698 699 700 701 702 703 704
    return_value = _winapi_PeekNamedPipe_impl(module, handle, size);

exit:
    return return_value;
}

PyDoc_STRVAR(_winapi_ReadFile__doc__,
"ReadFile($module, /, handle, size, overlapped=False)\n"
"--\n"
"\n");

#define _WINAPI_READFILE_METHODDEF    \
705
    {"ReadFile", (PyCFunction)_winapi_ReadFile, METH_FASTCALL, _winapi_ReadFile__doc__},
706 707

static PyObject *
708
_winapi_ReadFile_impl(PyObject *module, HANDLE handle, int size,
709
                      int use_overlapped);
710 711

static PyObject *
712
_winapi_ReadFile(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
713 714
{
    PyObject *return_value = NULL;
715 716
    static const char * const _keywords[] = {"handle", "size", "overlapped", NULL};
    static _PyArg_Parser _parser = {"" F_HANDLE "i|i:ReadFile", _keywords, 0};
717 718 719 720
    HANDLE handle;
    int size;
    int use_overlapped = 0;

721
    if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
722
        &handle, &size, &use_overlapped)) {
723
        goto exit;
724
    }
725 726 727 728 729 730 731 732 733 734 735 736 737
    return_value = _winapi_ReadFile_impl(module, handle, size, use_overlapped);

exit:
    return return_value;
}

PyDoc_STRVAR(_winapi_SetNamedPipeHandleState__doc__,
"SetNamedPipeHandleState($module, named_pipe, mode,\n"
"                        max_collection_count, collect_data_timeout, /)\n"
"--\n"
"\n");

#define _WINAPI_SETNAMEDPIPEHANDLESTATE_METHODDEF    \
738
    {"SetNamedPipeHandleState", (PyCFunction)_winapi_SetNamedPipeHandleState, METH_FASTCALL, _winapi_SetNamedPipeHandleState__doc__},
739 740

static PyObject *
741
_winapi_SetNamedPipeHandleState_impl(PyObject *module, HANDLE named_pipe,
742 743 744
                                     PyObject *mode,
                                     PyObject *max_collection_count,
                                     PyObject *collect_data_timeout);
745 746

static PyObject *
747
_winapi_SetNamedPipeHandleState(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
748 749 750 751 752 753 754
{
    PyObject *return_value = NULL;
    HANDLE named_pipe;
    PyObject *mode;
    PyObject *max_collection_count;
    PyObject *collect_data_timeout;

755
    if (!_PyArg_NoStackKeywords("SetNamedPipeHandleState", kwnames)) {
756
        goto exit;
757
    }
758

759 760
    if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "OOO:SetNamedPipeHandleState",
        &named_pipe, &mode, &max_collection_count, &collect_data_timeout)) {
761 762
        goto exit;
    }
763 764 765 766 767 768 769 770 771 772 773 774 775
    return_value = _winapi_SetNamedPipeHandleState_impl(module, named_pipe, mode, max_collection_count, collect_data_timeout);

exit:
    return return_value;
}

PyDoc_STRVAR(_winapi_TerminateProcess__doc__,
"TerminateProcess($module, handle, exit_code, /)\n"
"--\n"
"\n"
"Terminate the specified process and all of its threads.");

#define _WINAPI_TERMINATEPROCESS_METHODDEF    \
776
    {"TerminateProcess", (PyCFunction)_winapi_TerminateProcess, METH_FASTCALL, _winapi_TerminateProcess__doc__},
777 778

static PyObject *
779
_winapi_TerminateProcess_impl(PyObject *module, HANDLE handle,
780
                              UINT exit_code);
781 782

static PyObject *
783
_winapi_TerminateProcess(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
784 785 786 787 788
{
    PyObject *return_value = NULL;
    HANDLE handle;
    UINT exit_code;

789
    if (!_PyArg_NoStackKeywords("TerminateProcess", kwnames)) {
790
        goto exit;
791
    }
792

793 794
    if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "I:TerminateProcess",
        &handle, &exit_code)) {
795 796
        goto exit;
    }
797 798 799 800 801 802 803 804 805 806 807 808
    return_value = _winapi_TerminateProcess_impl(module, handle, exit_code);

exit:
    return return_value;
}

PyDoc_STRVAR(_winapi_WaitNamedPipe__doc__,
"WaitNamedPipe($module, name, timeout, /)\n"
"--\n"
"\n");

#define _WINAPI_WAITNAMEDPIPE_METHODDEF    \
809
    {"WaitNamedPipe", (PyCFunction)_winapi_WaitNamedPipe, METH_FASTCALL, _winapi_WaitNamedPipe__doc__},
810 811

static PyObject *
812
_winapi_WaitNamedPipe_impl(PyObject *module, LPCTSTR name, DWORD timeout);
813 814

static PyObject *
815
_winapi_WaitNamedPipe(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
816 817 818 819 820
{
    PyObject *return_value = NULL;
    LPCTSTR name;
    DWORD timeout;

821
    if (!_PyArg_NoStackKeywords("WaitNamedPipe", kwnames)) {
822
        goto exit;
823
    }
824

825 826
    if (!_PyArg_ParseStack(args, nargs, "sk:WaitNamedPipe",
        &name, &timeout)) {
827 828
        goto exit;
    }
829 830 831 832 833 834 835 836 837 838 839 840 841
    return_value = _winapi_WaitNamedPipe_impl(module, name, timeout);

exit:
    return return_value;
}

PyDoc_STRVAR(_winapi_WaitForMultipleObjects__doc__,
"WaitForMultipleObjects($module, handle_seq, wait_flag,\n"
"                       milliseconds=_winapi.INFINITE, /)\n"
"--\n"
"\n");

#define _WINAPI_WAITFORMULTIPLEOBJECTS_METHODDEF    \
842
    {"WaitForMultipleObjects", (PyCFunction)_winapi_WaitForMultipleObjects, METH_FASTCALL, _winapi_WaitForMultipleObjects__doc__},
843 844

static PyObject *
845 846
_winapi_WaitForMultipleObjects_impl(PyObject *module, PyObject *handle_seq,
                                    BOOL wait_flag, DWORD milliseconds);
847 848

static PyObject *
849
_winapi_WaitForMultipleObjects(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
850 851 852 853 854 855
{
    PyObject *return_value = NULL;
    PyObject *handle_seq;
    BOOL wait_flag;
    DWORD milliseconds = INFINITE;

856
    if (!_PyArg_NoStackKeywords("WaitForMultipleObjects", kwnames)) {
857
        goto exit;
858
    }
859

860 861
    if (!_PyArg_ParseStack(args, nargs, "Oi|k:WaitForMultipleObjects",
        &handle_seq, &wait_flag, &milliseconds)) {
862 863
        goto exit;
    }
864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880
    return_value = _winapi_WaitForMultipleObjects_impl(module, handle_seq, wait_flag, milliseconds);

exit:
    return return_value;
}

PyDoc_STRVAR(_winapi_WaitForSingleObject__doc__,
"WaitForSingleObject($module, handle, milliseconds, /)\n"
"--\n"
"\n"
"Wait for a single object.\n"
"\n"
"Wait until the specified object is in the signaled state or\n"
"the time-out interval elapses. The timeout value is specified\n"
"in milliseconds.");

#define _WINAPI_WAITFORSINGLEOBJECT_METHODDEF    \
881
    {"WaitForSingleObject", (PyCFunction)_winapi_WaitForSingleObject, METH_FASTCALL, _winapi_WaitForSingleObject__doc__},
882 883

static long
884
_winapi_WaitForSingleObject_impl(PyObject *module, HANDLE handle,
885
                                 DWORD milliseconds);
886 887

static PyObject *
888
_winapi_WaitForSingleObject(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
889 890 891 892 893 894
{
    PyObject *return_value = NULL;
    HANDLE handle;
    DWORD milliseconds;
    long _return_value;

895
    if (!_PyArg_NoStackKeywords("WaitForSingleObject", kwnames)) {
896
        goto exit;
897
    }
898

899 900
    if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "k:WaitForSingleObject",
        &handle, &milliseconds)) {
901 902
        goto exit;
    }
903
    _return_value = _winapi_WaitForSingleObject_impl(module, handle, milliseconds);
904
    if ((_return_value == -1) && PyErr_Occurred()) {
905
        goto exit;
906
    }
907 908 909 910 911 912 913 914 915 916 917 918
    return_value = PyLong_FromLong(_return_value);

exit:
    return return_value;
}

PyDoc_STRVAR(_winapi_WriteFile__doc__,
"WriteFile($module, /, handle, buffer, overlapped=False)\n"
"--\n"
"\n");

#define _WINAPI_WRITEFILE_METHODDEF    \
919
    {"WriteFile", (PyCFunction)_winapi_WriteFile, METH_FASTCALL, _winapi_WriteFile__doc__},
920 921

static PyObject *
922
_winapi_WriteFile_impl(PyObject *module, HANDLE handle, PyObject *buffer,
923
                       int use_overlapped);
924 925

static PyObject *
926
_winapi_WriteFile(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
927 928
{
    PyObject *return_value = NULL;
929 930
    static const char * const _keywords[] = {"handle", "buffer", "overlapped", NULL};
    static _PyArg_Parser _parser = {"" F_HANDLE "O|i:WriteFile", _keywords, 0};
931 932 933 934
    HANDLE handle;
    PyObject *buffer;
    int use_overlapped = 0;

935
    if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
936
        &handle, &buffer, &use_overlapped)) {
937
        goto exit;
938
    }
939 940 941 942 943
    return_value = _winapi_WriteFile_impl(module, handle, buffer, use_overlapped);

exit:
    return return_value;
}
944
/*[clinic end generated code: output=9555c16ed2d95a9f input=a9049054013a1b77]*/