Module: wine Branch: master Commit: 21b7e1faf66e9a04473cf97c49a10d4545fa8be7 URL: http://source.winehq.org/git/wine.git/?a=commit;h=21b7e1faf66e9a04473cf97c49...
Author: Juan Lang juan.lang@gmail.com Date: Fri Sep 21 17:07:16 2007 -0700
setupapi: Implement SetupDiCreateDeviceInterfaceRegKeyA/W.
---
dlls/setupapi/devinst.c | 105 +++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 101 insertions(+), 4 deletions(-)
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index 9593b1c..6d90d15 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -2171,9 +2171,27 @@ HKEY WINAPI SetupDiCreateDeviceInterfaceRegKeyA( HINF InfHandle, PCSTR InfSectionName) { - FIXME("%p %p %d %08x %p %p\n", DeviceInfoSet, DeviceInterfaceData, Reserved, + HKEY key; + PWSTR InfSectionNameW = NULL; + + TRACE("%p %p %d %08x %p %p\n", DeviceInfoSet, DeviceInterfaceData, Reserved, samDesired, InfHandle, InfSectionName); - return INVALID_HANDLE_VALUE; + if (InfHandle) + { + if (!InfSectionName) + { + SetLastError(ERROR_INVALID_PARAMETER); + return INVALID_HANDLE_VALUE; + } + InfSectionNameW = MultiByteToUnicode(InfSectionName, CP_ACP); + if (!InfSectionNameW) + return INVALID_HANDLE_VALUE; + } + key = SetupDiCreateDeviceInterfaceRegKeyW(DeviceInfoSet, + DeviceInterfaceData, Reserved, samDesired, InfHandle, + InfSectionNameW); + MyFree(InfSectionNameW); + return key; }
/*********************************************************************** @@ -2187,9 +2205,88 @@ HKEY WINAPI SetupDiCreateDeviceInterfaceRegKeyW( HINF InfHandle, PCWSTR InfSectionName) { - FIXME("%p %p %d %08x %p %p\n", DeviceInfoSet, DeviceInterfaceData, Reserved, + struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet; + HKEY key = INVALID_HANDLE_VALUE, interfacesKey; + LONG l; + + TRACE("%p %p %d %08x %p %p\n", DeviceInfoSet, DeviceInterfaceData, Reserved, samDesired, InfHandle, InfSectionName); - return INVALID_HANDLE_VALUE; + + if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE || + set->magic != SETUP_DEVICE_INFO_SET_MAGIC) + { + SetLastError(ERROR_INVALID_HANDLE); + return INVALID_HANDLE_VALUE; + } + if (!DeviceInterfaceData || + DeviceInterfaceData->cbSize != sizeof(SP_DEVICE_INTERFACE_DATA) || + !DeviceInterfaceData->Reserved) + { + SetLastError(ERROR_INVALID_PARAMETER); + return INVALID_HANDLE_VALUE; + } + if (InfHandle && !InfSectionName) + { + SetLastError(ERROR_INVALID_PARAMETER); + return INVALID_HANDLE_VALUE; + } + if (!(l = RegCreateKeyExW(HKEY_LOCAL_MACHINE, DeviceClasses, 0, NULL, 0, + samDesired, NULL, &interfacesKey, NULL))) + { + HKEY parent; + WCHAR bracedGuidString[39]; + + SETUPDI_GuidToString(&DeviceInterfaceData->InterfaceClassGuid, + bracedGuidString); + if (!(l = RegCreateKeyExW(interfacesKey, bracedGuidString, 0, NULL, 0, + samDesired, NULL, &parent, NULL))) + { + static const WCHAR hash[] = {'#',0}; + struct InterfaceInfo *ifaceInfo = + (struct InterfaceInfo *)DeviceInterfaceData->Reserved; + LPCWSTR instancePath = NULL; + LPWSTR referencePath = NULL; + + if (ifaceInfo->referenceString) + { + referencePath = HeapAlloc(GetProcessHeap(), 0, + (lstrlenW(ifaceInfo->referenceString) + 2) * + sizeof(WCHAR)); + if (referencePath) + { + lstrcpyW(referencePath, hash); + lstrcatW(referencePath, ifaceInfo->referenceString); + instancePath = referencePath; + } + else + SetLastError(ERROR_OUTOFMEMORY); + } + else + instancePath = hash; + if (instancePath) + { + LONG l; + + l = RegCreateKeyExW(parent, instancePath, 0, NULL, 0, + samDesired, NULL, &key, NULL); + if (l) + { + SetLastError(l); + key = INVALID_HANDLE_VALUE; + } + else if (InfHandle) + FIXME("INF section installation unsupported\n"); + } + HeapFree(GetProcessHeap(), 0, referencePath); + RegCloseKey(parent); + } + else + SetLastError(l); + RegCloseKey(interfacesKey); + } + else + SetLastError(l); + return key; }
/***********************************************************************