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