Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
e2194b93
Commit
e2194b93
authored
May 27, 2019
by
Zebediah Figura
Committed by
Alexandre Julliard
May 28, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
setupapi: Avoid adding duplicate devices in SetupDiGetClassDevs().
Signed-off-by:
Zebediah Figura
<
z.figura12@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
eca57ed6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
19 deletions
+18
-19
devinst.c
dlls/setupapi/devinst.c
+18
-17
devinst.c
dlls/setupapi/tests/devinst.c
+0
-2
No files found.
dlls/setupapi/devinst.c
View file @
e2194b93
...
@@ -748,7 +748,8 @@ static void delete_device(struct device *device)
...
@@ -748,7 +748,8 @@ static void delete_device(struct device *device)
heap_free
(
device
);
heap_free
(
device
);
}
}
static
struct
device
*
SETUPDI_CreateDeviceInfo
(
struct
DeviceInfoSet
*
set
,
/* Create a new device, or return a device already in the set. */
static
struct
device
*
create_device
(
struct
DeviceInfoSet
*
set
,
const
GUID
*
class
,
const
WCHAR
*
instanceid
,
BOOL
phantom
)
const
GUID
*
class
,
const
WCHAR
*
instanceid
,
BOOL
phantom
)
{
{
const
DWORD
one
=
1
;
const
DWORD
one
=
1
;
...
@@ -758,6 +759,15 @@ static struct device *SETUPDI_CreateDeviceInfo(struct DeviceInfoSet *set,
...
@@ -758,6 +759,15 @@ static struct device *SETUPDI_CreateDeviceInfo(struct DeviceInfoSet *set,
TRACE
(
"%p, %s, %s, %d
\n
"
,
set
,
debugstr_guid
(
class
),
TRACE
(
"%p, %s, %s, %d
\n
"
,
set
,
debugstr_guid
(
class
),
debugstr_w
(
instanceid
),
phantom
);
debugstr_w
(
instanceid
),
phantom
);
LIST_FOR_EACH_ENTRY
(
device
,
&
set
->
devices
,
struct
device
,
entry
)
{
if
(
!
strcmpiW
(
instanceid
,
device
->
instanceId
))
{
TRACE
(
"Found device %p already in set.
\n
"
,
device
);
return
device
;
}
}
if
(
!
(
device
=
heap_alloc_zero
(
sizeof
(
*
device
))))
if
(
!
(
device
=
heap_alloc_zero
(
sizeof
(
*
device
))))
{
{
SetLastError
(
ERROR_OUTOFMEMORY
);
SetLastError
(
ERROR_OUTOFMEMORY
);
...
@@ -788,6 +798,8 @@ static struct device *SETUPDI_CreateDeviceInfo(struct DeviceInfoSet *set,
...
@@ -788,6 +798,8 @@ static struct device *SETUPDI_CreateDeviceInfo(struct DeviceInfoSet *set,
SETUPDI_GuidToString
(
class
,
guidstr
);
SETUPDI_GuidToString
(
class
,
guidstr
);
SETUPDI_SetDeviceRegistryPropertyW
(
device
,
SPDRP_CLASSGUID
,
SETUPDI_SetDeviceRegistryPropertyW
(
device
,
SPDRP_CLASSGUID
,
(
const
BYTE
*
)
guidstr
,
sizeof
(
guidstr
));
(
const
BYTE
*
)
guidstr
,
sizeof
(
guidstr
));
TRACE
(
"Created new device %p.
\n
"
,
device
);
return
device
;
return
device
;
}
}
...
@@ -1620,7 +1632,7 @@ BOOL WINAPI SetupDiCreateDeviceInfoW(HDEVINFO devinfo, const WCHAR *name, const
...
@@ -1620,7 +1632,7 @@ BOOL WINAPI SetupDiCreateDeviceInfoW(HDEVINFO devinfo, const WCHAR *name, const
}
}
}
}
if
(
!
(
device
=
SETUPDI_CreateDeviceInfo
(
set
,
class
,
id
,
TRUE
)))
if
(
!
(
device
=
create_device
(
set
,
class
,
id
,
TRUE
)))
return
FALSE
;
return
FALSE
;
if
(
description
)
if
(
description
)
...
@@ -2196,8 +2208,7 @@ static void SETUPDI_EnumerateMatchingInterfaces(HDEVINFO DeviceInfoSet,
...
@@ -2196,8 +2208,7 @@ static void SETUPDI_EnumerateMatchingInterfaces(HDEVINFO DeviceInfoSet,
deviceClassStr
[
37
]
=
0
;
deviceClassStr
[
37
]
=
0
;
UuidFromStringW
(
&
deviceClassStr
[
1
],
UuidFromStringW
(
&
deviceClassStr
[
1
],
&
deviceClass
);
&
deviceClass
);
if
((
device
=
SETUPDI_CreateDeviceInfo
(
set
,
if
((
device
=
create_device
(
set
,
&
deviceClass
,
deviceInst
,
FALSE
)))
&
deviceClass
,
deviceInst
,
FALSE
)))
SETUPDI_AddDeviceInterfaces
(
device
,
subKey
,
guid
,
flags
);
SETUPDI_AddDeviceInterfaces
(
device
,
subKey
,
guid
,
flags
);
}
}
RegCloseKey
(
deviceKey
);
RegCloseKey
(
deviceKey
);
...
@@ -2318,7 +2329,7 @@ static void SETUPDI_EnumerateMatchingDeviceInstances(struct DeviceInfoSet *set,
...
@@ -2318,7 +2329,7 @@ static void SETUPDI_EnumerateMatchingDeviceInstances(struct DeviceInfoSet *set,
if
(
snprintfW
(
id
,
ARRAY_SIZE
(
id
),
fmt
,
enumerator
,
if
(
snprintfW
(
id
,
ARRAY_SIZE
(
id
),
fmt
,
enumerator
,
deviceName
,
deviceInstance
)
!=
-
1
)
deviceName
,
deviceInstance
)
!=
-
1
)
{
{
SETUPDI_CreateDeviceInfo
(
set
,
&
deviceClass
,
id
,
FALSE
);
create_device
(
set
,
&
deviceClass
,
id
,
FALSE
);
}
}
}
}
}
}
...
@@ -3398,7 +3409,7 @@ BOOL WINAPI SetupDiOpenDeviceInfoW(HDEVINFO devinfo, PCWSTR instance_id, HWND hw
...
@@ -3398,7 +3409,7 @@ BOOL WINAPI SetupDiOpenDeviceInfoW(HDEVINFO devinfo, PCWSTR instance_id, HWND hw
PSP_DEVINFO_DATA
device_data
)
PSP_DEVINFO_DATA
device_data
)
{
{
struct
DeviceInfoSet
*
set
;
struct
DeviceInfoSet
*
set
;
struct
device
*
device
=
NULL
,
*
enum_device
;
struct
device
*
device
;
WCHAR
classW
[
40
];
WCHAR
classW
[
40
];
GUID
guid
;
GUID
guid
;
HKEY
enumKey
=
NULL
;
HKEY
enumKey
=
NULL
;
...
@@ -3448,17 +3459,7 @@ BOOL WINAPI SetupDiOpenDeviceInfoW(HDEVINFO devinfo, PCWSTR instance_id, HWND hw
...
@@ -3448,17 +3459,7 @@ BOOL WINAPI SetupDiOpenDeviceInfoW(HDEVINFO devinfo, PCWSTR instance_id, HWND hw
goto
done
;
goto
done
;
}
}
/* If current set already contains a same instance, don't create new ones */
if
(
!
(
device
=
create_device
(
set
,
&
guid
,
instance_id
,
FALSE
)))
LIST_FOR_EACH_ENTRY
(
enum_device
,
&
set
->
devices
,
struct
device
,
entry
)
{
if
(
!
strcmpiW
(
instance_id
,
enum_device
->
instanceId
))
{
device
=
enum_device
;
break
;
}
}
if
(
!
device
&&
!
(
device
=
SETUPDI_CreateDeviceInfo
(
set
,
&
guid
,
instance_id
,
FALSE
)))
goto
done
;
goto
done
;
if
(
!
device_data
||
device_data
->
cbSize
==
sizeof
(
SP_DEVINFO_DATA
))
if
(
!
device_data
||
device_data
->
cbSize
==
sizeof
(
SP_DEVINFO_DATA
))
...
...
dlls/setupapi/tests/devinst.c
View file @
e2194b93
...
@@ -2933,7 +2933,6 @@ todo_wine {
...
@@ -2933,7 +2933,6 @@ todo_wine {
ok
(
set
!=
INVALID_HANDLE_VALUE
,
"Failed to create device list, error %#x.
\n
"
,
GetLastError
());
ok
(
set
!=
INVALID_HANDLE_VALUE
,
"Failed to create device list, error %#x.
\n
"
,
GetLastError
());
check_device_list
(
set
,
&
GUID_NULL
);
check_device_list
(
set
,
&
GUID_NULL
);
check_device_info
(
set
,
0
,
&
guid
,
"ROOT
\\
LEGACY_BOGUS
\\
FOO"
);
check_device_info
(
set
,
0
,
&
guid
,
"ROOT
\\
LEGACY_BOGUS
\\
FOO"
);
todo_wine
check_device_info
(
set
,
1
,
NULL
,
NULL
);
check_device_info
(
set
,
1
,
NULL
,
NULL
);
check_device_iface
(
set
,
NULL
,
&
iface_guid
,
0
,
0
,
"
\\\\
?
\\
root#legacy_bogus#foo#{deadbeef-3f65-11db-b704-0011955c2bdb}"
);
check_device_iface
(
set
,
NULL
,
&
iface_guid
,
0
,
0
,
"
\\\\
?
\\
root#legacy_bogus#foo#{deadbeef-3f65-11db-b704-0011955c2bdb}"
);
check_device_iface
(
set
,
NULL
,
&
iface_guid
,
1
,
0
,
NULL
);
check_device_iface
(
set
,
NULL
,
&
iface_guid
,
1
,
0
,
NULL
);
...
@@ -2980,7 +2979,6 @@ todo_wine {
...
@@ -2980,7 +2979,6 @@ todo_wine {
ok
(
set
!=
INVALID_HANDLE_VALUE
,
"Failed to create device list, error %#x.
\n
"
,
GetLastError
());
ok
(
set
!=
INVALID_HANDLE_VALUE
,
"Failed to create device list, error %#x.
\n
"
,
GetLastError
());
check_device_list
(
set
,
&
GUID_NULL
);
check_device_list
(
set
,
&
GUID_NULL
);
check_device_info
(
set
,
0
,
&
guid
,
"ROOT
\\
LEGACY_BOGUS
\\
FOO"
);
check_device_info
(
set
,
0
,
&
guid
,
"ROOT
\\
LEGACY_BOGUS
\\
FOO"
);
todo_wine
check_device_info
(
set
,
1
,
NULL
,
NULL
);
check_device_info
(
set
,
1
,
NULL
,
NULL
);
check_device_iface
(
set
,
NULL
,
&
iface_guid
,
0
,
0
,
"
\\\\
?
\\
root#legacy_bogus#foo#{deadbeef-3f65-11db-b704-0011955c2bdb}"
);
check_device_iface
(
set
,
NULL
,
&
iface_guid
,
0
,
0
,
"
\\\\
?
\\
root#legacy_bogus#foo#{deadbeef-3f65-11db-b704-0011955c2bdb}"
);
check_device_iface
(
set
,
NULL
,
&
iface_guid
,
1
,
0
,
NULL
);
check_device_iface
(
set
,
NULL
,
&
iface_guid
,
1
,
0
,
NULL
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment