- RegQueryValueExW returns ERRROR_SUCCESS
[reactos.git] / reactos / dll / win32 / setupapi / interface.c
index b08b6fd..37fa07c 100644 (file)
@@ -266,7 +266,7 @@ SETUP_CreateInterfaceList(
             else
             {
                 dwLength = sizeof(DWORD);
-                if (RegQueryValueExW(hControlKey, Linked, NULL, &dwRegType, (LPBYTE)&LinkedValue, &dwLength)
+                if (RegQueryValueExW(hControlKey, Linked, NULL, &dwRegType, (LPBYTE)&LinkedValue, &dwLength) == ERROR_SUCCESS
                     && dwRegType == REG_DWORD && LinkedValue)
                     interfaceInfo->Flags |= SPINT_ACTIVE;
                 RegCloseKey(hControlKey);
@@ -290,260 +290,6 @@ cleanup:
     return rc;
 }
 
-/***********************************************************************
- *             SetupDiEnumDeviceInterfaces (SETUPAPI.@)
- */
-BOOL WINAPI
-SetupDiEnumDeviceInterfaces(
-    IN HDEVINFO DeviceInfoSet,
-    IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL,
-    IN CONST GUID *InterfaceClassGuid,
-    IN DWORD MemberIndex,
-    OUT PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
-{
-    BOOL ret = FALSE;
-
-    TRACE("%p, %p, %s, %ld, %p\n", DeviceInfoSet, DeviceInfoData,
-     debugstr_guid(InterfaceClassGuid), MemberIndex, DeviceInterfaceData);
-
-    if (!DeviceInterfaceData)
-        SetLastError(ERROR_INVALID_PARAMETER);
-    else if (DeviceInterfaceData->cbSize != sizeof(SP_DEVICE_INTERFACE_DATA))
-        SetLastError(ERROR_INVALID_USER_BUFFER);
-    else if (DeviceInfoSet && DeviceInfoSet != (HDEVINFO)INVALID_HANDLE_VALUE)
-    {
-        struct DeviceInfoSet *list = (struct DeviceInfoSet *)DeviceInfoSet;
-
-        if (list->magic == SETUP_DEVICE_INFO_SET_MAGIC)
-        {
-            PLIST_ENTRY ItemList = list->ListHead.Flink;
-            BOOL Found = FALSE;
-            while (ItemList != &list->ListHead && !Found)
-            {
-                PLIST_ENTRY InterfaceListEntry;
-                struct DeviceInfo *DevInfo = CONTAINING_RECORD(ItemList, struct DeviceInfo, ListEntry);
-                if (DeviceInfoData && (struct DeviceInfo *)DeviceInfoData->Reserved != DevInfo)
-                {
-                    /* We are not searching for this element */
-                    ItemList = ItemList->Flink;
-                    continue;
-                }
-                InterfaceListEntry = DevInfo->InterfaceListHead.Flink;
-                while (InterfaceListEntry != &DevInfo->InterfaceListHead && !Found)
-                {
-                    struct DeviceInterface *DevItf = CONTAINING_RECORD(InterfaceListEntry, struct DeviceInterface, ListEntry);
-                    if (!IsEqualIID(&DevItf->InterfaceClassGuid, InterfaceClassGuid))
-                    {
-                        InterfaceListEntry = InterfaceListEntry->Flink;
-                        continue;
-                    }
-                    if (MemberIndex-- == 0)
-                    {
-                        /* return this item */
-                        memcpy(&DeviceInterfaceData->InterfaceClassGuid,
-                            &DevItf->InterfaceClassGuid,
-                            sizeof(GUID));
-                        DeviceInterfaceData->Flags = DevItf->Flags;
-                        DeviceInterfaceData->Reserved = (ULONG_PTR)DevItf;
-                        Found = TRUE;
-                    }
-                    InterfaceListEntry = InterfaceListEntry->Flink;
-                }
-                ItemList = ItemList->Flink;
-            }
-            if (!Found)
-                SetLastError(ERROR_NO_MORE_ITEMS);
-            else
-                ret = TRUE;
-        }
-        else
-            SetLastError(ERROR_INVALID_HANDLE);
-    }
-    else
-        SetLastError(ERROR_INVALID_HANDLE);
-    return ret;
-}
-
-/***********************************************************************
- *             SetupDiGetDeviceInterfaceDetailW (SETUPAPI.@)
- */
-BOOL WINAPI
-SetupDiGetDeviceInterfaceDetailW(
-    IN HDEVINFO DeviceInfoSet,
-    IN PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
-    OUT PSP_DEVICE_INTERFACE_DETAIL_DATA_W DeviceInterfaceDetailData OPTIONAL,
-    IN DWORD DeviceInterfaceDetailDataSize,
-    OUT PDWORD RequiredSize OPTIONAL,
-    OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
-{
-    BOOL ret = FALSE;
-
-    TRACE("%p %p %p %lu %p %p\n", DeviceInfoSet,
-        DeviceInterfaceData, DeviceInterfaceDetailData,
-        DeviceInterfaceDetailDataSize, RequiredSize, DeviceInfoData);
-
-    if (!DeviceInfoSet || !DeviceInterfaceData)
-        SetLastError(ERROR_INVALID_PARAMETER);
-    else if (DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
-        SetLastError(ERROR_INVALID_HANDLE);
-    else if (((struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEVICE_INFO_SET_MAGIC)
-        SetLastError(ERROR_INVALID_HANDLE);
-    else if (DeviceInterfaceData->cbSize != sizeof(SP_DEVICE_INTERFACE_DATA))
-        SetLastError(ERROR_INVALID_USER_BUFFER);
-    else if (DeviceInterfaceDetailData->cbSize != sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W))
-        SetLastError(ERROR_INVALID_USER_BUFFER);
-    else if (DeviceInfoData && DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
-        SetLastError(ERROR_INVALID_USER_BUFFER);
-    else if (DeviceInterfaceDetailData == NULL && DeviceInterfaceDetailDataSize != 0)
-        SetLastError(ERROR_INVALID_PARAMETER);
-    else if (DeviceInterfaceDetailData != NULL && DeviceInterfaceDetailDataSize < FIELD_OFFSET(SP_DEVICE_INTERFACE_DETAIL_DATA_W, DevicePath) + sizeof(WCHAR))
-        SetLastError(ERROR_INVALID_PARAMETER);
-    else
-    {
-        struct DeviceInterface *deviceInterface = (struct DeviceInterface *)DeviceInterfaceData->Reserved;
-        LPCWSTR devName = deviceInterface->SymbolicLink;
-        DWORD sizeRequired = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W) +
-            (lstrlenW(devName) + 1) * sizeof(WCHAR);
-
-        if (sizeRequired > DeviceInterfaceDetailDataSize)
-        {
-            SetLastError(ERROR_INSUFFICIENT_BUFFER);
-            if (RequiredSize)
-                *RequiredSize = sizeRequired;
-        }
-        else
-        {
-            strcpyW(DeviceInterfaceDetailData->DevicePath, devName);
-            TRACE("DevicePath is %s\n", debugstr_w(DeviceInterfaceDetailData->DevicePath));
-            if (DeviceInfoData)
-            {
-                memcpy(&DeviceInfoData->ClassGuid,
-                    &deviceInterface->DeviceInfo->ClassGuid,
-                    sizeof(GUID));
-                DeviceInfoData->DevInst = deviceInterface->DeviceInfo->dnDevInst;
-                DeviceInfoData->Reserved = (ULONG_PTR)deviceInterface->DeviceInfo;
-            }
-            ret = TRUE;
-        }
-    }
-
-    TRACE("Returning %d\n", ret);
-    return ret;
-}
-
-/***********************************************************************
- *             SetupDiGetDeviceInterfaceDetailA (SETUPAPI.@)
- */
-BOOL WINAPI
-SetupDiGetDeviceInterfaceDetailA(
-    IN HDEVINFO DeviceInfoSet,
-    IN PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
-    OUT PSP_DEVICE_INTERFACE_DETAIL_DATA_A DeviceInterfaceDetailData OPTIONAL,
-    IN DWORD DeviceInterfaceDetailDataSize,
-    OUT PDWORD RequiredSize OPTIONAL,
-    OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
-{
-    PSP_DEVICE_INTERFACE_DETAIL_DATA_W DeviceInterfaceDetailDataW = NULL;
-    DWORD sizeW = 0, sizeA;
-    BOOL ret = FALSE;
-
-    TRACE("%p %p %p %lu %p %p\n", DeviceInfoSet,
-        DeviceInterfaceData, DeviceInterfaceDetailData,
-        DeviceInterfaceDetailDataSize, RequiredSize, DeviceInfoData);
-
-    if (DeviceInterfaceDetailData->cbSize != sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A))
-        SetLastError(ERROR_INVALID_USER_BUFFER);
-    else if (DeviceInterfaceDetailData == NULL && DeviceInterfaceDetailDataSize != 0)
-        SetLastError(ERROR_INVALID_PARAMETER);
-    else if (DeviceInterfaceDetailData != NULL && DeviceInterfaceDetailDataSize < FIELD_OFFSET(SP_DEVICE_INTERFACE_DETAIL_DATA_A, DevicePath) + 1)
-        SetLastError(ERROR_INVALID_PARAMETER);
-    else
-    {
-        if (DeviceInterfaceDetailData != NULL)
-        {
-            sizeW = FIELD_OFFSET(SP_DEVICE_INTERFACE_DETAIL_DATA_W, DevicePath)
-                + (DeviceInterfaceDetailDataSize - FIELD_OFFSET(SP_DEVICE_INTERFACE_DETAIL_DATA_A, DevicePath)) * sizeof(WCHAR);
-            DeviceInterfaceDetailDataW = (PSP_DEVICE_INTERFACE_DETAIL_DATA_W)HeapAlloc(GetProcessHeap(), 0, sizeW);
-            if (!DeviceInterfaceDetailDataW)
-            {
-                SetLastError(ERROR_NOT_ENOUGH_MEMORY);
-            }
-        }
-        if (!DeviceInterfaceDetailData || (DeviceInterfaceDetailData && DeviceInterfaceDetailDataW))
-        {
-            DeviceInterfaceDetailDataW->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W);
-            ret = SetupDiGetDeviceInterfaceDetailW(
-                DeviceInfoSet,
-                DeviceInterfaceData,
-                DeviceInterfaceDetailDataW,
-                sizeW,
-                &sizeW,
-                DeviceInfoData);
-            sizeA = (sizeW - FIELD_OFFSET(SP_DEVICE_INTERFACE_DETAIL_DATA_W, DevicePath)) / sizeof(WCHAR)
-                + FIELD_OFFSET(SP_DEVICE_INTERFACE_DETAIL_DATA_A, DevicePath);
-            if (RequiredSize)
-                *RequiredSize = sizeA;
-            if (ret && DeviceInterfaceDetailData && DeviceInterfaceDetailDataSize <= sizeA)
-            {
-                if (!WideCharToMultiByte(
-                    CP_ACP, 0,
-                    DeviceInterfaceDetailDataW->DevicePath, -1,
-                    DeviceInterfaceDetailData->DevicePath, DeviceInterfaceDetailDataSize - FIELD_OFFSET(SP_DEVICE_INTERFACE_DETAIL_DATA_A, DevicePath),
-                    NULL, NULL))
-                {
-                    ret = FALSE;
-                }
-            }
-        }
-        HeapFree(GetProcessHeap(), 0, DeviceInterfaceDetailDataW);
-    }
-
-    TRACE("Returning %d\n", ret);
-    return ret;
-}
-
-/***********************************************************************
- *             SetupDiOpenDeviceInterfaceA (SETUPAPI.@)
- */
-BOOL WINAPI
-SetupDiOpenDeviceInterfaceA(
-    IN HDEVINFO DeviceInfoSet,
-    IN PCSTR DevicePath,
-    IN DWORD OpenFlags,
-    OUT PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData OPTIONAL)
-{
-    LPWSTR DevicePathW = NULL;
-    BOOL bResult;
-
-    TRACE("%p %s %08lx %p\n", DeviceInfoSet, debugstr_a(DevicePath), OpenFlags, DeviceInterfaceData);
-
-    DevicePathW = MultiByteToUnicode(DevicePath, CP_ACP);
-    if (DevicePathW == NULL)
-        return FALSE;
-
-    bResult = SetupDiOpenDeviceInterfaceW(DeviceInfoSet,
-        DevicePathW, OpenFlags, DeviceInterfaceData);
-
-    MyFree(DevicePathW);
-
-    return bResult;
-}
-
-/***********************************************************************
- *             SetupDiOpenDeviceInterfaceW (SETUPAPI.@)
- */
-BOOL WINAPI
-SetupDiOpenDeviceInterfaceW(
-    IN HDEVINFO DeviceInfoSet,
-    IN PCWSTR DevicePath,
-    IN DWORD OpenFlags,
-    OUT PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData OPTIONAL)
-{
-    FIXME("%p %s %08lx %p\n",
-        DeviceInfoSet, debugstr_w(DevicePath), OpenFlags, DeviceInterfaceData);
-    return FALSE;
-}
-
 static BOOL
 InstallOneInterface(
     IN LPGUID InterfaceGuid,