Debian Codegraph @

psutil/arch/windows/init.h

raw
1 /*
2 * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
5 */
6
7 #include <Python.h>
8 #include <windows.h>
9 #include <Winsvc.h>
10
11 #include "ntextapi.h"
12
13
14 extern int PSUTIL_WINVER;
15 extern SYSTEM_INFO PSUTIL_SYSTEM_INFO;
16 extern CRITICAL_SECTION PSUTIL_CRITICAL_SECTION;
17
18 #define PSUTIL_WINDOWS_VISTA 60
19 #define PSUTIL_WINDOWS_7 61
20 #define PSUTIL_WINDOWS_8 62
21 #define PSUTIL_WINDOWS_8_1 63
22 #define PSUTIL_WINDOWS_10 100
23 #define PSUTIL_WINDOWS_NEW MAXLONG
24
25 #define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
26 #define MALLOC_ZERO(x) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (x))
27 #define FREE(x) HeapFree(GetProcessHeap(), 0, (x))
28
29 #define _NT_FACILITY_MASK 0xfff
30 #define _NT_FACILITY_SHIFT 16
31 #define _NT_FACILITY(status) \
32 ((((ULONG)(status)) >> _NT_FACILITY_SHIFT) & _NT_FACILITY_MASK)
33
34 #define NT_NTWIN32(status) (_NT_FACILITY(status) == FACILITY_WIN32)
35 #define WIN32_FROM_NTSTATUS(status) (((ULONG)(status)) & 0xffff)
36
37 #define PSUTIL_FIRST_PROCESS(Processes) ( \
38 (PSYSTEM_PROCESS_INFORMATION)(Processes))
39 #define PSUTIL_NEXT_PROCESS(Process) ( \
40 ((PSYSTEM_PROCESS_INFORMATION)(Process))->NextEntryOffset ? \
41 (PSYSTEM_PROCESS_INFORMATION)((PCHAR)(Process) + \
42 ((PSYSTEM_PROCESS_INFORMATION)(Process))->NextEntryOffset) : NULL)
43
44 #define LO_T 1e-7
45 #define HI_T 429.4967296
46
47 #ifndef AF_INET6
48 #define AF_INET6 23
49 #endif
50
51 #if defined(PSUTIL_WINDOWS) && defined(PYPY_VERSION)
52 #if !defined(PyErr_SetFromWindowsErrWithFilename)
53 PyObject *PyErr_SetFromWindowsErrWithFilename(
54 int ierr, const char *filename
55 );
56 #endif
57 #if !defined(PyErr_SetExcFromWindowsErrWithFilenameObject)
58 PyObject *PyErr_SetExcFromWindowsErrWithFilenameObject(
59 PyObject *type, int ierr, PyObject *filename
60 );
61 #endif
62 #endif
63
64 double psutil_FiletimeToUnixTime(FILETIME ft);
65 double psutil_LargeIntegerToUnixTime(LARGE_INTEGER li);
66 int psutil_setup_windows(void);
67 PVOID psutil_GetProcAddress(LPCSTR libname, LPCSTR procname);
68 PVOID psutil_GetProcAddressFromLib(LPCSTR libname, LPCSTR procname);
69 PVOID psutil_SetFromNTStatusErr(NTSTATUS status, const char *syscall);
70
71 PyObject *TimeoutExpired;
72 PyObject *TimeoutAbandoned;
73
74
75 DWORD* psutil_get_pids(DWORD *numberOfReturnedPIDs);
76 HANDLE psutil_check_phandle(HANDLE hProcess, DWORD pid, int check_exit_code);
77 HANDLE psutil_handle_from_pid(DWORD pid, DWORD dwDesiredAccess);
78 int psutil_assert_pid_exists(DWORD pid, char *err);
79 int psutil_assert_pid_not_exists(DWORD pid, char *err);
80 int psutil_pid_is_running(DWORD pid);
81 int psutil_set_se_debug();
82 SC_HANDLE psutil_get_service_handle(char service_name, DWORD scm_access, DWORD access);
83
84 int psutil_get_proc_info(DWORD pid, PSYSTEM_PROCESS_INFORMATION *retProcess, PVOID *retBuffer);
85 PyObject *psutil_cpu_count_cores(PyObject *self, PyObject *args);
86 PyObject *psutil_cpu_count_logical(PyObject *self, PyObject *args);
87 PyObject *psutil_cpu_freq(PyObject *self, PyObject *args);
88 PyObject *psutil_cpu_stats(PyObject *self, PyObject *args);
89 PyObject *psutil_cpu_times(PyObject *self, PyObject *args);
90 PyObject *psutil_disk_io_counters(PyObject *self, PyObject *args);
91 PyObject *psutil_disk_partitions(PyObject *self, PyObject *args);
92 PyObject *psutil_disk_usage(PyObject *self, PyObject *args);
93 PyObject *psutil_get_loadavg();
94 PyObject *psutil_get_open_files(DWORD pid, HANDLE hProcess);
95 PyObject *psutil_getpagesize(PyObject *self, PyObject *args);
96 PyObject *psutil_init_loadavg_counter();
97 PyObject *psutil_net_connections(PyObject *self, PyObject *args);
98 PyObject *psutil_net_if_addrs(PyObject *self, PyObject *args);
99 PyObject *psutil_net_if_stats(PyObject *self, PyObject *args);
100 PyObject *psutil_net_io_counters(PyObject *self, PyObject *args);
101 PyObject *psutil_per_cpu_times(PyObject *self, PyObject *args);
102 PyObject *psutil_pid_exists(PyObject *self, PyObject *args);
103 PyObject *psutil_pids(PyObject *self, PyObject *args);
104 PyObject *psutil_ppid_map(PyObject *self, PyObject *args);
105 PyObject *psutil_proc_cmdline(PyObject *self, PyObject *args, PyObject *kwdict);
106 PyObject *psutil_proc_cpu_affinity_get(PyObject *self, PyObject *args);
107 PyObject *psutil_proc_cpu_affinity_set(PyObject *self, PyObject *args);
108 PyObject *psutil_proc_cwd(PyObject *self, PyObject *args);
109 PyObject *psutil_proc_environ(PyObject *self, PyObject *args);
110 PyObject *psutil_proc_exe(PyObject *self, PyObject *args);
111 PyObject *psutil_proc_info(PyObject *self, PyObject *args);
112 PyObject *psutil_proc_io_counters(PyObject *self, PyObject *args);
113 PyObject *psutil_proc_io_priority_get(PyObject *self, PyObject *args);
114 PyObject *psutil_proc_io_priority_set(PyObject *self, PyObject *args);
115 PyObject *psutil_proc_is_suspended(PyObject *self, PyObject *args);
116 PyObject *psutil_proc_kill(PyObject *self, PyObject *args);
117 PyObject *psutil_proc_memory_info(PyObject *self, PyObject *args);
118 PyObject *psutil_proc_memory_maps(PyObject *self, PyObject *args);
119 PyObject *psutil_proc_memory_uss(PyObject *self, PyObject *args);
120 PyObject *psutil_proc_num_handles(PyObject *self, PyObject *args);
121 PyObject *psutil_proc_open_files(PyObject *self, PyObject *args);
122 PyObject *psutil_proc_priority_get(PyObject *self, PyObject *args);
123 PyObject *psutil_proc_priority_set(PyObject *self, PyObject *args);
124 PyObject *psutil_proc_suspend_or_resume(PyObject *self, PyObject *args);
125 PyObject *psutil_proc_threads(PyObject *self, PyObject *args);
126 PyObject *psutil_proc_times(PyObject *self, PyObject *args);
127 PyObject *psutil_proc_username(PyObject *self, PyObject *args);
128 PyObject *psutil_proc_wait(PyObject *self, PyObject *args);
129 PyObject *psutil_QueryDosDevice(PyObject *self, PyObject *args);
130 PyObject *psutil_sensors_battery(PyObject *self, PyObject *args);
131 PyObject *psutil_swap_percent(PyObject *self, PyObject *args);
132 PyObject *psutil_uptime(PyObject *self, PyObject *args);
133 PyObject *psutil_users(PyObject *self, PyObject *args);
134 PyObject *psutil_virtual_mem(PyObject *self, PyObject *args);
135 PyObject *psutil_winservice_enumerate(PyObject *self, PyObject *args);
136 PyObject *psutil_winservice_query_config(PyObject *self, PyObject *args);
137 PyObject *psutil_winservice_query_descr(PyObject *self, PyObject *args);
138 PyObject *psutil_winservice_query_status(PyObject *self, PyObject *args);
139 PyObject *psutil_winservice_start(PyObject *self, PyObject *args);
140 PyObject *psutil_winservice_stop(PyObject *self, PyObject *args);