ReactOS 0.4.16-dev-2528-g7139e57
systeminfo.c File Reference
#include <wchar.h>
#include <stdio.h>
#include <windef.h>
#include <winbase.h>
#include <wincon.h>
#include <shlwapi.h>
#include <lm.h>
#include <iphlpapi.h>
#include <winsock2.h>
#include <udmihelp.h>
#include <conutils.h>
#include "resource.h"
Include dependency graph for systeminfo.c:

Go to the source code of this file.

Macros

#define BUFFER_SIZE   1024
 

Functions

static UINT RegGetSZ (HKEY hKey, PCWSTR pSubKey, PCWSTR pValueName, PWSTR pBuf, DWORD cchBuf)
 
static BOOL RegGetDWORD (HKEY hKey, PCWSTR pSubKey, PCWSTR pValueName, PDWORD pData)
 
static VOID FormatBytes (PWSTR pBuf, UINT cBytes)
 
static VOID FormatDateTime (time_t Time, PWSTR pBuf)
 
ULONGLONG GetSecondsQPC (VOID)
 
ULONGLONG GetSeconds (VOID)
 
static VOID Usage (VOID)
 
static VOID PrintRow (UINT nTitleID, BOOL bIndent, PCWSTR pFormat,...)
 
VOID AllSysInfo (VOID)
 
int wmain (int argc, wchar_t *argv[])
 

Macro Definition Documentation

◆ BUFFER_SIZE

#define BUFFER_SIZE   1024

Definition at line 27 of file systeminfo.c.

Function Documentation

◆ AllSysInfo()

VOID AllSysInfo ( VOID  )

Definition at line 257 of file systeminfo.c.

258{
259 DWORD dwCharCount, dwTimestamp, dwResult;
261 SYSTEM_INFO SysInfo;
262 WCHAR Buf[BUFFER_SIZE], Tmp[BUFFER_SIZE], szSystemDir[MAX_PATH];
263 PCWSTR SysType;
265 NETSETUP_JOIN_STATUS NetJoinStatus;
266 MEMORYSTATUS MemoryStatus;
267 UINT cSeconds, i, j;
268 TIME_ZONE_INFORMATION TimeZoneInfo;
269 HKEY hKey;
270 PIP_ADAPTER_ADDRESSES pAdapters;
271 ULONG cbAdapters;
272 PVOID SMBiosBuf;
273 PCHAR DmiStrings[ID_STRINGS_MAX] = { 0 };
274
275 if (!GetSystemDirectoryW(szSystemDir, _countof(szSystemDir)))
276 {
277 ConPrintf(StdErr, L"Error! GetSystemDirectory failed.\n");
278 return;
279 }
280
281 GetSystemInfo(&SysInfo);
282
283 /* Getting computer name */
284 dwCharCount = _countof(Buf);
285 if (!GetComputerNameW(Buf, &dwCharCount))
286 ConPrintf(StdErr, L"Error! GetComputerName failed.\n");
287 else
288 PrintRow(IDS_HOST_NAME, FALSE, L"%s", Buf);
289
290 /* Open CurrentVersion key */
292 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
293 0,
295 &hKey) != ERROR_SUCCESS)
296 {
297 ConPrintf(StdErr, L"Error! RegOpenKeyEx failed.\n");
298 return;
299 }
300
301 /* Getting OS Name */
302 RegGetSZ(hKey, NULL, L"ProductName", Buf, _countof(Buf));
303 PrintRow(IDS_OS_NAME, FALSE, L"%s", Buf);
304
305 /* Getting OS Version */
309
310 if (!LoadStringW(NULL, IDS_BUILD, Tmp, _countof(Tmp)))
311 Tmp[0] = L'\0';
313 FALSE,
314 L"%lu.%lu.%lu %s %s %lu",
319 Tmp,
321
322 /* Getting OS Manufacturer */
323
324 /* Getting OS Configuration */
325
326 /* Getting OS Build Type */
327 RegGetSZ(hKey, NULL, L"CurrentType", Buf, _countof(Buf));
328 PrintRow(IDS_OS_BUILD_TYPE, FALSE, L"%s", Buf);
329
330 /* Getting Registered Owner */
331 RegGetSZ(hKey, NULL, L"RegisteredOwner", Buf, _countof(Buf));
332 PrintRow(IDS_REG_OWNER, FALSE, L"%s", Buf);
333
334 /* Getting Registered Organization */
335 RegGetSZ(hKey, NULL, L"RegisteredOrganization", Buf, _countof(Buf));
336 PrintRow(IDS_REG_ORG, FALSE, L"%s", Buf);
337
338 /* Getting Product ID */
339 RegGetSZ(hKey, NULL, L"ProductId", Buf, _countof(Buf));
340 PrintRow(IDS_PRODUCT_ID, FALSE, L"%s", Buf);
341
342 /* Getting Install Date */
343 RegGetDWORD(hKey, NULL, L"InstallDate", &dwTimestamp);
344 FormatDateTime((time_t)dwTimestamp, Buf);
345 PrintRow(IDS_INST_DATE, FALSE, L"%s", Buf);
346
347 /* Close Current Version key now */
349
350 /* Getting System Up Time */
351 cSeconds = GetSeconds();
353 Tmp[0] = L'\0';
354 swprintf(Buf, Tmp, cSeconds / (60*60*24), (cSeconds / (60*60)) % 24, (cSeconds / 60) % 60, cSeconds % 60);
355 PrintRow(IDS_UP_TIME, FALSE, L"%s", Buf);
356
357 /* Prepare SMBIOS data */
358 SMBiosBuf = LoadSMBiosData(DmiStrings);
359
360 /* Getting System Manufacturer;
361 * HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation\Manufacturer
362 * for Win >= 6.0 */
363 swprintf(Tmp, L"%s\\oeminfo.ini", szSystemDir);
365 L"Manufacturer",
366 L"",
367 Buf,
368 _countof(Buf),
369 Tmp);
370 if (wcslen(Buf) == 0 && SMBiosBuf)
371 {
372 GetSMBiosStringW(DmiStrings[SYS_VENDOR], Buf, _countof(Buf), FALSE);
373 }
375
376 /* Getting System Model;
377 * HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation\Model
378 * for Win >= 6.0 */
380 L"Model",
381 L"",
382 Buf,
383 _countof(Buf),
384 Tmp);
385 if (wcslen(Buf) == 0 && SMBiosBuf)
386 {
387 GetSMBiosStringW(DmiStrings[SYS_PRODUCT], Buf, _countof(Buf), FALSE);
388 }
389 PrintRow(IDS_SYS_MODEL, FALSE, L"%s", Buf);
390
391 /* Getting System type */
392 switch (SysInfo.wProcessorArchitecture)
393 {
395 SysType = L"X86-based PC";
396 break;
398 SysType = L"IA64-based PC";
399 break;
401 SysType = L"AMD64-based PC";
402 break;
403 default:
404 SysType = L"Unknown";
405 break;
406 }
407 PrintRow(IDS_SYS_TYPE, FALSE, L"%s", SysType);
408
409 /* Getting Processor(s) */
411 Tmp[0] = L'\0';
412 swprintf(Buf, Tmp, (UINT)SysInfo.dwNumberOfProcessors);
413 PrintRow(IDS_PROCESSORS, FALSE, L"%s", Buf);
414 for (i = 0; i < (UINT)SysInfo.dwNumberOfProcessors; i++)
415 {
416 swprintf(Tmp, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%u", i);
417 j = swprintf(Buf, L"[%02u]: ", i + 1);
418
419 j += RegGetSZ(HKEY_LOCAL_MACHINE, Tmp, L"Identifier", Buf + j, _countof(Buf) - j);
420 if (j + 1 < _countof(Buf))
421 Buf[j++] = L' ';
422 RegGetSZ(HKEY_LOCAL_MACHINE, Tmp, L"VendorIdentifier", Buf + j, _countof(Buf) - j);
423
424 PrintRow(0, FALSE, L"%s", Buf);
425 }
426
427 /* Getting BIOS Version */
428 if (SMBiosBuf)
429 {
430 j = GetSMBiosStringW(DmiStrings[BIOS_VENDOR], Buf, _countof(Buf), TRUE);
431 if (j + 1 < _countof(Buf))
432 {
433 Buf[j++] = L' ';
434 Buf[j] = L'\0';
435 }
436 GetSMBiosStringW(DmiStrings[BIOS_VERSION], Buf + j, _countof(Buf) - j, TRUE);
437 }
438 else
439 {
441 L"HARDWARE\\DESCRIPTION\\System",
442 L"SystemBiosVersion",
443 Buf,
444 _countof(Buf));
445 }
446 PrintRow(IDS_BIOS_VERSION, FALSE, L"%s", Buf);
447
448 /* Getting BIOS date */
449 if (SMBiosBuf)
450 {
451 GetSMBiosStringW(DmiStrings[BIOS_DATE], Buf, _countof(Buf), TRUE);
452 }
453 else
454 {
456 L"HARDWARE\\DESCRIPTION\\System",
457 L"SystemBiosDate",
458 Buf,
459 _countof(Buf));
460 }
461 PrintRow(IDS_BIOS_DATE, FALSE, L"%s", Buf);
462
463 /* Clean SMBIOS data */
464 FreeSMBiosData(SMBiosBuf);
465
466 /* Getting ReactOS Directory */
467 if (!GetWindowsDirectoryW(Buf, _countof(Buf)))
468 ConPrintf(StdErr, L"Error! GetWindowsDirectory failed.");
469 else
470 PrintRow(IDS_ROS_DIR, FALSE, L"%s", Buf);
471
472 /* Getting System Directory */
473 PrintRow(IDS_SYS_DIR, 0, L"%s", szSystemDir);
474
475 /* Getting Boot Device */
477 L"SYSTEM\\Setup",
478 L"SystemPartition",
479 Buf,
480 _countof(Buf));
481 PrintRow(IDS_BOOT_DEV, FALSE, L"%s", Buf);
482
483 /* Getting System Locale */
485 {
487 L"MIME\\Database\\Rfc1766",
488 Tmp,
489 Buf,
490 _countof(Buf)))
491 {
492 /* Get rid of @filename,resource */
493 pBuffer = wcschr(Buf, L';');
494 if (pBuffer)
495 SHLoadIndirectString(pBuffer+1, pBuffer+1, _countof(Buf) - (pBuffer-Buf) - 1, NULL);
496
497 PrintRow(IDS_SYS_LOCALE, FALSE, L"%s", Buf);
498 }
499 }
500
501 /* Getting Input Locale */
503 L"Keyboard Layout\\Preload",
504 L"1",
505 Tmp,
506 _countof(Tmp)) && wcslen(Tmp) > 4)
507 {
509 L"MIME\\Database\\Rfc1766",
510 Tmp + 4,
511 Buf,
512 _countof(Buf)))
513 {
514 /* Get rid of @filename,resource */
515 pBuffer = wcschr(Buf, L';');
516 if (pBuffer)
517 SHLoadIndirectString(pBuffer+1, pBuffer+1, _countof(Buf) - (pBuffer-Buf) - 1, NULL);
518
519 PrintRow(IDS_INPUT_LOCALE, FALSE, L"%s", Buf);
520 }
521 }
522
523 /* Getting Time Zone */
524 GetTimeZoneInformation(&TimeZoneInfo);
525
526 /* Open Time Zones key */
528 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones",
529 0,
531 &hKey) == ERROR_SUCCESS)
532 {
533 /* Find current timezone */
534 UINT i;
535 dwCharCount = _countof(Tmp);
536 for (i = 0; RegEnumKeyExW(hKey, i, Tmp, &dwCharCount, NULL, NULL, NULL, NULL) == ERROR_SUCCESS; ++i, dwCharCount = 255)
537 {
538 RegGetSZ(hKey, Tmp, L"Std", Buf, _countof(Buf));
539
540 if (!wcscmp(Buf, TimeZoneInfo.StandardName))
541 {
542 RegGetSZ(hKey, Tmp, L"Display", Buf, _countof(Buf));
543
544 PrintRow(IDS_TIME_ZONE, FALSE, L"%s", Buf);
545
546 break;
547 }
548 }
550 }
551
552 /* Getting Total Physical Memory */
553 GlobalMemoryStatus(&MemoryStatus);
554 FormatBytes(Buf, MemoryStatus.dwTotalPhys);
556
557 /* Getting Available Physical Memory */
558 FormatBytes(Buf, MemoryStatus.dwAvailPhys);
560
561 /* Getting Virtual Memory: Max Size */
562 FormatBytes(Buf, MemoryStatus.dwTotalVirtual);
563 PrintRow(IDS_VIRT_MEM_MAX, FALSE, L"%s", Buf);
564
565 /* Getting Virtual Memory: Available */
566 FormatBytes(Buf, MemoryStatus.dwAvailVirtual);
568
569 /* Getting Virtual Memory: In Use */
570 FormatBytes(Buf, MemoryStatus.dwTotalVirtual-MemoryStatus.dwAvailVirtual);
572
573 /* Getting Page File Location(s) */
575 L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management",
576 L"PagingFiles",
577 Buf,
578 _countof(Buf)))
579 {
580 UINT i;
581 for (i = 0; Buf[i]; i++)
582 {
583 if (Buf[i] == L' ')
584 {
585 Buf[i] = L'\0';
586 break;
587 }
588 }
589
590 PrintRow(IDS_PAGEFILE_LOC, FALSE, L"%s", Buf);
591 }
592
593 /* Getting Domain */
594 if (NetGetJoinInformation(NULL, &pBuffer, &NetJoinStatus) == NERR_Success)
595 {
596 if (NetJoinStatus == NetSetupWorkgroupName || NetJoinStatus == NetSetupDomainName)
598
600 }
601
602 /* Getting Logon Server */
603
604 /* Getting NetWork Card(s) */
605 cbAdapters = 4096;
606 pAdapters = malloc(cbAdapters);
607 while ((dwResult = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_SKIP_ANYCAST, NULL, pAdapters, &cbAdapters)) == ERROR_BUFFER_OVERFLOW)
608 {
609 cbAdapters += 4096;
610 pAdapters = (PIP_ADAPTER_ADDRESSES)realloc(pAdapters, cbAdapters);
611 }
612
613 if (dwResult == ERROR_SUCCESS)
614 {
615 PIP_ADAPTER_ADDRESSES pCurrentAdapter = pAdapters;
616 UINT cAdapters = 0;
617
618 /* Count adapters */
619 for (i = 0; pCurrentAdapter; ++i)
620 {
621 if (pCurrentAdapter->IfType != IF_TYPE_SOFTWARE_LOOPBACK && pCurrentAdapter->IfType != IF_TYPE_TUNNEL)
622 ++cAdapters;
623 pCurrentAdapter = pCurrentAdapter->Next;
624 }
625
626 /* Print adapters count */
628 Tmp[0] = L'\0';
629 swprintf(Buf, Tmp, cAdapters);
630 PrintRow(IDS_NETWORK_CARDS, FALSE, L"%s", Buf);
631
632 /* Show information about each adapter */
633 pCurrentAdapter = pAdapters;
634 for (i = 0; pCurrentAdapter; ++i)
635 {
636 if (pCurrentAdapter->IfType != IF_TYPE_SOFTWARE_LOOPBACK && pCurrentAdapter->IfType != IF_TYPE_TUNNEL)
637 {
638 PIP_ADAPTER_UNICAST_ADDRESS pAddress;
639
640 PrintRow(0, FALSE, L"[%02u]: %s", i + 1, pCurrentAdapter->Description);
641 PrintRow(IDS_CONNECTION_NAME, TRUE, L"%s", pCurrentAdapter->FriendlyName);
642 if (!(pCurrentAdapter->Flags & IP_ADAPTER_DHCP_ENABLED))
643 {
644 if (!LoadStringW(NULL, IDS_NO, Buf, _countof(Buf)))
645 Buf[0] = L'\0';
647 }
648 if (pCurrentAdapter->OperStatus == IfOperStatusDown)
649 {
651 Buf[0] = L'\0';
652 PrintRow(IDS_STATUS, TRUE, Buf);
653 }
654 else
655 {
656 if (!LoadStringW(NULL, IDS_IP_ADDRESSES, Buf, _countof(Buf)))
657 Buf[0] = L'\0';
658 PrintRow(0, TRUE, Buf);
659 pAddress = pCurrentAdapter->FirstUnicastAddress;
660 for (j = 0; pAddress; ++j)
661 {
662 dwCharCount = _countof(Buf);
663 WSAAddressToStringW(pAddress->Address.lpSockaddr, pAddress->Address.iSockaddrLength, NULL, Buf, &dwCharCount);
664 PrintRow(0, TRUE, L"[%02u]: %s", j + 1, Buf);
665 pAddress = pAddress->Next;
666 }
667 }
668 }
669 pCurrentAdapter = pCurrentAdapter->Next;
670 }
671 }
672 free(pAdapters);
673}
#define IDS_NO
Definition: resource.h:17
#define IDS_STATUS
Definition: resource.h:22
#define IDS_OS_VERSION
Definition: resource.h:155
OSVERSIONINFOW VersionInfo
Definition: wkssvc.c:40
#define RegCloseKey(hKey)
Definition: registry.h:49
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:446
void ConPrintf(FILE *fp, LPCWSTR psz,...)
#define StdErr
Definition: conutils_noros.h:7
#define realloc
Definition: debug_ros.c:6
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2504
#define wcschr
Definition: compat.h:17
#define MAX_PATH
Definition: compat.h:34
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2232
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2271
VOID WINAPI GetSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
Definition: sysinfo.c:143
BOOL WINAPI GetVersionExW(IN LPOSVERSIONINFOW lpVersionInformation)
Definition: version.c:37
INT WINAPI GetPrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR def_val, LPWSTR buffer, UINT len, LPCWSTR filename)
Definition: profile.c:1142
DWORD WINAPI GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
Definition: timezone.c:262
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: locale.c:1675
HRESULT WINAPI SHLoadIndirectString(const WCHAR *src, WCHAR *dst, UINT dst_len, void **reserved)
Definition: string.c:1455
__time32_t time_t
Definition: corecrt.h:228
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2983
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1972
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
#define swprintf
Definition: precomp.h:40
@ BIOS_VERSION
Definition: dmilib.h:14
@ SYS_PRODUCT
Definition: dmilib.h:17
@ ID_STRINGS_MAX
Definition: dmilib.h:28
@ BIOS_DATE
Definition: dmilib.h:15
@ SYS_VENDOR
Definition: dmilib.h:16
@ BIOS_VENDOR
Definition: dmilib.h:13
#define L(x)
Definition: resources.c:13
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
VOID NTAPI GlobalMemoryStatus(LPMEMORYSTATUS lpBuffer)
Definition: heapmem.c:1365
@ IfOperStatusDown
Definition: ifdef.h:186
#define IF_TYPE_TUNNEL
Definition: ipifcons.h:151
#define IF_TYPE_SOFTWARE_LOOPBACK
Definition: ipifcons.h:44
#define NERR_Success
Definition: lmerr.h:5
@ NetSetupDomainName
Definition: lmjoin.h:13
@ NetSetupWorkgroupName
Definition: lmjoin.h:12
enum _NETSETUP_JOIN_STATUS NETSETUP_JOIN_STATUS
#define ZeroMemory
Definition: minwinbase.h:31
#define IDS_PAGEFILE_LOC
Definition: resource.h:33
#define IDS_SYS_DIR
Definition: resource.h:24
#define IDS_UP_TIME
Definition: resource.h:14
#define IDS_VIRT_MEM_INUSE
Definition: resource.h:32
#define IDS_SYS_MANUFACTURER
Definition: resource.h:16
#define IDS_CONNECTION_NAME
Definition: resource.h:38
#define IDS_SYS_LOCALE
Definition: resource.h:26
#define IDS_SYS_TYPE
Definition: resource.h:18
#define IDS_PROCESSORS_FORMAT
Definition: resource.h:20
#define IDS_UP_TIME_FORMAT
Definition: resource.h:15
#define IDS_NETWORK_CARDS
Definition: resource.h:36
#define IDS_TOTAL_PHYS_MEM
Definition: resource.h:28
#define IDS_AVAIL_PHISICAL_MEM
Definition: resource.h:29
#define IDS_TIME_ZONE
Definition: resource.h:34
#define IDS_BIOS_VERSION
Definition: resource.h:22
#define IDS_SYS_MODEL
Definition: resource.h:17
#define IDS_MEDIA_DISCONNECTED
Definition: resource.h:40
#define IDS_OS_BUILD_TYPE
Definition: resource.h:9
#define IDS_HOST_NAME
Definition: resource.h:5
#define IDS_REG_OWNER
Definition: resource.h:10
#define IDS_INPUT_LOCALE
Definition: resource.h:27
#define IDS_VIRT_MEM_MAX
Definition: resource.h:30
#define IDS_OS_NAME
Definition: resource.h:6
#define IDS_ROS_DIR
Definition: resource.h:23
#define IDS_IP_ADDRESSES
Definition: resource.h:43
#define IDS_PRODUCT_ID
Definition: resource.h:12
#define IDS_REG_ORG
Definition: resource.h:11
#define IDS_BOOT_DEV
Definition: resource.h:25
#define IDS_DOMAIN
Definition: resource.h:35
#define IDS_VIRT_MEM_AVAIL
Definition: resource.h:31
#define IDS_BUILD
Definition: resource.h:8
#define IDS_DHCP_ENABLED
Definition: resource.h:41
#define IDS_INST_DATE
Definition: resource.h:13
#define IDS_PROCESSORS
Definition: resource.h:19
#define IDS_BIOS_DATE
Definition: resource.h:21
#define IDS_NETWORK_CARDS_FORMAT
Definition: resource.h:37
static VOID PrintRow(UINT nTitleID, BOOL bIndent, PCWSTR pFormat,...)
Definition: systeminfo.c:223
static VOID FormatDateTime(time_t Time, PWSTR pBuf)
Definition: systeminfo.c:152
static UINT RegGetSZ(HKEY hKey, PCWSTR pSubKey, PCWSTR pValueName, PWSTR pBuf, DWORD cchBuf)
Definition: systeminfo.c:32
static BOOL RegGetDWORD(HKEY hKey, PCWSTR pSubKey, PCWSTR pValueName, PDWORD pData)
Definition: systeminfo.c:87
#define BUFFER_SIZE
Definition: systeminfo.c:27
static VOID FormatBytes(PWSTR pBuf, UINT cBytes)
Definition: systeminfo.c:128
ULONGLONG GetSeconds(VOID)
Definition: systeminfo.c:189
unsigned int UINT
Definition: ndis.h:50
#define PROCESSOR_ARCHITECTURE_IA64
Definition: ketypes.h:111
#define PROCESSOR_ARCHITECTURE_AMD64
Definition: ketypes.h:114
#define PROCESSOR_ARCHITECTURE_INTEL
Definition: ketypes.h:105
#define KEY_READ
Definition: nt_native.h:1026
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1022
#define LOCALE_SYSTEM_DEFAULT
PVOID pBuffer
INT WSAAPI WSAAddressToStringW(IN LPSOCKADDR lpsaAddress, IN DWORD dwAddressLength, IN LPWSAPROTOCOL_INFOW lpProtocolInfo, OUT LPWSTR lpszAddressString, IN OUT LPDWORD lpdwAddressStringLength)
Definition: rnr.c:128
#define LoadStringW
Definition: utils.h:64
#define _countof(array)
Definition: sndvol32.h:70
SIZE_T dwTotalPhys
Definition: winbase.h:943
SIZE_T dwAvailVirtual
Definition: winbase.h:948
SIZE_T dwAvailPhys
Definition: winbase.h:944
SIZE_T dwTotalVirtual
Definition: winbase.h:947
ULONG dwMinorVersion
Definition: rtltypes.h:248
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:246
ULONG dwMajorVersion
Definition: rtltypes.h:247
ULONG dwBuildNumber
Definition: rtltypes.h:249
WCHAR szCSDVersion[128]
Definition: rtltypes.h:251
DWORD dwNumberOfProcessors
Definition: winbase.h:902
WORD wProcessorArchitecture
Definition: winbase.h:894
WCHAR StandardName[32]
Definition: winbase.h:932
uint16_t * PWSTR
Definition: typedefs.h:56
const uint16_t * PCWSTR
Definition: typedefs.h:57
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
SIZE_T GetSMBiosStringW(_In_ PCSTR DmiString, _Out_ PWSTR pBuf, _In_ DWORD cchBuf, _In_ BOOL bTrim)
Definition: udmihelp.c:145
PVOID LoadSMBiosData(_Inout_updates_(ID_STRINGS_MAX) PCHAR *Strings)
Definition: udmihelp.c:30
VOID FreeSMBiosData(_In_ PVOID Buffer)
Definition: udmihelp.c:177
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:307
#define LOCALE_ILANGUAGE
Definition: winnls.h:30
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define AF_UNSPEC
Definition: winsock.h:338
NET_API_STATUS WINAPI NetGetJoinInformation(_In_ LPCWSTR lpServer, _Out_ LPWSTR *lpNameBuffer, _Out_ PNETSETUP_JOIN_STATUS BufferType)
Definition: wksta_new.c:317
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by wmain().

◆ FormatBytes()

static VOID FormatBytes ( PWSTR  pBuf,
UINT  cBytes 
)
static

Definition at line 128 of file systeminfo.c.

129{
130 WCHAR szMB[32];
132 UINT i;
133
134 _itow(cBytes / (1024*1024), szMB, 10);
135
136 fmt.NumDigits = 0;
137 fmt.LeadingZero = 0;
138 fmt.Grouping = 3;
139 fmt.lpDecimalSep = L"";
140 fmt.lpThousandSep = L" ";
141 fmt.NegativeOrder = 0;
142
143 i = GetNumberFormatW(LOCALE_SYSTEM_DEFAULT, 0, szMB, &fmt, pBuf, BUFFER_SIZE - 3);
144 if (i)
145 --i; /* don't count NULL character */
146 wcscpy(pBuf + i, L" MB");
147}
_ACRTIMP wchar_t *__cdecl _itow(int, wchar_t *, int)
Definition: string.c:2135
INT WINAPI GetNumberFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const NUMBERFMTW *lpFormat, LPWSTR lpNumberStr, int cchOut)
Definition: lcformat.c:1130
wcscpy
Definition: dsound.c:943

Referenced by AllSysInfo().

◆ FormatDateTime()

static VOID FormatDateTime ( time_t  Time,
PWSTR  pBuf 
)
static

Definition at line 152 of file systeminfo.c.

153{
154 UINT i;
155 SYSTEMTIME SysTime;
156 const struct tm *pTm;
157
158 pTm = localtime(&Time);
159 SysTime.wYear = (WORD)(1900 + pTm->tm_year);
160 SysTime.wMonth = (WORD)(1 + pTm->tm_mon);
161 SysTime.wDayOfWeek = (WORD)pTm->tm_wday;
162 SysTime.wDay = (WORD)pTm->tm_mday;
163 SysTime.wHour = (WORD)pTm->tm_hour;
164 SysTime.wMinute = (WORD)pTm->tm_min;
165 SysTime.wSecond = (WORD)pTm->tm_sec;
166 SysTime.wMilliseconds = 0;
167
168 /* Copy date first */
169 i = GetDateFormatW(LOCALE_SYSTEM_DEFAULT, 0, &SysTime, NULL, pBuf, BUFFER_SIZE - 2);
170 if (i)
171 --i; /* don't count NULL character */
172
173 /* Copy time now */
174 i += swprintf(pBuf + i, L", ");
175
176 GetTimeFormatW(LOCALE_SYSTEM_DEFAULT, 0, &SysTime, NULL, pBuf + i, BUFFER_SIZE - i);
177}
static struct tm * localtime(const time_t *t)
Definition: time.h:121
unsigned short WORD
Definition: ntddk_ex.h:93
INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1101
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:1001
static PLARGE_INTEGER Time
Definition: time.c:105
WORD wMilliseconds
Definition: minwinbase.h:263
WORD wSecond
Definition: minwinbase.h:262
WORD wMinute
Definition: minwinbase.h:261
WORD wDayOfWeek
Definition: minwinbase.h:258
int tm_mon
Definition: corecrt_wtime.h:16
int tm_year
Definition: corecrt_wtime.h:17
int tm_hour
Definition: corecrt_wtime.h:14
int tm_sec
Definition: corecrt_wtime.h:12
int tm_mday
Definition: corecrt_wtime.h:15
int tm_min
Definition: corecrt_wtime.h:13
int tm_wday
Definition: corecrt_wtime.h:18

Referenced by AllSysInfo().

◆ GetSeconds()

ULONGLONG GetSeconds ( VOID  )

Definition at line 189 of file systeminfo.c.

190{
192 ULONGLONG Ticks64;
193 HMODULE hModule = GetModuleHandleW(L"kernel32.dll");
194
195 pGetTickCount64 = (PVOID)GetProcAddress(hModule, "GetTickCount64");
196 if (pGetTickCount64)
197 return pGetTickCount64() / 1000;
198
199 hModule = LoadLibraryW(L"kernel32_vista.dll");
200 if (!hModule)
201 return GetSecondsQPC();
202
203 pGetTickCount64 = (PVOID)GetProcAddress(hModule, "GetTickCount64");
204 if (pGetTickCount64)
205 Ticks64 = pGetTickCount64() / 1000;
206 else
207 Ticks64 = GetSecondsQPC();
208
210 return Ticks64;
211}
#define VOID
Definition: acefi.h:82
static PFGETTICKCOUNT64 pGetTickCount64
Definition: general.c:36
HMODULE hModule
Definition: animate.c:44
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define LoadLibraryW(x)
Definition: compat.h:747
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
ULONGLONG GetSecondsQPC(VOID)
Definition: systeminfo.c:179
void * PVOID
Definition: typedefs.h:50
uint64_t ULONGLONG
Definition: typedefs.h:67
#define WINAPI
Definition: msvc.h:6

Referenced by AllSysInfo().

◆ GetSecondsQPC()

ULONGLONG GetSecondsQPC ( VOID  )

Definition at line 179 of file systeminfo.c.

180{
182
185
187}
BOOL WINAPI QueryPerformanceFrequency(OUT PLARGE_INTEGER lpFrequency)
Definition: perfcnt.c:45
BOOL WINAPI QueryPerformanceCounter(OUT PLARGE_INTEGER lpPerformanceCount)
Definition: perfcnt.c:23
static LARGE_INTEGER Frequency
Definition: clock.c:41
static LARGE_INTEGER Counter
Definition: clock.c:43
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by GetSeconds().

◆ PrintRow()

static VOID PrintRow ( UINT  nTitleID,
BOOL  bIndent,
PCWSTR  pFormat,
  ... 
)
static

Definition at line 223 of file systeminfo.c.

224{
226 UINT c;
227 WCHAR Buf[BUFFER_SIZE];
228
229 if (nTitleID)
230 {
231 c = LoadStringW(NULL, nTitleID, Buf, _countof(Buf) - 2);
232 if (!c)
233 return;
234 wcscpy(Buf + c, L": ");
235 }
236 else
237 {
238 Buf[0] = L'\0';
239 }
240
241 if (!bIndent)
242 ConPrintf(StdOut, L"%-32s", Buf);
243 else if (Buf[0])
244 ConPrintf(StdOut, L"%38s%-16s", L"", Buf);
245 else
246 ConPrintf(StdOut, L"%38s", L"");
247
248 va_start(Args, pFormat);
249 ConPrintfV(StdOut, pFormat, Args);
250 va_end(Args);
251
252 ConPuts(StdOut, L"\n");
253}
char ** Args
Definition: acdebug.h:353
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: conutils_noros.h:8
#define StdOut
Definition: conutils_noros.h:6
#define va_end(v)
Definition: stdarg.h:28
#define va_start(v, l)
Definition: stdarg.h:26
char * va_list
Definition: vadefs.h:50
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80
INT ConPrintfV(IN PCON_STREAM Stream, IN PCWSTR szStr, IN va_list args)
Definition: outstream.c:465

Referenced by AllSysInfo().

◆ RegGetDWORD()

static BOOL RegGetDWORD ( HKEY  hKey,
PCWSTR  pSubKey,
PCWSTR  pValueName,
PDWORD  pData 
)
static

Definition at line 87 of file systeminfo.c.

88{
89 DWORD dwBytes = sizeof(*pData), dwType;
90 BOOL bRet = TRUE;
91
92 /* If SubKey is specified open it */
93 if (pSubKey && RegOpenKeyExW(hKey,
94 pSubKey,
95 0,
98 {
99 ConPrintf(StdErr, L"Warning! Cannot open %s. Last error: %lu.\n",
100 pSubKey, GetLastError());
101 return FALSE;
102 }
103
104 /* Query registry value and check its type */
106 pValueName,
107 NULL,
108 &dwType,
109 (PBYTE)pData,
110 &dwBytes) != ERROR_SUCCESS || dwType != REG_DWORD)
111 {
112 ConPrintf(StdErr, L"Warning! Cannot query %s. Last err: %lu, type: %lu\n",
113 pValueName, GetLastError(), dwType);
114 *pData = 0;
115 bRet = FALSE;
116 }
117
118 /* Close key if we opened it */
119 if (pSubKey)
121
122 return bRet;
123}
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
unsigned int BOOL
Definition: ntddk_ex.h:94
BYTE * PBYTE
Definition: pedump.c:66
#define REG_DWORD
Definition: sdbapi.c:615
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by AllSysInfo().

◆ RegGetSZ()

static UINT RegGetSZ ( HKEY  hKey,
PCWSTR  pSubKey,
PCWSTR  pValueName,
PWSTR  pBuf,
DWORD  cchBuf 
)
static

Definition at line 32 of file systeminfo.c.

33{
34 DWORD dwBytes = cchBuf * sizeof(WCHAR), dwType = 0;
36
37 /* If SubKey is specified open it */
38 if (pSubKey && RegOpenKeyExW(hKey,
39 pSubKey,
40 0,
43 {
44 ConPrintf(StdErr, L"Warning! Cannot open %s. Last error: %lu.\n",
45 pSubKey, GetLastError());
46 return 0;
47 }
48
49 /* Query registry value and check its type */
51 pValueName,
52 NULL,
53 &dwType,
54 (PBYTE)pBuf,
55 &dwBytes) != ERROR_SUCCESS ||
56 (dwType != REG_SZ && dwType != REG_MULTI_SZ))
57 {
58 ConPrintf(StdErr, L"Warning! Cannot query %s. Last error: %lu, type: %lu.\n",
59 pValueName, GetLastError(), dwType);
60 dwBytes = 0;
61 }
62 else if (dwBytes == 0)
63 {
64 wcscpy(pBuf, L"N/A");
65 dwBytes = sizeof(L"N/A")-sizeof(WCHAR);
66 }
67
68 /* Close key if we opened it */
69 if (pSubKey)
71
72 cChars = dwBytes/sizeof(WCHAR);
73
74 /* NULL-terminate string */
75 pBuf[min(cchBuf-1, cChars)] = L'\0';
76
77 /* Don't count NULL characters */
78 while (cChars && !pBuf[cChars-1])
79 --cChars;
80
81 return cChars;
82}
#define REG_SZ
Definition: layer.c:22
static SCRIPT_CACHE SCRIPT_ANALYSIS OPENTYPE_TAG OPENTYPE_TAG int TEXTRANGE_PROPERTIES int const WCHAR int cChars
Definition: usp10.c:64
#define min(a, b)
Definition: monoChain.cc:55
#define REG_MULTI_SZ
Definition: nt_native.h:1504
_In_ UINT cchBuf
Definition: shlwapi.h:378

Referenced by AllSysInfo().

◆ Usage()

static VOID Usage ( VOID  )
static

Definition at line 216 of file systeminfo.c.

217{
219}
#define IDS_USAGE
Definition: resource.h:3
void ConResPrintf(FILE *fp, UINT nID,...)

◆ wmain()

int wmain ( int  argc,
wchar_t argv[] 
)

Definition at line 676 of file systeminfo.c.

677{
678 WSADATA WsaData;
679 int i;
680
681 /* Initialize the Console Standard Streams */
683
684 WSAStartup(MAKEWORD(2, 2), &WsaData);
685
686 for (i = 1; i < argc; ++i)
687 {
688 if (!wcscmp(argv[i], L"/?") || !wcscmp(argv[i], L"-?"))
689 {
690 Usage();
691 return 0;
692 }
693 else
694 {
695 ConPrintf(StdErr, L"Unsupported argument: %s\n", argv[i]);
696 return -1;
697 }
698 }
699
700 AllSysInfo();
701
702 return 0;
703}
#define ConInitStdStreams()
Definition: conutils_noros.h:5
MonoAssembly int argc
Definition: metahost.c:107
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE Usage
Definition: hidpi.h:384
VOID AllSysInfo(VOID)
Definition: systeminfo.c:257
#define argv
Definition: mplay32.c:18
#define MAKEWORD(a, b)
Definition: typedefs.h:248