ReactOS  0.4.14-dev-52-g6116262
pnpdump.c File Reference
#include <windows.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <ntddk.h>
#include <pshpack1.h>
#include <poppack.h>
Include dependency graph for pnpdump.c:

Go to the source code of this file.

Classes

struct  _CM_PNP_BIOS_DEVICE_NODE
 
struct  _CM_PNP_BIOS_INSTALLATION_CHECK
 
struct  _PNP_ID_NAME_
 

Typedefs

typedef struct _CM_PNP_BIOS_DEVICE_NODE CM_PNP_BIOS_DEVICE_NODE
 
typedef struct _CM_PNP_BIOS_DEVICE_NODEPCM_PNP_BIOS_DEVICE_NODE
 
typedef struct _CM_PNP_BIOS_INSTALLATION_CHECK CM_PNP_BIOS_INSTALLATION_CHECK
 
typedef struct _CM_PNP_BIOS_INSTALLATION_CHECKPCM_PNP_BIOS_INSTALLATION_CHECK
 
typedef struct _PNP_ID_NAME_ PNP_ID_NAME
 
typedef struct _PNP_ID_NAME_PPNP_ID_NAME
 

Functions

static charGetDeviceName (char *PnpId)
 
LONG GetPnpKey (PHKEY PnpKey)
 
static VOID PnpDecodeIrq (unsigned char *Ptr)
 
static VOID PnpDecodeDma (unsigned char *Ptr)
 
static VOID PnpDecodeIoPort (unsigned char *Ptr)
 
static VOID PnpDecodeFixedIoPort (unsigned char *Ptr)
 
static VOID PnpDecodeMemory16 (unsigned char *Ptr)
 
static VOID PnpDecodeMemory32 (unsigned char *Ptr)
 
static VOID PnpDecodeFixedMemory (unsigned char *Ptr)
 
void PrintDeviceData (PCM_PNP_BIOS_DEVICE_NODE DeviceNode)
 
int main (int argc, char *argv[])
 

Variables

static char Hex [] = "0123456789ABCDEF"
 
static PNP_ID_NAME PnpName []
 

Typedef Documentation

◆ CM_PNP_BIOS_DEVICE_NODE

◆ CM_PNP_BIOS_INSTALLATION_CHECK

◆ PCM_PNP_BIOS_DEVICE_NODE

◆ PCM_PNP_BIOS_INSTALLATION_CHECK

◆ PNP_ID_NAME

◆ PPNP_ID_NAME

Function Documentation

◆ GetDeviceName()

static char* GetDeviceName ( char PnpId)
static

Definition at line 240 of file pnpdump.c.

241 {
242  PPNP_ID_NAME IdName;
243 
244  IdName = PnpName;
245  while (IdName->PnpId != NULL)
246  {
247  if (!strcmp(IdName->PnpId, PnpId))
248  return IdName->DeviceName;
249 
250  IdName++;
251  }
252 
253  return "Unknown Device";
254 }
char * PnpId
Definition: pnpdump.c:45
smooth NULL
Definition: ftsmooth.c:416
char * DeviceName
Definition: pnpdump.c:46
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
static PNP_ID_NAME PnpName[]
Definition: pnpdump.c:52

Referenced by PrintDeviceData().

◆ GetPnpKey()

LONG GetPnpKey ( PHKEY  PnpKey)

Definition at line 258 of file pnpdump.c.

259 {
260  LONG lError;
261  char szBuffer[80];
262  HKEY hAdapterKey;
263  HKEY hBusKey;
264  DWORD dwBus;
265  DWORD dwType;
266  DWORD dwSize;
267 
268  *PnpKey = 0;
269 
271  "HARDWARE\\DESCRIPTION\\System\\MultifunctionAdapter",
272  &hAdapterKey);
273  if (lError != ERROR_SUCCESS)
274  return 0;
275 
276  /* Enumerate buses */
277  for (dwBus = 0; ; dwBus++)
278  {
279  sprintf(szBuffer, "%lu", dwBus);
280 
281  lError = RegOpenKey(hAdapterKey,
282  szBuffer,
283  &hBusKey);
284  if (lError != ERROR_SUCCESS)
285  {
286  RegCloseKey(hAdapterKey);
287  return lError;
288  }
289 
290  dwSize = 80;
291  lError = RegQueryValueEx(hBusKey,
292  "Identifier",
293  NULL,
294  &dwType,
295  (LPBYTE)szBuffer,
296  &dwSize);
297  if (lError != ERROR_SUCCESS)
298  {
299  RegCloseKey(hBusKey);
300  RegCloseKey(hAdapterKey);
301  return lError;
302  }
303 
304  if (dwType == REG_SZ && stricmp(szBuffer, "pnp bios") == 0)
305  {
306  *PnpKey = hBusKey;
307  RegCloseKey(hAdapterKey);
308  return ERROR_SUCCESS;
309  }
310 
311  RegCloseKey(hBusKey);
312  }
313 
314  return 1;
315 }
#define RegQueryValueEx
Definition: winreg.h:524
#define ERROR_SUCCESS
Definition: deptool.c:10
#define sprintf(buf, format,...)
Definition: sprintf.c:55
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
_Check_return_ _CRTIMP int __cdecl stricmp(_In_z_ const char *_Str1, _In_z_ const char *_Str2)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define RegOpenKey
Definition: winreg.h:519
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22

Referenced by main().

◆ main()

int main ( int argc  ,
char argv[] 
)

hosttype.c Copyright (C) 2002 by Brian Palmer brian.nosp@m.p@sg.nosp@m.inet..nosp@m.com

Definition at line 670 of file pnpdump.c.

671 {
672  LONG lError;
673  HKEY hPnpKey;
674  DWORD dwType;
675  DWORD dwSize;
676  BOOL Ask;
679  PCM_PNP_BIOS_DEVICE_NODE lpDevNode;
680  DWORD dwDataSize;
681  DWORD dwResourceSize;
682 
683  hPnpKey = 0;
684 
685  Ask = TRUE;
686  if (argc >1 && (!strcmp(argv[1],"/S") || !strcmp(argv[1],"/s")))
687  {
688  Ask = FALSE;
689  }
690 
691  if (argc >1 && !strcmp(argv[1],"/?"))
692  {
693  printf("This utility prints the PnP-nodes from the registry\n");
694  printf("\"/s\" prevents the \"Press any key\"\n\n");
695  return 0;
696  }
697 
698  lError = GetPnpKey(&hPnpKey);
699  if (lError != ERROR_SUCCESS)
700  {
701  printf("Failed to get PnP-BIOS key\n");
702  return 0;
703  }
704 
705  if (hPnpKey != 0)
706  {
707  printf("Found PnP-BIOS key\n");
708  }
709 
710  /* Allocate buffer */
711  dwSize = 2048;
713  if (lpBuffer == NULL)
714  {
715  printf("Error: malloc() failed\n");
716  RegCloseKey(hPnpKey);
717  return 0;
718  }
719 
720  do
721  {
722  lError = RegQueryValueEx(hPnpKey,
723  "Configuration Data",
724  NULL,
725  &dwType,
726  (LPBYTE)lpBuffer,
727  &dwSize);
728  if (lError == ERROR_MORE_DATA)
729  {
731  if (lpBuffer == NULL)
732  {
733  printf("Error: realloc() of %u bytes failed\n", (unsigned) dwSize);
734  RegCloseKey(hPnpKey);
735  return 0;
736  }
737  }
738  }
739  while (lError == ERROR_MORE_DATA);
740  if (lError != ERROR_SUCCESS)
741  {
742  printf("Failed to read 'Configuration Data' value\n");
743  free(lpBuffer);
744  RegCloseKey(hPnpKey);
745  return 0;
746  }
747 
748 // printf ("Data size: %lu\n", dwSize);
749 
750  RegCloseKey(hPnpKey);
751 
752 // printf("Resource count %lu\n", lpBuffer->PartialResourceList.Count);
753 
754  if (lpBuffer->PartialResourceList.Count == 0)
755  {
756  printf("Invalid resource count!\n");
757  free(lpBuffer);
758  return 0;
759  }
760 
761 // printf("lpBuffer %p\n", lpBuffer);
762 
763  dwResourceSize = lpBuffer->PartialResourceList.PartialDescriptors[0].u.DeviceSpecificData.DataSize;
764 // printf("ResourceSize: %lu\n", dwResourceSize);
765 
766  lpPnpInst = (PCM_PNP_BIOS_INSTALLATION_CHECK)
767  ((ULONG_PTR)(&lpBuffer->PartialResourceList.PartialDescriptors[0]) +
769 
770 // printf("lpPnpInst %p\n", lpPnpInst);
771 
772  printf("Signature '%.4s'\n", lpPnpInst->Signature);
773  if (strncmp((PCHAR)lpPnpInst->Signature, "$PnP", 4))
774  {
775  printf("Error: Invalid PnP signature\n");
776  free(lpBuffer);
777  return 0;
778  }
779 
780 // printf("InstCheck length: %lu\n", lpPnpInst->Length);
781 
782  dwDataSize = sizeof(CM_PNP_BIOS_INSTALLATION_CHECK);
783  lpDevNode = (PCM_PNP_BIOS_DEVICE_NODE)((DWORD)lpPnpInst + sizeof(CM_PNP_BIOS_INSTALLATION_CHECK));
784 
785  if (lpDevNode->Size == 0)
786  {
787  printf("Error: Device node size is zero!\n");
788  return 0;
789  }
790 
791 #if 0
792  printf("Node: %x Size %hu (0x%hx)\n",
793  lpDevNode->Node,
794  lpDevNode->Size,
795  lpDevNode->Size);
796 
797  printf("Done.\n");
798 return 0;
799 #endif
800 
801 
802  while (dwDataSize < dwResourceSize)
803  {
804  if (lpDevNode->Size == 0)
805  break;
806 
807  printf("Node: %x Size %hu (0x%hx)\n",
808  lpDevNode->Node,
809  lpDevNode->Size,
810  lpDevNode->Size);
811 
812  dwDataSize += lpDevNode->Size;
813  lpDevNode = (PCM_PNP_BIOS_DEVICE_NODE)((DWORD)lpDevNode + lpDevNode->Size);
814  }
815 
816  if (Ask)
817  {
818  printf("\n Press any key...\n");
819  getch();
820  }
821  else
822  {
823  printf("\n");
824  }
825 
826  dwDataSize = sizeof(CM_PNP_BIOS_INSTALLATION_CHECK);
827  lpDevNode = (PCM_PNP_BIOS_DEVICE_NODE)((DWORD)lpPnpInst + sizeof(CM_PNP_BIOS_INSTALLATION_CHECK));
828 
829  while (dwDataSize < dwResourceSize)
830  {
831  if (lpDevNode->Size == 0)
832  break;
833 
834  PrintDeviceData(lpDevNode);
835 
836  if (Ask)
837  {
838  printf("\n Press any key...\n");
839  getch();
840  }
841  else
842  {
843  printf("\n");
844  }
845 
846  dwDataSize += lpDevNode->Size;
847  lpDevNode = (PCM_PNP_BIOS_DEVICE_NODE)((DWORD)lpDevNode + lpDevNode->Size);
848  }
849 
850  free(lpBuffer);
851 
852  return 0;
853 }
#define realloc
Definition: debug_ros.c:6
#define RegQueryValueEx
Definition: winreg.h:524
signed char * PCHAR
Definition: retypes.h:7
static int argc
Definition: ServiceArgs.c:12
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
struct _CM_PNP_BIOS_INSTALLATION_CHECK * PCM_PNP_BIOS_INSTALLATION_CHECK
#define free
Definition: debug_ros.c:5
LONG GetPnpKey(PHKEY PnpKey)
Definition: pnpdump.c:258
struct _CM_PNP_BIOS_DEVICE_NODE * PCM_PNP_BIOS_DEVICE_NODE
#define argv
Definition: mplay32.c:18
uint32_t ULONG_PTR
Definition: typedefs.h:63
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
smooth NULL
Definition: ftsmooth.c:416
struct _CM_PNP_BIOS_INSTALLATION_CHECK CM_PNP_BIOS_INSTALLATION_CHECK
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERROR_MORE_DATA
Definition: dderror.h:13
_Check_return_ _CRTIMP int __cdecl getch(void)
void PrintDeviceData(PCM_PNP_BIOS_DEVICE_NODE DeviceNode)
Definition: pnpdump.c:550
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define malloc
Definition: debug_ros.c:4
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define printf
Definition: config.h:203

◆ PnpDecodeDma()

static VOID PnpDecodeDma ( unsigned char Ptr)
static

Definition at line 343 of file pnpdump.c.

344 {
345  unsigned char DmaChannel;
346  unsigned char DmaStatus;
347  int i;
348 
349  DmaChannel = *Ptr;
350  Ptr++;
351  DmaStatus = *Ptr;
352 
353  printf(" DMAs:");
354 
355  for (i = 0; i < 8; i++)
356  {
357  if (DmaChannel & (1 << i))
358  {
359  printf(" %u", i);
360  }
361  }
362 
363  printf("\n");
364 }
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
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 printf
Definition: config.h:203

Referenced by PrintDeviceData().

◆ PnpDecodeFixedIoPort()

static VOID PnpDecodeFixedIoPort ( unsigned char Ptr)
static

Definition at line 396 of file pnpdump.c.

397 {
398  USHORT IoPort;
399  UCHAR Length;
400 
401  IoPort = *Ptr;
402  Ptr++;
403  IoPort += (*Ptr << 8);
404  Ptr++;
405  Length = *Ptr;
406 
407  printf(" Fixed I/O Port descriptor\n");
408  printf(" PortBase 0x%hx Length 0x%x\n",
409  IoPort, Length);
410 
411 #if 0
412  if (Length == 1)
413  {
414  printf(" Fixed location I/O Port descriptor: 0x%x\n",
415  IoPort);
416  }
417  else
418  {
419  printf(" Fixed location I/O Port descriptor: 0x%x - 0x%x\n",
420  IoPort,
421  IoPort + Length - 1);
422  }
423 #endif
424 }
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned short USHORT
Definition: pedump.c:61
#define printf
Definition: config.h:203

Referenced by PrintDeviceData().

◆ PnpDecodeFixedMemory()

static VOID PnpDecodeFixedMemory ( unsigned char Ptr)
static

Definition at line 518 of file pnpdump.c.

519 {
520  UCHAR Info;
521  ULONG Base;
522  ULONG Length;
523 
524  Info = *Ptr;
525  Ptr++;
526 
527  Base = *Ptr;
528  Ptr++;
529  Base += (*Ptr << 8);
530  Ptr++;
531  Base += (*Ptr << 16);
532  Ptr++;
533  Base += (*Ptr << 24);
534  Ptr++;
535 
536  Length = *Ptr;
537  Ptr++;
538  Length += (*Ptr << 8);
539  Ptr++;
540  Length += (*Ptr << 16);
541  Ptr++;
542  Length += (*Ptr << 24);
543 
544  printf(" 32-Bit fixed location memory range descriptor\n");
545  printf(" Base 0x%lx Length 0x%lx Flags 0x%02x\n",
546  Base, Length, Info);
547 }
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2343
struct TraceInfo Info
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned int ULONG
Definition: retypes.h:1
#define printf
Definition: config.h:203

Referenced by PrintDeviceData().

◆ PnpDecodeIoPort()

static VOID PnpDecodeIoPort ( unsigned char Ptr)
static

Definition at line 368 of file pnpdump.c.

369 {
370  USHORT MinBase;
371  USHORT MaxBase;
372  UCHAR Align;
373  UCHAR Length;
374 
375  // Info = *Ptr;
376  Ptr++;
377  MinBase = *Ptr;
378  Ptr++;
379  MinBase += (*Ptr << 8);
380  Ptr++;
381  MaxBase = *Ptr;
382  Ptr++;
383  MaxBase += (*Ptr << 8);
384  Ptr++;
385  Align = *Ptr;
386  Ptr++;
387  Length = *Ptr;
388 
389  printf(" I/O Port descriptor\n");
390  printf(" MinBase 0x%x MaxBase 0x%x Align %u Length %u\n",
391  MinBase, MaxBase, Align, Length);
392 }
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned short USHORT
Definition: pedump.c:61
#define printf
Definition: config.h:203

Referenced by PrintDeviceData().

◆ PnpDecodeIrq()

static VOID PnpDecodeIrq ( unsigned char Ptr)
static

Definition at line 319 of file pnpdump.c.

320 {
321  USHORT IrqMask;
322  int i;
323 
324  IrqMask = *Ptr;
325  Ptr++;
326  IrqMask |= (*Ptr << 8);
327 
328  printf(" IRQs:");
329 
330  for (i = 0; i < 16; i++)
331  {
332  if (IrqMask & (1 << i))
333  {
334  printf(" %u", i);
335  }
336  }
337 
338  printf("\n");
339 }
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
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
unsigned short USHORT
Definition: pedump.c:61
#define printf
Definition: config.h:203

Referenced by PrintDeviceData().

◆ PnpDecodeMemory16()

static VOID PnpDecodeMemory16 ( unsigned char Ptr)
static

Definition at line 428 of file pnpdump.c.

429 {
430  UCHAR Info;
431  USHORT MinBase;
432  USHORT MaxBase;
433  USHORT Align;
434  USHORT Length;
435 
436  Info = *Ptr;
437  Ptr++;
438 
439  MinBase = *Ptr;
440  Ptr++;
441  MinBase += (*Ptr << 8);
442  Ptr++;
443 
444  MaxBase = *Ptr;
445  Ptr++;
446  MaxBase += (*Ptr << 8);
447  Ptr++;
448 
449  Align = *Ptr;
450  Ptr++;
451  Align += (*Ptr << 8);
452  Ptr++;
453 
454  Length = *Ptr;
455  Ptr++;
456  Length += (*Ptr << 8);
457 
458  printf(" 16-Bit memory range descriptor\n");
459  printf(" MinBase 0x%hx MaxBase 0x%hx Align 0x%hx Length 0x%hx Flags 0x%02x\n",
460  MinBase, MaxBase, Align,Length, Info);
461 }
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
struct TraceInfo Info
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned short USHORT
Definition: pedump.c:61
#define printf
Definition: config.h:203

Referenced by PrintDeviceData().

◆ PnpDecodeMemory32()

static VOID PnpDecodeMemory32 ( unsigned char Ptr)
static

Definition at line 465 of file pnpdump.c.

466 {
467  UCHAR Info;
468  ULONG MinBase;
469  ULONG MaxBase;
470  ULONG Align;
471  ULONG Length;
472 
473  Info = *Ptr;
474  Ptr++;
475 
476  MinBase = *Ptr;
477  Ptr++;
478  MinBase += (*Ptr << 8);
479  Ptr++;
480  MinBase += (*Ptr << 16);
481  Ptr++;
482  MinBase += (*Ptr << 24);
483  Ptr++;
484 
485  MaxBase = *Ptr;
486  Ptr++;
487  MaxBase += (*Ptr << 8);
488  Ptr++;
489  MaxBase += (*Ptr << 16);
490  Ptr++;
491  MaxBase += (*Ptr << 24);
492  Ptr++;
493 
494  Align = *Ptr;
495  Ptr++;
496  Align += (*Ptr << 8);
497  Ptr++;
498  Align += (*Ptr << 16);
499  Ptr++;
500  Align += (*Ptr << 24);
501  Ptr++;
502 
503  Length = *Ptr;
504  Ptr++;
505  Length += (*Ptr << 8);
506  Ptr++;
507  Length += (*Ptr << 16);
508  Ptr++;
509  Length += (*Ptr << 24);
510 
511  printf(" 32-Bit memory range descriptor\n");
512  printf(" MinBase 0x%lx MaxBase 0x%lx Align 0x%lx Length 0x%lx Flags 0x%02x\n",
513  MinBase, MaxBase, Align,Length, Info);
514 }
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
struct TraceInfo Info
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned int ULONG
Definition: retypes.h:1
#define printf
Definition: config.h:203

Referenced by PrintDeviceData().

◆ PrintDeviceData()

void PrintDeviceData ( PCM_PNP_BIOS_DEVICE_NODE  DeviceNode)

Definition at line 550 of file pnpdump.c.

551 {
552  char PnpId[8];
553  unsigned char *Ptr;
554  unsigned int TagSize;
555  unsigned int TagType;
556 
557  unsigned char Id[4];
558 
559  printf ("Node: %x Size %hu (0x%hx)\n",
560  DeviceNode->Node,
561  DeviceNode->Size,
562  DeviceNode->Size);
563 
564  memcpy(Id, &DeviceNode->ProductId, 4);
565 
566  PnpId[0] = ((Id[0] >> 2) & 0x1F) + 0x40;
567  PnpId[1] = ((Id[0] << 3) & 0x18) +
568  ((Id[1] >> 5) & 0x07) + 0x40;
569  PnpId[2] = (Id[1] & 0x1F) + 0x40;
570 
571  PnpId[3] = Hex[(Id[2] >> 4) & 0xF];
572  PnpId[4] = Hex[Id[2] & 0x0F];
573 
574  PnpId[5] = Hex[(Id[3] >> 4) & 0x0F];
575  PnpId[6] = Hex[Id[3] & 0x0F];
576  PnpId[7] = 0;
577 
578  printf(" '%s' (%s)\n",
579  PnpId, GetDeviceName(PnpId));
580 
581  if (DeviceNode->Size > sizeof(CM_PNP_BIOS_DEVICE_NODE))
582  {
583  Ptr = (unsigned char *)(DeviceNode + 1);
584  while (TRUE)
585  {
586  if (*Ptr & 0x80)
587  {
588  TagType = *Ptr & 0x7F;
589  Ptr++;
590  TagSize = *Ptr;
591  Ptr++;
592  TagSize += (*Ptr << 16);
593  Ptr++;
594 
595 
596  switch (TagType)
597  {
598  case 1:
600  break;
601 
602  case 5:
604  break;
605 
606  case 6:
608  break;
609 
610  default:
611  printf(" Large tag: type %u size %u\n",
612  TagType,
613  TagSize);
614  break;
615  }
616  }
617  else
618  {
619  TagType = (*Ptr >> 3) & 0x0F;
620  TagSize = *Ptr & 0x07;
621  Ptr++;
622 
623  switch (TagType)
624  {
625  case 2:
626  printf(" Logical device ID\n");
627  break;
628 
629  case 3:
630  printf(" Compatible device ID\n");
631  break;
632 
633  case 4:
634  PnpDecodeIrq(Ptr);
635  break;
636 
637  case 5:
638  PnpDecodeDma(Ptr);
639  break;
640 
641  case 8:
643  break;
644 
645  case 9:
647  break;
648 
649  case 0x0F: /* end tag */
650  break;
651 
652  default:
653  printf(" Small tag: type %u size %u\n",
654  TagType,
655  TagSize);
656  break;
657  }
658 
659  /* end tag */
660  if (TagType == 0x0F)
661  break;
662  }
663 
664  Ptr = Ptr + TagSize;
665  }
666  }
667 }
static VOID PnpDecodeIoPort(unsigned char *Ptr)
Definition: pnpdump.c:368
#define TRUE
Definition: types.h:120
static VOID PnpDecodeMemory16(unsigned char *Ptr)
Definition: pnpdump.c:428
static VOID PnpDecodeFixedMemory(unsigned char *Ptr)
Definition: pnpdump.c:518
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
static VOID PnpDecodeDma(unsigned char *Ptr)
Definition: pnpdump.c:343
static char * GetDeviceName(char *PnpId)
Definition: pnpdump.c:240
DWORD Id
static VOID PnpDecodeIrq(unsigned char *Ptr)
Definition: pnpdump.c:319
Definition: Node.h:9
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static VOID PnpDecodeFixedIoPort(unsigned char *Ptr)
Definition: pnpdump.c:396
static char Hex[]
Definition: pnpdump.c:50
static VOID PnpDecodeMemory32(unsigned char *Ptr)
Definition: pnpdump.c:465
#define printf
Definition: config.h:203

Referenced by main().

Variable Documentation

◆ Hex

char Hex[] = "0123456789ABCDEF"
static

Definition at line 50 of file pnpdump.c.

Referenced by PrintDeviceData().

◆ PnpName

PNP_ID_NAME PnpName[]
static

Definition at line 52 of file pnpdump.c.

Referenced by CompareProductName(), FindProductName(), and GetDeviceName().