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
aba3ed75
Commit
aba3ed75
authored
Nov 25, 2018
by
Zebediah Figura
Committed by
Alexandre Julliard
Nov 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
setupapi/devinst: Factor out get_device_set().
Signed-off-by:
Zebediah Figura
<
z.figura12@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
cdb486ae
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
124 deletions
+79
-124
devinst.c
dlls/setupapi/devinst.c
+79
-124
No files found.
dlls/setupapi/devinst.c
View file @
aba3ed75
...
@@ -129,10 +129,9 @@ struct device_iface
...
@@ -129,10 +129,9 @@ struct device_iface
struct
list
entry
;
struct
list
entry
;
};
};
static
struct
device
*
get_device
(
HDEVINFO
devinfo
,
const
SP_DEVINFO_DATA
*
data
)
static
struct
DeviceInfoSet
*
get_device_set
(
HDEVINFO
devinfo
)
{
{
struct
DeviceInfoSet
*
set
=
devinfo
;
struct
DeviceInfoSet
*
set
=
devinfo
;
struct
device
*
device
;
if
(
!
devinfo
||
devinfo
==
INVALID_HANDLE_VALUE
||
set
->
magic
!=
SETUP_DEVICE_INFO_SET_MAGIC
)
if
(
!
devinfo
||
devinfo
==
INVALID_HANDLE_VALUE
||
set
->
magic
!=
SETUP_DEVICE_INFO_SET_MAGIC
)
{
{
...
@@ -140,6 +139,17 @@ static struct device *get_device(HDEVINFO devinfo, const SP_DEVINFO_DATA *data)
...
@@ -140,6 +139,17 @@ static struct device *get_device(HDEVINFO devinfo, const SP_DEVINFO_DATA *data)
return
NULL
;
return
NULL
;
}
}
return
set
;
}
static
struct
device
*
get_device
(
HDEVINFO
devinfo
,
const
SP_DEVINFO_DATA
*
data
)
{
struct
DeviceInfoSet
*
set
;
struct
device
*
device
;
if
(
!
(
set
=
get_device_set
(
devinfo
)))
return
FALSE
;
if
(
!
data
||
data
->
cbSize
!=
sizeof
(
*
data
)
||
!
data
->
Reserved
)
if
(
!
data
||
data
->
cbSize
!=
sizeof
(
*
data
)
||
!
data
->
Reserved
)
{
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
...
@@ -159,13 +169,8 @@ static struct device *get_device(HDEVINFO devinfo, const SP_DEVINFO_DATA *data)
...
@@ -159,13 +169,8 @@ static struct device *get_device(HDEVINFO devinfo, const SP_DEVINFO_DATA *data)
static
struct
device_iface
*
get_device_iface
(
HDEVINFO
devinfo
,
const
SP_DEVICE_INTERFACE_DATA
*
data
)
static
struct
device_iface
*
get_device_iface
(
HDEVINFO
devinfo
,
const
SP_DEVICE_INTERFACE_DATA
*
data
)
{
{
struct
DeviceInfoSet
*
set
=
devinfo
;
if
(
!
get_device_set
(
devinfo
))
return
FALSE
;
if
(
!
devinfo
||
devinfo
==
INVALID_HANDLE_VALUE
||
set
->
magic
!=
SETUP_DEVICE_INFO_SET_MAGIC
)
{
SetLastError
(
ERROR_INVALID_HANDLE
);
return
NULL
;
}
if
(
!
data
||
data
->
cbSize
!=
sizeof
(
*
data
)
||
!
data
->
Reserved
)
if
(
!
data
||
data
->
cbSize
!=
sizeof
(
*
data
)
||
!
data
->
Reserved
)
{
{
...
@@ -1387,38 +1392,33 @@ static DWORD SETUPDI_DevNameToDevID(LPCWSTR devName)
...
@@ -1387,38 +1392,33 @@ static DWORD SETUPDI_DevNameToDevID(LPCWSTR devName)
/***********************************************************************
/***********************************************************************
* SetupDiCreateDeviceInfoW (SETUPAPI.@)
* SetupDiCreateDeviceInfoW (SETUPAPI.@)
*/
*/
BOOL
WINAPI
SetupDiCreateDeviceInfoW
(
HDEVINFO
DeviceInfoSet
,
PCWSTR
DeviceName
,
BOOL
WINAPI
SetupDiCreateDeviceInfoW
(
HDEVINFO
devinfo
,
PCWSTR
DeviceName
,
const
GUID
*
ClassGuid
,
PCWSTR
DeviceDescription
,
HWND
hwndParent
,
DWORD
CreationFlags
,
const
GUID
*
ClassGuid
,
PCWSTR
DeviceDescription
,
HWND
hwndParent
,
DWORD
CreationFlags
,
SP_DEVINFO_DATA
*
device_data
)
SP_DEVINFO_DATA
*
device_data
)
{
{
struct
DeviceInfoSet
*
set
=
DeviceInfoSet
;
struct
DeviceInfoSet
*
set
;
BOOL
ret
=
FALSE
,
allocatedInstanceId
=
FALSE
;
BOOL
ret
=
FALSE
,
allocatedInstanceId
=
FALSE
;
LPCWSTR
instanceId
=
NULL
;
LPCWSTR
instanceId
=
NULL
;
TRACE
(
"
%p %s %s %s %p %x %p
\n
"
,
DeviceInfoSet
,
debugstr_w
(
DeviceName
)
,
TRACE
(
"
devinfo %p, name %s, class %s, description %s, hwnd %p, flags %#x, device_data %p.
\n
"
,
debugstr_guid
(
ClassGuid
),
debugstr_w
(
DeviceDescription
),
devinfo
,
debugstr_w
(
DeviceName
),
debugstr_guid
(
ClassGuid
),
debugstr_w
(
DeviceDescription
),
hwndParent
,
CreationFlags
,
device_data
);
hwndParent
,
CreationFlags
,
device_data
);
if
(
!
DeviceName
)
if
(
!
DeviceName
)
{
{
SetLastError
(
ERROR_INVALID_DEVINST_NAME
);
SetLastError
(
ERROR_INVALID_DEVINST_NAME
);
return
FALSE
;
return
FALSE
;
}
}
if
(
!
DeviceInfoSet
||
DeviceInfoSet
==
INVALID_HANDLE_VALUE
)
{
if
(
!
(
set
=
get_device_set
(
devinfo
)))
SetLastError
(
ERROR_INVALID_HANDLE
);
return
FALSE
;
return
FALSE
;
}
if
(
!
ClassGuid
)
if
(
!
ClassGuid
)
{
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
return
FALSE
;
}
}
if
(
set
->
magic
!=
SETUP_DEVICE_INFO_SET_MAGIC
)
{
SetLastError
(
ERROR_INVALID_HANDLE
);
return
FALSE
;
}
if
(
!
IsEqualGUID
(
&
set
->
ClassGuid
,
&
GUID_NULL
)
&&
if
(
!
IsEqualGUID
(
&
set
->
ClassGuid
,
&
GUID_NULL
)
&&
!
IsEqualGUID
(
ClassGuid
,
&
set
->
ClassGuid
))
!
IsEqualGUID
(
ClassGuid
,
&
set
->
ClassGuid
))
{
{
...
@@ -1561,54 +1561,45 @@ BOOL WINAPI SetupDiRemoveDeviceInterface(HDEVINFO info, PSP_DEVICE_INTERFACE_DAT
...
@@ -1561,54 +1561,45 @@ BOOL WINAPI SetupDiRemoveDeviceInterface(HDEVINFO info, PSP_DEVICE_INTERFACE_DAT
/***********************************************************************
/***********************************************************************
* SetupDiEnumDeviceInfo (SETUPAPI.@)
* SetupDiEnumDeviceInfo (SETUPAPI.@)
*/
*/
BOOL
WINAPI
SetupDiEnumDeviceInfo
(
BOOL
WINAPI
SetupDiEnumDeviceInfo
(
HDEVINFO
devinfo
,
DWORD
index
,
SP_DEVINFO_DATA
*
device_data
)
HDEVINFO
devinfo
,
DWORD
index
,
PSP_DEVINFO_DATA
info
)
{
{
BOOL
ret
=
FALSE
;
struct
DeviceInfoSet
*
set
;
struct
device
*
device
;
DWORD
i
=
0
;
TRACE
(
"
%p %d %p
\n
"
,
devinfo
,
index
,
info
);
TRACE
(
"
devinfo %p, index %d, device_data %p
\n
"
,
devinfo
,
index
,
device_data
);
if
(
info
==
NULL
)
if
(
!
(
set
=
get_device_set
(
devinfo
)))
return
FALSE
;
if
(
!
device_data
)
{
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
return
FALSE
;
}
}
if
(
devinfo
&&
devinfo
!=
INVALID_HANDLE_VALUE
)
if
(
device_data
->
cbSize
!=
sizeof
(
SP_DEVINFO_DATA
))
{
{
struct
DeviceInfoSet
*
list
=
devinfo
;
SetLastError
(
ERROR_INVALID_USER_BUFFER
);
if
(
list
->
magic
==
SETUP_DEVICE_INFO_SET_MAGIC
)
return
FALSE
;
{
}
if
(
index
<
list
->
cDevices
)
{
if
(
info
->
cbSize
==
sizeof
(
SP_DEVINFO_DATA
))
{
struct
device
*
device
;
DWORD
i
=
0
;
LIST_FOR_EACH_ENTRY
(
device
,
&
list
->
devices
,
struct
device
,
entry
)
if
(
index
>=
set
->
cDevices
)
{
{
if
(
i
++
==
index
)
SetLastError
(
ERROR_NO_MORE_ITEMS
);
{
return
FALSE
;
copy_device_data
(
info
,
device
);
}
break
;
}
LIST_FOR_EACH_ENTRY
(
device
,
&
set
->
devices
,
struct
device
,
entry
)
}
{
ret
=
TRUE
;
if
(
i
++
==
index
)
}
{
else
copy_device_data
(
device_data
,
device
);
SetLastError
(
ERROR_INVALID_USER_BUFFER
);
break
;
}
else
SetLastError
(
ERROR_NO_MORE_ITEMS
);
}
}
else
SetLastError
(
ERROR_INVALID_HANDLE
);
}
}
else
SetLastError
(
ERROR_INVALID_HANDLE
);
return
TRUE
;
return
ret
;
}
}
/***********************************************************************
/***********************************************************************
...
@@ -2338,24 +2329,15 @@ HDEVINFO WINAPI SetupDiGetClassDevsExW(const GUID *class, PCWSTR enumstr, HWND p
...
@@ -2338,24 +2329,15 @@ HDEVINFO WINAPI SetupDiGetClassDevsExW(const GUID *class, PCWSTR enumstr, HWND p
/***********************************************************************
/***********************************************************************
* SetupDiGetDeviceInfoListDetailA (SETUPAPI.@)
* SetupDiGetDeviceInfoListDetailA (SETUPAPI.@)
*/
*/
BOOL
WINAPI
SetupDiGetDeviceInfoListDetailA
(
BOOL
WINAPI
SetupDiGetDeviceInfoListDetailA
(
HDEVINFO
devinfo
,
SP_DEVINFO_LIST_DETAIL_DATA_A
*
DevInfoData
)
HDEVINFO
DeviceInfoSet
,
PSP_DEVINFO_LIST_DETAIL_DATA_A
DevInfoData
)
{
{
struct
DeviceInfoSet
*
set
=
DeviceInfoSet
;
struct
DeviceInfoSet
*
set
;
TRACE
(
"
%p %p
\n
"
,
DeviceInfoSet
,
DevInfoData
);
TRACE
(
"
devinfo %p, detail_data %p.
\n
"
,
devinfo
,
DevInfoData
);
if
(
!
DeviceInfoSet
||
DeviceInfoSet
==
INVALID_HANDLE_VALUE
)
if
(
!
(
set
=
get_device_set
(
devinfo
)))
{
SetLastError
(
ERROR_INVALID_HANDLE
);
return
FALSE
;
return
FALSE
;
}
if
(
set
->
magic
!=
SETUP_DEVICE_INFO_SET_MAGIC
)
{
SetLastError
(
ERROR_INVALID_HANDLE
);
return
FALSE
;
}
if
(
!
DevInfoData
||
if
(
!
DevInfoData
||
DevInfoData
->
cbSize
!=
sizeof
(
SP_DEVINFO_LIST_DETAIL_DATA_A
))
DevInfoData
->
cbSize
!=
sizeof
(
SP_DEVINFO_LIST_DETAIL_DATA_A
))
{
{
...
@@ -2371,24 +2353,15 @@ BOOL WINAPI SetupDiGetDeviceInfoListDetailA(
...
@@ -2371,24 +2353,15 @@ BOOL WINAPI SetupDiGetDeviceInfoListDetailA(
/***********************************************************************
/***********************************************************************
* SetupDiGetDeviceInfoListDetailW (SETUPAPI.@)
* SetupDiGetDeviceInfoListDetailW (SETUPAPI.@)
*/
*/
BOOL
WINAPI
SetupDiGetDeviceInfoListDetailW
(
BOOL
WINAPI
SetupDiGetDeviceInfoListDetailW
(
HDEVINFO
devinfo
,
SP_DEVINFO_LIST_DETAIL_DATA_W
*
DevInfoData
)
HDEVINFO
DeviceInfoSet
,
PSP_DEVINFO_LIST_DETAIL_DATA_W
DevInfoData
)
{
{
struct
DeviceInfoSet
*
set
=
DeviceInfoSet
;
struct
DeviceInfoSet
*
set
;
TRACE
(
"
%p %p
\n
"
,
DeviceInfoSet
,
DevInfoData
);
TRACE
(
"
devinfo %p, detail_data %p.
\n
"
,
devinfo
,
DevInfoData
);
if
(
!
DeviceInfoSet
||
DeviceInfoSet
==
INVALID_HANDLE_VALUE
)
if
(
!
(
set
=
get_device_set
(
devinfo
)))
{
SetLastError
(
ERROR_INVALID_HANDLE
);
return
FALSE
;
}
if
(
set
->
magic
!=
SETUP_DEVICE_INFO_SET_MAGIC
)
{
SetLastError
(
ERROR_INVALID_HANDLE
);
return
FALSE
;
return
FALSE
;
}
if
(
!
DevInfoData
||
if
(
!
DevInfoData
||
DevInfoData
->
cbSize
!=
sizeof
(
SP_DEVINFO_LIST_DETAIL_DATA_W
))
DevInfoData
->
cbSize
!=
sizeof
(
SP_DEVINFO_LIST_DETAIL_DATA_W
))
{
{
...
@@ -2624,26 +2597,14 @@ BOOL WINAPI SetupDiEnumDeviceInterfaces(HDEVINFO devinfo,
...
@@ -2624,26 +2597,14 @@ BOOL WINAPI SetupDiEnumDeviceInterfaces(HDEVINFO devinfo,
SP_DEVINFO_DATA
*
device_data
,
const
GUID
*
class
,
DWORD
index
,
SP_DEVINFO_DATA
*
device_data
,
const
GUID
*
class
,
DWORD
index
,
SP_DEVICE_INTERFACE_DATA
*
iface_data
)
SP_DEVICE_INTERFACE_DATA
*
iface_data
)
{
{
struct
DeviceInfoSet
*
set
=
devinfo
;
struct
DeviceInfoSet
*
set
;
struct
device
*
device
;
struct
device
*
device
;
struct
device_iface
*
iface
;
struct
device_iface
*
iface
;
DWORD
i
=
0
;
DWORD
i
=
0
;
TRACE
(
"
%p, %p, %s, %u, %p
\n
"
,
devinfo
,
device_data
,
debugstr_guid
(
class
)
,
TRACE
(
"
devinfo %p, device_data %p, class %s, index %u, iface_data %p.
\n
"
,
index
,
iface_data
);
devinfo
,
device_data
,
debugstr_guid
(
class
),
index
,
iface_data
);
if
(
!
devinfo
||
devinfo
==
INVALID_HANDLE_VALUE
||
set
->
magic
!=
SETUP_DEVICE_INFO_SET_MAGIC
)
{
SetLastError
(
ERROR_INVALID_HANDLE
);
return
FALSE
;
}
if
(
device_data
&&
(
device_data
->
cbSize
!=
sizeof
(
SP_DEVINFO_DATA
)
||
!
device_data
->
Reserved
))
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
if
(
!
iface_data
||
iface_data
->
cbSize
!=
sizeof
(
SP_DEVICE_INTERFACE_DATA
))
if
(
!
iface_data
||
iface_data
->
cbSize
!=
sizeof
(
SP_DEVICE_INTERFACE_DATA
))
{
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
...
@@ -2656,7 +2617,8 @@ BOOL WINAPI SetupDiEnumDeviceInterfaces(HDEVINFO devinfo,
...
@@ -2656,7 +2617,8 @@ BOOL WINAPI SetupDiEnumDeviceInterfaces(HDEVINFO devinfo,
if
(
device_data
)
if
(
device_data
)
{
{
device
=
(
struct
device
*
)
device_data
->
Reserved
;
if
(
!
(
device
=
get_device
(
devinfo
,
device_data
)))
return
FALSE
;
LIST_FOR_EACH_ENTRY
(
iface
,
&
device
->
interfaces
,
struct
device_iface
,
entry
)
LIST_FOR_EACH_ENTRY
(
iface
,
&
device
->
interfaces
,
struct
device_iface
,
entry
)
{
{
...
@@ -2673,6 +2635,9 @@ BOOL WINAPI SetupDiEnumDeviceInterfaces(HDEVINFO devinfo,
...
@@ -2673,6 +2635,9 @@ BOOL WINAPI SetupDiEnumDeviceInterfaces(HDEVINFO devinfo,
}
}
else
else
{
{
if
(
!
(
set
=
get_device_set
(
devinfo
)))
return
FALSE
;
LIST_FOR_EACH_ENTRY
(
device
,
&
set
->
devices
,
struct
device
,
entry
)
LIST_FOR_EACH_ENTRY
(
device
,
&
set
->
devices
,
struct
device
,
entry
)
{
{
LIST_FOR_EACH_ENTRY
(
iface
,
&
device
->
interfaces
,
struct
device_iface
,
entry
)
LIST_FOR_EACH_ENTRY
(
iface
,
&
device
->
interfaces
,
struct
device_iface
,
entry
)
...
@@ -2708,31 +2673,21 @@ BOOL WINAPI SetupDiEnumDeviceInterfaces(HDEVINFO devinfo,
...
@@ -2708,31 +2673,21 @@ BOOL WINAPI SetupDiEnumDeviceInterfaces(HDEVINFO devinfo,
*/
*/
BOOL
WINAPI
SetupDiDestroyDeviceInfoList
(
HDEVINFO
devinfo
)
BOOL
WINAPI
SetupDiDestroyDeviceInfoList
(
HDEVINFO
devinfo
)
{
{
BOOL
ret
=
FALSE
;
struct
DeviceInfoSet
*
set
;
struct
device
*
device
,
*
device2
;
TRACE
(
"%p
\n
"
,
devinfo
);
TRACE
(
"devinfo %p.
\n
"
,
devinfo
);
if
(
devinfo
&&
devinfo
!=
INVALID_HANDLE_VALUE
)
{
struct
DeviceInfoSet
*
list
=
devinfo
;
if
(
list
->
magic
==
SETUP_DEVICE_INFO_SET_MAGIC
)
if
(
!
(
set
=
get_device_set
(
devinfo
)))
{
return
FALSE
;
struct
device
*
device
,
*
device2
;
LIST_FOR_EACH_ENTRY_SAFE
(
device
,
device2
,
&
list
->
devices
,
LIST_FOR_EACH_ENTRY_SAFE
(
device
,
device2
,
&
set
->
devices
,
struct
device
,
entry
)
struct
device
,
entry
)
{
{
SETUPDI_RemoveDevice
(
device
);
SETUPDI_RemoveDevice
(
device
);
}
HeapFree
(
GetProcessHeap
(),
0
,
list
);
ret
=
TRUE
;
}
}
}
heap_free
(
set
);
if
(
!
ret
)
return
TRUE
;
SetLastError
(
ERROR_INVALID_HANDLE
);
return
ret
;
}
}
/***********************************************************************
/***********************************************************************
...
...
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