ReactOS 0.4.15-dev-7842-g558ab78
udmihelp.c File Reference
#include "precomp.h"
Include dependency graph for udmihelp.c:

Go to the source code of this file.

Functions

static UINT (WINAPI *pGetSystemFirmwareTable)(DWORD
 
static VOID InitializeAPI ()
 
PVOID LoadSMBiosData (_Inout_updates_(ID_STRINGS_MAX) PCHAR *Strings)
 
VOID TrimDmiStringW (_Inout_ PWSTR pStr)
 
SIZE_T GetSMBiosStringW (_In_ PCSTR DmiString, _Out_ PWSTR pBuf, _In_ DWORD cchBuf, _In_ BOOL bTrim)
 
VOID FreeSMBiosData (_In_ PVOID Buffer)
 

Variables

static DWORD
 
static PVOID
 
static BOOL bInitAPI = FALSE
 

Function Documentation

◆ FreeSMBiosData()

VOID FreeSMBiosData ( _In_ PVOID  Buffer)

Definition at line 177 of file udmihelp.c.

179{
180 if (!Buffer)
181 return;
182
184}
Definition: bufpool.h:45
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735

Referenced by AllSysInfo(), GetSystemName(), InitializeSystemPage(), and PrintSystemInfo().

◆ GetSMBiosStringW()

SIZE_T GetSMBiosStringW ( _In_ PCSTR  DmiString,
_Out_ PWSTR  pBuf,
_In_ DWORD  cchBuf,
_In_ BOOL  bTrim 
)

Definition at line 145 of file udmihelp.c.

150{
152
153 if (!DmiString)
154 {
155 if (cchBuf >= 1)
156 {
157 *pBuf = 0;
158 }
159 return 0;
160 }
161
162 cChars = MultiByteToWideChar(CP_OEMCP, 0, DmiString, -1, pBuf, cchBuf);
163
164 /* NULL-terminate string */
165 pBuf[min(cchBuf-1, cChars)] = L'\0';
166
167 if (bTrim)
168 {
169 TrimDmiStringW(pBuf);
170 }
171
172 return wcslen(pBuf);
173}
#define MultiByteToWideChar
Definition: compat.h:110
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
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 L(x)
Definition: ntvdm.h:50
ULONG_PTR SIZE_T
Definition: typedefs.h:80
VOID TrimDmiStringW(_Inout_ PWSTR pStr)
Definition: udmihelp.c:110
#define CP_OEMCP
Definition: winnls.h:231

Referenced by AllSysInfo(), GetBIOSValue(), and GetSystemName().

◆ InitializeAPI()

static VOID InitializeAPI ( )
static

Definition at line 15 of file udmihelp.c.

16{
17 HANDLE hKernel;
18
19 pGetSystemFirmwareTable = NULL;
20
21 hKernel = GetModuleHandleW(L"kernel32.dll");
22 if (!hKernel)
23 return;
24
25 pGetSystemFirmwareTable = (void *)GetProcAddress(hKernel, "GetSystemFirmwareTable");
26}
#define NULL
Definition: types.h:112
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838

Referenced by LoadSMBiosData().

◆ LoadSMBiosData()

PVOID LoadSMBiosData ( _Inout_updates_(ID_STRINGS_MAX) PCHAR Strings)

Definition at line 30 of file udmihelp.c.

32{
34 HKEY hKey;
35 DWORD dwType, dwCheck, dwBytes = 0;
36
37 if (!bInitAPI)
38 {
40 bInitAPI = TRUE;
41 }
42
43 /* Try using GetSystemFirmwareTable (works on NT 5.2 and higher) */
44 if (pGetSystemFirmwareTable)
45 {
46 dwBytes = pGetSystemFirmwareTable('RSMB', 0, NULL, 0);
47 if (dwBytes > 0)
48 {
49 pBuffer = HeapAlloc(GetProcessHeap(), 0, dwBytes);
50 if (!pBuffer)
51 {
52 return NULL;
53 }
54 dwCheck = pGetSystemFirmwareTable('RSMB', 0, pBuffer, dwBytes);
55 if (dwCheck != dwBytes)
56 {
58 return NULL;
59 }
60 }
61 }
62 if (dwBytes == 0)
63 {
64 /* Try using registry (works on NT 5.1) */
66 L"SYSTEM\\CurrentControlSet\\Services\\mssmbios\\Data",
68 {
69 return NULL;
70 }
71
73 L"SMBiosData",
74 NULL,
75 &dwType,
76 NULL,
77 &dwBytes) != ERROR_SUCCESS || dwType != REG_BINARY)
78 {
80 return NULL;
81 }
82
83 pBuffer = HeapAlloc(GetProcessHeap(), 0, dwBytes);
84 if (!pBuffer)
85 {
87 return NULL;
88 }
89
91 L"SMBiosData",
92 NULL,
93 &dwType,
94 pBuffer,
95 &dwBytes) != ERROR_SUCCESS || dwType != REG_BINARY)
96 {
99 return NULL;
100 }
101
103 }
105 return pBuffer;
106}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3268
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
static const WCHAR Strings[]
Definition: reg.c:35
#define HeapAlloc
Definition: compat.h:733
VOID ParseSMBiosTables(_In_reads_bytes_(TableSize) PVOID SMBiosTables, _In_ ULONG TableSize, _Inout_updates_(ID_STRINGS_MAX) PCHAR *Strings)
Definition: dmilib.c:41
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
#define REG_BINARY
Definition: nt_native.h:1496
PVOID pBuffer
static VOID InitializeAPI()
Definition: udmihelp.c:15
static BOOL bInitAPI
Definition: udmihelp.c:11
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by AllSysInfo(), GetSystemName(), InitializeSystemPage(), and PrintSystemInfo().

◆ TrimDmiStringW()

VOID TrimDmiStringW ( _Inout_ PWSTR  pStr)

Definition at line 110 of file udmihelp.c.

112{
114 UINT i = 0;
115
116 if (!pStr)
117 return;
118
119 Length = wcslen(pStr);
120 if (Length == 0)
121 return;
122
123 /* Trim leading spaces */
124 while (i < Length && pStr[i] <= L' ')
125 {
126 i++;
127 }
128
129 if (i > 0)
130 {
131 Length -= i;
132 memmove(pStr, pStr + i, (Length + 1) * sizeof(WCHAR));
133 }
134
135 /* Trim trailing spaces */
136 while (Length && pStr[Length-1] <= L' ')
137 {
138 pStr[Length-1] = L'\0';
139 --Length;
140 }
141}
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
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
unsigned int UINT
Definition: ndis.h:50
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by GetSMBiosStringW(), InitializeSystemPage(), and wcsrep().

◆ UINT()

static UINT ( WINAPI pGetSystemFirmwareTable)
static

Variable Documentation

◆ bInitAPI

BOOL bInitAPI = FALSE
static

Definition at line 11 of file udmihelp.c.

Referenced by LoadSMBiosData().

◆ DWORD

Definition at line 10 of file udmihelp.c.

◆ PVOID

Definition at line 10 of file udmihelp.c.