Reactos

[SETUPAPI] Implement SetupDiGetClassRegistryPropertyA and SetupDiSetClassRegistryPropertyA

+164 -4
+162 -2
dll/win32/setupapi/devclass.c
··· 1421 1421 } 1422 1422 1423 1423 /*********************************************************************** 1424 + * SetupDiGetClassRegistryPropertyA(SETUPAPI.@) 1425 + */ 1426 + BOOL WINAPI 1427 + SetupDiGetClassRegistryPropertyA( 1428 + IN CONST GUID *ClassGuid, 1429 + IN DWORD Property, 1430 + OUT PDWORD PropertyRegDataType OPTIONAL, 1431 + OUT PBYTE PropertyBuffer, 1432 + IN DWORD PropertyBufferSize, 1433 + OUT PDWORD RequiredSize OPTIONAL, 1434 + IN PCSTR MachineName OPTIONAL, 1435 + IN PVOID Reserved) 1436 + { 1437 + HMACHINE hMachine = NULL; 1438 + DWORD PropLength = 0; 1439 + DWORD Error = ERROR_SUCCESS; 1440 + CONFIGRET cr; 1441 + 1442 + TRACE("%s %lu %p %p %lu %p %s %p\n", 1443 + debugstr_guid(ClassGuid), Property, PropertyRegDataType, PropertyBuffer, 1444 + PropertyBufferSize, RequiredSize, MachineName, Reserved); 1445 + 1446 + if (Reserved != NULL) 1447 + { 1448 + SetLastError(ERROR_INVALID_PARAMETER); 1449 + return FALSE; 1450 + } 1451 + 1452 + if (MachineName) 1453 + { 1454 + cr = CM_Connect_MachineA(MachineName, &hMachine); 1455 + if (cr != CR_SUCCESS) 1456 + goto done; 1457 + } 1458 + 1459 + if (Property >= SPCRP_MAXIMUM_PROPERTY) 1460 + { 1461 + cr = CR_INVALID_PROPERTY; 1462 + goto done; 1463 + } 1464 + 1465 + PropLength = PropertyBufferSize; 1466 + cr = CM_Get_Class_Registry_PropertyA((LPGUID)ClassGuid, 1467 + Property + (CM_DRP_DEVICEDESC - SPDRP_DEVICEDESC), 1468 + PropertyRegDataType, 1469 + PropertyBuffer, 1470 + &PropLength, 1471 + 0, 1472 + hMachine); 1473 + if ((cr == CR_SUCCESS) || (cr == CR_BUFFER_SMALL)) 1474 + { 1475 + if (RequiredSize) 1476 + *RequiredSize = PropLength; 1477 + } 1478 + 1479 + done: 1480 + if (cr != CR_SUCCESS) 1481 + { 1482 + switch (cr) 1483 + { 1484 + case CR_INVALID_DEVINST : 1485 + Error = ERROR_NO_SUCH_DEVINST; 1486 + break; 1487 + 1488 + case CR_INVALID_PROPERTY : 1489 + Error = ERROR_INVALID_REG_PROPERTY; 1490 + break; 1491 + 1492 + case CR_BUFFER_SMALL : 1493 + Error = ERROR_INSUFFICIENT_BUFFER; 1494 + break; 1495 + 1496 + default : 1497 + Error = GetErrorCodeFromCrCode(cr); 1498 + } 1499 + } 1500 + 1501 + if (hMachine != NULL) 1502 + CM_Disconnect_Machine(hMachine); 1503 + 1504 + SetLastError(Error); 1505 + return (cr == CR_SUCCESS); 1506 + } 1507 + 1508 + /*********************************************************************** 1424 1509 * SetupDiGetClassRegistryPropertyW(SETUPAPI.@) 1425 1510 */ 1426 1511 BOOL WINAPI ··· 1451 1536 1452 1537 if (MachineName) 1453 1538 { 1454 - cr = CM_Connect_Machine(MachineName, &hMachine); 1539 + cr = CM_Connect_MachineW(MachineName, &hMachine); 1455 1540 if (cr != CR_SUCCESS) 1456 1541 goto done; 1457 1542 } ··· 1506 1591 } 1507 1592 1508 1593 /*********************************************************************** 1594 + * SetupDiSetClassRegistryPropertyA(SETUPAPI.@) 1595 + */ 1596 + BOOL WINAPI 1597 + SetupDiSetClassRegistryPropertyA( 1598 + IN CONST GUID *ClassGuid, 1599 + IN DWORD Property, 1600 + IN CONST BYTE *PropertyBuffer OPTIONAL, 1601 + IN DWORD PropertyBufferSize, 1602 + IN PCSTR MachineName OPTIONAL, 1603 + IN PVOID Reserved) 1604 + { 1605 + HMACHINE hMachine = NULL; 1606 + DWORD Error = ERROR_SUCCESS; 1607 + CONFIGRET cr; 1608 + 1609 + TRACE("%s %lu %p %lu %s %p\n", 1610 + debugstr_guid(ClassGuid), Property, PropertyBuffer, 1611 + PropertyBufferSize, MachineName, Reserved); 1612 + 1613 + if (Reserved != NULL) 1614 + { 1615 + SetLastError(ERROR_INVALID_PARAMETER); 1616 + return FALSE; 1617 + } 1618 + 1619 + if (MachineName) 1620 + { 1621 + cr = CM_Connect_MachineA(MachineName, &hMachine); 1622 + if (cr != CR_SUCCESS) 1623 + goto done; 1624 + } 1625 + 1626 + if (Property >= SPCRP_MAXIMUM_PROPERTY) 1627 + { 1628 + cr = CR_INVALID_PROPERTY; 1629 + goto done; 1630 + } 1631 + 1632 + cr = CM_Set_Class_Registry_PropertyA((LPGUID)ClassGuid, 1633 + Property + (CM_DRP_DEVICEDESC - SPDRP_DEVICEDESC), 1634 + PropertyBuffer, 1635 + PropertyBufferSize, 1636 + 0, 1637 + hMachine); 1638 + 1639 + done: 1640 + if (cr != CR_SUCCESS) 1641 + { 1642 + switch (cr) 1643 + { 1644 + case CR_INVALID_DEVINST: 1645 + Error = ERROR_NO_SUCH_DEVINST; 1646 + break; 1647 + 1648 + case CR_INVALID_PROPERTY: 1649 + Error = ERROR_INVALID_REG_PROPERTY; 1650 + break; 1651 + 1652 + case CR_BUFFER_SMALL: 1653 + Error = ERROR_INSUFFICIENT_BUFFER; 1654 + break; 1655 + 1656 + default : 1657 + Error = GetErrorCodeFromCrCode(cr); 1658 + } 1659 + } 1660 + 1661 + if (hMachine != NULL) 1662 + CM_Disconnect_Machine(hMachine); 1663 + 1664 + SetLastError(Error); 1665 + return (cr == CR_SUCCESS); 1666 + } 1667 + 1668 + /*********************************************************************** 1509 1669 * SetupDiSetClassRegistryPropertyW(SETUPAPI.@) 1510 1670 */ 1511 1671 BOOL WINAPI ··· 1533 1693 1534 1694 if (MachineName) 1535 1695 { 1536 - cr = CM_Connect_Machine(MachineName, &hMachine); 1696 + cr = CM_Connect_MachineW(MachineName, &hMachine); 1537 1697 if (cr != CR_SUCCESS) 1538 1698 goto done; 1539 1699 }
+2 -2
dll/win32/setupapi/setupapi.spec
··· 313 313 @ stdcall SetupDiGetClassImageListExW(ptr wstr ptr) 314 314 @ stdcall SetupDiGetClassInstallParamsA(ptr ptr ptr long ptr) 315 315 @ stdcall SetupDiGetClassInstallParamsW(ptr ptr ptr long ptr) 316 - @ stub SetupDiGetClassRegistryPropertyA 316 + @ stdcall SetupDiGetClassRegistryPropertyA(ptr long ptr ptr long ptr str ptr) 317 317 @ stdcall SetupDiGetClassRegistryPropertyW(ptr long ptr ptr long ptr wstr ptr) 318 318 @ stub SetupDiGetCustomDevicePropertyA 319 319 @ stub SetupDiGetCustomDevicePropertyW ··· 374 374 @ stub SetupDiSelectOEMDrv 375 375 @ stdcall SetupDiSetClassInstallParamsA(ptr ptr ptr long) 376 376 @ stdcall SetupDiSetClassInstallParamsW(ptr ptr ptr long) 377 - @ stub SetupDiSetClassRegistryPropertyA 377 + @ stdcall SetupDiSetClassRegistryPropertyA(ptr long ptr long str ptr) 378 378 @ stdcall SetupDiSetClassRegistryPropertyW(ptr long ptr long wstr ptr) 379 379 @ stdcall SetupDiSetDeviceInstallParamsA(ptr ptr ptr) 380 380 @ stdcall SetupDiSetDeviceInstallParamsW(ptr ptr ptr)