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
44ac73ef
Commit
44ac73ef
authored
Sep 21, 2007
by
Juan Lang
Committed by
Alexandre Julliard
Sep 24, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
setupapi: Convert device's interfaces to a standard list.
parent
4bfca01d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
66 deletions
+41
-66
devinst.c
dlls/setupapi/devinst.c
+41
-66
No files found.
dlls/setupapi/devinst.c
View file @
44ac73ef
...
...
@@ -33,6 +33,7 @@
#include "winnls.h"
#include "setupapi.h"
#include "wine/debug.h"
#include "wine/list.h"
#include "wine/unicode.h"
#include "cfgmgr32.h"
#include "initguid.h"
...
...
@@ -116,17 +117,16 @@ struct InterfaceInstances
DWORD
cInstances
;
DWORD
cInstancesAllocated
;
SP_DEVICE_INTERFACE_DATA
*
instances
;
struct
list
entry
;
};
/* Pointed to by SP_DEVINFO_DATA's Reserved member */
struct
DeviceInfo
{
HKEY
key
;
BOOL
phantom
;
LPWSTR
instanceId
;
DWORD
cInterfaces
;
DWORD
cInterfacesAllocated
;
struct
InterfaceInstances
*
interfaces
;
HKEY
key
;
BOOL
phantom
;
LPWSTR
instanceId
;
struct
list
interfaces
;
};
static
void
SETUPDI_GuidToString
(
const
GUID
*
guid
,
LPWSTR
guidStr
)
...
...
@@ -157,27 +157,29 @@ static void SETUPDI_FreeInterfaceInstances(struct InterfaceInstances *instances)
}
/* Finds the interface with interface class InterfaceClassGuid in the device.
* Returns TRUE if found, and updates
interfaceIndex to the index of the
*
device's
interfaces member where the given interface was found.
* Returns TRUE if found, and updates
*interface to point to device's
* interfaces member where the given interface was found.
* Returns FALSE if not found.
*/
static
BOOL
SETUPDI_FindInterface
(
const
struct
DeviceInfo
*
devInfo
,
const
GUID
*
InterfaceClassGuid
,
DWORD
*
interfaceIndex
)
const
GUID
*
InterfaceClassGuid
,
struct
InterfaceInstances
**
interface
)
{
BOOL
found
=
FALSE
;
DWORD
i
;
struct
InterfaceInstances
*
iface
;
TRACE
(
"%s
\n
"
,
debugstr_guid
(
InterfaceClassGuid
));
for
(
i
=
0
;
!
found
&&
i
<
devInfo
->
cInterfaces
;
i
++
)
LIST_FOR_EACH_ENTRY
(
iface
,
&
devInfo
->
interfaces
,
struct
InterfaceInstances
,
entry
)
{
if
(
IsEqualGUID
(
&
devInfo
->
interfaces
[
i
].
guid
,
InterfaceClassGuid
))
if
(
IsEqualGUID
(
&
iface
->
guid
,
InterfaceClassGuid
))
{
*
interface
Index
=
i
;
*
interface
=
iface
;
found
=
TRUE
;
break
;
}
}
TRACE
(
"returning %d (%
d)
\n
"
,
found
,
found
?
*
interfaceIndex
:
0
);
TRACE
(
"returning %d (%
p)
\n
"
,
found
,
found
?
*
interface
:
NULL
);
return
found
;
}
...
...
@@ -261,42 +263,21 @@ static BOOL SETUPDI_AddInterfaceInstance(struct DeviceInfo *devInfo,
SP_DEVICE_INTERFACE_DATA
**
ifaceData
)
{
BOOL
newInterface
=
FALSE
,
ret
;
DWORD
interfaceIndex
=
0
;
struct
InterfaceInstances
*
iface
=
NULL
;
TRACE
(
"%p %s %s %p
\n
"
,
devInfo
,
debugstr_guid
(
InterfaceClassGuid
),
debugstr_w
(
ReferenceString
),
iface
);
if
(
!
(
ret
=
SETUPDI_FindInterface
(
devInfo
,
InterfaceClassGuid
,
&
interfaceIndex
)))
if
(
!
(
ret
=
SETUPDI_FindInterface
(
devInfo
,
InterfaceClassGuid
,
&
iface
)))
{
if
(
!
devInfo
->
cInterfacesAllocated
)
{
devInfo
->
interfaces
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
struct
InterfaceInstances
));
if
(
devInfo
->
interfaces
)
{
iface
=
&
devInfo
->
interfaces
[
devInfo
->
cInterfacesAllocated
++
];
newInterface
=
TRUE
;
}
}
else
if
(
devInfo
->
cInterfaces
==
devInfo
->
cInterfacesAllocated
)
iface
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
struct
InterfaceInstances
));
if
(
iface
)
{
devInfo
->
interfaces
=
HeapReAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
devInfo
->
interfaces
,
(
devInfo
->
cInterfacesAllocated
+
1
)
*
sizeof
(
struct
InterfaceInstances
));
if
(
devInfo
->
interfaces
)
{
iface
=
&
devInfo
->
interfaces
[
devInfo
->
cInterfacesAllocated
++
];
newInterface
=
TRUE
;
}
list_add_tail
(
&
devInfo
->
interfaces
,
&
iface
->
entry
);
newInterface
=
TRUE
;
}
else
iface
=
&
devInfo
->
interfaces
[
devInfo
->
cInterfaces
];
}
else
iface
=
&
devInfo
->
interfaces
[
interfaceIndex
];
if
(
iface
)
{
DWORD
instanceIndex
=
0
;
...
...
@@ -359,11 +340,8 @@ static BOOL SETUPDI_AddInterfaceInstance(struct DeviceInfo *devInfo,
instance
->
Flags
=
SPINT_ACTIVE
;
/* FIXME */
instance
->
Reserved
=
(
ULONG_PTR
)
ifaceInfo
;
if
(
newInterface
)
{
memcpy
(
&
iface
->
guid
,
InterfaceClassGuid
,
sizeof
(
GUID
));
devInfo
->
cInterfaces
++
;
}
/* FIXME: now create this homeboy in the registry */
if
(
ifaceData
)
*
ifaceData
=
instance
;
...
...
@@ -376,8 +354,7 @@ static BOOL SETUPDI_AddInterfaceInstance(struct DeviceInfo *devInfo,
else
{
if
(
ifaceData
)
*
ifaceData
=
&
devInfo
->
interfaces
[
interfaceIndex
].
instances
[
instanceIndex
];
*
ifaceData
=
&
iface
->
instances
[
instanceIndex
];
}
}
else
...
...
@@ -436,8 +413,7 @@ static struct DeviceInfo *SETUPDI_AllocateDeviceInfo(LPCWSTR instanceId,
(
LPBYTE
)
&
phantom
,
sizeof
(
phantom
));
RegCloseKey
(
enumKey
);
}
devInfo
->
cInterfaces
=
devInfo
->
cInterfacesAllocated
=
0
;
devInfo
->
interfaces
=
NULL
;
list_init
(
&
devInfo
->
interfaces
);
}
else
{
...
...
@@ -450,7 +426,7 @@ static struct DeviceInfo *SETUPDI_AllocateDeviceInfo(LPCWSTR instanceId,
static
void
SETUPDI_FreeDeviceInfo
(
struct
DeviceInfo
*
devInfo
)
{
DWORD
i
;
struct
InterfaceInstances
*
iface
,
*
next
;
if
(
devInfo
->
key
!=
INVALID_HANDLE_VALUE
)
RegCloseKey
(
devInfo
->
key
);
...
...
@@ -468,9 +444,13 @@ static void SETUPDI_FreeDeviceInfo(struct DeviceInfo *devInfo)
}
}
HeapFree
(
GetProcessHeap
(),
0
,
devInfo
->
instanceId
);
for
(
i
=
0
;
i
<
devInfo
->
cInterfaces
;
i
++
)
SETUPDI_FreeInterfaceInstances
(
&
devInfo
->
interfaces
[
i
]);
HeapFree
(
GetProcessHeap
(),
0
,
devInfo
->
interfaces
);
LIST_FOR_EACH_ENTRY_SAFE
(
iface
,
next
,
&
devInfo
->
interfaces
,
struct
InterfaceInstances
,
entry
)
{
list_remove
(
&
iface
->
entry
);
SETUPDI_FreeInterfaceInstances
(
iface
);
HeapFree
(
GetProcessHeap
(),
0
,
iface
);
}
HeapFree
(
GetProcessHeap
(),
0
,
devInfo
);
}
...
...
@@ -2238,13 +2218,12 @@ BOOL WINAPI SetupDiEnumDeviceInterfaces(
{
struct
DeviceInfo
*
devInfo
=
(
struct
DeviceInfo
*
)
DeviceInfoData
->
Reserved
;
DWORD
i
;
struct
InterfaceInstances
*
iface
;
if
((
ret
=
SETUPDI_FindInterface
(
devInfo
,
InterfaceClassGuid
,
&
i
)))
if
((
ret
=
SETUPDI_FindInterface
(
devInfo
,
InterfaceClassGuid
,
&
i
face
)))
{
if
(
MemberIndex
<
devInfo
->
interfaces
[
i
].
cInstances
)
memcpy
(
DeviceInterfaceData
,
&
devInfo
->
interfaces
[
i
].
instances
[
MemberIndex
],
if
(
MemberIndex
<
iface
->
cInstances
)
memcpy
(
DeviceInterfaceData
,
&
iface
->
instances
[
MemberIndex
],
sizeof
(
SP_DEVICE_INTERFACE_DATA
));
else
{
...
...
@@ -2265,22 +2244,18 @@ BOOL WINAPI SetupDiEnumDeviceInterfaces(
{
struct
DeviceInfo
*
devInfo
=
(
struct
DeviceInfo
*
)
set
->
devices
[
i
].
Reserved
;
DWORD
interfaceIndex
;
struct
InterfaceInstances
*
iface
;
if
(
SETUPDI_FindInterface
(
devInfo
,
InterfaceClassGuid
,
&
interfaceIndex
))
if
(
SETUPDI_FindInterface
(
devInfo
,
InterfaceClassGuid
,
&
iface
))
{
struct
InterfaceInstances
*
interface
=
&
devInfo
->
interfaces
[
interfaceIndex
];
if
(
cEnumerated
+
interface
->
cInstances
<
MemberIndex
+
1
)
cEnumerated
+=
interface
->
cInstances
;
if
(
cEnumerated
+
iface
->
cInstances
<
MemberIndex
+
1
)
cEnumerated
+=
iface
->
cInstances
;
else
{
DWORD
instanceIndex
=
MemberIndex
-
cEnumerated
;
memcpy
(
DeviceInterfaceData
,
&
i
nter
face
->
instances
[
instanceIndex
],
&
iface
->
instances
[
instanceIndex
],
sizeof
(
SP_DEVICE_INTERFACE_DATA
));
cEnumerated
+=
instanceIndex
+
1
;
found
=
TRUE
;
...
...
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