ReactOS 0.4.16-dev-329-g9223134
sysinfo.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: Dr. Watson crash reporter
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Output system info
5 * COPYRIGHT: Copyright 2017 Mark Jansen <mark.jansen@reactos.org>
6 */
7
8#include "precomp.h"
9#include <udmihelp.h>
10#include <winreg.h>
11#include <reactos/buildno.h>
12#include <reactos/stubs.h>
13
14static const char* Exception2Str(DWORD code)
15{
16 switch (code)
17 {
18#define EX_TO_STR(name) case (DWORD)(name): return #name
43 }
44
45 return "--";
46}
47
48static void ReadKey(HKEY hKey, const char* ValueName, char* Buffer, DWORD size)
49{
50 DWORD dwType;
52 if (ret != ERROR_SUCCESS || dwType != REG_SZ)
53 Buffer[0] = '\0';
54}
55
57{
58 SYSTEMTIME LocalTime;
59 GetLocalTime(&LocalTime);
60 xfprintf(output, NEWLINE "ReactOS " KERNEL_VERSION_STR " DrWtsn32" NEWLINE NEWLINE);
61 xfprintf(output, "Application exception occurred:" NEWLINE);
62 xfprintf(output, " App: %ls (pid=%d, tid=0x%x)" NEWLINE, data.ProcessName.c_str(), data.ProcessID, data.ThreadID);
63 xfprintf(output, " When: %d/%d/%d @ %02d:%02d:%02d.%d" NEWLINE,
64 LocalTime.wDay, LocalTime.wMonth, LocalTime.wYear,
65 LocalTime.wHour, LocalTime.wMinute, LocalTime.wSecond, LocalTime.wMilliseconds);
66
67 xfprintf(output, " First chance: %u" NEWLINE, data.ExceptionInfo.dwFirstChance);
68 EXCEPTION_RECORD& Record = data.ExceptionInfo.ExceptionRecord;
69 xfprintf(output, " Exception number: 0x%08x (%s)" NEWLINE, Record.ExceptionCode, Exception2Str(Record.ExceptionCode));
70 xfprintf(output, " Exception flags: 0x%08x" NEWLINE, Record.ExceptionFlags);
71 xfprintf(output, " Exception address: %p" NEWLINE, Record.ExceptionAddress);
72 if (Record.NumberParameters)
73 {
74 xfprintf(output, " Exception parameters: %u" NEWLINE, Record.NumberParameters);
75 for (DWORD n = 0; n < std::min<DWORD>(EXCEPTION_MAXIMUM_PARAMETERS, Record.NumberParameters); ++n)
76 {
77 xfprintf(output, " Parameter %u: 0x%p" NEWLINE, n, Record.ExceptionInformation[n]);
78 }
79 }
80
81 char Buffer[MAX_PATH];
82 DWORD count = sizeof(Buffer);
83 xfprintf(output, NEWLINE "*----> System Information <----*" NEWLINE NEWLINE);
85 xfprintf(output, " Computer Name: %s" NEWLINE, Buffer);
86 count = sizeof(Buffer);
88 xfprintf(output, " User Name: %s" NEWLINE, Buffer);
89
90
91 PVOID SMBiosBuf;
92 PCHAR DmiStrings[ID_STRINGS_MAX] = { 0 };
93 SMBiosBuf = LoadSMBiosData(DmiStrings);
94 if (SMBiosBuf)
95 {
96 if (DmiStrings[BIOS_VENDOR])
97 xfprintf(output, " BIOS Vendor: %s" NEWLINE, DmiStrings[BIOS_VENDOR]);
98 if (DmiStrings[BIOS_VERSION])
99 xfprintf(output, " BIOS Version: %s" NEWLINE, DmiStrings[BIOS_VERSION]);
100 if (DmiStrings[BIOS_DATE])
101 xfprintf(output, " BIOS Date: %s" NEWLINE, DmiStrings[BIOS_DATE]);
102 if (DmiStrings[SYS_VENDOR])
103 xfprintf(output, " System Manufacturer: %s" NEWLINE, DmiStrings[SYS_VENDOR]);
104 if (DmiStrings[SYS_FAMILY])
105 xfprintf(output, " System Family: %s" NEWLINE, DmiStrings[SYS_FAMILY]);
106 if (DmiStrings[SYS_PRODUCT])
107 xfprintf(output, " System Model: %s" NEWLINE, DmiStrings[SYS_PRODUCT]);
108 if (DmiStrings[SYS_VERSION])
109 xfprintf(output, " System Version: %s" NEWLINE, DmiStrings[SYS_VERSION]);
110 if (DmiStrings[SYS_SKU])
111 xfprintf(output, " System SKU: %s" NEWLINE, DmiStrings[SYS_SKU]);
112 if (DmiStrings[BOARD_VENDOR])
113 xfprintf(output, " Baseboard Manufacturer: %s" NEWLINE, DmiStrings[BOARD_VENDOR]);
114 if (DmiStrings[BOARD_NAME])
115 xfprintf(output, " Baseboard Model: %s" NEWLINE, DmiStrings[BOARD_NAME]);
116 if (DmiStrings[BOARD_VERSION])
117 xfprintf(output, " Baseboard Version: %s" NEWLINE, DmiStrings[BOARD_VERSION]);
118 FreeSMBiosData(SMBiosBuf);
119 }
120
123 xfprintf(output, " Number of Processors: %d" NEWLINE, info.dwNumberOfProcessors);
124
125 HKEY hKey;
126 LONG ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0",
127 0, KEY_READ, &hKey);
128 if (ret == ERROR_SUCCESS)
129 {
130 DWORD dwType;
131 count = sizeof(Buffer);
132 ret = RegQueryValueExA(hKey, "Identifier", NULL, &dwType, (LPBYTE)Buffer, &count);
133 if (ret == ERROR_SUCCESS && dwType == REG_SZ)
134 {
135 Buffer[count] = '\0';
136 xfprintf(output, " Processor Type: %s" NEWLINE, Buffer);
137 }
139 }
140
141 ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_READ, &hKey);
142 if (ret == ERROR_SUCCESS)
143 {
144 char Version[50];
145 ReadKey(hKey, "ProductName", Buffer, sizeof(Buffer));
146 ReadKey(hKey, "CurrentVersion", Version, sizeof(Version));
147 xfprintf(output, " %s Version: %s" NEWLINE, Buffer, Version);
148 ReadKey(hKey, "BuildLab", Buffer, sizeof(Buffer));
149 xfprintf(output, " BuildLab: %s" NEWLINE, Buffer);
150 ReadKey(hKey, "CSDVersion", Buffer, sizeof(Buffer));
151 if (Buffer[0])
152 xfprintf(output, " Service Pack: %s" NEWLINE, Buffer);
153 ReadKey(hKey, "CurrentType", Buffer, sizeof(Buffer));
154 xfprintf(output, " Current Type: %s" NEWLINE, Buffer);
155 ReadKey(hKey, "RegisteredOrganization", Buffer, sizeof(Buffer));
156 xfprintf(output, " Registered Organization: %s" NEWLINE, Buffer);
157 ReadKey(hKey, "RegisteredOwner", Buffer, sizeof(Buffer));
158 xfprintf(output, " Registered Owner: %s" NEWLINE, Buffer);
159
161 }
162}
#define RegCloseKey(hKey)
Definition: registry.h:49
Definition: bufpool.h:45
#define ERROR_SUCCESS
Definition: deptool.c:10
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3298
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4009
BOOL WINAPI GetUserNameA(LPSTR lpszName, LPDWORD lpSize)
Definition: misc.c:246
#define EXCEPTION_MAXIMUM_PARAMETERS
Definition: compat.h:206
#define MAX_PATH
Definition: compat.h:34
VOID WINAPI GetSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
Definition: sysinfo.c:143
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
@ BIOS_VERSION
Definition: dmilib.h:14
@ BOARD_VENDOR
Definition: dmilib.h:22
@ SYS_VERSION
Definition: dmilib.h:18
@ 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
@ BOARD_NAME
Definition: dmilib.h:23
@ BOARD_VERSION
Definition: dmilib.h:24
@ SYS_FAMILY
Definition: dmilib.h:21
@ SYS_SKU
Definition: dmilib.h:20
#define NEWLINE
Definition: drwtsn32.h:53
void xfprintf(FILE *stream, const char *fmt,...)
Definition: main.cpp:34
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
GLdouble n
Definition: glext.h:7729
#define REG_SZ
Definition: layer.c:22
#define KEY_READ
Definition: nt_native.h:1023
#define STATUS_ASSERTION_FAILURE
Definition: ntstatus.h:960
long LONG
Definition: pedump.c:60
BOOL WINAPI SHIM_OBJ_NAME() GetComputerNameA(LPSTR lpBuffer, LPDWORD lpnSize)
Definition: shimtest.c:21
WORD wYear
Definition: winbase.h:930
WORD wMilliseconds
Definition: winbase.h:937
WORD wMonth
Definition: winbase.h:931
WORD wHour
Definition: winbase.h:934
WORD wSecond
Definition: winbase.h:936
WORD wMinute
Definition: winbase.h:935
WORD wDay
Definition: winbase.h:933
Definition: inflate.c:139
#define EXCEPTION_WINE_STUB
Definition: stubs.h:31
static const char * Exception2Str(DWORD code)
Definition: sysinfo.cpp:14
#define EX_TO_STR(name)
static void ReadKey(HKEY hKey, const char *ValueName, char *Buffer, DWORD size)
Definition: sysinfo.cpp:48
void PrintSystemInfo(FILE *output, DumpData &data)
Definition: sysinfo.cpp:56
unsigned char * LPBYTE
Definition: typedefs.h:53
char * PCHAR
Definition: typedefs.h:51
PVOID LoadSMBiosData(_Inout_updates_(ID_STRINGS_MAX) PCHAR *Strings)
Definition: udmihelp.c:30
VOID FreeSMBiosData(_In_ PVOID Buffer)
Definition: udmihelp.c:177
int ret
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
#define EXCEPTION_SINGLE_STEP
Definition: winbase.h:340
#define EXCEPTION_NONCONTINUABLE_EXCEPTION
Definition: winbase.h:354
#define EXCEPTION_GUARD_PAGE
Definition: winbase.h:357
#define EXCEPTION_FLT_STACK_CHECK
Definition: winbase.h:347
#define EXCEPTION_STACK_OVERFLOW
Definition: winbase.h:355
#define EXCEPTION_INT_DIVIDE_BY_ZERO
Definition: winbase.h:349
#define EXCEPTION_IN_PAGE_ERROR
Definition: winbase.h:352
#define EXCEPTION_FLT_UNDERFLOW
Definition: winbase.h:348
#define EXCEPTION_INT_OVERFLOW
Definition: winbase.h:350
#define EXCEPTION_INVALID_HANDLE
Definition: winbase.h:358
#define EXCEPTION_INVALID_DISPOSITION
Definition: winbase.h:356
#define EXCEPTION_FLT_OVERFLOW
Definition: winbase.h:346
#define EXCEPTION_ARRAY_BOUNDS_EXCEEDED
Definition: winbase.h:341
#define EXCEPTION_DATATYPE_MISALIGNMENT
Definition: winbase.h:338
#define EXCEPTION_FLT_DENORMAL_OPERAND
Definition: winbase.h:342
#define EXCEPTION_FLT_INEXACT_RESULT
Definition: winbase.h:344
#define EXCEPTION_ILLEGAL_INSTRUCTION
Definition: winbase.h:353
#define EXCEPTION_ACCESS_VIOLATION
Definition: winbase.h:337
#define EXCEPTION_BREAKPOINT
Definition: winbase.h:339
#define EXCEPTION_FLT_INVALID_OPERATION
Definition: winbase.h:345
#define EXCEPTION_PRIV_INSTRUCTION
Definition: winbase.h:351
#define EXCEPTION_FLT_DIVIDE_BY_ZERO
Definition: winbase.h:343
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
_In_ struct _KBUGCHECK_REASON_CALLBACK_RECORD * Record
Definition: ketypes.h:268