Stop dumping PnP nodes at an empty node.

svn path=/trunk/; revision=9795
This commit is contained in:
Eric Kohl 2004-06-21 12:12:01 +00:00
parent a10440fe8a
commit 62e0fe6b5e

View file

@ -671,29 +671,28 @@ int main (int argc, char *argv[])
HKEY hPnpKey; HKEY hPnpKey;
DWORD dwType; DWORD dwType;
DWORD dwSize; DWORD dwSize;
BOOL Ask = TRUE; BOOL Ask;
PCM_FULL_RESOURCE_DESCRIPTOR lpBuffer; PCM_FULL_RESOURCE_DESCRIPTOR lpBuffer;
PCM_PNP_BIOS_INSTALLATION_CHECK lpPnpInst; PCM_PNP_BIOS_INSTALLATION_CHECK lpPnpInst;
PCM_PNP_BIOS_DEVICE_NODE lpDevNode; PCM_PNP_BIOS_DEVICE_NODE lpDevNode;
DWORD dwDataSize;
DWORD dwDataSize, dwResourceSize; DWORD dwResourceSize;
hPnpKey = 0; hPnpKey = 0;
if (argc >1 && (!strcmp (argv[1],"/S") || !strcmp (argv[1],"/s"))) Ask = TRUE;
if (argc >1 && (!strcmp(argv[1],"/S") || !strcmp(argv[1],"/s")))
{ {
Ask = FALSE; Ask = FALSE;
} }
if (argc >1 && !strcmp (argv[1],"/?")) if (argc >1 && !strcmp(argv[1],"/?"))
{ {
printf ("This utility prints the PnP-nodes from the registry\n"); printf("This utility prints the PnP-nodes from the registry\n");
printf ("\"/s\" prevents the \"Press any key\"\n\n"); printf("\"/s\" prevents the \"Press any key\"\n\n");
return 0; return 0;
} }
lError = GetPnpKey(&hPnpKey); lError = GetPnpKey(&hPnpKey);
if (lError != ERROR_SUCCESS) if (lError != ERROR_SUCCESS)
{ {
@ -709,6 +708,12 @@ int main (int argc, char *argv[])
/* Allocate buffer */ /* Allocate buffer */
dwSize = 1024; dwSize = 1024;
lpBuffer = malloc(dwSize); lpBuffer = malloc(dwSize);
if (lpBuffer == NULL)
{
printf("Error: malloc() failed\n");
RegCloseKey(hPnpKey);
return 0;
}
lError = RegQueryValueEx(hPnpKey, lError = RegQueryValueEx(hPnpKey,
"Configuration Data", "Configuration Data",
@ -721,11 +726,10 @@ int main (int argc, char *argv[])
if (lError == ERROR_MORE_DATA) if (lError == ERROR_MORE_DATA)
{ {
printf("Need to resize buffer to %lu\n", dwSize); printf("Need to resize buffer to %lu\n", dwSize);
} }
printf("Failed to read 'Configuration Data' value\n"); printf("Failed to read 'Configuration Data' value\n");
free (lpBuffer); free(lpBuffer);
RegCloseKey(hPnpKey); RegCloseKey(hPnpKey);
return 0; return 0;
} }
@ -739,7 +743,7 @@ int main (int argc, char *argv[])
if (lpBuffer->PartialResourceList.Count == 0) if (lpBuffer->PartialResourceList.Count == 0)
{ {
printf("Invalid resource count!\n"); printf("Invalid resource count!\n");
free (lpBuffer); free(lpBuffer);
return 0; return 0;
} }
@ -774,7 +778,7 @@ int main (int argc, char *argv[])
} }
#if 0 #if 0
printf ("Node: %x Size %hu (0x%hx)\n", printf("Node: %x Size %hu (0x%hx)\n",
lpDevNode->Node, lpDevNode->Node,
lpDevNode->Size, lpDevNode->Size,
lpDevNode->Size); lpDevNode->Size);
@ -789,10 +793,10 @@ return 0;
if (lpDevNode->Size == 0) if (lpDevNode->Size == 0)
break; break;
printf ("Node: %x Size %hu (0x%hx)\n", printf("Node: %x Size %hu (0x%hx)\n",
lpDevNode->Node, lpDevNode->Node,
lpDevNode->Size, lpDevNode->Size,
lpDevNode->Size); lpDevNode->Size);
dwDataSize += lpDevNode->Size; dwDataSize += lpDevNode->Size;
lpDevNode = (PCM_PNP_BIOS_DEVICE_NODE)((DWORD)lpDevNode + lpDevNode->Size); lpDevNode = (PCM_PNP_BIOS_DEVICE_NODE)((DWORD)lpDevNode + lpDevNode->Size);
@ -800,12 +804,12 @@ return 0;
if (Ask) if (Ask)
{ {
printf ("\n Press any key...\n"); printf("\n Press any key...\n");
getch(); getch();
} }
else else
{ {
printf ("\n"); printf("\n");
} }
dwDataSize = sizeof(CM_PNP_BIOS_INSTALLATION_CHECK); dwDataSize = sizeof(CM_PNP_BIOS_INSTALLATION_CHECK);
@ -813,23 +817,26 @@ return 0;
while (dwDataSize < dwResourceSize) while (dwDataSize < dwResourceSize)
{ {
PrintDeviceData (lpDevNode); if (lpDevNode->Size == 0)
break;
PrintDeviceData(lpDevNode);
if (Ask) if (Ask)
{ {
printf ("\n Press any key...\n"); printf("\n Press any key...\n");
getch(); getch();
} }
else else
{ {
printf ("\n"); printf("\n");
} }
dwDataSize += lpDevNode->Size; dwDataSize += lpDevNode->Size;
lpDevNode = (PCM_PNP_BIOS_DEVICE_NODE)((DWORD)lpDevNode + lpDevNode->Size); lpDevNode = (PCM_PNP_BIOS_DEVICE_NODE)((DWORD)lpDevNode + lpDevNode->Size);
} }
free (lpBuffer); free(lpBuffer);
return 0; return 0;
} }