5 #ifndef __MONO_PROC_LIB_H__
6 #define __MONO_PROC_LIB_H__
8 * Utility functions to access processes information and other info about the system.
12 #include <mono/utils/mono-compiler.h>
13 #include <mono/utils/mono-publib.h>
15 /* never remove or reorder these enums values: they are used in corlib/System */
18 MONO_PROCESS_NUM_THREADS
,
19 MONO_PROCESS_USER_TIME
, /* milliseconds */
20 MONO_PROCESS_SYSTEM_TIME
, /* milliseconds */
21 MONO_PROCESS_TOTAL_TIME
, /* milliseconds */
22 MONO_PROCESS_WORKING_SET
,
23 MONO_PROCESS_WORKING_SET_PEAK
, /* 5 */
24 MONO_PROCESS_PRIVATE_BYTES
,
25 MONO_PROCESS_VIRTUAL_BYTES
,
26 MONO_PROCESS_VIRTUAL_BYTES_PEAK
,
28 MONO_PROCESS_ELAPSED
, /* 10 */
30 MONO_PROCESS_PAGED_BYTES
,
44 MONO_PROCESS_ERROR_NONE
, /* no error happened */
45 MONO_PROCESS_ERROR_NOT_FOUND
, /* process not found */
46 MONO_PROCESS_ERROR_OTHER
49 typedef struct _MonoCpuUsageState MonoCpuUsageState
;
51 struct _MonoCpuUsageState
{
57 struct _MonoCpuUsageState
{
64 gpointer
* mono_process_list (int *size
);
66 void mono_process_get_times (gpointer pid
, gint64
*start_time
, gint64
*user_time
, gint64
*kernel_time
);
68 char* mono_process_get_name (gpointer pid
, char *buf
, int len
);
70 gint64
mono_process_get_data (gpointer pid
, MonoProcessData data
);
71 gint64
mono_process_get_data_with_error (gpointer pid
, MonoProcessData data
, MonoProcessError
*error
);
73 int mono_process_current_pid (void);
75 MONO_API
int mono_cpu_count (void);
76 gint64
mono_cpu_get_data (int cpu_id
, MonoCpuData data
, MonoProcessError
*error
);
77 gint32
mono_cpu_usage (MonoCpuUsageState
*prev
);
79 int mono_atexit (void (*func
)(void));
86 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
88 #define IMAGE_DIRECTORY_ENTRY_EXPORT 0
89 #define IMAGE_DIRECTORY_ENTRY_IMPORT 1
90 #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2
92 #define IMAGE_SIZEOF_SHORT_NAME 8
94 #if G_BYTE_ORDER != G_LITTLE_ENDIAN
95 #define IMAGE_DOS_SIGNATURE 0x4d5a
96 #define IMAGE_NT_SIGNATURE 0x50450000
97 #define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0xb10
98 #define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0xb20
100 #define IMAGE_DOS_SIGNATURE 0x5a4d
101 #define IMAGE_NT_SIGNATURE 0x00004550
102 #define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
103 #define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
130 guint16 NumberOfSections
;
131 guint32 TimeDateStamp
;
132 guint32 PointerToSymbolTable
;
133 guint32 NumberOfSymbols
;
134 guint16 SizeOfOptionalHeader
;
135 guint16 Characteristics
;
139 guint32 VirtualAddress
;
141 } IMAGE_DATA_DIRECTORY
;
145 guint8 MajorLinkerVersion
;
146 guint8 MinorLinkerVersion
;
148 guint32 SizeOfInitializedData
;
149 guint32 SizeOfUninitializedData
;
150 guint32 AddressOfEntryPoint
;
154 guint32 SectionAlignment
;
155 guint32 FileAlignment
;
156 guint16 MajorOperatingSystemVersion
;
157 guint16 MinorOperatingSystemVersion
;
158 guint16 MajorImageVersion
;
159 guint16 MinorImageVersion
;
160 guint16 MajorSubsystemVersion
;
161 guint16 MinorSubsystemVersion
;
162 guint32 Win32VersionValue
;
164 guint32 SizeOfHeaders
;
167 guint16 DllCharacteristics
;
168 guint32 SizeOfStackReserve
;
169 guint32 SizeOfStackCommit
;
170 guint32 SizeOfHeapReserve
;
171 guint32 SizeOfHeapCommit
;
173 guint32 NumberOfRvaAndSizes
;
174 IMAGE_DATA_DIRECTORY DataDirectory
[IMAGE_NUMBEROF_DIRECTORY_ENTRIES
];
175 } IMAGE_OPTIONAL_HEADER32
;
179 guint8 MajorLinkerVersion
;
180 guint8 MinorLinkerVersion
;
182 guint32 SizeOfInitializedData
;
183 guint32 SizeOfUninitializedData
;
184 guint32 AddressOfEntryPoint
;
187 guint32 SectionAlignment
;
188 guint32 FileAlignment
;
189 guint16 MajorOperatingSystemVersion
;
190 guint16 MinorOperatingSystemVersion
;
191 guint16 MajorImageVersion
;
192 guint16 MinorImageVersion
;
193 guint16 MajorSubsystemVersion
;
194 guint16 MinorSubsystemVersion
;
195 guint32 Win32VersionValue
;
197 guint32 SizeOfHeaders
;
200 guint16 DllCharacteristics
;
201 guint64 SizeOfStackReserve
;
202 guint64 SizeOfStackCommit
;
203 guint64 SizeOfHeapReserve
;
204 guint64 SizeOfHeapCommit
;
206 guint32 NumberOfRvaAndSizes
;
207 IMAGE_DATA_DIRECTORY DataDirectory
[IMAGE_NUMBEROF_DIRECTORY_ENTRIES
];
208 } IMAGE_OPTIONAL_HEADER64
;
210 #if SIZEOF_VOID_P == 8
211 typedef IMAGE_OPTIONAL_HEADER64 IMAGE_OPTIONAL_HEADER
;
213 typedef IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER
;
218 IMAGE_FILE_HEADER FileHeader
;
219 IMAGE_OPTIONAL_HEADER32 OptionalHeader
;
220 } IMAGE_NT_HEADERS32
;
224 IMAGE_FILE_HEADER FileHeader
;
225 IMAGE_OPTIONAL_HEADER64 OptionalHeader
;
226 } IMAGE_NT_HEADERS64
;
228 #if SIZEOF_VOID_P == 8
229 typedef IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS
;
231 typedef IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS
;
235 guint8 Name
[IMAGE_SIZEOF_SHORT_NAME
];
237 guint32 PhysicalAddress
;
240 guint32 VirtualAddress
;
241 guint32 SizeOfRawData
;
242 guint32 PointerToRawData
;
243 guint32 PointerToRelocations
;
244 guint32 PointerToLinenumbers
;
245 guint16 NumberOfRelocations
;
246 guint16 NumberOfLinenumbers
;
247 guint32 Characteristics
;
248 } IMAGE_SECTION_HEADER
;
250 #define IMAGE_FIRST_SECTION32(header) ((IMAGE_SECTION_HEADER *)((gsize)(header) + G_STRUCT_OFFSET (IMAGE_NT_HEADERS32, OptionalHeader) + GUINT16_FROM_LE (((IMAGE_NT_HEADERS32 *)(header))->FileHeader.SizeOfOptionalHeader)))
252 #define RT_CURSOR 0x01
253 #define RT_BITMAP 0x02
256 #define RT_DIALOG 0x05
257 #define RT_STRING 0x06
258 #define RT_FONTDIR 0x07
260 #define RT_ACCELERATOR 0x09
261 #define RT_RCDATA 0x0a
262 #define RT_MESSAGETABLE 0x0b
263 #define RT_GROUP_CURSOR 0x0c
264 #define RT_GROUP_ICON 0x0e
265 #define RT_VERSION 0x10
266 #define RT_DLGINCLUDE 0x11
267 #define RT_PLUGPLAY 0x13
269 #define RT_ANICURSOR 0x15
270 #define RT_ANIICON 0x16
272 #define RT_MANIFEST 0x18
275 guint32 Characteristics
;
276 guint32 TimeDateStamp
;
277 guint16 MajorVersion
;
278 guint16 MinorVersion
;
279 guint16 NumberOfNamedEntries
;
280 guint16 NumberOfIdEntries
;
281 } IMAGE_RESOURCE_DIRECTORY
;
286 #if G_BYTE_ORDER == G_BIG_ENDIAN
287 guint32 NameIsString
:1;
288 guint32 NameOffset
:31;
290 guint32 NameOffset
:31;
291 guint32 NameIsString
:1;
295 #if G_BYTE_ORDER == G_BIG_ENDIAN
297 guint16 __wapi_big_endian_padding
;
305 guint32 OffsetToData
;
307 #if G_BYTE_ORDER == G_BIG_ENDIAN
308 guint32 DataIsDirectory
:1;
309 guint32 OffsetToDirectory
:31;
311 guint32 OffsetToDirectory
:31;
312 guint32 DataIsDirectory
:1;
316 } IMAGE_RESOURCE_DIRECTORY_ENTRY
;
319 guint32 OffsetToData
;
323 } IMAGE_RESOURCE_DATA_ENTRY
;
328 mono_pe_file_time_date_stamp (const gunichar2
*filename
, guint32
*out
);
331 mono_pe_file_map (const gunichar2
*filename
, gint32
*map_size
, void **handle
);
334 mono_pe_file_unmap (gpointer file_map
, void *handle
);
335 #endif /* HOST_WIN32 */
337 #endif /* __MONO_PROC_LIB_H__ */