1c2c66affSColin Finck /* 2c2c66affSColin Finck * Configuration manager functions 3c2c66affSColin Finck * 4c2c66affSColin Finck * Copyright 2000 James Hatheway 5c2c66affSColin Finck * Copyright 2005, 2006 Eric Kohl 6c2c66affSColin Finck * 7c2c66affSColin Finck * This library is free software; you can redistribute it and/or 8c2c66affSColin Finck * modify it under the terms of the GNU Lesser General Public 9c2c66affSColin Finck * License as published by the Free Software Foundation; either 10c2c66affSColin Finck * version 2.1 of the License, or (at your option) any later version. 11c2c66affSColin Finck * 12c2c66affSColin Finck * This library is distributed in the hope that it will be useful, 13c2c66affSColin Finck * but WITHOUT ANY WARRANTY; without even the implied warranty of 14c2c66affSColin Finck * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15c2c66affSColin Finck * Lesser General Public License for more details. 16c2c66affSColin Finck * 17c2c66affSColin Finck * You should have received a copy of the GNU Lesser General Public 18c2c66affSColin Finck * License along with this library; if not, write to the Free Software 19c2c66affSColin Finck * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 20c2c66affSColin Finck */ 21c2c66affSColin Finck 22c2c66affSColin Finck #include "setupapi_private.h" 23c2c66affSColin Finck 24c2c66affSColin Finck #include <dbt.h> 25c2c66affSColin Finck #include <pnp_c.h> 26c2c66affSColin Finck 27c2c66affSColin Finck #include "rpc_private.h" 28c2c66affSColin Finck 29c2c66affSColin Finck /* Registry key and value names */ 30c2c66affSColin Finck static const WCHAR Backslash[] = {'\\', 0}; 31c2c66affSColin Finck static const WCHAR Class[] = {'C','l','a','s','s',0}; 32c2c66affSColin Finck 33c2c66affSColin Finck static const WCHAR ControlClass[] = {'S','y','s','t','e','m','\\', 34c2c66affSColin Finck 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\', 35c2c66affSColin Finck 'C','o','n','t','r','o','l','\\', 36c2c66affSColin Finck 'C','l','a','s','s',0}; 37c2c66affSColin Finck 38c2c66affSColin Finck static const WCHAR DeviceClasses[] = {'S','y','s','t','e','m','\\', 39c2c66affSColin Finck 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\', 40c2c66affSColin Finck 'C','o','n','t','r','o','l','\\', 41c2c66affSColin Finck 'D','e','v','i','c','e','C','l','a','s','s','e','s',0}; 42c2c66affSColin Finck 43c2c66affSColin Finck typedef struct _MACHINE_INFO 44c2c66affSColin Finck { 45c2c66affSColin Finck WCHAR szMachineName[SP_MAX_MACHINENAME_LENGTH]; 46c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle; 47c2c66affSColin Finck HSTRING_TABLE StringTable; 48c2c66affSColin Finck BOOL bLocal; 49c2c66affSColin Finck } MACHINE_INFO, *PMACHINE_INFO; 50c2c66affSColin Finck 51c2c66affSColin Finck 52c2c66affSColin Finck typedef struct _LOG_CONF_INFO 53c2c66affSColin Finck { 54c2c66affSColin Finck ULONG ulMagic; 55c2c66affSColin Finck DEVINST dnDevInst; 56c2c66affSColin Finck ULONG ulFlags; 57c2c66affSColin Finck ULONG ulTag; 58c2c66affSColin Finck } LOG_CONF_INFO, *PLOG_CONF_INFO; 59c2c66affSColin Finck 60c2c66affSColin Finck #define LOG_CONF_MAGIC 0x464E434C /* "LCNF" */ 61c2c66affSColin Finck 62c2c66affSColin Finck 63c2c66affSColin Finck typedef struct _NOTIFY_DATA 64c2c66affSColin Finck { 65c2c66affSColin Finck ULONG ulMagic; 66c2c66affSColin Finck ULONG ulNotifyData; 67c2c66affSColin Finck } NOTIFY_DATA, *PNOTIFY_DATA; 68c2c66affSColin Finck 69c2c66affSColin Finck #define NOTIFY_MAGIC 0x44556677 70c2c66affSColin Finck 71c2c66affSColin Finck 723ad5c7fdSEric Kohl typedef struct _INTERNAL_RANGE 73c2c66affSColin Finck { 743ad5c7fdSEric Kohl LIST_ENTRY ListEntry; 753ad5c7fdSEric Kohl DWORDLONG ullStart; 763ad5c7fdSEric Kohl DWORDLONG ullEnd; 773ad5c7fdSEric Kohl } INTERNAL_RANGE, *PINTERNAL_RANGE; 78c2c66affSColin Finck 79c2c66affSColin Finck typedef struct _INTERNAL_RANGE_LIST 80c2c66affSColin Finck { 81c2c66affSColin Finck ULONG ulMagic; 823ad5c7fdSEric Kohl HANDLE hMutex; 833ad5c7fdSEric Kohl LIST_ENTRY ListHead; 84c2c66affSColin Finck } INTERNAL_RANGE_LIST, *PINTERNAL_RANGE_LIST; 85c2c66affSColin Finck 86c2c66affSColin Finck #define RANGE_LIST_MAGIC 0x33445566 87c2c66affSColin Finck 88c2c66affSColin Finck 89d9a33981SEric Kohl static 90d9a33981SEric Kohl BOOL 91d9a33981SEric Kohl GuidToString( 92d9a33981SEric Kohl _In_ LPGUID Guid, 93d9a33981SEric Kohl _Out_ LPWSTR String) 94c2c66affSColin Finck { 95c2c66affSColin Finck LPWSTR lpString; 96c2c66affSColin Finck 97c2c66affSColin Finck if (UuidToStringW(Guid, &lpString) != RPC_S_OK) 98c2c66affSColin Finck return FALSE; 99c2c66affSColin Finck 100c2c66affSColin Finck lstrcpyW(&String[1], lpString); 101c2c66affSColin Finck 102c2c66affSColin Finck String[0] = '{'; 103c2c66affSColin Finck String[MAX_GUID_STRING_LEN - 2] = '}'; 104c2c66affSColin Finck String[MAX_GUID_STRING_LEN - 1] = UNICODE_NULL; 105c2c66affSColin Finck 106c2c66affSColin Finck RpcStringFreeW(&lpString); 107c2c66affSColin Finck 108c2c66affSColin Finck return TRUE; 109c2c66affSColin Finck } 110c2c66affSColin Finck 111c2c66affSColin Finck 112d9a33981SEric Kohl static 113d9a33981SEric Kohl CONFIGRET 114d9a33981SEric Kohl RpcStatusToCmStatus( 115d9a33981SEric Kohl _In_ RPC_STATUS Status) 116c2c66affSColin Finck { 117c2c66affSColin Finck return CR_FAILURE; 118c2c66affSColin Finck } 119c2c66affSColin Finck 120c2c66affSColin Finck 121c2c66affSColin Finck static 122c2c66affSColin Finck ULONG 123c2c66affSColin Finck GetRegistryPropertyType( 124d9a33981SEric Kohl _In_ ULONG ulProperty) 125c2c66affSColin Finck { 126c2c66affSColin Finck switch (ulProperty) 127c2c66affSColin Finck { 128c2c66affSColin Finck case CM_DRP_DEVICEDESC: 129c2c66affSColin Finck case CM_DRP_SERVICE: 130c2c66affSColin Finck case CM_DRP_CLASS: 131c2c66affSColin Finck case CM_DRP_CLASSGUID: 132c2c66affSColin Finck case CM_DRP_DRIVER: 133c2c66affSColin Finck case CM_DRP_MFG: 134c2c66affSColin Finck case CM_DRP_FRIENDLYNAME: 135c2c66affSColin Finck case CM_DRP_LOCATION_INFORMATION: 136c2c66affSColin Finck case CM_DRP_PHYSICAL_DEVICE_OBJECT_NAME: 137c2c66affSColin Finck case CM_DRP_ENUMERATOR_NAME: 138c2c66affSColin Finck case CM_DRP_SECURITY_SDS: 139c2c66affSColin Finck case CM_DRP_UI_NUMBER_DESC_FORMAT: 140c2c66affSColin Finck return REG_SZ; 141c2c66affSColin Finck 142c2c66affSColin Finck case CM_DRP_HARDWAREID: 143c2c66affSColin Finck case CM_DRP_COMPATIBLEIDS: 144c2c66affSColin Finck case CM_DRP_UPPERFILTERS: 145c2c66affSColin Finck case CM_DRP_LOWERFILTERS: 146c2c66affSColin Finck return REG_MULTI_SZ; 147c2c66affSColin Finck 148c2c66affSColin Finck case CM_DRP_CONFIGFLAGS: 149c2c66affSColin Finck case CM_DRP_CAPABILITIES: 150c2c66affSColin Finck case CM_DRP_UI_NUMBER: 151c2c66affSColin Finck case CM_DRP_LEGACYBUSTYPE: 152c2c66affSColin Finck case CM_DRP_BUSNUMBER: 153c2c66affSColin Finck case CM_DRP_DEVTYPE: 154c2c66affSColin Finck case CM_DRP_EXCLUSIVE: 155c2c66affSColin Finck case CM_DRP_CHARACTERISTICS: 156c2c66affSColin Finck case CM_DRP_ADDRESS: 157c2c66affSColin Finck case CM_DRP_REMOVAL_POLICY: 158c2c66affSColin Finck case CM_DRP_REMOVAL_POLICY_HW_DEFAULT: 159c2c66affSColin Finck case CM_DRP_REMOVAL_POLICY_OVERRIDE: 160c2c66affSColin Finck case CM_DRP_INSTALL_STATE: 161c2c66affSColin Finck return REG_DWORD; 162c2c66affSColin Finck 163c2c66affSColin Finck case CM_DRP_BUSTYPEGUID: 164c2c66affSColin Finck case CM_DRP_SECURITY: 165c2c66affSColin Finck case CM_DRP_DEVICE_POWER_DATA: 166c2c66affSColin Finck default: 167c2c66affSColin Finck return REG_BINARY; 168c2c66affSColin Finck } 169c2c66affSColin Finck 170c2c66affSColin Finck return REG_NONE; 171c2c66affSColin Finck } 172c2c66affSColin Finck 173c2c66affSColin Finck 17478cf2a04SEric Kohl static 17578cf2a04SEric Kohl VOID 17678cf2a04SEric Kohl SplitDeviceInstanceId( 17778cf2a04SEric Kohl _In_ PWSTR pszDeviceInstanceId, 17878cf2a04SEric Kohl _Out_ PWSTR pszDeviceId, 17978cf2a04SEric Kohl _Out_ PWSTR pszInstanceId) 18078cf2a04SEric Kohl { 18178cf2a04SEric Kohl PWCHAR ptr; 18278cf2a04SEric Kohl 18378cf2a04SEric Kohl wcscpy(pszDeviceId, pszDeviceInstanceId); 18478cf2a04SEric Kohl 18578cf2a04SEric Kohl ptr = wcschr(pszDeviceId, L'\\'); 18678cf2a04SEric Kohl if (ptr != NULL) 18778cf2a04SEric Kohl { 18878cf2a04SEric Kohl *ptr = UNICODE_NULL; 18978cf2a04SEric Kohl ptr++; 19078cf2a04SEric Kohl 19178cf2a04SEric Kohl wcscpy(pszInstanceId, ptr); 19278cf2a04SEric Kohl } 19378cf2a04SEric Kohl else 19478cf2a04SEric Kohl { 19578cf2a04SEric Kohl *pszInstanceId = UNICODE_NULL; 19678cf2a04SEric Kohl } 19778cf2a04SEric Kohl } 19878cf2a04SEric Kohl 19978cf2a04SEric Kohl 20078cf2a04SEric Kohl static 20178cf2a04SEric Kohl CONFIGRET 20278cf2a04SEric Kohl GetDeviceInstanceKeyPath( 20378cf2a04SEric Kohl _In_ RPC_BINDING_HANDLE BindingHandle, 20478cf2a04SEric Kohl _In_ PWSTR pszDeviceInst, 20578cf2a04SEric Kohl _Out_ PWSTR pszKeyPath, 20678cf2a04SEric Kohl _Out_ PWSTR pszInstancePath, 20778cf2a04SEric Kohl _In_ ULONG ulHardwareProfile, 20878cf2a04SEric Kohl _In_ ULONG ulFlags) 20978cf2a04SEric Kohl { 21078cf2a04SEric Kohl PWSTR pszBuffer = NULL; 21178cf2a04SEric Kohl ULONG ulType = 0; 21278cf2a04SEric Kohl ULONG ulTransferLength, ulLength; 21378cf2a04SEric Kohl CONFIGRET ret = CR_SUCCESS; 21478cf2a04SEric Kohl 21578cf2a04SEric Kohl TRACE("GetDeviceInstanceKeyPath()\n"); 21678cf2a04SEric Kohl 217d57b0ef9SEric Kohl /* Allocate a buffer for the device id */ 218d57b0ef9SEric Kohl pszBuffer = MyMalloc(300 * sizeof(WCHAR)); 219d57b0ef9SEric Kohl if (pszBuffer == NULL) 220d57b0ef9SEric Kohl { 221d57b0ef9SEric Kohl ERR("MyMalloc() failed\n"); 222d57b0ef9SEric Kohl return CR_OUT_OF_MEMORY; 223d57b0ef9SEric Kohl } 224d57b0ef9SEric Kohl 22578cf2a04SEric Kohl if (ulFlags & CM_REGISTRY_SOFTWARE) 22678cf2a04SEric Kohl { 22778cf2a04SEric Kohl /* Software Key Path */ 2288e850d19SEric Kohl 2298e850d19SEric Kohl if (ulFlags & CM_REGISTRY_CONFIG) 2308e850d19SEric Kohl { 2318e850d19SEric Kohl SplitDeviceInstanceId(pszDeviceInst, 2328e850d19SEric Kohl pszBuffer, 2338e850d19SEric Kohl pszInstancePath); 2348e850d19SEric Kohl 2358e850d19SEric Kohl if (ulHardwareProfile == 0) 2368e850d19SEric Kohl { 2378e850d19SEric Kohl wsprintfW(pszKeyPath, 2388e850d19SEric Kohl L"%s\\%s\\%s\\%s", 2398e850d19SEric Kohl L"System\\CurrentControlSet\\Hardware Profiles", 2408e850d19SEric Kohl L"Current", 241d57b0ef9SEric Kohl L"System\\CurrentControlSet\\Enum", 2428e850d19SEric Kohl pszBuffer); 2438e850d19SEric Kohl } 2448e850d19SEric Kohl else 2458e850d19SEric Kohl { 2468e850d19SEric Kohl wsprintfW(pszKeyPath, 2478e850d19SEric Kohl L"%s\\%04lu\\%s\\%s", 2488e850d19SEric Kohl L"System\\CurrentControlSet\\Hardware Profiles", 2498e850d19SEric Kohl ulHardwareProfile, 250d57b0ef9SEric Kohl L"System\\CurrentControlSet\\Enum", 2518e850d19SEric Kohl pszBuffer); 2528e850d19SEric Kohl } 2538e850d19SEric Kohl } 254d57b0ef9SEric Kohl else if (ulFlags & CM_REGISTRY_USER) 255d57b0ef9SEric Kohl { 256d57b0ef9SEric Kohl wsprintfW(pszKeyPath, 257d57b0ef9SEric Kohl L"%s\\%s", 258d57b0ef9SEric Kohl L"System\\CurrentControlSet\\Enum", 259d57b0ef9SEric Kohl pszDeviceInst); 260d57b0ef9SEric Kohl 261d57b0ef9SEric Kohl wcscpy(pszInstancePath, 262d57b0ef9SEric Kohl L"Device Parameters"); 263d57b0ef9SEric Kohl } 2648e850d19SEric Kohl else 2658e850d19SEric Kohl { 266d57b0ef9SEric Kohl SplitDeviceInstanceId(pszDeviceInst, 267d57b0ef9SEric Kohl pszBuffer, 268d57b0ef9SEric Kohl pszInstancePath); 269d57b0ef9SEric Kohl 270d57b0ef9SEric Kohl wsprintfW(pszKeyPath, 271d57b0ef9SEric Kohl L"%s\\%s", 272d57b0ef9SEric Kohl L"System\\CurrentControlSet\\Enum", 273d57b0ef9SEric Kohl pszBuffer); 27478cf2a04SEric Kohl } 2758e850d19SEric Kohl } 27678cf2a04SEric Kohl else 27778cf2a04SEric Kohl { 27878cf2a04SEric Kohl /* Hardware Key Path */ 27978cf2a04SEric Kohl 28078cf2a04SEric Kohl ulTransferLength = 300 * sizeof(WCHAR); 28178cf2a04SEric Kohl ulLength = 300 * sizeof(WCHAR); 28278cf2a04SEric Kohl ret = PNP_GetDeviceRegProp(BindingHandle, 28378cf2a04SEric Kohl pszDeviceInst, 28478cf2a04SEric Kohl CM_DRP_DRIVER, 28578cf2a04SEric Kohl &ulType, 28678cf2a04SEric Kohl (PVOID)pszBuffer, 28778cf2a04SEric Kohl &ulTransferLength, 28878cf2a04SEric Kohl &ulLength, 28978cf2a04SEric Kohl 0); 29078cf2a04SEric Kohl if (ret != CR_SUCCESS) 29178cf2a04SEric Kohl { 29278cf2a04SEric Kohl ERR("PNP_GetDeviceRegProp() failed (Error %lu)\n", ret); 29378cf2a04SEric Kohl goto done; 29478cf2a04SEric Kohl } 29578cf2a04SEric Kohl 29678cf2a04SEric Kohl TRACE("szBuffer: %S\n", pszBuffer); 29778cf2a04SEric Kohl 29878cf2a04SEric Kohl SplitDeviceInstanceId(pszBuffer, 29978cf2a04SEric Kohl pszBuffer, 30078cf2a04SEric Kohl pszInstancePath); 30178cf2a04SEric Kohl 30278cf2a04SEric Kohl TRACE("szBuffer: %S\n", pszBuffer); 30378cf2a04SEric Kohl 30478cf2a04SEric Kohl if (ulFlags & CM_REGISTRY_CONFIG) 30578cf2a04SEric Kohl { 30678cf2a04SEric Kohl if (ulHardwareProfile == 0) 30778cf2a04SEric Kohl { 30878cf2a04SEric Kohl wsprintfW(pszKeyPath, 30978cf2a04SEric Kohl L"%s\\%s\\%s\\%s", 31078cf2a04SEric Kohl L"System\\CurrentControlSet\\Hardware Profiles", 31178cf2a04SEric Kohl L"Current", 31278cf2a04SEric Kohl L"System\\CurrentControlSet\\Control\\Class", 31378cf2a04SEric Kohl pszBuffer); 31478cf2a04SEric Kohl } 31578cf2a04SEric Kohl else 31678cf2a04SEric Kohl { 31778cf2a04SEric Kohl wsprintfW(pszKeyPath, 31878cf2a04SEric Kohl L"%s\\%04lu\\%s\\%s", 31978cf2a04SEric Kohl L"System\\CurrentControlSet\\Hardware Profiles", 32078cf2a04SEric Kohl ulHardwareProfile, 32178cf2a04SEric Kohl L"System\\CurrentControlSet\\Control\\Class", 32278cf2a04SEric Kohl pszBuffer); 32378cf2a04SEric Kohl } 32478cf2a04SEric Kohl } 32578cf2a04SEric Kohl else 32678cf2a04SEric Kohl { 32778cf2a04SEric Kohl wsprintfW(pszKeyPath, 32878cf2a04SEric Kohl L"%s\\%s", 32978cf2a04SEric Kohl L"System\\CurrentControlSet\\Control\\Class", 33078cf2a04SEric Kohl pszBuffer); 33178cf2a04SEric Kohl } 33278cf2a04SEric Kohl } 33378cf2a04SEric Kohl 33478cf2a04SEric Kohl done: 33578cf2a04SEric Kohl if (pszBuffer != NULL) 33678cf2a04SEric Kohl MyFree(pszBuffer); 33778cf2a04SEric Kohl 33878cf2a04SEric Kohl return ret; 33978cf2a04SEric Kohl } 34078cf2a04SEric Kohl 34178cf2a04SEric Kohl 3423ad5c7fdSEric Kohl BOOL 3433ad5c7fdSEric Kohl IsValidRangeList( 34419fc20f2SEric Kohl _In_opt_ PINTERNAL_RANGE_LIST pRangeList) 3453ad5c7fdSEric Kohl { 3463ad5c7fdSEric Kohl BOOL bValid = TRUE; 3473ad5c7fdSEric Kohl 3483ad5c7fdSEric Kohl if (pRangeList == NULL) 3493ad5c7fdSEric Kohl return FALSE; 3503ad5c7fdSEric Kohl 3513ad5c7fdSEric Kohl _SEH2_TRY 3523ad5c7fdSEric Kohl { 3533ad5c7fdSEric Kohl if (pRangeList->ulMagic != RANGE_LIST_MAGIC) 3543ad5c7fdSEric Kohl bValid = FALSE; 3553ad5c7fdSEric Kohl } 3563ad5c7fdSEric Kohl _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) 3573ad5c7fdSEric Kohl { 3583ad5c7fdSEric Kohl bValid = FALSE; 3593ad5c7fdSEric Kohl } 3603ad5c7fdSEric Kohl _SEH2_END; 3613ad5c7fdSEric Kohl 3623ad5c7fdSEric Kohl return bValid; 3633ad5c7fdSEric Kohl } 3643ad5c7fdSEric Kohl 3653ad5c7fdSEric Kohl 36619fc20f2SEric Kohl BOOL 36719fc20f2SEric Kohl IsValidLogConf( 36819fc20f2SEric Kohl _In_opt_ PLOG_CONF_INFO pLogConfInfo) 36919fc20f2SEric Kohl { 37019fc20f2SEric Kohl BOOL bValid = TRUE; 37119fc20f2SEric Kohl 37219fc20f2SEric Kohl if (pLogConfInfo == NULL) 37319fc20f2SEric Kohl return FALSE; 37419fc20f2SEric Kohl 37519fc20f2SEric Kohl _SEH2_TRY 37619fc20f2SEric Kohl { 37719fc20f2SEric Kohl if (pLogConfInfo->ulMagic != LOG_CONF_MAGIC) 37819fc20f2SEric Kohl bValid = FALSE; 37919fc20f2SEric Kohl } 38019fc20f2SEric Kohl _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) 38119fc20f2SEric Kohl { 38219fc20f2SEric Kohl bValid = FALSE; 38319fc20f2SEric Kohl } 38419fc20f2SEric Kohl _SEH2_END; 38519fc20f2SEric Kohl 38619fc20f2SEric Kohl return bValid; 38719fc20f2SEric Kohl } 38819fc20f2SEric Kohl 38919fc20f2SEric Kohl 390c2c66affSColin Finck /*********************************************************************** 391c2c66affSColin Finck * CMP_GetBlockedDriverInfo [SETUPAPI.@] 392c2c66affSColin Finck */ 393c2c66affSColin Finck CONFIGRET 394c2c66affSColin Finck WINAPI 395c2c66affSColin Finck CMP_GetBlockedDriverInfo( 396c2c66affSColin Finck _Out_opt_ LPWSTR pszNames, 397c2c66affSColin Finck _Inout_ PULONG pulLength, 398c2c66affSColin Finck _In_ ULONG ulFlags, 399c2c66affSColin Finck _In_opt_ HMACHINE hMachine) 400c2c66affSColin Finck { 401c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 402c2c66affSColin Finck ULONG ulTransferLength; 403c2c66affSColin Finck CONFIGRET ret; 404c2c66affSColin Finck 405c2c66affSColin Finck TRACE("CMP_GetBlockedDriverInfo(%p %p %lx %p)\n", 406c2c66affSColin Finck pszNames, pulLength, ulFlags, hMachine); 407c2c66affSColin Finck 408c2c66affSColin Finck if (hMachine != NULL) 409c2c66affSColin Finck { 410c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 411c2c66affSColin Finck if (BindingHandle == NULL) 412c2c66affSColin Finck return CR_FAILURE; 413c2c66affSColin Finck } 414c2c66affSColin Finck else 415c2c66affSColin Finck { 416c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 417c2c66affSColin Finck return CR_FAILURE; 418c2c66affSColin Finck } 419c2c66affSColin Finck 420c2c66affSColin Finck ulTransferLength = *pulLength; 421c2c66affSColin Finck 422c2c66affSColin Finck RpcTryExcept 423c2c66affSColin Finck { 424c2c66affSColin Finck ret = PNP_GetBlockedDriverInfo(BindingHandle, 425c2c66affSColin Finck (PBYTE)pszNames, 426c2c66affSColin Finck &ulTransferLength, 427c2c66affSColin Finck pulLength, 428c2c66affSColin Finck ulFlags); 429c2c66affSColin Finck } 430c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 431c2c66affSColin Finck { 432c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 433c2c66affSColin Finck } 434c2c66affSColin Finck RpcEndExcept; 435c2c66affSColin Finck 436c2c66affSColin Finck return ret; 437c2c66affSColin Finck } 438c2c66affSColin Finck 439c2c66affSColin Finck 440c2c66affSColin Finck /*********************************************************************** 441c2c66affSColin Finck * CMP_GetServerSideDeviceInstallFlags [SETUPAPI.@] 442c2c66affSColin Finck */ 443c2c66affSColin Finck CONFIGRET 444c2c66affSColin Finck WINAPI 445c2c66affSColin Finck CMP_GetServerSideDeviceInstallFlags( 446c2c66affSColin Finck _Out_ PULONG pulSSDIFlags, 447c2c66affSColin Finck _In_ ULONG ulFlags, 448c2c66affSColin Finck _In_opt_ HMACHINE hMachine) 449c2c66affSColin Finck { 450c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 451c2c66affSColin Finck CONFIGRET ret; 452c2c66affSColin Finck 453c2c66affSColin Finck TRACE("CMP_GetServerSideDeviceInstallFlags(%p %lx %p)\n", 454c2c66affSColin Finck pulSSDIFlags, ulFlags, hMachine); 455c2c66affSColin Finck 456c2c66affSColin Finck if (pulSSDIFlags == NULL) 457c2c66affSColin Finck return CR_INVALID_POINTER; 458c2c66affSColin Finck 459c2c66affSColin Finck if (ulFlags != 0) 460c2c66affSColin Finck return CR_INVALID_FLAG; 461c2c66affSColin Finck 462c2c66affSColin Finck if (hMachine != NULL) 463c2c66affSColin Finck { 464c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 465c2c66affSColin Finck if (BindingHandle == NULL) 466c2c66affSColin Finck return CR_FAILURE; 467c2c66affSColin Finck } 468c2c66affSColin Finck else 469c2c66affSColin Finck { 470c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 471c2c66affSColin Finck return CR_FAILURE; 472c2c66affSColin Finck } 473c2c66affSColin Finck 474c2c66affSColin Finck RpcTryExcept 475c2c66affSColin Finck { 476c2c66affSColin Finck ret = PNP_GetServerSideDeviceInstallFlags(BindingHandle, 477c2c66affSColin Finck pulSSDIFlags, 478c2c66affSColin Finck ulFlags); 479c2c66affSColin Finck } 480c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 481c2c66affSColin Finck { 482c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 483c2c66affSColin Finck } 484c2c66affSColin Finck RpcEndExcept; 485c2c66affSColin Finck 486c2c66affSColin Finck return ret; 487c2c66affSColin Finck } 488c2c66affSColin Finck 489c2c66affSColin Finck 490c2c66affSColin Finck /*********************************************************************** 491c2c66affSColin Finck * CMP_Init_Detection [SETUPAPI.@] 492c2c66affSColin Finck */ 493c2c66affSColin Finck CONFIGRET 494c2c66affSColin Finck WINAPI 495c2c66affSColin Finck CMP_Init_Detection( 496c2c66affSColin Finck _In_ ULONG ulMagic) 497c2c66affSColin Finck { 498c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 499c2c66affSColin Finck CONFIGRET ret; 500c2c66affSColin Finck 501c2c66affSColin Finck TRACE("CMP_Init_Detection(%lu)\n", ulMagic); 502c2c66affSColin Finck 503c2c66affSColin Finck if (ulMagic != CMP_MAGIC) 504c2c66affSColin Finck return CR_INVALID_DATA; 505c2c66affSColin Finck 506c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 507c2c66affSColin Finck return CR_FAILURE; 508c2c66affSColin Finck 509c2c66affSColin Finck RpcTryExcept 510c2c66affSColin Finck { 511c2c66affSColin Finck ret = PNP_InitDetection(BindingHandle); 512c2c66affSColin Finck } 513c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 514c2c66affSColin Finck { 515c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 516c2c66affSColin Finck } 517c2c66affSColin Finck RpcEndExcept; 518c2c66affSColin Finck 519c2c66affSColin Finck return ret; 520c2c66affSColin Finck } 521c2c66affSColin Finck 522c2c66affSColin Finck 523c2c66affSColin Finck /*********************************************************************** 524c2c66affSColin Finck * CMP_RegisterNotification [SETUPAPI.@] 525c2c66affSColin Finck */ 526c2c66affSColin Finck CONFIGRET 527c2c66affSColin Finck WINAPI 528c2c66affSColin Finck CMP_RegisterNotification( 529c2c66affSColin Finck _In_ HANDLE hRecipient, 530c2c66affSColin Finck _In_ LPVOID lpvNotificationFilter, 531c2c66affSColin Finck _In_ ULONG ulFlags, 532c2c66affSColin Finck _Out_ PHDEVNOTIFY phDevNotify) 533c2c66affSColin Finck { 534c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 535c2c66affSColin Finck PNOTIFY_DATA pNotifyData = NULL; 536c2c66affSColin Finck CONFIGRET ret = CR_SUCCESS; 537c2c66affSColin Finck 538c2c66affSColin Finck TRACE("CMP_RegisterNotification(%p %p %lu %p)\n", 539c2c66affSColin Finck hRecipient, lpvNotificationFilter, ulFlags, phDevNotify); 540c2c66affSColin Finck 541c2c66affSColin Finck if ((hRecipient == NULL) || 542c2c66affSColin Finck (lpvNotificationFilter == NULL) || 543c2c66affSColin Finck (phDevNotify == NULL)) 544c2c66affSColin Finck return CR_INVALID_POINTER; 545c2c66affSColin Finck 546c2c66affSColin Finck if (ulFlags & ~0x7) 547c2c66affSColin Finck return CR_INVALID_FLAG; 548c2c66affSColin Finck 549c2c66affSColin Finck if (((PDEV_BROADCAST_HDR)lpvNotificationFilter)->dbch_size < sizeof(DEV_BROADCAST_HDR)) 550c2c66affSColin Finck return CR_INVALID_DATA; 551c2c66affSColin Finck 552c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 553c2c66affSColin Finck return CR_FAILURE; 554c2c66affSColin Finck 555c2c66affSColin Finck pNotifyData = HeapAlloc(GetProcessHeap(), 556c2c66affSColin Finck HEAP_ZERO_MEMORY, 557c2c66affSColin Finck sizeof(NOTIFY_DATA)); 558c2c66affSColin Finck if (pNotifyData == NULL) 559c2c66affSColin Finck return CR_OUT_OF_MEMORY; 560c2c66affSColin Finck 561c2c66affSColin Finck pNotifyData->ulMagic = NOTIFY_MAGIC; 562c2c66affSColin Finck 563c2c66affSColin Finck /* 564c2c66affSColin Finck if (dwFlags & DEVICE_NOTIFY_SERVICE_HANDLE == DEVICE_NOTYFY_WINDOW_HANDLE) 565c2c66affSColin Finck { 566c2c66affSColin Finck 567c2c66affSColin Finck } 568c2c66affSColin Finck else if (dwFlags & DEVICE_NOTIFY_SERVICE_HANDLE == DEVICE_NOTYFY_SERVICE_HANDLE) 569c2c66affSColin Finck { 570c2c66affSColin Finck 571c2c66affSColin Finck } 572c2c66affSColin Finck */ 573c2c66affSColin Finck 574c2c66affSColin Finck RpcTryExcept 575c2c66affSColin Finck { 576c2c66affSColin Finck ret = PNP_RegisterNotification(BindingHandle, 577c2c66affSColin Finck ulFlags, 578c2c66affSColin Finck &pNotifyData->ulNotifyData); 579c2c66affSColin Finck } 580c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 581c2c66affSColin Finck { 582c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 583c2c66affSColin Finck } 584c2c66affSColin Finck RpcEndExcept; 585c2c66affSColin Finck 586c2c66affSColin Finck if (ret == CR_SUCCESS) 587c2c66affSColin Finck { 588c2c66affSColin Finck *phDevNotify = (HDEVNOTIFY)pNotifyData; 589c2c66affSColin Finck } 590c2c66affSColin Finck else 591c2c66affSColin Finck { 592c2c66affSColin Finck if (pNotifyData != NULL) 593c2c66affSColin Finck HeapFree(GetProcessHeap(), 0, pNotifyData); 594c2c66affSColin Finck 595c2c66affSColin Finck *phDevNotify = (HDEVNOTIFY)NULL; 596c2c66affSColin Finck } 597c2c66affSColin Finck 598c2c66affSColin Finck return ret; 599c2c66affSColin Finck } 600c2c66affSColin Finck 601c2c66affSColin Finck 602c2c66affSColin Finck /*********************************************************************** 603c2c66affSColin Finck * CMP_Report_LogOn [SETUPAPI.@] 604c2c66affSColin Finck */ 605c2c66affSColin Finck CONFIGRET 606c2c66affSColin Finck WINAPI 607c2c66affSColin Finck CMP_Report_LogOn( 608c2c66affSColin Finck _In_ DWORD dwMagic, 609c2c66affSColin Finck _In_ DWORD dwProcessId) 610c2c66affSColin Finck { 611c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 612c2c66affSColin Finck CONFIGRET ret = CR_SUCCESS; 613c2c66affSColin Finck BOOL bAdmin; 614c2c66affSColin Finck DWORD i; 615c2c66affSColin Finck 616c2c66affSColin Finck TRACE("CMP_Report_LogOn(%lu %lu)\n", dwMagic, dwProcessId); 617c2c66affSColin Finck 618c2c66affSColin Finck if (dwMagic != CMP_MAGIC) 619c2c66affSColin Finck return CR_INVALID_DATA; 620c2c66affSColin Finck 621c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 622c2c66affSColin Finck return CR_FAILURE; 623c2c66affSColin Finck 624c2c66affSColin Finck bAdmin = pSetupIsUserAdmin(); 625c2c66affSColin Finck 626c2c66affSColin Finck for (i = 0; i < 30; i++) 627c2c66affSColin Finck { 628c2c66affSColin Finck RpcTryExcept 629c2c66affSColin Finck { 630c2c66affSColin Finck ret = PNP_ReportLogOn(BindingHandle, 631c2c66affSColin Finck bAdmin, 632c2c66affSColin Finck dwProcessId); 633c2c66affSColin Finck } 634c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 635c2c66affSColin Finck { 636c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 637c2c66affSColin Finck } 638c2c66affSColin Finck RpcEndExcept; 639c2c66affSColin Finck 640c2c66affSColin Finck if (ret == CR_SUCCESS) 641c2c66affSColin Finck break; 642c2c66affSColin Finck 643c2c66affSColin Finck Sleep(5000); 644c2c66affSColin Finck } 645c2c66affSColin Finck 646c2c66affSColin Finck return ret; 647c2c66affSColin Finck } 648c2c66affSColin Finck 649c2c66affSColin Finck 650c2c66affSColin Finck /*********************************************************************** 651c2c66affSColin Finck * CMP_UnregisterNotification [SETUPAPI.@] 652c2c66affSColin Finck */ 653c2c66affSColin Finck CONFIGRET 654c2c66affSColin Finck WINAPI 655c2c66affSColin Finck CMP_UnregisterNotification( 656c2c66affSColin Finck _In_ HDEVNOTIFY hDevNotify) 657c2c66affSColin Finck { 658c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 659c2c66affSColin Finck PNOTIFY_DATA pNotifyData; 660c2c66affSColin Finck CONFIGRET ret = CR_SUCCESS; 661c2c66affSColin Finck 662c2c66affSColin Finck TRACE("CMP_UnregisterNotification(%p)\n", hDevNotify); 663c2c66affSColin Finck 664c2c66affSColin Finck pNotifyData = (PNOTIFY_DATA)hDevNotify; 665c2c66affSColin Finck 666c2c66affSColin Finck if ((pNotifyData == NULL) || 667c2c66affSColin Finck (pNotifyData->ulMagic != NOTIFY_MAGIC)) 668c2c66affSColin Finck return CR_INVALID_POINTER; 669c2c66affSColin Finck 670c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 671c2c66affSColin Finck return CR_FAILURE; 672c2c66affSColin Finck 673c2c66affSColin Finck RpcTryExcept 674c2c66affSColin Finck { 675c2c66affSColin Finck ret = PNP_UnregisterNotification(BindingHandle, 676c2c66affSColin Finck pNotifyData->ulNotifyData); 677c2c66affSColin Finck } 678c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 679c2c66affSColin Finck { 680c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 681c2c66affSColin Finck } 682c2c66affSColin Finck RpcEndExcept; 683c2c66affSColin Finck 684c2c66affSColin Finck if (ret == CR_SUCCESS) 685c2c66affSColin Finck HeapFree(GetProcessHeap(), 0, pNotifyData); 686c2c66affSColin Finck 687c2c66affSColin Finck return ret; 688c2c66affSColin Finck } 689c2c66affSColin Finck 690c2c66affSColin Finck 691c2c66affSColin Finck /*********************************************************************** 692c2c66affSColin Finck * CMP_WaitNoPendingInstallEvents [SETUPAPI.@] 693c2c66affSColin Finck */ 694c2c66affSColin Finck DWORD 695c2c66affSColin Finck WINAPI 696c2c66affSColin Finck CMP_WaitNoPendingInstallEvents( 697c2c66affSColin Finck _In_ DWORD dwTimeout) 698c2c66affSColin Finck { 699c2c66affSColin Finck HANDLE hEvent; 700c2c66affSColin Finck DWORD ret; 701c2c66affSColin Finck 702c2c66affSColin Finck TRACE("CMP_WaitNoPendingInstallEvents(%lu)\n", dwTimeout); 703c2c66affSColin Finck 704c2c66affSColin Finck hEvent = OpenEventW(SYNCHRONIZE, FALSE, L"Global\\PnP_No_Pending_Install_Events"); 705c2c66affSColin Finck if (hEvent == NULL) 706c2c66affSColin Finck return WAIT_FAILED; 707c2c66affSColin Finck 708c2c66affSColin Finck ret = WaitForSingleObject(hEvent, dwTimeout); 709c2c66affSColin Finck CloseHandle(hEvent); 710c2c66affSColin Finck return ret; 711c2c66affSColin Finck } 712c2c66affSColin Finck 713c2c66affSColin Finck 714c2c66affSColin Finck /*********************************************************************** 715c2c66affSColin Finck * CMP_WaitServicesAvailable [SETUPAPI.@] 716c2c66affSColin Finck */ 717c2c66affSColin Finck CONFIGRET 718c2c66affSColin Finck WINAPI 719c2c66affSColin Finck CMP_WaitServicesAvailable( 720c2c66affSColin Finck _In_opt_ HMACHINE hMachine) 721c2c66affSColin Finck { 722c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 723c2c66affSColin Finck CONFIGRET ret = CR_SUCCESS; 724c2c66affSColin Finck WORD Version; 725c2c66affSColin Finck 726c2c66affSColin Finck TRACE("CMP_WaitServicesAvailable(%p)\n", hMachine); 727c2c66affSColin Finck 728c2c66affSColin Finck if (hMachine != NULL) 729c2c66affSColin Finck { 730c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 731c2c66affSColin Finck if (BindingHandle == NULL) 732c2c66affSColin Finck return CR_FAILURE; 733c2c66affSColin Finck } 734c2c66affSColin Finck else 735c2c66affSColin Finck { 736c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 737c2c66affSColin Finck return CR_FAILURE; 738c2c66affSColin Finck } 739c2c66affSColin Finck 740c2c66affSColin Finck RpcTryExcept 741c2c66affSColin Finck { 742c2c66affSColin Finck ret = PNP_GetVersion(BindingHandle, &Version); 743c2c66affSColin Finck } 744c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 745c2c66affSColin Finck { 746c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 747c2c66affSColin Finck } 748c2c66affSColin Finck RpcEndExcept; 749c2c66affSColin Finck 750c2c66affSColin Finck return ret; 751c2c66affSColin Finck } 752c2c66affSColin Finck 753c2c66affSColin Finck 754c2c66affSColin Finck /*********************************************************************** 755c2c66affSColin Finck * CM_Add_Empty_Log_Conf [SETUPAPI.@] 756c2c66affSColin Finck */ 757d9a33981SEric Kohl CONFIGRET 758d9a33981SEric Kohl WINAPI 759d9a33981SEric Kohl CM_Add_Empty_Log_Conf( 760d9a33981SEric Kohl _Out_ PLOG_CONF plcLogConf, 761d9a33981SEric Kohl _In_ DEVINST dnDevInst, 762d9a33981SEric Kohl _In_ PRIORITY Priority, 763d9a33981SEric Kohl _In_ ULONG ulFlags) 764c2c66affSColin Finck { 765d9a33981SEric Kohl TRACE("CM_Add_Empty_Log_Conf(%p %p %lu %lx)\n", 766d9a33981SEric Kohl plcLogConf, dnDevInst, Priority, ulFlags); 76765d3bf74SEric Kohl 768c2c66affSColin Finck return CM_Add_Empty_Log_Conf_Ex(plcLogConf, dnDevInst, Priority, 769c2c66affSColin Finck ulFlags, NULL); 770c2c66affSColin Finck } 771c2c66affSColin Finck 772c2c66affSColin Finck 773c2c66affSColin Finck /*********************************************************************** 774c2c66affSColin Finck * CM_Add_Empty_Log_Conf_Ex [SETUPAPI.@] 775c2c66affSColin Finck */ 776d9a33981SEric Kohl CONFIGRET 777d9a33981SEric Kohl WINAPI CM_Add_Empty_Log_Conf_Ex( 778d9a33981SEric Kohl _Out_ PLOG_CONF plcLogConf, 779d9a33981SEric Kohl _In_ DEVINST dnDevInst, 780d9a33981SEric Kohl _In_ PRIORITY Priority, 781d9a33981SEric Kohl _In_ ULONG ulFlags, 782d9a33981SEric Kohl _In_opt_ HMACHINE hMachine) 783c2c66affSColin Finck { 784c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 785c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 786c2c66affSColin Finck ULONG ulLogConfTag = 0; 787c2c66affSColin Finck LPWSTR lpDevInst; 788c2c66affSColin Finck PLOG_CONF_INFO pLogConfInfo; 789c2c66affSColin Finck CONFIGRET ret = CR_SUCCESS; 790c2c66affSColin Finck 791d9a33981SEric Kohl FIXME("CM_Add_Empty_Log_Conf_Ex(%p %p %lu %lx %p)\n", 792c2c66affSColin Finck plcLogConf, dnDevInst, Priority, ulFlags, hMachine); 793c2c66affSColin Finck 794c2c66affSColin Finck if (!pSetupIsUserAdmin()) 795c2c66affSColin Finck return CR_ACCESS_DENIED; 796c2c66affSColin Finck 797c2c66affSColin Finck if (plcLogConf == NULL) 798c2c66affSColin Finck return CR_INVALID_POINTER; 799c2c66affSColin Finck 800c2c66affSColin Finck if (dnDevInst == 0) 801c2c66affSColin Finck return CR_INVALID_DEVINST; 802c2c66affSColin Finck 803c2c66affSColin Finck if (Priority > 0xFFFF) 804c2c66affSColin Finck return CR_INVALID_PRIORITY; 805c2c66affSColin Finck 806c2c66affSColin Finck if (ulFlags & ~(LOG_CONF_BITS | PRIORITY_BIT)) 807c2c66affSColin Finck return CR_INVALID_FLAG; 808c2c66affSColin Finck 809c2c66affSColin Finck if (hMachine != NULL) 810c2c66affSColin Finck { 811c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 812c2c66affSColin Finck if (BindingHandle == NULL) 813c2c66affSColin Finck return CR_FAILURE; 814c2c66affSColin Finck 815c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 816c2c66affSColin Finck if (StringTable == 0) 817c2c66affSColin Finck return CR_FAILURE; 818c2c66affSColin Finck } 819c2c66affSColin Finck else 820c2c66affSColin Finck { 821c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 822c2c66affSColin Finck return CR_FAILURE; 823c2c66affSColin Finck } 824c2c66affSColin Finck 825c2c66affSColin Finck lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst); 826c2c66affSColin Finck if (lpDevInst == NULL) 827c2c66affSColin Finck return CR_INVALID_DEVNODE; 828c2c66affSColin Finck 829c2c66affSColin Finck RpcTryExcept 830c2c66affSColin Finck { 831c2c66affSColin Finck ret = PNP_AddEmptyLogConf(BindingHandle, lpDevInst, Priority, 832c2c66affSColin Finck &ulLogConfTag, ulFlags); 833c2c66affSColin Finck } 834c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 835c2c66affSColin Finck { 836c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 837c2c66affSColin Finck } 838c2c66affSColin Finck RpcEndExcept; 839c2c66affSColin Finck 840c2c66affSColin Finck if (ret == CR_SUCCESS) 841c2c66affSColin Finck { 842c2c66affSColin Finck pLogConfInfo = HeapAlloc(GetProcessHeap(), 0, sizeof(LOG_CONF_INFO)); 843c2c66affSColin Finck if (pLogConfInfo == NULL) 844c2c66affSColin Finck { 845c2c66affSColin Finck ret = CR_OUT_OF_MEMORY; 846c2c66affSColin Finck } 847c2c66affSColin Finck else 848c2c66affSColin Finck { 849c2c66affSColin Finck pLogConfInfo->ulMagic = LOG_CONF_MAGIC; 850c2c66affSColin Finck pLogConfInfo->dnDevInst = dnDevInst; 851c2c66affSColin Finck pLogConfInfo->ulFlags = ulFlags; 852c2c66affSColin Finck pLogConfInfo->ulTag = ulLogConfTag; 853c2c66affSColin Finck 854c2c66affSColin Finck *plcLogConf = (LOG_CONF)pLogConfInfo; 855c2c66affSColin Finck 856c2c66affSColin Finck ret = CR_SUCCESS; 857c2c66affSColin Finck } 858c2c66affSColin Finck } 859c2c66affSColin Finck 860c2c66affSColin Finck return ret; 861c2c66affSColin Finck } 862c2c66affSColin Finck 863c2c66affSColin Finck 864c2c66affSColin Finck /*********************************************************************** 865c2c66affSColin Finck * CM_Add_IDA [SETUPAPI.@] 866c2c66affSColin Finck */ 867d9a33981SEric Kohl CONFIGRET 868d9a33981SEric Kohl WINAPI 869d9a33981SEric Kohl CM_Add_IDA( 870d9a33981SEric Kohl _In_ DEVINST dnDevInst, 871d9a33981SEric Kohl _In_ PSTR pszID, 872d9a33981SEric Kohl _In_ ULONG ulFlags) 873c2c66affSColin Finck { 874d9a33981SEric Kohl TRACE("CM_Add_IDA(%p %s %lx)\n", 87565d3bf74SEric Kohl dnDevInst, debugstr_a(pszID), ulFlags); 87665d3bf74SEric Kohl 877c2c66affSColin Finck return CM_Add_ID_ExA(dnDevInst, pszID, ulFlags, NULL); 878c2c66affSColin Finck } 879c2c66affSColin Finck 880c2c66affSColin Finck 881c2c66affSColin Finck /*********************************************************************** 882c2c66affSColin Finck * CM_Add_IDW [SETUPAPI.@] 883c2c66affSColin Finck */ 884d9a33981SEric Kohl CONFIGRET 885d9a33981SEric Kohl WINAPI 886d9a33981SEric Kohl CM_Add_IDW( 887d9a33981SEric Kohl _In_ DEVINST dnDevInst, 888d9a33981SEric Kohl _In_ PWSTR pszID, 889d9a33981SEric Kohl _In_ ULONG ulFlags) 890c2c66affSColin Finck { 891d9a33981SEric Kohl TRACE("CM_Add_IDW(%p %s %lx)\n", 892d9a33981SEric Kohl dnDevInst, debugstr_w(pszID), ulFlags); 89365d3bf74SEric Kohl 894c2c66affSColin Finck return CM_Add_ID_ExW(dnDevInst, pszID, ulFlags, NULL); 895c2c66affSColin Finck } 896c2c66affSColin Finck 897c2c66affSColin Finck 898c2c66affSColin Finck /*********************************************************************** 899c2c66affSColin Finck * CM_Add_ID_ExA [SETUPAPI.@] 900c2c66affSColin Finck */ 901d9a33981SEric Kohl CONFIGRET 902d9a33981SEric Kohl WINAPI 903d9a33981SEric Kohl CM_Add_ID_ExA( 904d9a33981SEric Kohl _In_ DEVINST dnDevInst, 905d9a33981SEric Kohl _In_ PSTR pszID, 906d9a33981SEric Kohl _In_ ULONG ulFlags, 907d9a33981SEric Kohl _In_opt_ HMACHINE hMachine) 908c2c66affSColin Finck { 909c2c66affSColin Finck PWSTR pszIDW; 910c2c66affSColin Finck CONFIGRET ret; 911c2c66affSColin Finck 912d9a33981SEric Kohl TRACE("CM_Add_ID_ExA(%p %s %lx %p)\n", 91365d3bf74SEric Kohl dnDevInst, debugstr_a(pszID), ulFlags, hMachine); 914c2c66affSColin Finck 915c2c66affSColin Finck if (pSetupCaptureAndConvertAnsiArg(pszID, &pszIDW)) 916c2c66affSColin Finck return CR_INVALID_DATA; 917c2c66affSColin Finck 918c2c66affSColin Finck ret = CM_Add_ID_ExW(dnDevInst, pszIDW, ulFlags, hMachine); 919c2c66affSColin Finck 920c2c66affSColin Finck MyFree(pszIDW); 921c2c66affSColin Finck 922c2c66affSColin Finck return ret; 923c2c66affSColin Finck } 924c2c66affSColin Finck 925c2c66affSColin Finck 926c2c66affSColin Finck /*********************************************************************** 927c2c66affSColin Finck * CM_Add_ID_ExW [SETUPAPI.@] 928c2c66affSColin Finck */ 929d9a33981SEric Kohl CONFIGRET 930d9a33981SEric Kohl WINAPI 931d9a33981SEric Kohl CM_Add_ID_ExW( 932d9a33981SEric Kohl _In_ DEVINST dnDevInst, 933d9a33981SEric Kohl _In_ PWSTR pszID, 934d9a33981SEric Kohl _In_ ULONG ulFlags, 935d9a33981SEric Kohl _In_opt_ HMACHINE hMachine) 936c2c66affSColin Finck { 937c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 938c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 939c2c66affSColin Finck LPWSTR lpDevInst; 940c2c66affSColin Finck CONFIGRET ret; 941c2c66affSColin Finck 942d9a33981SEric Kohl TRACE("CM_Add_ID_ExW(%p %s %lx %p)\n", 943d9a33981SEric Kohl dnDevInst, debugstr_w(pszID), ulFlags, hMachine); 944c2c66affSColin Finck 945c2c66affSColin Finck if (!pSetupIsUserAdmin()) 946c2c66affSColin Finck return CR_ACCESS_DENIED; 947c2c66affSColin Finck 948c2c66affSColin Finck if (dnDevInst == 0) 949c2c66affSColin Finck return CR_INVALID_DEVINST; 950c2c66affSColin Finck 951c2c66affSColin Finck if (pszID == NULL) 952c2c66affSColin Finck return CR_INVALID_POINTER; 953c2c66affSColin Finck 954c2c66affSColin Finck if (ulFlags & ~CM_ADD_ID_BITS) 955c2c66affSColin Finck return CR_INVALID_FLAG; 956c2c66affSColin Finck 957c2c66affSColin Finck if (hMachine != NULL) 958c2c66affSColin Finck { 959c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 960c2c66affSColin Finck if (BindingHandle == NULL) 961c2c66affSColin Finck return CR_FAILURE; 962c2c66affSColin Finck 963c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 964c2c66affSColin Finck if (StringTable == 0) 965c2c66affSColin Finck return CR_FAILURE; 966c2c66affSColin Finck } 967c2c66affSColin Finck else 968c2c66affSColin Finck { 969c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 970c2c66affSColin Finck return CR_FAILURE; 971c2c66affSColin Finck } 972c2c66affSColin Finck 973c2c66affSColin Finck lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst); 974c2c66affSColin Finck if (lpDevInst == NULL) 975c2c66affSColin Finck return CR_INVALID_DEVNODE; 976c2c66affSColin Finck 977c2c66affSColin Finck RpcTryExcept 978c2c66affSColin Finck { 979c2c66affSColin Finck ret = PNP_AddID(BindingHandle, 980c2c66affSColin Finck lpDevInst, 981c2c66affSColin Finck pszID, 982c2c66affSColin Finck ulFlags); 983c2c66affSColin Finck } 984c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 985c2c66affSColin Finck { 986c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 987c2c66affSColin Finck } 988c2c66affSColin Finck RpcEndExcept; 989c2c66affSColin Finck 990c2c66affSColin Finck return ret; 991c2c66affSColin Finck } 992c2c66affSColin Finck 993c2c66affSColin Finck 994c2c66affSColin Finck /*********************************************************************** 995c2c66affSColin Finck * CM_Add_Range [SETUPAPI.@] 996c2c66affSColin Finck */ 997c2c66affSColin Finck CONFIGRET 998c2c66affSColin Finck WINAPI 999c2c66affSColin Finck CM_Add_Range( 1000c2c66affSColin Finck _In_ DWORDLONG ullStartValue, 1001c2c66affSColin Finck _In_ DWORDLONG ullEndValue, 1002c2c66affSColin Finck _In_ RANGE_LIST rlh, 1003c2c66affSColin Finck _In_ ULONG ulFlags) 1004c2c66affSColin Finck { 10053ad5c7fdSEric Kohl PINTERNAL_RANGE_LIST pRangeList; 10063ad5c7fdSEric Kohl PINTERNAL_RANGE pRange; 10073ad5c7fdSEric Kohl CONFIGRET ret = CR_SUCCESS; 10083ad5c7fdSEric Kohl 1009c2c66affSColin Finck FIXME("CM_Add_Range(%I64u %I64u %p %lx)\n", 1010c2c66affSColin Finck ullStartValue, ullEndValue, rlh, ulFlags); 10113ad5c7fdSEric Kohl 10123ad5c7fdSEric Kohl pRangeList = (PINTERNAL_RANGE_LIST)rlh; 10133ad5c7fdSEric Kohl 10143ad5c7fdSEric Kohl if (!IsValidRangeList(pRangeList)) 10153ad5c7fdSEric Kohl return CR_INVALID_RANGE_LIST; 10163ad5c7fdSEric Kohl 10173ad5c7fdSEric Kohl if (ulFlags & ~CM_ADD_RANGE_BITS) 10183ad5c7fdSEric Kohl return CR_INVALID_FLAG; 10193ad5c7fdSEric Kohl 10203ad5c7fdSEric Kohl if (ullEndValue < ullStartValue) 10213ad5c7fdSEric Kohl return CR_INVALID_RANGE; 10223ad5c7fdSEric Kohl 10233ad5c7fdSEric Kohl /* Lock the range list */ 10243ad5c7fdSEric Kohl WaitForSingleObject(pRangeList->hMutex, INFINITE); 10253ad5c7fdSEric Kohl 10263ad5c7fdSEric Kohl /* Allocate the new range */ 10273ad5c7fdSEric Kohl pRange = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNAL_RANGE)); 10283ad5c7fdSEric Kohl if (pRange == NULL) 10293ad5c7fdSEric Kohl { 10303ad5c7fdSEric Kohl ret = CR_OUT_OF_MEMORY; 10313ad5c7fdSEric Kohl goto done; 10323ad5c7fdSEric Kohl } 10333ad5c7fdSEric Kohl 10343ad5c7fdSEric Kohl pRange->ullStart = ullStartValue; 10353ad5c7fdSEric Kohl pRange->ullEnd = ullEndValue; 10363ad5c7fdSEric Kohl 10373ad5c7fdSEric Kohl /* Insert the range */ 10383ad5c7fdSEric Kohl if (IsListEmpty(&pRangeList->ListHead)) 10393ad5c7fdSEric Kohl { 10403ad5c7fdSEric Kohl InsertTailList(&pRangeList->ListHead, &pRange->ListEntry); 10413ad5c7fdSEric Kohl } 10423ad5c7fdSEric Kohl else 10433ad5c7fdSEric Kohl { 10443ad5c7fdSEric Kohl 10453ad5c7fdSEric Kohl } 10463ad5c7fdSEric Kohl 10473ad5c7fdSEric Kohl done: 10483ad5c7fdSEric Kohl /* Unlock the range list */ 10493ad5c7fdSEric Kohl ReleaseMutex(pRangeList->hMutex); 10503ad5c7fdSEric Kohl 10513ad5c7fdSEric Kohl return ret; 1052c2c66affSColin Finck } 1053c2c66affSColin Finck 1054c2c66affSColin Finck 1055c2c66affSColin Finck /*********************************************************************** 1056c2c66affSColin Finck * CM_Add_Res_Des [SETUPAPI.@] 1057c2c66affSColin Finck */ 1058d9a33981SEric Kohl CONFIGRET 1059d9a33981SEric Kohl WINAPI 1060d9a33981SEric Kohl CM_Add_Res_Des( 1061d9a33981SEric Kohl _Out_opt_ PRES_DES prdResDes, 1062d9a33981SEric Kohl _In_ LOG_CONF lcLogConf, 1063d9a33981SEric Kohl _In_ RESOURCEID ResourceID, 106465d3bf74SEric Kohl _In_reads_bytes_(ResourceLen) PCVOID ResourceData, 1065d9a33981SEric Kohl _In_ ULONG ResourceLen, 1066d9a33981SEric Kohl _In_ ULONG ulFlags) 1067c2c66affSColin Finck { 1068d9a33981SEric Kohl TRACE("CM_Add_Res_Des(%p %p %lu %p %lu %lx)\n", 1069d9a33981SEric Kohl prdResDes, lcLogConf, ResourceID, ResourceData, ResourceLen, ulFlags); 107065d3bf74SEric Kohl 1071c2c66affSColin Finck return CM_Add_Res_Des_Ex(prdResDes, lcLogConf, ResourceID, ResourceData, 1072c2c66affSColin Finck ResourceLen, ulFlags, NULL); 1073c2c66affSColin Finck } 1074c2c66affSColin Finck 1075c2c66affSColin Finck 1076c2c66affSColin Finck /*********************************************************************** 1077c2c66affSColin Finck * CM_Add_Res_Des_Ex [SETUPAPI.@] 1078c2c66affSColin Finck */ 1079d9a33981SEric Kohl CONFIGRET 1080d9a33981SEric Kohl WINAPI 1081d9a33981SEric Kohl CM_Add_Res_Des_Ex( 1082d9a33981SEric Kohl _Out_opt_ PRES_DES prdResDes, 1083d9a33981SEric Kohl _In_ LOG_CONF lcLogConf, 1084d9a33981SEric Kohl _In_ RESOURCEID ResourceID, 108565d3bf74SEric Kohl _In_reads_bytes_(ResourceLen) PCVOID ResourceData, 1086d9a33981SEric Kohl _In_ ULONG ResourceLen, 1087d9a33981SEric Kohl _In_ ULONG ulFlags, 1088d9a33981SEric Kohl _In_opt_ HMACHINE hMachine) 1089c2c66affSColin Finck { 1090d9a33981SEric Kohl FIXME("CM_Add_Res_Des_Ex(%p %p %lu %p %lu %lx %p)\n", 1091d9a33981SEric Kohl prdResDes, lcLogConf, ResourceID, 1092c2c66affSColin Finck ResourceData, ResourceLen, ulFlags, hMachine); 1093c2c66affSColin Finck 1094c2c66affSColin Finck return CR_CALL_NOT_IMPLEMENTED; 1095c2c66affSColin Finck } 1096c2c66affSColin Finck 1097c2c66affSColin Finck 1098c2c66affSColin Finck /*********************************************************************** 1099c2c66affSColin Finck * CM_Connect_MachineA [SETUPAPI.@] 1100c2c66affSColin Finck */ 1101d9a33981SEric Kohl CONFIGRET 1102d9a33981SEric Kohl WINAPI 1103d9a33981SEric Kohl CM_Connect_MachineA( 1104d9a33981SEric Kohl _In_opt_ PCSTR UNCServerName, 1105d9a33981SEric Kohl _Out_ PHMACHINE phMachine) 1106c2c66affSColin Finck { 1107c2c66affSColin Finck PWSTR pServerNameW; 1108c2c66affSColin Finck CONFIGRET ret; 1109c2c66affSColin Finck 1110d9a33981SEric Kohl TRACE("CM_Connect_MachineA(%s %p)\n", 111165d3bf74SEric Kohl debugstr_a(UNCServerName), phMachine); 1112c2c66affSColin Finck 1113c2c66affSColin Finck if (UNCServerName == NULL || *UNCServerName == 0) 1114c2c66affSColin Finck return CM_Connect_MachineW(NULL, phMachine); 1115c2c66affSColin Finck 1116c2c66affSColin Finck if (pSetupCaptureAndConvertAnsiArg(UNCServerName, &pServerNameW)) 1117c2c66affSColin Finck return CR_INVALID_DATA; 1118c2c66affSColin Finck 1119c2c66affSColin Finck ret = CM_Connect_MachineW(pServerNameW, phMachine); 1120c2c66affSColin Finck 1121c2c66affSColin Finck MyFree(pServerNameW); 1122c2c66affSColin Finck 1123c2c66affSColin Finck return ret; 1124c2c66affSColin Finck } 1125c2c66affSColin Finck 1126c2c66affSColin Finck 1127c2c66affSColin Finck /*********************************************************************** 1128c2c66affSColin Finck * CM_Connect_MachineW [SETUPAPI.@] 1129c2c66affSColin Finck */ 1130d9a33981SEric Kohl CONFIGRET 1131d9a33981SEric Kohl WINAPI 1132d9a33981SEric Kohl CM_Connect_MachineW( 1133d9a33981SEric Kohl _In_opt_ PCWSTR UNCServerName, 1134d9a33981SEric Kohl _Out_ PHMACHINE phMachine) 1135c2c66affSColin Finck { 1136c2c66affSColin Finck PMACHINE_INFO pMachine; 1137c2c66affSColin Finck 1138d9a33981SEric Kohl TRACE("CM_Connect_MachineW(%s %p)\n", 1139d9a33981SEric Kohl debugstr_w(UNCServerName), phMachine); 1140c2c66affSColin Finck 1141c2c66affSColin Finck if (phMachine == NULL) 1142c2c66affSColin Finck return CR_INVALID_POINTER; 1143c2c66affSColin Finck 1144c2c66affSColin Finck *phMachine = NULL; 1145c2c66affSColin Finck 1146c2c66affSColin Finck pMachine = HeapAlloc(GetProcessHeap(), 0, sizeof(MACHINE_INFO)); 1147c2c66affSColin Finck if (pMachine == NULL) 1148c2c66affSColin Finck return CR_OUT_OF_MEMORY; 1149c2c66affSColin Finck 1150c2c66affSColin Finck if (UNCServerName == NULL || *UNCServerName == 0) 1151c2c66affSColin Finck { 1152c2c66affSColin Finck pMachine->bLocal = TRUE; 1153c2c66affSColin Finck 1154c2c66affSColin Finck /* FIXME: store the computers name in pMachine->szMachineName */ 1155c2c66affSColin Finck 1156c2c66affSColin Finck if (!PnpGetLocalHandles(&pMachine->BindingHandle, 1157c2c66affSColin Finck &pMachine->StringTable)) 1158c2c66affSColin Finck { 1159c2c66affSColin Finck HeapFree(GetProcessHeap(), 0, pMachine); 1160c2c66affSColin Finck return CR_FAILURE; 1161c2c66affSColin Finck } 1162c2c66affSColin Finck } 1163c2c66affSColin Finck else 1164c2c66affSColin Finck { 1165c2c66affSColin Finck pMachine->bLocal = FALSE; 1166c2c66affSColin Finck if (wcslen(UNCServerName) >= SP_MAX_MACHINENAME_LENGTH - 1) 1167c2c66affSColin Finck { 1168c2c66affSColin Finck HeapFree(GetProcessHeap(), 0, pMachine); 1169c2c66affSColin Finck return CR_INVALID_MACHINENAME; 1170c2c66affSColin Finck } 1171c2c66affSColin Finck lstrcpyW(pMachine->szMachineName, UNCServerName); 1172c2c66affSColin Finck 1173c2c66affSColin Finck pMachine->StringTable = pSetupStringTableInitialize(); 1174c2c66affSColin Finck if (pMachine->StringTable == NULL) 1175c2c66affSColin Finck { 1176c2c66affSColin Finck HeapFree(GetProcessHeap(), 0, pMachine); 1177c2c66affSColin Finck return CR_FAILURE; 1178c2c66affSColin Finck } 1179c2c66affSColin Finck 1180c2c66affSColin Finck pSetupStringTableAddString(pMachine->StringTable, L"PLT", 1); 1181c2c66affSColin Finck 1182c2c66affSColin Finck if (!PnpBindRpc(UNCServerName, &pMachine->BindingHandle)) 1183c2c66affSColin Finck { 1184c2c66affSColin Finck pSetupStringTableDestroy(pMachine->StringTable); 1185c2c66affSColin Finck HeapFree(GetProcessHeap(), 0, pMachine); 1186c2c66affSColin Finck return CR_INVALID_MACHINENAME; 1187c2c66affSColin Finck } 1188c2c66affSColin Finck } 1189c2c66affSColin Finck 1190c2c66affSColin Finck *phMachine = (PHMACHINE)pMachine; 1191c2c66affSColin Finck 1192c2c66affSColin Finck return CR_SUCCESS; 1193c2c66affSColin Finck } 1194c2c66affSColin Finck 1195c2c66affSColin Finck 1196c2c66affSColin Finck /*********************************************************************** 1197c2c66affSColin Finck * CM_Create_DevNodeA [SETUPAPI.@] 1198c2c66affSColin Finck */ 1199d9a33981SEric Kohl CONFIGRET 1200d9a33981SEric Kohl WINAPI 1201d9a33981SEric Kohl CM_Create_DevNodeA( 1202d9a33981SEric Kohl _Out_ PDEVINST pdnDevInst, 1203d9a33981SEric Kohl _In_ DEVINSTID_A pDeviceID, 1204d9a33981SEric Kohl _In_ DEVINST dnParent, 1205d9a33981SEric Kohl _In_ ULONG ulFlags) 1206c2c66affSColin Finck { 1207d9a33981SEric Kohl TRACE("CM_Create_DevNodeA(%p %s %p %lx)\n", 1208c2c66affSColin Finck pdnDevInst, debugstr_a(pDeviceID), dnParent, ulFlags); 120965d3bf74SEric Kohl 1210c2c66affSColin Finck return CM_Create_DevNode_ExA(pdnDevInst, pDeviceID, dnParent, 1211c2c66affSColin Finck ulFlags, NULL); 1212c2c66affSColin Finck } 1213c2c66affSColin Finck 1214c2c66affSColin Finck 1215c2c66affSColin Finck /*********************************************************************** 1216c2c66affSColin Finck * CM_Create_DevNodeW [SETUPAPI.@] 1217c2c66affSColin Finck */ 1218d9a33981SEric Kohl CONFIGRET 1219d9a33981SEric Kohl WINAPI 1220d9a33981SEric Kohl CM_Create_DevNodeW( 1221d9a33981SEric Kohl _Out_ PDEVINST pdnDevInst, 1222d9a33981SEric Kohl _In_ DEVINSTID_W pDeviceID, 1223d9a33981SEric Kohl _In_ DEVINST dnParent, 1224d9a33981SEric Kohl _In_ ULONG ulFlags) 1225c2c66affSColin Finck { 1226d9a33981SEric Kohl TRACE("CM_Create_DevNodeW(%p %s %p %lx)\n", 1227c2c66affSColin Finck pdnDevInst, debugstr_w(pDeviceID), dnParent, ulFlags); 122865d3bf74SEric Kohl 1229c2c66affSColin Finck return CM_Create_DevNode_ExW(pdnDevInst, pDeviceID, dnParent, 1230c2c66affSColin Finck ulFlags, NULL); 1231c2c66affSColin Finck } 1232c2c66affSColin Finck 1233c2c66affSColin Finck 1234c2c66affSColin Finck /*********************************************************************** 1235c2c66affSColin Finck * CM_Create_DevNode_ExA [SETUPAPI.@] 1236c2c66affSColin Finck */ 1237d9a33981SEric Kohl CONFIGRET 1238d9a33981SEric Kohl WINAPI 1239d9a33981SEric Kohl CM_Create_DevNode_ExA( 1240d9a33981SEric Kohl _Out_ PDEVINST pdnDevInst, 1241d9a33981SEric Kohl _In_ DEVINSTID_A pDeviceID, 1242d9a33981SEric Kohl _In_ DEVINST dnParent, 1243d9a33981SEric Kohl _In_ ULONG ulFlags, 1244d9a33981SEric Kohl _In_opt_ HANDLE hMachine) 1245c2c66affSColin Finck { 1246c2c66affSColin Finck DEVINSTID_W pDeviceIDW; 1247c2c66affSColin Finck CONFIGRET ret; 1248c2c66affSColin Finck 1249d9a33981SEric Kohl TRACE("CM_Create_DevNode_ExA(%p %s %p %lx %p)\n", 1250c2c66affSColin Finck pdnDevInst, debugstr_a(pDeviceID), dnParent, ulFlags, hMachine); 1251c2c66affSColin Finck 1252c2c66affSColin Finck if (pSetupCaptureAndConvertAnsiArg(pDeviceID, &pDeviceIDW)) 1253c2c66affSColin Finck return CR_INVALID_DATA; 1254c2c66affSColin Finck 1255c2c66affSColin Finck ret = CM_Create_DevNode_ExW(pdnDevInst, pDeviceIDW, dnParent, ulFlags, 1256c2c66affSColin Finck hMachine); 1257c2c66affSColin Finck 1258c2c66affSColin Finck MyFree(pDeviceIDW); 1259c2c66affSColin Finck 1260c2c66affSColin Finck return ret; 1261c2c66affSColin Finck } 1262c2c66affSColin Finck 1263c2c66affSColin Finck 1264c2c66affSColin Finck /*********************************************************************** 1265c2c66affSColin Finck * CM_Create_DevNode_ExW [SETUPAPI.@] 1266c2c66affSColin Finck */ 1267d9a33981SEric Kohl CONFIGRET 1268d9a33981SEric Kohl WINAPI 1269d9a33981SEric Kohl CM_Create_DevNode_ExW( 1270d9a33981SEric Kohl _Out_ PDEVINST pdnDevInst, 1271d9a33981SEric Kohl _In_ DEVINSTID_W pDeviceID, 1272d9a33981SEric Kohl _In_ DEVINST dnParent, 1273d9a33981SEric Kohl _In_ ULONG ulFlags, 1274d9a33981SEric Kohl _In_opt_ HANDLE hMachine) 1275c2c66affSColin Finck { 1276c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 1277c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 1278c2c66affSColin Finck LPWSTR lpParentDevInst; 1279c2c66affSColin Finck CONFIGRET ret = CR_SUCCESS; 1280c2c66affSColin Finck WCHAR szLocalDeviceID[MAX_DEVICE_ID_LEN]; 1281c2c66affSColin Finck 1282d9a33981SEric Kohl TRACE("CM_Create_DevNode_ExW(%p %s %p %lx %p)\n", 1283c2c66affSColin Finck pdnDevInst, debugstr_w(pDeviceID), dnParent, ulFlags, hMachine); 1284c2c66affSColin Finck 1285c2c66affSColin Finck if (!pSetupIsUserAdmin()) 1286c2c66affSColin Finck return CR_ACCESS_DENIED; 1287c2c66affSColin Finck 1288c2c66affSColin Finck if (pdnDevInst == NULL) 1289c2c66affSColin Finck return CR_INVALID_POINTER; 1290c2c66affSColin Finck 1291c2c66affSColin Finck if (pDeviceID == NULL || wcslen(pDeviceID) == 0 || wcslen(pDeviceID) >= MAX_DEVICE_ID_LEN) 1292c2c66affSColin Finck return CR_INVALID_DEVICE_ID; 1293c2c66affSColin Finck 1294c2c66affSColin Finck if (dnParent == 0) 1295c2c66affSColin Finck return CR_INVALID_DEVNODE; 1296c2c66affSColin Finck 1297c2c66affSColin Finck if (ulFlags & ~CM_CREATE_DEVNODE_BITS) 1298c2c66affSColin Finck return CR_INVALID_FLAG; 1299c2c66affSColin Finck 1300c2c66affSColin Finck if (hMachine != NULL) 1301c2c66affSColin Finck { 1302c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 1303c2c66affSColin Finck if (BindingHandle == NULL) 1304c2c66affSColin Finck return CR_FAILURE; 1305c2c66affSColin Finck 1306c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 1307c2c66affSColin Finck if (StringTable == 0) 1308c2c66affSColin Finck return CR_FAILURE; 1309c2c66affSColin Finck } 1310c2c66affSColin Finck else 1311c2c66affSColin Finck { 1312c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 1313c2c66affSColin Finck return CR_FAILURE; 1314c2c66affSColin Finck } 1315c2c66affSColin Finck 1316c2c66affSColin Finck lpParentDevInst = pSetupStringTableStringFromId(StringTable, dnParent); 1317c2c66affSColin Finck if (lpParentDevInst == NULL) 1318c2c66affSColin Finck return CR_INVALID_DEVNODE; 1319c2c66affSColin Finck 1320c2c66affSColin Finck wcscpy(szLocalDeviceID, pDeviceID); 1321c2c66affSColin Finck 1322c2c66affSColin Finck RpcTryExcept 1323c2c66affSColin Finck { 1324c2c66affSColin Finck ret = PNP_CreateDevInst(BindingHandle, 1325c2c66affSColin Finck szLocalDeviceID, 1326c2c66affSColin Finck lpParentDevInst, 1327c2c66affSColin Finck MAX_DEVICE_ID_LEN, 1328c2c66affSColin Finck ulFlags); 1329c2c66affSColin Finck } 1330c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 1331c2c66affSColin Finck { 1332c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 1333c2c66affSColin Finck } 1334c2c66affSColin Finck RpcEndExcept; 1335c2c66affSColin Finck 1336c2c66affSColin Finck if (ret == CR_SUCCESS) 1337c2c66affSColin Finck { 1338c2c66affSColin Finck /* If CM_CREATE_DEVINST_GENERATE_ID was passed in, PNP_CreateDevInst 1339c2c66affSColin Finck * will return the generated device ID in szLocalDeviceID */ 1340c2c66affSColin Finck *pdnDevInst = pSetupStringTableAddString(StringTable, szLocalDeviceID, 1); 1341c2c66affSColin Finck if (*pdnDevInst == 0) 1342c2c66affSColin Finck ret = CR_NO_SUCH_DEVNODE; 1343c2c66affSColin Finck } 1344c2c66affSColin Finck 1345c2c66affSColin Finck return ret; 1346c2c66affSColin Finck } 1347c2c66affSColin Finck 1348c2c66affSColin Finck 1349c2c66affSColin Finck /*********************************************************************** 1350c2c66affSColin Finck * CM_Create_Range_List [SETUPAPI.@] 1351c2c66affSColin Finck */ 1352c2c66affSColin Finck CONFIGRET 1353c2c66affSColin Finck WINAPI 1354c2c66affSColin Finck CM_Create_Range_List( 1355c2c66affSColin Finck _Out_ PRANGE_LIST prlh, 1356c2c66affSColin Finck _In_ ULONG ulFlags) 1357c2c66affSColin Finck { 1358c2c66affSColin Finck PINTERNAL_RANGE_LIST pRangeList = NULL; 1359c2c66affSColin Finck 136065d3bf74SEric Kohl FIXME("CM_Create_Range_List(%p %lx)\n", 136165d3bf74SEric Kohl prlh, ulFlags); 1362c2c66affSColin Finck 1363c2c66affSColin Finck if (ulFlags != 0) 1364c2c66affSColin Finck return CR_INVALID_FLAG; 1365c2c66affSColin Finck 1366c2c66affSColin Finck if (prlh == NULL) 1367c2c66affSColin Finck return CR_INVALID_POINTER; 1368c2c66affSColin Finck 13693ad5c7fdSEric Kohl /* Allocate the range list */ 1370c2c66affSColin Finck pRangeList = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(INTERNAL_RANGE_LIST)); 1371c2c66affSColin Finck if (pRangeList == NULL) 1372c2c66affSColin Finck return CR_OUT_OF_MEMORY; 1373c2c66affSColin Finck 13743ad5c7fdSEric Kohl /* Set the magic value */ 1375c2c66affSColin Finck pRangeList->ulMagic = RANGE_LIST_MAGIC; 1376c2c66affSColin Finck 13773ad5c7fdSEric Kohl /* Initialize the mutex for synchonized access */ 13783ad5c7fdSEric Kohl pRangeList->hMutex = CreateMutex(NULL, FALSE, NULL); 13793ad5c7fdSEric Kohl if (pRangeList->hMutex == NULL) 13803ad5c7fdSEric Kohl { 13813ad5c7fdSEric Kohl HeapFree(GetProcessHeap(), 0, pRangeList); 13823ad5c7fdSEric Kohl return CR_FAILURE; 13833ad5c7fdSEric Kohl } 13843ad5c7fdSEric Kohl 13853ad5c7fdSEric Kohl InitializeListHead(&pRangeList->ListHead); 1386c2c66affSColin Finck 1387c2c66affSColin Finck *prlh = (RANGE_LIST)pRangeList; 1388c2c66affSColin Finck 1389c2c66affSColin Finck return CR_SUCCESS; 1390c2c66affSColin Finck } 1391c2c66affSColin Finck 1392c2c66affSColin Finck 1393c2c66affSColin Finck /*********************************************************************** 1394c2c66affSColin Finck * CM_Delete_Class_Key [SETUPAPI.@] 1395c2c66affSColin Finck */ 1396d9a33981SEric Kohl CONFIGRET 1397d9a33981SEric Kohl WINAPI 1398d9a33981SEric Kohl CM_Delete_Class_Key( 1399d9a33981SEric Kohl _In_ LPGUID ClassGuid, 1400d9a33981SEric Kohl _In_ ULONG ulFlags) 1401c2c66affSColin Finck { 1402d9a33981SEric Kohl TRACE("CM_Delete_Class_Key(%p %lx)\n", 1403d9a33981SEric Kohl ClassGuid, ulFlags); 140465d3bf74SEric Kohl 1405c2c66affSColin Finck return CM_Delete_Class_Key_Ex(ClassGuid, ulFlags, NULL); 1406c2c66affSColin Finck } 1407c2c66affSColin Finck 1408c2c66affSColin Finck 1409c2c66affSColin Finck /*********************************************************************** 1410c2c66affSColin Finck * CM_Delete_Class_Key_Ex [SETUPAPI.@] 1411c2c66affSColin Finck */ 1412d9a33981SEric Kohl CONFIGRET 1413d9a33981SEric Kohl WINAPI 1414d9a33981SEric Kohl CM_Delete_Class_Key_Ex( 1415d9a33981SEric Kohl _In_ LPGUID ClassGuid, 1416d9a33981SEric Kohl _In_ ULONG ulFlags, 1417d9a33981SEric Kohl _In_opt_ HANDLE hMachine) 1418c2c66affSColin Finck { 1419c2c66affSColin Finck WCHAR szGuidString[MAX_GUID_STRING_LEN]; 1420c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 1421c2c66affSColin Finck CONFIGRET ret; 1422c2c66affSColin Finck 142360a21894SEric Kohl TRACE("CM_Delete_Class_Key_Ex(%p %lx %p)\n", 1424d9a33981SEric Kohl ClassGuid, ulFlags, hMachine); 1425c2c66affSColin Finck 1426c2c66affSColin Finck if (ClassGuid == NULL) 1427c2c66affSColin Finck return CR_INVALID_POINTER; 1428c2c66affSColin Finck 1429c2c66affSColin Finck if (ulFlags & ~CM_DELETE_CLASS_BITS) 1430c2c66affSColin Finck return CR_INVALID_FLAG; 1431c2c66affSColin Finck 1432c2c66affSColin Finck if (!GuidToString(ClassGuid, szGuidString)) 1433c2c66affSColin Finck return CR_INVALID_DATA; 1434c2c66affSColin Finck 1435c2c66affSColin Finck if (hMachine != NULL) 1436c2c66affSColin Finck { 1437c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 1438c2c66affSColin Finck if (BindingHandle == NULL) 1439c2c66affSColin Finck return CR_FAILURE; 1440c2c66affSColin Finck } 1441c2c66affSColin Finck else 1442c2c66affSColin Finck { 1443c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 1444c2c66affSColin Finck return CR_FAILURE; 1445c2c66affSColin Finck } 1446c2c66affSColin Finck 1447c2c66affSColin Finck RpcTryExcept 1448c2c66affSColin Finck { 1449c2c66affSColin Finck ret = PNP_DeleteClassKey(BindingHandle, 1450c2c66affSColin Finck szGuidString, 1451c2c66affSColin Finck ulFlags); 1452c2c66affSColin Finck } 1453c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 1454c2c66affSColin Finck { 1455c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 1456c2c66affSColin Finck } 1457c2c66affSColin Finck RpcEndExcept; 1458c2c66affSColin Finck 1459c2c66affSColin Finck return ret; 1460c2c66affSColin Finck } 1461c2c66affSColin Finck 1462c2c66affSColin Finck 1463c2c66affSColin Finck /*********************************************************************** 1464c2c66affSColin Finck * CM_Delete_DevNode_Key [SETUPAPI.@] 1465c2c66affSColin Finck */ 1466d9a33981SEric Kohl CONFIGRET 1467d9a33981SEric Kohl WINAPI 1468d9a33981SEric Kohl CM_Delete_DevNode_Key( 1469d9a33981SEric Kohl _In_ DEVNODE dnDevNode, 1470d9a33981SEric Kohl _In_ ULONG ulHardwareProfile, 1471d9a33981SEric Kohl _In_ ULONG ulFlags) 1472c2c66affSColin Finck { 1473d9a33981SEric Kohl TRACE("CM_Delete_DevNode_Key(%p %lu %lx)\n", 1474d9a33981SEric Kohl dnDevNode, ulHardwareProfile, ulFlags); 147565d3bf74SEric Kohl 1476c2c66affSColin Finck return CM_Delete_DevNode_Key_Ex(dnDevNode, ulHardwareProfile, ulFlags, 1477c2c66affSColin Finck NULL); 1478c2c66affSColin Finck } 1479c2c66affSColin Finck 1480c2c66affSColin Finck 1481c2c66affSColin Finck /*********************************************************************** 1482c2c66affSColin Finck * CM_Delete_DevNode_Key_Ex [SETUPAPI.@] 1483c2c66affSColin Finck */ 1484d9a33981SEric Kohl CONFIGRET 1485d9a33981SEric Kohl WINAPI 1486d9a33981SEric Kohl CM_Delete_DevNode_Key_Ex( 1487d9a33981SEric Kohl _In_ DEVNODE dnDevNode, 1488d9a33981SEric Kohl _In_ ULONG ulHardwareProfile, 1489d9a33981SEric Kohl _In_ ULONG ulFlags, 1490d9a33981SEric Kohl _In_opt_ HANDLE hMachine) 1491c2c66affSColin Finck { 1492d9a33981SEric Kohl FIXME("CM_Delete_DevNode_Key_Ex(%p %lu %lx %p)\n", 1493c2c66affSColin Finck dnDevNode, ulHardwareProfile, ulFlags, hMachine); 1494c2c66affSColin Finck 1495c2c66affSColin Finck return CR_CALL_NOT_IMPLEMENTED; 1496c2c66affSColin Finck } 1497c2c66affSColin Finck 1498c2c66affSColin Finck 1499c2c66affSColin Finck /*********************************************************************** 1500c2c66affSColin Finck * CM_Delete_Range [SETUPAPI.@] 1501c2c66affSColin Finck */ 1502c2c66affSColin Finck CONFIGRET 1503c2c66affSColin Finck WINAPI 1504c2c66affSColin Finck CM_Delete_Range( 1505c2c66affSColin Finck _In_ DWORDLONG ullStartValue, 1506c2c66affSColin Finck _In_ DWORDLONG ullEndValue, 1507c2c66affSColin Finck _In_ RANGE_LIST rlh, 1508c2c66affSColin Finck _In_ ULONG ulFlags) 1509c2c66affSColin Finck { 1510c2c66affSColin Finck FIXME("CM_Delete_Range(%I64u %I64u %p %lx)\n", 1511c2c66affSColin Finck ullStartValue, ullEndValue, rlh, ulFlags); 151265d3bf74SEric Kohl 1513c2c66affSColin Finck return CR_CALL_NOT_IMPLEMENTED; 1514c2c66affSColin Finck } 1515c2c66affSColin Finck 1516c2c66affSColin Finck 1517c2c66affSColin Finck /*********************************************************************** 1518c2c66affSColin Finck * CM_Disable_DevNode [SETUPAPI.@] 1519c2c66affSColin Finck */ 1520c7fc2ef4SEric Kohl CONFIGRET 1521c7fc2ef4SEric Kohl WINAPI 1522c7fc2ef4SEric Kohl CM_Disable_DevNode( 1523c7fc2ef4SEric Kohl _In_ DEVINST dnDevInst, 1524c7fc2ef4SEric Kohl _In_ ULONG ulFlags) 1525c2c66affSColin Finck { 1526c7fc2ef4SEric Kohl TRACE("CM_Disable_DevNode(%p %lx)\n", 1527c7fc2ef4SEric Kohl dnDevInst, ulFlags); 152865d3bf74SEric Kohl 1529c2c66affSColin Finck return CM_Disable_DevNode_Ex(dnDevInst, ulFlags, NULL); 1530c2c66affSColin Finck } 1531c2c66affSColin Finck 1532c2c66affSColin Finck 1533c2c66affSColin Finck /*********************************************************************** 1534c2c66affSColin Finck * CM_Disable_DevNode_Ex [SETUPAPI.@] 1535c2c66affSColin Finck */ 1536c7fc2ef4SEric Kohl CONFIGRET 1537c7fc2ef4SEric Kohl WINAPI 1538c7fc2ef4SEric Kohl CM_Disable_DevNode_Ex( 1539c7fc2ef4SEric Kohl _In_ DEVINST dnDevInst, 1540c7fc2ef4SEric Kohl _In_ ULONG ulFlags, 1541c7fc2ef4SEric Kohl _In_opt_ HMACHINE hMachine) 1542c2c66affSColin Finck { 1543c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 1544c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 1545c2c66affSColin Finck LPWSTR lpDevInst; 1546c2c66affSColin Finck CONFIGRET ret; 1547c2c66affSColin Finck 1548c7fc2ef4SEric Kohl FIXME("CM_Disable_DevNode_Ex(%p %lx %p)\n", 1549c7fc2ef4SEric Kohl dnDevInst, ulFlags, hMachine); 1550c2c66affSColin Finck 1551c2c66affSColin Finck if (!pSetupIsUserAdmin()) 1552c2c66affSColin Finck return CR_ACCESS_DENIED; 1553c2c66affSColin Finck 1554c2c66affSColin Finck if (dnDevInst == 0) 1555c2c66affSColin Finck return CR_INVALID_DEVINST; 1556c2c66affSColin Finck 1557c2c66affSColin Finck if (ulFlags != 0) 1558c2c66affSColin Finck return CR_INVALID_FLAG; 1559c2c66affSColin Finck 1560c2c66affSColin Finck if (hMachine != NULL) 1561c2c66affSColin Finck { 1562c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 1563c2c66affSColin Finck if (BindingHandle == NULL) 1564c2c66affSColin Finck return CR_FAILURE; 1565c2c66affSColin Finck 1566c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 1567c2c66affSColin Finck if (StringTable == 0) 1568c2c66affSColin Finck return CR_FAILURE; 1569c2c66affSColin Finck } 1570c2c66affSColin Finck else 1571c2c66affSColin Finck { 1572c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 1573c2c66affSColin Finck return CR_FAILURE; 1574c2c66affSColin Finck } 1575c2c66affSColin Finck 1576c2c66affSColin Finck lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst); 1577c2c66affSColin Finck if (lpDevInst == NULL) 1578c2c66affSColin Finck return CR_INVALID_DEVNODE; 1579c2c66affSColin Finck 1580c2c66affSColin Finck RpcTryExcept 1581c2c66affSColin Finck { 1582c2c66affSColin Finck ret = PNP_DeviceInstanceAction(BindingHandle, 1583c2c66affSColin Finck PNP_DEVINST_DISABLE, 1584c2c66affSColin Finck ulFlags, 1585c2c66affSColin Finck lpDevInst, 1586c2c66affSColin Finck NULL); 1587c2c66affSColin Finck } 1588c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 1589c2c66affSColin Finck { 1590c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 1591c2c66affSColin Finck } 1592c2c66affSColin Finck RpcEndExcept; 1593c2c66affSColin Finck 1594c2c66affSColin Finck return ret; 1595c2c66affSColin Finck } 1596c2c66affSColin Finck 1597c2c66affSColin Finck 1598c2c66affSColin Finck /*********************************************************************** 1599c2c66affSColin Finck * CM_Disconnect_Machine [SETUPAPI.@] 1600c2c66affSColin Finck */ 1601c7fc2ef4SEric Kohl CONFIGRET 1602c7fc2ef4SEric Kohl WINAPI 1603c7fc2ef4SEric Kohl CM_Disconnect_Machine( 1604c7fc2ef4SEric Kohl _In_opt_ HMACHINE hMachine) 1605c2c66affSColin Finck { 1606c2c66affSColin Finck PMACHINE_INFO pMachine; 1607c2c66affSColin Finck 160860a21894SEric Kohl TRACE("CM_Disconnect_Machine(%p)\n", hMachine); 1609c2c66affSColin Finck 1610c2c66affSColin Finck pMachine = (PMACHINE_INFO)hMachine; 1611c2c66affSColin Finck if (pMachine == NULL) 1612c2c66affSColin Finck return CR_SUCCESS; 1613c2c66affSColin Finck 1614c2c66affSColin Finck if (pMachine->bLocal == FALSE) 1615c2c66affSColin Finck { 1616c2c66affSColin Finck if (pMachine->StringTable != NULL) 1617c2c66affSColin Finck pSetupStringTableDestroy(pMachine->StringTable); 1618c2c66affSColin Finck 1619c2c66affSColin Finck if (!PnpUnbindRpc(pMachine->BindingHandle)) 1620c2c66affSColin Finck return CR_ACCESS_DENIED; 1621c2c66affSColin Finck } 1622c2c66affSColin Finck 1623c2c66affSColin Finck HeapFree(GetProcessHeap(), 0, pMachine); 1624c2c66affSColin Finck 1625c2c66affSColin Finck return CR_SUCCESS; 1626c2c66affSColin Finck } 1627c2c66affSColin Finck 1628c2c66affSColin Finck 1629c2c66affSColin Finck /*********************************************************************** 1630c2c66affSColin Finck * CM_Dup_Range_List [SETUPAPI.@] 1631c2c66affSColin Finck */ 1632c2c66affSColin Finck CONFIGRET 1633c2c66affSColin Finck WINAPI 1634c2c66affSColin Finck CM_Dup_Range_List( 1635c2c66affSColin Finck _In_ RANGE_LIST rlhOld, 1636c2c66affSColin Finck _In_ RANGE_LIST rlhNew, 1637c2c66affSColin Finck _In_ ULONG ulFlags) 1638c2c66affSColin Finck { 1639c2c66affSColin Finck FIXME("CM_Dup_Range_List(%p %p %lx)\n", 1640c2c66affSColin Finck rlhOld, rlhNew, ulFlags); 164165d3bf74SEric Kohl 1642c2c66affSColin Finck return CR_CALL_NOT_IMPLEMENTED; 1643c2c66affSColin Finck } 1644c2c66affSColin Finck 1645c2c66affSColin Finck 1646c2c66affSColin Finck /*********************************************************************** 1647c2c66affSColin Finck * CM_Enable_DevNode [SETUPAPI.@] 1648c2c66affSColin Finck */ 1649c7fc2ef4SEric Kohl CONFIGRET 1650c7fc2ef4SEric Kohl WINAPI 1651c7fc2ef4SEric Kohl CM_Enable_DevNode( 1652c7fc2ef4SEric Kohl _In_ DEVINST dnDevInst, 1653c7fc2ef4SEric Kohl _In_ ULONG ulFlags) 1654c2c66affSColin Finck { 165565d3bf74SEric Kohl TRACE("CM_Enable_DevNode(%p %lx)\n", 165665d3bf74SEric Kohl dnDevInst, ulFlags); 165765d3bf74SEric Kohl 1658c2c66affSColin Finck return CM_Enable_DevNode_Ex(dnDevInst, ulFlags, NULL); 1659c2c66affSColin Finck } 1660c2c66affSColin Finck 1661c2c66affSColin Finck 1662c2c66affSColin Finck /*********************************************************************** 1663c2c66affSColin Finck * CM_Enable_DevNode_Ex [SETUPAPI.@] 1664c2c66affSColin Finck */ 1665c7fc2ef4SEric Kohl CONFIGRET 1666c7fc2ef4SEric Kohl WINAPI 1667c7fc2ef4SEric Kohl CM_Enable_DevNode_Ex( 1668c7fc2ef4SEric Kohl _In_ DEVINST dnDevInst, 1669c7fc2ef4SEric Kohl _In_ ULONG ulFlags, 1670c7fc2ef4SEric Kohl _In_opt_ HMACHINE hMachine) 1671c2c66affSColin Finck { 1672c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 1673c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 1674c2c66affSColin Finck LPWSTR lpDevInst; 1675c2c66affSColin Finck CONFIGRET ret; 1676c2c66affSColin Finck 167765d3bf74SEric Kohl TRACE("CM_Enable_DevNode_Ex(%p %lx %p)\n", 167865d3bf74SEric Kohl dnDevInst, ulFlags, hMachine); 1679c2c66affSColin Finck 1680c2c66affSColin Finck if (!pSetupIsUserAdmin()) 1681c2c66affSColin Finck return CR_ACCESS_DENIED; 1682c2c66affSColin Finck 1683c2c66affSColin Finck if (dnDevInst == 0) 1684c2c66affSColin Finck return CR_INVALID_DEVINST; 1685c2c66affSColin Finck 1686c2c66affSColin Finck if (ulFlags != 0) 1687c2c66affSColin Finck return CR_INVALID_FLAG; 1688c2c66affSColin Finck 1689c2c66affSColin Finck if (hMachine != NULL) 1690c2c66affSColin Finck { 1691c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 1692c2c66affSColin Finck if (BindingHandle == NULL) 1693c2c66affSColin Finck return CR_FAILURE; 1694c2c66affSColin Finck 1695c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 1696c2c66affSColin Finck if (StringTable == 0) 1697c2c66affSColin Finck return CR_FAILURE; 1698c2c66affSColin Finck } 1699c2c66affSColin Finck else 1700c2c66affSColin Finck { 1701c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 1702c2c66affSColin Finck return CR_FAILURE; 1703c2c66affSColin Finck } 1704c2c66affSColin Finck 1705c2c66affSColin Finck lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst); 1706c2c66affSColin Finck if (lpDevInst == NULL) 1707c2c66affSColin Finck return CR_INVALID_DEVNODE; 1708c2c66affSColin Finck 1709c2c66affSColin Finck RpcTryExcept 1710c2c66affSColin Finck { 1711c2c66affSColin Finck ret = PNP_DeviceInstanceAction(BindingHandle, 1712c2c66affSColin Finck PNP_DEVINST_ENABLE, 1713c2c66affSColin Finck ulFlags, 1714c2c66affSColin Finck lpDevInst, 1715c2c66affSColin Finck NULL); 1716c2c66affSColin Finck } 1717c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 1718c2c66affSColin Finck { 1719c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 1720c2c66affSColin Finck } 1721c2c66affSColin Finck RpcEndExcept; 1722c2c66affSColin Finck 1723c2c66affSColin Finck return ret; 1724c2c66affSColin Finck } 1725c2c66affSColin Finck 1726c2c66affSColin Finck 1727c2c66affSColin Finck /*********************************************************************** 1728c2c66affSColin Finck * CM_Enumerate_Classes [SETUPAPI.@] 1729c2c66affSColin Finck */ 1730c7fc2ef4SEric Kohl CONFIGRET 1731c7fc2ef4SEric Kohl WINAPI 1732c7fc2ef4SEric Kohl CM_Enumerate_Classes( 1733c7fc2ef4SEric Kohl _In_ ULONG ulClassIndex, 1734c7fc2ef4SEric Kohl _Out_ LPGUID ClassGuid, 1735c7fc2ef4SEric Kohl _In_ ULONG ulFlags) 1736c2c66affSColin Finck { 1737c7fc2ef4SEric Kohl TRACE("CM_Enumerate_Classes(%lx %p %lx)\n", 1738c7fc2ef4SEric Kohl ulClassIndex, ClassGuid, ulFlags); 1739c7fc2ef4SEric Kohl 1740c2c66affSColin Finck return CM_Enumerate_Classes_Ex(ulClassIndex, ClassGuid, ulFlags, NULL); 1741c2c66affSColin Finck } 1742c2c66affSColin Finck 1743c2c66affSColin Finck 1744c2c66affSColin Finck /*********************************************************************** 1745c2c66affSColin Finck * CM_Enumerate_Classes_Ex [SETUPAPI.@] 1746c2c66affSColin Finck */ 1747c7fc2ef4SEric Kohl CONFIGRET 1748c7fc2ef4SEric Kohl WINAPI 1749c7fc2ef4SEric Kohl CM_Enumerate_Classes_Ex( 1750c7fc2ef4SEric Kohl _In_ ULONG ulClassIndex, 1751c7fc2ef4SEric Kohl _Out_ LPGUID ClassGuid, 1752c7fc2ef4SEric Kohl _In_ ULONG ulFlags, 1753c7fc2ef4SEric Kohl _In_opt_ HMACHINE hMachine) 1754c2c66affSColin Finck { 1755c2c66affSColin Finck WCHAR szBuffer[MAX_GUID_STRING_LEN]; 1756c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 1757c2c66affSColin Finck CONFIGRET ret = CR_SUCCESS; 1758c2c66affSColin Finck ULONG ulLength = MAX_GUID_STRING_LEN; 1759c2c66affSColin Finck 1760c7fc2ef4SEric Kohl TRACE("CM_Enumerate_Classes_Ex(%lx %p %lx %p)\n", 1761c7fc2ef4SEric Kohl ulClassIndex, ClassGuid, ulFlags, hMachine); 1762c2c66affSColin Finck 1763c2c66affSColin Finck if (ClassGuid == NULL) 1764c2c66affSColin Finck return CR_INVALID_POINTER; 1765c2c66affSColin Finck 1766c2c66affSColin Finck if (ulFlags != 0) 1767c2c66affSColin Finck return CR_INVALID_FLAG; 1768c2c66affSColin Finck 1769c2c66affSColin Finck if (hMachine != NULL) 1770c2c66affSColin Finck { 1771c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 1772c2c66affSColin Finck if (BindingHandle == NULL) 1773c2c66affSColin Finck return CR_FAILURE; 1774c2c66affSColin Finck } 1775c2c66affSColin Finck else 1776c2c66affSColin Finck { 1777c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 1778c2c66affSColin Finck return CR_FAILURE; 1779c2c66affSColin Finck } 1780c2c66affSColin Finck 1781c2c66affSColin Finck RpcTryExcept 1782c2c66affSColin Finck { 1783c2c66affSColin Finck ret = PNP_EnumerateSubKeys(BindingHandle, 1784c2c66affSColin Finck PNP_CLASS_SUBKEYS, 1785c2c66affSColin Finck ulClassIndex, 1786c2c66affSColin Finck szBuffer, 1787c2c66affSColin Finck MAX_GUID_STRING_LEN, 1788c2c66affSColin Finck &ulLength, 1789c2c66affSColin Finck ulFlags); 1790c2c66affSColin Finck } 1791c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 1792c2c66affSColin Finck { 1793c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 1794c2c66affSColin Finck } 1795c2c66affSColin Finck RpcEndExcept; 1796c2c66affSColin Finck 1797c2c66affSColin Finck if (ret == CR_SUCCESS) 1798c2c66affSColin Finck { 1799c2c66affSColin Finck /* Remove the {} */ 1800c2c66affSColin Finck szBuffer[MAX_GUID_STRING_LEN - 2] = UNICODE_NULL; 1801c2c66affSColin Finck 1802c2c66affSColin Finck /* Convert the buffer to a GUID */ 1803c2c66affSColin Finck if (UuidFromStringW(&szBuffer[1], ClassGuid) != RPC_S_OK) 1804c2c66affSColin Finck return CR_FAILURE; 1805c2c66affSColin Finck } 1806c2c66affSColin Finck 1807c2c66affSColin Finck return ret; 1808c2c66affSColin Finck } 1809c2c66affSColin Finck 1810c2c66affSColin Finck 1811c2c66affSColin Finck /*********************************************************************** 1812c2c66affSColin Finck * CM_Enumerate_EnumeratorsA [SETUPAPI.@] 1813c2c66affSColin Finck */ 1814c7fc2ef4SEric Kohl CONFIGRET 1815c7fc2ef4SEric Kohl WINAPI 1816c7fc2ef4SEric Kohl CM_Enumerate_EnumeratorsA( 1817c7fc2ef4SEric Kohl _In_ ULONG ulEnumIndex, 181865d3bf74SEric Kohl _Out_writes_(*pulLength) PCHAR Buffer, 1819c7fc2ef4SEric Kohl _Inout_ PULONG pulLength, 1820c7fc2ef4SEric Kohl _In_ ULONG ulFlags) 1821c2c66affSColin Finck { 1822c7fc2ef4SEric Kohl TRACE("CM_Enumerate_EnumeratorsA(%lu %p %p %lx)\n", 1823c7fc2ef4SEric Kohl ulEnumIndex, Buffer, pulLength, ulFlags); 1824c7fc2ef4SEric Kohl 1825c2c66affSColin Finck return CM_Enumerate_Enumerators_ExA(ulEnumIndex, Buffer, pulLength, 1826c2c66affSColin Finck ulFlags, NULL); 1827c2c66affSColin Finck } 1828c2c66affSColin Finck 1829c2c66affSColin Finck 1830c2c66affSColin Finck /*********************************************************************** 1831c2c66affSColin Finck * CM_Enumerate_EnumeratorsW [SETUPAPI.@] 1832c2c66affSColin Finck */ 1833c7fc2ef4SEric Kohl CONFIGRET 1834c7fc2ef4SEric Kohl WINAPI 1835c7fc2ef4SEric Kohl CM_Enumerate_EnumeratorsW( 1836c7fc2ef4SEric Kohl _In_ ULONG ulEnumIndex, 183765d3bf74SEric Kohl _Out_writes_(*pulLength) PWCHAR Buffer, 1838c7fc2ef4SEric Kohl _Inout_ PULONG pulLength, 1839c7fc2ef4SEric Kohl _In_ ULONG ulFlags) 1840c2c66affSColin Finck { 1841c7fc2ef4SEric Kohl TRACE("CM_Enumerate_EnumeratorsW(%lu %p %p %lx)\n", 1842c7fc2ef4SEric Kohl ulEnumIndex, Buffer, pulLength, ulFlags); 1843c7fc2ef4SEric Kohl 1844c2c66affSColin Finck return CM_Enumerate_Enumerators_ExW(ulEnumIndex, Buffer, pulLength, 1845c2c66affSColin Finck ulFlags, NULL); 1846c2c66affSColin Finck } 1847c2c66affSColin Finck 1848c2c66affSColin Finck 1849c2c66affSColin Finck /*********************************************************************** 1850c2c66affSColin Finck * CM_Enumerate_Enumerators_ExA [SETUPAPI.@] 1851c2c66affSColin Finck */ 1852c7fc2ef4SEric Kohl CONFIGRET 1853c7fc2ef4SEric Kohl WINAPI 1854c7fc2ef4SEric Kohl CM_Enumerate_Enumerators_ExA( 1855c7fc2ef4SEric Kohl _In_ ULONG ulEnumIndex, 185665d3bf74SEric Kohl _Out_writes_(*pulLength) PCHAR Buffer, 1857c7fc2ef4SEric Kohl _Inout_ PULONG pulLength, 1858c7fc2ef4SEric Kohl _In_ ULONG ulFlags, 1859c7fc2ef4SEric Kohl _In_opt_ HMACHINE hMachine) 1860c2c66affSColin Finck { 1861c2c66affSColin Finck WCHAR szBuffer[MAX_DEVICE_ID_LEN]; 1862c2c66affSColin Finck ULONG ulOrigLength; 1863c2c66affSColin Finck ULONG ulLength; 1864c2c66affSColin Finck CONFIGRET ret = CR_SUCCESS; 1865c2c66affSColin Finck 186660a21894SEric Kohl TRACE("CM_Enumerate_Enumerators_ExA(%lu %p %p %lx %p)\n", 1867c7fc2ef4SEric Kohl ulEnumIndex, Buffer, pulLength, ulFlags, hMachine); 1868c2c66affSColin Finck 1869c2c66affSColin Finck if (Buffer == NULL || pulLength == NULL) 1870c2c66affSColin Finck return CR_INVALID_POINTER; 1871c2c66affSColin Finck 1872c2c66affSColin Finck if (ulFlags != 0) 1873c2c66affSColin Finck return CR_INVALID_FLAG; 1874c2c66affSColin Finck 1875c2c66affSColin Finck ulOrigLength = *pulLength; 1876c2c66affSColin Finck *pulLength = 0; 1877c2c66affSColin Finck 1878c2c66affSColin Finck ulLength = MAX_DEVICE_ID_LEN; 1879c2c66affSColin Finck ret = CM_Enumerate_Enumerators_ExW(ulEnumIndex, szBuffer, &ulLength, 1880c2c66affSColin Finck ulFlags, hMachine); 1881c2c66affSColin Finck if (ret == CR_SUCCESS) 1882c2c66affSColin Finck { 1883c2c66affSColin Finck if (WideCharToMultiByte(CP_ACP, 1884c2c66affSColin Finck 0, 1885c2c66affSColin Finck szBuffer, 1886c2c66affSColin Finck ulLength, 1887c2c66affSColin Finck Buffer, 1888c2c66affSColin Finck ulOrigLength, 1889c2c66affSColin Finck NULL, 1890c2c66affSColin Finck NULL) == 0) 1891c2c66affSColin Finck ret = CR_FAILURE; 1892c2c66affSColin Finck else 1893c2c66affSColin Finck *pulLength = lstrlenA(Buffer) + 1; 1894c2c66affSColin Finck } 1895c2c66affSColin Finck 1896c2c66affSColin Finck return ret; 1897c2c66affSColin Finck } 1898c2c66affSColin Finck 1899c2c66affSColin Finck 1900c2c66affSColin Finck /*********************************************************************** 1901c2c66affSColin Finck * CM_Enumerate_Enumerators_ExW [SETUPAPI.@] 1902c2c66affSColin Finck */ 1903c7fc2ef4SEric Kohl CONFIGRET 1904c7fc2ef4SEric Kohl WINAPI 1905c7fc2ef4SEric Kohl CM_Enumerate_Enumerators_ExW( 1906c7fc2ef4SEric Kohl _In_ ULONG ulEnumIndex, 190765d3bf74SEric Kohl _Out_writes_(*pulLength) PWCHAR Buffer, 1908c7fc2ef4SEric Kohl _Inout_ PULONG pulLength, 1909c7fc2ef4SEric Kohl _In_ ULONG ulFlags, 1910c7fc2ef4SEric Kohl _In_opt_ HMACHINE hMachine) 1911c2c66affSColin Finck { 1912c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 1913c2c66affSColin Finck CONFIGRET ret; 1914c2c66affSColin Finck 191560a21894SEric Kohl TRACE("CM_Enumerate_Enumerators_ExW(%lu %p %p %lx %p)\n", 1916c7fc2ef4SEric Kohl ulEnumIndex, Buffer, pulLength, ulFlags, hMachine); 1917c2c66affSColin Finck 1918c2c66affSColin Finck if (Buffer == NULL || pulLength == NULL) 1919c2c66affSColin Finck return CR_INVALID_POINTER; 1920c2c66affSColin Finck 1921c2c66affSColin Finck if (ulFlags != 0) 1922c2c66affSColin Finck return CR_INVALID_FLAG; 1923c2c66affSColin Finck 1924c2c66affSColin Finck *Buffer = UNICODE_NULL; 1925c2c66affSColin Finck 1926c2c66affSColin Finck if (hMachine != NULL) 1927c2c66affSColin Finck { 1928c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 1929c2c66affSColin Finck if (BindingHandle == NULL) 1930c2c66affSColin Finck return CR_FAILURE; 1931c2c66affSColin Finck } 1932c2c66affSColin Finck else 1933c2c66affSColin Finck { 1934c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 1935c2c66affSColin Finck return CR_FAILURE; 1936c2c66affSColin Finck } 1937c2c66affSColin Finck 1938c2c66affSColin Finck RpcTryExcept 1939c2c66affSColin Finck { 1940c2c66affSColin Finck ret = PNP_EnumerateSubKeys(BindingHandle, 1941c2c66affSColin Finck PNP_ENUMERATOR_SUBKEYS, 1942c2c66affSColin Finck ulEnumIndex, 1943c2c66affSColin Finck Buffer, 1944c2c66affSColin Finck *pulLength, 1945c2c66affSColin Finck pulLength, 1946c2c66affSColin Finck ulFlags); 1947c2c66affSColin Finck } 1948c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 1949c2c66affSColin Finck { 1950c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 1951c2c66affSColin Finck } 1952c2c66affSColin Finck RpcEndExcept; 1953c2c66affSColin Finck 1954c2c66affSColin Finck return ret; 1955c2c66affSColin Finck } 1956c2c66affSColin Finck 1957c2c66affSColin Finck 1958c2c66affSColin Finck /*********************************************************************** 1959c2c66affSColin Finck * CM_Find_Range [SETUPAPI.@] 1960c2c66affSColin Finck */ 1961c2c66affSColin Finck CONFIGRET 1962c2c66affSColin Finck WINAPI 1963c2c66affSColin Finck CM_Find_Range( 1964c2c66affSColin Finck _Out_ PDWORDLONG pullStart, 1965c2c66affSColin Finck _In_ DWORDLONG ullStart, 1966c2c66affSColin Finck _In_ ULONG ulLength, 1967c2c66affSColin Finck _In_ DWORDLONG ullAlignment, 1968c2c66affSColin Finck _In_ DWORDLONG ullEnd, 1969c2c66affSColin Finck _In_ RANGE_LIST rlh, 1970c2c66affSColin Finck _In_ ULONG ulFlags) 1971c2c66affSColin Finck { 1972c2c66affSColin Finck FIXME("CM_Find_Range(%p %I64u %lu %I64u %I64u %p %lx)\n", 1973c2c66affSColin Finck pullStart, ullStart, ulLength, ullAlignment, ullEnd, rlh, ulFlags); 197465d3bf74SEric Kohl 1975c2c66affSColin Finck return CR_CALL_NOT_IMPLEMENTED; 1976c2c66affSColin Finck } 1977c2c66affSColin Finck 1978c2c66affSColin Finck 1979c2c66affSColin Finck /*********************************************************************** 1980c2c66affSColin Finck * CM_First_Range [SETUPAPI.@] 1981c2c66affSColin Finck */ 1982c2c66affSColin Finck CONFIGRET 1983c2c66affSColin Finck WINAPI 1984c2c66affSColin Finck CM_First_Range( 1985c2c66affSColin Finck _In_ RANGE_LIST rlh, 1986c2c66affSColin Finck _Out_ PDWORDLONG pullStart, 1987c2c66affSColin Finck _Out_ PDWORDLONG pullEnd, 1988c2c66affSColin Finck _Out_ PRANGE_ELEMENT preElement, 1989c2c66affSColin Finck _In_ ULONG ulFlags) 1990c2c66affSColin Finck { 19913ad5c7fdSEric Kohl PINTERNAL_RANGE_LIST pRangeList; 19923ad5c7fdSEric Kohl PINTERNAL_RANGE pRange; 19933ad5c7fdSEric Kohl PLIST_ENTRY ListEntry; 19943ad5c7fdSEric Kohl CONFIGRET ret = CR_SUCCESS; 19953ad5c7fdSEric Kohl 1996c2c66affSColin Finck FIXME("CM_First_Range(%p %p %p %p %lx)\n", 1997c2c66affSColin Finck rlh, pullStart, pullEnd, preElement, ulFlags); 19983ad5c7fdSEric Kohl 19993ad5c7fdSEric Kohl pRangeList = (PINTERNAL_RANGE_LIST)rlh; 20003ad5c7fdSEric Kohl 20013ad5c7fdSEric Kohl if (!IsValidRangeList(pRangeList)) 20023ad5c7fdSEric Kohl return CR_INVALID_RANGE_LIST; 20033ad5c7fdSEric Kohl 20043ad5c7fdSEric Kohl if (pullStart == NULL || pullEnd == NULL || preElement == NULL) 20053ad5c7fdSEric Kohl return CR_INVALID_POINTER; 20063ad5c7fdSEric Kohl 20073ad5c7fdSEric Kohl if (ulFlags != 0) 20083ad5c7fdSEric Kohl return CR_INVALID_FLAG; 20093ad5c7fdSEric Kohl 20103ad5c7fdSEric Kohl /* Lock the range list */ 20113ad5c7fdSEric Kohl WaitForSingleObject(pRangeList->hMutex, INFINITE); 20123ad5c7fdSEric Kohl 20133ad5c7fdSEric Kohl /* Fail, if the list is empty */ 20143ad5c7fdSEric Kohl if (IsListEmpty(&pRangeList->ListHead)) 20153ad5c7fdSEric Kohl { 20163ad5c7fdSEric Kohl ret = CR_FAILURE; 20173ad5c7fdSEric Kohl goto done; 20183ad5c7fdSEric Kohl } 20193ad5c7fdSEric Kohl 20203ad5c7fdSEric Kohl /* Get the first range */ 20213ad5c7fdSEric Kohl ListEntry = pRangeList->ListHead.Flink; 20223ad5c7fdSEric Kohl pRange = CONTAINING_RECORD(ListEntry, INTERNAL_RANGE, ListEntry); 20233ad5c7fdSEric Kohl 20243ad5c7fdSEric Kohl /* Return the range data */ 20253ad5c7fdSEric Kohl *pullStart = pRange->ullStart; 20263ad5c7fdSEric Kohl *pullEnd = pRange->ullEnd; 20273ad5c7fdSEric Kohl *preElement = (RANGE_ELEMENT)pRange; 20283ad5c7fdSEric Kohl 20293ad5c7fdSEric Kohl done: 20303ad5c7fdSEric Kohl /* Unlock the range list */ 20313ad5c7fdSEric Kohl ReleaseMutex(pRangeList->hMutex); 20323ad5c7fdSEric Kohl 20333ad5c7fdSEric Kohl return ret; 2034c2c66affSColin Finck } 2035c2c66affSColin Finck 2036c2c66affSColin Finck 2037c2c66affSColin Finck /*********************************************************************** 2038c2c66affSColin Finck * CM_Free_Log_Conf [SETUPAPI.@] 2039c2c66affSColin Finck */ 2040c7fc2ef4SEric Kohl CONFIGRET 2041c7fc2ef4SEric Kohl WINAPI 2042c7fc2ef4SEric Kohl CM_Free_Log_Conf( 2043c7fc2ef4SEric Kohl _In_ LOG_CONF lcLogConfToBeFreed, 2044c7fc2ef4SEric Kohl _In_ ULONG ulFlags) 2045c2c66affSColin Finck { 2046c7fc2ef4SEric Kohl TRACE("CM_Free_Log_Conf(%lx %lx)\n", 2047c7fc2ef4SEric Kohl lcLogConfToBeFreed, ulFlags); 2048c7fc2ef4SEric Kohl 2049c2c66affSColin Finck return CM_Free_Log_Conf_Ex(lcLogConfToBeFreed, ulFlags, NULL); 2050c2c66affSColin Finck } 2051c2c66affSColin Finck 2052c2c66affSColin Finck 2053c2c66affSColin Finck /*********************************************************************** 2054c2c66affSColin Finck * CM_Free_Log_Conf_Ex [SETUPAPI.@] 2055c2c66affSColin Finck */ 2056c7fc2ef4SEric Kohl CONFIGRET 2057c7fc2ef4SEric Kohl WINAPI 2058c7fc2ef4SEric Kohl CM_Free_Log_Conf_Ex( 2059c7fc2ef4SEric Kohl _In_ LOG_CONF lcLogConfToBeFreed, 2060c7fc2ef4SEric Kohl _In_ ULONG ulFlags, 2061c7fc2ef4SEric Kohl _In_opt_ HMACHINE hMachine) 2062c2c66affSColin Finck { 2063c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 2064c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 2065c2c66affSColin Finck LPWSTR lpDevInst; 2066c2c66affSColin Finck PLOG_CONF_INFO pLogConfInfo; 2067c2c66affSColin Finck CONFIGRET ret; 2068c2c66affSColin Finck 206960a21894SEric Kohl TRACE("CM_Free_Log_Conf_Ex(%lx %lx %p)\n", 2070c7fc2ef4SEric Kohl lcLogConfToBeFreed, ulFlags, hMachine); 2071c2c66affSColin Finck 2072c2c66affSColin Finck if (!pSetupIsUserAdmin()) 2073c2c66affSColin Finck return CR_ACCESS_DENIED; 2074c2c66affSColin Finck 2075c2c66affSColin Finck pLogConfInfo = (PLOG_CONF_INFO)lcLogConfToBeFreed; 207619fc20f2SEric Kohl if (!IsValidLogConf(pLogConfInfo)) 2077c2c66affSColin Finck return CR_INVALID_LOG_CONF; 2078c2c66affSColin Finck 2079c2c66affSColin Finck if (ulFlags != 0) 2080c2c66affSColin Finck return CR_INVALID_FLAG; 2081c2c66affSColin Finck 2082c2c66affSColin Finck if (hMachine != NULL) 2083c2c66affSColin Finck { 2084c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 2085c2c66affSColin Finck if (BindingHandle == NULL) 2086c2c66affSColin Finck return CR_FAILURE; 2087c2c66affSColin Finck 2088c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 2089c2c66affSColin Finck if (StringTable == 0) 2090c2c66affSColin Finck return CR_FAILURE; 2091c2c66affSColin Finck } 2092c2c66affSColin Finck else 2093c2c66affSColin Finck { 2094c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 2095c2c66affSColin Finck return CR_FAILURE; 2096c2c66affSColin Finck } 2097c2c66affSColin Finck 2098c2c66affSColin Finck lpDevInst = pSetupStringTableStringFromId(StringTable, pLogConfInfo->dnDevInst); 2099c2c66affSColin Finck if (lpDevInst == NULL) 2100c2c66affSColin Finck return CR_INVALID_DEVNODE; 2101c2c66affSColin Finck 2102c2c66affSColin Finck RpcTryExcept 2103c2c66affSColin Finck { 2104c2c66affSColin Finck ret = PNP_FreeLogConf(BindingHandle, lpDevInst, pLogConfInfo->ulFlags, 2105c2c66affSColin Finck pLogConfInfo->ulTag, 0); 2106c2c66affSColin Finck } 2107c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 2108c2c66affSColin Finck { 2109c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 2110c2c66affSColin Finck } 2111c2c66affSColin Finck RpcEndExcept; 2112c2c66affSColin Finck 2113c2c66affSColin Finck return ret; 2114c2c66affSColin Finck } 2115c2c66affSColin Finck 2116c2c66affSColin Finck 2117c2c66affSColin Finck /*********************************************************************** 2118c2c66affSColin Finck * CM_Free_Log_Conf_Handle [SETUPAPI.@] 2119c2c66affSColin Finck */ 2120c7fc2ef4SEric Kohl CONFIGRET 2121c7fc2ef4SEric Kohl WINAPI 2122c7fc2ef4SEric Kohl CM_Free_Log_Conf_Handle( 2123c7fc2ef4SEric Kohl _In_ LOG_CONF lcLogConf) 2124c2c66affSColin Finck { 2125c2c66affSColin Finck PLOG_CONF_INFO pLogConfInfo; 2126c2c66affSColin Finck 2127c7fc2ef4SEric Kohl TRACE("CM_Free_Log_Conf_Handle(%lx)\n", lcLogConf); 2128c2c66affSColin Finck 2129c2c66affSColin Finck pLogConfInfo = (PLOG_CONF_INFO)lcLogConf; 213019fc20f2SEric Kohl if (!IsValidLogConf(pLogConfInfo)) 2131c2c66affSColin Finck return CR_INVALID_LOG_CONF; 2132c2c66affSColin Finck 2133c2c66affSColin Finck HeapFree(GetProcessHeap(), 0, pLogConfInfo); 2134c2c66affSColin Finck 2135c2c66affSColin Finck return CR_SUCCESS; 2136c2c66affSColin Finck } 2137c2c66affSColin Finck 2138c2c66affSColin Finck 2139c2c66affSColin Finck /*********************************************************************** 2140c2c66affSColin Finck * CM_Free_Range_List [SETUPAPI.@] 2141c2c66affSColin Finck */ 2142c2c66affSColin Finck CONFIGRET 2143c2c66affSColin Finck WINAPI 2144c2c66affSColin Finck CM_Free_Range_List( 2145c2c66affSColin Finck _In_ RANGE_LIST RangeList, 2146c2c66affSColin Finck _In_ ULONG ulFlags) 2147c2c66affSColin Finck { 2148c2c66affSColin Finck PINTERNAL_RANGE_LIST pRangeList; 21493ad5c7fdSEric Kohl PINTERNAL_RANGE pRange; 21503ad5c7fdSEric Kohl PLIST_ENTRY ListEntry; 2151c2c66affSColin Finck 21523ad5c7fdSEric Kohl FIXME("CM_Free_Range_List(%p %lx)\n", 21533ad5c7fdSEric Kohl RangeList, ulFlags); 2154c2c66affSColin Finck 2155c2c66affSColin Finck pRangeList = (PINTERNAL_RANGE_LIST)RangeList; 2156c2c66affSColin Finck 21573ad5c7fdSEric Kohl if (!IsValidRangeList(pRangeList)) 2158c2c66affSColin Finck return CR_INVALID_RANGE_LIST; 2159c2c66affSColin Finck 2160c2c66affSColin Finck if (ulFlags != 0) 2161c2c66affSColin Finck return CR_INVALID_FLAG; 2162c2c66affSColin Finck 21633ad5c7fdSEric Kohl /* Lock the range list */ 21643ad5c7fdSEric Kohl WaitForSingleObject(pRangeList->hMutex, INFINITE); 2165c2c66affSColin Finck 21663ad5c7fdSEric Kohl /* Free the list of ranges */ 21673ad5c7fdSEric Kohl while (!IsListEmpty(&pRangeList->ListHead)) 21683ad5c7fdSEric Kohl { 21693ad5c7fdSEric Kohl ListEntry = RemoveHeadList(&pRangeList->ListHead); 21703ad5c7fdSEric Kohl pRange = CONTAINING_RECORD(ListEntry, INTERNAL_RANGE, ListEntry); 21713ad5c7fdSEric Kohl HeapFree(GetProcessHeap(), 0, pRange); 21723ad5c7fdSEric Kohl } 21733ad5c7fdSEric Kohl 21743ad5c7fdSEric Kohl /* Unlock the range list */ 21753ad5c7fdSEric Kohl ReleaseMutex(pRangeList->hMutex); 21763ad5c7fdSEric Kohl 21773ad5c7fdSEric Kohl /* Close the mutex */ 21783ad5c7fdSEric Kohl CloseHandle(pRangeList->hMutex); 21793ad5c7fdSEric Kohl 21803ad5c7fdSEric Kohl /* Free the range list */ 2181c2c66affSColin Finck HeapFree(GetProcessHeap(), 0, pRangeList); 2182c2c66affSColin Finck 2183c2c66affSColin Finck return CR_SUCCESS; 2184c2c66affSColin Finck } 2185c2c66affSColin Finck 2186c2c66affSColin Finck 2187c2c66affSColin Finck /*********************************************************************** 2188c2c66affSColin Finck * CM_Free_Res_Des [SETUPAPI.@] 2189c2c66affSColin Finck */ 2190c7fc2ef4SEric Kohl CONFIGRET 2191c7fc2ef4SEric Kohl WINAPI 2192c7fc2ef4SEric Kohl CM_Free_Res_Des( 2193c7fc2ef4SEric Kohl _Out_ PRES_DES prdResDes, 2194c7fc2ef4SEric Kohl _In_ RES_DES rdResDes, 2195c7fc2ef4SEric Kohl _In_ ULONG ulFlags) 2196c2c66affSColin Finck { 2197c7fc2ef4SEric Kohl TRACE("CM_Free_Res_Des(%p %p %lx)\n", 2198c7fc2ef4SEric Kohl prdResDes, rdResDes, ulFlags); 2199c7fc2ef4SEric Kohl 2200c2c66affSColin Finck return CM_Free_Res_Des_Ex(prdResDes, rdResDes, ulFlags, NULL); 2201c2c66affSColin Finck } 2202c2c66affSColin Finck 2203c2c66affSColin Finck 2204c2c66affSColin Finck /*********************************************************************** 2205c2c66affSColin Finck * CM_Free_Res_Des_Ex [SETUPAPI.@] 2206c2c66affSColin Finck */ 2207c7fc2ef4SEric Kohl CONFIGRET 2208c7fc2ef4SEric Kohl WINAPI 2209c7fc2ef4SEric Kohl CM_Free_Res_Des_Ex( 2210c7fc2ef4SEric Kohl _Out_ PRES_DES prdResDes, 2211c7fc2ef4SEric Kohl _In_ RES_DES rdResDes, 2212c7fc2ef4SEric Kohl _In_ ULONG ulFlags, 2213c7fc2ef4SEric Kohl _In_opt_ HMACHINE hMachine) 2214c2c66affSColin Finck { 221560a21894SEric Kohl FIXME("CM_Free_Res_Des_Ex(%p %p %lx %p)\n", 2216c7fc2ef4SEric Kohl prdResDes, rdResDes, ulFlags, hMachine); 2217c2c66affSColin Finck 2218c2c66affSColin Finck return CR_CALL_NOT_IMPLEMENTED; 2219c2c66affSColin Finck } 2220c2c66affSColin Finck 2221c2c66affSColin Finck 2222c2c66affSColin Finck /*********************************************************************** 2223c2c66affSColin Finck * CM_Free_Res_Des_Handle [SETUPAPI.@] 2224c2c66affSColin Finck */ 2225c7fc2ef4SEric Kohl CONFIGRET 2226c7fc2ef4SEric Kohl WINAPI 2227c7fc2ef4SEric Kohl CM_Free_Res_Des_Handle( 2228c7fc2ef4SEric Kohl _In_ RES_DES rdResDes) 2229c2c66affSColin Finck { 2230c7fc2ef4SEric Kohl FIXME("CM_Free_Res_Des_Handle(%p)\n", rdResDes); 2231c2c66affSColin Finck 2232c2c66affSColin Finck return CR_CALL_NOT_IMPLEMENTED; 2233c2c66affSColin Finck } 2234c2c66affSColin Finck 2235c2c66affSColin Finck 2236c2c66affSColin Finck /*********************************************************************** 2237*d7e40954SEric Kohl * CM_Free_Resource_Conflict_Handle [SETUPAPI.@] 2238*d7e40954SEric Kohl */ 2239*d7e40954SEric Kohl CONFIGRET 2240*d7e40954SEric Kohl WINAPI 2241*d7e40954SEric Kohl CM_Free_Resource_Conflict_Handle( 2242*d7e40954SEric Kohl _In_ CONFLICT_LIST clConflictList) 2243*d7e40954SEric Kohl { 2244*d7e40954SEric Kohl FIXME("CM_Free_Resource_Conflict_Handle(%p)\n", clConflictList); 2245*d7e40954SEric Kohl 2246*d7e40954SEric Kohl return CR_CALL_NOT_IMPLEMENTED; 2247*d7e40954SEric Kohl } 2248*d7e40954SEric Kohl 2249*d7e40954SEric Kohl 2250*d7e40954SEric Kohl /*********************************************************************** 2251c2c66affSColin Finck * CM_Get_Child [SETUPAPI.@] 2252c2c66affSColin Finck */ 2253c7fc2ef4SEric Kohl CONFIGRET 2254c7fc2ef4SEric Kohl WINAPI 2255c7fc2ef4SEric Kohl CM_Get_Child( 2256c7fc2ef4SEric Kohl _Out_ PDEVINST pdnDevInst, 2257c7fc2ef4SEric Kohl _In_ DEVINST dnDevInst, 2258c7fc2ef4SEric Kohl _In_ ULONG ulFlags) 2259c2c66affSColin Finck { 2260c7fc2ef4SEric Kohl TRACE("CM_Get_Child(%p %p %lx)\n", 2261c7fc2ef4SEric Kohl pdnDevInst, dnDevInst, ulFlags); 2262c7fc2ef4SEric Kohl 2263c2c66affSColin Finck return CM_Get_Child_Ex(pdnDevInst, dnDevInst, ulFlags, NULL); 2264c2c66affSColin Finck } 2265c2c66affSColin Finck 2266c2c66affSColin Finck 2267c2c66affSColin Finck /*********************************************************************** 2268c2c66affSColin Finck * CM_Get_Child_Ex [SETUPAPI.@] 2269c2c66affSColin Finck */ 2270c7fc2ef4SEric Kohl CONFIGRET 2271c7fc2ef4SEric Kohl WINAPI 2272c7fc2ef4SEric Kohl CM_Get_Child_Ex( 2273c7fc2ef4SEric Kohl _Out_ PDEVINST pdnDevInst, 2274c7fc2ef4SEric Kohl _In_ DEVINST dnDevInst, 2275c7fc2ef4SEric Kohl _In_ ULONG ulFlags, 2276c7fc2ef4SEric Kohl _In_opt_ HMACHINE hMachine) 2277c2c66affSColin Finck { 2278c2c66affSColin Finck WCHAR szRelatedDevInst[MAX_DEVICE_ID_LEN]; 2279c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 2280c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 2281c2c66affSColin Finck LPWSTR lpDevInst; 2282c2c66affSColin Finck DWORD dwIndex, dwLength = MAX_DEVICE_ID_LEN; 2283c2c66affSColin Finck CONFIGRET ret; 2284c2c66affSColin Finck 228560a21894SEric Kohl TRACE("CM_Get_Child_Ex(%p %lx %lx %p)\n", 2286c7fc2ef4SEric Kohl pdnDevInst, dnDevInst, ulFlags, hMachine); 2287c2c66affSColin Finck 2288c2c66affSColin Finck if (pdnDevInst == NULL) 2289c2c66affSColin Finck return CR_INVALID_POINTER; 2290c2c66affSColin Finck 2291c2c66affSColin Finck if (dnDevInst == 0) 2292c2c66affSColin Finck return CR_INVALID_DEVINST; 2293c2c66affSColin Finck 2294c2c66affSColin Finck if (ulFlags != 0) 2295c2c66affSColin Finck return CR_INVALID_FLAG; 2296c2c66affSColin Finck 2297c2c66affSColin Finck *pdnDevInst = -1; 2298c2c66affSColin Finck 2299c2c66affSColin Finck if (hMachine != NULL) 2300c2c66affSColin Finck { 2301c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 2302c2c66affSColin Finck if (BindingHandle == NULL) 2303c2c66affSColin Finck return CR_FAILURE; 2304c2c66affSColin Finck 2305c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 2306c2c66affSColin Finck if (StringTable == 0) 2307c2c66affSColin Finck return CR_FAILURE; 2308c2c66affSColin Finck } 2309c2c66affSColin Finck else 2310c2c66affSColin Finck { 2311c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 2312c2c66affSColin Finck return CR_FAILURE; 2313c2c66affSColin Finck } 2314c2c66affSColin Finck 2315c2c66affSColin Finck lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst); 2316c2c66affSColin Finck if (lpDevInst == NULL) 2317c2c66affSColin Finck return CR_INVALID_DEVNODE; 2318c2c66affSColin Finck 2319c2c66affSColin Finck RpcTryExcept 2320c2c66affSColin Finck { 2321c2c66affSColin Finck ret = PNP_GetRelatedDeviceInstance(BindingHandle, 2322c2c66affSColin Finck PNP_GET_CHILD_DEVICE_INSTANCE, 2323c2c66affSColin Finck lpDevInst, 2324c2c66affSColin Finck szRelatedDevInst, 2325c2c66affSColin Finck &dwLength, 2326c2c66affSColin Finck 0); 2327c2c66affSColin Finck } 2328c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 2329c2c66affSColin Finck { 2330c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 2331c2c66affSColin Finck } 2332c2c66affSColin Finck RpcEndExcept; 2333c2c66affSColin Finck 2334c2c66affSColin Finck if (ret != CR_SUCCESS) 2335c2c66affSColin Finck return ret; 2336c2c66affSColin Finck 2337c2c66affSColin Finck TRACE("szRelatedDevInst: %s\n", debugstr_w(szRelatedDevInst)); 2338c2c66affSColin Finck 2339c2c66affSColin Finck dwIndex = pSetupStringTableAddString(StringTable, szRelatedDevInst, 1); 2340c2c66affSColin Finck if (dwIndex == -1) 2341c2c66affSColin Finck return CR_FAILURE; 2342c2c66affSColin Finck 2343c2c66affSColin Finck *pdnDevInst = dwIndex; 2344c2c66affSColin Finck 2345c2c66affSColin Finck return CR_SUCCESS; 2346c2c66affSColin Finck } 2347c2c66affSColin Finck 2348c2c66affSColin Finck 2349c2c66affSColin Finck /*********************************************************************** 2350c2c66affSColin Finck * CM_Get_Class_Key_NameA [SETUPAPI.@] 2351c2c66affSColin Finck */ 235265d3bf74SEric Kohl CONFIGRET 235365d3bf74SEric Kohl WINAPI 235465d3bf74SEric Kohl CM_Get_Class_Key_NameA( 235565d3bf74SEric Kohl _In_ LPGUID ClassGuid, 235665d3bf74SEric Kohl _Out_writes_opt_(*pulLength) LPSTR pszKeyName, 235765d3bf74SEric Kohl _Inout_ PULONG pulLength, 235865d3bf74SEric Kohl _In_ ULONG ulFlags) 2359c2c66affSColin Finck { 236065d3bf74SEric Kohl TRACE("CM_Get_Class_Key_NameA(%p %p %p %lx)\n", 2361c2c66affSColin Finck ClassGuid, pszKeyName, pulLength, ulFlags); 236265d3bf74SEric Kohl 2363c2c66affSColin Finck return CM_Get_Class_Key_Name_ExA(ClassGuid, pszKeyName, pulLength, 2364c2c66affSColin Finck ulFlags, NULL); 2365c2c66affSColin Finck } 2366c2c66affSColin Finck 2367c2c66affSColin Finck 2368c2c66affSColin Finck /*********************************************************************** 2369c2c66affSColin Finck * CM_Get_Class_Key_NameW [SETUPAPI.@] 2370c2c66affSColin Finck */ 237165d3bf74SEric Kohl CONFIGRET 237265d3bf74SEric Kohl WINAPI 237365d3bf74SEric Kohl CM_Get_Class_Key_NameW( 237465d3bf74SEric Kohl _In_ LPGUID ClassGuid, 237565d3bf74SEric Kohl _Out_writes_opt_(*pulLength) LPWSTR pszKeyName, 237665d3bf74SEric Kohl _Inout_ PULONG pulLength, 237765d3bf74SEric Kohl _In_ ULONG ulFlags) 2378c2c66affSColin Finck { 237965d3bf74SEric Kohl TRACE("CM_Get_Class_Key_NameW(%p %p %p %lx)\n", 2380c2c66affSColin Finck ClassGuid, pszKeyName, pulLength, ulFlags); 238165d3bf74SEric Kohl 2382c2c66affSColin Finck return CM_Get_Class_Key_Name_ExW(ClassGuid, pszKeyName, pulLength, 2383c2c66affSColin Finck ulFlags, NULL); 2384c2c66affSColin Finck } 2385c2c66affSColin Finck 2386c2c66affSColin Finck 2387c2c66affSColin Finck /*********************************************************************** 2388c2c66affSColin Finck * CM_Get_Class_Key_Name_ExA [SETUPAPI.@] 2389c2c66affSColin Finck */ 239065d3bf74SEric Kohl CONFIGRET 239165d3bf74SEric Kohl WINAPI 239265d3bf74SEric Kohl CM_Get_Class_Key_Name_ExA( 239365d3bf74SEric Kohl _In_ LPGUID ClassGuid, 239465d3bf74SEric Kohl _Out_writes_opt_(*pulLength) LPSTR pszKeyName, 239565d3bf74SEric Kohl _Inout_ PULONG pulLength, 239665d3bf74SEric Kohl _In_ ULONG ulFlags, 239765d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 2398c2c66affSColin Finck { 2399c2c66affSColin Finck WCHAR szBuffer[MAX_GUID_STRING_LEN]; 2400c2c66affSColin Finck CONFIGRET ret = CR_SUCCESS; 2401c2c66affSColin Finck ULONG ulLength; 2402c2c66affSColin Finck ULONG ulOrigLength; 2403c2c66affSColin Finck 240460a21894SEric Kohl TRACE("CM_Get_Class_Key_Name_ExA(%p %p %p %lx %p)\n", 2405c2c66affSColin Finck ClassGuid, pszKeyName, pulLength, ulFlags, hMachine); 2406c2c66affSColin Finck 2407c2c66affSColin Finck if (ClassGuid == NULL || pszKeyName == NULL || pulLength == NULL) 2408c2c66affSColin Finck return CR_INVALID_POINTER; 2409c2c66affSColin Finck 2410c2c66affSColin Finck ulOrigLength = *pulLength; 2411c2c66affSColin Finck *pulLength = 0; 2412c2c66affSColin Finck 2413c2c66affSColin Finck ulLength = MAX_GUID_STRING_LEN; 2414c2c66affSColin Finck ret = CM_Get_Class_Key_Name_ExW(ClassGuid, szBuffer, &ulLength, 2415c2c66affSColin Finck ulFlags, hMachine); 2416c2c66affSColin Finck if (ret == CR_SUCCESS) 2417c2c66affSColin Finck { 2418c2c66affSColin Finck if (WideCharToMultiByte(CP_ACP, 2419c2c66affSColin Finck 0, 2420c2c66affSColin Finck szBuffer, 2421c2c66affSColin Finck ulLength, 2422c2c66affSColin Finck pszKeyName, 2423c2c66affSColin Finck ulOrigLength, 2424c2c66affSColin Finck NULL, 2425c2c66affSColin Finck NULL) == 0) 2426c2c66affSColin Finck ret = CR_FAILURE; 2427c2c66affSColin Finck else 2428c2c66affSColin Finck *pulLength = lstrlenA(pszKeyName) + 1; 2429c2c66affSColin Finck } 2430c2c66affSColin Finck 2431c2c66affSColin Finck return CR_SUCCESS; 2432c2c66affSColin Finck } 2433c2c66affSColin Finck 2434c2c66affSColin Finck 2435c2c66affSColin Finck /*********************************************************************** 2436c2c66affSColin Finck * CM_Get_Class_Key_Name_ExW [SETUPAPI.@] 2437c2c66affSColin Finck */ 243865d3bf74SEric Kohl CONFIGRET 243965d3bf74SEric Kohl WINAPI 244065d3bf74SEric Kohl CM_Get_Class_Key_Name_ExW( 244165d3bf74SEric Kohl _In_ LPGUID ClassGuid, 244265d3bf74SEric Kohl _Out_writes_opt_(*pulLength) LPWSTR pszKeyName, 244365d3bf74SEric Kohl _Inout_ PULONG pulLength, 244465d3bf74SEric Kohl _In_ ULONG ulFlags, 244565d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 2446c2c66affSColin Finck { 244760a21894SEric Kohl TRACE("CM_Get_Class_Key_Name_ExW(%p %p %p %lx %p)\n", 2448c2c66affSColin Finck ClassGuid, pszKeyName, pulLength, ulFlags, hMachine); 2449c2c66affSColin Finck 2450c2c66affSColin Finck if (ClassGuid == NULL || pszKeyName == NULL || pulLength == NULL) 2451c2c66affSColin Finck return CR_INVALID_POINTER; 2452c2c66affSColin Finck 2453c2c66affSColin Finck if (ulFlags != 0) 2454c2c66affSColin Finck return CR_INVALID_FLAG; 2455c2c66affSColin Finck 2456c2c66affSColin Finck if (*pulLength < MAX_GUID_STRING_LEN) 2457c2c66affSColin Finck { 2458c2c66affSColin Finck *pulLength = 0; 2459c2c66affSColin Finck return CR_BUFFER_SMALL; 2460c2c66affSColin Finck } 2461c2c66affSColin Finck 2462c2c66affSColin Finck if (!GuidToString(ClassGuid, pszKeyName)) 2463c2c66affSColin Finck return CR_INVALID_DATA; 2464c2c66affSColin Finck 2465c2c66affSColin Finck *pulLength = MAX_GUID_STRING_LEN; 2466c2c66affSColin Finck 2467c2c66affSColin Finck return CR_SUCCESS; 2468c2c66affSColin Finck } 2469c2c66affSColin Finck 2470c2c66affSColin Finck 2471c2c66affSColin Finck /*********************************************************************** 2472c2c66affSColin Finck * CM_Get_Class_NameA [SETUPAPI.@] 2473c2c66affSColin Finck */ 247465d3bf74SEric Kohl CONFIGRET 247565d3bf74SEric Kohl WINAPI 247665d3bf74SEric Kohl CM_Get_Class_NameA( 247765d3bf74SEric Kohl _In_ LPGUID ClassGuid, 247865d3bf74SEric Kohl _Out_writes_opt_(*pulLength) PCHAR Buffer, 247965d3bf74SEric Kohl _Inout_ PULONG pulLength, 248065d3bf74SEric Kohl _In_ ULONG ulFlags) 2481c2c66affSColin Finck { 248265d3bf74SEric Kohl TRACE("CM_Get_Class_NameA(%p %p %p %lx)\n", 248365d3bf74SEric Kohl ClassGuid, Buffer, pulLength, ulFlags); 248465d3bf74SEric Kohl 2485c2c66affSColin Finck return CM_Get_Class_Name_ExA(ClassGuid, Buffer, pulLength, ulFlags, 2486c2c66affSColin Finck NULL); 2487c2c66affSColin Finck } 2488c2c66affSColin Finck 2489c2c66affSColin Finck 2490c2c66affSColin Finck /*********************************************************************** 2491c2c66affSColin Finck * CM_Get_Class_NameW [SETUPAPI.@] 2492c2c66affSColin Finck */ 249365d3bf74SEric Kohl CONFIGRET 249465d3bf74SEric Kohl WINAPI 249565d3bf74SEric Kohl CM_Get_Class_NameW( 249665d3bf74SEric Kohl _In_ LPGUID ClassGuid, 249765d3bf74SEric Kohl _Out_writes_opt_(*pulLength) PWCHAR Buffer, 249865d3bf74SEric Kohl _Inout_ PULONG pulLength, 249965d3bf74SEric Kohl _In_ ULONG ulFlags) 2500c2c66affSColin Finck { 250165d3bf74SEric Kohl TRACE("CM_Get_Class_NameW(%p %p %p %lx)\n", 250265d3bf74SEric Kohl ClassGuid, Buffer, pulLength, ulFlags); 250365d3bf74SEric Kohl 2504c2c66affSColin Finck return CM_Get_Class_Name_ExW(ClassGuid, Buffer, pulLength, ulFlags, 2505c2c66affSColin Finck NULL); 2506c2c66affSColin Finck } 2507c2c66affSColin Finck 2508c2c66affSColin Finck 2509c2c66affSColin Finck /*********************************************************************** 2510c2c66affSColin Finck * CM_Get_Class_Name_ExA [SETUPAPI.@] 2511c2c66affSColin Finck */ 251265d3bf74SEric Kohl CONFIGRET 251365d3bf74SEric Kohl WINAPI 251465d3bf74SEric Kohl CM_Get_Class_Name_ExA( 251565d3bf74SEric Kohl _In_ LPGUID ClassGuid, 251665d3bf74SEric Kohl _Out_writes_opt_(*pulLength) PCHAR Buffer, 251765d3bf74SEric Kohl _Inout_ PULONG pulLength, 251865d3bf74SEric Kohl _In_ ULONG ulFlags, 251965d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 2520c2c66affSColin Finck { 2521c2c66affSColin Finck WCHAR szBuffer[MAX_CLASS_NAME_LEN]; 2522c2c66affSColin Finck CONFIGRET ret = CR_SUCCESS; 2523c2c66affSColin Finck ULONG ulLength; 2524c2c66affSColin Finck ULONG ulOrigLength; 2525c2c66affSColin Finck 252660a21894SEric Kohl TRACE("CM_Get_Class_Name_ExA(%p %p %p %lx %p)\n", 2527c2c66affSColin Finck ClassGuid, Buffer, pulLength, ulFlags, hMachine); 2528c2c66affSColin Finck 2529c2c66affSColin Finck if (ClassGuid == NULL || Buffer == NULL || pulLength == NULL) 2530c2c66affSColin Finck return CR_INVALID_POINTER; 2531c2c66affSColin Finck 2532c2c66affSColin Finck ulOrigLength = *pulLength; 2533c2c66affSColin Finck *pulLength = 0; 2534c2c66affSColin Finck 2535c2c66affSColin Finck ulLength = MAX_CLASS_NAME_LEN; 2536c2c66affSColin Finck ret = CM_Get_Class_Name_ExW(ClassGuid, szBuffer, &ulLength, 2537c2c66affSColin Finck ulFlags, hMachine); 2538c2c66affSColin Finck if (ret == CR_SUCCESS) 2539c2c66affSColin Finck { 2540c2c66affSColin Finck if (WideCharToMultiByte(CP_ACP, 2541c2c66affSColin Finck 0, 2542c2c66affSColin Finck szBuffer, 2543c2c66affSColin Finck ulLength, 2544c2c66affSColin Finck Buffer, 2545c2c66affSColin Finck ulOrigLength, 2546c2c66affSColin Finck NULL, 2547c2c66affSColin Finck NULL) == 0) 2548c2c66affSColin Finck ret = CR_FAILURE; 2549c2c66affSColin Finck else 2550c2c66affSColin Finck *pulLength = lstrlenA(Buffer) + 1; 2551c2c66affSColin Finck } 2552c2c66affSColin Finck 2553c2c66affSColin Finck return ret; 2554c2c66affSColin Finck } 2555c2c66affSColin Finck 2556c2c66affSColin Finck 2557c2c66affSColin Finck /*********************************************************************** 2558c2c66affSColin Finck * CM_Get_Class_Name_ExW [SETUPAPI.@] 2559c2c66affSColin Finck */ 256065d3bf74SEric Kohl CONFIGRET 256165d3bf74SEric Kohl WINAPI 2562c2c66affSColin Finck CM_Get_Class_Name_ExW( 256365d3bf74SEric Kohl _In_ LPGUID ClassGuid, 256465d3bf74SEric Kohl _Out_writes_opt_(*pulLength) PWCHAR Buffer, 256565d3bf74SEric Kohl _Inout_ PULONG pulLength, 256665d3bf74SEric Kohl _In_ ULONG ulFlags, 256765d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 2568c2c66affSColin Finck { 2569c2c66affSColin Finck WCHAR szGuidString[MAX_GUID_STRING_LEN]; 2570c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 2571c2c66affSColin Finck CONFIGRET ret; 2572c2c66affSColin Finck 257360a21894SEric Kohl TRACE("CM_Get_Class_Name_ExW(%p %p %p %lx %p\n", 2574c2c66affSColin Finck ClassGuid, Buffer, pulLength, ulFlags, hMachine); 2575c2c66affSColin Finck 2576c2c66affSColin Finck if (ClassGuid == NULL || Buffer == NULL || pulLength == NULL) 2577c2c66affSColin Finck return CR_INVALID_POINTER; 2578c2c66affSColin Finck 2579c2c66affSColin Finck if (ulFlags != 0) 2580c2c66affSColin Finck return CR_INVALID_FLAG; 2581c2c66affSColin Finck 2582c2c66affSColin Finck if (!GuidToString(ClassGuid, szGuidString)) 2583c2c66affSColin Finck return CR_INVALID_DATA; 2584c2c66affSColin Finck 2585c2c66affSColin Finck TRACE("Guid %s\n", debugstr_w(szGuidString)); 2586c2c66affSColin Finck 2587c2c66affSColin Finck if (hMachine != NULL) 2588c2c66affSColin Finck { 2589c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 2590c2c66affSColin Finck if (BindingHandle == NULL) 2591c2c66affSColin Finck return CR_FAILURE; 2592c2c66affSColin Finck } 2593c2c66affSColin Finck else 2594c2c66affSColin Finck { 2595c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 2596c2c66affSColin Finck return CR_FAILURE; 2597c2c66affSColin Finck } 2598c2c66affSColin Finck 2599c2c66affSColin Finck RpcTryExcept 2600c2c66affSColin Finck { 2601c2c66affSColin Finck ret = PNP_GetClassName(BindingHandle, 2602c2c66affSColin Finck szGuidString, 2603c2c66affSColin Finck Buffer, 2604c2c66affSColin Finck pulLength, 2605c2c66affSColin Finck ulFlags); 2606c2c66affSColin Finck } 2607c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 2608c2c66affSColin Finck { 2609c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 2610c2c66affSColin Finck } 2611c2c66affSColin Finck RpcEndExcept; 2612c2c66affSColin Finck 2613c2c66affSColin Finck return ret; 2614c2c66affSColin Finck } 2615c2c66affSColin Finck 2616c2c66affSColin Finck 2617c2c66affSColin Finck /*********************************************************************** 2618c2c66affSColin Finck * CM_Get_Class_Registry_PropertyA [SETUPAPI.@] 2619c2c66affSColin Finck */ 262065d3bf74SEric Kohl CONFIGRET 262165d3bf74SEric Kohl WINAPI 262265d3bf74SEric Kohl CM_Get_Class_Registry_PropertyA( 262365d3bf74SEric Kohl LPGUID ClassGuid, 262465d3bf74SEric Kohl ULONG ulProperty, 262565d3bf74SEric Kohl PULONG pulRegDataType, 262665d3bf74SEric Kohl PVOID Buffer, 262765d3bf74SEric Kohl PULONG pulLength, 262865d3bf74SEric Kohl ULONG ulFlags, 262965d3bf74SEric Kohl HMACHINE hMachine) 2630c2c66affSColin Finck { 2631c2c66affSColin Finck PWSTR BufferW = NULL; 2632c2c66affSColin Finck ULONG ulLength = 0; 2633c2c66affSColin Finck ULONG ulType; 2634c2c66affSColin Finck CONFIGRET ret; 2635c2c66affSColin Finck 263660a21894SEric Kohl TRACE("CM_Get_Class_Registry_PropertyA(%p %lu %p %p %p %lx %p)\n", 2637c2c66affSColin Finck ClassGuid, ulProperty, pulRegDataType, Buffer, pulLength, 2638c2c66affSColin Finck ulFlags, hMachine); 2639c2c66affSColin Finck 2640c2c66affSColin Finck if (pulLength == NULL) 2641c2c66affSColin Finck return CR_INVALID_POINTER; 2642c2c66affSColin Finck 2643c2c66affSColin Finck if (ulProperty < CM_CRP_MIN || ulProperty > CM_CRP_MAX) 2644c2c66affSColin Finck return CR_INVALID_PROPERTY; 2645c2c66affSColin Finck 2646c2c66affSColin Finck ulType = GetRegistryPropertyType(ulProperty); 2647c2c66affSColin Finck if (ulType == REG_SZ || ulType == REG_MULTI_SZ) 2648c2c66affSColin Finck { 2649c2c66affSColin Finck /* Get the required buffer size */ 2650c2c66affSColin Finck ret = CM_Get_Class_Registry_PropertyW(ClassGuid, ulProperty, pulRegDataType, 2651c2c66affSColin Finck NULL, &ulLength, ulFlags, hMachine); 2652c2c66affSColin Finck if (ret != CR_BUFFER_SMALL) 2653c2c66affSColin Finck return ret; 2654c2c66affSColin Finck 2655c2c66affSColin Finck /* Allocate the unicode buffer */ 2656c2c66affSColin Finck BufferW = HeapAlloc(GetProcessHeap(), 0, ulLength); 2657c2c66affSColin Finck if (BufferW == NULL) 2658c2c66affSColin Finck return CR_OUT_OF_MEMORY; 2659c2c66affSColin Finck 2660c2c66affSColin Finck /* Get the property */ 2661c2c66affSColin Finck ret = CM_Get_Class_Registry_PropertyW(ClassGuid, ulProperty, pulRegDataType, 2662c2c66affSColin Finck BufferW, &ulLength, ulFlags, hMachine); 2663c2c66affSColin Finck if (ret != CR_SUCCESS) 2664c2c66affSColin Finck { 2665c2c66affSColin Finck HeapFree(GetProcessHeap(), 0, BufferW); 2666c2c66affSColin Finck return ret; 2667c2c66affSColin Finck } 2668c2c66affSColin Finck 2669c2c66affSColin Finck /* Do W->A conversion */ 2670c2c66affSColin Finck *pulLength = WideCharToMultiByte(CP_ACP, 2671c2c66affSColin Finck 0, 2672c2c66affSColin Finck BufferW, 2673c2c66affSColin Finck lstrlenW(BufferW) + 1, 2674c2c66affSColin Finck Buffer, 2675c2c66affSColin Finck *pulLength, 2676c2c66affSColin Finck NULL, 2677c2c66affSColin Finck NULL); 2678c2c66affSColin Finck 2679c2c66affSColin Finck /* Release the unicode buffer */ 2680c2c66affSColin Finck HeapFree(GetProcessHeap(), 0, BufferW); 2681c2c66affSColin Finck 2682c2c66affSColin Finck if (*pulLength == 0) 2683c2c66affSColin Finck ret = CR_FAILURE; 2684c2c66affSColin Finck } 2685c2c66affSColin Finck else 2686c2c66affSColin Finck { 2687c2c66affSColin Finck /* Get the property */ 2688c2c66affSColin Finck ret = CM_Get_Class_Registry_PropertyW(ClassGuid, ulProperty, pulRegDataType, 2689c2c66affSColin Finck Buffer, pulLength, ulFlags, hMachine); 2690c2c66affSColin Finck } 2691c2c66affSColin Finck 2692c2c66affSColin Finck return ret; 2693c2c66affSColin Finck } 2694c2c66affSColin Finck 2695c2c66affSColin Finck 2696c2c66affSColin Finck /*********************************************************************** 2697c2c66affSColin Finck * CM_Get_Class_Registry_PropertyW [SETUPAPI.@] 2698c2c66affSColin Finck */ 269965d3bf74SEric Kohl CONFIGRET 270065d3bf74SEric Kohl WINAPI 270165d3bf74SEric Kohl CM_Get_Class_Registry_PropertyW( 270265d3bf74SEric Kohl LPGUID ClassGuid, 270365d3bf74SEric Kohl ULONG ulProperty, 270465d3bf74SEric Kohl PULONG pulRegDataType, 270565d3bf74SEric Kohl PVOID Buffer, 270665d3bf74SEric Kohl PULONG pulLength, 270765d3bf74SEric Kohl ULONG ulFlags, 270865d3bf74SEric Kohl HMACHINE hMachine) 2709c2c66affSColin Finck { 2710c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 2711c2c66affSColin Finck WCHAR szGuidString[PNP_MAX_GUID_STRING_LEN + 1]; 2712c2c66affSColin Finck ULONG ulType = 0; 2713c2c66affSColin Finck ULONG ulTransferLength = 0; 2714c2c66affSColin Finck CONFIGRET ret; 2715c2c66affSColin Finck 271660a21894SEric Kohl TRACE("CM_Get_Class_Registry_PropertyW(%p %lu %p %p %p %lx %p)\n", 2717c2c66affSColin Finck ClassGuid, ulProperty, pulRegDataType, Buffer, pulLength, 2718c2c66affSColin Finck ulFlags, hMachine); 2719c2c66affSColin Finck 2720c2c66affSColin Finck if (ClassGuid == NULL || pulLength == NULL) 2721c2c66affSColin Finck return CR_INVALID_POINTER; 2722c2c66affSColin Finck 2723c2c66affSColin Finck if (ulFlags != 0) 2724c2c66affSColin Finck return CR_INVALID_FLAG; 2725c2c66affSColin Finck 2726c2c66affSColin Finck if (pSetupStringFromGuid(ClassGuid, 2727c2c66affSColin Finck szGuidString, 2728c2c66affSColin Finck PNP_MAX_GUID_STRING_LEN) != 0) 2729c2c66affSColin Finck return CR_INVALID_DATA; 2730c2c66affSColin Finck 2731c2c66affSColin Finck if (ulProperty < CM_CRP_MIN || ulProperty > CM_CRP_MAX) 2732c2c66affSColin Finck return CR_INVALID_PROPERTY; 2733c2c66affSColin Finck 2734c2c66affSColin Finck if (hMachine != NULL) 2735c2c66affSColin Finck { 2736c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 2737c2c66affSColin Finck if (BindingHandle == NULL) 2738c2c66affSColin Finck return CR_FAILURE; 2739c2c66affSColin Finck } 2740c2c66affSColin Finck else 2741c2c66affSColin Finck { 2742c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 2743c2c66affSColin Finck return CR_FAILURE; 2744c2c66affSColin Finck } 2745c2c66affSColin Finck 2746c2c66affSColin Finck ulTransferLength = *pulLength; 2747c2c66affSColin Finck 2748c2c66affSColin Finck RpcTryExcept 2749c2c66affSColin Finck { 2750c2c66affSColin Finck ret = PNP_GetClassRegProp(BindingHandle, 2751c2c66affSColin Finck szGuidString, 2752c2c66affSColin Finck ulProperty, 2753c2c66affSColin Finck &ulType, 2754c2c66affSColin Finck Buffer, 2755c2c66affSColin Finck &ulTransferLength, 2756c2c66affSColin Finck pulLength, 2757c2c66affSColin Finck ulFlags); 2758c2c66affSColin Finck } 2759c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 2760c2c66affSColin Finck { 2761c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 2762c2c66affSColin Finck } 2763c2c66affSColin Finck RpcEndExcept; 2764c2c66affSColin Finck 2765c2c66affSColin Finck if (ret == CR_SUCCESS) 2766c2c66affSColin Finck { 2767c2c66affSColin Finck if (pulRegDataType != NULL) 2768c2c66affSColin Finck *pulRegDataType = ulType; 2769c2c66affSColin Finck } 2770c2c66affSColin Finck 2771c2c66affSColin Finck return ret; 2772c2c66affSColin Finck } 2773c2c66affSColin Finck 2774c2c66affSColin Finck 2775c2c66affSColin Finck /*********************************************************************** 2776c2c66affSColin Finck * CM_Get_Depth [SETUPAPI.@] 2777c2c66affSColin Finck */ 277865d3bf74SEric Kohl CONFIGRET 277965d3bf74SEric Kohl WINAPI 278065d3bf74SEric Kohl CM_Get_Depth( 278165d3bf74SEric Kohl _Out_ PULONG pulDepth, 278265d3bf74SEric Kohl _In_ DEVINST dnDevInst, 278365d3bf74SEric Kohl _In_ ULONG ulFlags) 2784c2c66affSColin Finck { 278565d3bf74SEric Kohl TRACE("CM_Get_Depth(%p %lx %lx)\n", 278665d3bf74SEric Kohl pulDepth, dnDevInst, ulFlags); 278765d3bf74SEric Kohl 2788c2c66affSColin Finck return CM_Get_Depth_Ex(pulDepth, dnDevInst, ulFlags, NULL); 2789c2c66affSColin Finck } 2790c2c66affSColin Finck 2791c2c66affSColin Finck 2792c2c66affSColin Finck /*********************************************************************** 2793c2c66affSColin Finck * CM_Get_Depth_Ex [SETUPAPI.@] 2794c2c66affSColin Finck */ 279565d3bf74SEric Kohl CONFIGRET 279665d3bf74SEric Kohl WINAPI 279765d3bf74SEric Kohl CM_Get_Depth_Ex( 279865d3bf74SEric Kohl _Out_ PULONG pulDepth, 279965d3bf74SEric Kohl _In_ DEVINST dnDevInst, 280065d3bf74SEric Kohl _In_ ULONG ulFlags, 280165d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 2802c2c66affSColin Finck { 2803c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 2804c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 2805c2c66affSColin Finck LPWSTR lpDevInst; 2806c2c66affSColin Finck CONFIGRET ret; 2807c2c66affSColin Finck 280860a21894SEric Kohl TRACE("CM_Get_Depth_Ex(%p %lx %lx %p)\n", 2809c2c66affSColin Finck pulDepth, dnDevInst, ulFlags, hMachine); 2810c2c66affSColin Finck 2811c2c66affSColin Finck if (pulDepth == NULL) 2812c2c66affSColin Finck return CR_INVALID_POINTER; 2813c2c66affSColin Finck 2814c2c66affSColin Finck if (dnDevInst == 0) 2815c2c66affSColin Finck return CR_INVALID_DEVINST; 2816c2c66affSColin Finck 2817c2c66affSColin Finck if (ulFlags != 0) 2818c2c66affSColin Finck return CR_INVALID_FLAG; 2819c2c66affSColin Finck 2820c2c66affSColin Finck if (hMachine != NULL) 2821c2c66affSColin Finck { 2822c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 2823c2c66affSColin Finck if (BindingHandle == NULL) 2824c2c66affSColin Finck return CR_FAILURE; 2825c2c66affSColin Finck 2826c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 2827c2c66affSColin Finck if (StringTable == 0) 2828c2c66affSColin Finck return CR_FAILURE; 2829c2c66affSColin Finck } 2830c2c66affSColin Finck else 2831c2c66affSColin Finck { 2832c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 2833c2c66affSColin Finck return CR_FAILURE; 2834c2c66affSColin Finck } 2835c2c66affSColin Finck 2836c2c66affSColin Finck lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst); 2837c2c66affSColin Finck if (lpDevInst == NULL) 2838c2c66affSColin Finck return CR_INVALID_DEVNODE; 2839c2c66affSColin Finck 2840c2c66affSColin Finck RpcTryExcept 2841c2c66affSColin Finck { 2842c2c66affSColin Finck ret = PNP_GetDepth(BindingHandle, 2843c2c66affSColin Finck lpDevInst, 2844c2c66affSColin Finck pulDepth, 2845c2c66affSColin Finck ulFlags); 2846c2c66affSColin Finck } 2847c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 2848c2c66affSColin Finck { 2849c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 2850c2c66affSColin Finck } 2851c2c66affSColin Finck RpcEndExcept; 2852c2c66affSColin Finck 2853c2c66affSColin Finck return ret; 2854c2c66affSColin Finck } 2855c2c66affSColin Finck 2856c2c66affSColin Finck 2857c2c66affSColin Finck /*********************************************************************** 2858c2c66affSColin Finck * CM_Get_DevNode_Custom_PropertyA [SETUPAPI.@] 2859c2c66affSColin Finck */ 286065d3bf74SEric Kohl CONFIGRET 286165d3bf74SEric Kohl WINAPI 286265d3bf74SEric Kohl CM_Get_DevNode_Custom_PropertyA( 286365d3bf74SEric Kohl _In_ DEVINST dnDevInst, 286465d3bf74SEric Kohl _In_ PCSTR pszCustomPropertyName, 286565d3bf74SEric Kohl _Out_opt_ PULONG pulRegDataType, 286665d3bf74SEric Kohl _Out_writes_bytes_opt_(*pulLength) PVOID Buffer, 286765d3bf74SEric Kohl _Inout_ PULONG pulLength, 286865d3bf74SEric Kohl _In_ ULONG ulFlags) 2869c2c66affSColin Finck { 287065d3bf74SEric Kohl TRACE("CM_Get_DevNode_Custom_PropertyA(%lx %s %p %p %p %lx)\n", 287165d3bf74SEric Kohl dnDevInst, pszCustomPropertyName, pulRegDataType, 287265d3bf74SEric Kohl Buffer, pulLength, ulFlags); 287365d3bf74SEric Kohl 2874c2c66affSColin Finck return CM_Get_DevNode_Custom_Property_ExA(dnDevInst, pszCustomPropertyName, 2875c2c66affSColin Finck pulRegDataType, Buffer, 2876c2c66affSColin Finck pulLength, ulFlags, NULL); 2877c2c66affSColin Finck } 2878c2c66affSColin Finck 2879c2c66affSColin Finck 2880c2c66affSColin Finck /*********************************************************************** 2881c2c66affSColin Finck * CM_Get_DevNode_Custom_PropertyW [SETUPAPI.@] 2882c2c66affSColin Finck */ 288365d3bf74SEric Kohl CONFIGRET 288465d3bf74SEric Kohl WINAPI 288565d3bf74SEric Kohl CM_Get_DevNode_Custom_PropertyW( 288665d3bf74SEric Kohl _In_ DEVINST dnDevInst, 288765d3bf74SEric Kohl _In_ PCWSTR pszCustomPropertyName, 288865d3bf74SEric Kohl _Out_opt_ PULONG pulRegDataType, 288965d3bf74SEric Kohl _Out_writes_bytes_opt_(*pulLength) PVOID Buffer, 289065d3bf74SEric Kohl _Inout_ PULONG pulLength, 289165d3bf74SEric Kohl _In_ ULONG ulFlags) 2892c2c66affSColin Finck { 289365d3bf74SEric Kohl TRACE("CM_Get_DevNode_Custom_PropertyW(%lx %s %p %p %p %lx)\n", 289465d3bf74SEric Kohl dnDevInst, debugstr_w(pszCustomPropertyName), pulRegDataType, 289565d3bf74SEric Kohl Buffer, pulLength, ulFlags); 289665d3bf74SEric Kohl 2897c2c66affSColin Finck return CM_Get_DevNode_Custom_Property_ExW(dnDevInst, pszCustomPropertyName, 2898c2c66affSColin Finck pulRegDataType, Buffer, 2899c2c66affSColin Finck pulLength, ulFlags, NULL); 2900c2c66affSColin Finck } 2901c2c66affSColin Finck 2902c2c66affSColin Finck 2903c2c66affSColin Finck /*********************************************************************** 2904c2c66affSColin Finck * CM_Get_DevNode_Custom_Property_ExA [SETUPAPI.@] 2905c2c66affSColin Finck */ 290665d3bf74SEric Kohl CONFIGRET 290765d3bf74SEric Kohl WINAPI 290865d3bf74SEric Kohl CM_Get_DevNode_Custom_Property_ExA( 290965d3bf74SEric Kohl _In_ DEVINST dnDevInst, 291065d3bf74SEric Kohl _In_ PCSTR pszCustomPropertyName, 291165d3bf74SEric Kohl _Out_opt_ PULONG pulRegDataType, 291265d3bf74SEric Kohl _Out_writes_bytes_opt_(*pulLength) PVOID Buffer, 291365d3bf74SEric Kohl _Inout_ PULONG pulLength, 291465d3bf74SEric Kohl _In_ ULONG ulFlags, 291565d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 2916c2c66affSColin Finck { 2917c2c66affSColin Finck LPWSTR pszPropertyNameW = NULL; 2918c2c66affSColin Finck PVOID BufferW; 2919c2c66affSColin Finck ULONG ulLengthW; 2920c2c66affSColin Finck ULONG ulDataType = REG_NONE; 2921c2c66affSColin Finck CONFIGRET ret; 2922c2c66affSColin Finck 292365d3bf74SEric Kohl TRACE("CM_Get_DevNode_Custom_Property_ExA(%lx %s %p %p %p %lx %p)\n", 292465d3bf74SEric Kohl dnDevInst, pszCustomPropertyName, pulRegDataType, 292565d3bf74SEric Kohl Buffer, pulLength, ulFlags, hMachine); 2926c2c66affSColin Finck 2927c2c66affSColin Finck if (!pulLength) 2928c2c66affSColin Finck return CR_INVALID_POINTER; 2929c2c66affSColin Finck 2930c2c66affSColin Finck ulLengthW = *pulLength * sizeof(WCHAR); 2931c2c66affSColin Finck BufferW = HeapAlloc(GetProcessHeap(), 0, ulLengthW); 2932c2c66affSColin Finck if (!BufferW) 2933c2c66affSColin Finck return CR_OUT_OF_MEMORY; 2934c2c66affSColin Finck 2935c2c66affSColin Finck pszPropertyNameW = pSetupMultiByteToUnicode(pszCustomPropertyName, 2936c2c66affSColin Finck CP_ACP); 2937c2c66affSColin Finck if (pszPropertyNameW == NULL) 2938c2c66affSColin Finck { 2939c2c66affSColin Finck HeapFree(GetProcessHeap(), 0, BufferW); 2940c2c66affSColin Finck return CR_OUT_OF_MEMORY; 2941c2c66affSColin Finck } 2942c2c66affSColin Finck 2943c2c66affSColin Finck ret = CM_Get_DevNode_Custom_Property_ExW(dnDevInst, 2944c2c66affSColin Finck pszPropertyNameW, 2945c2c66affSColin Finck &ulDataType, 2946c2c66affSColin Finck BufferW, 2947c2c66affSColin Finck &ulLengthW, 2948c2c66affSColin Finck ulFlags, 2949c2c66affSColin Finck hMachine); 2950c2c66affSColin Finck if (ret == CR_SUCCESS) 2951c2c66affSColin Finck { 2952c2c66affSColin Finck if (ulDataType == REG_SZ || 2953c2c66affSColin Finck ulDataType == REG_EXPAND_SZ || 2954c2c66affSColin Finck ulDataType == REG_MULTI_SZ) 2955c2c66affSColin Finck { 2956c2c66affSColin Finck /* Do W->A conversion */ 2957c2c66affSColin Finck *pulLength = WideCharToMultiByte(CP_ACP, 2958c2c66affSColin Finck 0, 2959c2c66affSColin Finck BufferW, 2960c2c66affSColin Finck lstrlenW(BufferW) + 1, 2961c2c66affSColin Finck Buffer, 2962c2c66affSColin Finck *pulLength, 2963c2c66affSColin Finck NULL, 2964c2c66affSColin Finck NULL); 2965c2c66affSColin Finck if (*pulLength == 0) 2966c2c66affSColin Finck ret = CR_FAILURE; 2967c2c66affSColin Finck } 2968c2c66affSColin Finck else 2969c2c66affSColin Finck { 2970c2c66affSColin Finck /* Directly copy the value */ 2971c2c66affSColin Finck if (ulLengthW <= *pulLength) 2972c2c66affSColin Finck memcpy(Buffer, BufferW, ulLengthW); 2973c2c66affSColin Finck else 2974c2c66affSColin Finck { 2975c2c66affSColin Finck *pulLength = ulLengthW; 2976c2c66affSColin Finck ret = CR_BUFFER_SMALL; 2977c2c66affSColin Finck } 2978c2c66affSColin Finck } 2979c2c66affSColin Finck } 2980c2c66affSColin Finck 2981c2c66affSColin Finck if (pulRegDataType) 2982c2c66affSColin Finck *pulRegDataType = ulDataType; 2983c2c66affSColin Finck 2984c2c66affSColin Finck HeapFree(GetProcessHeap(), 0, BufferW); 2985c2c66affSColin Finck MyFree(pszPropertyNameW); 2986c2c66affSColin Finck 2987c2c66affSColin Finck return ret; 2988c2c66affSColin Finck } 2989c2c66affSColin Finck 2990c2c66affSColin Finck 2991c2c66affSColin Finck /*********************************************************************** 2992c2c66affSColin Finck * CM_Get_DevNode_Custom_Property_ExW [SETUPAPI.@] 2993c2c66affSColin Finck */ 299465d3bf74SEric Kohl CONFIGRET 299565d3bf74SEric Kohl WINAPI 299665d3bf74SEric Kohl CM_Get_DevNode_Custom_Property_ExW( 299765d3bf74SEric Kohl _In_ DEVINST dnDevInst, 299865d3bf74SEric Kohl _In_ PCWSTR pszCustomPropertyName, 299965d3bf74SEric Kohl _Out_opt_ PULONG pulRegDataType, 300065d3bf74SEric Kohl _Out_writes_bytes_opt_(*pulLength) PVOID Buffer, 300165d3bf74SEric Kohl _Inout_ PULONG pulLength, 300265d3bf74SEric Kohl _In_ ULONG ulFlags, 300365d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 3004c2c66affSColin Finck { 3005c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 3006c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 3007c2c66affSColin Finck LPWSTR lpDevInst; 3008c2c66affSColin Finck ULONG ulDataType = REG_NONE; 3009c2c66affSColin Finck ULONG ulTransferLength; 3010c2c66affSColin Finck CONFIGRET ret = CR_SUCCESS; 3011c2c66affSColin Finck 301265d3bf74SEric Kohl TRACE("CM_Get_DevNode_Custom_Property_ExW(%lx %s %p %p %p %lx %p)\n", 301365d3bf74SEric Kohl dnDevInst, debugstr_w(pszCustomPropertyName), pulRegDataType, 301465d3bf74SEric Kohl Buffer, pulLength, ulFlags, hMachine); 3015c2c66affSColin Finck 3016c2c66affSColin Finck if (dnDevInst == 0) 3017c2c66affSColin Finck return CR_INVALID_DEVNODE; 3018c2c66affSColin Finck 3019c2c66affSColin Finck if (pszCustomPropertyName == NULL || 3020c2c66affSColin Finck pulLength == NULL || 3021c2c66affSColin Finck *pulLength == 0) 3022c2c66affSColin Finck return CR_INVALID_POINTER; 3023c2c66affSColin Finck 3024c2c66affSColin Finck if (ulFlags & ~CM_CUSTOMDEVPROP_BITS) 3025c2c66affSColin Finck return CR_INVALID_FLAG; 3026c2c66affSColin Finck 3027c2c66affSColin Finck if (hMachine != NULL) 3028c2c66affSColin Finck { 3029c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 3030c2c66affSColin Finck if (BindingHandle == NULL) 3031c2c66affSColin Finck return CR_FAILURE; 3032c2c66affSColin Finck 3033c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 3034c2c66affSColin Finck if (StringTable == 0) 3035c2c66affSColin Finck return CR_FAILURE; 3036c2c66affSColin Finck } 3037c2c66affSColin Finck else 3038c2c66affSColin Finck { 3039c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 3040c2c66affSColin Finck return CR_FAILURE; 3041c2c66affSColin Finck } 3042c2c66affSColin Finck 3043c2c66affSColin Finck lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst); 3044c2c66affSColin Finck if (lpDevInst == NULL) 3045c2c66affSColin Finck return CR_INVALID_DEVNODE; 3046c2c66affSColin Finck 3047c2c66affSColin Finck ulTransferLength = *pulLength; 3048c2c66affSColin Finck 3049c2c66affSColin Finck RpcTryExcept 3050c2c66affSColin Finck { 3051c2c66affSColin Finck ret = PNP_GetCustomDevProp(BindingHandle, 3052c2c66affSColin Finck lpDevInst, 3053c2c66affSColin Finck (LPWSTR)pszCustomPropertyName, 3054c2c66affSColin Finck &ulDataType, 3055c2c66affSColin Finck Buffer, 3056c2c66affSColin Finck &ulTransferLength, 3057c2c66affSColin Finck pulLength, 3058c2c66affSColin Finck ulFlags); 3059c2c66affSColin Finck } 3060c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 3061c2c66affSColin Finck { 3062c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 3063c2c66affSColin Finck } 3064c2c66affSColin Finck RpcEndExcept; 3065c2c66affSColin Finck 3066c2c66affSColin Finck if (ret == CR_SUCCESS) 3067c2c66affSColin Finck { 3068c2c66affSColin Finck if (pulRegDataType != NULL) 3069c2c66affSColin Finck *pulRegDataType = ulDataType; 3070c2c66affSColin Finck } 3071c2c66affSColin Finck 3072c2c66affSColin Finck return ret; 3073c2c66affSColin Finck } 3074c2c66affSColin Finck 3075c2c66affSColin Finck 3076c2c66affSColin Finck /*********************************************************************** 3077c2c66affSColin Finck * CM_Get_DevNode_Registry_PropertyA [SETUPAPI.@] 3078c2c66affSColin Finck */ 307965d3bf74SEric Kohl CONFIGRET 308065d3bf74SEric Kohl WINAPI 308165d3bf74SEric Kohl CM_Get_DevNode_Registry_PropertyA( 308265d3bf74SEric Kohl _In_ DEVINST dnDevInst, 308365d3bf74SEric Kohl _In_ ULONG ulProperty, 308465d3bf74SEric Kohl _Out_opt_ PULONG pulRegDataType, 308565d3bf74SEric Kohl _Out_writes_bytes_opt_(*pulLength) PVOID Buffer, 308665d3bf74SEric Kohl _Inout_ PULONG pulLength, 308765d3bf74SEric Kohl _In_ ULONG ulFlags) 3088c2c66affSColin Finck { 308965d3bf74SEric Kohl TRACE("CM_Get_DevNode_Registry_PropertyA(%lx %lu %p %p %p %lx)\n", 3090c2c66affSColin Finck dnDevInst, ulProperty, pulRegDataType, Buffer, pulLength, ulFlags); 3091c2c66affSColin Finck 3092c2c66affSColin Finck return CM_Get_DevNode_Registry_Property_ExA(dnDevInst, ulProperty, 3093c2c66affSColin Finck pulRegDataType, Buffer, 3094c2c66affSColin Finck pulLength, ulFlags, NULL); 3095c2c66affSColin Finck } 3096c2c66affSColin Finck 3097c2c66affSColin Finck 3098c2c66affSColin Finck /*********************************************************************** 3099c2c66affSColin Finck * CM_Get_DevNode_Registry_PropertyW [SETUPAPI.@] 3100c2c66affSColin Finck */ 310165d3bf74SEric Kohl CONFIGRET 310265d3bf74SEric Kohl WINAPI 310365d3bf74SEric Kohl CM_Get_DevNode_Registry_PropertyW( 310465d3bf74SEric Kohl _In_ DEVINST dnDevInst, 310565d3bf74SEric Kohl _In_ ULONG ulProperty, 310665d3bf74SEric Kohl _Out_opt_ PULONG pulRegDataType, 310765d3bf74SEric Kohl _Out_writes_bytes_opt_(*pulLength) PVOID Buffer, 310865d3bf74SEric Kohl _Inout_ PULONG pulLength, 310965d3bf74SEric Kohl _In_ ULONG ulFlags) 3110c2c66affSColin Finck { 311165d3bf74SEric Kohl TRACE("CM_Get_DevNode_Registry_PropertyW(%lx %lu %p %p %p %lx)\n", 3112c2c66affSColin Finck dnDevInst, ulProperty, pulRegDataType, Buffer, pulLength, ulFlags); 3113c2c66affSColin Finck 3114c2c66affSColin Finck return CM_Get_DevNode_Registry_Property_ExW(dnDevInst, ulProperty, 3115c2c66affSColin Finck pulRegDataType, Buffer, 3116c2c66affSColin Finck pulLength, ulFlags, NULL); 3117c2c66affSColin Finck } 3118c2c66affSColin Finck 3119c2c66affSColin Finck 3120c2c66affSColin Finck /*********************************************************************** 3121c2c66affSColin Finck * CM_Get_DevNode_Registry_Property_ExA [SETUPAPI.@] 3122c2c66affSColin Finck */ 312365d3bf74SEric Kohl CONFIGRET 312465d3bf74SEric Kohl WINAPI 312565d3bf74SEric Kohl CM_Get_DevNode_Registry_Property_ExA( 312665d3bf74SEric Kohl _In_ DEVINST dnDevInst, 312765d3bf74SEric Kohl _In_ ULONG ulProperty, 312865d3bf74SEric Kohl _Out_opt_ PULONG pulRegDataType, 312965d3bf74SEric Kohl _Out_writes_bytes_opt_(*pulLength) PVOID Buffer, 313065d3bf74SEric Kohl _Inout_ PULONG pulLength, 313165d3bf74SEric Kohl _In_ ULONG ulFlags, 313265d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 3133c2c66affSColin Finck { 3134c2c66affSColin Finck PVOID BufferW; 3135c2c66affSColin Finck ULONG LengthW; 3136c2c66affSColin Finck ULONG ulDataType = REG_NONE; 3137c2c66affSColin Finck CONFIGRET ret; 3138c2c66affSColin Finck 313960a21894SEric Kohl TRACE("CM_Get_DevNode_Registry_Property_ExA(%lx %lu %p %p %p %lx %p)\n", 3140c2c66affSColin Finck dnDevInst, ulProperty, pulRegDataType, Buffer, pulLength, 3141c2c66affSColin Finck ulFlags, hMachine); 3142c2c66affSColin Finck 3143c2c66affSColin Finck if (!pulLength) 3144c2c66affSColin Finck return CR_INVALID_POINTER; 3145c2c66affSColin Finck 3146c2c66affSColin Finck LengthW = *pulLength * sizeof(WCHAR); 3147c2c66affSColin Finck BufferW = HeapAlloc(GetProcessHeap(), 0, LengthW); 3148c2c66affSColin Finck 3149c2c66affSColin Finck if (!BufferW) 3150c2c66affSColin Finck return CR_OUT_OF_MEMORY; 3151c2c66affSColin Finck 3152c2c66affSColin Finck ret = CM_Get_DevNode_Registry_Property_ExW(dnDevInst, 3153c2c66affSColin Finck ulProperty, 3154c2c66affSColin Finck &ulDataType, 3155c2c66affSColin Finck BufferW, 3156c2c66affSColin Finck &LengthW, 3157c2c66affSColin Finck ulFlags, 3158c2c66affSColin Finck hMachine); 3159c2c66affSColin Finck 3160c2c66affSColin Finck if (ret == CR_SUCCESS) 3161c2c66affSColin Finck { 3162c2c66affSColin Finck if (ulDataType == REG_SZ || 3163c2c66affSColin Finck ulDataType == REG_EXPAND_SZ || 3164c2c66affSColin Finck ulDataType == REG_MULTI_SZ) 3165c2c66affSColin Finck { 3166c2c66affSColin Finck /* Do W->A conversion */ 3167c2c66affSColin Finck *pulLength = WideCharToMultiByte(CP_ACP, 3168c2c66affSColin Finck 0, 3169c2c66affSColin Finck BufferW, 3170c2c66affSColin Finck lstrlenW(BufferW) + 1, 3171c2c66affSColin Finck Buffer, 3172c2c66affSColin Finck *pulLength, 3173c2c66affSColin Finck NULL, 3174c2c66affSColin Finck NULL); 3175c2c66affSColin Finck if (*pulLength == 0) 3176c2c66affSColin Finck ret = CR_FAILURE; 3177c2c66affSColin Finck } 3178c2c66affSColin Finck else 3179c2c66affSColin Finck { 3180c2c66affSColin Finck /* Directly copy the value */ 3181c2c66affSColin Finck if (LengthW <= *pulLength) 3182c2c66affSColin Finck memcpy(Buffer, BufferW, LengthW); 3183c2c66affSColin Finck else 3184c2c66affSColin Finck { 3185c2c66affSColin Finck *pulLength = LengthW; 3186c2c66affSColin Finck ret = CR_BUFFER_SMALL; 3187c2c66affSColin Finck } 3188c2c66affSColin Finck } 3189c2c66affSColin Finck } 3190c2c66affSColin Finck 3191c2c66affSColin Finck if (pulRegDataType) 3192c2c66affSColin Finck *pulRegDataType = ulDataType; 3193c2c66affSColin Finck 3194c2c66affSColin Finck HeapFree(GetProcessHeap(), 0, BufferW); 3195c2c66affSColin Finck 3196c2c66affSColin Finck return ret; 3197c2c66affSColin Finck } 3198c2c66affSColin Finck 3199c2c66affSColin Finck 3200c2c66affSColin Finck /*********************************************************************** 3201c2c66affSColin Finck * CM_Get_DevNode_Registry_Property_ExW [SETUPAPI.@] 3202c2c66affSColin Finck */ 320365d3bf74SEric Kohl CONFIGRET 320465d3bf74SEric Kohl WINAPI 320565d3bf74SEric Kohl CM_Get_DevNode_Registry_Property_ExW( 320665d3bf74SEric Kohl _In_ DEVINST dnDevInst, 320765d3bf74SEric Kohl _In_ ULONG ulProperty, 320865d3bf74SEric Kohl _Out_opt_ PULONG pulRegDataType, 320965d3bf74SEric Kohl _Out_writes_bytes_opt_(*pulLength) PVOID Buffer, 321065d3bf74SEric Kohl _Inout_ PULONG pulLength, 321165d3bf74SEric Kohl _In_ ULONG ulFlags, 321265d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 3213c2c66affSColin Finck { 3214c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 3215c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 3216c2c66affSColin Finck CONFIGRET ret = CR_SUCCESS; 3217c2c66affSColin Finck LPWSTR lpDevInst; 3218c2c66affSColin Finck ULONG ulDataType = REG_NONE; 3219c2c66affSColin Finck ULONG ulTransferLength = 0; 3220c2c66affSColin Finck 322160a21894SEric Kohl TRACE("CM_Get_DevNode_Registry_Property_ExW(%lx %lu %p %p %p %lx %p)\n", 3222c2c66affSColin Finck dnDevInst, ulProperty, pulRegDataType, Buffer, pulLength, 3223c2c66affSColin Finck ulFlags, hMachine); 3224c2c66affSColin Finck 3225c2c66affSColin Finck if (dnDevInst == 0) 3226c2c66affSColin Finck return CR_INVALID_DEVNODE; 3227c2c66affSColin Finck 3228c2c66affSColin Finck if (ulProperty < CM_DRP_MIN || ulProperty > CM_DRP_MAX) 3229c2c66affSColin Finck return CR_INVALID_PROPERTY; 3230c2c66affSColin Finck 3231c2c66affSColin Finck /* pulRegDataType is optional */ 3232c2c66affSColin Finck 3233c2c66affSColin Finck /* Buffer is optional */ 3234c2c66affSColin Finck 3235c2c66affSColin Finck if (pulLength == NULL) 3236c2c66affSColin Finck return CR_INVALID_POINTER; 3237c2c66affSColin Finck 3238c2c66affSColin Finck if (*pulLength == 0) 3239c2c66affSColin Finck return CR_INVALID_POINTER; 3240c2c66affSColin Finck 3241c2c66affSColin Finck if (ulFlags != 0) 3242c2c66affSColin Finck return CR_INVALID_FLAG; 3243c2c66affSColin Finck 3244c2c66affSColin Finck if (hMachine != NULL) 3245c2c66affSColin Finck { 3246c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 3247c2c66affSColin Finck if (BindingHandle == NULL) 3248c2c66affSColin Finck return CR_FAILURE; 3249c2c66affSColin Finck 3250c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 3251c2c66affSColin Finck if (StringTable == 0) 3252c2c66affSColin Finck return CR_FAILURE; 3253c2c66affSColin Finck } 3254c2c66affSColin Finck else 3255c2c66affSColin Finck { 3256c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 3257c2c66affSColin Finck return CR_FAILURE; 3258c2c66affSColin Finck } 3259c2c66affSColin Finck 3260c2c66affSColin Finck lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst); 3261c2c66affSColin Finck if (lpDevInst == NULL) 3262c2c66affSColin Finck return CR_INVALID_DEVNODE; 3263c2c66affSColin Finck 3264c2c66affSColin Finck ulTransferLength = *pulLength; 3265c2c66affSColin Finck 3266c2c66affSColin Finck RpcTryExcept 3267c2c66affSColin Finck { 3268c2c66affSColin Finck ret = PNP_GetDeviceRegProp(BindingHandle, 3269c2c66affSColin Finck lpDevInst, 3270c2c66affSColin Finck ulProperty, 3271c2c66affSColin Finck &ulDataType, 3272c2c66affSColin Finck Buffer, 3273c2c66affSColin Finck &ulTransferLength, 3274c2c66affSColin Finck pulLength, 3275c2c66affSColin Finck ulFlags); 3276c2c66affSColin Finck } 3277c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 3278c2c66affSColin Finck { 3279c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 3280c2c66affSColin Finck } 3281c2c66affSColin Finck RpcEndExcept; 3282c2c66affSColin Finck 3283c2c66affSColin Finck if (ret == CR_SUCCESS) 3284c2c66affSColin Finck { 3285c2c66affSColin Finck if (pulRegDataType != NULL) 3286c2c66affSColin Finck *pulRegDataType = ulDataType; 3287c2c66affSColin Finck } 3288c2c66affSColin Finck 3289c2c66affSColin Finck return ret; 3290c2c66affSColin Finck } 3291c2c66affSColin Finck 3292c2c66affSColin Finck 3293c2c66affSColin Finck /*********************************************************************** 3294c2c66affSColin Finck * CM_Get_DevNode_Status [SETUPAPI.@] 3295c2c66affSColin Finck */ 329665d3bf74SEric Kohl CONFIGRET 329765d3bf74SEric Kohl WINAPI 329865d3bf74SEric Kohl CM_Get_DevNode_Status( 329965d3bf74SEric Kohl _Out_ PULONG pulStatus, 330065d3bf74SEric Kohl _Out_ PULONG pulProblemNumber, 330165d3bf74SEric Kohl _In_ DEVINST dnDevInst, 330265d3bf74SEric Kohl _In_ ULONG ulFlags) 3303c2c66affSColin Finck { 330465d3bf74SEric Kohl TRACE("CM_Get_DevNode_Status(%p %p %lx %lx)\n", 3305c2c66affSColin Finck pulStatus, pulProblemNumber, dnDevInst, ulFlags); 330665d3bf74SEric Kohl 3307c2c66affSColin Finck return CM_Get_DevNode_Status_Ex(pulStatus, pulProblemNumber, dnDevInst, 3308c2c66affSColin Finck ulFlags, NULL); 3309c2c66affSColin Finck } 3310c2c66affSColin Finck 3311c2c66affSColin Finck 3312c2c66affSColin Finck /*********************************************************************** 3313c2c66affSColin Finck * CM_Get_DevNode_Status_Ex [SETUPAPI.@] 3314c2c66affSColin Finck */ 331565d3bf74SEric Kohl CONFIGRET 331665d3bf74SEric Kohl WINAPI 3317c2c66affSColin Finck CM_Get_DevNode_Status_Ex( 331865d3bf74SEric Kohl _Out_ PULONG pulStatus, 331965d3bf74SEric Kohl _Out_ PULONG pulProblemNumber, 332065d3bf74SEric Kohl _In_ DEVINST dnDevInst, 332165d3bf74SEric Kohl _In_ ULONG ulFlags, 332265d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 3323c2c66affSColin Finck { 3324c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 3325c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 3326c2c66affSColin Finck LPWSTR lpDevInst; 3327c2c66affSColin Finck CONFIGRET ret; 3328c2c66affSColin Finck 332960a21894SEric Kohl TRACE("CM_Get_DevNode_Status_Ex(%p %p %lx %lx %p)\n", 3330c2c66affSColin Finck pulStatus, pulProblemNumber, dnDevInst, ulFlags, hMachine); 3331c2c66affSColin Finck 3332c2c66affSColin Finck if (pulStatus == NULL || pulProblemNumber == NULL) 3333c2c66affSColin Finck return CR_INVALID_POINTER; 3334c2c66affSColin Finck 3335c2c66affSColin Finck if (dnDevInst == 0) 3336c2c66affSColin Finck return CR_INVALID_DEVINST; 3337c2c66affSColin Finck 3338c2c66affSColin Finck if (ulFlags != 0) 3339c2c66affSColin Finck return CR_INVALID_FLAG; 3340c2c66affSColin Finck 3341c2c66affSColin Finck if (hMachine != NULL) 3342c2c66affSColin Finck { 3343c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 3344c2c66affSColin Finck if (BindingHandle == NULL) 3345c2c66affSColin Finck return CR_FAILURE; 3346c2c66affSColin Finck 3347c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 3348c2c66affSColin Finck if (StringTable == 0) 3349c2c66affSColin Finck return CR_FAILURE; 3350c2c66affSColin Finck } 3351c2c66affSColin Finck else 3352c2c66affSColin Finck { 3353c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 3354c2c66affSColin Finck return CR_FAILURE; 3355c2c66affSColin Finck } 3356c2c66affSColin Finck 3357c2c66affSColin Finck lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst); 3358c2c66affSColin Finck if (lpDevInst == NULL) 3359c2c66affSColin Finck return CR_INVALID_DEVNODE; 3360c2c66affSColin Finck 3361c2c66affSColin Finck RpcTryExcept 3362c2c66affSColin Finck { 3363c2c66affSColin Finck ret = PNP_GetDeviceStatus(BindingHandle, 3364c2c66affSColin Finck lpDevInst, 3365c2c66affSColin Finck pulStatus, 3366c2c66affSColin Finck pulProblemNumber, 3367c2c66affSColin Finck ulFlags); 3368c2c66affSColin Finck } 3369c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 3370c2c66affSColin Finck { 3371c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 3372c2c66affSColin Finck } 3373c2c66affSColin Finck RpcEndExcept; 3374c2c66affSColin Finck 3375c2c66affSColin Finck return ret; 3376c2c66affSColin Finck } 3377c2c66affSColin Finck 3378c2c66affSColin Finck 3379c2c66affSColin Finck /*********************************************************************** 3380c2c66affSColin Finck * CM_Get_Device_IDA [SETUPAPI.@] 3381c2c66affSColin Finck */ 338265d3bf74SEric Kohl CONFIGRET 338365d3bf74SEric Kohl WINAPI 338465d3bf74SEric Kohl CM_Get_Device_IDA( 338565d3bf74SEric Kohl _In_ DEVINST dnDevInst, 338665d3bf74SEric Kohl _Out_writes_(BufferLen) PCHAR Buffer, 338765d3bf74SEric Kohl _In_ ULONG BufferLen, 338865d3bf74SEric Kohl _In_ ULONG ulFlags) 3389c2c66affSColin Finck { 339060a21894SEric Kohl TRACE("CM_Get_Device_IDA(%lx %p %lu %lx)\n", 3391c2c66affSColin Finck dnDevInst, Buffer, BufferLen, ulFlags); 339265d3bf74SEric Kohl 3393c2c66affSColin Finck return CM_Get_Device_ID_ExA(dnDevInst, Buffer, BufferLen, ulFlags, NULL); 3394c2c66affSColin Finck } 3395c2c66affSColin Finck 3396c2c66affSColin Finck 3397c2c66affSColin Finck /*********************************************************************** 3398c2c66affSColin Finck * CM_Get_Device_IDW [SETUPAPI.@] 3399c2c66affSColin Finck */ 340065d3bf74SEric Kohl CONFIGRET 340165d3bf74SEric Kohl WINAPI 340265d3bf74SEric Kohl CM_Get_Device_IDW( 340365d3bf74SEric Kohl _In_ DEVINST dnDevInst, 340465d3bf74SEric Kohl _Out_writes_(BufferLen) PWCHAR Buffer, 340565d3bf74SEric Kohl _In_ ULONG BufferLen, 340665d3bf74SEric Kohl _In_ ULONG ulFlags) 3407c2c66affSColin Finck { 340860a21894SEric Kohl TRACE("CM_Get_Device_IDW(%lx %p %lu %lx)\n", 3409c2c66affSColin Finck dnDevInst, Buffer, BufferLen, ulFlags); 341065d3bf74SEric Kohl 3411c2c66affSColin Finck return CM_Get_Device_ID_ExW(dnDevInst, Buffer, BufferLen, ulFlags, NULL); 3412c2c66affSColin Finck } 3413c2c66affSColin Finck 3414c2c66affSColin Finck 3415c2c66affSColin Finck /*********************************************************************** 3416c2c66affSColin Finck * CM_Get_Device_ID_ExA [SETUPAPI.@] 3417c2c66affSColin Finck */ 341865d3bf74SEric Kohl CONFIGRET 341965d3bf74SEric Kohl WINAPI 342065d3bf74SEric Kohl CM_Get_Device_ID_ExA( 342165d3bf74SEric Kohl _In_ DEVINST dnDevInst, 342265d3bf74SEric Kohl _Out_writes_(BufferLen) PCHAR Buffer, 342365d3bf74SEric Kohl _In_ ULONG BufferLen, 342465d3bf74SEric Kohl _In_ ULONG ulFlags, 342565d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 3426c2c66affSColin Finck { 3427c2c66affSColin Finck WCHAR szBufferW[MAX_DEVICE_ID_LEN]; 3428c2c66affSColin Finck CONFIGRET ret = CR_SUCCESS; 3429c2c66affSColin Finck 343060a21894SEric Kohl TRACE("CM_Get_Device_ID_ExA(%lx %p %lu %lx %p)\n", 3431c2c66affSColin Finck dnDevInst, Buffer, BufferLen, ulFlags, hMachine); 3432c2c66affSColin Finck 3433c2c66affSColin Finck if (Buffer == NULL) 3434c2c66affSColin Finck return CR_INVALID_POINTER; 3435c2c66affSColin Finck 3436c2c66affSColin Finck ret = CM_Get_Device_ID_ExW(dnDevInst, 3437c2c66affSColin Finck szBufferW, 3438c2c66affSColin Finck MAX_DEVICE_ID_LEN, 3439c2c66affSColin Finck ulFlags, 3440c2c66affSColin Finck hMachine); 3441c2c66affSColin Finck if (ret == CR_SUCCESS) 3442c2c66affSColin Finck { 3443c2c66affSColin Finck if (WideCharToMultiByte(CP_ACP, 3444c2c66affSColin Finck 0, 3445c2c66affSColin Finck szBufferW, 3446c2c66affSColin Finck lstrlenW(szBufferW) + 1, 3447c2c66affSColin Finck Buffer, 3448c2c66affSColin Finck BufferLen, 3449c2c66affSColin Finck NULL, 3450c2c66affSColin Finck NULL) == 0) 3451c2c66affSColin Finck ret = CR_FAILURE; 3452c2c66affSColin Finck } 3453c2c66affSColin Finck 3454c2c66affSColin Finck return ret; 3455c2c66affSColin Finck } 3456c2c66affSColin Finck 3457c2c66affSColin Finck 3458c2c66affSColin Finck /*********************************************************************** 3459c2c66affSColin Finck * CM_Get_Device_ID_ExW [SETUPAPI.@] 3460c2c66affSColin Finck */ 346165d3bf74SEric Kohl CONFIGRET 346265d3bf74SEric Kohl WINAPI 346365d3bf74SEric Kohl CM_Get_Device_ID_ExW( 346465d3bf74SEric Kohl _In_ DEVINST dnDevInst, 346565d3bf74SEric Kohl _Out_writes_(BufferLen) PWCHAR Buffer, 346665d3bf74SEric Kohl _In_ ULONG BufferLen, 346765d3bf74SEric Kohl _In_ ULONG ulFlags, 346865d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 3469c2c66affSColin Finck { 3470c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 3471c2c66affSColin Finck 347260a21894SEric Kohl TRACE("CM_Get_Device_ID_ExW(%lx %p %lu %lx %p)\n", 3473c2c66affSColin Finck dnDevInst, Buffer, BufferLen, ulFlags, hMachine); 3474c2c66affSColin Finck 3475c2c66affSColin Finck if (dnDevInst == 0) 3476c2c66affSColin Finck return CR_INVALID_DEVINST; 3477c2c66affSColin Finck 3478c2c66affSColin Finck if (Buffer == NULL) 3479c2c66affSColin Finck return CR_INVALID_POINTER; 3480c2c66affSColin Finck 3481c2c66affSColin Finck if (ulFlags != 0) 3482c2c66affSColin Finck return CR_INVALID_FLAG; 3483c2c66affSColin Finck 3484c2c66affSColin Finck if (hMachine != NULL) 3485c2c66affSColin Finck { 3486c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 3487c2c66affSColin Finck if (StringTable == NULL) 3488c2c66affSColin Finck return CR_FAILURE; 3489c2c66affSColin Finck } 3490c2c66affSColin Finck else 3491c2c66affSColin Finck { 3492c2c66affSColin Finck if (!PnpGetLocalHandles(NULL, &StringTable)) 3493c2c66affSColin Finck return CR_FAILURE; 3494c2c66affSColin Finck } 3495c2c66affSColin Finck 3496c2c66affSColin Finck if (!pSetupStringTableStringFromIdEx(StringTable, 3497c2c66affSColin Finck dnDevInst, 3498c2c66affSColin Finck Buffer, 3499c2c66affSColin Finck &BufferLen)) 3500c2c66affSColin Finck return CR_FAILURE; 3501c2c66affSColin Finck 3502c2c66affSColin Finck return CR_SUCCESS; 3503c2c66affSColin Finck } 3504c2c66affSColin Finck 3505c2c66affSColin Finck 3506c2c66affSColin Finck /*********************************************************************** 3507c2c66affSColin Finck * CM_Get_Device_ID_ListA [SETUPAPI.@] 3508c2c66affSColin Finck */ 350965d3bf74SEric Kohl CONFIGRET 351065d3bf74SEric Kohl WINAPI 351165d3bf74SEric Kohl CM_Get_Device_ID_ListA( 351265d3bf74SEric Kohl _In_ PCSTR pszFilter, 351365d3bf74SEric Kohl _Out_writes_(BufferLen) PCHAR Buffer, 351465d3bf74SEric Kohl _In_ ULONG BufferLen, 351565d3bf74SEric Kohl _In_ ULONG ulFlags) 3516c2c66affSColin Finck { 351760a21894SEric Kohl TRACE("CM_Get_Device_ID_ListA(%p %p %lu %lx)\n", 351865d3bf74SEric Kohl pszFilter, Buffer, BufferLen, ulFlags); 351965d3bf74SEric Kohl 3520c2c66affSColin Finck return CM_Get_Device_ID_List_ExA(pszFilter, Buffer, BufferLen, 3521c2c66affSColin Finck ulFlags, NULL); 3522c2c66affSColin Finck } 3523c2c66affSColin Finck 3524c2c66affSColin Finck 3525c2c66affSColin Finck /*********************************************************************** 3526c2c66affSColin Finck * CM_Get_Device_ID_ListW [SETUPAPI.@] 3527c2c66affSColin Finck */ 352865d3bf74SEric Kohl CONFIGRET 352965d3bf74SEric Kohl WINAPI 353065d3bf74SEric Kohl CM_Get_Device_ID_ListW( 353165d3bf74SEric Kohl _In_ PCWSTR pszFilter, 353265d3bf74SEric Kohl _Out_writes_(BufferLen) PWCHAR Buffer, 353365d3bf74SEric Kohl _In_ ULONG BufferLen, 353465d3bf74SEric Kohl _In_ ULONG ulFlags) 3535c2c66affSColin Finck { 353660a21894SEric Kohl TRACE("CM_Get_Device_ID_ListW(%p %p %lu %lx)\n", 353765d3bf74SEric Kohl pszFilter, Buffer, BufferLen, ulFlags); 353865d3bf74SEric Kohl 3539c2c66affSColin Finck return CM_Get_Device_ID_List_ExW(pszFilter, Buffer, BufferLen, 3540c2c66affSColin Finck ulFlags, NULL); 3541c2c66affSColin Finck } 3542c2c66affSColin Finck 3543c2c66affSColin Finck 3544c2c66affSColin Finck /*********************************************************************** 3545c2c66affSColin Finck * CM_Get_Device_ID_List_ExA [SETUPAPI.@] 3546c2c66affSColin Finck */ 354765d3bf74SEric Kohl CONFIGRET 354865d3bf74SEric Kohl WINAPI 354965d3bf74SEric Kohl CM_Get_Device_ID_List_ExA( 355065d3bf74SEric Kohl _In_ PCSTR pszFilter, 355165d3bf74SEric Kohl _Out_writes_(BufferLen) PCHAR Buffer, 355265d3bf74SEric Kohl _In_ ULONG BufferLen, 355365d3bf74SEric Kohl _In_ ULONG ulFlags, 355465d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 3555c2c66affSColin Finck { 3556c2c66affSColin Finck LPWSTR BufferW = NULL; 3557c2c66affSColin Finck LPWSTR pszFilterW = NULL; 3558c2c66affSColin Finck CONFIGRET ret = CR_SUCCESS; 3559c2c66affSColin Finck 356060a21894SEric Kohl TRACE("CM_Get_Device_ID_List_ExA(%p %p %lu %lx %p)\n", 3561c2c66affSColin Finck pszFilter, Buffer, BufferLen, ulFlags, hMachine); 3562c2c66affSColin Finck 3563c2c66affSColin Finck BufferW = MyMalloc(BufferLen * sizeof(WCHAR)); 3564c2c66affSColin Finck if (BufferW == NULL) 3565c2c66affSColin Finck return CR_OUT_OF_MEMORY; 3566c2c66affSColin Finck 3567c2c66affSColin Finck if (pszFilter == NULL) 3568c2c66affSColin Finck { 3569c2c66affSColin Finck ret = CM_Get_Device_ID_List_ExW(NULL, 3570c2c66affSColin Finck BufferW, 3571c2c66affSColin Finck BufferLen, 3572c2c66affSColin Finck ulFlags, 3573c2c66affSColin Finck hMachine); 3574c2c66affSColin Finck } 3575c2c66affSColin Finck else 3576c2c66affSColin Finck { 3577c2c66affSColin Finck if (pSetupCaptureAndConvertAnsiArg(pszFilter, &pszFilterW)) 3578c2c66affSColin Finck { 3579c2c66affSColin Finck ret = CR_INVALID_DEVICE_ID; 3580c2c66affSColin Finck goto Done; 3581c2c66affSColin Finck } 3582c2c66affSColin Finck 3583c2c66affSColin Finck ret = CM_Get_Device_ID_List_ExW(pszFilterW, 3584c2c66affSColin Finck BufferW, 3585c2c66affSColin Finck BufferLen, 3586c2c66affSColin Finck ulFlags, 3587c2c66affSColin Finck hMachine); 3588c2c66affSColin Finck 3589c2c66affSColin Finck MyFree(pszFilterW); 3590c2c66affSColin Finck } 3591c2c66affSColin Finck 3592c2c66affSColin Finck if (WideCharToMultiByte(CP_ACP, 3593c2c66affSColin Finck 0, 3594c2c66affSColin Finck BufferW, 3595c2c66affSColin Finck lstrlenW(BufferW) + 1, 3596c2c66affSColin Finck Buffer, 3597c2c66affSColin Finck BufferLen, 3598c2c66affSColin Finck NULL, 3599c2c66affSColin Finck NULL) == 0) 3600c2c66affSColin Finck ret = CR_FAILURE; 3601c2c66affSColin Finck 3602c2c66affSColin Finck Done: 3603c2c66affSColin Finck MyFree(BufferW); 3604c2c66affSColin Finck 3605c2c66affSColin Finck return ret; 3606c2c66affSColin Finck } 3607c2c66affSColin Finck 3608c2c66affSColin Finck 3609c2c66affSColin Finck /*********************************************************************** 3610c2c66affSColin Finck * CM_Get_Device_ID_List_ExW [SETUPAPI.@] 3611c2c66affSColin Finck */ 361265d3bf74SEric Kohl CONFIGRET 361365d3bf74SEric Kohl WINAPI 361465d3bf74SEric Kohl CM_Get_Device_ID_List_ExW( 361565d3bf74SEric Kohl _In_ PCWSTR pszFilter, 361665d3bf74SEric Kohl _Out_writes_(BufferLen) PWCHAR Buffer, 361765d3bf74SEric Kohl _In_ ULONG BufferLen, 361865d3bf74SEric Kohl _In_ ULONG ulFlags, 361965d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 3620c2c66affSColin Finck { 3621c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 3622c2c66affSColin Finck CONFIGRET ret; 3623c2c66affSColin Finck 362460a21894SEric Kohl TRACE("CM_Get_Device_ID_List_ExW(%p %p %lu %lx %p)\n", 3625c2c66affSColin Finck pszFilter, Buffer, BufferLen, ulFlags, hMachine); 3626c2c66affSColin Finck 3627c2c66affSColin Finck if (Buffer == NULL || BufferLen == 0) 3628c2c66affSColin Finck return CR_INVALID_POINTER; 3629c2c66affSColin Finck 3630c2c66affSColin Finck if (ulFlags & ~CM_GETIDLIST_FILTER_BITS) 3631c2c66affSColin Finck return CR_INVALID_FLAG; 3632c2c66affSColin Finck 3633c2c66affSColin Finck if (hMachine != NULL) 3634c2c66affSColin Finck { 3635c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 3636c2c66affSColin Finck if (BindingHandle == NULL) 3637c2c66affSColin Finck return CR_FAILURE; 3638c2c66affSColin Finck } 3639c2c66affSColin Finck else 3640c2c66affSColin Finck { 3641c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 3642c2c66affSColin Finck return CR_FAILURE; 3643c2c66affSColin Finck } 3644c2c66affSColin Finck 3645c2c66affSColin Finck *Buffer = 0; 3646c2c66affSColin Finck 3647c2c66affSColin Finck RpcTryExcept 3648c2c66affSColin Finck { 3649c2c66affSColin Finck ret = PNP_GetDeviceList(BindingHandle, 3650c2c66affSColin Finck (LPWSTR)pszFilter, 3651c2c66affSColin Finck Buffer, 3652c2c66affSColin Finck &BufferLen, 3653c2c66affSColin Finck ulFlags); 3654c2c66affSColin Finck } 3655c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 3656c2c66affSColin Finck { 3657c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 3658c2c66affSColin Finck } 3659c2c66affSColin Finck RpcEndExcept; 3660c2c66affSColin Finck 3661c2c66affSColin Finck return ret; 3662c2c66affSColin Finck } 3663c2c66affSColin Finck 3664c2c66affSColin Finck 3665c2c66affSColin Finck /*********************************************************************** 3666c2c66affSColin Finck * CM_Get_Device_ID_List_SizeA [SETUPAPI.@] 3667c2c66affSColin Finck */ 366865d3bf74SEric Kohl CONFIGRET 366965d3bf74SEric Kohl WINAPI 367065d3bf74SEric Kohl CM_Get_Device_ID_List_SizeA( 367165d3bf74SEric Kohl _Out_ PULONG pulLen, 367265d3bf74SEric Kohl _In_opt_ PCSTR pszFilter, 367365d3bf74SEric Kohl _In_ ULONG ulFlags) 3674c2c66affSColin Finck { 367565d3bf74SEric Kohl TRACE("CM_Get_Device_ID_List_SizeA(%p %s %lx)\n", 367665d3bf74SEric Kohl pulLen, debugstr_a(pszFilter), ulFlags); 367765d3bf74SEric Kohl 3678c2c66affSColin Finck return CM_Get_Device_ID_List_Size_ExA(pulLen, pszFilter, ulFlags, NULL); 3679c2c66affSColin Finck } 3680c2c66affSColin Finck 3681c2c66affSColin Finck 3682c2c66affSColin Finck /*********************************************************************** 3683c2c66affSColin Finck * CM_Get_Device_ID_List_SizeW [SETUPAPI.@] 3684c2c66affSColin Finck */ 368565d3bf74SEric Kohl CONFIGRET 368665d3bf74SEric Kohl WINAPI 368765d3bf74SEric Kohl CM_Get_Device_ID_List_SizeW( 368865d3bf74SEric Kohl _Out_ PULONG pulLen, 368965d3bf74SEric Kohl _In_opt_ PCWSTR pszFilter, 369065d3bf74SEric Kohl _In_ ULONG ulFlags) 3691c2c66affSColin Finck { 369265d3bf74SEric Kohl TRACE("CM_Get_Device_ID_List_SizeW(%p %s %lx)\n", 369365d3bf74SEric Kohl pulLen, debugstr_w(pszFilter), ulFlags); 369465d3bf74SEric Kohl 3695c2c66affSColin Finck return CM_Get_Device_ID_List_Size_ExW(pulLen, pszFilter, ulFlags, NULL); 3696c2c66affSColin Finck } 3697c2c66affSColin Finck 3698c2c66affSColin Finck 3699c2c66affSColin Finck /*********************************************************************** 3700c2c66affSColin Finck * CM_Get_Device_ID_List_Size_ExA [SETUPAPI.@] 3701c2c66affSColin Finck */ 370265d3bf74SEric Kohl CONFIGRET 370365d3bf74SEric Kohl WINAPI 370465d3bf74SEric Kohl CM_Get_Device_ID_List_Size_ExA( 370565d3bf74SEric Kohl _Out_ PULONG pulLen, 370665d3bf74SEric Kohl _In_opt_ PCSTR pszFilter, 370765d3bf74SEric Kohl _In_ ULONG ulFlags, 370865d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 3709c2c66affSColin Finck { 3710c2c66affSColin Finck LPWSTR pszFilterW = NULL; 3711c2c66affSColin Finck CONFIGRET ret = CR_SUCCESS; 3712c2c66affSColin Finck 371360a21894SEric Kohl FIXME("CM_Get_Device_ID_List_Size_ExA(%p %s %lx %p)\n", 371465d3bf74SEric Kohl pulLen, debugstr_a(pszFilter), ulFlags, hMachine); 3715c2c66affSColin Finck 3716c2c66affSColin Finck if (pszFilter == NULL) 3717c2c66affSColin Finck { 3718c2c66affSColin Finck ret = CM_Get_Device_ID_List_Size_ExW(pulLen, 3719c2c66affSColin Finck NULL, 3720c2c66affSColin Finck ulFlags, 3721c2c66affSColin Finck hMachine); 3722c2c66affSColin Finck } 3723c2c66affSColin Finck else 3724c2c66affSColin Finck { 3725c2c66affSColin Finck if (pSetupCaptureAndConvertAnsiArg(pszFilter, &pszFilterW)) 3726c2c66affSColin Finck return CR_INVALID_DEVICE_ID; 3727c2c66affSColin Finck 3728c2c66affSColin Finck ret = CM_Get_Device_ID_List_Size_ExW(pulLen, 3729c2c66affSColin Finck pszFilterW, 3730c2c66affSColin Finck ulFlags, 3731c2c66affSColin Finck hMachine); 3732c2c66affSColin Finck 3733c2c66affSColin Finck MyFree(pszFilterW); 3734c2c66affSColin Finck } 3735c2c66affSColin Finck 3736c2c66affSColin Finck return ret; 3737c2c66affSColin Finck } 3738c2c66affSColin Finck 3739c2c66affSColin Finck 3740c2c66affSColin Finck /*********************************************************************** 3741c2c66affSColin Finck * CM_Get_Device_ID_List_Size_ExW [SETUPAPI.@] 3742c2c66affSColin Finck */ 374365d3bf74SEric Kohl CONFIGRET 374465d3bf74SEric Kohl WINAPI 374565d3bf74SEric Kohl CM_Get_Device_ID_List_Size_ExW( 374665d3bf74SEric Kohl _Out_ PULONG pulLen, 374765d3bf74SEric Kohl _In_opt_ PCWSTR pszFilter, 374865d3bf74SEric Kohl _In_ ULONG ulFlags, 374965d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 3750c2c66affSColin Finck { 3751c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 3752c2c66affSColin Finck CONFIGRET ret; 3753c2c66affSColin Finck 375460a21894SEric Kohl FIXME("CM_Get_Device_ID_List_Size_ExW(%p %s %lx %p)\n", 375565d3bf74SEric Kohl pulLen, debugstr_w(pszFilter), ulFlags, hMachine); 3756c2c66affSColin Finck 3757c2c66affSColin Finck if (pulLen == NULL) 3758c2c66affSColin Finck return CR_INVALID_POINTER; 3759c2c66affSColin Finck 3760c2c66affSColin Finck if (ulFlags & ~CM_GETIDLIST_FILTER_BITS) 3761c2c66affSColin Finck return CR_INVALID_FLAG; 3762c2c66affSColin Finck 3763c2c66affSColin Finck if (hMachine != NULL) 3764c2c66affSColin Finck { 3765c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 3766c2c66affSColin Finck if (BindingHandle == NULL) 3767c2c66affSColin Finck return CR_FAILURE; 3768c2c66affSColin Finck } 3769c2c66affSColin Finck else 3770c2c66affSColin Finck { 3771c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 3772c2c66affSColin Finck return CR_FAILURE; 3773c2c66affSColin Finck } 3774c2c66affSColin Finck 3775c2c66affSColin Finck *pulLen = 0; 3776c2c66affSColin Finck 3777c2c66affSColin Finck RpcTryExcept 3778c2c66affSColin Finck { 3779c2c66affSColin Finck ret = PNP_GetDeviceListSize(BindingHandle, 3780c2c66affSColin Finck (LPWSTR)pszFilter, 3781c2c66affSColin Finck pulLen, 3782c2c66affSColin Finck ulFlags); 3783c2c66affSColin Finck } 3784c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 3785c2c66affSColin Finck { 3786c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 3787c2c66affSColin Finck } 3788c2c66affSColin Finck RpcEndExcept; 3789c2c66affSColin Finck 3790c2c66affSColin Finck return ret; 3791c2c66affSColin Finck } 3792c2c66affSColin Finck 3793c2c66affSColin Finck 3794c2c66affSColin Finck /*********************************************************************** 3795c2c66affSColin Finck * CM_Get_Device_ID_Size [SETUPAPI.@] 3796c2c66affSColin Finck */ 379765d3bf74SEric Kohl CONFIGRET 379865d3bf74SEric Kohl WINAPI 379965d3bf74SEric Kohl CM_Get_Device_ID_Size( 380065d3bf74SEric Kohl _Out_ PULONG pulLen, 380165d3bf74SEric Kohl _In_ DEVINST dnDevInst, 380265d3bf74SEric Kohl _In_ ULONG ulFlags) 3803c2c66affSColin Finck { 380465d3bf74SEric Kohl TRACE("CM_Get_Device_ID_Size(%p %lx %lx)\n", 380565d3bf74SEric Kohl pulLen, dnDevInst, ulFlags); 380665d3bf74SEric Kohl 3807c2c66affSColin Finck return CM_Get_Device_ID_Size_Ex(pulLen, dnDevInst, ulFlags, NULL); 3808c2c66affSColin Finck } 3809c2c66affSColin Finck 3810c2c66affSColin Finck 3811c2c66affSColin Finck /*********************************************************************** 3812c2c66affSColin Finck * CM_Get_Device_ID_Size_Ex [SETUPAPI.@] 3813c2c66affSColin Finck */ 381465d3bf74SEric Kohl CONFIGRET 381565d3bf74SEric Kohl WINAPI 381665d3bf74SEric Kohl CM_Get_Device_ID_Size_Ex( 381765d3bf74SEric Kohl _Out_ PULONG pulLen, 381865d3bf74SEric Kohl _In_ DEVINST dnDevInst, 381965d3bf74SEric Kohl _In_ ULONG ulFlags, 382065d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 3821c2c66affSColin Finck { 3822c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 3823c2c66affSColin Finck LPWSTR DeviceId; 3824c2c66affSColin Finck 382560a21894SEric Kohl TRACE("CM_Get_Device_ID_Size_Ex(%p %lx %lx %p)\n", 382665d3bf74SEric Kohl pulLen, dnDevInst, ulFlags, hMachine); 3827c2c66affSColin Finck 3828c2c66affSColin Finck if (pulLen == NULL) 3829c2c66affSColin Finck return CR_INVALID_POINTER; 3830c2c66affSColin Finck 3831c2c66affSColin Finck if (dnDevInst == 0) 3832c2c66affSColin Finck return CR_INVALID_DEVINST; 3833c2c66affSColin Finck 3834c2c66affSColin Finck if (ulFlags != 0) 3835c2c66affSColin Finck return CR_INVALID_FLAG; 3836c2c66affSColin Finck 3837c2c66affSColin Finck if (hMachine != NULL) 3838c2c66affSColin Finck { 3839c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 3840c2c66affSColin Finck if (StringTable == NULL) 3841c2c66affSColin Finck return CR_FAILURE; 3842c2c66affSColin Finck } 3843c2c66affSColin Finck else 3844c2c66affSColin Finck { 3845c2c66affSColin Finck if (!PnpGetLocalHandles(NULL, &StringTable)) 3846c2c66affSColin Finck return CR_FAILURE; 3847c2c66affSColin Finck } 3848c2c66affSColin Finck 3849c2c66affSColin Finck DeviceId = pSetupStringTableStringFromId(StringTable, dnDevInst); 3850c2c66affSColin Finck if (DeviceId == NULL) 3851c2c66affSColin Finck { 3852c2c66affSColin Finck *pulLen = 0; 3853c2c66affSColin Finck return CR_SUCCESS; 3854c2c66affSColin Finck } 3855c2c66affSColin Finck 3856c2c66affSColin Finck *pulLen = lstrlenW(DeviceId); 3857c2c66affSColin Finck 3858c2c66affSColin Finck return CR_SUCCESS; 3859c2c66affSColin Finck } 3860c2c66affSColin Finck 3861c2c66affSColin Finck 3862c2c66affSColin Finck /*********************************************************************** 3863c2c66affSColin Finck * CM_Get_Device_Interface_AliasA [SETUPAPI.@] 3864c2c66affSColin Finck */ 386565d3bf74SEric Kohl CONFIGRET 386665d3bf74SEric Kohl WINAPI 386765d3bf74SEric Kohl CM_Get_Device_Interface_AliasA( 386865d3bf74SEric Kohl _In_ LPCSTR pszDeviceInterface, 386965d3bf74SEric Kohl _In_ LPGUID AliasInterfaceGuid, 387065d3bf74SEric Kohl _Out_writes_(*pulLength) LPSTR pszAliasDeviceInterface, 387165d3bf74SEric Kohl _Inout_ PULONG pulLength, 387265d3bf74SEric Kohl _In_ ULONG ulFlags) 3873c2c66affSColin Finck { 387465d3bf74SEric Kohl TRACE("CM_Get_Device_Interface_AliasA(%p %p %p %p %lx)\n", 387565d3bf74SEric Kohl pszDeviceInterface, AliasInterfaceGuid, 3876c2c66affSColin Finck pszAliasDeviceInterface, pulLength, ulFlags); 3877c2c66affSColin Finck 3878c2c66affSColin Finck return CM_Get_Device_Interface_Alias_ExA(pszDeviceInterface, 3879c2c66affSColin Finck AliasInterfaceGuid, pszAliasDeviceInterface, pulLength, 3880c2c66affSColin Finck ulFlags, NULL); 3881c2c66affSColin Finck } 3882c2c66affSColin Finck 3883c2c66affSColin Finck 3884c2c66affSColin Finck /*********************************************************************** 3885c2c66affSColin Finck * CM_Get_Device_Interface_AliasW [SETUPAPI.@] 3886c2c66affSColin Finck */ 388765d3bf74SEric Kohl CONFIGRET 388865d3bf74SEric Kohl WINAPI 388965d3bf74SEric Kohl CM_Get_Device_Interface_AliasW( 389065d3bf74SEric Kohl _In_ LPCWSTR pszDeviceInterface, 389165d3bf74SEric Kohl _In_ LPGUID AliasInterfaceGuid, 389265d3bf74SEric Kohl _Out_writes_(*pulLength) LPWSTR pszAliasDeviceInterface, 389365d3bf74SEric Kohl _Inout_ PULONG pulLength, 389465d3bf74SEric Kohl _In_ ULONG ulFlags) 3895c2c66affSColin Finck { 389665d3bf74SEric Kohl TRACE("CM_Get_Device_Interface_AliasW(%p %p %p %p %lx)\n", 389765d3bf74SEric Kohl pszDeviceInterface, AliasInterfaceGuid, 3898c2c66affSColin Finck pszAliasDeviceInterface, pulLength, ulFlags); 3899c2c66affSColin Finck 3900c2c66affSColin Finck return CM_Get_Device_Interface_Alias_ExW(pszDeviceInterface, 3901c2c66affSColin Finck AliasInterfaceGuid, pszAliasDeviceInterface, pulLength, 3902c2c66affSColin Finck ulFlags, NULL); 3903c2c66affSColin Finck } 3904c2c66affSColin Finck 3905c2c66affSColin Finck 3906c2c66affSColin Finck /*********************************************************************** 3907c2c66affSColin Finck * CM_Get_Device_Interface_Alias_ExA [SETUPAPI.@] 3908c2c66affSColin Finck */ 390965d3bf74SEric Kohl CONFIGRET 391065d3bf74SEric Kohl WINAPI 391165d3bf74SEric Kohl CM_Get_Device_Interface_Alias_ExA( 391265d3bf74SEric Kohl _In_ LPCSTR pszDeviceInterface, 391365d3bf74SEric Kohl _In_ LPGUID AliasInterfaceGuid, 391465d3bf74SEric Kohl _Out_writes_(*pulLength) LPSTR pszAliasDeviceInterface, 391565d3bf74SEric Kohl _Inout_ PULONG pulLength, 391665d3bf74SEric Kohl _In_ ULONG ulFlags, 391765d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 3918c2c66affSColin Finck { 391960a21894SEric Kohl FIXME("CM_Get_Device_Interface_Alias_ExA(%p %p %p %p %lx %p)\n", 392065d3bf74SEric Kohl pszDeviceInterface, AliasInterfaceGuid, 3921c2c66affSColin Finck pszAliasDeviceInterface, pulLength, ulFlags, hMachine); 3922c2c66affSColin Finck 3923c2c66affSColin Finck return CR_CALL_NOT_IMPLEMENTED; 3924c2c66affSColin Finck } 3925c2c66affSColin Finck 3926c2c66affSColin Finck 3927c2c66affSColin Finck /*********************************************************************** 3928c2c66affSColin Finck * CM_Get_Device_Interface_Alias_ExW [SETUPAPI.@] 3929c2c66affSColin Finck */ 393065d3bf74SEric Kohl CONFIGRET 393165d3bf74SEric Kohl WINAPI 393265d3bf74SEric Kohl CM_Get_Device_Interface_Alias_ExW( 393365d3bf74SEric Kohl _In_ LPCWSTR pszDeviceInterface, 393465d3bf74SEric Kohl _In_ LPGUID AliasInterfaceGuid, 393565d3bf74SEric Kohl _Out_writes_(*pulLength) LPWSTR pszAliasDeviceInterface, 393665d3bf74SEric Kohl _Inout_ PULONG pulLength, 393765d3bf74SEric Kohl _In_ ULONG ulFlags, 393865d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 3939c2c66affSColin Finck { 3940c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 3941c2c66affSColin Finck ULONG ulTransferLength; 3942c2c66affSColin Finck CONFIGRET ret = CR_SUCCESS; 3943c2c66affSColin Finck 394460a21894SEric Kohl TRACE("CM_Get_Device_Interface_Alias_ExW(%p %p %p %p %lx %p)\n", 394565d3bf74SEric Kohl pszDeviceInterface, AliasInterfaceGuid, 3946c2c66affSColin Finck pszAliasDeviceInterface, pulLength, ulFlags, hMachine); 3947c2c66affSColin Finck 3948c2c66affSColin Finck if (pszDeviceInterface == NULL || 3949c2c66affSColin Finck AliasInterfaceGuid == NULL || 3950c2c66affSColin Finck pszAliasDeviceInterface == NULL || 3951c2c66affSColin Finck pulLength == NULL) 3952c2c66affSColin Finck return CR_INVALID_POINTER; 3953c2c66affSColin Finck 3954c2c66affSColin Finck if (ulFlags != 0) 3955c2c66affSColin Finck return CR_INVALID_FLAG; 3956c2c66affSColin Finck 3957c2c66affSColin Finck if (hMachine != NULL) 3958c2c66affSColin Finck { 3959c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 3960c2c66affSColin Finck if (BindingHandle == NULL) 3961c2c66affSColin Finck return CR_FAILURE; 3962c2c66affSColin Finck } 3963c2c66affSColin Finck else 3964c2c66affSColin Finck { 3965c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 3966c2c66affSColin Finck return CR_FAILURE; 3967c2c66affSColin Finck } 3968c2c66affSColin Finck 3969c2c66affSColin Finck ulTransferLength = *pulLength; 3970c2c66affSColin Finck 3971c2c66affSColin Finck RpcTryExcept 3972c2c66affSColin Finck { 3973c2c66affSColin Finck ret = PNP_GetInterfaceDeviceAlias(BindingHandle, 3974c2c66affSColin Finck (LPWSTR)pszDeviceInterface, 3975c2c66affSColin Finck AliasInterfaceGuid, 3976c2c66affSColin Finck pszAliasDeviceInterface, 3977c2c66affSColin Finck pulLength, 3978c2c66affSColin Finck &ulTransferLength, 3979c2c66affSColin Finck 0); 3980c2c66affSColin Finck } 3981c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 3982c2c66affSColin Finck { 3983c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 3984c2c66affSColin Finck } 3985c2c66affSColin Finck RpcEndExcept; 3986c2c66affSColin Finck 3987c2c66affSColin Finck return ret; 3988c2c66affSColin Finck } 3989c2c66affSColin Finck 3990c2c66affSColin Finck 3991c2c66affSColin Finck /*********************************************************************** 3992c2c66affSColin Finck * CM_Get_Device_Interface_ListA (SETUPAPI.@) 3993c2c66affSColin Finck */ 399465d3bf74SEric Kohl CONFIGRET 399565d3bf74SEric Kohl WINAPI 399665d3bf74SEric Kohl CM_Get_Device_Interface_ListA( 399765d3bf74SEric Kohl _In_ LPGUID InterfaceClassGuid, 399865d3bf74SEric Kohl _In_opt_ DEVINSTID_A pDeviceID, 399965d3bf74SEric Kohl _Out_writes_(BufferLen) PCHAR Buffer, 400065d3bf74SEric Kohl _In_ ULONG BufferLen, 400165d3bf74SEric Kohl _In_ ULONG ulFlags) 4002c2c66affSColin Finck { 400365d3bf74SEric Kohl TRACE("CM_Get_Device_Interface_ListA(%s %s %p %lu 0x%08lx)\n", 400465d3bf74SEric Kohl debugstr_guid(InterfaceClassGuid), debugstr_a(pDeviceID), 400565d3bf74SEric Kohl Buffer, BufferLen, ulFlags); 4006c2c66affSColin Finck 4007c2c66affSColin Finck return CM_Get_Device_Interface_List_ExA(InterfaceClassGuid, pDeviceID, 4008c2c66affSColin Finck Buffer, BufferLen, ulFlags, NULL); 4009c2c66affSColin Finck } 4010c2c66affSColin Finck 4011c2c66affSColin Finck 4012c2c66affSColin Finck /*********************************************************************** 4013c2c66affSColin Finck * CM_Get_Device_Interface_ListW (SETUPAPI.@) 4014c2c66affSColin Finck */ 401565d3bf74SEric Kohl CONFIGRET 401665d3bf74SEric Kohl WINAPI 401765d3bf74SEric Kohl CM_Get_Device_Interface_ListW( 401865d3bf74SEric Kohl _In_ LPGUID InterfaceClassGuid, 401965d3bf74SEric Kohl _In_opt_ DEVINSTID_W pDeviceID, 402065d3bf74SEric Kohl _Out_writes_(BufferLen) PWCHAR Buffer, 402165d3bf74SEric Kohl _In_ ULONG BufferLen, 402265d3bf74SEric Kohl _In_ ULONG ulFlags) 4023c2c66affSColin Finck { 402465d3bf74SEric Kohl TRACE("CM_Get_Device_Interface_ListW(%s %s %p %lu 0x%08lx)\n", 402565d3bf74SEric Kohl debugstr_guid(InterfaceClassGuid), debugstr_w(pDeviceID), 402665d3bf74SEric Kohl Buffer, BufferLen, ulFlags); 4027c2c66affSColin Finck 4028c2c66affSColin Finck return CM_Get_Device_Interface_List_ExW(InterfaceClassGuid, pDeviceID, 4029c2c66affSColin Finck Buffer, BufferLen, ulFlags, NULL); 4030c2c66affSColin Finck } 4031c2c66affSColin Finck 4032c2c66affSColin Finck 4033c2c66affSColin Finck /*********************************************************************** 4034c2c66affSColin Finck * CM_Get_Device_Interface_List_ExA (SETUPAPI.@) 4035c2c66affSColin Finck */ 403665d3bf74SEric Kohl CONFIGRET 403765d3bf74SEric Kohl WINAPI 403865d3bf74SEric Kohl CM_Get_Device_Interface_List_ExA( 403965d3bf74SEric Kohl _In_ LPGUID InterfaceClassGuid, 404065d3bf74SEric Kohl _In_opt_ DEVINSTID_A pDeviceID, 404165d3bf74SEric Kohl _Out_writes_(BufferLen) PCHAR Buffer, 404265d3bf74SEric Kohl _In_ ULONG BufferLen, 404365d3bf74SEric Kohl _In_ ULONG ulFlags, 404465d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 4045c2c66affSColin Finck { 4046c2c66affSColin Finck DEVINSTID_W pDeviceIdW = NULL; 4047c2c66affSColin Finck PWCHAR BufferW = NULL; 4048c2c66affSColin Finck CONFIGRET ret = CR_SUCCESS; 4049c2c66affSColin Finck 405065d3bf74SEric Kohl TRACE("CM_Get_Device_Interface_List_ExA(%s %s %p %lu 0x%08lx %p)\n", 405165d3bf74SEric Kohl debugstr_guid(InterfaceClassGuid), debugstr_a(pDeviceID), 405265d3bf74SEric Kohl Buffer, BufferLen, ulFlags, hMachine); 4053c2c66affSColin Finck 4054c2c66affSColin Finck if (Buffer == NULL || 4055c2c66affSColin Finck BufferLen == 0) 4056c2c66affSColin Finck return CR_INVALID_POINTER; 4057c2c66affSColin Finck 4058c2c66affSColin Finck if (pDeviceID != NULL) 4059c2c66affSColin Finck { 4060c2c66affSColin Finck if (!pSetupCaptureAndConvertAnsiArg(pDeviceID, &pDeviceIdW)) 4061c2c66affSColin Finck return CR_INVALID_DEVICE_ID; 4062c2c66affSColin Finck } 4063c2c66affSColin Finck 4064c2c66affSColin Finck BufferW = MyMalloc(BufferLen * sizeof(WCHAR)); 4065c2c66affSColin Finck if (BufferW == NULL) 4066c2c66affSColin Finck { 4067c2c66affSColin Finck ret = CR_OUT_OF_MEMORY; 4068c2c66affSColin Finck goto Done; 4069c2c66affSColin Finck } 4070c2c66affSColin Finck 4071c2c66affSColin Finck ret = CM_Get_Device_Interface_List_ExW(InterfaceClassGuid, pDeviceIdW, 4072c2c66affSColin Finck BufferW, BufferLen, ulFlags, 4073c2c66affSColin Finck hMachine); 4074c2c66affSColin Finck if (ret != CR_SUCCESS) 4075c2c66affSColin Finck goto Done; 4076c2c66affSColin Finck 4077c2c66affSColin Finck if (WideCharToMultiByte(CP_ACP, 4078c2c66affSColin Finck 0, 4079c2c66affSColin Finck BufferW, 4080c2c66affSColin Finck lstrlenW(BufferW) + 1, 4081c2c66affSColin Finck Buffer, 4082c2c66affSColin Finck BufferLen, 4083c2c66affSColin Finck NULL, 4084c2c66affSColin Finck NULL) == 0) 4085c2c66affSColin Finck ret = CR_FAILURE; 4086c2c66affSColin Finck 4087c2c66affSColin Finck Done: 4088c2c66affSColin Finck if (BufferW != NULL) 4089c2c66affSColin Finck MyFree(BufferW); 4090c2c66affSColin Finck 4091c2c66affSColin Finck if (pDeviceIdW != NULL) 4092c2c66affSColin Finck MyFree(pDeviceIdW); 4093c2c66affSColin Finck 4094c2c66affSColin Finck return ret; 4095c2c66affSColin Finck } 4096c2c66affSColin Finck 4097c2c66affSColin Finck 4098c2c66affSColin Finck /*********************************************************************** 4099c2c66affSColin Finck * CM_Get_Device_Interface_List_ExW (SETUPAPI.@) 4100c2c66affSColin Finck */ 410165d3bf74SEric Kohl CONFIGRET 410265d3bf74SEric Kohl WINAPI 410365d3bf74SEric Kohl CM_Get_Device_Interface_List_ExW( 410465d3bf74SEric Kohl _In_ LPGUID InterfaceClassGuid, 410565d3bf74SEric Kohl _In_opt_ DEVINSTID_W pDeviceID, 410665d3bf74SEric Kohl _Out_writes_(BufferLen) PWCHAR Buffer, 410765d3bf74SEric Kohl _In_ ULONG BufferLen, 410865d3bf74SEric Kohl _In_ ULONG ulFlags, 410965d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 4110c2c66affSColin Finck { 4111c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 4112c2c66affSColin Finck PNP_RPC_BUFFER_SIZE BufferSize = 0; 4113c2c66affSColin Finck CONFIGRET ret = CR_SUCCESS; 4114c2c66affSColin Finck 411565d3bf74SEric Kohl TRACE("CM_Get_Device_Interface_List_ExW(%s %s %p %lu 0x%08lx %p)\n", 411665d3bf74SEric Kohl debugstr_guid(InterfaceClassGuid), debugstr_w(pDeviceID), 411765d3bf74SEric Kohl Buffer, BufferLen, ulFlags, hMachine); 4118c2c66affSColin Finck 4119c2c66affSColin Finck if (Buffer == NULL || 4120c2c66affSColin Finck BufferLen == 0) 4121c2c66affSColin Finck return CR_INVALID_POINTER; 4122c2c66affSColin Finck 4123c2c66affSColin Finck if (ulFlags & ~CM_GET_DEVICE_INTERFACE_LIST_BITS) 4124c2c66affSColin Finck return CR_INVALID_FLAG; 4125c2c66affSColin Finck 4126c2c66affSColin Finck if (hMachine != NULL) 4127c2c66affSColin Finck { 4128c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 4129c2c66affSColin Finck if (BindingHandle == NULL) 4130c2c66affSColin Finck return CR_FAILURE; 4131c2c66affSColin Finck } 4132c2c66affSColin Finck else 4133c2c66affSColin Finck { 4134c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 4135c2c66affSColin Finck return CR_FAILURE; 4136c2c66affSColin Finck } 4137c2c66affSColin Finck 4138c2c66affSColin Finck *Buffer = 0; 4139c2c66affSColin Finck BufferSize = BufferLen; 4140c2c66affSColin Finck 4141c2c66affSColin Finck RpcTryExcept 4142c2c66affSColin Finck { 4143c2c66affSColin Finck ret = PNP_GetInterfaceDeviceList(BindingHandle, 4144c2c66affSColin Finck InterfaceClassGuid, 4145c2c66affSColin Finck pDeviceID, 4146c2c66affSColin Finck (LPBYTE)Buffer, 4147c2c66affSColin Finck &BufferSize, 4148c2c66affSColin Finck ulFlags); 4149c2c66affSColin Finck } 4150c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 4151c2c66affSColin Finck { 4152c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 4153c2c66affSColin Finck } 4154c2c66affSColin Finck RpcEndExcept; 4155c2c66affSColin Finck 4156c2c66affSColin Finck return ret; 4157c2c66affSColin Finck } 4158c2c66affSColin Finck 4159c2c66affSColin Finck 4160c2c66affSColin Finck /*********************************************************************** 4161c2c66affSColin Finck * CM_Get_Device_Interface_List_SizeA (SETUPAPI.@) 4162c2c66affSColin Finck */ 416365d3bf74SEric Kohl CONFIGRET 416465d3bf74SEric Kohl WINAPI 416565d3bf74SEric Kohl CM_Get_Device_Interface_List_SizeA( 416665d3bf74SEric Kohl _Out_ PULONG pulLen, 416765d3bf74SEric Kohl _In_ LPGUID InterfaceClassGuid, 416865d3bf74SEric Kohl _In_opt_ DEVINSTID_A pDeviceID, 416965d3bf74SEric Kohl _In_ ULONG ulFlags) 4170c2c66affSColin Finck { 417165d3bf74SEric Kohl TRACE("CM_Get_Device_Interface_List_SizeA(%p %p %s 0x%08lx)\n", 417265d3bf74SEric Kohl pulLen, InterfaceClassGuid, debugstr_a(pDeviceID), ulFlags); 4173c2c66affSColin Finck 4174c2c66affSColin Finck return CM_Get_Device_Interface_List_Size_ExA(pulLen, InterfaceClassGuid, 417565d3bf74SEric Kohl pDeviceID, ulFlags, NULL); 4176c2c66affSColin Finck } 4177c2c66affSColin Finck 4178c2c66affSColin Finck 4179c2c66affSColin Finck /*********************************************************************** 4180c2c66affSColin Finck * CM_Get_Device_Interface_List_SizeW (SETUPAPI.@) 4181c2c66affSColin Finck */ 418265d3bf74SEric Kohl CONFIGRET 418365d3bf74SEric Kohl WINAPI 418465d3bf74SEric Kohl CM_Get_Device_Interface_List_SizeW( 418565d3bf74SEric Kohl _Out_ PULONG pulLen, 418665d3bf74SEric Kohl _In_ LPGUID InterfaceClassGuid, 418765d3bf74SEric Kohl _In_opt_ DEVINSTID_W pDeviceID, 418865d3bf74SEric Kohl _In_ ULONG ulFlags) 4189c2c66affSColin Finck { 419065d3bf74SEric Kohl TRACE("CM_Get_Device_Interface_List_SizeW(%p %p %s 0x%08lx)\n", 419165d3bf74SEric Kohl pulLen, InterfaceClassGuid, debugstr_w(pDeviceID), ulFlags); 4192c2c66affSColin Finck 4193c2c66affSColin Finck return CM_Get_Device_Interface_List_Size_ExW(pulLen, InterfaceClassGuid, 419465d3bf74SEric Kohl pDeviceID, ulFlags, NULL); 4195c2c66affSColin Finck } 4196c2c66affSColin Finck 4197c2c66affSColin Finck 4198c2c66affSColin Finck /*********************************************************************** 4199c2c66affSColin Finck * CM_Get_Device_Interface_List_Size_ExA (SETUPAPI.@) 4200c2c66affSColin Finck */ 420165d3bf74SEric Kohl CONFIGRET 420265d3bf74SEric Kohl WINAPI 420365d3bf74SEric Kohl CM_Get_Device_Interface_List_Size_ExA( 420465d3bf74SEric Kohl _Out_ PULONG pulLen, 420565d3bf74SEric Kohl _In_ LPGUID InterfaceClassGuid, 420665d3bf74SEric Kohl _In_opt_ DEVINSTID_A pDeviceID, 420765d3bf74SEric Kohl _In_ ULONG ulFlags, 420865d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 4209c2c66affSColin Finck { 4210c2c66affSColin Finck DEVINSTID_W pDeviceIdW = NULL; 4211c2c66affSColin Finck CONFIGRET ret = CR_SUCCESS; 4212c2c66affSColin Finck 421365d3bf74SEric Kohl TRACE("CM_Get_Device_Interface_List_Size_ExA(%p %p %s 0x%08lx %p)\n", 421465d3bf74SEric Kohl pulLen, InterfaceClassGuid, debugstr_a(pDeviceID), ulFlags, hMachine); 4215c2c66affSColin Finck 4216c2c66affSColin Finck if (pulLen == NULL) 4217c2c66affSColin Finck return CR_INVALID_POINTER; 4218c2c66affSColin Finck 421965d3bf74SEric Kohl if (pDeviceID != NULL) 4220c2c66affSColin Finck { 422165d3bf74SEric Kohl if (!pSetupCaptureAndConvertAnsiArg(pDeviceID, &pDeviceIdW)) 4222c2c66affSColin Finck return CR_INVALID_DEVICE_ID; 4223c2c66affSColin Finck } 4224c2c66affSColin Finck 4225c2c66affSColin Finck *pulLen = 0; 4226c2c66affSColin Finck 4227c2c66affSColin Finck ret = CM_Get_Device_Interface_List_Size_ExW(pulLen, InterfaceClassGuid, 4228c2c66affSColin Finck pDeviceIdW, ulFlags, hMachine); 4229c2c66affSColin Finck 4230c2c66affSColin Finck if (pDeviceIdW != NULL) 4231c2c66affSColin Finck MyFree(pDeviceIdW); 4232c2c66affSColin Finck 4233c2c66affSColin Finck return ret; 4234c2c66affSColin Finck } 4235c2c66affSColin Finck 4236c2c66affSColin Finck 4237c2c66affSColin Finck /*********************************************************************** 4238c2c66affSColin Finck * CM_Get_Device_Interface_List_Size_ExW (SETUPAPI.@) 4239c2c66affSColin Finck */ 424065d3bf74SEric Kohl CONFIGRET 424165d3bf74SEric Kohl WINAPI 424265d3bf74SEric Kohl CM_Get_Device_Interface_List_Size_ExW( 424365d3bf74SEric Kohl _Out_ PULONG pulLen, 424465d3bf74SEric Kohl _In_ LPGUID InterfaceClassGuid, 424565d3bf74SEric Kohl _In_opt_ DEVINSTID_W pDeviceID, 424665d3bf74SEric Kohl _In_ ULONG ulFlags, 424765d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 4248c2c66affSColin Finck { 4249c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 4250c2c66affSColin Finck CONFIGRET ret = CR_SUCCESS; 4251c2c66affSColin Finck 425265d3bf74SEric Kohl TRACE("CM_Get_Device_Interface_List_Size_ExW(%p %p %s 0x%08lx %p)\n", 425365d3bf74SEric Kohl pulLen, InterfaceClassGuid, debugstr_w(pDeviceID), ulFlags, hMachine); 4254c2c66affSColin Finck 4255c2c66affSColin Finck if (pulLen == NULL) 4256c2c66affSColin Finck return CR_INVALID_POINTER; 4257c2c66affSColin Finck 4258c2c66affSColin Finck if (ulFlags & ~CM_GET_DEVICE_INTERFACE_LIST_BITS) 4259c2c66affSColin Finck return CR_INVALID_FLAG; 4260c2c66affSColin Finck 4261c2c66affSColin Finck if (hMachine != NULL) 4262c2c66affSColin Finck { 4263c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 4264c2c66affSColin Finck if (BindingHandle == NULL) 4265c2c66affSColin Finck return CR_FAILURE; 4266c2c66affSColin Finck } 4267c2c66affSColin Finck else 4268c2c66affSColin Finck { 4269c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 4270c2c66affSColin Finck return CR_FAILURE; 4271c2c66affSColin Finck } 4272c2c66affSColin Finck 4273c2c66affSColin Finck *pulLen = 0; 4274c2c66affSColin Finck 4275c2c66affSColin Finck RpcTryExcept 4276c2c66affSColin Finck { 4277c2c66affSColin Finck ret = PNP_GetInterfaceDeviceListSize(BindingHandle, 4278c2c66affSColin Finck pulLen, 4279c2c66affSColin Finck InterfaceClassGuid, 428065d3bf74SEric Kohl pDeviceID, 4281c2c66affSColin Finck ulFlags); 4282c2c66affSColin Finck } 4283c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 4284c2c66affSColin Finck { 4285c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 4286c2c66affSColin Finck } 4287c2c66affSColin Finck RpcEndExcept; 4288c2c66affSColin Finck 4289c2c66affSColin Finck return ret; 4290c2c66affSColin Finck } 4291c2c66affSColin Finck 4292c2c66affSColin Finck 4293c2c66affSColin Finck /*********************************************************************** 4294c2c66affSColin Finck * CM_Get_First_Log_Conf [SETUPAPI.@] 4295c2c66affSColin Finck */ 429665d3bf74SEric Kohl CONFIGRET 429765d3bf74SEric Kohl WINAPI 429865d3bf74SEric Kohl CM_Get_First_Log_Conf( 429965d3bf74SEric Kohl _Out_opt_ PLOG_CONF plcLogConf, 430065d3bf74SEric Kohl _In_ DEVINST dnDevInst, 430165d3bf74SEric Kohl _In_ ULONG ulFlags) 4302c2c66affSColin Finck { 430365d3bf74SEric Kohl TRACE("CM_Get_First_Log_Conf(%p %lx %lx)\n", 430465d3bf74SEric Kohl plcLogConf, dnDevInst, ulFlags); 430565d3bf74SEric Kohl 4306c2c66affSColin Finck return CM_Get_First_Log_Conf_Ex(plcLogConf, dnDevInst, ulFlags, NULL); 4307c2c66affSColin Finck } 4308c2c66affSColin Finck 4309c2c66affSColin Finck 4310c2c66affSColin Finck /*********************************************************************** 4311c2c66affSColin Finck * CM_Get_First_Log_Conf_Ex [SETUPAPI.@] 4312c2c66affSColin Finck */ 431365d3bf74SEric Kohl CONFIGRET 431465d3bf74SEric Kohl WINAPI 431565d3bf74SEric Kohl CM_Get_First_Log_Conf_Ex( 431665d3bf74SEric Kohl _Out_opt_ PLOG_CONF plcLogConf, 431765d3bf74SEric Kohl _In_ DEVINST dnDevInst, 431865d3bf74SEric Kohl _In_ ULONG ulFlags, 431965d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 4320c2c66affSColin Finck { 4321c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 4322c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 4323c2c66affSColin Finck LPWSTR lpDevInst = NULL; 4324c2c66affSColin Finck CONFIGRET ret = CR_SUCCESS; 4325c2c66affSColin Finck ULONG ulTag; 4326c2c66affSColin Finck PLOG_CONF_INFO pLogConfInfo; 4327c2c66affSColin Finck 432860a21894SEric Kohl FIXME("CM_Get_First_Log_Conf_Ex(%p %lx %lx %p)\n", 432965d3bf74SEric Kohl plcLogConf, dnDevInst, ulFlags, hMachine); 4330c2c66affSColin Finck 4331c2c66affSColin Finck if (dnDevInst == 0) 4332c2c66affSColin Finck return CR_INVALID_DEVINST; 4333c2c66affSColin Finck 4334c2c66affSColin Finck if (ulFlags & ~LOG_CONF_BITS) 4335c2c66affSColin Finck return CR_INVALID_FLAG; 4336c2c66affSColin Finck 4337c2c66affSColin Finck if (plcLogConf) 4338c2c66affSColin Finck *plcLogConf = 0; 4339c2c66affSColin Finck 4340c2c66affSColin Finck if (hMachine != NULL) 4341c2c66affSColin Finck { 4342c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 4343c2c66affSColin Finck if (BindingHandle == NULL) 4344c2c66affSColin Finck return CR_FAILURE; 4345c2c66affSColin Finck 4346c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 4347c2c66affSColin Finck if (StringTable == 0) 4348c2c66affSColin Finck return CR_FAILURE; 4349c2c66affSColin Finck } 4350c2c66affSColin Finck else 4351c2c66affSColin Finck { 4352c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 4353c2c66affSColin Finck return CR_FAILURE; 4354c2c66affSColin Finck } 4355c2c66affSColin Finck 4356c2c66affSColin Finck lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst); 4357c2c66affSColin Finck if (lpDevInst == NULL) 4358c2c66affSColin Finck return CR_INVALID_DEVNODE; 4359c2c66affSColin Finck 4360c2c66affSColin Finck RpcTryExcept 4361c2c66affSColin Finck { 4362c2c66affSColin Finck ret = PNP_GetFirstLogConf(BindingHandle, 4363c2c66affSColin Finck lpDevInst, 4364c2c66affSColin Finck ulFlags, 4365c2c66affSColin Finck &ulTag, 4366c2c66affSColin Finck ulFlags); 4367c2c66affSColin Finck } 4368c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 4369c2c66affSColin Finck { 4370c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 4371c2c66affSColin Finck } 4372c2c66affSColin Finck RpcEndExcept; 4373c2c66affSColin Finck 4374c2c66affSColin Finck if (ret != CR_SUCCESS) 4375c2c66affSColin Finck return ret; 4376c2c66affSColin Finck 4377c2c66affSColin Finck if (plcLogConf) 4378c2c66affSColin Finck { 4379c2c66affSColin Finck pLogConfInfo = HeapAlloc(GetProcessHeap(), 0, sizeof(LOG_CONF_INFO)); 4380c2c66affSColin Finck if (pLogConfInfo == NULL) 4381c2c66affSColin Finck return CR_OUT_OF_MEMORY; 4382c2c66affSColin Finck 4383c2c66affSColin Finck pLogConfInfo->ulMagic = LOG_CONF_MAGIC; 4384c2c66affSColin Finck pLogConfInfo->dnDevInst = dnDevInst; 4385c2c66affSColin Finck pLogConfInfo->ulFlags = ulFlags; 4386c2c66affSColin Finck pLogConfInfo->ulTag = ulTag; 4387c2c66affSColin Finck 4388c2c66affSColin Finck *plcLogConf = (LOG_CONF)pLogConfInfo; 4389c2c66affSColin Finck } 4390c2c66affSColin Finck 4391c2c66affSColin Finck return CR_SUCCESS; 4392c2c66affSColin Finck } 4393c2c66affSColin Finck 4394c2c66affSColin Finck 4395c2c66affSColin Finck /*********************************************************************** 4396c2c66affSColin Finck * CM_Get_Global_State [SETUPAPI.@] 4397c2c66affSColin Finck */ 439865d3bf74SEric Kohl CONFIGRET 439965d3bf74SEric Kohl WINAPI 440065d3bf74SEric Kohl CM_Get_Global_State( 440165d3bf74SEric Kohl _Out_ PULONG pulState, 440265d3bf74SEric Kohl _In_ ULONG ulFlags) 4403c2c66affSColin Finck { 440465d3bf74SEric Kohl TRACE("CM_Get_Global_State(%p %lx)\n", 440565d3bf74SEric Kohl pulState, ulFlags); 440665d3bf74SEric Kohl 4407c2c66affSColin Finck return CM_Get_Global_State_Ex(pulState, ulFlags, NULL); 4408c2c66affSColin Finck } 4409c2c66affSColin Finck 4410c2c66affSColin Finck 4411c2c66affSColin Finck /*********************************************************************** 4412c2c66affSColin Finck * CM_Get_Global_State_Ex [SETUPAPI.@] 4413c2c66affSColin Finck */ 441465d3bf74SEric Kohl CONFIGRET 441565d3bf74SEric Kohl WINAPI 441665d3bf74SEric Kohl CM_Get_Global_State_Ex( 441765d3bf74SEric Kohl _Out_ PULONG pulState, 441865d3bf74SEric Kohl _In_ ULONG ulFlags, 441965d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 4420c2c66affSColin Finck { 4421c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 4422c2c66affSColin Finck CONFIGRET ret; 4423c2c66affSColin Finck 442460a21894SEric Kohl TRACE("CM_Get_Global_State_Ex(%p %lx %p)\n", 442565d3bf74SEric Kohl pulState, ulFlags, hMachine); 4426c2c66affSColin Finck 4427c2c66affSColin Finck if (pulState == NULL) 4428c2c66affSColin Finck return CR_INVALID_POINTER; 4429c2c66affSColin Finck 4430c2c66affSColin Finck if (ulFlags != 0) 4431c2c66affSColin Finck return CR_INVALID_FLAG; 4432c2c66affSColin Finck 4433c2c66affSColin Finck if (hMachine != NULL) 4434c2c66affSColin Finck { 4435c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 4436c2c66affSColin Finck if (BindingHandle == NULL) 4437c2c66affSColin Finck return CR_FAILURE; 4438c2c66affSColin Finck } 4439c2c66affSColin Finck else 4440c2c66affSColin Finck { 4441c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 4442c2c66affSColin Finck return CR_FAILURE; 4443c2c66affSColin Finck } 4444c2c66affSColin Finck 4445c2c66affSColin Finck RpcTryExcept 4446c2c66affSColin Finck { 4447c2c66affSColin Finck ret = PNP_GetGlobalState(BindingHandle, pulState, ulFlags); 4448c2c66affSColin Finck } 4449c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 4450c2c66affSColin Finck { 4451c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 4452c2c66affSColin Finck } 4453c2c66affSColin Finck RpcEndExcept; 4454c2c66affSColin Finck 4455c2c66affSColin Finck return ret; 4456c2c66affSColin Finck } 4457c2c66affSColin Finck 4458c2c66affSColin Finck 4459c2c66affSColin Finck /*********************************************************************** 4460c2c66affSColin Finck * CM_Get_HW_Prof_FlagsA [SETUPAPI.@] 4461c2c66affSColin Finck */ 446265d3bf74SEric Kohl CONFIGRET 446365d3bf74SEric Kohl WINAPI 446465d3bf74SEric Kohl CM_Get_HW_Prof_FlagsA( 446565d3bf74SEric Kohl _In_ DEVINSTID_A szDevInstName, 446665d3bf74SEric Kohl _In_ ULONG ulHardwareProfile, 446765d3bf74SEric Kohl _Out_ PULONG pulValue, 446865d3bf74SEric Kohl _In_ ULONG ulFlags) 4469c2c66affSColin Finck { 447065d3bf74SEric Kohl TRACE("CM_Get_HW_Prof_FlagsA(%s %lu %p %lx)\n", 447165d3bf74SEric Kohl debugstr_a(szDevInstName), ulHardwareProfile, pulValue, ulFlags); 4472c2c66affSColin Finck 4473c2c66affSColin Finck return CM_Get_HW_Prof_Flags_ExA(szDevInstName, ulHardwareProfile, 4474c2c66affSColin Finck pulValue, ulFlags, NULL); 4475c2c66affSColin Finck } 4476c2c66affSColin Finck 4477c2c66affSColin Finck 4478c2c66affSColin Finck /*********************************************************************** 4479c2c66affSColin Finck * CM_Get_HW_Prof_FlagsW [SETUPAPI.@] 4480c2c66affSColin Finck */ 448165d3bf74SEric Kohl CONFIGRET 448265d3bf74SEric Kohl WINAPI 448365d3bf74SEric Kohl CM_Get_HW_Prof_FlagsW( 448465d3bf74SEric Kohl _In_ DEVINSTID_W szDevInstName, 448565d3bf74SEric Kohl _In_ ULONG ulHardwareProfile, 448665d3bf74SEric Kohl _Out_ PULONG pulValue, 448765d3bf74SEric Kohl _In_ ULONG ulFlags) 4488c2c66affSColin Finck { 448965d3bf74SEric Kohl TRACE("CM_Get_HW_Prof_FlagsW(%s %lu %p %lx)\n", 449065d3bf74SEric Kohl debugstr_w(szDevInstName), ulHardwareProfile, pulValue, ulFlags); 4491c2c66affSColin Finck 4492c2c66affSColin Finck return CM_Get_HW_Prof_Flags_ExW(szDevInstName, ulHardwareProfile, 4493c2c66affSColin Finck pulValue, ulFlags, NULL); 4494c2c66affSColin Finck } 4495c2c66affSColin Finck 4496c2c66affSColin Finck 4497c2c66affSColin Finck /*********************************************************************** 4498c2c66affSColin Finck * CM_Get_HW_Prof_Flags_ExA [SETUPAPI.@] 4499c2c66affSColin Finck */ 450065d3bf74SEric Kohl CONFIGRET 450165d3bf74SEric Kohl WINAPI 450265d3bf74SEric Kohl CM_Get_HW_Prof_Flags_ExA( 450365d3bf74SEric Kohl _In_ DEVINSTID_A szDevInstName, 450465d3bf74SEric Kohl _In_ ULONG ulHardwareProfile, 450565d3bf74SEric Kohl _Out_ PULONG pulValue, 450665d3bf74SEric Kohl _In_ ULONG ulFlags, 450765d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 4508c2c66affSColin Finck { 4509c2c66affSColin Finck DEVINSTID_W pszDevIdW = NULL; 4510c2c66affSColin Finck CONFIGRET ret = CR_SUCCESS; 4511c2c66affSColin Finck 451260a21894SEric Kohl TRACE("CM_Get_HW_Prof_Flags_ExA(%s %lu %p %lx %p)\n", 451365d3bf74SEric Kohl debugstr_a(szDevInstName), ulHardwareProfile, pulValue, ulFlags, hMachine); 4514c2c66affSColin Finck 4515c2c66affSColin Finck if (szDevInstName != NULL) 4516c2c66affSColin Finck { 4517c2c66affSColin Finck if (pSetupCaptureAndConvertAnsiArg(szDevInstName, &pszDevIdW)) 4518c2c66affSColin Finck return CR_INVALID_DEVICE_ID; 4519c2c66affSColin Finck } 4520c2c66affSColin Finck 4521c2c66affSColin Finck ret = CM_Get_HW_Prof_Flags_ExW(pszDevIdW, ulHardwareProfile, 4522c2c66affSColin Finck pulValue, ulFlags, hMachine); 4523c2c66affSColin Finck 4524c2c66affSColin Finck if (pszDevIdW != NULL) 4525c2c66affSColin Finck MyFree(pszDevIdW); 4526c2c66affSColin Finck 4527c2c66affSColin Finck return ret; 4528c2c66affSColin Finck } 4529c2c66affSColin Finck 4530c2c66affSColin Finck 4531c2c66affSColin Finck /*********************************************************************** 4532c2c66affSColin Finck * CM_Get_HW_Prof_Flags_ExW [SETUPAPI.@] 4533c2c66affSColin Finck */ 453465d3bf74SEric Kohl CONFIGRET 453565d3bf74SEric Kohl WINAPI 453665d3bf74SEric Kohl CM_Get_HW_Prof_Flags_ExW( 453765d3bf74SEric Kohl _In_ DEVINSTID_W szDevInstName, 453865d3bf74SEric Kohl _In_ ULONG ulHardwareProfile, 453965d3bf74SEric Kohl _Out_ PULONG pulValue, 454065d3bf74SEric Kohl _In_ ULONG ulFlags, 454165d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 4542c2c66affSColin Finck { 4543c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 4544c2c66affSColin Finck CONFIGRET ret; 4545c2c66affSColin Finck 454660a21894SEric Kohl FIXME("CM_Get_HW_Prof_Flags_ExW(%s %lu %p %lx %p)\n", 454765d3bf74SEric Kohl debugstr_w(szDevInstName), ulHardwareProfile, pulValue, ulFlags, hMachine); 4548c2c66affSColin Finck 4549c2c66affSColin Finck if ((szDevInstName == NULL) || (pulValue == NULL)) 4550c2c66affSColin Finck return CR_INVALID_POINTER; 4551c2c66affSColin Finck 4552c2c66affSColin Finck if (ulFlags != 0) 4553c2c66affSColin Finck return CR_INVALID_FLAG; 4554c2c66affSColin Finck 4555c2c66affSColin Finck /* FIXME: Check whether szDevInstName is valid */ 4556c2c66affSColin Finck 4557c2c66affSColin Finck if (hMachine != NULL) 4558c2c66affSColin Finck { 4559c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 4560c2c66affSColin Finck if (BindingHandle == NULL) 4561c2c66affSColin Finck return CR_FAILURE; 4562c2c66affSColin Finck } 4563c2c66affSColin Finck else 4564c2c66affSColin Finck { 4565c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 4566c2c66affSColin Finck return CR_FAILURE; 4567c2c66affSColin Finck } 4568c2c66affSColin Finck 4569c2c66affSColin Finck RpcTryExcept 4570c2c66affSColin Finck { 4571c2c66affSColin Finck ret = PNP_HwProfFlags(BindingHandle, PNP_GET_HWPROFFLAGS, szDevInstName, 4572c2c66affSColin Finck ulHardwareProfile, pulValue, NULL, NULL, 0, 0); 4573c2c66affSColin Finck } 4574c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 4575c2c66affSColin Finck { 4576c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 4577c2c66affSColin Finck } 4578c2c66affSColin Finck RpcEndExcept; 4579c2c66affSColin Finck 4580c2c66affSColin Finck return ret; 4581c2c66affSColin Finck } 4582c2c66affSColin Finck 4583c2c66affSColin Finck 4584c2c66affSColin Finck /*********************************************************************** 4585c2c66affSColin Finck * CM_Get_Hardware_Profile_InfoA [SETUPAPI.@] 4586c2c66affSColin Finck */ 458760a21894SEric Kohl CONFIGRET 458860a21894SEric Kohl WINAPI 458960a21894SEric Kohl CM_Get_Hardware_Profile_InfoA( 459060a21894SEric Kohl _In_ ULONG ulIndex, 459160a21894SEric Kohl _Out_ PHWPROFILEINFO_A pHWProfileInfo, 459260a21894SEric Kohl _In_ ULONG ulFlags) 4593c2c66affSColin Finck { 459460a21894SEric Kohl TRACE("CM_Get_Hardware_Profile_InfoA(%lu %p %lx)\n", 459560a21894SEric Kohl ulIndex, pHWProfileInfo, ulFlags); 4596c2c66affSColin Finck 4597c2c66affSColin Finck return CM_Get_Hardware_Profile_Info_ExA(ulIndex, pHWProfileInfo, 4598c2c66affSColin Finck ulFlags, NULL); 4599c2c66affSColin Finck } 4600c2c66affSColin Finck 4601c2c66affSColin Finck 4602c2c66affSColin Finck /*********************************************************************** 4603c2c66affSColin Finck * CM_Get_Hardware_Profile_InfoW [SETUPAPI.@] 4604c2c66affSColin Finck */ 460560a21894SEric Kohl CONFIGRET 460660a21894SEric Kohl WINAPI 460760a21894SEric Kohl CM_Get_Hardware_Profile_InfoW( 460860a21894SEric Kohl _In_ ULONG ulIndex, 460960a21894SEric Kohl _Out_ PHWPROFILEINFO_W pHWProfileInfo, 461060a21894SEric Kohl _In_ ULONG ulFlags) 4611c2c66affSColin Finck { 461260a21894SEric Kohl TRACE("CM_Get_Hardware_Profile_InfoW(%lu %p %lx)\n", 461360a21894SEric Kohl ulIndex, pHWProfileInfo, ulFlags); 4614c2c66affSColin Finck 4615c2c66affSColin Finck return CM_Get_Hardware_Profile_Info_ExW(ulIndex, pHWProfileInfo, 4616c2c66affSColin Finck ulFlags, NULL); 4617c2c66affSColin Finck } 4618c2c66affSColin Finck 4619c2c66affSColin Finck 4620c2c66affSColin Finck /*********************************************************************** 4621c2c66affSColin Finck * CM_Get_Hardware_Profile_Info_ExA [SETUPAPI.@] 4622c2c66affSColin Finck */ 462360a21894SEric Kohl CONFIGRET 462460a21894SEric Kohl WINAPI 462560a21894SEric Kohl CM_Get_Hardware_Profile_Info_ExA( 462660a21894SEric Kohl _In_ ULONG ulIndex, 462760a21894SEric Kohl _Out_ PHWPROFILEINFO_A pHWProfileInfo, 462860a21894SEric Kohl _In_ ULONG ulFlags, 462960a21894SEric Kohl _In_opt_ HMACHINE hMachine) 4630c2c66affSColin Finck { 4631c2c66affSColin Finck HWPROFILEINFO_W LocalProfileInfo; 4632c2c66affSColin Finck CONFIGRET ret; 4633c2c66affSColin Finck 463460a21894SEric Kohl TRACE("CM_Get_Hardware_Profile_Info_ExA(%lu %p %lx %p)\n", 463560a21894SEric Kohl ulIndex, pHWProfileInfo, ulFlags, hMachine); 4636c2c66affSColin Finck 4637c2c66affSColin Finck if (pHWProfileInfo == NULL) 4638c2c66affSColin Finck return CR_INVALID_POINTER; 4639c2c66affSColin Finck 4640c2c66affSColin Finck ret = CM_Get_Hardware_Profile_Info_ExW(ulIndex, &LocalProfileInfo, 4641c2c66affSColin Finck ulFlags, hMachine); 4642c2c66affSColin Finck if (ret == CR_SUCCESS) 4643c2c66affSColin Finck { 4644c2c66affSColin Finck pHWProfileInfo->HWPI_ulHWProfile = LocalProfileInfo.HWPI_ulHWProfile; 4645c2c66affSColin Finck pHWProfileInfo->HWPI_dwFlags = LocalProfileInfo.HWPI_dwFlags; 4646c2c66affSColin Finck 4647c2c66affSColin Finck if (WideCharToMultiByte(CP_ACP, 4648c2c66affSColin Finck 0, 4649c2c66affSColin Finck LocalProfileInfo.HWPI_szFriendlyName, 4650c2c66affSColin Finck lstrlenW(LocalProfileInfo.HWPI_szFriendlyName) + 1, 4651c2c66affSColin Finck pHWProfileInfo->HWPI_szFriendlyName, 4652c2c66affSColin Finck MAX_PROFILE_LEN, 4653c2c66affSColin Finck NULL, 4654c2c66affSColin Finck NULL) == 0) 4655c2c66affSColin Finck ret = CR_FAILURE; 4656c2c66affSColin Finck } 4657c2c66affSColin Finck 4658c2c66affSColin Finck return ret; 4659c2c66affSColin Finck } 4660c2c66affSColin Finck 4661c2c66affSColin Finck 4662c2c66affSColin Finck /*********************************************************************** 4663c2c66affSColin Finck * CM_Get_Hardware_Profile_Info_ExW [SETUPAPI.@] 4664c2c66affSColin Finck */ 466560a21894SEric Kohl CONFIGRET 466660a21894SEric Kohl WINAPI 466760a21894SEric Kohl CM_Get_Hardware_Profile_Info_ExW( 466860a21894SEric Kohl _In_ ULONG ulIndex, 466960a21894SEric Kohl _Out_ PHWPROFILEINFO_W pHWProfileInfo, 467060a21894SEric Kohl _In_ ULONG ulFlags, 467160a21894SEric Kohl _In_opt_ HMACHINE hMachine) 4672c2c66affSColin Finck { 4673c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 4674c2c66affSColin Finck CONFIGRET ret; 4675c2c66affSColin Finck 467660a21894SEric Kohl TRACE("CM_Get_Hardware_Profile_Info_ExW(%lu %p %lx %p)\n", 467760a21894SEric Kohl ulIndex, pHWProfileInfo, ulFlags, hMachine); 4678c2c66affSColin Finck 4679c2c66affSColin Finck if (pHWProfileInfo == NULL) 4680c2c66affSColin Finck return CR_INVALID_POINTER; 4681c2c66affSColin Finck 4682c2c66affSColin Finck if (ulFlags != 0) 4683c2c66affSColin Finck return CR_INVALID_FLAG; 4684c2c66affSColin Finck 4685c2c66affSColin Finck if (hMachine != NULL) 4686c2c66affSColin Finck { 4687c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 4688c2c66affSColin Finck if (BindingHandle == NULL) 4689c2c66affSColin Finck return CR_FAILURE; 4690c2c66affSColin Finck } 4691c2c66affSColin Finck else 4692c2c66affSColin Finck { 4693c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 4694c2c66affSColin Finck return CR_FAILURE; 4695c2c66affSColin Finck } 4696c2c66affSColin Finck 4697c2c66affSColin Finck RpcTryExcept 4698c2c66affSColin Finck { 4699c2c66affSColin Finck ret = PNP_GetHwProfInfo(BindingHandle, ulIndex, pHWProfileInfo, 4700c2c66affSColin Finck sizeof(HWPROFILEINFO_W), 0); 4701c2c66affSColin Finck } 4702c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 4703c2c66affSColin Finck { 4704c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 4705c2c66affSColin Finck } 4706c2c66affSColin Finck RpcEndExcept; 4707c2c66affSColin Finck 4708c2c66affSColin Finck return ret; 4709c2c66affSColin Finck } 4710c2c66affSColin Finck 4711c2c66affSColin Finck 4712c2c66affSColin Finck /*********************************************************************** 4713c2c66affSColin Finck * CM_Get_Log_Conf_Priority [SETUPAPI.@] 4714c2c66affSColin Finck */ 471560a21894SEric Kohl CONFIGRET 471660a21894SEric Kohl WINAPI 471760a21894SEric Kohl CM_Get_Log_Conf_Priority( 471860a21894SEric Kohl _In_ LOG_CONF lcLogConf, 471960a21894SEric Kohl _Out_ PPRIORITY pPriority, 472060a21894SEric Kohl _In_ ULONG ulFlags) 4721c2c66affSColin Finck { 472260a21894SEric Kohl TRACE("CM_Get_Log_Conf_Priority(%p %p %lx)\n", 472360a21894SEric Kohl lcLogConf, pPriority, ulFlags); 472460a21894SEric Kohl 4725c2c66affSColin Finck return CM_Get_Log_Conf_Priority_Ex(lcLogConf, pPriority, ulFlags, NULL); 4726c2c66affSColin Finck } 4727c2c66affSColin Finck 4728c2c66affSColin Finck 4729c2c66affSColin Finck /*********************************************************************** 4730c2c66affSColin Finck * CM_Get_Log_Conf_Priority_Ex [SETUPAPI.@] 4731c2c66affSColin Finck */ 473260a21894SEric Kohl CONFIGRET 473360a21894SEric Kohl WINAPI 473460a21894SEric Kohl CM_Get_Log_Conf_Priority_Ex( 473560a21894SEric Kohl _In_ LOG_CONF lcLogConf, 473660a21894SEric Kohl _Out_ PPRIORITY pPriority, 473760a21894SEric Kohl _In_ ULONG ulFlags, 473860a21894SEric Kohl _In_opt_ HMACHINE hMachine) 4739c2c66affSColin Finck { 4740c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 4741c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 4742c2c66affSColin Finck PLOG_CONF_INFO pLogConfInfo; 4743c2c66affSColin Finck LPWSTR lpDevInst; 4744c2c66affSColin Finck CONFIGRET ret; 4745c2c66affSColin Finck 474660a21894SEric Kohl FIXME("CM_Get_Log_Conf_Priority_Ex(%p %p %lx %p)\n", 474760a21894SEric Kohl lcLogConf, pPriority, ulFlags, hMachine); 4748c2c66affSColin Finck 4749c2c66affSColin Finck pLogConfInfo = (PLOG_CONF_INFO)lcLogConf; 475019fc20f2SEric Kohl if (!IsValidLogConf(pLogConfInfo)) 4751c2c66affSColin Finck return CR_INVALID_LOG_CONF; 4752c2c66affSColin Finck 4753c2c66affSColin Finck if (pPriority == NULL) 4754c2c66affSColin Finck return CR_INVALID_POINTER; 4755c2c66affSColin Finck 4756c2c66affSColin Finck if (ulFlags != 0) 4757c2c66affSColin Finck return CR_INVALID_FLAG; 4758c2c66affSColin Finck 4759c2c66affSColin Finck if (hMachine != NULL) 4760c2c66affSColin Finck { 4761c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 4762c2c66affSColin Finck if (BindingHandle == NULL) 4763c2c66affSColin Finck return CR_FAILURE; 4764c2c66affSColin Finck 4765c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 4766c2c66affSColin Finck if (StringTable == 0) 4767c2c66affSColin Finck return CR_FAILURE; 4768c2c66affSColin Finck } 4769c2c66affSColin Finck else 4770c2c66affSColin Finck { 4771c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 4772c2c66affSColin Finck return CR_FAILURE; 4773c2c66affSColin Finck } 4774c2c66affSColin Finck 4775c2c66affSColin Finck lpDevInst = pSetupStringTableStringFromId(StringTable, pLogConfInfo->dnDevInst); 4776c2c66affSColin Finck if (lpDevInst == NULL) 4777c2c66affSColin Finck return CR_INVALID_DEVNODE; 4778c2c66affSColin Finck 4779c2c66affSColin Finck RpcTryExcept 4780c2c66affSColin Finck { 4781c2c66affSColin Finck ret = PNP_GetLogConfPriority(BindingHandle, 4782c2c66affSColin Finck lpDevInst, 4783c2c66affSColin Finck pLogConfInfo->ulFlags, 4784c2c66affSColin Finck pLogConfInfo->ulTag, 4785c2c66affSColin Finck pPriority, 4786c2c66affSColin Finck 0); 4787c2c66affSColin Finck } 4788c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 4789c2c66affSColin Finck { 4790c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 4791c2c66affSColin Finck } 4792c2c66affSColin Finck RpcEndExcept; 4793c2c66affSColin Finck 4794c2c66affSColin Finck return ret; 4795c2c66affSColin Finck } 4796c2c66affSColin Finck 4797c2c66affSColin Finck 4798c2c66affSColin Finck /*********************************************************************** 4799c2c66affSColin Finck * CM_Get_Next_Log_Conf [SETUPAPI.@] 4800c2c66affSColin Finck */ 480160a21894SEric Kohl CONFIGRET 480260a21894SEric Kohl WINAPI 480360a21894SEric Kohl CM_Get_Next_Log_Conf( 480460a21894SEric Kohl _Out_opt_ PLOG_CONF plcLogConf, 480560a21894SEric Kohl _In_ LOG_CONF lcLogConf, 480660a21894SEric Kohl _In_ ULONG ulFlags) 4807c2c66affSColin Finck { 480860a21894SEric Kohl TRACE("CM_Get_Next_Log_Conf(%p %p %lx)\n", 480960a21894SEric Kohl plcLogConf, lcLogConf, ulFlags); 481060a21894SEric Kohl 4811c2c66affSColin Finck return CM_Get_Next_Log_Conf_Ex(plcLogConf, lcLogConf, ulFlags, NULL); 4812c2c66affSColin Finck } 4813c2c66affSColin Finck 4814c2c66affSColin Finck 4815c2c66affSColin Finck /*********************************************************************** 4816c2c66affSColin Finck * CM_Get_Next_Log_Conf_Ex [SETUPAPI.@] 4817c2c66affSColin Finck */ 481860a21894SEric Kohl CONFIGRET 481960a21894SEric Kohl WINAPI 482060a21894SEric Kohl CM_Get_Next_Log_Conf_Ex( 482160a21894SEric Kohl _Out_opt_ PLOG_CONF plcLogConf, 482260a21894SEric Kohl _In_ LOG_CONF lcLogConf, 482360a21894SEric Kohl _In_ ULONG ulFlags, 482460a21894SEric Kohl _In_opt_ HMACHINE hMachine) 4825c2c66affSColin Finck { 4826c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 4827c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 4828c2c66affSColin Finck PLOG_CONF_INFO pLogConfInfo; 4829c2c66affSColin Finck PLOG_CONF_INFO pNewLogConfInfo; 4830c2c66affSColin Finck ULONG ulNewTag; 4831c2c66affSColin Finck LPWSTR lpDevInst; 4832c2c66affSColin Finck CONFIGRET ret; 4833c2c66affSColin Finck 483460a21894SEric Kohl FIXME("CM_Get_Next_Log_Conf_Ex(%p %p %lx %p)\n", 483560a21894SEric Kohl plcLogConf, lcLogConf, ulFlags, hMachine); 4836c2c66affSColin Finck 4837c2c66affSColin Finck if (plcLogConf) 4838c2c66affSColin Finck *plcLogConf = 0; 4839c2c66affSColin Finck 4840c2c66affSColin Finck pLogConfInfo = (PLOG_CONF_INFO)lcLogConf; 484119fc20f2SEric Kohl if (!IsValidLogConf(pLogConfInfo)) 4842c2c66affSColin Finck return CR_INVALID_LOG_CONF; 4843c2c66affSColin Finck 4844c2c66affSColin Finck if (ulFlags != 0) 4845c2c66affSColin Finck return CR_INVALID_FLAG; 4846c2c66affSColin Finck 4847c2c66affSColin Finck if (hMachine != NULL) 4848c2c66affSColin Finck { 4849c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 4850c2c66affSColin Finck if (BindingHandle == NULL) 4851c2c66affSColin Finck return CR_FAILURE; 4852c2c66affSColin Finck 4853c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 4854c2c66affSColin Finck if (StringTable == 0) 4855c2c66affSColin Finck return CR_FAILURE; 4856c2c66affSColin Finck } 4857c2c66affSColin Finck else 4858c2c66affSColin Finck { 4859c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 4860c2c66affSColin Finck return CR_FAILURE; 4861c2c66affSColin Finck } 4862c2c66affSColin Finck 4863c2c66affSColin Finck lpDevInst = pSetupStringTableStringFromId(StringTable, pLogConfInfo->dnDevInst); 4864c2c66affSColin Finck if (lpDevInst == NULL) 4865c2c66affSColin Finck return CR_INVALID_DEVNODE; 4866c2c66affSColin Finck 4867c2c66affSColin Finck RpcTryExcept 4868c2c66affSColin Finck { 4869c2c66affSColin Finck ret = PNP_GetNextLogConf(BindingHandle, 4870c2c66affSColin Finck lpDevInst, 4871c2c66affSColin Finck pLogConfInfo->ulFlags, 4872c2c66affSColin Finck pLogConfInfo->ulTag, 4873c2c66affSColin Finck &ulNewTag, 4874c2c66affSColin Finck 0); 4875c2c66affSColin Finck } 4876c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 4877c2c66affSColin Finck { 4878c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 4879c2c66affSColin Finck } 4880c2c66affSColin Finck RpcEndExcept; 4881c2c66affSColin Finck 4882c2c66affSColin Finck if (ret != CR_SUCCESS) 4883c2c66affSColin Finck return ret; 4884c2c66affSColin Finck 4885c2c66affSColin Finck if (plcLogConf) 4886c2c66affSColin Finck { 4887c2c66affSColin Finck pNewLogConfInfo = HeapAlloc(GetProcessHeap(), 0, sizeof(LOG_CONF_INFO)); 4888c2c66affSColin Finck if (pNewLogConfInfo == NULL) 4889c2c66affSColin Finck return CR_OUT_OF_MEMORY; 4890c2c66affSColin Finck 4891c2c66affSColin Finck pNewLogConfInfo->ulMagic = LOG_CONF_MAGIC; 4892c2c66affSColin Finck pNewLogConfInfo->dnDevInst = pLogConfInfo->dnDevInst; 4893c2c66affSColin Finck pNewLogConfInfo->ulFlags = pLogConfInfo->ulFlags; 4894c2c66affSColin Finck pNewLogConfInfo->ulTag = ulNewTag; 4895c2c66affSColin Finck 4896c2c66affSColin Finck *plcLogConf = (LOG_CONF)pNewLogConfInfo; 4897c2c66affSColin Finck } 4898c2c66affSColin Finck 4899c2c66affSColin Finck return CR_SUCCESS; 4900c2c66affSColin Finck } 4901c2c66affSColin Finck 4902c2c66affSColin Finck 4903c2c66affSColin Finck /*********************************************************************** 4904c2c66affSColin Finck * CM_Get_Next_Re_Des [SETUPAPI.@] 4905c2c66affSColin Finck */ 490660a21894SEric Kohl CONFIGRET 490760a21894SEric Kohl WINAPI 490860a21894SEric Kohl CM_Get_Next_Res_Des( 490960a21894SEric Kohl _Out_ PRES_DES prdResDes, 491060a21894SEric Kohl _In_ RES_DES rdResDes, 491160a21894SEric Kohl _In_ RESOURCEID ForResource, 491260a21894SEric Kohl _Out_opt_ PRESOURCEID pResourceID, 491360a21894SEric Kohl _In_ ULONG ulFlags) 4914c2c66affSColin Finck { 491560a21894SEric Kohl TRACE("CM_Get_Next_Res_Des(%p %p %lu %p %lx)\n", 491660a21894SEric Kohl prdResDes, rdResDes, ForResource, pResourceID, ulFlags); 491760a21894SEric Kohl 4918c2c66affSColin Finck return CM_Get_Next_Res_Des_Ex(prdResDes, rdResDes, ForResource, 4919c2c66affSColin Finck pResourceID, ulFlags, NULL); 4920c2c66affSColin Finck } 4921c2c66affSColin Finck 4922c2c66affSColin Finck 4923c2c66affSColin Finck /*********************************************************************** 4924c2c66affSColin Finck * CM_Get_Next_Re_Des_Ex [SETUPAPI.@] 4925c2c66affSColin Finck */ 492660a21894SEric Kohl CONFIGRET 492760a21894SEric Kohl WINAPI 492860a21894SEric Kohl CM_Get_Next_Res_Des_Ex( 492960a21894SEric Kohl _Out_ PRES_DES prdResDes, 493060a21894SEric Kohl _In_ RES_DES rdResDes, 493160a21894SEric Kohl _In_ RESOURCEID ForResource, 493260a21894SEric Kohl _Out_opt_ PRESOURCEID pResourceID, 493360a21894SEric Kohl _In_ ULONG ulFlags, 493460a21894SEric Kohl _In_opt_ HMACHINE hMachine) 4935c2c66affSColin Finck { 493660a21894SEric Kohl FIXME("CM_Get_Next_Res_Des_Ex(%p %p %lu %p %lx %p)\n", 493760a21894SEric Kohl prdResDes, rdResDes, ForResource, pResourceID, ulFlags, hMachine); 4938c2c66affSColin Finck 4939c2c66affSColin Finck return CR_CALL_NOT_IMPLEMENTED; 4940c2c66affSColin Finck } 4941c2c66affSColin Finck 4942c2c66affSColin Finck 4943c2c66affSColin Finck /*********************************************************************** 4944c2c66affSColin Finck * CM_Get_Parent [SETUPAPI.@] 4945c2c66affSColin Finck */ 494660a21894SEric Kohl CONFIGRET 494760a21894SEric Kohl WINAPI 494860a21894SEric Kohl CM_Get_Parent( 494960a21894SEric Kohl _Out_ PDEVINST pdnDevInst, 495060a21894SEric Kohl _In_ DEVINST dnDevInst, 495160a21894SEric Kohl _In_ ULONG ulFlags) 4952c2c66affSColin Finck { 495360a21894SEric Kohl TRACE("CM_Get_Parent(%p %p %lx)\n", 495460a21894SEric Kohl pdnDevInst, dnDevInst, ulFlags); 495560a21894SEric Kohl 4956c2c66affSColin Finck return CM_Get_Parent_Ex(pdnDevInst, dnDevInst, ulFlags, NULL); 4957c2c66affSColin Finck } 4958c2c66affSColin Finck 4959c2c66affSColin Finck 4960c2c66affSColin Finck /*********************************************************************** 4961c2c66affSColin Finck * CM_Get_Parent_Ex [SETUPAPI.@] 4962c2c66affSColin Finck */ 496360a21894SEric Kohl CONFIGRET 496460a21894SEric Kohl WINAPI 496560a21894SEric Kohl CM_Get_Parent_Ex( 496660a21894SEric Kohl _Out_ PDEVINST pdnDevInst, 496760a21894SEric Kohl _In_ DEVINST dnDevInst, 496860a21894SEric Kohl _In_ ULONG ulFlags, 496960a21894SEric Kohl _In_opt_ HMACHINE hMachine) 4970c2c66affSColin Finck { 4971c2c66affSColin Finck WCHAR szRelatedDevInst[MAX_DEVICE_ID_LEN]; 4972c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 4973c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 4974c2c66affSColin Finck LPWSTR lpDevInst; 4975c2c66affSColin Finck DWORD dwIndex, dwLength = MAX_DEVICE_ID_LEN; 4976c2c66affSColin Finck CONFIGRET ret; 4977c2c66affSColin Finck 497860a21894SEric Kohl TRACE("CM_Get_Parent_Ex(%p %lx %lx %p)\n", 497960a21894SEric Kohl pdnDevInst, dnDevInst, ulFlags, hMachine); 4980c2c66affSColin Finck 4981c2c66affSColin Finck if (pdnDevInst == NULL) 4982c2c66affSColin Finck return CR_INVALID_POINTER; 4983c2c66affSColin Finck 4984c2c66affSColin Finck if (dnDevInst == 0) 4985c2c66affSColin Finck return CR_INVALID_DEVINST; 4986c2c66affSColin Finck 4987c2c66affSColin Finck if (ulFlags != 0) 4988c2c66affSColin Finck return CR_INVALID_FLAG; 4989c2c66affSColin Finck 4990c2c66affSColin Finck *pdnDevInst = -1; 4991c2c66affSColin Finck 4992c2c66affSColin Finck if (hMachine != NULL) 4993c2c66affSColin Finck { 4994c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 4995c2c66affSColin Finck if (BindingHandle == NULL) 4996c2c66affSColin Finck return CR_FAILURE; 4997c2c66affSColin Finck 4998c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 4999c2c66affSColin Finck if (StringTable == 0) 5000c2c66affSColin Finck return CR_FAILURE; 5001c2c66affSColin Finck } 5002c2c66affSColin Finck else 5003c2c66affSColin Finck { 5004c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 5005c2c66affSColin Finck return CR_FAILURE; 5006c2c66affSColin Finck } 5007c2c66affSColin Finck 5008c2c66affSColin Finck lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst); 5009c2c66affSColin Finck if (lpDevInst == NULL) 5010c2c66affSColin Finck return CR_INVALID_DEVNODE; 5011c2c66affSColin Finck 5012c2c66affSColin Finck RpcTryExcept 5013c2c66affSColin Finck { 5014c2c66affSColin Finck ret = PNP_GetRelatedDeviceInstance(BindingHandle, 5015c2c66affSColin Finck PNP_GET_PARENT_DEVICE_INSTANCE, 5016c2c66affSColin Finck lpDevInst, 5017c2c66affSColin Finck szRelatedDevInst, 5018c2c66affSColin Finck &dwLength, 5019c2c66affSColin Finck 0); 5020c2c66affSColin Finck } 5021c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 5022c2c66affSColin Finck { 5023c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 5024c2c66affSColin Finck } 5025c2c66affSColin Finck RpcEndExcept; 5026c2c66affSColin Finck 5027c2c66affSColin Finck if (ret != CR_SUCCESS) 5028c2c66affSColin Finck return ret; 5029c2c66affSColin Finck 5030c2c66affSColin Finck TRACE("szRelatedDevInst: %s\n", debugstr_w(szRelatedDevInst)); 5031c2c66affSColin Finck 5032c2c66affSColin Finck dwIndex = pSetupStringTableAddString(StringTable, szRelatedDevInst, 1); 5033c2c66affSColin Finck if (dwIndex == -1) 5034c2c66affSColin Finck return CR_FAILURE; 5035c2c66affSColin Finck 5036c2c66affSColin Finck *pdnDevInst = dwIndex; 5037c2c66affSColin Finck 5038c2c66affSColin Finck return CR_SUCCESS; 5039c2c66affSColin Finck } 5040c2c66affSColin Finck 5041c2c66affSColin Finck 5042c2c66affSColin Finck /*********************************************************************** 5043c2c66affSColin Finck * CM_Get_Res_Des_Data [SETUPAPI.@] 5044c2c66affSColin Finck */ 504560a21894SEric Kohl CONFIGRET 504660a21894SEric Kohl WINAPI 504760a21894SEric Kohl CM_Get_Res_Des_Data( 504860a21894SEric Kohl _In_ RES_DES rdResDes, 504960a21894SEric Kohl _Out_writes_bytes_(BufferLen) PVOID Buffer, 505060a21894SEric Kohl _In_ ULONG BufferLen, 505160a21894SEric Kohl _In_ ULONG ulFlags) 5052c2c66affSColin Finck { 505360a21894SEric Kohl TRACE("CM_Get_Res_Des_Data(%p %p %lu %lx)\n", 505460a21894SEric Kohl rdResDes, Buffer, BufferLen, ulFlags); 505560a21894SEric Kohl 5056c2c66affSColin Finck return CM_Get_Res_Des_Data_Ex(rdResDes, Buffer, BufferLen, ulFlags, NULL); 5057c2c66affSColin Finck } 5058c2c66affSColin Finck 5059c2c66affSColin Finck 5060c2c66affSColin Finck /*********************************************************************** 5061c2c66affSColin Finck * CM_Get_Res_Des_Data_Ex [SETUPAPI.@] 5062c2c66affSColin Finck */ 506360a21894SEric Kohl CONFIGRET 506460a21894SEric Kohl WINAPI 506560a21894SEric Kohl CM_Get_Res_Des_Data_Ex( 506660a21894SEric Kohl _In_ RES_DES rdResDes, 506760a21894SEric Kohl _Out_writes_bytes_(BufferLen) PVOID Buffer, 506860a21894SEric Kohl _In_ ULONG BufferLen, 506960a21894SEric Kohl _In_ ULONG ulFlags, 507060a21894SEric Kohl _In_opt_ HMACHINE hMachine) 5071c2c66affSColin Finck { 507260a21894SEric Kohl FIXME("CM_Get_Res_Des_Data_Ex(%p %p %lu %lx %p)\n", 507360a21894SEric Kohl rdResDes, Buffer, BufferLen, ulFlags, hMachine); 507460a21894SEric Kohl 5075c2c66affSColin Finck return CR_CALL_NOT_IMPLEMENTED; 5076c2c66affSColin Finck } 5077c2c66affSColin Finck 5078c2c66affSColin Finck 5079c2c66affSColin Finck /*********************************************************************** 5080c2c66affSColin Finck * CM_Get_Res_Des_Size [SETUPAPI.@] 5081c2c66affSColin Finck */ 508260a21894SEric Kohl CONFIGRET 508360a21894SEric Kohl WINAPI 508460a21894SEric Kohl CM_Get_Res_Des_Data_Size( 508560a21894SEric Kohl _Out_ PULONG pulSize, 508660a21894SEric Kohl _In_ RES_DES rdResDes, 508760a21894SEric Kohl _In_ ULONG ulFlags) 5088c2c66affSColin Finck { 508960a21894SEric Kohl TRACE("CM_Get_Res_Des_Data_Size(%p %p %lx)\n", 509060a21894SEric Kohl pulSize, rdResDes, ulFlags); 509160a21894SEric Kohl 5092c2c66affSColin Finck return CM_Get_Res_Des_Data_Size_Ex(pulSize, rdResDes, ulFlags, NULL); 5093c2c66affSColin Finck } 5094c2c66affSColin Finck 5095c2c66affSColin Finck 5096c2c66affSColin Finck /*********************************************************************** 5097c2c66affSColin Finck * CM_Get_Res_Des_Size_Ex [SETUPAPI.@] 5098c2c66affSColin Finck */ 509960a21894SEric Kohl CONFIGRET 510060a21894SEric Kohl WINAPI 510160a21894SEric Kohl CM_Get_Res_Des_Data_Size_Ex( 510260a21894SEric Kohl _Out_ PULONG pulSize, 510360a21894SEric Kohl _In_ RES_DES rdResDes, 510460a21894SEric Kohl _In_ ULONG ulFlags, 510560a21894SEric Kohl _In_opt_ HMACHINE hMachine) 5106c2c66affSColin Finck { 510760a21894SEric Kohl TRACE("CM_Get_Res_Des_Data_Size_Ex(%p %p %lx %p)\n", 510860a21894SEric Kohl pulSize, rdResDes, ulFlags, hMachine); 510960a21894SEric Kohl 5110c2c66affSColin Finck return CR_CALL_NOT_IMPLEMENTED; 5111c2c66affSColin Finck } 5112c2c66affSColin Finck 5113c2c66affSColin Finck 5114c2c66affSColin Finck /*********************************************************************** 5115c2c66affSColin Finck * CM_Get_Sibling [SETUPAPI.@] 5116c2c66affSColin Finck */ 511760a21894SEric Kohl CONFIGRET 511860a21894SEric Kohl WINAPI 511960a21894SEric Kohl CM_Get_Sibling( 512060a21894SEric Kohl _Out_ PDEVINST pdnDevInst, 512160a21894SEric Kohl _In_ DEVINST dnDevInst, 512260a21894SEric Kohl _In_ ULONG ulFlags) 5123c2c66affSColin Finck { 512460a21894SEric Kohl TRACE("CM_Get_Sibling(%p %p %lx)\n", 512560a21894SEric Kohl pdnDevInst, dnDevInst, ulFlags); 512660a21894SEric Kohl 5127c2c66affSColin Finck return CM_Get_Sibling_Ex(pdnDevInst, dnDevInst, ulFlags, NULL); 5128c2c66affSColin Finck } 5129c2c66affSColin Finck 5130c2c66affSColin Finck 5131c2c66affSColin Finck /*********************************************************************** 5132c2c66affSColin Finck * CM_Get_Sibling_Ex [SETUPAPI.@] 5133c2c66affSColin Finck */ 513460a21894SEric Kohl CONFIGRET 513560a21894SEric Kohl WINAPI 513660a21894SEric Kohl CM_Get_Sibling_Ex( 513760a21894SEric Kohl _Out_ PDEVINST pdnDevInst, 513860a21894SEric Kohl _In_ DEVINST dnDevInst, 513960a21894SEric Kohl _In_ ULONG ulFlags, 514060a21894SEric Kohl _In_opt_ HMACHINE hMachine) 5141c2c66affSColin Finck { 5142c2c66affSColin Finck WCHAR szRelatedDevInst[MAX_DEVICE_ID_LEN]; 5143c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 5144c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 5145c2c66affSColin Finck LPWSTR lpDevInst; 5146c2c66affSColin Finck DWORD dwIndex, dwLength = MAX_DEVICE_ID_LEN; 5147c2c66affSColin Finck CONFIGRET ret; 5148c2c66affSColin Finck 514960a21894SEric Kohl TRACE("CM_Get_Sibling_Ex(%p %lx %lx %p)\n", 515060a21894SEric Kohl pdnDevInst, dnDevInst, ulFlags, hMachine); 5151c2c66affSColin Finck 5152c2c66affSColin Finck if (pdnDevInst == NULL) 5153c2c66affSColin Finck return CR_INVALID_POINTER; 5154c2c66affSColin Finck 5155c2c66affSColin Finck if (dnDevInst == 0) 5156c2c66affSColin Finck return CR_INVALID_DEVINST; 5157c2c66affSColin Finck 5158c2c66affSColin Finck if (ulFlags != 0) 5159c2c66affSColin Finck return CR_INVALID_FLAG; 5160c2c66affSColin Finck 5161c2c66affSColin Finck *pdnDevInst = -1; 5162c2c66affSColin Finck 5163c2c66affSColin Finck if (hMachine != NULL) 5164c2c66affSColin Finck { 5165c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 5166c2c66affSColin Finck if (BindingHandle == NULL) 5167c2c66affSColin Finck return CR_FAILURE; 5168c2c66affSColin Finck 5169c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 5170c2c66affSColin Finck if (StringTable == 0) 5171c2c66affSColin Finck return CR_FAILURE; 5172c2c66affSColin Finck } 5173c2c66affSColin Finck else 5174c2c66affSColin Finck { 5175c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 5176c2c66affSColin Finck return CR_FAILURE; 5177c2c66affSColin Finck } 5178c2c66affSColin Finck 5179c2c66affSColin Finck lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst); 5180c2c66affSColin Finck if (lpDevInst == NULL) 5181c2c66affSColin Finck return CR_INVALID_DEVNODE; 5182c2c66affSColin Finck 5183c2c66affSColin Finck RpcTryExcept 5184c2c66affSColin Finck { 5185c2c66affSColin Finck ret = PNP_GetRelatedDeviceInstance(BindingHandle, 5186c2c66affSColin Finck PNP_GET_SIBLING_DEVICE_INSTANCE, 5187c2c66affSColin Finck lpDevInst, 5188c2c66affSColin Finck szRelatedDevInst, 5189c2c66affSColin Finck &dwLength, 5190c2c66affSColin Finck 0); 5191c2c66affSColin Finck } 5192c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 5193c2c66affSColin Finck { 5194c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 5195c2c66affSColin Finck } 5196c2c66affSColin Finck RpcEndExcept; 5197c2c66affSColin Finck 5198c2c66affSColin Finck if (ret != CR_SUCCESS) 5199c2c66affSColin Finck return ret; 5200c2c66affSColin Finck 5201c2c66affSColin Finck TRACE("szRelatedDevInst: %s\n", debugstr_w(szRelatedDevInst)); 5202c2c66affSColin Finck 5203c2c66affSColin Finck dwIndex = pSetupStringTableAddString(StringTable, szRelatedDevInst, 1); 5204c2c66affSColin Finck if (dwIndex == -1) 5205c2c66affSColin Finck return CR_FAILURE; 5206c2c66affSColin Finck 5207c2c66affSColin Finck *pdnDevInst = dwIndex; 5208c2c66affSColin Finck 5209c2c66affSColin Finck return CR_SUCCESS; 5210c2c66affSColin Finck } 5211c2c66affSColin Finck 5212c2c66affSColin Finck 5213c2c66affSColin Finck /*********************************************************************** 5214c2c66affSColin Finck * CM_Get_Version [SETUPAPI.@] 5215c2c66affSColin Finck */ 521660a21894SEric Kohl WORD 521760a21894SEric Kohl WINAPI 521860a21894SEric Kohl CM_Get_Version(VOID) 5219c2c66affSColin Finck { 522060a21894SEric Kohl TRACE("CM_Get_Version()\n"); 522160a21894SEric Kohl 5222c2c66affSColin Finck return CM_Get_Version_Ex(NULL); 5223c2c66affSColin Finck } 5224c2c66affSColin Finck 5225c2c66affSColin Finck 5226c2c66affSColin Finck /*********************************************************************** 5227c2c66affSColin Finck * CM_Get_Version_Ex [SETUPAPI.@] 5228c2c66affSColin Finck */ 522960a21894SEric Kohl WORD 523060a21894SEric Kohl WINAPI 523160a21894SEric Kohl CM_Get_Version_Ex( 523260a21894SEric Kohl _In_opt_ HMACHINE hMachine) 5233c2c66affSColin Finck { 5234c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 5235c2c66affSColin Finck WORD Version = 0; 5236c2c66affSColin Finck CONFIGRET ret; 5237c2c66affSColin Finck 523860a21894SEric Kohl TRACE("CM_Get_Version_Ex(%p)\n", hMachine); 5239c2c66affSColin Finck 5240c2c66affSColin Finck if (hMachine != NULL) 5241c2c66affSColin Finck { 5242c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 5243c2c66affSColin Finck if (BindingHandle == NULL) 5244c2c66affSColin Finck return 0; 5245c2c66affSColin Finck } 5246c2c66affSColin Finck else 5247c2c66affSColin Finck { 5248c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 5249c2c66affSColin Finck return CR_FAILURE; 5250c2c66affSColin Finck } 5251c2c66affSColin Finck 5252c2c66affSColin Finck RpcTryExcept 5253c2c66affSColin Finck { 5254c2c66affSColin Finck ret = PNP_GetVersion(BindingHandle, &Version); 5255c2c66affSColin Finck } 5256c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 5257c2c66affSColin Finck { 5258c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 5259c2c66affSColin Finck } 5260c2c66affSColin Finck RpcEndExcept; 5261c2c66affSColin Finck 5262c2c66affSColin Finck if (ret != CR_SUCCESS) 5263c2c66affSColin Finck return 0; 5264c2c66affSColin Finck 5265c2c66affSColin Finck return Version; 5266c2c66affSColin Finck } 5267c2c66affSColin Finck 5268c2c66affSColin Finck 5269c2c66affSColin Finck /*********************************************************************** 5270c2c66affSColin Finck * CM_Intersect_Range_List [SETUPAPI.@] 5271c2c66affSColin Finck */ 5272c2c66affSColin Finck CONFIGRET 5273c2c66affSColin Finck WINAPI 5274c2c66affSColin Finck CM_Intersect_Range_List( 5275c2c66affSColin Finck _In_ RANGE_LIST rlhOld1, 5276c2c66affSColin Finck _In_ RANGE_LIST rlhOld2, 5277c2c66affSColin Finck _In_ RANGE_LIST rlhNew, 5278c2c66affSColin Finck _In_ ULONG ulFlags) 5279c2c66affSColin Finck { 5280c2c66affSColin Finck FIXME("CM_Intersect_Range_List(%p %p %p %lx)\n", 5281c2c66affSColin Finck rlhOld1, rlhOld2, rlhNew, ulFlags); 528265d3bf74SEric Kohl 5283c2c66affSColin Finck return CR_CALL_NOT_IMPLEMENTED; 5284c2c66affSColin Finck } 5285c2c66affSColin Finck 5286c2c66affSColin Finck 5287c2c66affSColin Finck /*********************************************************************** 5288c2c66affSColin Finck * CM_Invert_Range_List [SETUPAPI.@] 5289c2c66affSColin Finck */ 5290c2c66affSColin Finck CONFIGRET 5291c2c66affSColin Finck WINAPI 5292c2c66affSColin Finck CM_Invert_Range_List( 5293c2c66affSColin Finck _In_ RANGE_LIST rlhOld, 5294c2c66affSColin Finck _In_ RANGE_LIST rlhNew, 5295c2c66affSColin Finck _In_ DWORDLONG ullMaxValue, 5296c2c66affSColin Finck _In_ ULONG ulFlags) 5297c2c66affSColin Finck { 5298c2c66affSColin Finck FIXME("CM_Invert_Range_List(%p %p %I64u %lx)\n", 5299c2c66affSColin Finck rlhOld, rlhNew, ullMaxValue, ulFlags); 530065d3bf74SEric Kohl 5301c2c66affSColin Finck return CR_CALL_NOT_IMPLEMENTED; 5302c2c66affSColin Finck } 5303c2c66affSColin Finck 5304c2c66affSColin Finck 5305c2c66affSColin Finck /*********************************************************************** 5306c2c66affSColin Finck * CM_Is_Dock_Station_Present [SETUPAPI.@] 5307c2c66affSColin Finck */ 5308f86e78d0SEric Kohl CONFIGRET 5309f86e78d0SEric Kohl WINAPI 5310f86e78d0SEric Kohl CM_Is_Dock_Station_Present( 5311f86e78d0SEric Kohl _Out_ PBOOL pbPresent) 5312c2c66affSColin Finck { 5313f86e78d0SEric Kohl TRACE("CM_Is_Dock_Station_Present(%p)\n", 5314f86e78d0SEric Kohl pbPresent); 531565d3bf74SEric Kohl 5316c2c66affSColin Finck return CM_Is_Dock_Station_Present_Ex(pbPresent, NULL); 5317c2c66affSColin Finck } 5318c2c66affSColin Finck 5319c2c66affSColin Finck 5320c2c66affSColin Finck /*********************************************************************** 5321c2c66affSColin Finck * CM_Is_Dock_Station_Present_Ex [SETUPAPI.@] 5322c2c66affSColin Finck */ 5323f86e78d0SEric Kohl CONFIGRET 5324f86e78d0SEric Kohl WINAPI 5325f86e78d0SEric Kohl CM_Is_Dock_Station_Present_Ex( 5326f86e78d0SEric Kohl _Out_ PBOOL pbPresent, 5327f86e78d0SEric Kohl _In_opt_ HMACHINE hMachine) 5328c2c66affSColin Finck { 5329c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 5330c2c66affSColin Finck CONFIGRET ret; 5331c2c66affSColin Finck 533260a21894SEric Kohl TRACE("CM_Is_Dock_Station_Present_Ex(%p %p)\n", 5333f86e78d0SEric Kohl pbPresent, hMachine); 5334c2c66affSColin Finck 5335c2c66affSColin Finck if (pbPresent == NULL) 5336c2c66affSColin Finck return CR_INVALID_POINTER; 5337c2c66affSColin Finck 5338c2c66affSColin Finck *pbPresent = FALSE; 5339c2c66affSColin Finck 5340c2c66affSColin Finck if (hMachine != NULL) 5341c2c66affSColin Finck { 5342c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 5343c2c66affSColin Finck if (BindingHandle == NULL) 5344c2c66affSColin Finck return CR_FAILURE; 5345c2c66affSColin Finck } 5346c2c66affSColin Finck else 5347c2c66affSColin Finck { 5348c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 5349c2c66affSColin Finck return CR_FAILURE; 5350c2c66affSColin Finck } 5351c2c66affSColin Finck 5352c2c66affSColin Finck RpcTryExcept 5353c2c66affSColin Finck { 5354c2c66affSColin Finck ret = PNP_IsDockStationPresent(BindingHandle, 5355c2c66affSColin Finck pbPresent); 5356c2c66affSColin Finck } 5357c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 5358c2c66affSColin Finck { 5359c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 5360c2c66affSColin Finck } 5361c2c66affSColin Finck RpcEndExcept; 5362c2c66affSColin Finck 5363c2c66affSColin Finck return ret; 5364c2c66affSColin Finck } 5365c2c66affSColin Finck 5366c2c66affSColin Finck 5367c2c66affSColin Finck /*********************************************************************** 5368c2c66affSColin Finck * CM_Is_Version_Available_Ex [SETUPAPI.@] 5369c2c66affSColin Finck */ 5370f86e78d0SEric Kohl BOOL 5371f86e78d0SEric Kohl WINAPI 5372f86e78d0SEric Kohl CM_Is_Version_Available( 5373f86e78d0SEric Kohl _In_ WORD wVersion) 5374c2c66affSColin Finck { 5375f86e78d0SEric Kohl TRACE("CM_Is_Version_Available(%hu)\n", 5376f86e78d0SEric Kohl wVersion); 537765d3bf74SEric Kohl 5378c2c66affSColin Finck return CM_Is_Version_Available_Ex(wVersion, NULL); 5379c2c66affSColin Finck } 5380c2c66affSColin Finck 5381c2c66affSColin Finck 5382c2c66affSColin Finck /*********************************************************************** 5383c2c66affSColin Finck * CM_Is_Version_Available_Ex [SETUPAPI.@] 5384c2c66affSColin Finck */ 5385f86e78d0SEric Kohl BOOL 5386f86e78d0SEric Kohl WINAPI 5387f86e78d0SEric Kohl CM_Is_Version_Available_Ex( 5388f86e78d0SEric Kohl _In_ WORD wVersion, 5389f86e78d0SEric Kohl _In_opt_ HMACHINE hMachine) 5390c2c66affSColin Finck { 5391c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 5392c2c66affSColin Finck WORD wServerVersion; 5393c2c66affSColin Finck CONFIGRET ret; 5394c2c66affSColin Finck 539560a21894SEric Kohl TRACE("CM_Is_Version_Available_Ex(%hu %p)\n", 5396f86e78d0SEric Kohl wVersion, hMachine); 5397c2c66affSColin Finck 5398c2c66affSColin Finck if (wVersion <= 0x400) 5399c2c66affSColin Finck return TRUE; 5400c2c66affSColin Finck 5401c2c66affSColin Finck if (hMachine != NULL) 5402c2c66affSColin Finck { 5403c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 5404c2c66affSColin Finck if (BindingHandle == NULL) 5405c2c66affSColin Finck return FALSE; 5406c2c66affSColin Finck } 5407c2c66affSColin Finck else 5408c2c66affSColin Finck { 5409c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 5410c2c66affSColin Finck return FALSE; 5411c2c66affSColin Finck } 5412c2c66affSColin Finck 5413c2c66affSColin Finck RpcTryExcept 5414c2c66affSColin Finck { 5415c2c66affSColin Finck ret = PNP_GetVersion(BindingHandle, &wServerVersion); 5416c2c66affSColin Finck } 5417c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 5418c2c66affSColin Finck { 5419c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 5420c2c66affSColin Finck } 5421c2c66affSColin Finck RpcEndExcept; 5422c2c66affSColin Finck 5423c2c66affSColin Finck if (ret != CR_SUCCESS) 5424c2c66affSColin Finck return FALSE; 5425c2c66affSColin Finck 5426c2c66affSColin Finck return (wServerVersion >= wVersion); 5427c2c66affSColin Finck } 5428c2c66affSColin Finck 5429c2c66affSColin Finck 5430c2c66affSColin Finck /*********************************************************************** 5431c2c66affSColin Finck * CM_Locate_DevNodeA [SETUPAPI.@] 5432c2c66affSColin Finck */ 5433f86e78d0SEric Kohl CONFIGRET 5434f86e78d0SEric Kohl WINAPI 5435f86e78d0SEric Kohl CM_Locate_DevNodeA( 5436f86e78d0SEric Kohl _Out_ PDEVINST pdnDevInst, 5437f86e78d0SEric Kohl _In_opt_ DEVINSTID_A pDeviceID, 5438f86e78d0SEric Kohl _In_ ULONG ulFlags) 5439c2c66affSColin Finck { 544060a21894SEric Kohl TRACE("CM_Locate_DevNodeA(%p %s %lx)\n", 544160a21894SEric Kohl pdnDevInst, debugstr_a(pDeviceID), ulFlags); 544265d3bf74SEric Kohl 5443c2c66affSColin Finck return CM_Locate_DevNode_ExA(pdnDevInst, pDeviceID, ulFlags, NULL); 5444c2c66affSColin Finck } 5445c2c66affSColin Finck 5446c2c66affSColin Finck 5447c2c66affSColin Finck /*********************************************************************** 5448c2c66affSColin Finck * CM_Locate_DevNodeW [SETUPAPI.@] 5449c2c66affSColin Finck */ 5450f86e78d0SEric Kohl CONFIGRET 5451f86e78d0SEric Kohl WINAPI 5452f86e78d0SEric Kohl CM_Locate_DevNodeW( 5453f86e78d0SEric Kohl _Out_ PDEVINST pdnDevInst, 5454f86e78d0SEric Kohl _In_opt_ DEVINSTID_W pDeviceID, 5455f86e78d0SEric Kohl _In_ ULONG ulFlags) 5456c2c66affSColin Finck { 545760a21894SEric Kohl TRACE("CM_Locate_DevNodeW(%p %s %lx)\n", 5458f86e78d0SEric Kohl pdnDevInst, debugstr_w(pDeviceID), ulFlags); 545965d3bf74SEric Kohl 5460c2c66affSColin Finck return CM_Locate_DevNode_ExW(pdnDevInst, pDeviceID, ulFlags, NULL); 5461c2c66affSColin Finck } 5462c2c66affSColin Finck 5463c2c66affSColin Finck 5464c2c66affSColin Finck /*********************************************************************** 5465c2c66affSColin Finck * CM_Locate_DevNode_ExA [SETUPAPI.@] 5466c2c66affSColin Finck */ 5467f86e78d0SEric Kohl CONFIGRET 5468f86e78d0SEric Kohl WINAPI 5469f86e78d0SEric Kohl CM_Locate_DevNode_ExA( 5470f86e78d0SEric Kohl _Out_ PDEVINST pdnDevInst, 5471f86e78d0SEric Kohl _In_opt_ DEVINSTID_A pDeviceID, 5472f86e78d0SEric Kohl _In_ ULONG ulFlags, 5473f86e78d0SEric Kohl _In_opt_ HMACHINE hMachine) 5474c2c66affSColin Finck { 5475c2c66affSColin Finck DEVINSTID_W pDevIdW = NULL; 5476c2c66affSColin Finck CONFIGRET ret = CR_SUCCESS; 5477c2c66affSColin Finck 547860a21894SEric Kohl TRACE("CM_Locate_DevNode_ExA(%p %s %lx %p)\n", 547960a21894SEric Kohl pdnDevInst, debugstr_a(pDeviceID), ulFlags, hMachine); 5480c2c66affSColin Finck 5481c2c66affSColin Finck if (pDeviceID != NULL) 5482c2c66affSColin Finck { 5483c2c66affSColin Finck if (pSetupCaptureAndConvertAnsiArg(pDeviceID, &pDevIdW)) 5484c2c66affSColin Finck return CR_INVALID_DEVICE_ID; 5485c2c66affSColin Finck } 5486c2c66affSColin Finck 5487c2c66affSColin Finck ret = CM_Locate_DevNode_ExW(pdnDevInst, pDevIdW, ulFlags, hMachine); 5488c2c66affSColin Finck 5489c2c66affSColin Finck if (pDevIdW != NULL) 5490c2c66affSColin Finck MyFree(pDevIdW); 5491c2c66affSColin Finck 5492c2c66affSColin Finck return ret; 5493c2c66affSColin Finck } 5494c2c66affSColin Finck 5495c2c66affSColin Finck 5496c2c66affSColin Finck /*********************************************************************** 5497c2c66affSColin Finck * CM_Locate_DevNode_ExW [SETUPAPI.@] 5498c2c66affSColin Finck */ 5499f86e78d0SEric Kohl CONFIGRET 5500f86e78d0SEric Kohl WINAPI 5501f86e78d0SEric Kohl CM_Locate_DevNode_ExW( 5502f86e78d0SEric Kohl _Out_ PDEVINST pdnDevInst, 5503f86e78d0SEric Kohl _In_opt_ DEVINSTID_W pDeviceID, 5504f86e78d0SEric Kohl _In_ ULONG ulFlags, 5505f86e78d0SEric Kohl _In_opt_ HMACHINE hMachine) 5506c2c66affSColin Finck { 5507c2c66affSColin Finck WCHAR DeviceIdBuffer[MAX_DEVICE_ID_LEN]; 5508c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 5509c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 5510c2c66affSColin Finck CONFIGRET ret = CR_SUCCESS; 5511c2c66affSColin Finck 551260a21894SEric Kohl TRACE("CM_Locate_DevNode_ExW(%p %s %lx %p)\n", 5513f86e78d0SEric Kohl pdnDevInst, debugstr_w(pDeviceID), ulFlags, hMachine); 5514c2c66affSColin Finck 5515c2c66affSColin Finck if (pdnDevInst == NULL) 5516c2c66affSColin Finck return CR_INVALID_POINTER; 5517c2c66affSColin Finck 5518c2c66affSColin Finck if (ulFlags & ~CM_LOCATE_DEVNODE_BITS) 5519c2c66affSColin Finck return CR_INVALID_FLAG; 5520c2c66affSColin Finck 5521c2c66affSColin Finck if (hMachine != NULL) 5522c2c66affSColin Finck { 5523c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 5524c2c66affSColin Finck if (BindingHandle == NULL) 5525c2c66affSColin Finck return CR_FAILURE; 5526c2c66affSColin Finck 5527c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 5528c2c66affSColin Finck if (StringTable == 0) 5529c2c66affSColin Finck return CR_FAILURE; 5530c2c66affSColin Finck } 5531c2c66affSColin Finck else 5532c2c66affSColin Finck { 5533c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 5534c2c66affSColin Finck return CR_FAILURE; 5535c2c66affSColin Finck } 5536c2c66affSColin Finck 5537c2c66affSColin Finck if (pDeviceID != NULL && lstrlenW(pDeviceID) != 0) 5538c2c66affSColin Finck { 5539c2c66affSColin Finck lstrcpyW(DeviceIdBuffer, pDeviceID); 5540c2c66affSColin Finck } 5541c2c66affSColin Finck else 5542c2c66affSColin Finck { 5543c2c66affSColin Finck RpcTryExcept 5544c2c66affSColin Finck { 5545c2c66affSColin Finck /* Get the root device ID */ 5546c2c66affSColin Finck ret = PNP_GetRootDeviceInstance(BindingHandle, 5547c2c66affSColin Finck DeviceIdBuffer, 5548c2c66affSColin Finck MAX_DEVICE_ID_LEN); 5549c2c66affSColin Finck } 5550c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 5551c2c66affSColin Finck { 5552c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 5553c2c66affSColin Finck } 5554c2c66affSColin Finck RpcEndExcept; 5555c2c66affSColin Finck 5556c2c66affSColin Finck if (ret != CR_SUCCESS) 5557c2c66affSColin Finck return CR_FAILURE; 5558c2c66affSColin Finck } 5559c2c66affSColin Finck TRACE("DeviceIdBuffer: %s\n", debugstr_w(DeviceIdBuffer)); 5560c2c66affSColin Finck 5561c2c66affSColin Finck RpcTryExcept 5562c2c66affSColin Finck { 5563c2c66affSColin Finck /* Validate the device ID */ 5564c2c66affSColin Finck ret = PNP_ValidateDeviceInstance(BindingHandle, 5565c2c66affSColin Finck DeviceIdBuffer, 5566c2c66affSColin Finck ulFlags); 5567c2c66affSColin Finck } 5568c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 5569c2c66affSColin Finck { 5570c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 5571c2c66affSColin Finck } 5572c2c66affSColin Finck RpcEndExcept; 5573c2c66affSColin Finck 5574c2c66affSColin Finck if (ret == CR_SUCCESS) 5575c2c66affSColin Finck { 5576c2c66affSColin Finck *pdnDevInst = pSetupStringTableAddString(StringTable, DeviceIdBuffer, 1); 5577c2c66affSColin Finck if (*pdnDevInst == -1) 5578c2c66affSColin Finck ret = CR_FAILURE; 5579c2c66affSColin Finck } 5580c2c66affSColin Finck 5581c2c66affSColin Finck return ret; 5582c2c66affSColin Finck } 5583c2c66affSColin Finck 5584c2c66affSColin Finck 5585c2c66affSColin Finck /*********************************************************************** 5586c2c66affSColin Finck * CM_Merge_Range_List [SETUPAPI.@] 5587c2c66affSColin Finck */ 5588c2c66affSColin Finck CONFIGRET 5589c2c66affSColin Finck WINAPI 5590c2c66affSColin Finck CM_Merge_Range_List( 5591c2c66affSColin Finck _In_ RANGE_LIST rlhOld1, 5592c2c66affSColin Finck _In_ RANGE_LIST rlhOld2, 5593c2c66affSColin Finck _In_ RANGE_LIST rlhNew, 5594c2c66affSColin Finck _In_ ULONG ulFlags) 5595c2c66affSColin Finck { 5596c2c66affSColin Finck FIXME("CM_Merge_Range_List(%p %p %p %lx)\n", 5597c2c66affSColin Finck rlhOld1, rlhOld2, rlhNew, ulFlags); 559865d3bf74SEric Kohl 5599c2c66affSColin Finck return CR_CALL_NOT_IMPLEMENTED; 5600c2c66affSColin Finck } 5601c2c66affSColin Finck 5602c2c66affSColin Finck 5603c2c66affSColin Finck /*********************************************************************** 5604c2c66affSColin Finck * CM_Modify_Res_Des [SETUPAPI.@] 5605c2c66affSColin Finck */ 5606f86e78d0SEric Kohl CONFIGRET 5607f86e78d0SEric Kohl WINAPI 5608f86e78d0SEric Kohl CM_Modify_Res_Des( 5609f86e78d0SEric Kohl _Out_ PRES_DES prdResDes, 5610f86e78d0SEric Kohl _In_ RES_DES rdResDes, 5611f86e78d0SEric Kohl _In_ RESOURCEID ResourceID, 561260a21894SEric Kohl _In_reads_bytes_(ResourceLen) PCVOID ResourceData, 5613f86e78d0SEric Kohl _In_ ULONG ResourceLen, 5614f86e78d0SEric Kohl _In_ ULONG ulFlags) 5615c2c66affSColin Finck { 5616f86e78d0SEric Kohl TRACE("CM_Modify_Res_Des(%p %p %lx %p %lu %lx)\n", 5617f86e78d0SEric Kohl prdResDes, rdResDes, ResourceID, ResourceData, 5618c2c66affSColin Finck ResourceLen, ulFlags); 561965d3bf74SEric Kohl 5620c2c66affSColin Finck return CM_Modify_Res_Des_Ex(prdResDes, rdResDes, ResourceID, ResourceData, 5621c2c66affSColin Finck ResourceLen, ulFlags, NULL); 5622c2c66affSColin Finck } 5623c2c66affSColin Finck 5624c2c66affSColin Finck 5625c2c66affSColin Finck /*********************************************************************** 5626c2c66affSColin Finck * CM_Modify_Res_Des_Ex [SETUPAPI.@] 5627c2c66affSColin Finck */ 5628f86e78d0SEric Kohl CONFIGRET 5629f86e78d0SEric Kohl WINAPI 5630f86e78d0SEric Kohl CM_Modify_Res_Des_Ex( 5631f86e78d0SEric Kohl _Out_ PRES_DES prdResDes, 5632f86e78d0SEric Kohl _In_ RES_DES rdResDes, 5633f86e78d0SEric Kohl _In_ RESOURCEID ResourceID, 563460a21894SEric Kohl _In_reads_bytes_(ResourceLen) PCVOID ResourceData, 5635f86e78d0SEric Kohl _In_ ULONG ResourceLen, 5636f86e78d0SEric Kohl _In_ ULONG ulFlags, 5637f86e78d0SEric Kohl _In_opt_ HMACHINE hMachine) 5638c2c66affSColin Finck { 563960a21894SEric Kohl FIXME("CM_Modify_Res_Des_Ex(%p %p %lx %p %lu %lx %p)\n", 5640f86e78d0SEric Kohl prdResDes, rdResDes, ResourceID, ResourceData, 5641c2c66affSColin Finck ResourceLen, ulFlags, hMachine); 564265d3bf74SEric Kohl 5643c2c66affSColin Finck return CR_CALL_NOT_IMPLEMENTED; 5644c2c66affSColin Finck } 5645c2c66affSColin Finck 5646c2c66affSColin Finck 5647c2c66affSColin Finck /*********************************************************************** 5648c2c66affSColin Finck * CM_Move_DevNode [SETUPAPI.@] 5649c2c66affSColin Finck */ 5650f86e78d0SEric Kohl CONFIGRET 5651f86e78d0SEric Kohl WINAPI 5652f86e78d0SEric Kohl CM_Move_DevNode( 5653f86e78d0SEric Kohl _In_ DEVINST dnFromDevInst, 5654f86e78d0SEric Kohl _In_ DEVINST dnToDevInst, 5655f86e78d0SEric Kohl _In_ ULONG ulFlags) 5656c2c66affSColin Finck { 5657f86e78d0SEric Kohl TRACE("CM_Move_DevNode(%lx %lx %lx)\n", 5658f86e78d0SEric Kohl dnFromDevInst, dnToDevInst, ulFlags); 565965d3bf74SEric Kohl 5660c2c66affSColin Finck return CM_Move_DevNode_Ex(dnFromDevInst, dnToDevInst, ulFlags, NULL); 5661c2c66affSColin Finck } 5662c2c66affSColin Finck 5663c2c66affSColin Finck 5664c2c66affSColin Finck /*********************************************************************** 5665c2c66affSColin Finck * CM_Move_DevNode_Ex [SETUPAPI.@] 5666c2c66affSColin Finck */ 5667f86e78d0SEric Kohl CONFIGRET 5668f86e78d0SEric Kohl WINAPI 5669f86e78d0SEric Kohl CM_Move_DevNode_Ex( 5670f86e78d0SEric Kohl _In_ DEVINST dnFromDevInst, 5671f86e78d0SEric Kohl _In_ DEVINST dnToDevInst, 5672f86e78d0SEric Kohl _In_ ULONG ulFlags, 5673f86e78d0SEric Kohl _In_opt_ HMACHINE hMachine) 5674c2c66affSColin Finck { 5675c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 5676c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 5677c2c66affSColin Finck LPWSTR lpFromDevInst; 5678c2c66affSColin Finck LPWSTR lpToDevInst; 5679c2c66affSColin Finck CONFIGRET ret; 5680c2c66affSColin Finck 568160a21894SEric Kohl FIXME("CM_Move_DevNode_Ex(%lx %lx %lx %p)\n", 5682c2c66affSColin Finck dnFromDevInst, dnToDevInst, ulFlags, hMachine); 5683c2c66affSColin Finck 5684c2c66affSColin Finck if (!pSetupIsUserAdmin()) 5685c2c66affSColin Finck return CR_ACCESS_DENIED; 5686c2c66affSColin Finck 5687c2c66affSColin Finck if (dnFromDevInst == 0 || dnToDevInst == 0) 5688c2c66affSColin Finck return CR_INVALID_DEVNODE; 5689c2c66affSColin Finck 5690c2c66affSColin Finck if (ulFlags != 0) 5691c2c66affSColin Finck return CR_INVALID_FLAG; 5692c2c66affSColin Finck 5693c2c66affSColin Finck if (hMachine != NULL) 5694c2c66affSColin Finck { 5695c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 5696c2c66affSColin Finck if (BindingHandle == NULL) 5697c2c66affSColin Finck return CR_FAILURE; 5698c2c66affSColin Finck 5699c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 5700c2c66affSColin Finck if (StringTable == 0) 5701c2c66affSColin Finck return CR_FAILURE; 5702c2c66affSColin Finck } 5703c2c66affSColin Finck else 5704c2c66affSColin Finck { 5705c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 5706c2c66affSColin Finck return CR_FAILURE; 5707c2c66affSColin Finck } 5708c2c66affSColin Finck 5709c2c66affSColin Finck lpFromDevInst = pSetupStringTableStringFromId(StringTable, dnFromDevInst); 5710c2c66affSColin Finck if (lpFromDevInst == NULL) 5711c2c66affSColin Finck return CR_INVALID_DEVNODE; 5712c2c66affSColin Finck 5713c2c66affSColin Finck lpToDevInst = pSetupStringTableStringFromId(StringTable, dnToDevInst); 5714c2c66affSColin Finck if (lpToDevInst == NULL) 5715c2c66affSColin Finck return CR_INVALID_DEVNODE; 5716c2c66affSColin Finck 5717c2c66affSColin Finck RpcTryExcept 5718c2c66affSColin Finck { 5719c2c66affSColin Finck ret = PNP_DeviceInstanceAction(BindingHandle, 5720c2c66affSColin Finck PNP_DEVINST_MOVE, 5721c2c66affSColin Finck ulFlags, 5722c2c66affSColin Finck lpFromDevInst, 5723c2c66affSColin Finck lpToDevInst); 5724c2c66affSColin Finck } 5725c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 5726c2c66affSColin Finck { 5727c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 5728c2c66affSColin Finck } 5729c2c66affSColin Finck RpcEndExcept; 5730c2c66affSColin Finck 5731c2c66affSColin Finck return ret; 5732c2c66affSColin Finck } 5733c2c66affSColin Finck 5734c2c66affSColin Finck 5735c2c66affSColin Finck /*********************************************************************** 5736c2c66affSColin Finck * CM_Next_Range [SETUPAPI.@] 5737c2c66affSColin Finck */ 5738c2c66affSColin Finck CONFIGRET 5739c2c66affSColin Finck WINAPI 5740c2c66affSColin Finck CM_Next_Range( 5741c2c66affSColin Finck _Inout_ PRANGE_ELEMENT preElement, 5742c2c66affSColin Finck _Out_ PDWORDLONG pullStart, 5743c2c66affSColin Finck _Out_ PDWORDLONG pullEnd, 5744c2c66affSColin Finck _In_ ULONG ulFlags) 5745c2c66affSColin Finck { 5746c2c66affSColin Finck FIXME("CM_Next_Range(%p %p %p %lx)\n", 5747c2c66affSColin Finck preElement, pullStart, pullEnd, ulFlags); 574865d3bf74SEric Kohl 5749c2c66affSColin Finck return CR_CALL_NOT_IMPLEMENTED; 5750c2c66affSColin Finck } 5751c2c66affSColin Finck 5752c2c66affSColin Finck 5753c2c66affSColin Finck /*********************************************************************** 5754c2c66affSColin Finck * CM_Open_Class_KeyA [SETUPAPI.@] 5755c2c66affSColin Finck */ 5756f86e78d0SEric Kohl CONFIGRET 5757f86e78d0SEric Kohl WINAPI 5758f86e78d0SEric Kohl CM_Open_Class_KeyA( 5759f86e78d0SEric Kohl _In_opt_ LPGUID pClassGuid, 5760f86e78d0SEric Kohl _In_opt_ LPCSTR pszClassName, 5761f86e78d0SEric Kohl _In_ REGSAM samDesired, 5762f86e78d0SEric Kohl _In_ REGDISPOSITION Disposition, 5763f86e78d0SEric Kohl _Out_ PHKEY phkClass, 5764f86e78d0SEric Kohl _In_ ULONG ulFlags) 5765c2c66affSColin Finck { 5766f86e78d0SEric Kohl TRACE("CM_Open_Class_KeyA(%p %s %lx %lx %p %lx)\n", 576760a21894SEric Kohl debugstr_guid(pClassGuid), debugstr_a(pszClassName), 5768c2c66affSColin Finck samDesired, Disposition, phkClass, ulFlags); 5769c2c66affSColin Finck 5770c2c66affSColin Finck return CM_Open_Class_Key_ExA(pClassGuid, pszClassName, samDesired, 5771c2c66affSColin Finck Disposition, phkClass, ulFlags, NULL); 5772c2c66affSColin Finck } 5773c2c66affSColin Finck 5774c2c66affSColin Finck 5775c2c66affSColin Finck /*********************************************************************** 5776c2c66affSColin Finck * CM_Open_Class_KeyW [SETUPAPI.@] 5777c2c66affSColin Finck */ 5778f86e78d0SEric Kohl CONFIGRET 5779f86e78d0SEric Kohl WINAPI 5780f86e78d0SEric Kohl CM_Open_Class_KeyW( 5781f86e78d0SEric Kohl _In_opt_ LPGUID pClassGuid, 5782f86e78d0SEric Kohl _In_opt_ LPCWSTR pszClassName, 5783f86e78d0SEric Kohl _In_ REGSAM samDesired, 5784f86e78d0SEric Kohl _In_ REGDISPOSITION Disposition, 5785f86e78d0SEric Kohl _Out_ PHKEY phkClass, 5786f86e78d0SEric Kohl _In_ ULONG ulFlags) 5787c2c66affSColin Finck { 5788f86e78d0SEric Kohl TRACE("CM_Open_Class_KeyW%p %s %lx %lx %p %lx)\n", 5789c2c66affSColin Finck debugstr_guid(pClassGuid), debugstr_w(pszClassName), 5790c2c66affSColin Finck samDesired, Disposition, phkClass, ulFlags); 5791c2c66affSColin Finck 5792c2c66affSColin Finck return CM_Open_Class_Key_ExW(pClassGuid, pszClassName, samDesired, 5793c2c66affSColin Finck Disposition, phkClass, ulFlags, NULL); 5794c2c66affSColin Finck } 5795c2c66affSColin Finck 5796c2c66affSColin Finck 5797c2c66affSColin Finck /*********************************************************************** 5798c2c66affSColin Finck * CM_Open_Class_Key_ExA [SETUPAPI.@] 5799c2c66affSColin Finck */ 5800f86e78d0SEric Kohl CONFIGRET 5801f86e78d0SEric Kohl WINAPI 5802f86e78d0SEric Kohl CM_Open_Class_Key_ExA( 5803f86e78d0SEric Kohl _In_opt_ LPGUID pClassGuid, 5804f86e78d0SEric Kohl _In_opt_ LPCSTR pszClassName, 5805f86e78d0SEric Kohl _In_ REGSAM samDesired, 5806f86e78d0SEric Kohl _In_ REGDISPOSITION Disposition, 5807f86e78d0SEric Kohl _Out_ PHKEY phkClass, 5808f86e78d0SEric Kohl _In_ ULONG ulFlags, 5809f86e78d0SEric Kohl _In_opt_ HMACHINE hMachine) 5810c2c66affSColin Finck { 5811c2c66affSColin Finck LPWSTR pszClassNameW = NULL; 5812c2c66affSColin Finck CONFIGRET ret; 5813c2c66affSColin Finck 581460a21894SEric Kohl TRACE("CM_Open_Class_Key_ExA(%p %s %lx %lx %p %lx %p)\n", 581560a21894SEric Kohl debugstr_guid(pClassGuid), debugstr_a(pszClassName), 5816c2c66affSColin Finck samDesired, Disposition, phkClass, ulFlags, hMachine); 5817c2c66affSColin Finck 5818c2c66affSColin Finck if (pszClassName != NULL) 5819c2c66affSColin Finck { 5820c2c66affSColin Finck if (pSetupCaptureAndConvertAnsiArg(pszClassName, &pszClassNameW)) 5821c2c66affSColin Finck return CR_INVALID_DATA; 5822c2c66affSColin Finck } 5823c2c66affSColin Finck 5824c2c66affSColin Finck ret = CM_Open_Class_Key_ExW(pClassGuid, pszClassNameW, samDesired, 5825c2c66affSColin Finck Disposition, phkClass, ulFlags, hMachine); 5826c2c66affSColin Finck 5827c2c66affSColin Finck if (pszClassNameW != NULL) 5828c2c66affSColin Finck MyFree(pszClassNameW); 5829c2c66affSColin Finck 5830c2c66affSColin Finck return ret; 5831c2c66affSColin Finck } 5832c2c66affSColin Finck 5833c2c66affSColin Finck 5834c2c66affSColin Finck /*********************************************************************** 5835c2c66affSColin Finck * CM_Open_Class_Key_ExW [SETUPAPI.@] 5836c2c66affSColin Finck */ 5837f86e78d0SEric Kohl CONFIGRET 5838f86e78d0SEric Kohl WINAPI 5839f86e78d0SEric Kohl CM_Open_Class_Key_ExW( 5840f86e78d0SEric Kohl _In_opt_ LPGUID pClassGuid, 5841f86e78d0SEric Kohl _In_opt_ LPCWSTR pszClassName, 5842f86e78d0SEric Kohl _In_ REGSAM samDesired, 5843f86e78d0SEric Kohl _In_ REGDISPOSITION Disposition, 5844f86e78d0SEric Kohl _Out_ PHKEY phkClass, 5845f86e78d0SEric Kohl _In_ ULONG ulFlags, 5846f86e78d0SEric Kohl _In_opt_ HMACHINE hMachine) 5847c2c66affSColin Finck { 5848c2c66affSColin Finck WCHAR szKeyName[MAX_PATH]; 5849c2c66affSColin Finck LPWSTR lpGuidString; 5850c2c66affSColin Finck DWORD dwDisposition; 5851c2c66affSColin Finck DWORD dwError; 5852c2c66affSColin Finck HKEY hKey; 5853c2c66affSColin Finck 585460a21894SEric Kohl TRACE("CM_Open_Class_Key_ExW(%p %s %lx %lx %p %lx %p)\n", 5855c2c66affSColin Finck debugstr_guid(pClassGuid), debugstr_w(pszClassName), 5856c2c66affSColin Finck samDesired, Disposition, phkClass, ulFlags, hMachine); 5857c2c66affSColin Finck 5858c2c66affSColin Finck /* Check Disposition and ulFlags */ 5859c2c66affSColin Finck if ((Disposition & ~RegDisposition_Bits) || 5860c2c66affSColin Finck (ulFlags & ~CM_OPEN_CLASS_KEY_BITS)) 5861c2c66affSColin Finck return CR_INVALID_FLAG; 5862c2c66affSColin Finck 5863c2c66affSColin Finck /* Check phkClass */ 5864c2c66affSColin Finck if (phkClass == NULL) 5865c2c66affSColin Finck return CR_INVALID_POINTER; 5866c2c66affSColin Finck 5867c2c66affSColin Finck *phkClass = NULL; 5868c2c66affSColin Finck 5869c2c66affSColin Finck if (ulFlags == CM_OPEN_CLASS_KEY_INTERFACE && 5870c2c66affSColin Finck pszClassName != NULL) 5871c2c66affSColin Finck return CR_INVALID_DATA; 5872c2c66affSColin Finck 5873c2c66affSColin Finck if (hMachine == NULL) 5874c2c66affSColin Finck { 5875c2c66affSColin Finck hKey = HKEY_LOCAL_MACHINE; 5876c2c66affSColin Finck } 5877c2c66affSColin Finck else 5878c2c66affSColin Finck { 5879c2c66affSColin Finck if (RegConnectRegistryW(((PMACHINE_INFO)hMachine)->szMachineName, 588006f9e122SEric Kohl HKEY_LOCAL_MACHINE, 588106f9e122SEric Kohl &hKey)) 5882c2c66affSColin Finck return CR_REGISTRY_ERROR; 5883c2c66affSColin Finck } 5884c2c66affSColin Finck 5885c2c66affSColin Finck if (ulFlags & CM_OPEN_CLASS_KEY_INTERFACE) 5886c2c66affSColin Finck { 5887c2c66affSColin Finck lstrcpyW(szKeyName, DeviceClasses); 5888c2c66affSColin Finck } 5889c2c66affSColin Finck else 5890c2c66affSColin Finck { 5891c2c66affSColin Finck lstrcpyW(szKeyName, ControlClass); 5892c2c66affSColin Finck } 5893c2c66affSColin Finck 5894c2c66affSColin Finck if (pClassGuid != NULL) 5895c2c66affSColin Finck { 5896c2c66affSColin Finck if (UuidToStringW((UUID*)pClassGuid, &lpGuidString) != RPC_S_OK) 5897c2c66affSColin Finck { 5898c2c66affSColin Finck RegCloseKey(hKey); 5899c2c66affSColin Finck return CR_INVALID_DATA; 5900c2c66affSColin Finck } 5901c2c66affSColin Finck 5902c2c66affSColin Finck lstrcatW(szKeyName, Backslash); 5903c2c66affSColin Finck lstrcatW(szKeyName, lpGuidString); 5904c2c66affSColin Finck } 5905c2c66affSColin Finck 5906c2c66affSColin Finck if (Disposition == RegDisposition_OpenAlways) 5907c2c66affSColin Finck { 5908c2c66affSColin Finck dwError = RegCreateKeyExW(hKey, szKeyName, 0, NULL, 0, samDesired, 5909c2c66affSColin Finck NULL, phkClass, &dwDisposition); 5910c2c66affSColin Finck } 5911c2c66affSColin Finck else 5912c2c66affSColin Finck { 5913c2c66affSColin Finck dwError = RegOpenKeyExW(hKey, szKeyName, 0, samDesired, phkClass); 5914c2c66affSColin Finck } 5915c2c66affSColin Finck 5916c2c66affSColin Finck RegCloseKey(hKey); 5917c2c66affSColin Finck 5918c2c66affSColin Finck if (pClassGuid != NULL) 5919c2c66affSColin Finck RpcStringFreeW(&lpGuidString); 5920c2c66affSColin Finck 5921c2c66affSColin Finck if (dwError != ERROR_SUCCESS) 5922c2c66affSColin Finck { 5923c2c66affSColin Finck *phkClass = NULL; 5924c2c66affSColin Finck return CR_NO_SUCH_REGISTRY_KEY; 5925c2c66affSColin Finck } 5926c2c66affSColin Finck 5927c2c66affSColin Finck if (pszClassName != NULL) 5928c2c66affSColin Finck { 5929c2c66affSColin Finck RegSetValueExW(*phkClass, Class, 0, REG_SZ, (LPBYTE)pszClassName, 5930c2c66affSColin Finck (lstrlenW(pszClassName) + 1) * sizeof(WCHAR)); 5931c2c66affSColin Finck } 5932c2c66affSColin Finck 5933c2c66affSColin Finck return CR_SUCCESS; 5934c2c66affSColin Finck } 5935c2c66affSColin Finck 5936c2c66affSColin Finck 5937c2c66affSColin Finck /*********************************************************************** 5938c2c66affSColin Finck * CM_Open_DevNode_Key [SETUPAPI.@] 5939c2c66affSColin Finck */ 594078cf2a04SEric Kohl CONFIGRET 594178cf2a04SEric Kohl WINAPI 594278cf2a04SEric Kohl CM_Open_DevNode_Key( 594378cf2a04SEric Kohl _In_ DEVINST dnDevNode, 594478cf2a04SEric Kohl _In_ REGSAM samDesired, 594578cf2a04SEric Kohl _In_ ULONG ulHardwareProfile, 594678cf2a04SEric Kohl _In_ REGDISPOSITION Disposition, 594778cf2a04SEric Kohl _Out_ PHKEY phkDevice, 594878cf2a04SEric Kohl _In_ ULONG ulFlags) 5949c2c66affSColin Finck { 595078cf2a04SEric Kohl TRACE("CM_Open_DevNode_Key(%lx %lx %lu %lx %p %lx)\n", 595178cf2a04SEric Kohl dnDevNode, samDesired, ulHardwareProfile, Disposition, phkDevice, ulFlags); 595265d3bf74SEric Kohl 5953c2c66affSColin Finck return CM_Open_DevNode_Key_Ex(dnDevNode, samDesired, ulHardwareProfile, 5954c2c66affSColin Finck Disposition, phkDevice, ulFlags, NULL); 5955c2c66affSColin Finck } 5956c2c66affSColin Finck 5957c2c66affSColin Finck 5958c2c66affSColin Finck /*********************************************************************** 5959c2c66affSColin Finck * CM_Open_DevNode_Key_Ex [SETUPAPI.@] 5960c2c66affSColin Finck */ 596178cf2a04SEric Kohl CONFIGRET 596278cf2a04SEric Kohl WINAPI 596378cf2a04SEric Kohl CM_Open_DevNode_Key_Ex( 596478cf2a04SEric Kohl _In_ DEVINST dnDevNode, 596578cf2a04SEric Kohl _In_ REGSAM samDesired, 596678cf2a04SEric Kohl _In_ ULONG ulHardwareProfile, 596778cf2a04SEric Kohl _In_ REGDISPOSITION Disposition, 596878cf2a04SEric Kohl _Out_ PHKEY phkDevice, 596978cf2a04SEric Kohl _In_ ULONG ulFlags, 5970f86e78d0SEric Kohl _In_opt_ HMACHINE hMachine) 5971c2c66affSColin Finck { 597278cf2a04SEric Kohl RPC_BINDING_HANDLE BindingHandle = NULL; 597378cf2a04SEric Kohl HSTRING_TABLE StringTable = NULL; 597478cf2a04SEric Kohl LPWSTR pszDevInst, pszKeyPath = NULL, pszInstancePath = NULL; 597578cf2a04SEric Kohl LONG lError; 597606f9e122SEric Kohl DWORD dwDisposition; 597706f9e122SEric Kohl HKEY hRootKey = NULL; 597878cf2a04SEric Kohl CONFIGRET ret = CR_CALL_NOT_IMPLEMENTED; 5979c2c66affSColin Finck 598060a21894SEric Kohl TRACE("CM_Open_DevNode_Key_Ex(%lx %lx %lu %lx %p %lx %p)\n", 598178cf2a04SEric Kohl dnDevNode, samDesired, ulHardwareProfile, Disposition, phkDevice, ulFlags, hMachine); 598278cf2a04SEric Kohl 598378cf2a04SEric Kohl if (phkDevice == NULL) 598478cf2a04SEric Kohl return CR_INVALID_POINTER; 598578cf2a04SEric Kohl 598678cf2a04SEric Kohl *phkDevice = NULL; 598778cf2a04SEric Kohl 598878cf2a04SEric Kohl if (dnDevNode == 0) 598978cf2a04SEric Kohl return CR_INVALID_DEVNODE; 599078cf2a04SEric Kohl 599178cf2a04SEric Kohl if (ulFlags & ~CM_REGISTRY_BITS) 599278cf2a04SEric Kohl return CR_INVALID_FLAG; 599378cf2a04SEric Kohl 599478cf2a04SEric Kohl if (Disposition & ~RegDisposition_Bits) 599578cf2a04SEric Kohl return CR_INVALID_DATA; 599678cf2a04SEric Kohl 599778cf2a04SEric Kohl if (hMachine != NULL) 599878cf2a04SEric Kohl { 599978cf2a04SEric Kohl BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 600078cf2a04SEric Kohl if (BindingHandle == NULL) 600178cf2a04SEric Kohl return CR_FAILURE; 600278cf2a04SEric Kohl 600378cf2a04SEric Kohl StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 600478cf2a04SEric Kohl if (StringTable == 0) 600578cf2a04SEric Kohl return CR_FAILURE; 600678cf2a04SEric Kohl } 600778cf2a04SEric Kohl else 600878cf2a04SEric Kohl { 600978cf2a04SEric Kohl if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 601078cf2a04SEric Kohl return CR_FAILURE; 601178cf2a04SEric Kohl } 601278cf2a04SEric Kohl 601378cf2a04SEric Kohl pszDevInst = pSetupStringTableStringFromId(StringTable, dnDevNode); 601478cf2a04SEric Kohl if (pszDevInst == NULL) 601578cf2a04SEric Kohl return CR_INVALID_DEVNODE; 601678cf2a04SEric Kohl 601778cf2a04SEric Kohl TRACE("pszDevInst: %S\n", pszDevInst); 601878cf2a04SEric Kohl 601906f9e122SEric Kohl pszKeyPath = MyMalloc(512 * sizeof(WCHAR)); 602078cf2a04SEric Kohl if (pszKeyPath == NULL) 602178cf2a04SEric Kohl { 602278cf2a04SEric Kohl ret = CR_OUT_OF_MEMORY; 602378cf2a04SEric Kohl goto done; 602478cf2a04SEric Kohl } 602578cf2a04SEric Kohl 602606f9e122SEric Kohl pszInstancePath = MyMalloc(512 * sizeof(WCHAR)); 602778cf2a04SEric Kohl if (pszInstancePath == NULL) 602878cf2a04SEric Kohl { 602978cf2a04SEric Kohl ret = CR_OUT_OF_MEMORY; 603078cf2a04SEric Kohl goto done; 603178cf2a04SEric Kohl } 603278cf2a04SEric Kohl 603378cf2a04SEric Kohl ret = GetDeviceInstanceKeyPath(BindingHandle, 603478cf2a04SEric Kohl pszDevInst, 603578cf2a04SEric Kohl pszKeyPath, 603678cf2a04SEric Kohl pszInstancePath, 603778cf2a04SEric Kohl ulHardwareProfile, 603878cf2a04SEric Kohl ulFlags); 603978cf2a04SEric Kohl if (ret != CR_SUCCESS) 604078cf2a04SEric Kohl goto done; 604178cf2a04SEric Kohl 6042a2a37239SEric Kohl TRACE("pszKeyPath: %S\n", pszKeyPath); 6043a2a37239SEric Kohl TRACE("pszInstancePath: %S\n", pszInstancePath); 604478cf2a04SEric Kohl 604578cf2a04SEric Kohl wcscat(pszKeyPath, L"\\"); 604678cf2a04SEric Kohl wcscat(pszKeyPath, pszInstancePath); 604778cf2a04SEric Kohl 6048a2a37239SEric Kohl TRACE("pszKeyPath: %S\n", pszKeyPath); 604978cf2a04SEric Kohl 605006f9e122SEric Kohl if (hMachine == NULL) 605106f9e122SEric Kohl { 605206f9e122SEric Kohl hRootKey = HKEY_LOCAL_MACHINE; 605306f9e122SEric Kohl } 605406f9e122SEric Kohl else 605506f9e122SEric Kohl { 605606f9e122SEric Kohl if (RegConnectRegistryW(((PMACHINE_INFO)hMachine)->szMachineName, 605706f9e122SEric Kohl HKEY_LOCAL_MACHINE, 605806f9e122SEric Kohl &hRootKey)) 605906f9e122SEric Kohl { 606006f9e122SEric Kohl ret = CR_REGISTRY_ERROR; 606106f9e122SEric Kohl goto done; 606206f9e122SEric Kohl } 606306f9e122SEric Kohl } 606478cf2a04SEric Kohl 606506f9e122SEric Kohl if (Disposition == RegDisposition_OpenAlways) 606606f9e122SEric Kohl { 606706f9e122SEric Kohl lError = RegCreateKeyExW(hRootKey, 606806f9e122SEric Kohl pszKeyPath, 606906f9e122SEric Kohl 0, 607006f9e122SEric Kohl NULL, 607106f9e122SEric Kohl 0, 607206f9e122SEric Kohl samDesired, 607306f9e122SEric Kohl NULL, 607406f9e122SEric Kohl phkDevice, 607506f9e122SEric Kohl &dwDisposition); 607606f9e122SEric Kohl } 607706f9e122SEric Kohl else 607806f9e122SEric Kohl { 607906f9e122SEric Kohl lError = RegOpenKeyExW(hRootKey, 608078cf2a04SEric Kohl pszKeyPath, 608178cf2a04SEric Kohl 0, 608278cf2a04SEric Kohl samDesired, 608378cf2a04SEric Kohl phkDevice); 608406f9e122SEric Kohl } 608506f9e122SEric Kohl 608678cf2a04SEric Kohl if (lError != ERROR_SUCCESS) 608778cf2a04SEric Kohl { 608878cf2a04SEric Kohl *phkDevice = NULL; 608978cf2a04SEric Kohl ret = CR_NO_SUCH_REGISTRY_KEY; 609078cf2a04SEric Kohl } 609178cf2a04SEric Kohl 609278cf2a04SEric Kohl done: 609306f9e122SEric Kohl if ((hRootKey != NULL) && (hRootKey != HKEY_LOCAL_MACHINE)) 609406f9e122SEric Kohl RegCloseKey(hRootKey); 609506f9e122SEric Kohl 609678cf2a04SEric Kohl if (pszInstancePath != NULL) 609778cf2a04SEric Kohl MyFree(pszInstancePath); 609878cf2a04SEric Kohl 609978cf2a04SEric Kohl if (pszKeyPath != NULL) 610078cf2a04SEric Kohl MyFree(pszKeyPath); 610178cf2a04SEric Kohl 610278cf2a04SEric Kohl return ret; 6103c2c66affSColin Finck } 6104c2c66affSColin Finck 6105c2c66affSColin Finck 6106c2c66affSColin Finck /*********************************************************************** 6107c2c66affSColin Finck * CM_Query_And_Remove_SubTreeA [SETUPAPI.@] 6108c2c66affSColin Finck */ 610965d3bf74SEric Kohl CONFIGRET 611065d3bf74SEric Kohl WINAPI 611165d3bf74SEric Kohl CM_Query_And_Remove_SubTreeA( 611265d3bf74SEric Kohl _In_ DEVINST dnAncestor, 611365d3bf74SEric Kohl _Out_opt_ PPNP_VETO_TYPE pVetoType, 611465d3bf74SEric Kohl _Out_writes_opt_(ulNameLength) LPSTR pszVetoName, 611565d3bf74SEric Kohl _In_ ULONG ulNameLength, 611665d3bf74SEric Kohl _In_ ULONG ulFlags) 6117c2c66affSColin Finck { 611865d3bf74SEric Kohl TRACE("CM_Query_And_Remove_SubTreeA(%lx %p %s %lu %lx)\n", 611965d3bf74SEric Kohl dnAncestor, pVetoType, pszVetoName, ulNameLength, ulFlags); 6120c2c66affSColin Finck 6121c2c66affSColin Finck return CM_Query_And_Remove_SubTree_ExA(dnAncestor, pVetoType, pszVetoName, 6122c2c66affSColin Finck ulNameLength, ulFlags, NULL); 6123c2c66affSColin Finck } 6124c2c66affSColin Finck 6125c2c66affSColin Finck 6126c2c66affSColin Finck /*********************************************************************** 6127c2c66affSColin Finck * CM_Query_And_Remove_SubTreeW [SETUPAPI.@] 6128c2c66affSColin Finck */ 612965d3bf74SEric Kohl CONFIGRET 613065d3bf74SEric Kohl WINAPI 613165d3bf74SEric Kohl CM_Query_And_Remove_SubTreeW( 613265d3bf74SEric Kohl _In_ DEVINST dnAncestor, 613365d3bf74SEric Kohl _Out_opt_ PPNP_VETO_TYPE pVetoType, 613465d3bf74SEric Kohl _Out_writes_opt_(ulNameLength) LPWSTR pszVetoName, 613565d3bf74SEric Kohl _In_ ULONG ulNameLength, 613665d3bf74SEric Kohl _In_ ULONG ulFlags) 6137c2c66affSColin Finck { 613865d3bf74SEric Kohl TRACE("CM_Query_And_Remove_SubTreeW(%lx %p %s %lu %lx)\n", 613965d3bf74SEric Kohl dnAncestor, pVetoType, debugstr_w(pszVetoName), ulNameLength, ulFlags); 6140c2c66affSColin Finck 6141c2c66affSColin Finck return CM_Query_And_Remove_SubTree_ExW(dnAncestor, pVetoType, pszVetoName, 6142c2c66affSColin Finck ulNameLength, ulFlags, NULL); 6143c2c66affSColin Finck } 6144c2c66affSColin Finck 6145c2c66affSColin Finck 6146c2c66affSColin Finck /*********************************************************************** 6147c2c66affSColin Finck * CM_Query_And_Remove_SubTree_ExA [SETUPAPI.@] 6148c2c66affSColin Finck */ 614965d3bf74SEric Kohl CONFIGRET 615065d3bf74SEric Kohl WINAPI 615165d3bf74SEric Kohl CM_Query_And_Remove_SubTree_ExA( 615265d3bf74SEric Kohl _In_ DEVINST dnAncestor, 615365d3bf74SEric Kohl _Out_opt_ PPNP_VETO_TYPE pVetoType, 615465d3bf74SEric Kohl _Out_writes_opt_(ulNameLength) LPSTR pszVetoName, 615565d3bf74SEric Kohl _In_ ULONG ulNameLength, 615665d3bf74SEric Kohl _In_ ULONG ulFlags, 615765d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 6158c2c66affSColin Finck { 6159c2c66affSColin Finck LPWSTR lpLocalVetoName; 6160c2c66affSColin Finck CONFIGRET ret; 6161c2c66affSColin Finck 616260a21894SEric Kohl TRACE("CM_Query_And_Remove_SubTree_ExA(%lx %p %s %lu %lx %p)\n", 616365d3bf74SEric Kohl dnAncestor, pVetoType, debugstr_a(pszVetoName), ulNameLength, 616465d3bf74SEric Kohl ulFlags, hMachine); 6165c2c66affSColin Finck 6166c2c66affSColin Finck if (pszVetoName == NULL && ulNameLength == 0) 6167c2c66affSColin Finck return CR_INVALID_POINTER; 6168c2c66affSColin Finck 6169c2c66affSColin Finck lpLocalVetoName = HeapAlloc(GetProcessHeap(), 0, ulNameLength * sizeof(WCHAR)); 6170c2c66affSColin Finck if (lpLocalVetoName == NULL) 6171c2c66affSColin Finck return CR_OUT_OF_MEMORY; 6172c2c66affSColin Finck 6173c2c66affSColin Finck ret = CM_Query_And_Remove_SubTree_ExW(dnAncestor, pVetoType, lpLocalVetoName, 6174c2c66affSColin Finck ulNameLength, ulFlags, hMachine); 6175c2c66affSColin Finck if (ret == CR_REMOVE_VETOED) 6176c2c66affSColin Finck { 6177c2c66affSColin Finck if (WideCharToMultiByte(CP_ACP, 6178c2c66affSColin Finck 0, 6179c2c66affSColin Finck lpLocalVetoName, 6180c2c66affSColin Finck ulNameLength, 6181c2c66affSColin Finck pszVetoName, 6182c2c66affSColin Finck ulNameLength, 6183c2c66affSColin Finck NULL, 6184c2c66affSColin Finck NULL) == 0) 6185c2c66affSColin Finck ret = CR_FAILURE; 6186c2c66affSColin Finck } 6187c2c66affSColin Finck 6188c2c66affSColin Finck HeapFree(GetProcessHeap(), 0, lpLocalVetoName); 6189c2c66affSColin Finck 6190c2c66affSColin Finck return ret; 6191c2c66affSColin Finck } 6192c2c66affSColin Finck 6193c2c66affSColin Finck 6194c2c66affSColin Finck /*********************************************************************** 6195c2c66affSColin Finck * CM_Query_And_Remove_SubTree_ExW [SETUPAPI.@] 6196c2c66affSColin Finck */ 619765d3bf74SEric Kohl CONFIGRET 619865d3bf74SEric Kohl WINAPI 619965d3bf74SEric Kohl CM_Query_And_Remove_SubTree_ExW( 620065d3bf74SEric Kohl _In_ DEVINST dnAncestor, 620165d3bf74SEric Kohl _Out_opt_ PPNP_VETO_TYPE pVetoType, 620265d3bf74SEric Kohl _Out_writes_opt_(ulNameLength) LPWSTR pszVetoName, 620365d3bf74SEric Kohl _In_ ULONG ulNameLength, 620465d3bf74SEric Kohl _In_ ULONG ulFlags, 620565d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 6206c2c66affSColin Finck { 6207c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 6208c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 6209c2c66affSColin Finck LPWSTR lpDevInst; 6210c2c66affSColin Finck CONFIGRET ret; 6211c2c66affSColin Finck 621260a21894SEric Kohl TRACE("CM_Query_And_Remove_SubTree_ExW(%lx %p %s %lu %lx %p)\n", 621365d3bf74SEric Kohl dnAncestor, pVetoType, debugstr_w(pszVetoName), ulNameLength, 621465d3bf74SEric Kohl ulFlags, hMachine); 6215c2c66affSColin Finck 6216c2c66affSColin Finck if (dnAncestor == 0) 6217c2c66affSColin Finck return CR_INVALID_DEVNODE; 6218c2c66affSColin Finck 6219c2c66affSColin Finck if (ulFlags & ~CM_REMOVE_BITS) 6220c2c66affSColin Finck return CR_INVALID_FLAG; 6221c2c66affSColin Finck 6222c2c66affSColin Finck if (pszVetoName == NULL && ulNameLength == 0) 6223c2c66affSColin Finck return CR_INVALID_POINTER; 6224c2c66affSColin Finck 6225c2c66affSColin Finck if (hMachine != NULL) 6226c2c66affSColin Finck { 6227c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 6228c2c66affSColin Finck if (BindingHandle == NULL) 6229c2c66affSColin Finck return CR_FAILURE; 6230c2c66affSColin Finck 6231c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 6232c2c66affSColin Finck if (StringTable == 0) 6233c2c66affSColin Finck return CR_FAILURE; 6234c2c66affSColin Finck } 6235c2c66affSColin Finck else 6236c2c66affSColin Finck { 6237c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 6238c2c66affSColin Finck return CR_FAILURE; 6239c2c66affSColin Finck } 6240c2c66affSColin Finck 6241c2c66affSColin Finck lpDevInst = pSetupStringTableStringFromId(StringTable, dnAncestor); 6242c2c66affSColin Finck if (lpDevInst == NULL) 6243c2c66affSColin Finck return CR_INVALID_DEVNODE; 6244c2c66affSColin Finck 6245c2c66affSColin Finck RpcTryExcept 6246c2c66affSColin Finck { 6247c2c66affSColin Finck ret = PNP_QueryRemove(BindingHandle, 6248c2c66affSColin Finck lpDevInst, 6249c2c66affSColin Finck pVetoType, 6250c2c66affSColin Finck pszVetoName, 6251c2c66affSColin Finck ulNameLength, 6252c2c66affSColin Finck ulFlags); 6253c2c66affSColin Finck } 6254c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 6255c2c66affSColin Finck { 6256c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 6257c2c66affSColin Finck } 6258c2c66affSColin Finck RpcEndExcept; 6259c2c66affSColin Finck 6260c2c66affSColin Finck return ret; 6261c2c66affSColin Finck } 6262c2c66affSColin Finck 6263c2c66affSColin Finck 6264c2c66affSColin Finck /*********************************************************************** 6265c2c66affSColin Finck * CM_Query_Arbitrator_Free_Data [SETUPAPI.@] 6266c2c66affSColin Finck */ 626765d3bf74SEric Kohl CONFIGRET 626865d3bf74SEric Kohl WINAPI 626965d3bf74SEric Kohl CM_Query_Arbitrator_Free_Data( 627065d3bf74SEric Kohl _Out_writes_bytes_(DataLen) PVOID pData, 627165d3bf74SEric Kohl _In_ ULONG DataLen, 627265d3bf74SEric Kohl _In_ DEVINST dnDevInst, 627365d3bf74SEric Kohl _In_ RESOURCEID ResourceID, 627465d3bf74SEric Kohl _In_ ULONG ulFlags) 6275c2c66affSColin Finck { 627665d3bf74SEric Kohl TRACE("CM_Query_Arbitrator_Free_Data(%p %lu %lx %lu 0x%08lx)\n", 627765d3bf74SEric Kohl pData, DataLen, dnDevInst, ResourceID, ulFlags); 6278c2c66affSColin Finck 6279c2c66affSColin Finck return CM_Query_Arbitrator_Free_Data_Ex(pData, DataLen, dnDevInst, 6280c2c66affSColin Finck ResourceID, ulFlags, NULL); 6281c2c66affSColin Finck } 6282c2c66affSColin Finck 6283c2c66affSColin Finck 6284c2c66affSColin Finck /*********************************************************************** 6285c2c66affSColin Finck * CM_Query_Arbitrator_Free_Data_Ex [SETUPAPI.@] 6286c2c66affSColin Finck */ 628765d3bf74SEric Kohl CONFIGRET 628865d3bf74SEric Kohl WINAPI 628965d3bf74SEric Kohl CM_Query_Arbitrator_Free_Data_Ex( 629065d3bf74SEric Kohl _Out_writes_bytes_(DataLen) PVOID pData, 629165d3bf74SEric Kohl _In_ ULONG DataLen, 629265d3bf74SEric Kohl _In_ DEVINST dnDevInst, 629365d3bf74SEric Kohl _In_ RESOURCEID ResourceID, 629465d3bf74SEric Kohl _In_ ULONG ulFlags, 629565d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 6296c2c66affSColin Finck { 6297c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 6298c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 6299c2c66affSColin Finck LPWSTR lpDevInst; 6300c2c66affSColin Finck CONFIGRET ret; 6301c2c66affSColin Finck 630265d3bf74SEric Kohl TRACE("CM_Query_Arbitrator_Free_Data_Ex(%p %lu %lx %lu 0x%08lx %p)\n", 630365d3bf74SEric Kohl pData, DataLen, dnDevInst, ResourceID, ulFlags, hMachine); 6304c2c66affSColin Finck 6305c2c66affSColin Finck if (pData == NULL || DataLen == 0) 6306c2c66affSColin Finck return CR_INVALID_POINTER; 6307c2c66affSColin Finck 6308c2c66affSColin Finck if (dnDevInst == 0) 6309c2c66affSColin Finck return CR_INVALID_DEVINST; 6310c2c66affSColin Finck 6311c2c66affSColin Finck if (ulFlags & ~CM_QUERY_ARBITRATOR_BITS) 6312c2c66affSColin Finck return CR_INVALID_FLAG; 6313c2c66affSColin Finck 6314c2c66affSColin Finck if (hMachine != NULL) 6315c2c66affSColin Finck { 6316c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 6317c2c66affSColin Finck if (BindingHandle == NULL) 6318c2c66affSColin Finck return CR_FAILURE; 6319c2c66affSColin Finck 6320c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 6321c2c66affSColin Finck if (StringTable == 0) 6322c2c66affSColin Finck return CR_FAILURE; 6323c2c66affSColin Finck } 6324c2c66affSColin Finck else 6325c2c66affSColin Finck { 6326c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 6327c2c66affSColin Finck return CR_FAILURE; 6328c2c66affSColin Finck } 6329c2c66affSColin Finck 6330c2c66affSColin Finck lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst); 6331c2c66affSColin Finck if (lpDevInst == NULL) 6332c2c66affSColin Finck return CR_INVALID_DEVNODE; 6333c2c66affSColin Finck 6334c2c66affSColin Finck RpcTryExcept 6335c2c66affSColin Finck { 6336c2c66affSColin Finck ret = PNP_QueryArbitratorFreeData(BindingHandle, 6337c2c66affSColin Finck pData, 6338c2c66affSColin Finck DataLen, 6339c2c66affSColin Finck lpDevInst, 6340c2c66affSColin Finck ResourceID, 6341c2c66affSColin Finck ulFlags); 6342c2c66affSColin Finck } 6343c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 6344c2c66affSColin Finck { 6345c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 6346c2c66affSColin Finck } 6347c2c66affSColin Finck RpcEndExcept; 6348c2c66affSColin Finck 6349c2c66affSColin Finck return ret; 6350c2c66affSColin Finck } 6351c2c66affSColin Finck 6352c2c66affSColin Finck 6353c2c66affSColin Finck /*********************************************************************** 6354c2c66affSColin Finck * CM_Query_Arbitrator_Free_Size [SETUPAPI.@] 6355c2c66affSColin Finck */ 635665d3bf74SEric Kohl CONFIGRET 635765d3bf74SEric Kohl WINAPI 635865d3bf74SEric Kohl CM_Query_Arbitrator_Free_Size( 635965d3bf74SEric Kohl _Out_ PULONG pulSize, 636065d3bf74SEric Kohl _In_ DEVINST dnDevInst, 636165d3bf74SEric Kohl _In_ RESOURCEID ResourceID, 636265d3bf74SEric Kohl _In_ ULONG ulFlags) 6363c2c66affSColin Finck { 636465d3bf74SEric Kohl TRACE("CM_Query_Arbitrator_Free_Size(%p %lu %lx 0x%08lx)\n", 636565d3bf74SEric Kohl pulSize, dnDevInst,ResourceID, ulFlags); 6366c2c66affSColin Finck 6367c2c66affSColin Finck return CM_Query_Arbitrator_Free_Size_Ex(pulSize, dnDevInst, ResourceID, 6368c2c66affSColin Finck ulFlags, NULL); 6369c2c66affSColin Finck } 6370c2c66affSColin Finck 6371c2c66affSColin Finck 6372c2c66affSColin Finck /*********************************************************************** 6373c2c66affSColin Finck * CM_Query_Arbitrator_Free_Size_Ex [SETUPAPI.@] 6374c2c66affSColin Finck */ 637565d3bf74SEric Kohl CONFIGRET 637665d3bf74SEric Kohl WINAPI 637765d3bf74SEric Kohl CM_Query_Arbitrator_Free_Size_Ex( 637865d3bf74SEric Kohl _Out_ PULONG pulSize, 637965d3bf74SEric Kohl _In_ DEVINST dnDevInst, 638065d3bf74SEric Kohl _In_ RESOURCEID ResourceID, 638165d3bf74SEric Kohl _In_ ULONG ulFlags, 638265d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 6383c2c66affSColin Finck { 6384c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 6385c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 6386c2c66affSColin Finck LPWSTR lpDevInst; 6387c2c66affSColin Finck CONFIGRET ret; 6388c2c66affSColin Finck 638965d3bf74SEric Kohl TRACE("CM_Query_Arbitrator_Free_Size_Ex(%p %lu %lx 0x%08lx %p)\n", 639065d3bf74SEric Kohl pulSize, dnDevInst,ResourceID, ulFlags, hMachine); 6391c2c66affSColin Finck 6392c2c66affSColin Finck if (pulSize == NULL) 6393c2c66affSColin Finck return CR_INVALID_POINTER; 6394c2c66affSColin Finck 6395c2c66affSColin Finck if (dnDevInst == 0) 6396c2c66affSColin Finck return CR_INVALID_DEVINST; 6397c2c66affSColin Finck 6398c2c66affSColin Finck if (ulFlags & ~CM_QUERY_ARBITRATOR_BITS) 6399c2c66affSColin Finck return CR_INVALID_FLAG; 6400c2c66affSColin Finck 6401c2c66affSColin Finck if (hMachine != NULL) 6402c2c66affSColin Finck { 6403c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 6404c2c66affSColin Finck if (BindingHandle == NULL) 6405c2c66affSColin Finck return CR_FAILURE; 6406c2c66affSColin Finck 6407c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 6408c2c66affSColin Finck if (StringTable == 0) 6409c2c66affSColin Finck return CR_FAILURE; 6410c2c66affSColin Finck } 6411c2c66affSColin Finck else 6412c2c66affSColin Finck { 6413c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 6414c2c66affSColin Finck return CR_FAILURE; 6415c2c66affSColin Finck } 6416c2c66affSColin Finck 6417c2c66affSColin Finck lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst); 6418c2c66affSColin Finck if (lpDevInst == NULL) 6419c2c66affSColin Finck return CR_INVALID_DEVNODE; 6420c2c66affSColin Finck 6421c2c66affSColin Finck RpcTryExcept 6422c2c66affSColin Finck { 6423c2c66affSColin Finck ret = PNP_QueryArbitratorFreeSize(BindingHandle, 6424c2c66affSColin Finck pulSize, 6425c2c66affSColin Finck lpDevInst, 6426c2c66affSColin Finck ResourceID, 6427c2c66affSColin Finck ulFlags); 6428c2c66affSColin Finck } 6429c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 6430c2c66affSColin Finck { 6431c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 6432c2c66affSColin Finck } 6433c2c66affSColin Finck RpcEndExcept; 6434c2c66affSColin Finck 6435c2c66affSColin Finck return ret; 6436c2c66affSColin Finck } 6437c2c66affSColin Finck 6438c2c66affSColin Finck 6439c2c66affSColin Finck /*********************************************************************** 6440c2c66affSColin Finck * CM_Query_Remove_SubTree [SETUPAPI.@] 6441c2c66affSColin Finck * 6442c2c66affSColin Finck * This function is obsolete in Windows XP and above. 6443c2c66affSColin Finck */ 644465d3bf74SEric Kohl CONFIGRET 644565d3bf74SEric Kohl WINAPI 644665d3bf74SEric Kohl CM_Query_Remove_SubTree( 644765d3bf74SEric Kohl _In_ DEVINST dnAncestor, 644865d3bf74SEric Kohl _In_ ULONG ulFlags) 6449c2c66affSColin Finck { 645065d3bf74SEric Kohl TRACE("CM_Query_Remove_SubTree(%lx %lx)\n", 645165d3bf74SEric Kohl dnAncestor, ulFlags); 645265d3bf74SEric Kohl 6453c2c66affSColin Finck return CR_CALL_NOT_IMPLEMENTED; 6454c2c66affSColin Finck } 6455c2c66affSColin Finck 6456c2c66affSColin Finck 6457c2c66affSColin Finck /*********************************************************************** 6458c2c66affSColin Finck * CM_Query_Remove_SubTree_Ex [SETUPAPI.@] 6459c2c66affSColin Finck * 6460c2c66affSColin Finck * This function is obsolete in Windows XP and above. 6461c2c66affSColin Finck */ 646265d3bf74SEric Kohl CONFIGRET 646365d3bf74SEric Kohl WINAPI 646465d3bf74SEric Kohl CM_Query_Remove_SubTree_Ex( 646565d3bf74SEric Kohl _In_ DEVINST dnAncestor, 646665d3bf74SEric Kohl _In_ ULONG ulFlags, 646765d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 6468c2c66affSColin Finck { 646960a21894SEric Kohl TRACE("CM_Query_Remove_SubTree_Ex(%lx %lx %p)\n", 647065d3bf74SEric Kohl dnAncestor, ulFlags, hMachine); 647165d3bf74SEric Kohl 6472c2c66affSColin Finck return CR_CALL_NOT_IMPLEMENTED; 6473c2c66affSColin Finck } 6474c2c66affSColin Finck 6475c2c66affSColin Finck 6476c2c66affSColin Finck /*********************************************************************** 6477*d7e40954SEric Kohl * CM_Query_Resource_Conflict_List [SETUPAPI.@] 6478*d7e40954SEric Kohl */ 6479*d7e40954SEric Kohl CONFIGRET 6480*d7e40954SEric Kohl WINAPI 6481*d7e40954SEric Kohl CM_Query_Resource_Conflict_List( 6482*d7e40954SEric Kohl _Out_ PCONFLICT_LIST pclConflictList, 6483*d7e40954SEric Kohl _In_ DEVINST dnDevInst, 6484*d7e40954SEric Kohl _In_ RESOURCEID ResourceID, 6485*d7e40954SEric Kohl _In_ PCVOID ResourceData, 6486*d7e40954SEric Kohl _In_ ULONG ResourceLen, 6487*d7e40954SEric Kohl _In_ ULONG ulFlags, 6488*d7e40954SEric Kohl _In_opt_ HMACHINE hMachine) 6489*d7e40954SEric Kohl { 6490*d7e40954SEric Kohl FIXME("CM_Query_Resource_Conflict_List(%p %lx %lu %p %lu %lx %p)\n", 6491*d7e40954SEric Kohl pclConflictList, dnDevInst, ResourceID, ResourceData, 6492*d7e40954SEric Kohl ResourceLen, ulFlags, hMachine); 6493*d7e40954SEric Kohl 6494*d7e40954SEric Kohl return CR_CALL_NOT_IMPLEMENTED; 6495*d7e40954SEric Kohl } 6496*d7e40954SEric Kohl 6497*d7e40954SEric Kohl 6498*d7e40954SEric Kohl /*********************************************************************** 6499c2c66affSColin Finck * CM_Reenumerate_DevNode [SETUPAPI.@] 6500c2c66affSColin Finck */ 650165d3bf74SEric Kohl CONFIGRET 650265d3bf74SEric Kohl WINAPI 650365d3bf74SEric Kohl CM_Reenumerate_DevNode( 650465d3bf74SEric Kohl _In_ DEVINST dnDevInst, 650565d3bf74SEric Kohl _In_ ULONG ulFlags) 6506c2c66affSColin Finck { 650765d3bf74SEric Kohl TRACE("CM_Reenumerate_DevNode(%lx %lx)\n", 650865d3bf74SEric Kohl dnDevInst, ulFlags); 650965d3bf74SEric Kohl 6510c2c66affSColin Finck return CM_Reenumerate_DevNode_Ex(dnDevInst, ulFlags, NULL); 6511c2c66affSColin Finck } 6512c2c66affSColin Finck 6513c2c66affSColin Finck 6514c2c66affSColin Finck /*********************************************************************** 6515c2c66affSColin Finck * CM_Reenumerate_DevNode_Ex [SETUPAPI.@] 6516c2c66affSColin Finck */ 6517c2c66affSColin Finck CONFIGRET WINAPI 6518c2c66affSColin Finck CM_Reenumerate_DevNode_Ex( 6519c7fc2ef4SEric Kohl _In_ DEVINST dnDevInst, 6520c7fc2ef4SEric Kohl _In_ ULONG ulFlags, 652165d3bf74SEric Kohl _In_opt_ HMACHINE hMachine) 6522c2c66affSColin Finck { 6523c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 6524c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 6525c2c66affSColin Finck LPWSTR lpDevInst; 6526c2c66affSColin Finck CONFIGRET ret; 6527c2c66affSColin Finck 652860a21894SEric Kohl FIXME("CM_Reenumerate_DevNode_Ex(%lx %lx %p)\n", 652965d3bf74SEric Kohl dnDevInst, ulFlags, hMachine); 6530c2c66affSColin Finck 6531c2c66affSColin Finck if (dnDevInst == 0) 6532c2c66affSColin Finck return CR_INVALID_DEVNODE; 6533c2c66affSColin Finck 6534c2c66affSColin Finck if (ulFlags & ~CM_REENUMERATE_BITS) 6535c2c66affSColin Finck return CR_INVALID_FLAG; 6536c2c66affSColin Finck 6537c2c66affSColin Finck if (hMachine != NULL) 6538c2c66affSColin Finck { 6539c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 6540c2c66affSColin Finck if (BindingHandle == NULL) 6541c2c66affSColin Finck return CR_FAILURE; 6542c2c66affSColin Finck 6543c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 6544c2c66affSColin Finck if (StringTable == 0) 6545c2c66affSColin Finck return CR_FAILURE; 6546c2c66affSColin Finck } 6547c2c66affSColin Finck else 6548c2c66affSColin Finck { 6549c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 6550c2c66affSColin Finck return CR_FAILURE; 6551c2c66affSColin Finck } 6552c2c66affSColin Finck 6553c2c66affSColin Finck lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst); 6554c2c66affSColin Finck if (lpDevInst == NULL) 6555c2c66affSColin Finck return CR_INVALID_DEVNODE; 6556c2c66affSColin Finck 6557c2c66affSColin Finck RpcTryExcept 6558c2c66affSColin Finck { 6559c2c66affSColin Finck ret = PNP_DeviceInstanceAction(BindingHandle, 6560c2c66affSColin Finck PNP_DEVINST_REENUMERATE, 6561c2c66affSColin Finck ulFlags, 6562c2c66affSColin Finck lpDevInst, 6563c2c66affSColin Finck NULL); 6564c2c66affSColin Finck } 6565c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 6566c2c66affSColin Finck { 6567c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 6568c2c66affSColin Finck } 6569c2c66affSColin Finck RpcEndExcept; 6570c2c66affSColin Finck 6571c2c66affSColin Finck return ret; 6572c2c66affSColin Finck } 6573c2c66affSColin Finck 6574c2c66affSColin Finck 6575c2c66affSColin Finck /*********************************************************************** 657660a21894SEric Kohl * CM_Register_Device_Driver [SETUPAPI.@] 657760a21894SEric Kohl */ 657860a21894SEric Kohl CONFIGRET 657960a21894SEric Kohl WINAPI 658060a21894SEric Kohl CM_Register_Device_Driver( 658160a21894SEric Kohl _In_ DEVINST dnDevInst, 658260a21894SEric Kohl _In_ ULONG ulFlags) 658360a21894SEric Kohl { 658460a21894SEric Kohl TRACE("CM_Register_Device_Driver(%lx 0x%08lx)\n", 658560a21894SEric Kohl dnDevInst, ulFlags); 658660a21894SEric Kohl 658760a21894SEric Kohl return CM_Register_Device_Driver_Ex(dnDevInst, ulFlags, NULL); 658860a21894SEric Kohl } 658960a21894SEric Kohl 659060a21894SEric Kohl 659160a21894SEric Kohl /*********************************************************************** 659260a21894SEric Kohl * CM_Register_Device_Driver_Ex [SETUPAPI.@] 659360a21894SEric Kohl */ 659460a21894SEric Kohl CONFIGRET 659560a21894SEric Kohl WINAPI 659660a21894SEric Kohl CM_Register_Device_Driver_Ex( 659760a21894SEric Kohl _In_ DEVINST dnDevInst, 659860a21894SEric Kohl _In_ ULONG ulFlags, 659960a21894SEric Kohl _In_opt_ HMACHINE hMachine) 660060a21894SEric Kohl { 660160a21894SEric Kohl RPC_BINDING_HANDLE BindingHandle = NULL; 660260a21894SEric Kohl HSTRING_TABLE StringTable = NULL; 660360a21894SEric Kohl LPWSTR lpDevInst; 660460a21894SEric Kohl CONFIGRET ret; 660560a21894SEric Kohl 660660a21894SEric Kohl TRACE("CM_Register_Device_Driver_Ex(%lx 0x%08lx %p)\n", 660760a21894SEric Kohl dnDevInst, ulFlags, hMachine); 660860a21894SEric Kohl 660960a21894SEric Kohl if (dnDevInst == 0) 661060a21894SEric Kohl return CR_INVALID_DEVNODE; 661160a21894SEric Kohl 661260a21894SEric Kohl if (ulFlags & ~CM_REGISTER_DEVICE_DRIVER_BITS) 661360a21894SEric Kohl return CR_INVALID_FLAG; 661460a21894SEric Kohl 661560a21894SEric Kohl if (hMachine != NULL) 661660a21894SEric Kohl { 661760a21894SEric Kohl BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 661860a21894SEric Kohl if (BindingHandle == NULL) 661960a21894SEric Kohl return CR_FAILURE; 662060a21894SEric Kohl 662160a21894SEric Kohl StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 662260a21894SEric Kohl if (StringTable == 0) 662360a21894SEric Kohl return CR_FAILURE; 662460a21894SEric Kohl } 662560a21894SEric Kohl else 662660a21894SEric Kohl { 662760a21894SEric Kohl if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 662860a21894SEric Kohl return CR_FAILURE; 662960a21894SEric Kohl } 663060a21894SEric Kohl 663160a21894SEric Kohl lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst); 663260a21894SEric Kohl if (lpDevInst == NULL) 663360a21894SEric Kohl return CR_INVALID_DEVNODE; 663460a21894SEric Kohl 663560a21894SEric Kohl RpcTryExcept 663660a21894SEric Kohl { 663760a21894SEric Kohl ret = PNP_RegisterDriver(BindingHandle, 663860a21894SEric Kohl lpDevInst, 663960a21894SEric Kohl ulFlags); 664060a21894SEric Kohl } 664160a21894SEric Kohl RpcExcept(EXCEPTION_EXECUTE_HANDLER) 664260a21894SEric Kohl { 664360a21894SEric Kohl ret = RpcStatusToCmStatus(RpcExceptionCode()); 664460a21894SEric Kohl } 664560a21894SEric Kohl RpcEndExcept; 664660a21894SEric Kohl 664760a21894SEric Kohl return ret; 664860a21894SEric Kohl } 664960a21894SEric Kohl 665060a21894SEric Kohl 665160a21894SEric Kohl /*********************************************************************** 6652c2c66affSColin Finck * CM_Register_Device_InterfaceA [SETUPAPI.@] 6653c2c66affSColin Finck */ 665460a21894SEric Kohl CONFIGRET 665560a21894SEric Kohl WINAPI 665660a21894SEric Kohl CM_Register_Device_InterfaceA( 665760a21894SEric Kohl _In_ DEVINST dnDevInst, 665860a21894SEric Kohl _In_ LPGUID InterfaceClassGuid, 665960a21894SEric Kohl _In_opt_ LPCSTR pszReference, 666060a21894SEric Kohl _Out_writes_(*pulLength) LPSTR pszDeviceInterface, 666160a21894SEric Kohl _Inout_ PULONG pulLength, 666260a21894SEric Kohl _In_ ULONG ulFlags) 6663c2c66affSColin Finck { 666460a21894SEric Kohl TRACE("CM_Register_Device_InterfaceA(%lx %s %s %p %p %lx)\n", 666560a21894SEric Kohl dnDevInst, debugstr_guid(InterfaceClassGuid), 6666c2c66affSColin Finck pszReference, pszDeviceInterface, pulLength, ulFlags); 6667c2c66affSColin Finck 6668c2c66affSColin Finck return CM_Register_Device_Interface_ExA(dnDevInst, InterfaceClassGuid, 6669c2c66affSColin Finck pszReference, pszDeviceInterface, 6670c2c66affSColin Finck pulLength, ulFlags, NULL); 6671c2c66affSColin Finck } 6672c2c66affSColin Finck 6673c2c66affSColin Finck 6674c2c66affSColin Finck /*********************************************************************** 6675c2c66affSColin Finck * CM_Register_Device_InterfaceW [SETUPAPI.@] 6676c2c66affSColin Finck */ 667760a21894SEric Kohl CONFIGRET 667860a21894SEric Kohl WINAPI 667960a21894SEric Kohl CM_Register_Device_InterfaceW( 668060a21894SEric Kohl _In_ DEVINST dnDevInst, 668160a21894SEric Kohl _In_ LPGUID InterfaceClassGuid, 668260a21894SEric Kohl _In_opt_ LPCWSTR pszReference, 668360a21894SEric Kohl _Out_writes_(*pulLength) LPWSTR pszDeviceInterface, 668460a21894SEric Kohl _Inout_ PULONG pulLength, 668560a21894SEric Kohl _In_ ULONG ulFlags) 6686c2c66affSColin Finck { 668760a21894SEric Kohl TRACE("CM_Register_Device_InterfaceW(%lx %s %s %p %p %lx)\n", 668860a21894SEric Kohl dnDevInst, debugstr_guid(InterfaceClassGuid), 6689c2c66affSColin Finck debugstr_w(pszReference), pszDeviceInterface, pulLength, ulFlags); 6690c2c66affSColin Finck 6691c2c66affSColin Finck return CM_Register_Device_Interface_ExW(dnDevInst, InterfaceClassGuid, 6692c2c66affSColin Finck pszReference, pszDeviceInterface, 6693c2c66affSColin Finck pulLength, ulFlags, NULL); 6694c2c66affSColin Finck } 6695c2c66affSColin Finck 6696c2c66affSColin Finck 6697c2c66affSColin Finck /*********************************************************************** 6698c2c66affSColin Finck * CM_Register_Device_Interface_ExA [SETUPAPI.@] 6699c2c66affSColin Finck */ 670060a21894SEric Kohl CONFIGRET 670160a21894SEric Kohl WINAPI 670260a21894SEric Kohl CM_Register_Device_Interface_ExA( 670360a21894SEric Kohl _In_ DEVINST dnDevInst, 670460a21894SEric Kohl _In_ LPGUID InterfaceClassGuid, 670560a21894SEric Kohl _In_opt_ LPCSTR pszReference, 670660a21894SEric Kohl _Out_writes_(*pulLength) LPSTR pszDeviceInterface, 670760a21894SEric Kohl _Inout_ PULONG pulLength, 670860a21894SEric Kohl _In_ ULONG ulFlags, 670960a21894SEric Kohl _In_opt_ HMACHINE hMachine) 6710c2c66affSColin Finck { 6711c2c66affSColin Finck LPWSTR pszReferenceW = NULL; 6712c2c66affSColin Finck LPWSTR pszDeviceInterfaceW = NULL; 6713c2c66affSColin Finck ULONG ulLength; 6714c2c66affSColin Finck CONFIGRET ret; 6715c2c66affSColin Finck 671660a21894SEric Kohl TRACE("CM_Register_Device_Interface_ExA(%lx %s %s %p %p %lx %p)\n", 671760a21894SEric Kohl dnDevInst, debugstr_guid(InterfaceClassGuid), debugstr_a(pszReference), 671860a21894SEric Kohl pszDeviceInterface, pulLength, ulFlags, hMachine); 6719c2c66affSColin Finck 6720c2c66affSColin Finck if (pulLength == NULL || pszDeviceInterface == NULL) 6721c2c66affSColin Finck return CR_INVALID_POINTER; 6722c2c66affSColin Finck 6723c2c66affSColin Finck if (pszReference != NULL) 6724c2c66affSColin Finck { 6725c2c66affSColin Finck if (pSetupCaptureAndConvertAnsiArg(pszReference, &pszReferenceW)) 6726c2c66affSColin Finck return CR_INVALID_DATA; 6727c2c66affSColin Finck } 6728c2c66affSColin Finck 6729c2c66affSColin Finck ulLength = *pulLength; 6730c2c66affSColin Finck 6731c2c66affSColin Finck pszDeviceInterfaceW = HeapAlloc(GetProcessHeap(), 0, ulLength * sizeof(WCHAR)); 6732c2c66affSColin Finck if (pszDeviceInterfaceW == NULL) 6733c2c66affSColin Finck { 6734c2c66affSColin Finck ret = CR_OUT_OF_MEMORY; 6735c2c66affSColin Finck goto Done; 6736c2c66affSColin Finck } 6737c2c66affSColin Finck 6738c2c66affSColin Finck ret = CM_Register_Device_Interface_ExW(dnDevInst, 6739c2c66affSColin Finck InterfaceClassGuid, 6740c2c66affSColin Finck pszReferenceW, 6741c2c66affSColin Finck pszDeviceInterfaceW, 6742c2c66affSColin Finck &ulLength, 6743c2c66affSColin Finck ulFlags, 6744c2c66affSColin Finck hMachine); 6745c2c66affSColin Finck if (ret == CR_SUCCESS) 6746c2c66affSColin Finck { 6747c2c66affSColin Finck if (WideCharToMultiByte(CP_ACP, 6748c2c66affSColin Finck 0, 6749c2c66affSColin Finck pszDeviceInterfaceW, 6750c2c66affSColin Finck ulLength, 6751c2c66affSColin Finck pszDeviceInterface, 6752c2c66affSColin Finck *pulLength, 6753c2c66affSColin Finck NULL, 6754c2c66affSColin Finck NULL) == 0) 6755c2c66affSColin Finck ret = CR_FAILURE; 6756c2c66affSColin Finck } 6757c2c66affSColin Finck 6758c2c66affSColin Finck *pulLength = ulLength; 6759c2c66affSColin Finck 6760c2c66affSColin Finck Done: 6761c2c66affSColin Finck if (pszDeviceInterfaceW != NULL) 6762c2c66affSColin Finck HeapFree(GetProcessHeap(), 0, pszDeviceInterfaceW); 6763c2c66affSColin Finck 6764c2c66affSColin Finck if (pszReferenceW != NULL) 6765c2c66affSColin Finck MyFree(pszReferenceW); 6766c2c66affSColin Finck 6767c2c66affSColin Finck return ret; 6768c2c66affSColin Finck } 6769c2c66affSColin Finck 6770c2c66affSColin Finck 6771c2c66affSColin Finck /*********************************************************************** 6772c2c66affSColin Finck * CM_Register_Device_Interface_ExW [SETUPAPI.@] 6773c2c66affSColin Finck */ 677460a21894SEric Kohl CONFIGRET 677560a21894SEric Kohl WINAPI 677660a21894SEric Kohl CM_Register_Device_Interface_ExW( 677760a21894SEric Kohl _In_ DEVINST dnDevInst, 677860a21894SEric Kohl _In_ LPGUID InterfaceClassGuid, 677960a21894SEric Kohl _In_opt_ LPCWSTR pszReference, 678060a21894SEric Kohl _Out_writes_(*pulLength) LPWSTR pszDeviceInterface, 678160a21894SEric Kohl _Inout_ PULONG pulLength, 678260a21894SEric Kohl _In_ ULONG ulFlags, 678360a21894SEric Kohl _In_opt_ HMACHINE hMachine) 6784c2c66affSColin Finck { 6785c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 6786c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 6787c2c66affSColin Finck LPWSTR lpDevInst; 6788c2c66affSColin Finck ULONG ulTransferLength; 6789c2c66affSColin Finck CONFIGRET ret; 6790c2c66affSColin Finck 679160a21894SEric Kohl TRACE("CM_Register_Device_Interface_ExW(%lx %s %s %p %p %lx %p)\n", 679260a21894SEric Kohl dnDevInst, debugstr_guid(InterfaceClassGuid), debugstr_w(pszReference), 679360a21894SEric Kohl pszDeviceInterface, pulLength, ulFlags, hMachine); 6794c2c66affSColin Finck 6795c2c66affSColin Finck if (dnDevInst == 0) 6796c2c66affSColin Finck return CR_INVALID_DEVNODE; 6797c2c66affSColin Finck 6798c2c66affSColin Finck if (InterfaceClassGuid == NULL || 6799c2c66affSColin Finck pszDeviceInterface == NULL || 6800c2c66affSColin Finck pulLength == NULL) 6801c2c66affSColin Finck return CR_INVALID_POINTER; 6802c2c66affSColin Finck 6803c2c66affSColin Finck if (ulFlags != 0) 6804c2c66affSColin Finck return CR_INVALID_FLAG; 6805c2c66affSColin Finck 6806c2c66affSColin Finck if (hMachine != NULL) 6807c2c66affSColin Finck { 6808c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 6809c2c66affSColin Finck if (BindingHandle == NULL) 6810c2c66affSColin Finck return CR_FAILURE; 6811c2c66affSColin Finck 6812c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 6813c2c66affSColin Finck if (StringTable == 0) 6814c2c66affSColin Finck return CR_FAILURE; 6815c2c66affSColin Finck } 6816c2c66affSColin Finck else 6817c2c66affSColin Finck { 6818c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 6819c2c66affSColin Finck return CR_FAILURE; 6820c2c66affSColin Finck } 6821c2c66affSColin Finck 6822c2c66affSColin Finck lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst); 6823c2c66affSColin Finck if (lpDevInst == NULL) 6824c2c66affSColin Finck return CR_INVALID_DEVNODE; 6825c2c66affSColin Finck 6826c2c66affSColin Finck ulTransferLength = *pulLength; 6827c2c66affSColin Finck 6828c2c66affSColin Finck RpcTryExcept 6829c2c66affSColin Finck { 6830c2c66affSColin Finck ret = PNP_RegisterDeviceClassAssociation(BindingHandle, 6831c2c66affSColin Finck lpDevInst, 6832c2c66affSColin Finck InterfaceClassGuid, 6833c2c66affSColin Finck (LPWSTR)pszReference, 6834c2c66affSColin Finck pszDeviceInterface, 6835c2c66affSColin Finck pulLength, 6836c2c66affSColin Finck &ulTransferLength, 6837c2c66affSColin Finck 0); 6838c2c66affSColin Finck } 6839c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 6840c2c66affSColin Finck { 6841c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 6842c2c66affSColin Finck } 6843c2c66affSColin Finck RpcEndExcept; 6844c2c66affSColin Finck 6845c2c66affSColin Finck return ret; 6846c2c66affSColin Finck } 6847c2c66affSColin Finck 6848c2c66affSColin Finck 6849c2c66affSColin Finck /*********************************************************************** 6850c2c66affSColin Finck * CM_Remove_SubTree [SETUPAPI.@] 6851c2c66affSColin Finck * 6852c2c66affSColin Finck * This function is obsolete in Windows XP and above. 6853c2c66affSColin Finck */ 685460a21894SEric Kohl CONFIGRET 685560a21894SEric Kohl WINAPI 685660a21894SEric Kohl CM_Remove_SubTree( 685760a21894SEric Kohl _In_ DEVINST dnAncestor, 685860a21894SEric Kohl _In_ ULONG ulFlags) 6859c2c66affSColin Finck { 686060a21894SEric Kohl TRACE("CM_Remove_SubTree(%lx %lx)\n", 686160a21894SEric Kohl dnAncestor, ulFlags); 686260a21894SEric Kohl 6863c2c66affSColin Finck return CR_CALL_NOT_IMPLEMENTED; 6864c2c66affSColin Finck } 6865c2c66affSColin Finck 6866c2c66affSColin Finck 6867c2c66affSColin Finck /*********************************************************************** 6868c2c66affSColin Finck * CM_Remove_SubTree_Ex [SETUPAPI.@] 6869c2c66affSColin Finck * 6870c2c66affSColin Finck * This function is obsolete in Windows XP and above. 6871c2c66affSColin Finck */ 687260a21894SEric Kohl CONFIGRET 687360a21894SEric Kohl WINAPI 687460a21894SEric Kohl CM_Remove_SubTree_Ex( 687560a21894SEric Kohl _In_ DEVINST dnAncestor, 687660a21894SEric Kohl _In_ ULONG ulFlags, 687760a21894SEric Kohl _In_opt_ HMACHINE hMachine) 6878c2c66affSColin Finck { 687960a21894SEric Kohl TRACE("CM_Remove_SubTree_Ex(%lx %lx %p)\n", 688060a21894SEric Kohl dnAncestor, ulFlags, hMachine); 688160a21894SEric Kohl 6882c2c66affSColin Finck return CR_CALL_NOT_IMPLEMENTED; 6883c2c66affSColin Finck } 6884c2c66affSColin Finck 6885c2c66affSColin Finck 6886c2c66affSColin Finck /*********************************************************************** 6887c2c66affSColin Finck * CM_Request_Device_EjectA [SETUPAPI.@] 6888c2c66affSColin Finck */ 688960a21894SEric Kohl CONFIGRET 689060a21894SEric Kohl WINAPI 689160a21894SEric Kohl CM_Request_Device_EjectA( 689260a21894SEric Kohl _In_ DEVINST dnDevInst, 689360a21894SEric Kohl _Out_opt_ PPNP_VETO_TYPE pVetoType, 689460a21894SEric Kohl _Out_writes_opt_(ulNameLength) LPSTR pszVetoName, 689560a21894SEric Kohl _In_ ULONG ulNameLength, 689660a21894SEric Kohl _In_ ULONG ulFlags) 6897c2c66affSColin Finck { 689860a21894SEric Kohl TRACE("CM_Request_Device_EjectA(%lx %p %s %lu %lx)\n", 689960a21894SEric Kohl dnDevInst, pVetoType, debugstr_a(pszVetoName), ulNameLength, ulFlags); 690060a21894SEric Kohl 6901c2c66affSColin Finck return CM_Request_Device_Eject_ExA(dnDevInst, pVetoType, pszVetoName, 6902c2c66affSColin Finck ulNameLength, ulFlags, NULL); 6903c2c66affSColin Finck } 6904c2c66affSColin Finck 6905c2c66affSColin Finck 6906c2c66affSColin Finck /*********************************************************************** 6907c2c66affSColin Finck * CM_Request_Device_EjectW [SETUPAPI.@] 6908c2c66affSColin Finck */ 690960a21894SEric Kohl CONFIGRET 691060a21894SEric Kohl WINAPI 691160a21894SEric Kohl CM_Request_Device_EjectW( 691260a21894SEric Kohl _In_ DEVINST dnDevInst, 691360a21894SEric Kohl _Out_opt_ PPNP_VETO_TYPE pVetoType, 691460a21894SEric Kohl _Out_writes_opt_(ulNameLength) LPWSTR pszVetoName, 691560a21894SEric Kohl _In_ ULONG ulNameLength, 691660a21894SEric Kohl _In_ ULONG ulFlags) 6917c2c66affSColin Finck { 691860a21894SEric Kohl TRACE("CM_Request_Device_EjectW(%lx %p %s %lu %lx)\n", 691960a21894SEric Kohl dnDevInst, pVetoType, debugstr_w(pszVetoName), ulNameLength, ulFlags); 692060a21894SEric Kohl 6921c2c66affSColin Finck return CM_Request_Device_Eject_ExW(dnDevInst, pVetoType, pszVetoName, 6922c2c66affSColin Finck ulNameLength, ulFlags, NULL); 6923c2c66affSColin Finck } 6924c2c66affSColin Finck 6925c2c66affSColin Finck 6926c2c66affSColin Finck /*********************************************************************** 6927c2c66affSColin Finck * CM_Request_Device_Eject_ExA [SETUPAPI.@] 6928c2c66affSColin Finck */ 692960a21894SEric Kohl CONFIGRET 693060a21894SEric Kohl WINAPI 693160a21894SEric Kohl CM_Request_Device_Eject_ExA( 693260a21894SEric Kohl _In_ DEVINST dnDevInst, 693360a21894SEric Kohl _Out_opt_ PPNP_VETO_TYPE pVetoType, 693460a21894SEric Kohl _Out_writes_opt_(ulNameLength) LPSTR pszVetoName, 693560a21894SEric Kohl _In_ ULONG ulNameLength, 693660a21894SEric Kohl _In_ ULONG ulFlags, 693760a21894SEric Kohl _In_opt_ HMACHINE hMachine) 6938c2c66affSColin Finck { 6939c2c66affSColin Finck LPWSTR lpLocalVetoName; 6940c2c66affSColin Finck CONFIGRET ret; 6941c2c66affSColin Finck 694260a21894SEric Kohl TRACE("CM_Request_Device_Eject_ExA(%lx %p %s %lu %lx %p)\n", 694360a21894SEric Kohl dnDevInst, pVetoType, debugstr_a(pszVetoName), ulNameLength, ulFlags, hMachine); 6944c2c66affSColin Finck 6945c2c66affSColin Finck if (pszVetoName == NULL && ulNameLength == 0) 6946c2c66affSColin Finck return CR_INVALID_POINTER; 6947c2c66affSColin Finck 6948c2c66affSColin Finck lpLocalVetoName = HeapAlloc(GetProcessHeap(), 0, ulNameLength * sizeof(WCHAR)); 6949c2c66affSColin Finck if (lpLocalVetoName == NULL) 6950c2c66affSColin Finck return CR_OUT_OF_MEMORY; 6951c2c66affSColin Finck 6952c2c66affSColin Finck ret = CM_Request_Device_Eject_ExW(dnDevInst, pVetoType, lpLocalVetoName, 6953c2c66affSColin Finck ulNameLength, ulFlags, hMachine); 6954c2c66affSColin Finck if (ret == CR_REMOVE_VETOED) 6955c2c66affSColin Finck { 6956c2c66affSColin Finck if (WideCharToMultiByte(CP_ACP, 6957c2c66affSColin Finck 0, 6958c2c66affSColin Finck lpLocalVetoName, 6959c2c66affSColin Finck ulNameLength, 6960c2c66affSColin Finck pszVetoName, 6961c2c66affSColin Finck ulNameLength, 6962c2c66affSColin Finck NULL, 6963c2c66affSColin Finck NULL) == 0) 6964c2c66affSColin Finck ret = CR_FAILURE; 6965c2c66affSColin Finck } 6966c2c66affSColin Finck 6967c2c66affSColin Finck HeapFree(GetProcessHeap(), 0, lpLocalVetoName); 6968c2c66affSColin Finck 6969c2c66affSColin Finck return ret; 6970c2c66affSColin Finck } 6971c2c66affSColin Finck 6972c2c66affSColin Finck 6973c2c66affSColin Finck /*********************************************************************** 6974c2c66affSColin Finck * CM_Request_Device_Eject_ExW [SETUPAPI.@] 6975c2c66affSColin Finck */ 697660a21894SEric Kohl CONFIGRET 697760a21894SEric Kohl WINAPI 697860a21894SEric Kohl CM_Request_Device_Eject_ExW( 697960a21894SEric Kohl _In_ DEVINST dnDevInst, 698060a21894SEric Kohl _Out_opt_ PPNP_VETO_TYPE pVetoType, 698160a21894SEric Kohl _Out_writes_opt_(ulNameLength) LPWSTR pszVetoName, 698260a21894SEric Kohl _In_ ULONG ulNameLength, 698360a21894SEric Kohl _In_ ULONG ulFlags, 698460a21894SEric Kohl _In_opt_ HMACHINE hMachine) 6985c2c66affSColin Finck { 6986c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 6987c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 6988c2c66affSColin Finck LPWSTR lpDevInst; 6989c2c66affSColin Finck CONFIGRET ret; 6990c2c66affSColin Finck 699160a21894SEric Kohl TRACE("CM_Request_Device_Eject_ExW(%lx %p %s %lu %lx %p)\n", 699260a21894SEric Kohl dnDevInst, pVetoType, debugstr_w(pszVetoName), ulNameLength, ulFlags, hMachine); 6993c2c66affSColin Finck 6994c2c66affSColin Finck if (dnDevInst == 0) 6995c2c66affSColin Finck return CR_INVALID_DEVNODE; 6996c2c66affSColin Finck 6997c2c66affSColin Finck if (ulFlags != 0) 6998c2c66affSColin Finck return CR_INVALID_FLAG; 6999c2c66affSColin Finck 7000c2c66affSColin Finck if (pszVetoName == NULL && ulNameLength == 0) 7001c2c66affSColin Finck return CR_INVALID_POINTER; 7002c2c66affSColin Finck 7003c2c66affSColin Finck if (hMachine != NULL) 7004c2c66affSColin Finck { 7005c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 7006c2c66affSColin Finck if (BindingHandle == NULL) 7007c2c66affSColin Finck return CR_FAILURE; 7008c2c66affSColin Finck 7009c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 7010c2c66affSColin Finck if (StringTable == 0) 7011c2c66affSColin Finck return CR_FAILURE; 7012c2c66affSColin Finck } 7013c2c66affSColin Finck else 7014c2c66affSColin Finck { 7015c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 7016c2c66affSColin Finck return CR_FAILURE; 7017c2c66affSColin Finck } 7018c2c66affSColin Finck 7019c2c66affSColin Finck lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst); 7020c2c66affSColin Finck if (lpDevInst == NULL) 7021c2c66affSColin Finck return CR_INVALID_DEVNODE; 7022c2c66affSColin Finck 7023c2c66affSColin Finck RpcTryExcept 7024c2c66affSColin Finck { 7025c2c66affSColin Finck ret = PNP_RequestDeviceEject(BindingHandle, 7026c2c66affSColin Finck lpDevInst, 7027c2c66affSColin Finck pVetoType, 7028c2c66affSColin Finck pszVetoName, 7029c2c66affSColin Finck ulNameLength, 7030c2c66affSColin Finck ulFlags); 7031c2c66affSColin Finck } 7032c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 7033c2c66affSColin Finck { 7034c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 7035c2c66affSColin Finck } 7036c2c66affSColin Finck RpcEndExcept; 7037c2c66affSColin Finck 7038c2c66affSColin Finck return ret; 7039c2c66affSColin Finck } 7040c2c66affSColin Finck 7041c2c66affSColin Finck 7042c2c66affSColin Finck /*********************************************************************** 7043c2c66affSColin Finck * CM_Request_Eject_PC [SETUPAPI.@] 7044c2c66affSColin Finck */ 704560a21894SEric Kohl CONFIGRET 704660a21894SEric Kohl WINAPI 704760a21894SEric Kohl CM_Request_Eject_PC(VOID) 7048c2c66affSColin Finck { 704960a21894SEric Kohl TRACE("CM_Request_Eject_PC()\n"); 705060a21894SEric Kohl 7051c2c66affSColin Finck return CM_Request_Eject_PC_Ex(NULL); 7052c2c66affSColin Finck } 7053c2c66affSColin Finck 7054c2c66affSColin Finck 7055c2c66affSColin Finck /*********************************************************************** 7056c2c66affSColin Finck * CM_Request_Eject_PC_Ex [SETUPAPI.@] 7057c2c66affSColin Finck */ 705860a21894SEric Kohl CONFIGRET 705960a21894SEric Kohl WINAPI 706060a21894SEric Kohl CM_Request_Eject_PC_Ex( 706160a21894SEric Kohl _In_opt_ HMACHINE hMachine) 7062c2c66affSColin Finck { 7063c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 7064c2c66affSColin Finck CONFIGRET ret; 7065c2c66affSColin Finck 706660a21894SEric Kohl TRACE("CM_Request_Eject_PC_Ex(%p)\n", hMachine); 7067c2c66affSColin Finck 7068c2c66affSColin Finck if (hMachine != NULL) 7069c2c66affSColin Finck { 7070c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 7071c2c66affSColin Finck if (BindingHandle == NULL) 7072c2c66affSColin Finck return CR_FAILURE; 7073c2c66affSColin Finck } 7074c2c66affSColin Finck else 7075c2c66affSColin Finck { 7076c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 7077c2c66affSColin Finck return CR_FAILURE; 7078c2c66affSColin Finck } 7079c2c66affSColin Finck 7080c2c66affSColin Finck RpcTryExcept 7081c2c66affSColin Finck { 7082c2c66affSColin Finck ret = PNP_RequestEjectPC(BindingHandle); 7083c2c66affSColin Finck } 7084c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 7085c2c66affSColin Finck { 7086c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 7087c2c66affSColin Finck } 7088c2c66affSColin Finck RpcEndExcept; 7089c2c66affSColin Finck 7090c2c66affSColin Finck return ret; 7091c2c66affSColin Finck } 7092c2c66affSColin Finck 7093c2c66affSColin Finck 7094c2c66affSColin Finck /*********************************************************************** 7095c2c66affSColin Finck * CM_Run_Detection [SETUPAPI.@] 7096c2c66affSColin Finck */ 709760a21894SEric Kohl CONFIGRET 709860a21894SEric Kohl WINAPI 709960a21894SEric Kohl CM_Run_Detection( 710060a21894SEric Kohl _In_ ULONG ulFlags) 7101c2c66affSColin Finck { 710260a21894SEric Kohl TRACE("CM_Run_Detection(%lx)\n", ulFlags); 710360a21894SEric Kohl 7104c2c66affSColin Finck return CM_Run_Detection_Ex(ulFlags, NULL); 7105c2c66affSColin Finck } 7106c2c66affSColin Finck 7107c2c66affSColin Finck 7108c2c66affSColin Finck /*********************************************************************** 7109c2c66affSColin Finck * CM_Run_Detection_Ex [SETUPAPI.@] 7110c2c66affSColin Finck */ 711160a21894SEric Kohl CONFIGRET 711260a21894SEric Kohl WINAPI 711360a21894SEric Kohl CM_Run_Detection_Ex( 711460a21894SEric Kohl _In_ ULONG ulFlags, 711560a21894SEric Kohl _In_opt_ HMACHINE hMachine) 7116c2c66affSColin Finck { 7117c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 7118c2c66affSColin Finck CONFIGRET ret; 7119c2c66affSColin Finck 712060a21894SEric Kohl TRACE("CM_Run_Detection_Ex(%lx %p)\n", 712160a21894SEric Kohl ulFlags, hMachine); 7122c2c66affSColin Finck 7123c2c66affSColin Finck if (!pSetupIsUserAdmin()) 7124c2c66affSColin Finck return CR_ACCESS_DENIED; 7125c2c66affSColin Finck 7126c2c66affSColin Finck if (ulFlags & ~CM_DETECT_BITS) 7127c2c66affSColin Finck return CR_INVALID_FLAG; 7128c2c66affSColin Finck 7129c2c66affSColin Finck if (hMachine != NULL) 7130c2c66affSColin Finck { 7131c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 7132c2c66affSColin Finck if (BindingHandle == NULL) 7133c2c66affSColin Finck return CR_FAILURE; 7134c2c66affSColin Finck } 7135c2c66affSColin Finck else 7136c2c66affSColin Finck { 7137c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 7138c2c66affSColin Finck return CR_FAILURE; 7139c2c66affSColin Finck } 7140c2c66affSColin Finck 7141c2c66affSColin Finck RpcTryExcept 7142c2c66affSColin Finck { 7143c2c66affSColin Finck ret = PNP_RunDetection(BindingHandle, 7144c2c66affSColin Finck ulFlags); 7145c2c66affSColin Finck } 7146c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 7147c2c66affSColin Finck { 7148c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 7149c2c66affSColin Finck } 7150c2c66affSColin Finck RpcEndExcept; 7151c2c66affSColin Finck 7152c2c66affSColin Finck return ret; 7153c2c66affSColin Finck } 7154c2c66affSColin Finck 7155c2c66affSColin Finck 7156c2c66affSColin Finck /*********************************************************************** 7157c2c66affSColin Finck * CM_Set_Class_Registry_PropertyA [SETUPAPI.@] 7158c2c66affSColin Finck */ 715960a21894SEric Kohl CONFIGRET 716060a21894SEric Kohl WINAPI 716160a21894SEric Kohl CM_Set_Class_Registry_PropertyA( 716260a21894SEric Kohl _In_ LPGUID ClassGuid, 716360a21894SEric Kohl _In_ ULONG ulProperty, 716460a21894SEric Kohl _In_reads_bytes_opt_(ulLength) PCVOID Buffer, 716560a21894SEric Kohl _In_ ULONG ulLength, 716660a21894SEric Kohl _In_ ULONG ulFlags, 716760a21894SEric Kohl _In_opt_ HMACHINE hMachine) 7168c2c66affSColin Finck { 716960a21894SEric Kohl FIXME("CM_Set_Class_Registry_PropertyA(%p %lx %p %lu %lx %p)\n", 7170c2c66affSColin Finck ClassGuid, ulProperty, Buffer, ulLength, ulFlags, hMachine); 717160a21894SEric Kohl 7172c2c66affSColin Finck return CR_CALL_NOT_IMPLEMENTED; 7173c2c66affSColin Finck } 7174c2c66affSColin Finck 7175c2c66affSColin Finck 7176c2c66affSColin Finck /*********************************************************************** 7177c2c66affSColin Finck * CM_Set_Class_Registry_PropertyW [SETUPAPI.@] 7178c2c66affSColin Finck */ 717960a21894SEric Kohl CONFIGRET 718060a21894SEric Kohl WINAPI 718160a21894SEric Kohl CM_Set_Class_Registry_PropertyW( 718260a21894SEric Kohl _In_ LPGUID ClassGuid, 718360a21894SEric Kohl _In_ ULONG ulProperty, 718460a21894SEric Kohl _In_reads_bytes_opt_(ulLength) PCVOID Buffer, 718560a21894SEric Kohl _In_ ULONG ulLength, 718660a21894SEric Kohl _In_ ULONG ulFlags, 718760a21894SEric Kohl _In_opt_ HMACHINE hMachine) 7188c2c66affSColin Finck { 718960a21894SEric Kohl FIXME("CM_Set_Class_Registry_PropertyW(%p %lx %p %lu %lx %p)\n", 7190c2c66affSColin Finck ClassGuid, ulProperty, Buffer, ulLength, ulFlags, hMachine); 719160a21894SEric Kohl 7192c2c66affSColin Finck return CR_CALL_NOT_IMPLEMENTED; 7193c2c66affSColin Finck } 7194c2c66affSColin Finck 7195c2c66affSColin Finck 7196c2c66affSColin Finck /*********************************************************************** 7197c2c66affSColin Finck * CM_Set_DevNode_Problem [SETUPAPI.@] 7198c2c66affSColin Finck */ 719960a21894SEric Kohl CONFIGRET 720060a21894SEric Kohl WINAPI 720160a21894SEric Kohl CM_Set_DevNode_Problem( 720260a21894SEric Kohl _In_ DEVINST dnDevInst, 720360a21894SEric Kohl _In_ ULONG ulProblem, 720460a21894SEric Kohl _In_ ULONG ulFlags) 7205c2c66affSColin Finck { 720660a21894SEric Kohl TRACE("CM_Set_DevNode_Problem(%lx %lx %lx)\n", 720760a21894SEric Kohl dnDevInst, ulProblem, ulFlags); 720860a21894SEric Kohl 7209c2c66affSColin Finck return CM_Set_DevNode_Problem_Ex(dnDevInst, ulProblem, ulFlags, NULL); 7210c2c66affSColin Finck } 7211c2c66affSColin Finck 7212c2c66affSColin Finck 7213c2c66affSColin Finck /*********************************************************************** 7214c2c66affSColin Finck * CM_Set_DevNode_Problem_Ex [SETUPAPI.@] 7215c2c66affSColin Finck */ 721660a21894SEric Kohl CONFIGRET 721760a21894SEric Kohl WINAPI 721860a21894SEric Kohl CM_Set_DevNode_Problem_Ex( 721960a21894SEric Kohl _In_ DEVINST dnDevInst, 722060a21894SEric Kohl _In_ ULONG ulProblem, 722160a21894SEric Kohl _In_ ULONG ulFlags, 722260a21894SEric Kohl _In_opt_ HMACHINE hMachine) 7223c2c66affSColin Finck { 7224c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 7225c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 7226c2c66affSColin Finck LPWSTR lpDevInst; 7227c2c66affSColin Finck CONFIGRET ret; 7228c2c66affSColin Finck 722960a21894SEric Kohl TRACE("CM_Set_DevNode_Problem_Ex(%lx %lx %lx %p)\n", 723060a21894SEric Kohl dnDevInst, ulProblem, ulFlags, hMachine); 7231c2c66affSColin Finck 7232c2c66affSColin Finck if (dnDevInst == 0) 7233c2c66affSColin Finck return CR_INVALID_DEVNODE; 7234c2c66affSColin Finck 7235c2c66affSColin Finck if (ulFlags & ~CM_SET_DEVNODE_PROBLEM_BITS) 7236c2c66affSColin Finck return CR_INVALID_FLAG; 7237c2c66affSColin Finck 7238c2c66affSColin Finck if (hMachine != NULL) 7239c2c66affSColin Finck { 7240c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 7241c2c66affSColin Finck if (BindingHandle == NULL) 7242c2c66affSColin Finck return CR_FAILURE; 7243c2c66affSColin Finck 7244c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 7245c2c66affSColin Finck if (StringTable == 0) 7246c2c66affSColin Finck return CR_FAILURE; 7247c2c66affSColin Finck } 7248c2c66affSColin Finck else 7249c2c66affSColin Finck { 7250c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 7251c2c66affSColin Finck return CR_FAILURE; 7252c2c66affSColin Finck } 7253c2c66affSColin Finck 7254c2c66affSColin Finck lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst); 7255c2c66affSColin Finck if (lpDevInst == NULL) 7256c2c66affSColin Finck return CR_INVALID_DEVNODE; 7257c2c66affSColin Finck 7258c2c66affSColin Finck RpcTryExcept 7259c2c66affSColin Finck { 7260c2c66affSColin Finck ret = PNP_SetDeviceProblem(BindingHandle, 7261c2c66affSColin Finck lpDevInst, 7262c2c66affSColin Finck ulProblem, 7263c2c66affSColin Finck ulFlags); 7264c2c66affSColin Finck } 7265c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 7266c2c66affSColin Finck { 7267c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 7268c2c66affSColin Finck } 7269c2c66affSColin Finck RpcEndExcept; 7270c2c66affSColin Finck 7271c2c66affSColin Finck return ret; 7272c2c66affSColin Finck } 7273c2c66affSColin Finck 7274c2c66affSColin Finck 7275c2c66affSColin Finck /*********************************************************************** 7276c2c66affSColin Finck * CM_Set_DevNode_Registry_PropertyA [SETUPAPI.@] 7277c2c66affSColin Finck */ 727860a21894SEric Kohl CONFIGRET 727960a21894SEric Kohl WINAPI 728060a21894SEric Kohl CM_Set_DevNode_Registry_PropertyA( 728160a21894SEric Kohl _In_ DEVINST dnDevInst, 728260a21894SEric Kohl _In_ ULONG ulProperty, 728360a21894SEric Kohl _In_reads_bytes_opt_(ulLength) PCVOID Buffer, 728460a21894SEric Kohl _In_ ULONG ulLength, 728560a21894SEric Kohl _In_ ULONG ulFlags) 7286c2c66affSColin Finck { 728760a21894SEric Kohl TRACE("CM_Set_DevNode_Registry_PropertyA(%lx %lu %p %lx %lx)\n", 7288c2c66affSColin Finck dnDevInst, ulProperty, Buffer, ulLength, ulFlags); 728960a21894SEric Kohl 7290c2c66affSColin Finck return CM_Set_DevNode_Registry_Property_ExA(dnDevInst, ulProperty, 7291c2c66affSColin Finck Buffer, ulLength, 7292c2c66affSColin Finck ulFlags, NULL); 7293c2c66affSColin Finck } 7294c2c66affSColin Finck 7295c2c66affSColin Finck 7296c2c66affSColin Finck /*********************************************************************** 7297c2c66affSColin Finck * CM_Set_DevNode_Registry_PropertyW [SETUPAPI.@] 7298c2c66affSColin Finck */ 729960a21894SEric Kohl CONFIGRET 730060a21894SEric Kohl WINAPI 730160a21894SEric Kohl CM_Set_DevNode_Registry_PropertyW( 730260a21894SEric Kohl _In_ DEVINST dnDevInst, 730360a21894SEric Kohl _In_ ULONG ulProperty, 730460a21894SEric Kohl _In_reads_bytes_opt_(ulLength) PCVOID Buffer, 730560a21894SEric Kohl _In_ ULONG ulLength, 730660a21894SEric Kohl _In_ ULONG ulFlags) 7307c2c66affSColin Finck { 730860a21894SEric Kohl TRACE("CM_Set_DevNode_Registry_PropertyW(%lx %lu %p %lx %lx)\n", 7309c2c66affSColin Finck dnDevInst, ulProperty, Buffer, ulLength, ulFlags); 731060a21894SEric Kohl 7311c2c66affSColin Finck return CM_Set_DevNode_Registry_Property_ExW(dnDevInst, ulProperty, 7312c2c66affSColin Finck Buffer, ulLength, 7313c2c66affSColin Finck ulFlags, NULL); 7314c2c66affSColin Finck } 7315c2c66affSColin Finck 7316c2c66affSColin Finck 7317c2c66affSColin Finck /*********************************************************************** 7318c2c66affSColin Finck * CM_Set_DevNode_Registry_Property_ExA [SETUPAPI.@] 7319c2c66affSColin Finck */ 732060a21894SEric Kohl CONFIGRET 732160a21894SEric Kohl WINAPI 732260a21894SEric Kohl CM_Set_DevNode_Registry_Property_ExA( 732360a21894SEric Kohl _In_ DEVINST dnDevInst, 732460a21894SEric Kohl _In_ ULONG ulProperty, 732560a21894SEric Kohl _In_reads_bytes_opt_(ulLength) PCVOID Buffer, 732660a21894SEric Kohl _In_ ULONG ulLength, 732760a21894SEric Kohl _In_ ULONG ulFlags, 732860a21894SEric Kohl _In_opt_ HMACHINE hMachine) 7329c2c66affSColin Finck { 7330c2c66affSColin Finck CONFIGRET ret = CR_SUCCESS; 7331c2c66affSColin Finck LPWSTR lpBuffer; 7332c2c66affSColin Finck ULONG ulType; 7333c2c66affSColin Finck 733460a21894SEric Kohl FIXME("CM_Set_DevNode_Registry_Property_ExA(%lx %lu %p %lx %lx %p)\n", 7335c2c66affSColin Finck dnDevInst, ulProperty, Buffer, ulLength, ulFlags, hMachine); 7336c2c66affSColin Finck 7337c2c66affSColin Finck if (Buffer == NULL && ulLength != 0) 7338c2c66affSColin Finck return CR_INVALID_POINTER; 7339c2c66affSColin Finck 7340c2c66affSColin Finck if (ulProperty < CM_DRP_MIN || ulProperty > CM_DRP_MAX) 7341c2c66affSColin Finck return CR_INVALID_PROPERTY; 7342c2c66affSColin Finck 7343c2c66affSColin Finck if (Buffer == NULL) 7344c2c66affSColin Finck { 7345c2c66affSColin Finck ret = CM_Set_DevNode_Registry_Property_ExW(dnDevInst, 7346c2c66affSColin Finck ulProperty, 7347c2c66affSColin Finck NULL, 7348c2c66affSColin Finck 0, 7349c2c66affSColin Finck ulFlags, 7350c2c66affSColin Finck hMachine); 7351c2c66affSColin Finck } 7352c2c66affSColin Finck else 7353c2c66affSColin Finck { 7354c2c66affSColin Finck /* Get property type */ 7355c2c66affSColin Finck ulType = GetRegistryPropertyType(ulProperty); 7356c2c66affSColin Finck 7357c2c66affSColin Finck /* Allocate buffer if needed */ 7358c2c66affSColin Finck if (ulType == REG_SZ || 7359c2c66affSColin Finck ulType == REG_MULTI_SZ) 7360c2c66affSColin Finck { 7361c2c66affSColin Finck lpBuffer = MyMalloc(ulLength * sizeof(WCHAR)); 7362c2c66affSColin Finck if (lpBuffer == NULL) 7363c2c66affSColin Finck { 7364c2c66affSColin Finck ret = CR_OUT_OF_MEMORY; 7365c2c66affSColin Finck } 7366c2c66affSColin Finck else 7367c2c66affSColin Finck { 7368c2c66affSColin Finck if (!MultiByteToWideChar(CP_ACP, 0, Buffer, 7369c2c66affSColin Finck ulLength, lpBuffer, ulLength)) 7370c2c66affSColin Finck { 7371c2c66affSColin Finck MyFree(lpBuffer); 7372c2c66affSColin Finck ret = CR_FAILURE; 7373c2c66affSColin Finck } 7374c2c66affSColin Finck else 7375c2c66affSColin Finck { 7376c2c66affSColin Finck ret = CM_Set_DevNode_Registry_Property_ExW(dnDevInst, 7377c2c66affSColin Finck ulProperty, 7378c2c66affSColin Finck lpBuffer, 7379c2c66affSColin Finck ulLength * sizeof(WCHAR), 7380c2c66affSColin Finck ulFlags, 7381c2c66affSColin Finck hMachine); 7382c2c66affSColin Finck MyFree(lpBuffer); 7383c2c66affSColin Finck } 7384c2c66affSColin Finck } 7385c2c66affSColin Finck } 7386c2c66affSColin Finck else 7387c2c66affSColin Finck { 7388c2c66affSColin Finck ret = CM_Set_DevNode_Registry_Property_ExW(dnDevInst, 7389c2c66affSColin Finck ulProperty, 7390c2c66affSColin Finck Buffer, 7391c2c66affSColin Finck ulLength, 7392c2c66affSColin Finck ulFlags, 7393c2c66affSColin Finck hMachine); 7394c2c66affSColin Finck } 7395c2c66affSColin Finck 7396c2c66affSColin Finck ret = CR_CALL_NOT_IMPLEMENTED; 7397c2c66affSColin Finck } 7398c2c66affSColin Finck 7399c2c66affSColin Finck return ret; 7400c2c66affSColin Finck } 7401c2c66affSColin Finck 7402c2c66affSColin Finck 7403c2c66affSColin Finck /*********************************************************************** 7404c2c66affSColin Finck * CM_Set_DevNode_Registry_Property_ExW [SETUPAPI.@] 7405c2c66affSColin Finck */ 740660a21894SEric Kohl CONFIGRET 740760a21894SEric Kohl WINAPI 740860a21894SEric Kohl CM_Set_DevNode_Registry_Property_ExW( 740960a21894SEric Kohl _In_ DEVINST dnDevInst, 741060a21894SEric Kohl _In_ ULONG ulProperty, 741160a21894SEric Kohl _In_reads_bytes_opt_(ulLength) PCVOID Buffer, 741260a21894SEric Kohl _In_ ULONG ulLength, 741360a21894SEric Kohl _In_ ULONG ulFlags, 741460a21894SEric Kohl _In_opt_ HMACHINE hMachine) 7415c2c66affSColin Finck { 7416c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 7417c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 7418c2c66affSColin Finck LPWSTR lpDevInst; 7419c2c66affSColin Finck ULONG ulType; 7420c2c66affSColin Finck CONFIGRET ret; 7421c2c66affSColin Finck 742260a21894SEric Kohl TRACE("CM_Set_DevNode_Registry_Property_ExW(%lx %lu %p %lx %lx %p)\n", 7423c2c66affSColin Finck dnDevInst, ulProperty, Buffer, ulLength, ulFlags, hMachine); 7424c2c66affSColin Finck 7425c2c66affSColin Finck if (dnDevInst == 0) 7426c2c66affSColin Finck return CR_INVALID_DEVNODE; 7427c2c66affSColin Finck 7428c2c66affSColin Finck if (ulProperty < CM_DRP_MIN || ulProperty > CM_DRP_MAX) 7429c2c66affSColin Finck return CR_INVALID_PROPERTY; 7430c2c66affSColin Finck 7431c2c66affSColin Finck if (Buffer != NULL && ulLength == 0) 7432c2c66affSColin Finck return CR_INVALID_POINTER; 7433c2c66affSColin Finck 7434c2c66affSColin Finck if (ulFlags != 0) 7435c2c66affSColin Finck return CR_INVALID_FLAG; 7436c2c66affSColin Finck 7437c2c66affSColin Finck if (hMachine != NULL) 7438c2c66affSColin Finck { 7439c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 7440c2c66affSColin Finck if (BindingHandle == NULL) 7441c2c66affSColin Finck return CR_FAILURE; 7442c2c66affSColin Finck 7443c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 7444c2c66affSColin Finck if (StringTable == 0) 7445c2c66affSColin Finck return CR_FAILURE; 7446c2c66affSColin Finck } 7447c2c66affSColin Finck else 7448c2c66affSColin Finck { 7449c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 7450c2c66affSColin Finck return CR_FAILURE; 7451c2c66affSColin Finck } 7452c2c66affSColin Finck 7453c2c66affSColin Finck lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst); 7454c2c66affSColin Finck if (lpDevInst == NULL) 7455c2c66affSColin Finck return CR_INVALID_DEVNODE; 7456c2c66affSColin Finck 7457c2c66affSColin Finck /* Get property type */ 7458c2c66affSColin Finck ulType = GetRegistryPropertyType(ulProperty); 7459c2c66affSColin Finck 7460c2c66affSColin Finck RpcTryExcept 7461c2c66affSColin Finck { 7462c2c66affSColin Finck ret = PNP_SetDeviceRegProp(BindingHandle, 7463c2c66affSColin Finck lpDevInst, 7464c2c66affSColin Finck ulProperty, 7465c2c66affSColin Finck ulType, 7466c2c66affSColin Finck (BYTE *)Buffer, 7467c2c66affSColin Finck ulLength, 7468c2c66affSColin Finck ulFlags); 7469c2c66affSColin Finck } 7470c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 7471c2c66affSColin Finck { 7472c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 7473c2c66affSColin Finck } 7474c2c66affSColin Finck RpcEndExcept; 7475c2c66affSColin Finck 7476c2c66affSColin Finck return ret; 7477c2c66affSColin Finck } 7478c2c66affSColin Finck 7479c2c66affSColin Finck 7480c2c66affSColin Finck /*********************************************************************** 7481c2c66affSColin Finck * CM_Set_HW_Prof [SETUPAPI.@] 7482c2c66affSColin Finck */ 748360a21894SEric Kohl CONFIGRET 748460a21894SEric Kohl WINAPI 748560a21894SEric Kohl CM_Set_HW_Prof( 748660a21894SEric Kohl _In_ ULONG ulHardwareProfile, 748760a21894SEric Kohl _In_ ULONG ulFlags) 7488c2c66affSColin Finck { 748960a21894SEric Kohl TRACE("CM_Set_HW_Prof(%lu %lx)\n", 749060a21894SEric Kohl ulHardwareProfile, ulFlags); 749160a21894SEric Kohl 7492c2c66affSColin Finck return CM_Set_HW_Prof_Ex(ulHardwareProfile, ulFlags, NULL); 7493c2c66affSColin Finck } 7494c2c66affSColin Finck 7495c2c66affSColin Finck 7496c2c66affSColin Finck /*********************************************************************** 7497c2c66affSColin Finck * CM_Set_HW_Prof_Ex [SETUPAPI.@] 7498c2c66affSColin Finck */ 749960a21894SEric Kohl CONFIGRET 750060a21894SEric Kohl WINAPI 750160a21894SEric Kohl CM_Set_HW_Prof_Ex( 750260a21894SEric Kohl _In_ ULONG ulHardwareProfile, 750360a21894SEric Kohl _In_ ULONG ulFlags, 750460a21894SEric Kohl _In_opt_ HMACHINE hMachine) 7505c2c66affSColin Finck { 7506c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 7507c2c66affSColin Finck CONFIGRET ret; 7508c2c66affSColin Finck 750960a21894SEric Kohl TRACE("CM_Set_HW_Prof_Ex(%lu %lx %p)\n", 751060a21894SEric Kohl ulHardwareProfile, ulFlags, hMachine); 7511c2c66affSColin Finck 7512c2c66affSColin Finck if (!pSetupIsUserAdmin()) 7513c2c66affSColin Finck return CR_ACCESS_DENIED; 7514c2c66affSColin Finck 7515c2c66affSColin Finck if (ulFlags != 0) 7516c2c66affSColin Finck return CR_INVALID_FLAG; 7517c2c66affSColin Finck 7518c2c66affSColin Finck if (hMachine != NULL) 7519c2c66affSColin Finck { 7520c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 7521c2c66affSColin Finck if (BindingHandle == NULL) 7522c2c66affSColin Finck return CR_FAILURE; 7523c2c66affSColin Finck } 7524c2c66affSColin Finck else 7525c2c66affSColin Finck { 7526c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 7527c2c66affSColin Finck return CR_FAILURE; 7528c2c66affSColin Finck } 7529c2c66affSColin Finck 7530c2c66affSColin Finck RpcTryExcept 7531c2c66affSColin Finck { 7532c2c66affSColin Finck ret = PNP_SetHwProf(BindingHandle, ulHardwareProfile, ulFlags); 7533c2c66affSColin Finck } 7534c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 7535c2c66affSColin Finck { 7536c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 7537c2c66affSColin Finck } 7538c2c66affSColin Finck RpcEndExcept; 7539c2c66affSColin Finck 7540c2c66affSColin Finck return ret; 7541c2c66affSColin Finck } 7542c2c66affSColin Finck 7543c2c66affSColin Finck 7544c2c66affSColin Finck /*********************************************************************** 7545c2c66affSColin Finck * CM_Set_HW_Prof_FlagsA [SETUPAPI.@] 7546c2c66affSColin Finck */ 754760a21894SEric Kohl CONFIGRET 754860a21894SEric Kohl WINAPI 754960a21894SEric Kohl CM_Set_HW_Prof_FlagsA( 755060a21894SEric Kohl _In_ DEVINSTID_A szDevInstName, 755160a21894SEric Kohl _In_ ULONG ulConfig, 755260a21894SEric Kohl _In_ ULONG ulValue, 755360a21894SEric Kohl _In_ ULONG ulFlags) 7554c2c66affSColin Finck { 755560a21894SEric Kohl TRACE("CM_Set_HW_Prof_FlagsA(%s %lu %lu %lx)\n", 755660a21894SEric Kohl debugstr_a(szDevInstName), ulConfig, ulValue, ulFlags); 755760a21894SEric Kohl 7558c2c66affSColin Finck return CM_Set_HW_Prof_Flags_ExA(szDevInstName, ulConfig, ulValue, 7559c2c66affSColin Finck ulFlags, NULL); 7560c2c66affSColin Finck } 7561c2c66affSColin Finck 7562c2c66affSColin Finck 7563c2c66affSColin Finck /*********************************************************************** 7564c2c66affSColin Finck * CM_Set_HW_Prof_FlagsW [SETUPAPI.@] 7565c2c66affSColin Finck */ 756660a21894SEric Kohl CONFIGRET 756760a21894SEric Kohl WINAPI 756860a21894SEric Kohl CM_Set_HW_Prof_FlagsW( 756960a21894SEric Kohl _In_ DEVINSTID_W szDevInstName, 757060a21894SEric Kohl _In_ ULONG ulConfig, 757160a21894SEric Kohl _In_ ULONG ulValue, 757260a21894SEric Kohl _In_ ULONG ulFlags) 7573c2c66affSColin Finck { 757460a21894SEric Kohl TRACE("CM_Set_HW_Prof_FlagsW(%s %lu %lu %lx)\n", 757560a21894SEric Kohl debugstr_w(szDevInstName), ulConfig, ulValue, ulFlags); 757660a21894SEric Kohl 7577c2c66affSColin Finck return CM_Set_HW_Prof_Flags_ExW(szDevInstName, ulConfig, ulValue, 7578c2c66affSColin Finck ulFlags, NULL); 7579c2c66affSColin Finck } 7580c2c66affSColin Finck 7581c2c66affSColin Finck 7582c2c66affSColin Finck /*********************************************************************** 7583c2c66affSColin Finck * CM_Set_HW_Prof_Flags_ExA [SETUPAPI.@] 7584c2c66affSColin Finck */ 758560a21894SEric Kohl CONFIGRET 758660a21894SEric Kohl WINAPI 758760a21894SEric Kohl CM_Set_HW_Prof_Flags_ExA( 758860a21894SEric Kohl _In_ DEVINSTID_A szDevInstName, 758960a21894SEric Kohl _In_ ULONG ulConfig, 759060a21894SEric Kohl _In_ ULONG ulValue, 759160a21894SEric Kohl _In_ ULONG ulFlags, 759260a21894SEric Kohl _In_opt_ HMACHINE hMachine) 7593c2c66affSColin Finck { 7594c2c66affSColin Finck DEVINSTID_W pszDevIdW = NULL; 7595c2c66affSColin Finck CONFIGRET ret = CR_SUCCESS; 7596c2c66affSColin Finck 759760a21894SEric Kohl TRACE("CM_Set_HW_Prof_Flags_ExA(%s %lu %lu %lx %p)\n", 759860a21894SEric Kohl debugstr_a(szDevInstName), ulConfig, ulValue, ulFlags, hMachine); 7599c2c66affSColin Finck 7600c2c66affSColin Finck if (szDevInstName != NULL) 7601c2c66affSColin Finck { 7602c2c66affSColin Finck if (pSetupCaptureAndConvertAnsiArg(szDevInstName, &pszDevIdW)) 7603c2c66affSColin Finck return CR_INVALID_DEVICE_ID; 7604c2c66affSColin Finck } 7605c2c66affSColin Finck 7606c2c66affSColin Finck ret = CM_Set_HW_Prof_Flags_ExW(pszDevIdW, ulConfig, ulValue, 7607c2c66affSColin Finck ulFlags, hMachine); 7608c2c66affSColin Finck 7609c2c66affSColin Finck if (pszDevIdW != NULL) 7610c2c66affSColin Finck MyFree(pszDevIdW); 7611c2c66affSColin Finck 7612c2c66affSColin Finck return ret; 7613c2c66affSColin Finck } 7614c2c66affSColin Finck 7615c2c66affSColin Finck 7616c2c66affSColin Finck /*********************************************************************** 7617c2c66affSColin Finck * CM_Set_HW_Prof_Flags_ExW [SETUPAPI.@] 7618c2c66affSColin Finck */ 761960a21894SEric Kohl CONFIGRET 762060a21894SEric Kohl WINAPI 762160a21894SEric Kohl CM_Set_HW_Prof_Flags_ExW( 762260a21894SEric Kohl _In_ DEVINSTID_W szDevInstName, 762360a21894SEric Kohl _In_ ULONG ulConfig, 762460a21894SEric Kohl _In_ ULONG ulValue, 762560a21894SEric Kohl _In_ ULONG ulFlags, 762660a21894SEric Kohl _In_opt_ HMACHINE hMachine) 7627c2c66affSColin Finck { 7628c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 7629c2c66affSColin Finck CONFIGRET ret; 7630c2c66affSColin Finck 763160a21894SEric Kohl FIXME("CM_Set_HW_Prof_Flags_ExW(%s %lu %lu %lx %p)\n", 763260a21894SEric Kohl debugstr_w(szDevInstName), ulConfig, ulValue, ulFlags, hMachine); 7633c2c66affSColin Finck 7634c2c66affSColin Finck if (szDevInstName == NULL) 7635c2c66affSColin Finck return CR_INVALID_POINTER; 7636c2c66affSColin Finck 7637c2c66affSColin Finck if (ulFlags & ~ CM_SET_HW_PROF_FLAGS_BITS) 7638c2c66affSColin Finck return CR_INVALID_FLAG; 7639c2c66affSColin Finck 7640c2c66affSColin Finck /* FIXME: Check whether szDevInstName is valid */ 7641c2c66affSColin Finck 7642c2c66affSColin Finck if (hMachine != NULL) 7643c2c66affSColin Finck { 7644c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 7645c2c66affSColin Finck if (BindingHandle == NULL) 7646c2c66affSColin Finck return CR_FAILURE; 7647c2c66affSColin Finck } 7648c2c66affSColin Finck else 7649c2c66affSColin Finck { 7650c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 7651c2c66affSColin Finck return CR_FAILURE; 7652c2c66affSColin Finck } 7653c2c66affSColin Finck 7654c2c66affSColin Finck RpcTryExcept 7655c2c66affSColin Finck { 7656c2c66affSColin Finck ret = PNP_HwProfFlags(BindingHandle, PNP_SET_HWPROFFLAGS, szDevInstName, 7657c2c66affSColin Finck ulConfig, &ulValue, NULL, NULL, 0, 0); 7658c2c66affSColin Finck } 7659c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 7660c2c66affSColin Finck { 7661c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 7662c2c66affSColin Finck } 7663c2c66affSColin Finck RpcEndExcept; 7664c2c66affSColin Finck 7665c2c66affSColin Finck return ret; 7666c2c66affSColin Finck } 7667c2c66affSColin Finck 7668c2c66affSColin Finck 7669c2c66affSColin Finck /*********************************************************************** 7670c2c66affSColin Finck * CM_Setup_DevNode [SETUPAPI.@] 7671c2c66affSColin Finck */ 767260a21894SEric Kohl CONFIGRET 767360a21894SEric Kohl WINAPI 767460a21894SEric Kohl CM_Setup_DevNode( 767560a21894SEric Kohl _In_ DEVINST dnDevInst, 767660a21894SEric Kohl _In_ ULONG ulFlags) 7677c2c66affSColin Finck { 767860a21894SEric Kohl TRACE("CM_Setup_DevNode(%lx %lx)\n", 767960a21894SEric Kohl dnDevInst, ulFlags); 768060a21894SEric Kohl 7681c2c66affSColin Finck return CM_Setup_DevNode_Ex(dnDevInst, ulFlags, NULL); 7682c2c66affSColin Finck } 7683c2c66affSColin Finck 7684c2c66affSColin Finck 7685c2c66affSColin Finck /*********************************************************************** 7686c2c66affSColin Finck * CM_Setup_DevNode_Ex [SETUPAPI.@] 7687c2c66affSColin Finck */ 768860a21894SEric Kohl CONFIGRET 768960a21894SEric Kohl WINAPI 769060a21894SEric Kohl CM_Setup_DevNode_Ex( 769160a21894SEric Kohl _In_ DEVINST dnDevInst, 769260a21894SEric Kohl _In_ ULONG ulFlags, 769360a21894SEric Kohl _In_opt_ HMACHINE hMachine) 7694c2c66affSColin Finck { 7695c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 7696c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 7697c2c66affSColin Finck LPWSTR lpDevInst; 7698c2c66affSColin Finck CONFIGRET ret; 7699c2c66affSColin Finck 770060a21894SEric Kohl FIXME("CM_Setup_DevNode_Ex(%lx %lx %p)\n", 770160a21894SEric Kohl dnDevInst, ulFlags, hMachine); 7702c2c66affSColin Finck 7703c2c66affSColin Finck if (!pSetupIsUserAdmin()) 7704c2c66affSColin Finck return CR_ACCESS_DENIED; 7705c2c66affSColin Finck 7706c2c66affSColin Finck if (dnDevInst == 0) 7707c2c66affSColin Finck return CR_INVALID_DEVNODE; 7708c2c66affSColin Finck 7709c2c66affSColin Finck if (ulFlags & ~CM_SETUP_BITS) 7710c2c66affSColin Finck return CR_INVALID_FLAG; 7711c2c66affSColin Finck 7712c2c66affSColin Finck if (hMachine != NULL) 7713c2c66affSColin Finck { 7714c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 7715c2c66affSColin Finck if (BindingHandle == NULL) 7716c2c66affSColin Finck return CR_FAILURE; 7717c2c66affSColin Finck 7718c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 7719c2c66affSColin Finck if (StringTable == 0) 7720c2c66affSColin Finck return CR_FAILURE; 7721c2c66affSColin Finck } 7722c2c66affSColin Finck else 7723c2c66affSColin Finck { 7724c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 7725c2c66affSColin Finck return CR_FAILURE; 7726c2c66affSColin Finck } 7727c2c66affSColin Finck 7728c2c66affSColin Finck lpDevInst = pSetupStringTableStringFromId(StringTable, dnDevInst); 7729c2c66affSColin Finck if (lpDevInst == NULL) 7730c2c66affSColin Finck return CR_INVALID_DEVNODE; 7731c2c66affSColin Finck 7732c2c66affSColin Finck RpcTryExcept 7733c2c66affSColin Finck { 7734c2c66affSColin Finck ret = PNP_DeviceInstanceAction(BindingHandle, 7735c2c66affSColin Finck PNP_DEVINST_SETUP, 7736c2c66affSColin Finck ulFlags, 7737c2c66affSColin Finck lpDevInst, 7738c2c66affSColin Finck NULL); 7739c2c66affSColin Finck } 7740c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 7741c2c66affSColin Finck { 7742c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 7743c2c66affSColin Finck } 7744c2c66affSColin Finck RpcEndExcept; 7745c2c66affSColin Finck 7746c2c66affSColin Finck return ret; 7747c2c66affSColin Finck } 7748c2c66affSColin Finck 7749c2c66affSColin Finck 7750c2c66affSColin Finck /*********************************************************************** 7751c2c66affSColin Finck * CM_Test_Range_Available [SETUPAPI.@] 7752c2c66affSColin Finck */ 7753c2c66affSColin Finck CONFIGRET 7754c2c66affSColin Finck WINAPI 7755c2c66affSColin Finck CM_Test_Range_Available( 7756c2c66affSColin Finck _In_ DWORDLONG ullStartValue, 7757c2c66affSColin Finck _In_ DWORDLONG ullEndValue, 7758c2c66affSColin Finck _In_ RANGE_LIST rlh, 7759c2c66affSColin Finck _In_ ULONG ulFlags) 7760c2c66affSColin Finck { 7761c2c66affSColin Finck FIXME("CM_Test_Range_Available(%I64u %I64u %p %lx)\n", 7762c2c66affSColin Finck ullStartValue, ullEndValue, rlh, ulFlags); 7763c2c66affSColin Finck return CR_CALL_NOT_IMPLEMENTED; 7764c2c66affSColin Finck } 7765c2c66affSColin Finck 7766c2c66affSColin Finck 7767c2c66affSColin Finck /*********************************************************************** 7768c2c66affSColin Finck * CM_Uninstall_DevNode [SETUPAPI.@] 7769c2c66affSColin Finck */ 777060a21894SEric Kohl CONFIGRET 777160a21894SEric Kohl WINAPI 777260a21894SEric Kohl CM_Uninstall_DevNode( 777360a21894SEric Kohl _In_ DEVINST dnPhantom, 777460a21894SEric Kohl _In_ ULONG ulFlags) 7775c2c66affSColin Finck { 777660a21894SEric Kohl TRACE("CM_Uninstall_DevNode(%lx %lx)\n", 777760a21894SEric Kohl dnPhantom, ulFlags); 777860a21894SEric Kohl 7779c2c66affSColin Finck return CM_Uninstall_DevNode_Ex(dnPhantom, ulFlags, NULL); 7780c2c66affSColin Finck } 7781c2c66affSColin Finck 7782c2c66affSColin Finck 7783c2c66affSColin Finck /*********************************************************************** 7784c2c66affSColin Finck * CM_Uninstall_DevNode_Ex [SETUPAPI.@] 7785c2c66affSColin Finck */ 778660a21894SEric Kohl CONFIGRET 778760a21894SEric Kohl WINAPI 778860a21894SEric Kohl CM_Uninstall_DevNode_Ex( 778960a21894SEric Kohl _In_ DEVINST dnPhantom, 779060a21894SEric Kohl _In_ ULONG ulFlags, 779160a21894SEric Kohl _In_opt_ HMACHINE hMachine) 7792c2c66affSColin Finck { 7793c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 7794c2c66affSColin Finck HSTRING_TABLE StringTable = NULL; 7795c2c66affSColin Finck LPWSTR lpDevInst; 7796c2c66affSColin Finck CONFIGRET ret; 7797c2c66affSColin Finck 779860a21894SEric Kohl TRACE("CM_Uninstall_DevNode_Ex(%lx %lx %p)\n", 779960a21894SEric Kohl dnPhantom, ulFlags, hMachine); 7800c2c66affSColin Finck 7801c2c66affSColin Finck if (dnPhantom == 0) 7802c2c66affSColin Finck return CR_INVALID_DEVNODE; 7803c2c66affSColin Finck 7804c2c66affSColin Finck if (ulFlags != 0) 7805c2c66affSColin Finck return CR_INVALID_FLAG; 7806c2c66affSColin Finck 7807c2c66affSColin Finck if (hMachine != NULL) 7808c2c66affSColin Finck { 7809c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 7810c2c66affSColin Finck if (BindingHandle == NULL) 7811c2c66affSColin Finck return CR_FAILURE; 7812c2c66affSColin Finck 7813c2c66affSColin Finck StringTable = ((PMACHINE_INFO)hMachine)->StringTable; 7814c2c66affSColin Finck if (StringTable == 0) 7815c2c66affSColin Finck return CR_FAILURE; 7816c2c66affSColin Finck } 7817c2c66affSColin Finck else 7818c2c66affSColin Finck { 7819c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) 7820c2c66affSColin Finck return CR_FAILURE; 7821c2c66affSColin Finck } 7822c2c66affSColin Finck 7823c2c66affSColin Finck lpDevInst = pSetupStringTableStringFromId(StringTable, dnPhantom); 7824c2c66affSColin Finck if (lpDevInst == NULL) 7825c2c66affSColin Finck return CR_INVALID_DEVNODE; 7826c2c66affSColin Finck 7827c2c66affSColin Finck RpcTryExcept 7828c2c66affSColin Finck { 7829c2c66affSColin Finck ret = PNP_UninstallDevInst(BindingHandle, 7830c2c66affSColin Finck lpDevInst, 7831c2c66affSColin Finck ulFlags); 7832c2c66affSColin Finck } 7833c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 7834c2c66affSColin Finck { 7835c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 7836c2c66affSColin Finck } 7837c2c66affSColin Finck RpcEndExcept; 7838c2c66affSColin Finck 7839c2c66affSColin Finck return ret; 7840c2c66affSColin Finck } 7841c2c66affSColin Finck 7842c2c66affSColin Finck 7843c2c66affSColin Finck /*********************************************************************** 7844c2c66affSColin Finck * CM_Unregister_Device_InterfaceA [SETUPAPI.@] 7845c2c66affSColin Finck */ 784660a21894SEric Kohl CONFIGRET 784760a21894SEric Kohl WINAPI 784860a21894SEric Kohl CM_Unregister_Device_InterfaceA( 784960a21894SEric Kohl _In_ LPCSTR pszDeviceInterface, 785060a21894SEric Kohl _In_ ULONG ulFlags) 7851c2c66affSColin Finck { 785260a21894SEric Kohl TRACE("CM_Unregister_Device_InterfaceA(%s %lx)\n", 785360a21894SEric Kohl debugstr_a(pszDeviceInterface), ulFlags); 7854c2c66affSColin Finck 7855c2c66affSColin Finck return CM_Unregister_Device_Interface_ExA(pszDeviceInterface, 7856c2c66affSColin Finck ulFlags, NULL); 7857c2c66affSColin Finck } 7858c2c66affSColin Finck 7859c2c66affSColin Finck 7860c2c66affSColin Finck /*********************************************************************** 7861c2c66affSColin Finck * CM_Unregister_Device_InterfaceW [SETUPAPI.@] 7862c2c66affSColin Finck */ 786360a21894SEric Kohl CONFIGRET 786460a21894SEric Kohl WINAPI 786560a21894SEric Kohl CM_Unregister_Device_InterfaceW( 786660a21894SEric Kohl _In_ LPCWSTR pszDeviceInterface, 786760a21894SEric Kohl _In_ ULONG ulFlags) 7868c2c66affSColin Finck { 786960a21894SEric Kohl TRACE("CM_Unregister_Device_InterfaceW(%s %lx)\n", 787060a21894SEric Kohl debugstr_w(pszDeviceInterface), ulFlags); 7871c2c66affSColin Finck 7872c2c66affSColin Finck return CM_Unregister_Device_Interface_ExW(pszDeviceInterface, 7873c2c66affSColin Finck ulFlags, NULL); 7874c2c66affSColin Finck } 7875c2c66affSColin Finck 7876c2c66affSColin Finck 7877c2c66affSColin Finck /*********************************************************************** 7878c2c66affSColin Finck * CM_Unregister_Device_Interface_ExA [SETUPAPI.@] 7879c2c66affSColin Finck */ 788060a21894SEric Kohl CONFIGRET 788160a21894SEric Kohl WINAPI 788260a21894SEric Kohl CM_Unregister_Device_Interface_ExA( 788360a21894SEric Kohl _In_ LPCSTR pszDeviceInterface, 788460a21894SEric Kohl _In_ ULONG ulFlags, 788560a21894SEric Kohl _In_opt_ HMACHINE hMachine) 7886c2c66affSColin Finck { 7887c2c66affSColin Finck LPWSTR pszDeviceInterfaceW = NULL; 7888c2c66affSColin Finck CONFIGRET ret; 7889c2c66affSColin Finck 789060a21894SEric Kohl TRACE("CM_Unregister_Device_Interface_ExA(%s %lx %p)\n", 789160a21894SEric Kohl debugstr_a(pszDeviceInterface), ulFlags, hMachine); 7892c2c66affSColin Finck 7893c2c66affSColin Finck if (pszDeviceInterface == NULL) 7894c2c66affSColin Finck return CR_INVALID_POINTER; 7895c2c66affSColin Finck 7896c2c66affSColin Finck if (pSetupCaptureAndConvertAnsiArg(pszDeviceInterface, &pszDeviceInterfaceW)) 7897c2c66affSColin Finck return CR_INVALID_DATA; 7898c2c66affSColin Finck 7899c2c66affSColin Finck ret = CM_Unregister_Device_Interface_ExW(pszDeviceInterfaceW, 7900c2c66affSColin Finck ulFlags, hMachine); 7901c2c66affSColin Finck 7902c2c66affSColin Finck if (pszDeviceInterfaceW != NULL) 7903c2c66affSColin Finck MyFree(pszDeviceInterfaceW); 7904c2c66affSColin Finck 7905c2c66affSColin Finck return ret; 7906c2c66affSColin Finck } 7907c2c66affSColin Finck 7908c2c66affSColin Finck 7909c2c66affSColin Finck /*********************************************************************** 7910c2c66affSColin Finck * CM_Unregister_Device_Interface_ExW [SETUPAPI.@] 7911c2c66affSColin Finck */ 791260a21894SEric Kohl CONFIGRET 791360a21894SEric Kohl WINAPI 791460a21894SEric Kohl CM_Unregister_Device_Interface_ExW( 791560a21894SEric Kohl _In_ LPCWSTR pszDeviceInterface, 791660a21894SEric Kohl _In_ ULONG ulFlags, 791760a21894SEric Kohl _In_opt_ HMACHINE hMachine) 7918c2c66affSColin Finck { 7919c2c66affSColin Finck RPC_BINDING_HANDLE BindingHandle = NULL; 7920c2c66affSColin Finck CONFIGRET ret; 7921c2c66affSColin Finck 792260a21894SEric Kohl TRACE("CM_Unregister_Device_Interface_ExW(%s %lx %p)\n", 792360a21894SEric Kohl debugstr_w(pszDeviceInterface), ulFlags, hMachine); 7924c2c66affSColin Finck 7925c2c66affSColin Finck if (pszDeviceInterface == NULL) 7926c2c66affSColin Finck return CR_INVALID_POINTER; 7927c2c66affSColin Finck 7928c2c66affSColin Finck if (ulFlags != 0) 7929c2c66affSColin Finck return CR_INVALID_FLAG; 7930c2c66affSColin Finck 7931c2c66affSColin Finck if (hMachine != NULL) 7932c2c66affSColin Finck { 7933c2c66affSColin Finck BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; 7934c2c66affSColin Finck if (BindingHandle == NULL) 7935c2c66affSColin Finck return CR_FAILURE; 7936c2c66affSColin Finck } 7937c2c66affSColin Finck else 7938c2c66affSColin Finck { 7939c2c66affSColin Finck if (!PnpGetLocalHandles(&BindingHandle, NULL)) 7940c2c66affSColin Finck return CR_FAILURE; 7941c2c66affSColin Finck } 7942c2c66affSColin Finck 7943c2c66affSColin Finck RpcTryExcept 7944c2c66affSColin Finck { 7945c2c66affSColin Finck ret = PNP_UnregisterDeviceClassAssociation(BindingHandle, 7946c2c66affSColin Finck (LPWSTR)pszDeviceInterface, 7947c2c66affSColin Finck ulFlags); 7948c2c66affSColin Finck } 7949c2c66affSColin Finck RpcExcept(EXCEPTION_EXECUTE_HANDLER) 7950c2c66affSColin Finck { 7951c2c66affSColin Finck ret = RpcStatusToCmStatus(RpcExceptionCode()); 7952c2c66affSColin Finck } 7953c2c66affSColin Finck RpcEndExcept; 7954c2c66affSColin Finck 7955c2c66affSColin Finck return ret; 7956c2c66affSColin Finck } 7957