sigar-test 0.7.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +201 -0
  3. data/NOTICE +117 -0
  4. data/README +2 -0
  5. data/Rakefile +105 -0
  6. data/bindings/SigarBuild.pm +301 -0
  7. data/bindings/SigarWrapper.pm +3025 -0
  8. data/bindings/ruby/extconf.rb +131 -0
  9. data/bindings/ruby/rbsigar.c +888 -0
  10. data/include/sigar.h +984 -0
  11. data/include/sigar_fileinfo.h +157 -0
  12. data/include/sigar_format.h +65 -0
  13. data/include/sigar_getline.h +18 -0
  14. data/include/sigar_log.h +80 -0
  15. data/include/sigar_private.h +429 -0
  16. data/include/sigar_ptql.h +53 -0
  17. data/include/sigar_util.h +197 -0
  18. data/src/os/aix/aix_sigar.c +2168 -0
  19. data/src/os/aix/sigar_os.h +73 -0
  20. data/src/os/darwin/Info.plist.in +27 -0
  21. data/src/os/darwin/darwin_sigar.c +3718 -0
  22. data/src/os/darwin/sigar_os.h +80 -0
  23. data/src/os/hpux/hpux_sigar.c +1361 -0
  24. data/src/os/hpux/sigar_os.h +49 -0
  25. data/src/os/linux/linux_sigar.c +2810 -0
  26. data/src/os/linux/sigar_os.h +82 -0
  27. data/src/os/solaris/get_mib2.c +321 -0
  28. data/src/os/solaris/get_mib2.h +127 -0
  29. data/src/os/solaris/kstats.c +181 -0
  30. data/src/os/solaris/procfs.c +97 -0
  31. data/src/os/solaris/sigar_os.h +224 -0
  32. data/src/os/solaris/solaris_sigar.c +2732 -0
  33. data/src/os/win32/peb.c +212 -0
  34. data/src/os/win32/sigar.rc.in +40 -0
  35. data/src/os/win32/sigar_os.h +685 -0
  36. data/src/os/win32/sigar_pdh.h +47 -0
  37. data/src/os/win32/win32_sigar.c +4109 -0
  38. data/src/sigar.c +2444 -0
  39. data/src/sigar_cache.c +253 -0
  40. data/src/sigar_fileinfo.c +815 -0
  41. data/src/sigar_format.c +696 -0
  42. data/src/sigar_getline.c +1849 -0
  43. data/src/sigar_ptql.c +1976 -0
  44. data/src/sigar_signal.c +216 -0
  45. data/src/sigar_util.c +1060 -0
  46. data/src/sigar_version.c.in +22 -0
  47. data/src/sigar_version_autoconf.c.in +22 -0
  48. data/version.properties +11 -0
  49. metadata +91 -0
@@ -0,0 +1,685 @@
1
+ /*
2
+ * Copyright (c) 2004-2009 Hyperic, Inc.
3
+ * Copyright (c) 2009 SpringSource, Inc.
4
+ * Copyright (c) 2009-2010 VMware, Inc.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ #ifndef SIGAR_OS_H
20
+ #define SIGAR_OS_H
21
+
22
+ #if !defined(MSVC) && defined(_MSC_VER)
23
+ #define MSVC
24
+ #endif
25
+
26
+ #ifdef MSVC
27
+ #define WIN32_LEAN_AND_MEAN
28
+ #define snprintf _snprintf
29
+ #if _MSC_VER <= 1200
30
+ #define SIGAR_USING_MSC6 /* Visual Studio version 6 */
31
+ #define HAVE_MIB_IPADDRROW_WTYPE 0
32
+ #else
33
+ #define HAVE_MIB_IPADDRROW_WTYPE 1
34
+ #endif
35
+ #else
36
+ /* Cross compiling */
37
+ #define _WIN32_WINNT 0x0501
38
+ #endif
39
+
40
+ #include <windows.h>
41
+ #include <winreg.h>
42
+ #include <winperf.h>
43
+ #include <winsock2.h>
44
+ #include <ws2tcpip.h>
45
+ #include <stddef.h>
46
+ #include <sys/types.h>
47
+ #include <malloc.h>
48
+ #include <stdio.h>
49
+ #include <errno.h>
50
+ #include <tlhelp32.h>
51
+
52
+ #include "sigar_util.h"
53
+
54
+ #ifdef MSVC
55
+ # define INT64_C(val) val##i64
56
+ # define SIGAR_DLLFUNC(api, name) \
57
+ struct { \
58
+ const char *name; \
59
+ ##api##_##name func; \
60
+ } ##name
61
+ #else
62
+ /* The GCC compiler doesn't require/accept the ## prefix */
63
+ # define INT64_C(val) val##L
64
+ # define SIGAR_DLLFUNC(api, name) \
65
+ struct { \
66
+ const char *name; \
67
+ api##_##name func; \
68
+ } name
69
+ #endif
70
+
71
+ /* see apr/include/arch/win32/atime.h */
72
+ #define EPOCH_DELTA INT64_C(11644473600000000)
73
+
74
+ #define SIGAR_CMDLINE_MAX 4096<<2
75
+
76
+ /* XXX: support CP_UTF8 ? */
77
+
78
+ #define SIGAR_A2W(lpa, lpw, bytes) \
79
+ (lpw[0] = 0, MultiByteToWideChar(CP_ACP, 0, \
80
+ lpa, -1, lpw, (bytes/sizeof(WCHAR))))
81
+
82
+ #define SIGAR_W2A(lpw, lpa, chars) \
83
+ (lpa[0] = '\0', WideCharToMultiByte(CP_ACP, 0, \
84
+ lpw, -1, (LPSTR)lpa, chars, \
85
+ NULL, NULL))
86
+
87
+ /* iptypes.h from vc7, not available in vc6 */
88
+ /* copy from PSDK if using vc6 */
89
+ #include "iptypes.h"
90
+
91
+ /* from wtsapi32.h not in vs6.0 */
92
+ typedef enum {
93
+ WTSInitialProgram,
94
+ WTSApplicationName,
95
+ WTSWorkingDirectory,
96
+ WTSOEMId,
97
+ WTSSessionId,
98
+ WTSUserName,
99
+ WTSWinStationName,
100
+ WTSDomainName,
101
+ WTSConnectState,
102
+ WTSClientBuildNumber,
103
+ WTSClientName,
104
+ WTSClientDirectory,
105
+ WTSClientProductId,
106
+ WTSClientHardwareId,
107
+ WTSClientAddress,
108
+ WTSClientDisplay,
109
+ WTSClientProtocolType,
110
+ } WTS_INFO_CLASS;
111
+
112
+ typedef enum _WTS_CONNECTSTATE_CLASS {
113
+ WTSActive,
114
+ WTSConnected,
115
+ WTSConnectQuery,
116
+ WTSShadow,
117
+ WTSDisconnected,
118
+ WTSIdle,
119
+ WTSListen,
120
+ WTSReset,
121
+ WTSDown,
122
+ WTSInit
123
+ } WTS_CONNECTSTATE_CLASS;
124
+
125
+ #define WTS_PROTOCOL_TYPE_CONSOLE 0
126
+ #define WTS_PROTOCOL_TYPE_ICA 1
127
+ #define WTS_PROTOCOL_TYPE_RDP 2
128
+
129
+ typedef struct _WTS_SESSION_INFO {
130
+ DWORD SessionId;
131
+ LPTSTR pWinStationName;
132
+ DWORD State;
133
+ } WTS_SESSION_INFO, *PWTS_SESSION_INFO;
134
+
135
+ typedef struct _WTS_PROCESS_INFO {
136
+ DWORD SessionId;
137
+ DWORD ProcessId;
138
+ LPSTR pProcessName;
139
+ PSID pUserSid;
140
+ } WTS_PROCESS_INFO, *PWTS_PROCESS_INFO;
141
+
142
+ typedef struct _WTS_CLIENT_ADDRESS {
143
+ DWORD AddressFamily;
144
+ BYTE Address[20];
145
+ } WTS_CLIENT_ADDRESS, *PWTS_CLIENT_ADDRESS;
146
+
147
+ /* the WINSTATION_INFO stuff here is undocumented
148
+ * got the howto from google groups:
149
+ * http://redirx.com/?31gy
150
+ */
151
+ typedef enum _WINSTATION_INFO_CLASS {
152
+ WinStationInformation = 8
153
+ } WINSTATION_INFO_CLASS;
154
+
155
+ typedef struct _WINSTATION_INFO {
156
+ BYTE Reserved1[72];
157
+ ULONG SessionId;
158
+ BYTE Reserved2[4];
159
+ FILETIME ConnectTime;
160
+ FILETIME DisconnectTime;
161
+ FILETIME LastInputTime;
162
+ FILETIME LoginTime;
163
+ BYTE Reserved3[1096];
164
+ FILETIME CurrentTime;
165
+ } WINSTATION_INFO, *PWINSTATION_INFO;
166
+
167
+ /* end wtsapi32.h */
168
+
169
+ #ifdef SIGAR_USING_MSC6
170
+
171
+ /* from winbase.h not in vs6.0 */
172
+ typedef struct {
173
+ DWORD dwLength;
174
+ DWORD dwMemoryLoad;
175
+ DWORDLONG ullTotalPhys;
176
+ DWORDLONG ullAvailPhys;
177
+ DWORDLONG ullTotalPageFile;
178
+ DWORDLONG ullAvailPageFile;
179
+ DWORDLONG ullTotalVirtual;
180
+ DWORDLONG ullAvailVirtual;
181
+ DWORDLONG ullAvailExtendedVirtual;
182
+ } MEMORYSTATUSEX;
183
+
184
+ /* service manager stuff not in vs6.0 */
185
+ typedef struct _SERVICE_STATUS_PROCESS {
186
+ DWORD dwServiceType;
187
+ DWORD dwCurrentState;
188
+ DWORD dwControlsAccepted;
189
+ DWORD dwWin32ExitCode;
190
+ DWORD dwServiceSpecificExitCode;
191
+ DWORD dwCheckPoint;
192
+ DWORD dwWaitHint;
193
+ DWORD dwProcessId;
194
+ DWORD dwServiceFlags;
195
+ } SERVICE_STATUS_PROCESS;
196
+
197
+ typedef enum {
198
+ SC_STATUS_PROCESS_INFO = 0
199
+ } SC_STATUS_TYPE;
200
+
201
+ #ifndef ERROR_DATATYPE_MISMATCH
202
+ #define ERROR_DATATYPE_MISMATCH 1629L
203
+ #endif
204
+
205
+ #endif /* _MSC_VER */
206
+
207
+ #include <iprtrmib.h>
208
+
209
+ /* undocumented structures */
210
+ typedef struct {
211
+ DWORD dwState;
212
+ DWORD dwLocalAddr;
213
+ DWORD dwLocalPort;
214
+ DWORD dwRemoteAddr;
215
+ DWORD dwRemotePort;
216
+ DWORD dwProcessId;
217
+ } MIB_TCPEXROW, *PMIB_TCPEXROW;
218
+
219
+ typedef struct {
220
+ DWORD dwNumEntries;
221
+ MIB_TCPEXROW table[ANY_SIZE];
222
+ } MIB_TCPEXTABLE, *PMIB_TCPEXTABLE;
223
+
224
+ typedef struct {
225
+ DWORD dwLocalAddr;
226
+ DWORD dwLocalPort;
227
+ DWORD dwProcessId;
228
+ } MIB_UDPEXROW, *PMIB_UDPEXROW;
229
+
230
+ typedef struct {
231
+ DWORD dwNumEntries;
232
+ MIB_UDPEXROW table[ANY_SIZE];
233
+ } MIB_UDPEXTABLE, *PMIB_UDPEXTABLE;
234
+
235
+ /* end undocumented structures */
236
+
237
+ /* no longer in the standard header files */
238
+ typedef struct {
239
+ LARGE_INTEGER IdleTime;
240
+ LARGE_INTEGER KernelTime;
241
+ LARGE_INTEGER UserTime;
242
+ LARGE_INTEGER DpcTime;
243
+ LARGE_INTEGER InterruptTime;
244
+ ULONG InterruptCount;
245
+ } SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION;
246
+
247
+ #define SystemProcessorPerformanceInformation 8
248
+
249
+ /* PEB decls from msdn docs w/ slight mods */
250
+ #define ProcessBasicInformation 0
251
+
252
+ typedef struct _UNICODE_STRING {
253
+ USHORT Length;
254
+ USHORT MaximumLength;
255
+ PWSTR Buffer;
256
+ } UNICODE_STRING, *PUNICODE_STRING;
257
+
258
+ typedef struct _PEB_LDR_DATA {
259
+ BYTE Reserved1[8];
260
+ PVOID Reserved2[3];
261
+ LIST_ENTRY InMemoryOrderModuleList;
262
+ } PEB_LDR_DATA, *PPEB_LDR_DATA;
263
+
264
+ typedef struct RTL_DRIVE_LETTER_CURDIR {
265
+ USHORT Flags;
266
+ USHORT Length;
267
+ ULONG TimeStamp;
268
+ UNICODE_STRING DosPath;
269
+ } RTL_DRIVE_LETTER_CURDIR, *PRTL_DRIVE_LETTER_CURDIR;
270
+
271
+ /* from: http://source.winehq.org/source/include/winternl.h */
272
+ typedef struct _RTL_USER_PROCESS_PARAMETERS {
273
+ ULONG AllocationSize;
274
+ ULONG Size;
275
+ ULONG Flags;
276
+ ULONG DebugFlags;
277
+ HANDLE hConsole;
278
+ ULONG ProcessGroup;
279
+ HANDLE hStdInput;
280
+ HANDLE hStdOutput;
281
+ HANDLE hStdError;
282
+ UNICODE_STRING CurrentDirectoryName;
283
+ HANDLE CurrentDirectoryHandle;
284
+ UNICODE_STRING DllPath;
285
+ UNICODE_STRING ImagePathName;
286
+ UNICODE_STRING CommandLine;
287
+ PWSTR Environment;
288
+ ULONG dwX;
289
+ ULONG dwY;
290
+ ULONG dwXSize;
291
+ ULONG dwYSize;
292
+ ULONG dwXCountChars;
293
+ ULONG dwYCountChars;
294
+ ULONG dwFillAttribute;
295
+ ULONG dwFlags;
296
+ ULONG wShowWindow;
297
+ UNICODE_STRING WindowTitle;
298
+ UNICODE_STRING Desktop;
299
+ UNICODE_STRING ShellInfo;
300
+ UNICODE_STRING RuntimeInfo;
301
+ RTL_DRIVE_LETTER_CURDIR DLCurrentDirectory[0x20];
302
+ } RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS;
303
+
304
+ /* from msdn docs
305
+ typedef struct _RTL_USER_PROCESS_PARAMETERS {
306
+ BYTE Reserved1[16];
307
+ PVOID Reserved2[10];
308
+ UNICODE_STRING ImagePathName;
309
+ UNICODE_STRING CommandLine;
310
+ } RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS;
311
+ */
312
+
313
+ typedef struct _PEB {
314
+ BYTE Reserved1[2];
315
+ BYTE BeingDebugged;
316
+ BYTE Reserved2[1];
317
+ PVOID Reserved3[2];
318
+ PPEB_LDR_DATA Ldr;
319
+ PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
320
+ BYTE Reserved4[104];
321
+ PVOID Reserved5[52];
322
+ /*PPS_POST_PROCESS_INIT_ROUTINE*/ PVOID PostProcessInitRoutine;
323
+ BYTE Reserved6[128];
324
+ PVOID Reserved7[1];
325
+ ULONG SessionId;
326
+ } PEB, *PPEB;
327
+
328
+ typedef struct _PROCESS_BASIC_INFORMATION {
329
+ PVOID Reserved1;
330
+ PPEB PebBaseAddress;
331
+ PVOID Reserved2[2];
332
+ /*ULONG_PTR*/ UINT_PTR UniqueProcessId;
333
+ PVOID Reserved3;
334
+ } PROCESS_BASIC_INFORMATION;
335
+
336
+ typedef struct {
337
+ sigar_pid_t pid;
338
+ int ppid;
339
+ int priority;
340
+ time_t mtime;
341
+ sigar_uint64_t size;
342
+ sigar_uint64_t resident;
343
+ char name[SIGAR_PROC_NAME_LEN];
344
+ char state;
345
+ sigar_uint64_t handles;
346
+ sigar_uint64_t threads;
347
+ sigar_uint64_t page_faults;
348
+ sigar_uint64_t bytes_read;
349
+ sigar_uint64_t bytes_written;
350
+ } sigar_win32_pinfo_t;
351
+
352
+ typedef struct {
353
+ const char *name;
354
+ HINSTANCE handle;
355
+ } sigar_dll_handle_t;
356
+
357
+ typedef struct {
358
+ const char *name;
359
+ FARPROC func;
360
+ } sigar_dll_func_t;
361
+
362
+ typedef struct {
363
+ const char *name;
364
+ HINSTANCE handle;
365
+ sigar_dll_func_t funcs[12];
366
+ } sigar_dll_module_t;
367
+
368
+ /* wtsapi.dll */
369
+ typedef BOOL (CALLBACK *wtsapi_enum_sessions)(HANDLE,
370
+ DWORD,
371
+ DWORD,
372
+ PWTS_SESSION_INFO *,
373
+ DWORD *);
374
+
375
+ typedef void (CALLBACK *wtsapi_free_mem)(PVOID);
376
+
377
+ typedef BOOL (CALLBACK *wtsapi_query_session)(HANDLE,
378
+ DWORD,
379
+ WTS_INFO_CLASS,
380
+ LPSTR *, DWORD *);
381
+ /* iphlpapi.dll */
382
+
383
+ typedef DWORD (CALLBACK *iphlpapi_get_ipforward_table)(PMIB_IPFORWARDTABLE,
384
+ PULONG,
385
+ BOOL);
386
+
387
+ typedef DWORD (CALLBACK *iphlpapi_get_ipaddr_table)(PMIB_IPADDRTABLE,
388
+ PULONG,
389
+ BOOL);
390
+
391
+ typedef DWORD (CALLBACK *iphlpapi_get_if_table)(PMIB_IFTABLE,
392
+ PULONG,
393
+ BOOL);
394
+
395
+ typedef DWORD (CALLBACK *iphlpapi_get_if_entry)(PMIB_IFROW);
396
+
397
+ typedef DWORD (CALLBACK *iphlpapi_get_num_if)(PDWORD);
398
+
399
+ typedef DWORD (CALLBACK *iphlpapi_get_tcp_table)(PMIB_TCPTABLE,
400
+ PDWORD,
401
+ BOOL);
402
+
403
+ typedef DWORD (CALLBACK *iphlpapi_get_udp_table)(PMIB_UDPTABLE,
404
+ PDWORD,
405
+ BOOL);
406
+
407
+ typedef DWORD (CALLBACK *iphlpapi_get_tcpx_table)(PMIB_TCPEXTABLE *,
408
+ BOOL,
409
+ HANDLE,
410
+ DWORD,
411
+ DWORD);
412
+
413
+ typedef DWORD (CALLBACK *iphlpapi_get_udpx_table)(PMIB_UDPEXTABLE *,
414
+ BOOL,
415
+ HANDLE,
416
+ DWORD,
417
+ DWORD);
418
+
419
+ typedef DWORD (CALLBACK *iphlpapi_get_tcp_stats)(PMIB_TCPSTATS);
420
+
421
+ typedef DWORD (CALLBACK *iphlpapi_get_net_params)(PFIXED_INFO,
422
+ PULONG);
423
+
424
+ typedef DWORD (CALLBACK *iphlpapi_get_adapters_info)(PIP_ADAPTER_INFO,
425
+ PULONG);
426
+
427
+ typedef ULONG (CALLBACK *iphlpapi_get_adapters_addrs)(ULONG,
428
+ ULONG,
429
+ PVOID,
430
+ PIP_ADAPTER_ADDRESSES,
431
+ PULONG);
432
+
433
+ /* advapi32.dll */
434
+ typedef BOOL (CALLBACK *advapi_convert_string_sid)(LPCSTR,
435
+ PSID *);
436
+
437
+ typedef BOOL (CALLBACK *advapi_query_service_status)(SC_HANDLE,
438
+ SC_STATUS_TYPE,
439
+ LPBYTE,
440
+ DWORD,
441
+ LPDWORD);
442
+
443
+ typedef DWORD (CALLBACK *iphlpapi_get_ipnet_table)(PMIB_IPNETTABLE,
444
+ PDWORD,
445
+ BOOL);
446
+
447
+ /* ntdll.dll */
448
+ typedef DWORD (CALLBACK *ntdll_query_sys_info)(DWORD,
449
+ PVOID,
450
+ ULONG,
451
+ PULONG);
452
+
453
+ typedef DWORD (CALLBACK *ntdll_query_proc_info)(HANDLE,
454
+ DWORD,
455
+ PVOID,
456
+ ULONG,
457
+ PULONG);
458
+
459
+ /* psapi.dll */
460
+ typedef BOOL (CALLBACK *psapi_enum_modules)(HANDLE,
461
+ HMODULE *,
462
+ DWORD,
463
+ LPDWORD);
464
+
465
+ typedef DWORD (CALLBACK *psapi_get_module_name)(HANDLE,
466
+ HMODULE,
467
+ LPTSTR,
468
+ DWORD);
469
+
470
+ typedef BOOL (CALLBACK *psapi_enum_processes)(DWORD *,
471
+ DWORD,
472
+ DWORD *);
473
+
474
+ /* winsta.dll */
475
+ typedef BOOLEAN (CALLBACK *winsta_query_info)(HANDLE,
476
+ ULONG,
477
+ WINSTATION_INFO_CLASS,
478
+ PVOID,
479
+ ULONG,
480
+ PULONG);
481
+
482
+ /* kernel32.dll */
483
+ typedef BOOL (CALLBACK *kernel_memory_status)(MEMORYSTATUSEX *);
484
+
485
+ /* mpr.dll */
486
+ typedef BOOL (CALLBACK *mpr_get_net_connection)(LPCTSTR,
487
+ LPTSTR,
488
+ LPDWORD);
489
+
490
+ typedef struct {
491
+ sigar_dll_handle_t handle;
492
+
493
+ SIGAR_DLLFUNC(wtsapi, enum_sessions);
494
+ SIGAR_DLLFUNC(wtsapi, free_mem);
495
+ SIGAR_DLLFUNC(wtsapi, query_session);
496
+
497
+ sigar_dll_func_t end;
498
+ } sigar_wtsapi_t;
499
+
500
+ typedef struct {
501
+ sigar_dll_handle_t handle;
502
+
503
+ SIGAR_DLLFUNC(iphlpapi, get_ipforward_table);
504
+ SIGAR_DLLFUNC(iphlpapi, get_ipaddr_table);
505
+ SIGAR_DLLFUNC(iphlpapi, get_if_table);
506
+ SIGAR_DLLFUNC(iphlpapi, get_if_entry);
507
+ SIGAR_DLLFUNC(iphlpapi, get_num_if);
508
+ SIGAR_DLLFUNC(iphlpapi, get_tcp_table);
509
+ SIGAR_DLLFUNC(iphlpapi, get_udp_table);
510
+ SIGAR_DLLFUNC(iphlpapi, get_tcpx_table);
511
+ SIGAR_DLLFUNC(iphlpapi, get_udpx_table);
512
+ SIGAR_DLLFUNC(iphlpapi, get_tcp_stats);
513
+ SIGAR_DLLFUNC(iphlpapi, get_net_params);
514
+ SIGAR_DLLFUNC(iphlpapi, get_adapters_info);
515
+ SIGAR_DLLFUNC(iphlpapi, get_adapters_addrs);
516
+ SIGAR_DLLFUNC(iphlpapi, get_ipnet_table);
517
+
518
+ sigar_dll_func_t end;
519
+ } sigar_iphlpapi_t;
520
+
521
+ typedef struct {
522
+ sigar_dll_handle_t handle;
523
+
524
+ SIGAR_DLLFUNC(advapi, convert_string_sid);
525
+ SIGAR_DLLFUNC(advapi, query_service_status);
526
+
527
+ sigar_dll_func_t end;
528
+ } sigar_advapi_t;
529
+
530
+ typedef struct {
531
+ sigar_dll_handle_t handle;
532
+
533
+ SIGAR_DLLFUNC(ntdll, query_sys_info);
534
+ SIGAR_DLLFUNC(ntdll, query_proc_info);
535
+
536
+ sigar_dll_func_t end;
537
+ } sigar_ntdll_t;
538
+
539
+ typedef struct {
540
+ sigar_dll_handle_t handle;
541
+
542
+ SIGAR_DLLFUNC(psapi, enum_modules);
543
+ SIGAR_DLLFUNC(psapi, enum_processes);
544
+ SIGAR_DLLFUNC(psapi, get_module_name);
545
+
546
+ sigar_dll_func_t end;
547
+ } sigar_psapi_t;
548
+
549
+ typedef struct {
550
+ sigar_dll_handle_t handle;
551
+
552
+ SIGAR_DLLFUNC(winsta, query_info);
553
+
554
+ sigar_dll_func_t end;
555
+ } sigar_winsta_t;
556
+
557
+ typedef struct {
558
+ sigar_dll_handle_t handle;
559
+
560
+ SIGAR_DLLFUNC(kernel, memory_status);
561
+
562
+ sigar_dll_func_t end;
563
+ } sigar_kernel_t;
564
+
565
+ typedef struct {
566
+ sigar_dll_handle_t handle;
567
+
568
+ SIGAR_DLLFUNC(mpr, get_net_connection);
569
+
570
+ sigar_dll_func_t end;
571
+ } sigar_mpr_t;
572
+
573
+ typedef struct
574
+ {
575
+ char *buffer;
576
+ DWORD size;
577
+ time_t create_time;
578
+ } buffer_t;
579
+
580
+ struct sigar_t {
581
+ SIGAR_T_BASE;
582
+ char *machine;
583
+ int using_wide;
584
+ long pagesize;
585
+ HKEY handle;
586
+ buffer_t** performanceBuffers;
587
+ buffer_t* processesBuffer;
588
+ sigar_wtsapi_t wtsapi;
589
+ sigar_iphlpapi_t iphlpapi;
590
+ sigar_advapi_t advapi;
591
+ sigar_ntdll_t ntdll;
592
+ sigar_psapi_t psapi;
593
+ sigar_winsta_t winsta;
594
+ sigar_kernel_t kernel;
595
+ sigar_mpr_t mpr;
596
+ sigar_win32_pinfo_t pinfo;
597
+ sigar_cache_t *netif_adapters;
598
+ sigar_cache_t *netif_mib_rows;
599
+ sigar_cache_t *netif_addr_rows;
600
+ sigar_cache_t *netif_names; /* dwIndex -> net_interface_config.name */
601
+ int netif_name_short;
602
+
603
+ WORD ws_version;
604
+ int ws_error;
605
+ int ht_enabled;
606
+ int lcpu; //number of logical cpus
607
+ int winnt;
608
+ };
609
+
610
+ #ifdef __cplusplus
611
+ extern "C" {
612
+ #endif
613
+
614
+ sigar_uint64_t sigar_FileTimeToTime(FILETIME *ft);
615
+
616
+ int sigar_wsa_init(sigar_t *sigar);
617
+
618
+ int sigar_proc_exe_peb_get(sigar_t *sigar, HANDLE proc,
619
+ sigar_proc_exe_t *procexe);
620
+
621
+ int sigar_proc_args_peb_get(sigar_t *sigar, HANDLE proc,
622
+ sigar_proc_args_t *procargs);
623
+
624
+ int sigar_proc_env_peb_get(sigar_t *sigar, HANDLE proc,
625
+ WCHAR *env, DWORD envlen);
626
+
627
+ int sigar_proc_args_wmi_get(sigar_t *sigar, sigar_pid_t pid,
628
+ sigar_proc_args_t *procargs);
629
+
630
+ int sigar_proc_exe_wmi_get(sigar_t *sigar, sigar_pid_t pid,
631
+ sigar_proc_exe_t *procexe);
632
+
633
+ int sigar_parse_proc_args(sigar_t *sigar, WCHAR *buf,
634
+ sigar_proc_args_t *procargs);
635
+
636
+ int sigar_service_pid_get(sigar_t *sigar, char *name, sigar_pid_t *pid);
637
+
638
+ typedef struct {
639
+ DWORD size;
640
+ DWORD count;
641
+ ENUM_SERVICE_STATUS *services;
642
+ SC_HANDLE handle;
643
+ } sigar_services_status_t;
644
+
645
+ int sigar_services_status_get(sigar_services_status_t *ss, DWORD state);
646
+
647
+ void sigar_services_status_close(sigar_services_status_t *ss);
648
+
649
+ typedef struct sigar_services_walker_t sigar_services_walker_t;
650
+
651
+ struct sigar_services_walker_t {
652
+ sigar_t *sigar;
653
+ int flags;
654
+ void *data; /* user data */
655
+ int (*add_service)(sigar_services_walker_t *walker, char *name);
656
+ };
657
+
658
+ int sigar_services_query(char *ptql,
659
+ sigar_ptql_error_t *error,
660
+ sigar_services_walker_t *walker);
661
+
662
+ char *sigar_service_exe_get(char *path, char *buffer, int basename);
663
+
664
+ typedef struct {
665
+ WORD product_major;
666
+ WORD product_minor;
667
+ WORD product_build;
668
+ WORD product_revision;
669
+ WORD file_major;
670
+ WORD file_minor;
671
+ WORD file_build;
672
+ WORD file_revision;
673
+ } sigar_file_version_t;
674
+
675
+ int sigar_file_version_get(sigar_file_version_t *version,
676
+ char *name,
677
+ sigar_proc_env_t *infocb);
678
+
679
+ #ifdef __cplusplus
680
+ }
681
+ #endif
682
+
683
+ #define SIGAR_NO_SUCH_PROCESS (SIGAR_OS_START_ERROR+1)
684
+
685
+ #endif /* SIGAR_OS_H */