blob: ac38d374a22cb1499d52e05ce57f1f877e7e4252 [file] [log] [blame]
Zachary Waref2244ea2015-05-13 01:22:54 -05001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_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
13static PyObject *
14_winapi_Overlapped_GetOverlappedResult_impl(OverlappedObject *self, int wait);
15
16static PyObject *
17_winapi_Overlapped_GetOverlappedResult(OverlappedObject *self, PyObject *arg)
18{
19 PyObject *return_value = NULL;
20 int wait;
21
Zachary Ware77772c02015-05-13 10:58:35 -050022 if (!PyArg_Parse(arg, "p:GetOverlappedResult", &wait))
Zachary Waref2244ea2015-05-13 01:22:54 -050023 goto exit;
24 return_value = _winapi_Overlapped_GetOverlappedResult_impl(self, wait);
25
26exit:
27 return return_value;
28}
29
30PyDoc_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
38static PyObject *
39_winapi_Overlapped_getbuffer_impl(OverlappedObject *self);
40
41static PyObject *
42_winapi_Overlapped_getbuffer(OverlappedObject *self, PyObject *Py_UNUSED(ignored))
43{
44 return _winapi_Overlapped_getbuffer_impl(self);
45}
46
47PyDoc_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
55static PyObject *
56_winapi_Overlapped_cancel_impl(OverlappedObject *self);
57
58static PyObject *
59_winapi_Overlapped_cancel(OverlappedObject *self, PyObject *Py_UNUSED(ignored))
60{
61 return _winapi_Overlapped_cancel_impl(self);
62}
63
64PyDoc_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
73static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +030074_winapi_CloseHandle_impl(PyObject *module, HANDLE handle);
Zachary Waref2244ea2015-05-13 01:22:54 -050075
76static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +030077_winapi_CloseHandle(PyObject *module, PyObject *arg)
Zachary Waref2244ea2015-05-13 01:22:54 -050078{
79 PyObject *return_value = NULL;
80 HANDLE handle;
81
Zachary Ware77772c02015-05-13 10:58:35 -050082 if (!PyArg_Parse(arg, "" F_HANDLE ":CloseHandle", &handle))
Zachary Waref2244ea2015-05-13 01:22:54 -050083 goto exit;
84 return_value = _winapi_CloseHandle_impl(module, handle);
85
86exit:
87 return return_value;
88}
89
90PyDoc_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
98static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +030099_winapi_ConnectNamedPipe_impl(PyObject *module, HANDLE handle,
Zachary Ware77772c02015-05-13 10:58:35 -0500100 int use_overlapped);
Zachary Waref2244ea2015-05-13 01:22:54 -0500101
102static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300103_winapi_ConnectNamedPipe(PyObject *module, PyObject *args, PyObject *kwargs)
Zachary Waref2244ea2015-05-13 01:22:54 -0500104{
105 PyObject *return_value = NULL;
106 static char *_keywords[] = {"handle", "overlapped", NULL};
107 HANDLE handle;
108 int use_overlapped = 0;
109
Zachary Ware77772c02015-05-13 10:58:35 -0500110 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "" F_HANDLE "|i:ConnectNamedPipe", _keywords,
Zachary Waref2244ea2015-05-13 01:22:54 -0500111 &handle, &use_overlapped))
112 goto exit;
113 return_value = _winapi_ConnectNamedPipe_impl(module, handle, use_overlapped);
114
115exit:
116 return return_value;
117}
118
119PyDoc_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
129static HANDLE
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300130_winapi_CreateFile_impl(PyObject *module, LPCTSTR file_name,
Zachary Ware77772c02015-05-13 10:58:35 -0500131 DWORD desired_access, DWORD share_mode,
132 LPSECURITY_ATTRIBUTES security_attributes,
133 DWORD creation_disposition,
134 DWORD flags_and_attributes, HANDLE template_file);
Zachary Waref2244ea2015-05-13 01:22:54 -0500135
136static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300137_winapi_CreateFile(PyObject *module, PyObject *args)
Zachary Waref2244ea2015-05-13 01:22:54 -0500138{
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 Ware77772c02015-05-13 10:58:35 -0500149 if (!PyArg_ParseTuple(args, "skk" F_POINTER "kk" F_HANDLE ":CreateFile",
Zachary Waref2244ea2015-05-13 01:22:54 -0500150 &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
159exit:
160 return return_value;
161}
162
163PyDoc_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
171static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300172_winapi_CreateJunction_impl(PyObject *module, LPWSTR src_path,
Zachary Ware77772c02015-05-13 10:58:35 -0500173 LPWSTR dst_path);
Zachary Waref2244ea2015-05-13 01:22:54 -0500174
175static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300176_winapi_CreateJunction(PyObject *module, PyObject *args)
Zachary Waref2244ea2015-05-13 01:22:54 -0500177{
178 PyObject *return_value = NULL;
179 LPWSTR src_path;
180 LPWSTR dst_path;
181
Zachary Ware77772c02015-05-13 10:58:35 -0500182 if (!PyArg_ParseTuple(args, "uu:CreateJunction",
Zachary Waref2244ea2015-05-13 01:22:54 -0500183 &src_path, &dst_path))
184 goto exit;
185 return_value = _winapi_CreateJunction_impl(module, src_path, dst_path);
186
187exit:
188 return return_value;
189}
190
191PyDoc_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
201static HANDLE
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300202_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 Ware77772c02015-05-13 10:58:35 -0500206 LPSECURITY_ATTRIBUTES security_attributes);
Zachary Waref2244ea2015-05-13 01:22:54 -0500207
208static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300209_winapi_CreateNamedPipe(PyObject *module, PyObject *args)
Zachary Waref2244ea2015-05-13 01:22:54 -0500210{
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 Ware77772c02015-05-13 10:58:35 -0500222 if (!PyArg_ParseTuple(args, "skkkkkk" F_POINTER ":CreateNamedPipe",
Zachary Waref2244ea2015-05-13 01:22:54 -0500223 &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
232exit:
233 return return_value;
234}
235
236PyDoc_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
250static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300251_winapi_CreatePipe_impl(PyObject *module, PyObject *pipe_attrs, DWORD size);
Zachary Waref2244ea2015-05-13 01:22:54 -0500252
253static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300254_winapi_CreatePipe(PyObject *module, PyObject *args)
Zachary Waref2244ea2015-05-13 01:22:54 -0500255{
256 PyObject *return_value = NULL;
257 PyObject *pipe_attrs;
258 DWORD size;
259
Zachary Ware77772c02015-05-13 10:58:35 -0500260 if (!PyArg_ParseTuple(args, "Ok:CreatePipe",
Zachary Waref2244ea2015-05-13 01:22:54 -0500261 &pipe_attrs, &size))
262 goto exit;
263 return_value = _winapi_CreatePipe_impl(module, pipe_attrs, size);
264
265exit:
266 return return_value;
267}
268
269PyDoc_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
288static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300289_winapi_CreateProcess_impl(PyObject *module, Py_UNICODE *application_name,
Zachary Ware77772c02015-05-13 10:58:35 -0500290 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 Waref2244ea2015-05-13 01:22:54 -0500295
296static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300297_winapi_CreateProcess(PyObject *module, PyObject *args)
Zachary Waref2244ea2015-05-13 01:22:54 -0500298{
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 Ware77772c02015-05-13 10:58:35 -0500310 if (!PyArg_ParseTuple(args, "ZZOOikOZO:CreateProcess",
Zachary Waref2244ea2015-05-13 01:22:54 -0500311 &application_name, &command_line, &proc_attrs, &thread_attrs, &inherit_handles, &creation_flags, &env_mapping, &current_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
315exit:
316 return return_value;
317}
318
319PyDoc_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
334static HANDLE
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300335_winapi_DuplicateHandle_impl(PyObject *module, HANDLE source_process_handle,
Zachary Ware77772c02015-05-13 10:58:35 -0500336 HANDLE source_handle,
337 HANDLE target_process_handle,
338 DWORD desired_access, BOOL inherit_handle,
339 DWORD options);
Zachary Waref2244ea2015-05-13 01:22:54 -0500340
341static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300342_winapi_DuplicateHandle(PyObject *module, PyObject *args)
Zachary Waref2244ea2015-05-13 01:22:54 -0500343{
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 Ware77772c02015-05-13 10:58:35 -0500353 if (!PyArg_ParseTuple(args, "" F_HANDLE "" F_HANDLE "" F_HANDLE "ki|k:DuplicateHandle",
Zachary Waref2244ea2015-05-13 01:22:54 -0500354 &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
363exit:
364 return return_value;
365}
366
367PyDoc_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
375static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300376_winapi_ExitProcess_impl(PyObject *module, UINT ExitCode);
Zachary Waref2244ea2015-05-13 01:22:54 -0500377
378static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300379_winapi_ExitProcess(PyObject *module, PyObject *arg)
Zachary Waref2244ea2015-05-13 01:22:54 -0500380{
381 PyObject *return_value = NULL;
382 UINT ExitCode;
383
Zachary Ware77772c02015-05-13 10:58:35 -0500384 if (!PyArg_Parse(arg, "I:ExitProcess", &ExitCode))
Zachary Waref2244ea2015-05-13 01:22:54 -0500385 goto exit;
386 return_value = _winapi_ExitProcess_impl(module, ExitCode);
387
388exit:
389 return return_value;
390}
391
392PyDoc_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
401static HANDLE
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300402_winapi_GetCurrentProcess_impl(PyObject *module);
Zachary Waref2244ea2015-05-13 01:22:54 -0500403
404static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300405_winapi_GetCurrentProcess(PyObject *module, PyObject *Py_UNUSED(ignored))
Zachary Waref2244ea2015-05-13 01:22:54 -0500406{
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
417exit:
418 return return_value;
419}
420
421PyDoc_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
430static DWORD
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300431_winapi_GetExitCodeProcess_impl(PyObject *module, HANDLE process);
Zachary Waref2244ea2015-05-13 01:22:54 -0500432
433static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300434_winapi_GetExitCodeProcess(PyObject *module, PyObject *arg)
Zachary Waref2244ea2015-05-13 01:22:54 -0500435{
436 PyObject *return_value = NULL;
437 HANDLE process;
438 DWORD _return_value;
439
Zachary Ware77772c02015-05-13 10:58:35 -0500440 if (!PyArg_Parse(arg, "" F_HANDLE ":GetExitCodeProcess", &process))
Zachary Waref2244ea2015-05-13 01:22:54 -0500441 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
447exit:
448 return return_value;
449}
450
451PyDoc_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
459static DWORD
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300460_winapi_GetLastError_impl(PyObject *module);
Zachary Waref2244ea2015-05-13 01:22:54 -0500461
462static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300463_winapi_GetLastError(PyObject *module, PyObject *Py_UNUSED(ignored))
Zachary Waref2244ea2015-05-13 01:22:54 -0500464{
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
473exit:
474 return return_value;
475}
476
477PyDoc_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
493static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300494_winapi_GetModuleFileName_impl(PyObject *module, HMODULE module_handle);
Zachary Waref2244ea2015-05-13 01:22:54 -0500495
496static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300497_winapi_GetModuleFileName(PyObject *module, PyObject *arg)
Zachary Waref2244ea2015-05-13 01:22:54 -0500498{
499 PyObject *return_value = NULL;
500 HMODULE module_handle;
501
Zachary Ware77772c02015-05-13 10:58:35 -0500502 if (!PyArg_Parse(arg, "" F_HANDLE ":GetModuleFileName", &module_handle))
Zachary Waref2244ea2015-05-13 01:22:54 -0500503 goto exit;
504 return_value = _winapi_GetModuleFileName_impl(module, module_handle);
505
506exit:
507 return return_value;
508}
509
510PyDoc_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
524static HANDLE
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300525_winapi_GetStdHandle_impl(PyObject *module, DWORD std_handle);
Zachary Waref2244ea2015-05-13 01:22:54 -0500526
527static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300528_winapi_GetStdHandle(PyObject *module, PyObject *arg)
Zachary Waref2244ea2015-05-13 01:22:54 -0500529{
530 PyObject *return_value = NULL;
531 DWORD std_handle;
532 HANDLE _return_value;
533
Zachary Ware77772c02015-05-13 10:58:35 -0500534 if (!PyArg_Parse(arg, "k:GetStdHandle", &std_handle))
Zachary Waref2244ea2015-05-13 01:22:54 -0500535 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
543exit:
544 return return_value;
545}
546
547PyDoc_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
556static long
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300557_winapi_GetVersion_impl(PyObject *module);
Zachary Waref2244ea2015-05-13 01:22:54 -0500558
559static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300560_winapi_GetVersion(PyObject *module, PyObject *Py_UNUSED(ignored))
Zachary Waref2244ea2015-05-13 01:22:54 -0500561{
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
570exit:
571 return return_value;
572}
573
574PyDoc_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
582static HANDLE
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300583_winapi_OpenProcess_impl(PyObject *module, DWORD desired_access,
Zachary Ware77772c02015-05-13 10:58:35 -0500584 BOOL inherit_handle, DWORD process_id);
Zachary Waref2244ea2015-05-13 01:22:54 -0500585
586static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300587_winapi_OpenProcess(PyObject *module, PyObject *args)
Zachary Waref2244ea2015-05-13 01:22:54 -0500588{
589 PyObject *return_value = NULL;
590 DWORD desired_access;
591 BOOL inherit_handle;
592 DWORD process_id;
593 HANDLE _return_value;
594
Zachary Ware77772c02015-05-13 10:58:35 -0500595 if (!PyArg_ParseTuple(args, "kik:OpenProcess",
Zachary Waref2244ea2015-05-13 01:22:54 -0500596 &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
605exit:
606 return return_value;
607}
608
609PyDoc_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
617static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300618_winapi_PeekNamedPipe_impl(PyObject *module, HANDLE handle, int size);
Zachary Waref2244ea2015-05-13 01:22:54 -0500619
620static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300621_winapi_PeekNamedPipe(PyObject *module, PyObject *args)
Zachary Waref2244ea2015-05-13 01:22:54 -0500622{
623 PyObject *return_value = NULL;
624 HANDLE handle;
625 int size = 0;
626
Zachary Ware77772c02015-05-13 10:58:35 -0500627 if (!PyArg_ParseTuple(args, "" F_HANDLE "|i:PeekNamedPipe",
Zachary Waref2244ea2015-05-13 01:22:54 -0500628 &handle, &size))
629 goto exit;
630 return_value = _winapi_PeekNamedPipe_impl(module, handle, size);
631
632exit:
633 return return_value;
634}
635
636PyDoc_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
644static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300645_winapi_ReadFile_impl(PyObject *module, HANDLE handle, int size,
Zachary Ware77772c02015-05-13 10:58:35 -0500646 int use_overlapped);
Zachary Waref2244ea2015-05-13 01:22:54 -0500647
648static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300649_winapi_ReadFile(PyObject *module, PyObject *args, PyObject *kwargs)
Zachary Waref2244ea2015-05-13 01:22:54 -0500650{
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 Ware77772c02015-05-13 10:58:35 -0500657 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "" F_HANDLE "i|i:ReadFile", _keywords,
Zachary Waref2244ea2015-05-13 01:22:54 -0500658 &handle, &size, &use_overlapped))
659 goto exit;
660 return_value = _winapi_ReadFile_impl(module, handle, size, use_overlapped);
661
662exit:
663 return return_value;
664}
665
666PyDoc_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
675static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300676_winapi_SetNamedPipeHandleState_impl(PyObject *module, HANDLE named_pipe,
Zachary Ware77772c02015-05-13 10:58:35 -0500677 PyObject *mode,
678 PyObject *max_collection_count,
679 PyObject *collect_data_timeout);
Zachary Waref2244ea2015-05-13 01:22:54 -0500680
681static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300682_winapi_SetNamedPipeHandleState(PyObject *module, PyObject *args)
Zachary Waref2244ea2015-05-13 01:22:54 -0500683{
684 PyObject *return_value = NULL;
685 HANDLE named_pipe;
686 PyObject *mode;
687 PyObject *max_collection_count;
688 PyObject *collect_data_timeout;
689
Zachary Ware77772c02015-05-13 10:58:35 -0500690 if (!PyArg_ParseTuple(args, "" F_HANDLE "OOO:SetNamedPipeHandleState",
Zachary Waref2244ea2015-05-13 01:22:54 -0500691 &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
695exit:
696 return return_value;
697}
698
699PyDoc_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
708static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300709_winapi_TerminateProcess_impl(PyObject *module, HANDLE handle,
Zachary Ware77772c02015-05-13 10:58:35 -0500710 UINT exit_code);
Zachary Waref2244ea2015-05-13 01:22:54 -0500711
712static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300713_winapi_TerminateProcess(PyObject *module, PyObject *args)
Zachary Waref2244ea2015-05-13 01:22:54 -0500714{
715 PyObject *return_value = NULL;
716 HANDLE handle;
717 UINT exit_code;
718
Zachary Ware77772c02015-05-13 10:58:35 -0500719 if (!PyArg_ParseTuple(args, "" F_HANDLE "I:TerminateProcess",
Zachary Waref2244ea2015-05-13 01:22:54 -0500720 &handle, &exit_code))
721 goto exit;
722 return_value = _winapi_TerminateProcess_impl(module, handle, exit_code);
723
724exit:
725 return return_value;
726}
727
728PyDoc_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
736static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300737_winapi_WaitNamedPipe_impl(PyObject *module, LPCTSTR name, DWORD timeout);
Zachary Waref2244ea2015-05-13 01:22:54 -0500738
739static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300740_winapi_WaitNamedPipe(PyObject *module, PyObject *args)
Zachary Waref2244ea2015-05-13 01:22:54 -0500741{
742 PyObject *return_value = NULL;
743 LPCTSTR name;
744 DWORD timeout;
745
Zachary Ware77772c02015-05-13 10:58:35 -0500746 if (!PyArg_ParseTuple(args, "sk:WaitNamedPipe",
Zachary Waref2244ea2015-05-13 01:22:54 -0500747 &name, &timeout))
748 goto exit;
749 return_value = _winapi_WaitNamedPipe_impl(module, name, timeout);
750
751exit:
752 return return_value;
753}
754
755PyDoc_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
764static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300765_winapi_WaitForMultipleObjects_impl(PyObject *module, PyObject *handle_seq,
766 BOOL wait_flag, DWORD milliseconds);
Zachary Waref2244ea2015-05-13 01:22:54 -0500767
768static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300769_winapi_WaitForMultipleObjects(PyObject *module, PyObject *args)
Zachary Waref2244ea2015-05-13 01:22:54 -0500770{
771 PyObject *return_value = NULL;
772 PyObject *handle_seq;
773 BOOL wait_flag;
774 DWORD milliseconds = INFINITE;
775
Zachary Ware77772c02015-05-13 10:58:35 -0500776 if (!PyArg_ParseTuple(args, "Oi|k:WaitForMultipleObjects",
Zachary Waref2244ea2015-05-13 01:22:54 -0500777 &handle_seq, &wait_flag, &milliseconds))
778 goto exit;
779 return_value = _winapi_WaitForMultipleObjects_impl(module, handle_seq, wait_flag, milliseconds);
780
781exit:
782 return return_value;
783}
784
785PyDoc_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
798static long
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300799_winapi_WaitForSingleObject_impl(PyObject *module, HANDLE handle,
Zachary Ware77772c02015-05-13 10:58:35 -0500800 DWORD milliseconds);
Zachary Waref2244ea2015-05-13 01:22:54 -0500801
802static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300803_winapi_WaitForSingleObject(PyObject *module, PyObject *args)
Zachary Waref2244ea2015-05-13 01:22:54 -0500804{
805 PyObject *return_value = NULL;
806 HANDLE handle;
807 DWORD milliseconds;
808 long _return_value;
809
Zachary Ware77772c02015-05-13 10:58:35 -0500810 if (!PyArg_ParseTuple(args, "" F_HANDLE "k:WaitForSingleObject",
Zachary Waref2244ea2015-05-13 01:22:54 -0500811 &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
818exit:
819 return return_value;
820}
821
822PyDoc_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
830static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300831_winapi_WriteFile_impl(PyObject *module, HANDLE handle, PyObject *buffer,
Zachary Ware77772c02015-05-13 10:58:35 -0500832 int use_overlapped);
Zachary Waref2244ea2015-05-13 01:22:54 -0500833
834static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300835_winapi_WriteFile(PyObject *module, PyObject *args, PyObject *kwargs)
Zachary Waref2244ea2015-05-13 01:22:54 -0500836{
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 Ware77772c02015-05-13 10:58:35 -0500843 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "" F_HANDLE "O|i:WriteFile", _keywords,
Zachary Waref2244ea2015-05-13 01:22:54 -0500844 &handle, &buffer, &use_overlapped))
845 goto exit;
846 return_value = _winapi_WriteFile_impl(module, handle, buffer, use_overlapped);
847
848exit:
849 return return_value;
850}
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300851/*[clinic end generated code: output=a4c4b2a9fcb0bea1 input=a9049054013a1b77]*/