MCPcopy Create free account
hub / github.com/NullArray/WinKernel-Resources / GetDevMultiSz

Function GetDevMultiSz

Drivers/Driver-SRC/setup/devcon/devcon.cpp:493–553  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

491
492__drv_allocatesMem(object)
493LPTSTR * GetDevMultiSz(_In_ HDEVINFO Devs, _In_ PSP_DEVINFO_DATA DevInfo, _In_ DWORD Prop)
494/*++
495
496Routine Description:
497
498 Get a multi-sz device property
499 and return as an array of strings
500
501Arguments:
502
503 Devs - HDEVINFO containing DevInfo
504 DevInfo - Specific device
505 Prop - SPDRP_HARDWAREID or SPDRP_COMPATIBLEIDS
506
507Return Value:
508
509 array of strings. last entry+1 of array contains NULL
510 returns NULL on failure
511
512--*/
513{
514 LPTSTR buffer;
515 DWORD size;
516 DWORD reqSize;
517 DWORD dataType;
518 LPTSTR * array;
519 DWORD szChars;
520
521 size = 8192; // initial guess, nothing magic about this
522 buffer = new TCHAR[(size/sizeof(TCHAR))+2];
523 if(!buffer) {
524 return NULL;
525 }
526 while(!SetupDiGetDeviceRegistryProperty(Devs,DevInfo,Prop,&dataType,(LPBYTE)buffer,size,&reqSize)) {
527 if(GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
528 goto failed;
529 }
530 if(dataType != REG_MULTI_SZ) {
531 goto failed;
532 }
533 size = reqSize;
534 delete [] buffer;
535 buffer = new TCHAR[(size/sizeof(TCHAR))+2];
536 if(!buffer) {
537 goto failed;
538 }
539 }
540 szChars = reqSize/sizeof(TCHAR);
541 buffer[szChars] = TEXT('\0');
542 buffer[szChars+1] = TEXT('\0');
543 array = GetMultiSzIndexArray(buffer);
544 if(array) {
545 return array;
546 }
547
548failed:
549 if(buffer) {
550 delete [] buffer;

Callers 4

EnumerateDevicesFunction · 0.85
DumpDeviceHwIdsFunction · 0.85
DumpDeviceStackFunction · 0.85
SetHwidCallbackFunction · 0.85

Calls 1

GetMultiSzIndexArrayFunction · 0.85

Tested by

no test coverage detected