ReactOS  0.4.11-dev-765-g5e024bf
systeminfo.c
Go to the documentation of this file.
1 /*
2  This program is free software; you can redistribute it and/or modify
3  it under the terms of the GNU General Public License as published by
4  the Free Software Foundation; either version 2 of the License, or
5  (at your option) any later version.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software
14  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15 */
16 /* Copyright (C) 2007, Dmitry Chapyshev <lentind@yandex.ru> */
17 /* Copyright (C) 2011, Rafal Harabien <rafalh1992@o2.pl> */
18 
19 #include <wchar.h>
20 #include <stdio.h>
21 #include <string.h>
22 #include <stdarg.h>
23 #include <windows.h>
24 #include <time.h>
25 #include <locale.h>
26 #include <lm.h>
27 #include <shlwapi.h>
28 #include <iphlpapi.h>
29 #include <winsock2.h>
30 #include <udmihelp.h>
31 #include <dmilib.h>
32 
33 #include "resource.h"
34 
35 #define BUFFER_SIZE 1024
36 
37 /* Load string from registry */
38 static
39 unsigned
40 RegGetSZ(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpValueName, LPWSTR lpBuf, DWORD cchBuf)
41 {
42  DWORD dwBytes = cchBuf*sizeof(WCHAR), dwType = 0;
43  unsigned cChars;
44 
45  /* If SubKey is specified open it */
46  if (lpSubKey && RegOpenKeyExW(hKey,
47  lpSubKey,
48  0,
50  &hKey) != ERROR_SUCCESS)
51  {
52  wprintf(L"Warning! Cannot open %s. Last error: %lu.\n", lpSubKey, GetLastError());
53  return 0;
54  }
55 
56  /* Query registry value and check its type */
57  if (RegQueryValueExW(hKey,
58  lpValueName,
59  NULL,
60  &dwType,
61  (LPBYTE)lpBuf,
62  &dwBytes) != ERROR_SUCCESS || (dwType != REG_SZ && dwType != REG_MULTI_SZ))
63  {
64  wprintf(L"Warning! Cannot query %s. Last error: %lu, type: %lu.\n", lpValueName, GetLastError(), dwType);
65  dwBytes = 0;
66  }
67  else if (dwBytes == 0)
68  {
69  wcscpy(lpBuf, L"N/A");
70  dwBytes = 6;
71  }
72 
73  /* Close key if we opened it */
74  if (lpSubKey)
75  RegCloseKey(hKey);
76 
77  cChars = dwBytes/sizeof(WCHAR);
78 
79  /* NULL-terminate string */
80  lpBuf[min(cchBuf-1, cChars)] = L'\0';
81 
82  /* Don't count NULL characters */
83  while(cChars && !lpBuf[cChars-1])
84  --cChars;
85 
86  return cChars;
87 }
88 
89 /* Load DWORD from registry */
90 static
91 BOOL
92 RegGetDWORD(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpValueName, LPDWORD lpData)
93 {
94  DWORD dwBytes = sizeof(*lpData), dwType;
95  BOOL bRet = TRUE;
96 
97  /* If SubKey is specified open it */
98  if (lpSubKey && RegOpenKeyExW(hKey,
99  lpSubKey,
100  0,
102  &hKey) != ERROR_SUCCESS)
103  {
104  wprintf(L"Warning! Cannot open %s. Last error: %lu.\n", lpSubKey, GetLastError());
105  return FALSE;
106  }
107 
108  /* Query registry value and check its type */
109  if (RegQueryValueExW(hKey,
110  lpValueName,
111  NULL,
112  &dwType,
113  (LPBYTE)lpData,
114  &dwBytes) != ERROR_SUCCESS || dwType != REG_DWORD)
115  {
116  wprintf(L"Warning! Cannot query %s. Last err: %lu, type: %lu\n", lpValueName, GetLastError(), dwType);
117  *lpData = 0;
118  bRet = FALSE;
119  }
120 
121  /* Close key if we opened it */
122  if (lpSubKey)
123  RegCloseKey(hKey);
124 
125  return bRet;
126 }
127 
128 /* Format bytes */
129 static
130 VOID
131 FormatBytes(LPWSTR lpBuf, unsigned cBytes)
132 {
133  WCHAR szMB[32];
134  NUMBERFMTW fmt;
135  unsigned i;
136 
137  _itow(cBytes / (1024*1024), szMB, 10);
138 
139  fmt.NumDigits = 0;
140  fmt.LeadingZero = 0;
141  fmt.Grouping = 3;
142  fmt.lpDecimalSep = L"";
143  fmt.lpThousandSep = L" ";
144  fmt.NegativeOrder = 0;
145 
146  i = GetNumberFormatW(LOCALE_SYSTEM_DEFAULT, 0, szMB, &fmt, lpBuf, BUFFER_SIZE - 3);
147  if (i)
148  --i; /* don't count NULL character */
149  wcscpy(lpBuf + i, L" MB");
150 }
151 
152 /* Format date and time */
153 static
154 VOID
156 {
157  unsigned i;
158  SYSTEMTIME SysTime;
159  const struct tm *lpTm;
160 
161  lpTm = localtime(&Time);
162  SysTime.wYear = (WORD)(1900 + lpTm->tm_year);
163  SysTime.wMonth = (WORD)(1 + lpTm->tm_mon);
164  SysTime.wDayOfWeek = (WORD)lpTm->tm_wday;
165  SysTime.wDay = (WORD)lpTm->tm_mday;
166  SysTime.wHour = (WORD)lpTm->tm_hour;
167  SysTime.wMinute = (WORD)lpTm->tm_min;
168  SysTime.wSecond = (WORD)lpTm->tm_sec;
169  SysTime.wMilliseconds = 0;
170 
171  /* Copy date first */
172  i = GetDateFormatW(LOCALE_SYSTEM_DEFAULT, 0, &SysTime, NULL, lpBuf, BUFFER_SIZE - 2);
173  if (i)
174  --i; /* don't count NULL character */
175 
176  /* Copy time now */
177  i += swprintf(lpBuf + i, L", ");
178 
179  GetTimeFormatW(LOCALE_SYSTEM_DEFAULT, 0, &SysTime, NULL, lpBuf + i, BUFFER_SIZE - i);
180 }
181 
183 {
185 
186  QueryPerformanceCounter(&Counter);
187  QueryPerformanceFrequency(&Frequency);
188 
189  return Counter.QuadPart / Frequency.QuadPart;
190 }
191 
193 {
194  ULONGLONG (WINAPI * pGetTickCount64)(VOID);
195  ULONGLONG Ticks64;
196  HMODULE hModule = GetModuleHandleW(L"kernel32.dll");
197 
198  pGetTickCount64 = (PVOID)GetProcAddress(hModule, "GetTickCount64");
199  if (pGetTickCount64)
200  {
201  return pGetTickCount64() / 1000;
202  }
203 
204  hModule = LoadLibraryW(L"kernel32_vista.dll");
205 
206  if (!hModule)
207  {
208  return GetSecondsQPC();
209  }
210 
211  pGetTickCount64 = (PVOID)GetProcAddress(hModule, "GetTickCount64");
212 
213  if (pGetTickCount64)
214  {
215  Ticks64 = pGetTickCount64() / 1000;
216  }
217  else
218  {
219  Ticks64 = GetSecondsQPC();
220  }
221 
222  FreeLibrary(hModule);
223  return Ticks64;
224 }
225 
226 /* Show usage */
227 static
228 VOID
230 {
231  WCHAR Buf[4096];
232  if (LoadStringW(GetModuleHandle(NULL), IDS_USAGE, Buf, 4096))
233  wprintf(L"%s", Buf);
234 }
235 
236 static
237 VOID
238 PrintRow(UINT nTitleID, BOOL bIndent, LPWSTR lpFormat, ...)
239 {
240  WCHAR Buf[BUFFER_SIZE];
241  va_list Args;
242  unsigned c;
243 
244  if (nTitleID)
245  {
246  c = LoadStringW(GetModuleHandle(NULL), nTitleID, Buf, BUFFER_SIZE - 2);
247  if (!c)
248  return;
249 
250  wcscpy(Buf + c, L": ");
251  } else
252  Buf[0] = L'\0';
253 
254  if (!bIndent)
255  wprintf(L"%-32s", Buf);
256  else if (Buf[0])
257  wprintf(L"%38s%-16s", L"", Buf);
258  else
259  wprintf(L"%38s", L"");
260 
261  va_start(Args, lpFormat);
262  vwprintf(lpFormat, Args);
263  va_end(Args);
264 
265  wprintf(L"\n");
266 }
267 
268 /* Print all system information */
269 VOID
271 {
272  DWORD dwCharCount = BUFFER_SIZE, dwTimestamp, dwResult;
273  OSVERSIONINFOW VersionInfo;
274  SYSTEM_INFO SysInfo;
275  WCHAR Buf[BUFFER_SIZE], Tmp[BUFFER_SIZE], szSystemDir[MAX_PATH];
276  const WCHAR *lpcszSysType;
278  NETSETUP_JOIN_STATUS NetJoinStatus;
279  MEMORYSTATUS MemoryStatus;
280  unsigned int cSeconds, i, j;
281  TIME_ZONE_INFORMATION TimeZoneInfo;
282  HKEY hKey;
283  PIP_ADAPTER_ADDRESSES pAdapters;
284  ULONG cbAdapters;
285  PVOID SMBiosBuf;
286  PCHAR DmiStrings[ID_STRINGS_MAX] = { 0 };
287 
288  if (!GetSystemDirectoryW(szSystemDir, sizeof(szSystemDir)/sizeof(szSystemDir[0])))
289  {
290  wprintf(L"Error! GetSystemDirectory failed.\n");
291  return;
292  }
293 
294  GetSystemInfo(&SysInfo);
295 
296  // getting computer name
297  dwCharCount = BUFFER_SIZE;
298  if (!GetComputerNameW(Buf, &dwCharCount))
299  wprintf(L"Error! GetComputerName failed.\n");
300  else
301  PrintRow(IDS_HOST_NAME, FALSE, L"%s", Buf);
302 
303  // open CurrentVersion key
305  L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
306  0,
308  &hKey) != ERROR_SUCCESS)
309  {
310  wprintf(L"Error! RegOpenKeyEx failed.\n");
311  return;
312  }
313 
314  //getting OS Name
315  RegGetSZ(hKey, NULL, L"ProductName", Buf, BUFFER_SIZE);
316  PrintRow(IDS_OS_NAME, FALSE, L"%s", Buf);
317 
318  //getting OS Version
319  ZeroMemory(&VersionInfo, sizeof(VersionInfo));
320  VersionInfo.dwOSVersionInfoSize = sizeof(VersionInfo);
321  GetVersionExW(&VersionInfo);
322 
324  Tmp[0] = L'\0';
326  FALSE,
327  L"%lu.%lu.%lu %s %s %lu",
328  VersionInfo.dwMajorVersion,
329  VersionInfo.dwMinorVersion,
330  VersionInfo.dwBuildNumber,
331  VersionInfo.szCSDVersion,
332  Tmp,
333  VersionInfo.dwBuildNumber);
334 
335  //getting OS Manufacturer
336 
337  //getting OS Configuration
338 
339  //getting OS Build Type
340  RegGetSZ(hKey, NULL, L"CurrentType", Buf, BUFFER_SIZE);
341  PrintRow(IDS_OS_BUILD_TYPE, FALSE, L"%s", Buf);
342 
343  //getting Registered Owner
344  RegGetSZ(hKey, NULL, L"RegisteredOwner", Buf, BUFFER_SIZE);
345  PrintRow(IDS_REG_OWNER, FALSE, L"%s", Buf);
346 
347  //getting Registered Organization
348  RegGetSZ(hKey, NULL, L"RegisteredOrganization", Buf, BUFFER_SIZE);
349  PrintRow(IDS_REG_ORG, FALSE, L"%s", Buf);
350 
351  //getting Product ID
352  RegGetSZ(hKey, NULL, L"ProductId", Buf, BUFFER_SIZE);
353  PrintRow(IDS_PRODUCT_ID, FALSE, L"%s", Buf);
354 
355  //getting Install Date
356  RegGetDWORD(hKey, NULL, L"InstallDate", &dwTimestamp);
357  FormatDateTime((time_t)dwTimestamp, Buf);
358  PrintRow(IDS_INST_DATE, FALSE, L"%s", Buf);
359 
360  // close Current Version key now
361  RegCloseKey(hKey);
362 
363  //getting System Up Time
364  cSeconds = GetSeconds();
366  Tmp[0] = L'\0';
367  swprintf(Buf, Tmp, cSeconds / (60*60*24), (cSeconds / (60*60)) % 24, (cSeconds / 60) % 60, cSeconds % 60);
368  PrintRow(IDS_UP_TIME, FALSE, L"%s", Buf);
369 
370  // prepare SMBIOS data
371  SMBiosBuf = LoadSMBiosData(DmiStrings);
372 
373  //getting System Manufacturer; HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation\Manufacturer for Win >= 6.0
374  swprintf(Tmp, L"%s\\oeminfo.ini", szSystemDir);
375  GetPrivateProfileStringW(L"General",
376  L"Manufacturer",
377  L"",
378  Buf,
379  sizeof(Buf)/sizeof(Buf[0]),
380  Tmp);
381  if (wcslen(Buf) == 0 && SMBiosBuf)
382  {
383  GetSMBiosStringW(DmiStrings[SYS_VENDOR], Buf, _countof(Buf), FALSE);
384  }
385  PrintRow(IDS_SYS_MANUFACTURER, FALSE, L"%s", Buf);
386 
387  //getting System Model; HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation\Model for Win >= 6.0
388  GetPrivateProfileStringW(L"General",
389  L"Model",
390  L"",
391  Buf,
392  sizeof(Buf)/sizeof(Buf[0]),
393  Tmp);
394  if (wcslen(Buf) == 0 && SMBiosBuf)
395  {
396  GetSMBiosStringW(DmiStrings[SYS_PRODUCT], Buf, _countof(Buf), FALSE);
397  }
398  PrintRow(IDS_SYS_MODEL, FALSE, L"%s", Buf);
399 
400  //getting System type
401  switch (SysInfo.wProcessorArchitecture)
402  {
404  lpcszSysType = L"X86-based PC";
405  break;
407  lpcszSysType = L"IA64-based PC";
408  break;
410  lpcszSysType = L"AMD64-based PC";
411  break;
412  default:
413  lpcszSysType = L"Unknown";
414  break;
415  }
416  PrintRow(IDS_SYS_TYPE, FALSE, L"%s", lpcszSysType);
417 
418  //getting Processor(s)
420  Tmp[0] = L'\0';
421  swprintf(Buf, Tmp, (unsigned)SysInfo.dwNumberOfProcessors);
422  PrintRow(IDS_PROCESSORS, FALSE, L"%s", Buf);
423  for(i = 0; i < (unsigned int)SysInfo.dwNumberOfProcessors; i++)
424  {
425  swprintf(Tmp, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%u", i);
426  j = swprintf(Buf, L"[%02u]: ", i + 1);
427 
428  j += RegGetSZ(HKEY_LOCAL_MACHINE, Tmp, L"Identifier", Buf + j, BUFFER_SIZE - j);
429  if(j + 1 < BUFFER_SIZE)
430  Buf[j++] = L' ';
431  RegGetSZ(HKEY_LOCAL_MACHINE, Tmp, L"VendorIdentifier", Buf + j, BUFFER_SIZE - j);
432 
433  PrintRow(0, FALSE, L"%s", Buf);
434  }
435 
436  //getting BIOS Version
437  if (SMBiosBuf)
438  {
439  j = GetSMBiosStringW(DmiStrings[BIOS_VENDOR], Buf, BUFFER_SIZE, TRUE);
440  if (j + 1 < BUFFER_SIZE)
441  {
442  Buf[j++] = L' ';
443  Buf[j] = L'\0';
444  }
445  GetSMBiosStringW(DmiStrings[BIOS_VERSION], Buf + j, BUFFER_SIZE - j, TRUE);
446  }
447  else
448  {
450  L"HARDWARE\\DESCRIPTION\\System",
451  L"SystemBiosVersion",
452  Buf,
453  BUFFER_SIZE);
454  }
455  PrintRow(IDS_BIOS_VERSION, FALSE, L"%s", Buf);
456 
457  //gettings BIOS date
458  if (SMBiosBuf)
459  {
460  GetSMBiosStringW(DmiStrings[BIOS_DATE], Buf, BUFFER_SIZE, TRUE);
461  }
462  else
463  {
465  L"HARDWARE\\DESCRIPTION\\System",
466  L"SystemBiosDate",
467  Buf,
468  BUFFER_SIZE);
469  }
470  PrintRow(IDS_BIOS_DATE, FALSE, L"%s", Buf);
471 
472  // clean SMBIOS data
473  FreeSMBiosData(SMBiosBuf);
474 
475  //getting ReactOS Directory
477  wprintf(L"Error! GetWindowsDirectory failed.");
478  else
479  PrintRow(IDS_ROS_DIR, FALSE, L"%s", Buf);
480 
481  //getting System Directory
482  PrintRow(IDS_SYS_DIR, 0, L"%s", szSystemDir);
483 
484  //getting Boot Device
486  L"SYSTEM\\Setup",
487  L"SystemPartition",
488  Buf,
489  BUFFER_SIZE);
490  PrintRow(IDS_BOOT_DEV, FALSE, L"%s", Buf);
491 
492  //getting System Locale
495  L"MIME\\Database\\Rfc1766",
496  Tmp,
497  Buf,
498  BUFFER_SIZE))
499  {
500  /* get rid of @filename,resource */
501  lpBuffer = wcschr(Buf, L';');
502  if (lpBuffer)
503  SHLoadIndirectString(lpBuffer+1, lpBuffer+1, BUFFER_SIZE - (lpBuffer-Buf) - 1, NULL);
504 
505  PrintRow(IDS_SYS_LOCALE, FALSE, L"%s", Buf);
506  }
507 
508  //getting Input Locale
510  L"Keyboard Layout\\Preload",
511  L"1",
512  Tmp,
513  BUFFER_SIZE) && wcslen(Tmp) > 4)
515  L"MIME\\Database\\Rfc1766",
516  Tmp + 4,
517  Buf,
518  BUFFER_SIZE))
519  {
520  /* get rid of @filename,resource */
521  lpBuffer = wcschr(Buf, L';');
522  if (lpBuffer)
523  SHLoadIndirectString(lpBuffer+1, lpBuffer+1, BUFFER_SIZE - (lpBuffer-Buf) - 1, NULL);
524 
525  PrintRow(IDS_INPUT_LOCALE, FALSE, L"%s", Buf);
526  }
527 
528  //getting Time Zone
529  GetTimeZoneInformation(&TimeZoneInfo);
530 
531  /* Open Time Zones key */
533  L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones",
534  0,
536  &hKey) == ERROR_SUCCESS)
537  {
538  unsigned i;
539 
540  /* Find current timezone */
541  dwCharCount = BUFFER_SIZE;
542  for(i = 0; RegEnumKeyExW(hKey, i, Tmp, &dwCharCount, NULL, NULL, NULL, NULL) == ERROR_SUCCESS; ++i, dwCharCount = 255)
543  {
544  RegGetSZ(hKey, Tmp, L"Std", Buf, BUFFER_SIZE);
545 
546  if (!wcscmp(Buf, TimeZoneInfo.StandardName))
547  {
548  RegGetSZ(hKey, Tmp, L"Display", Buf, BUFFER_SIZE);
549 
550  PrintRow(IDS_TIME_ZONE, FALSE, L"%s", Buf);
551 
552  break;
553  }
554  }
555  RegCloseKey(hKey);
556  }
557 
558  //getting Total Physical Memory
559  GlobalMemoryStatus(&MemoryStatus);
560  FormatBytes(Buf, MemoryStatus.dwTotalPhys);
561  PrintRow(IDS_TOTAL_PHYS_MEM, FALSE, L"%s", Buf);
562 
563  //getting Available Physical Memory
564  FormatBytes(Buf, MemoryStatus.dwAvailPhys);
566 
567  //getting Virtual Memory: Max Size
568  FormatBytes(Buf, MemoryStatus.dwTotalVirtual);
569  PrintRow(IDS_VIRT_MEM_MAX, FALSE, L"%s", Buf);
570 
571  //getting Virtual Memory: Available
572  FormatBytes(Buf, MemoryStatus.dwAvailVirtual);
573  PrintRow(IDS_VIRT_MEM_AVAIL, FALSE, L"%s", Buf);
574 
575  //getting Virtual Memory: In Use
576  FormatBytes(Buf, MemoryStatus.dwTotalVirtual-MemoryStatus.dwAvailVirtual);
577  PrintRow(IDS_VIRT_MEM_INUSE, FALSE, L"%s", Buf);
578 
579  //getting Page File Location(s)
581  L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management",
582  L"PagingFiles",
583  Buf,
584  BUFFER_SIZE))
585  {
586  int i;
587 
588  for(i = 0; Buf[i]; i++)
589  {
590  if (Buf[i] == L' ')
591  {
592  Buf[i] = L'\0';
593  break;
594  }
595  }
596 
597  PrintRow(IDS_PAGEFILE_LOC, FALSE, L"%s", Buf);
598  }
599 
600  //getting Domain
601  if (NetGetJoinInformation (NULL, &lpBuffer, &NetJoinStatus) == NERR_Success)
602  {
603  if (NetJoinStatus == NetSetupWorkgroupName || NetJoinStatus == NetSetupDomainName)
604  PrintRow(IDS_DOMAIN, FALSE, L"%s", lpBuffer);
605 
606  NetApiBufferFree(lpBuffer);
607  }
608 
609  //getting Logon Server
610 
611  //getting NetWork Card(s)
612  cbAdapters = 4096;
613  pAdapters = malloc(cbAdapters);
614  while((dwResult = GetAdaptersAddresses(AF_UNSPEC, 0x0002, NULL, pAdapters, &cbAdapters)) == ERROR_BUFFER_OVERFLOW)
615  {
616  cbAdapters += 4096;
617  pAdapters = (PIP_ADAPTER_ADDRESSES)realloc(pAdapters, cbAdapters);
618  }
619 
620  if (dwResult == ERROR_SUCCESS)
621  {
622  PIP_ADAPTER_ADDRESSES pCurrentAdapter = pAdapters;
623  unsigned cAdapters = 0;
624 
625  /* Count adapters */
626  for(i = 0; pCurrentAdapter; ++i)
627  {
628  if (pCurrentAdapter->IfType != 24 && pCurrentAdapter->IfType != 131)
629  ++cAdapters;
630  pCurrentAdapter = pCurrentAdapter->Next;
631  }
632 
633 
634  /* Print adapters count */
636  Tmp[0] = L'\0';
637  swprintf(Buf, Tmp, cAdapters);
638  PrintRow(IDS_NETWORK_CARDS, FALSE, L"%s", Buf);
639 
640  /* Show information about each adapter */
641  pCurrentAdapter = pAdapters;
642  for(i = 0; pCurrentAdapter; ++i)
643  {
644  if (pCurrentAdapter->IfType != 24 && pCurrentAdapter->IfType != 131)//IF_TYPE_SOFTWARE_LOOPBACK)
645  {
646  PIP_ADAPTER_UNICAST_ADDRESS pAddress;
647 
648  PrintRow(0, FALSE, L"[%02u]: %s", i + 1, pCurrentAdapter->Description);
649  PrintRow(IDS_CONNECTION_NAME, TRUE, L"%s", pCurrentAdapter->FriendlyName);
650  if (!(pCurrentAdapter->Flags & 0x0004))
651  {
653  Buf[0] = L'\0';
655  }
656  if (pCurrentAdapter->OperStatus == IfOperStatusDown)
657  {
659  Buf[0] = L'\0';
660  PrintRow(IDS_STATUS, TRUE, Buf);
661  }
662  else
663  {
665  Buf[0] = L'\0';
666  PrintRow(0, TRUE, Buf);
667  pAddress = pCurrentAdapter->FirstUnicastAddress;
668  for (j = 0; pAddress; ++j)
669  {
670  dwCharCount = BUFFER_SIZE;
671  WSAAddressToStringW(pAddress->Address.lpSockaddr, pAddress->Address.iSockaddrLength, NULL, Buf, &dwCharCount);
672  PrintRow(0, TRUE, L"[%02u]: %s", j + 1, Buf);
673  pAddress = pAddress->Next;
674  }
675  }
676  }
677  pCurrentAdapter = pCurrentAdapter->Next;
678  }
679  }
680  free(pAdapters);
681 }
682 
683 /* Main program */
684 int
685 main(int argc, char *argv[])
686 {
687  WSADATA WsaData;
688  int i;
689 
690  setlocale(LC_ALL, "");
691 
692  WSAStartup(MAKEWORD(2, 2), &WsaData);
693 
694  for (i = 1; i < argc; ++i)
695  {
696  if (!strcmp(argv[i], "/?") || !strcmp(argv[i], "-?"))
697  {
698  Usage();
699  return 0;
700  }
701  else
702  {
703  printf("Unsupported argument: %s\n", argv[i]);
704  return -1;
705  }
706  }
707 
708  AllSysInfo();
709 
710  return 0;
711 }
#define realloc
Definition: debug_ros.c:6
DWORD *typedef PVOID
Definition: winlogon.h:61
#define IDS_MEDIA_DISCONNECTED
Definition: resource.h:40
LPWSTR lpThousandSep
Definition: winnls.h:627
signed char * PCHAR
Definition: retypes.h:7
DWORD WINAPI GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
Definition: timezone.c:262
static int argc
Definition: ServiceArgs.c:12
int tm_min
Definition: time.h:78
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint 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 GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
unsigned short WORD
Definition: ntddk_ex.h:93
INT WINAPI GetPrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR def_val, LPWSTR buffer, UINT len, LPCWSTR filename)
Definition: profile.c:1142
#define TRUE
Definition: types.h:120
#define IDS_OS_VERSION
Definition: resource.h:155
#define ERROR_SUCCESS
Definition: deptool.c:10
LPWSTR lpDecimalSep
Definition: winnls.h:626
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 IDS_VIRT_MEM_MAX
Definition: resource.h:30
int main(int argc, char *argv[])
Definition: systeminfo.c:685
#define IDS_STATUS
Definition: resource.h:22
#define IDS_REG_ORG
Definition: resource.h:11
static BOOL RegGetDWORD(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpValueName, LPDWORD lpData)
Definition: systeminfo.c:92
WORD wMonth
Definition: winbase.h:871
#define MAKEWORD(a, b)
Definition: typedefs.h:247
ULONGLONG GetSeconds(VOID)
Definition: systeminfo.c:192
#define IDS_OS_NAME
Definition: resource.h:6
#define KEY_READ
Definition: nt_native.h:1023
#define BUFFER_SIZE
Definition: systeminfo.c:35
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
#define _countof(array)
Definition: fontsub.cpp:30
#define IDS_VIRT_MEM_INUSE
Definition: resource.h:32
WORD wDayOfWeek
Definition: winbase.h:872
#define HKEY_CURRENT_USER
Definition: winreg.h:11
unsigned char * LPBYTE
Definition: typedefs.h:52
#define free
Definition: debug_ros.c:5
#define IDS_BIOS_VERSION
Definition: resource.h:22
int tm_mday
Definition: time.h:80
const char * fmt
Definition: wsprintf.c:30
WCHAR szCSDVersion[128]
Definition: rtltypes.h:247
UINT Grouping
Definition: winnls.h:625
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define IDS_DOMAIN
Definition: resource.h:35
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1635
ULONGLONG GetSecondsQPC(VOID)
Definition: systeminfo.c:182
#define IDS_USAGE
Definition: resource.h:3
_CRTIMP wchar_t *__cdecl _itow(_In_ int _Value, _Pre_notnull_ _Post_z_ wchar_t *_Dest, _In_ int _Radix)
#define LOCALE_ILANGUAGE
Definition: winnls.h:25
int tm_year
Definition: time.h:82
NET_API_STATUS NET_API_FUNCTION NetGetJoinInformation(LPCWSTR Server, LPWSTR *Name, PNETSETUP_JOIN_STATUS type)
Definition: wksta.c:559
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:339
#define wprintf(...)
Definition: whoami.c:18
BOOL WINAPI GetVersionExW(IN LPOSVERSIONINFOW lpVersionInformation)
Definition: version.c:37
#define WCHAR
Definition: msvc.h:43
SIZE_T GetSMBiosStringW(_In_ PCSTR DmiString, _Out_ PWSTR pBuf, _In_ DWORD cchBuf, _In_ BOOL bTrim)
Definition: udmihelp.c:145
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
DWORD DWORD
Definition: winlogon.h:84
static char ** argv
Definition: ServiceArgs.c:11
UINT NegativeOrder
Definition: winnls.h:628
SIZE_T dwAvailVirtual
Definition: winbase.h:1176
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2351
#define NERR_Success
Definition: lmerr.h:5
#define PROCESSOR_ARCHITECTURE_IA64
Definition: ketypes.h:111
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:807
#define IDS_NETWORK_CARDS_FORMAT
Definition: resource.h:37
WORD wYear
Definition: winbase.h:870
GLenum GLclampf GLint i
Definition: glfuncs.h:14
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
SIZE_T dwAvailPhys
Definition: winbase.h:1172
#define va_end(ap)
Definition: acmsvcex.h:90
#define FALSE
Definition: types.h:117
#define REG_MULTI_SZ
Definition: nt_native.h:1501
UINT NumDigits
Definition: winnls.h:623
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:163
WORD wMinute
Definition: winbase.h:875
BOOL WINAPI QueryPerformanceFrequency(OUT PLARGE_INTEGER lpFrequency)
Definition: perfcnt.c:45
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
#define LoadLibraryW(x)
Definition: compat.h:404
smooth NULL
Definition: ftsmooth.c:416
#define IDS_ROS_DIR
Definition: resource.h:23
char * va_list
Definition: acmsvcex.h:78
#define IDS_NO
Definition: resource.h:17
VOID AllSysInfo(VOID)
Definition: systeminfo.c:270
char ** Args
Definition: acdebug.h:342
#define IDS_SYS_LOCALE
Definition: resource.h:26
int tm_mon
Definition: time.h:81
_Check_return_opt_ _CRTIMP int __cdecl vwprintf(_In_z_ _Printf_format_string_ const wchar_t *_Format, va_list _ArgList)
#define IDS_TOTAL_PHYS_MEM
Definition: resource.h:28
#define AF_UNSPEC
Definition: winsock.h:344
#define IDS_NETWORK_CARDS
Definition: resource.h:36
static SCRIPT_CACHE SCRIPT_ANALYSIS OPENTYPE_TAG OPENTYPE_TAG int TEXTRANGE_PROPERTIES int const WCHAR int cChars
Definition: usp10.c:64
#define IDS_DHCP_ENABLED
Definition: resource.h:41
#define LC_ALL
Definition: locale.h:25
SIZE_T dwTotalVirtual
Definition: winbase.h:1175
#define FreeLibrary(x)
Definition: compat.h:405
unsigned int BOOL
Definition: ntddk_ex.h:94
ULONG dwMajorVersion
Definition: rtltypes.h:243
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
HANDLE HKEY
Definition: registry.h:24
uint64_t ULONGLONG
Definition: typedefs.h:65
enum tagNETSETUP_JOIN_STATUS NETSETUP_JOIN_STATUS
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:242
#define MAX_PATH
Definition: compat.h:26
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define IDS_AVAIL_PHISICAL_MEM
Definition: resource.h:29
#define LOCALE_SYSTEM_DEFAULT
#define IDS_SYS_MODEL
Definition: resource.h:17
static VOID PrintRow(UINT nTitleID, BOOL bIndent, LPWSTR lpFormat,...)
Definition: systeminfo.c:238
#define IDS_SYS_MANUFACTURER
Definition: resource.h:16
VOID NTAPI GlobalMemoryStatus(LPMEMORYSTATUS lpBuffer)
Definition: heapmem.c:1348
#define IDS_TIME_ZONE
Definition: resource.h:34
#define PROCESSOR_ARCHITECTURE_AMD64
Definition: ketypes.h:114
WORD wSecond
Definition: winbase.h:876
static VOID FormatBytes(LPWSTR lpBuf, unsigned cBytes)
Definition: systeminfo.c:131
WORD wMilliseconds
Definition: winbase.h:877
ULONG dwBuildNumber
Definition: rtltypes.h:245
BOOL WINAPI QueryPerformanceCounter(OUT PLARGE_INTEGER lpPerformanceCount)
Definition: perfcnt.c:23
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1087
#define VOID
Definition: acefi.h:82
LPCWSTR lpFormat
Definition: trayclock.cpp:32
Definition: time.h:76
_CRTIMP struct tm *__cdecl localtime(const time_t *_Time)
Definition: time.h:426
#define IDS_SYS_TYPE
Definition: resource.h:18
#define WINAPI
Definition: msvc.h:20
int tm_wday
Definition: time.h:83
#define IDS_SYS_DIR
Definition: resource.h:24
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:916
HRESULT WINAPI SHLoadIndirectString(LPCWSTR src, LPWSTR dst, UINT dst_len, void **reserved)
Definition: string.c:2842
#define PROCESSOR_ARCHITECTURE_INTEL
Definition: ketypes.h:105
WORD wDay
Definition: winbase.h:873
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define IDS_REG_OWNER
Definition: resource.h:10
#define IDS_INST_DATE
Definition: resource.h:13
#define IDS_HOST_NAME
Definition: resource.h:5
#define IDS_PROCESSORS
Definition: resource.h:19
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
#define GetModuleHandle
Definition: winbase.h:3641
static unsigned RegGetSZ(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpValueName, LPWSTR lpBuf, DWORD cchBuf)
Definition: systeminfo.c:40
#define IDS_VIRT_MEM_AVAIL
Definition: resource.h:31
__kernel_time_t time_t
Definition: linux.h:252
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
VOID FreeSMBiosData(_In_ PVOID Buffer)
Definition: udmihelp.c:177
#define IDS_INPUT_LOCALE
Definition: resource.h:27
WORD wHour
Definition: winbase.h:874
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2312
VOID WINAPI GetSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
Definition: sysinfo.c:142
#define IDS_UP_TIME_FORMAT
Definition: resource.h:15
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define IDS_UP_TIME
Definition: resource.h:14
#define IDS_PROCESSORS_FORMAT
Definition: resource.h:20
#define IDS_BUILD
Definition: resource.h:8
static LARGE_INTEGER Frequency
Definition: clock.c:41
WORD wProcessorArchitecture
Definition: winbase.h:1122
int tm_sec
Definition: time.h:77
#define IDS_OS_BUILD_TYPE
Definition: resource.h:9
HANDLE HMODULE
Definition: typedefs.h:75
static LARGE_INTEGER Counter
Definition: clock.c:43
ULONG dwMinorVersion
Definition: rtltypes.h:244
DWORD dwNumberOfProcessors
Definition: winbase.h:1130
uint32_t * LPDWORD
Definition: typedefs.h:57
static VOID FormatDateTime(time_t Time, LPWSTR lpBuf)
Definition: systeminfo.c:155
#define c
Definition: ke_i.h:80
int tm_hour
Definition: time.h:79
unsigned int ULONG
Definition: retypes.h:1
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:845
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
UINT LeadingZero
Definition: winnls.h:624
#define setlocale(n, s)
Definition: locale.h:46
PVOID LoadSMBiosData(_Inout_updates_(ID_STRINGS_MAX) PCHAR *Strings)
Definition: udmihelp.c:30
#define GetProcAddress(x, y)
Definition: compat.h:410
#define malloc
Definition: debug_ros.c:4
#define IDS_IP_ADDRESSES
Definition: resource.h:43
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
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:2541
INT WINAPI GetNumberFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const NUMBERFMTW *lpFormat, LPWSTR lpNumberStr, int cchOut)
Definition: lcformat.c:1135
#define IDS_BOOT_DEV
Definition: resource.h:25
#define IDS_CONNECTION_NAME
Definition: resource.h:38
INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1016
#define REG_DWORD
Definition: sdbapi.c:539
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static PIP_ADAPTER_ADDRESSES
Definition: iphlpapi.c:76
static VOID Usage(VOID)
Definition: systeminfo.c:229
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
WCHAR StandardName[32]
Definition: winbase.h:1160
static PLARGE_INTEGER Time
Definition: time.c:105
#define IDS_BIOS_DATE
Definition: resource.h:21
SIZE_T dwTotalPhys
Definition: winbase.h:1171
LONGLONG QuadPart
Definition: typedefs.h:112
LPVOID pAddress
Definition: wglext.h:735
HMODULE hModule
Definition: animate.c:44
#define IDS_PAGEFILE_LOC
Definition: resource.h:33
#define printf
Definition: config.h:203
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define IDS_PRODUCT_ID
Definition: resource.h:12
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define REG_SZ
Definition: layer.c:22