ReactOS  0.4.15-dev-5461-g062a8f2
hwhacks.c File Reference
#include "i8042prt.h"
#include <wmiguid.h>
#include <wmidata.h>
#include <wmistr.h>
#include <dmilib.h>
#include <debug.h>
Include dependency graph for hwhacks.c:

Go to the source code of this file.

Classes

struct  _MATCHENTRY
 
struct  _HARDWARE_TABLE
 

Macros

#define NDEBUG
 
#define MAX_MATCH_ENTRIES   3
 

Typedefs

typedef struct _MATCHENTRY MATCHENTRY
 
typedef struct _HARDWARE_TABLE HARDWARE_TABLE
 

Functions

static VOID i8042ParseSMBiosTables (_In_reads_bytes_(TableSize) PVOID SMBiosTables, _In_ ULONG TableSize)
 
static VOID i8042StoreSMBiosTables (_In_reads_bytes_(TableSize) PVOID SMBiosTables, _In_ ULONG TableSize)
 
VOID NTAPI i8042InitializeHwHacks (VOID)
 

Variables

const GUID MSSmBios_RawSMBiosTables_GUID = SMBIOS_DATA_GUID
 
PVOID i8042SMBiosTables
 
ULONG i8042HwFlags
 
const HARDWARE_TABLE i8042HardwareTable []
 

Macro Definition Documentation

◆ MAX_MATCH_ENTRIES

#define MAX_MATCH_ENTRIES   3

Definition at line 30 of file hwhacks.c.

◆ NDEBUG

#define NDEBUG

Definition at line 17 of file hwhacks.c.

Typedef Documentation

◆ HARDWARE_TABLE

◆ MATCHENTRY

Function Documentation

◆ i8042InitializeHwHacks()

VOID NTAPI i8042InitializeHwHacks ( VOID  )

Definition at line 184 of file hwhacks.c.

186 {
188  PVOID DataBlockObject;
189  PWNODE_ALL_DATA AllData;
191 
192  /* Open the data block object for the SMBIOS table */
195  &DataBlockObject);
196  if (!NT_SUCCESS(Status))
197  {
198  DPRINT1("IoWMIOpenBlock failed: 0x%08lx\n", Status);
199  return;
200  }
201 
202  /* Query the required buffer size */
203  BufferSize = 0;
204  Status = IoWMIQueryAllData(DataBlockObject, &BufferSize, NULL);
205  if (!NT_SUCCESS(Status))
206  {
207  DPRINT1("IoWMIOpenBlock failed: 0x%08lx\n", Status);
208  return;
209  }
210 
211  AllData = ExAllocatePoolWithTag(PagedPool, BufferSize, 'BTMS');
212  if (AllData == NULL)
213  {
214  DPRINT1("Failed to allocate %lu bytes for SMBIOS tables\n", BufferSize);
215  return;
216  }
217 
218  /* Query the buffer data */
219  Status = IoWMIQueryAllData(DataBlockObject, &BufferSize, AllData);
220  if (!NT_SUCCESS(Status))
221  {
222  DPRINT1("IoWMIOpenBlock failed: 0x%08lx\n", Status);
223  ExFreePoolWithTag(AllData, 'BTMS');
224  return;
225  }
226 
227  /* FIXME: This function should be removed once the mssmbios driver is implemented */
228  /* Store SMBios data in registry */
229  i8042StoreSMBiosTables(AllData + 1,
230  AllData->FixedInstanceSize);
231  DPRINT1("SMBiosTables HACK, see CORE-14867\n");
232 
233  /* Parse the table */
234  i8042ParseSMBiosTables(AllData + 1,
235  AllData->WnodeHeader.BufferSize);
236 
237  /* Free the buffer */
238  ExFreePoolWithTag(AllData, 'BTMS');
239 }
static VOID i8042StoreSMBiosTables(_In_reads_bytes_(TableSize) PVOID SMBiosTables, _In_ ULONG TableSize)
Definition: hwhacks.c:120
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI IoWMIQueryAllData(IN PVOID DataBlockObject, IN OUT ULONG *InOutBufferSize, OUT PVOID OutBuffer)
Definition: wmi.c:169
Status
Definition: gdiplustypes.h:24
const GUID MSSmBios_RawSMBiosTables_GUID
Definition: hwhacks.c:20
static VOID i8042ParseSMBiosTables(_In_reads_bytes_(TableSize) PVOID SMBiosTables, _In_ ULONG TableSize)
Definition: hwhacks.c:63
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
NTSTATUS NTAPI IoWMIOpenBlock(_In_ LPCGUID DataBlockGuid, _In_ ULONG DesiredAccess, _Out_ PVOID *DataBlockObject)
Definition: wmi.c:140
ULONG FixedInstanceSize
Definition: wmistr.h:118
#define WMIGUID_QUERY
Definition: wmistr.h:159
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
struct _WNODE_HEADER WnodeHeader
Definition: wmistr.h:112
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define BufferSize
Definition: mmc.h:75
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251

Referenced by DriverEntry().

◆ i8042ParseSMBiosTables()

static VOID i8042ParseSMBiosTables ( _In_reads_bytes_(TableSize) PVOID  SMBiosTables,
_In_ ULONG  TableSize 
)
static

Definition at line 63 of file hwhacks.c.

66 {
67  ULONG i, j;
68  PCHAR Strings[ID_STRINGS_MAX] = { 0 };
69 
70  ParseSMBiosTables(SMBiosTables, TableSize, Strings);
71 
72 #if 0 // DBG
73  DbgPrint("i8042prt: Dumping DMI data:\n");
74  DbgPrint("BIOS_VENDOR: %s\n", Strings[BIOS_VENDOR]);
75  DbgPrint("BIOS_VERSION: %s\n", Strings[BIOS_VERSION]);
76  DbgPrint("BIOS_DATE: %s\n", Strings[BIOS_DATE]);
77  DbgPrint("SYS_VENDOR: %s\n", Strings[SYS_VENDOR]);
78  DbgPrint("SYS_PRODUCT: %s\n", Strings[SYS_PRODUCT]);
79  DbgPrint("SYS_VERSION: %s\n", Strings[SYS_VERSION]);
80  DbgPrint("SYS_SERIAL: %s\n", Strings[SYS_SERIAL]);
81  DbgPrint("BOARD_VENDOR: %s\n", Strings[BOARD_VENDOR]);
82  DbgPrint("BOARD_NAME: %s\n", Strings[BOARD_NAME]);
83  DbgPrint("BOARD_VERSION: %s\n", Strings[BOARD_VERSION]);
84  DbgPrint("BOARD_SERIAL: %s\n", Strings[BOARD_SERIAL]);
85  DbgPrint("BOARD_ASSET_TAG: %s\n", Strings[BOARD_ASSET_TAG]);
86 #endif
87 
88  /* Now loop the hardware table to find a match */
89  for (i = 0; i < ARRAYSIZE(i8042HardwareTable); i++)
90  {
91  for (j = 0; j < MAX_MATCH_ENTRIES; j++)
92  {
94 
95  if (Type != ID_NONE)
96  {
97  /* Check for a match */
98  if ((Strings[Type] == NULL) ||
99  strcmp(i8042HardwareTable[i].MatchEntries[j].String,
100  Strings[i8042HardwareTable[i].MatchEntries[j].Type]))
101  {
102  /* Does not match, try next entry */
103  break;
104  }
105  }
106  }
107 
108  if (j == MAX_MATCH_ENTRIES)
109  {
110  /* All items matched! */
112  DPRINT("Found match for hw table index %u\n", i);
113  break;
114  }
115  }
116 }
signed char * PCHAR
Definition: retypes.h:7
#define DbgPrint
Definition: hal.h:12
VOID ParseSMBiosTables(_In_reads_bytes_(TableSize) PVOID SMBiosTables, _In_ ULONG TableSize, _Inout_updates_(ID_STRINGS_MAX) PCHAR *Strings)
Definition: dmilib.c:41
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
MATCHENTRY MatchEntries[MAX_MATCH_ENTRIES]
Definition: hwhacks.c:33
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2430
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
Type
Definition: Type.h:6
static const WCHAR Strings[]
Definition: reg.c:35
ULONG Flags
Definition: hwhacks.c:34
ULONG i8042HwFlags
Definition: hwhacks.c:22
#define MAX_MATCH_ENTRIES
Definition: hwhacks.c:30
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 NULL
Definition: types.h:112
_Must_inspect_result_ typedef _Out_ PULONG TableSize
Definition: iotypes.h:4327
ULONG Type
Definition: hwhacks.c:26
unsigned int ULONG
Definition: retypes.h:1
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define DPRINT
Definition: sndvol32.h:71
Definition: dmilib.h:14
const HARDWARE_TABLE i8042HardwareTable[]
Definition: hwhacks.c:37

Referenced by i8042InitializeHwHacks().

◆ i8042StoreSMBiosTables()

static VOID i8042StoreSMBiosTables ( _In_reads_bytes_(TableSize) PVOID  SMBiosTables,
_In_ ULONG  TableSize 
)
static

Definition at line 120 of file hwhacks.c.

123 {
124  static UNICODE_STRING mssmbiosKeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services\\mssmbios");
125  static UNICODE_STRING DataName = RTL_CONSTANT_STRING(L"Data");
126  static UNICODE_STRING ValueName = RTL_CONSTANT_STRING(L"SMBiosData");
130 
131  /* Create registry key */
133  &mssmbiosKeyName,
135  NULL,
136  NULL);
137  Status = ZwCreateKey(&KeyHandle,
138  KEY_WRITE,
140  0,
141  NULL,
143  NULL);
144 
145  if (!NT_SUCCESS(Status))
146  {
147  return;
148  }
149 
150  /* Create sub key */
152  &DataName,
154  KeyHandle,
155  NULL);
156  Status = ZwCreateKey(&SubKeyHandle,
157  KEY_WRITE,
159  0,
160  NULL,
162  NULL);
163 
164  if (!NT_SUCCESS(Status))
165  {
167  return;
168  }
169 
170  /* Write value */
171  ZwSetValueKey(SubKeyHandle,
172  &ValueName,
173  0,
174  REG_BINARY,
175  SMBiosTables,
176  TableSize);
177 
180 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
#define REG_BINARY
Definition: nt_native.h:1496
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define L(x)
Definition: ntvdm.h:50
Status
Definition: gdiplustypes.h:24
#define KEY_WRITE
Definition: nt_native.h:1031
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ PNDIS_STRING _Out_ PNDIS_HANDLE SubKeyHandle
Definition: ndis.h:4723
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:240
#define NULL
Definition: types.h:112
_Must_inspect_result_ typedef _Out_ PULONG TableSize
Definition: iotypes.h:4327
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define REG_OPTION_VOLATILE
Definition: nt_native.h:1060
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by i8042InitializeHwHacks().

Variable Documentation

◆ i8042HardwareTable

const HARDWARE_TABLE i8042HardwareTable[]
Initial value:
=
{
{ {{SYS_VENDOR, "Microsoft Corporation"}, {SYS_PRODUCT, "Virtual Machine"}}, FL_INITHACK },
{ {{SYS_VENDOR, "Dell Inc."}, {SYS_PRODUCT, "Inspiron 6000 "}}, FL_INITHACK },
{ {{SYS_VENDOR, "Dell Inc."}, {SYS_PRODUCT, "Latitude D430 "}}, FL_INITHACK },
{ {{SYS_VENDOR, "Dell Inc."}, {SYS_PRODUCT, "Latitude D530 "}}, FL_INITHACK },
{ {{SYS_VENDOR, "Dell Inc."}, {SYS_PRODUCT, "Latitude D531 "}}, FL_INITHACK },
{ {{SYS_VENDOR, "Dell Inc."}, {SYS_PRODUCT, "Latitude D600 "}}, FL_INITHACK },
{ {{SYS_VENDOR, "Dell Inc."}, {SYS_PRODUCT, "Latitude D610 "}}, FL_INITHACK },
{ {{SYS_VENDOR, "Dell Inc."}, {SYS_PRODUCT, "Latitude D620 "}}, FL_INITHACK },
{ {{SYS_VENDOR, "Dell Inc."}, {SYS_PRODUCT, "Latitude D630 "}}, FL_INITHACK },
{ {{SYS_VENDOR, "Dell Inc."}, {SYS_PRODUCT, "Latitude D810 "}}, FL_INITHACK },
{ {{SYS_VENDOR, "Dell Inc."}, {SYS_PRODUCT, "Latitude D820 "}}, FL_INITHACK },
{ {{SYS_VENDOR, "Dell Inc."}, {SYS_PRODUCT, "Latitude E4300 "}}, FL_INITHACK },
{ {{SYS_VENDOR, "Dell Inc."}, {SYS_PRODUCT, "Latitude E4310 "}}, FL_INITHACK },
{ {{SYS_VENDOR, "Dell Inc."}, {SYS_PRODUCT, "Latitude E6400 "}}, FL_INITHACK },
}

Definition at line 37 of file hwhacks.c.

Referenced by i8042ParseSMBiosTables().

◆ i8042HwFlags

ULONG i8042HwFlags

Definition at line 22 of file hwhacks.c.

Referenced by i8042ParseSMBiosTables(), and StartProcedure().

◆ i8042SMBiosTables

PVOID i8042SMBiosTables

Definition at line 21 of file hwhacks.c.

◆ MSSmBios_RawSMBiosTables_GUID

const GUID MSSmBios_RawSMBiosTables_GUID = SMBIOS_DATA_GUID