Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
cdb486ae
Commit
cdb486ae
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_iface().
Signed-off-by:
Zebediah Figura
<
z.figura12@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
62bf00b9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
78 deletions
+43
-78
devinst.c
dlls/setupapi/devinst.c
+43
-78
No files found.
dlls/setupapi/devinst.c
View file @
cdb486ae
...
...
@@ -157,6 +157,25 @@ static struct device *get_device(HDEVINFO devinfo, const SP_DEVINFO_DATA *data)
return
device
;
}
static
struct
device_iface
*
get_device_iface
(
HDEVINFO
devinfo
,
const
SP_DEVICE_INTERFACE_DATA
*
data
)
{
struct
DeviceInfoSet
*
set
=
devinfo
;
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
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
NULL
;
}
return
(
struct
device_iface
*
)
data
->
Reserved
;
}
static
inline
void
copy_device_data
(
SP_DEVINFO_DATA
*
data
,
const
struct
device
*
device
)
{
data
->
ClassGuid
=
device
->
class
;
...
...
@@ -2493,34 +2512,22 @@ HKEY WINAPI SetupDiCreateDeviceInterfaceRegKeyW(HDEVINFO devinfo,
SP_DEVICE_INTERFACE_DATA
*
iface_data
,
DWORD
reserved
,
REGSAM
access
,
HINF
hinf
,
const
WCHAR
*
section
)
{
struct
DeviceInfoSet
*
set
=
devinfo
;
struct
device_iface
*
iface
;
HKEY
refstr_key
,
params_key
;
WCHAR
*
path
;
LONG
ret
;
TRACE
(
"%p %p %d %#x %p %s
\n
"
,
devinfo
,
iface_data
,
reserved
,
access
,
hinf
,
debugstr_w
(
section
));
TRACE
(
"devinfo %p, iface_data %p, reserved %d, access %#x, hinf %p, section %s.
\n
"
,
devinfo
,
iface_data
,
reserved
,
access
,
hinf
,
debugstr_w
(
section
));
if
(
!
(
iface
=
get_device_iface
(
devinfo
,
iface_data
)))
if
(
!
devinfo
||
devinfo
==
INVALID_HANDLE_VALUE
||
set
->
magic
!=
SETUP_DEVICE_INFO_SET_MAGIC
)
{
SetLastError
(
ERROR_INVALID_HANDLE
);
return
INVALID_HANDLE_VALUE
;
}
if
(
!
iface_data
||
iface_data
->
cbSize
!=
sizeof
(
SP_DEVICE_INTERFACE_DATA
)
||
!
iface_data
->
Reserved
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
INVALID_HANDLE_VALUE
;
}
if
(
hinf
&&
!
section
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
INVALID_HANDLE_VALUE
;
}
iface
=
(
struct
device_iface
*
)
iface_data
->
Reserved
;
if
(
!
(
path
=
get_refstr_key_path
(
iface
)))
{
SetLastError
(
ERROR_OUTOFMEMORY
);
...
...
@@ -2554,28 +2561,16 @@ HKEY WINAPI SetupDiCreateDeviceInterfaceRegKeyW(HDEVINFO devinfo,
BOOL
WINAPI
SetupDiDeleteDeviceInterfaceRegKey
(
HDEVINFO
devinfo
,
SP_DEVICE_INTERFACE_DATA
*
iface_data
,
DWORD
reserved
)
{
struct
DeviceInfoSet
*
set
=
devinfo
;
struct
device_iface
*
iface
;
HKEY
refstr_key
;
WCHAR
*
path
;
LONG
ret
;
TRACE
(
"
%p %p %d
\n
"
,
devinfo
,
iface_data
,
reserved
);
TRACE
(
"
devinfo %p, iface_data %p, reserved %d.
\n
"
,
devinfo
,
iface_data
,
reserved
);
if
(
!
devinfo
||
devinfo
==
INVALID_HANDLE_VALUE
||
set
->
magic
!=
SETUP_DEVICE_INFO_SET_MAGIC
)
{
SetLastError
(
ERROR_INVALID_HANDLE
);
return
FALSE
;
}
if
(
!
iface_data
||
iface_data
->
cbSize
!=
sizeof
(
SP_DEVICE_INTERFACE_DATA
)
||
!
iface_data
->
Reserved
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
if
(
!
(
iface
=
get_device_iface
(
devinfo
,
iface_data
)))
return
FALSE
;
}
iface
=
(
struct
device_iface
*
)
iface_data
->
Reserved
;
if
(
!
(
path
=
get_refstr_key_path
(
iface
)))
{
SetLastError
(
ERROR_OUTOFMEMORY
);
...
...
@@ -2743,36 +2738,21 @@ BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
/***********************************************************************
* SetupDiGetDeviceInterfaceDetailA (SETUPAPI.@)
*/
BOOL
WINAPI
SetupDiGetDeviceInterfaceDetailA
(
HDEVINFO
DeviceInfoSet
,
PSP_DEVICE_INTERFACE_DATA
DeviceInterfaceData
,
PSP_DEVICE_INTERFACE_DETAIL_DATA_A
DeviceInterfaceDetailData
,
DWORD
DeviceInterfaceDetailDataSize
,
PDWORD
RequiredSize
,
SP_DEVINFO_DATA
*
device_data
)
BOOL
WINAPI
SetupDiGetDeviceInterfaceDetailA
(
HDEVINFO
devinfo
,
SP_DEVICE_INTERFACE_DATA
*
iface_data
,
SP_DEVICE_INTERFACE_DETAIL_DATA_A
*
DeviceInterfaceDetailData
,
DWORD
DeviceInterfaceDetailDataSize
,
DWORD
*
RequiredSize
,
SP_DEVINFO_DATA
*
device_data
)
{
struct
DeviceInfoSet
*
set
=
DeviceInfoSet
;
struct
device_iface
*
iface
;
DWORD
bytesNeeded
=
FIELD_OFFSET
(
SP_DEVICE_INTERFACE_DETAIL_DATA_A
,
DevicePath
[
1
]);
BOOL
ret
=
FALSE
;
TRACE
(
"
(%p, %p, %p, %d, %p, %p)
\n
"
,
DeviceInfoSet
,
DeviceInterfaceData
,
DeviceInterfaceDetailData
,
DeviceInterfaceDetailDataSize
,
RequiredSize
,
device_data
);
TRACE
(
"
devinfo %p, iface_data %p, detail_data %p, size %d, needed %p, device_data %p.
\n
"
,
devinfo
,
iface_data
,
DeviceInterfaceDetailData
,
DeviceInterfaceDetailDataSize
,
RequiredSize
,
device_data
);
if
(
!
DeviceInfoSet
||
DeviceInfoSet
==
INVALID_HANDLE_VALUE
||
set
->
magic
!=
SETUP_DEVICE_INFO_SET_MAGIC
)
{
SetLastError
(
ERROR_INVALID_HANDLE
);
return
FALSE
;
}
if
(
!
DeviceInterfaceData
||
DeviceInterfaceData
->
cbSize
!=
sizeof
(
SP_DEVICE_INTERFACE_DATA
)
||
!
DeviceInterfaceData
->
Reserved
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
if
(
!
(
iface
=
get_device_iface
(
devinfo
,
iface_data
)))
return
FALSE
;
}
if
(
DeviceInterfaceDetailData
&&
DeviceInterfaceDetailData
->
cbSize
!=
sizeof
(
SP_DEVICE_INTERFACE_DETAIL_DATA_A
))
{
...
...
@@ -2784,7 +2764,7 @@ BOOL WINAPI SetupDiGetDeviceInterfaceDetailA(
SetLastError
(
ERROR_INVALID_USER_BUFFER
);
return
FALSE
;
}
iface
=
(
struct
device_iface
*
)
DeviceInterfaceData
->
Reserved
;
if
(
iface
->
symlink
)
bytesNeeded
+=
WideCharToMultiByte
(
CP_ACP
,
0
,
iface
->
symlink
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
...
...
@@ -2816,37 +2796,22 @@ BOOL WINAPI SetupDiGetDeviceInterfaceDetailA(
/***********************************************************************
* SetupDiGetDeviceInterfaceDetailW (SETUPAPI.@)
*/
BOOL
WINAPI
SetupDiGetDeviceInterfaceDetailW
(
HDEVINFO
DeviceInfoSet
,
PSP_DEVICE_INTERFACE_DATA
DeviceInterfaceData
,
PSP_DEVICE_INTERFACE_DETAIL_DATA_W
DeviceInterfaceDetailData
,
DWORD
DeviceInterfaceDetailDataSize
,
PDWORD
RequiredSize
,
SP_DEVINFO_DATA
*
device_data
)
BOOL
WINAPI
SetupDiGetDeviceInterfaceDetailW
(
HDEVINFO
devinfo
,
SP_DEVICE_INTERFACE_DATA
*
iface_data
,
SP_DEVICE_INTERFACE_DETAIL_DATA_W
*
DeviceInterfaceDetailData
,
DWORD
DeviceInterfaceDetailDataSize
,
DWORD
*
RequiredSize
,
SP_DEVINFO_DATA
*
device_data
)
{
struct
DeviceInfoSet
*
set
=
DeviceInfoSet
;
struct
device_iface
*
iface
;
DWORD
bytesNeeded
=
offsetof
(
SP_DEVICE_INTERFACE_DETAIL_DATA_W
,
DevicePath
)
+
sizeof
(
WCHAR
);
/* include NULL terminator */
BOOL
ret
=
FALSE
;
TRACE
(
"
(%p, %p, %p, %d, %p, %p)
\n
"
,
DeviceInfoSet
,
DeviceInterfaceData
,
DeviceInterfaceDetailData
,
DeviceInterfaceDetailDataSize
,
RequiredSize
,
device_data
);
TRACE
(
"
devinfo %p, iface_data %p, detail_data %p, size %d, needed %p, device_data %p.
\n
"
,
devinfo
,
iface_data
,
DeviceInterfaceDetailData
,
DeviceInterfaceDetailDataSize
,
RequiredSize
,
device_data
);
if
(
!
DeviceInfoSet
||
DeviceInfoSet
==
INVALID_HANDLE_VALUE
||
set
->
magic
!=
SETUP_DEVICE_INFO_SET_MAGIC
)
{
SetLastError
(
ERROR_INVALID_HANDLE
);
if
(
!
(
iface
=
get_device_iface
(
devinfo
,
iface_data
)))
return
FALSE
;
}
if
(
!
DeviceInterfaceData
||
DeviceInterfaceData
->
cbSize
!=
sizeof
(
SP_DEVICE_INTERFACE_DATA
)
||
!
DeviceInterfaceData
->
Reserved
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
if
(
DeviceInterfaceDetailData
&&
(
DeviceInterfaceDetailData
->
cbSize
<
offsetof
(
SP_DEVICE_INTERFACE_DETAIL_DATA_W
,
DevicePath
)
+
sizeof
(
WCHAR
)
||
DeviceInterfaceDetailData
->
cbSize
>
sizeof
(
SP_DEVICE_INTERFACE_DETAIL_DATA_W
)))
...
...
@@ -2859,7 +2824,7 @@ BOOL WINAPI SetupDiGetDeviceInterfaceDetailW(
SetLastError
(
ERROR_INVALID_USER_BUFFER
);
return
FALSE
;
}
iface
=
(
struct
device_iface
*
)
DeviceInterfaceData
->
Reserved
;
if
(
iface
->
symlink
)
bytesNeeded
+=
sizeof
(
WCHAR
)
*
lstrlenW
(
iface
->
symlink
);
if
(
DeviceInterfaceDetailDataSize
>=
bytesNeeded
)
...
...
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