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