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