[Wine-patches] [eterhack 04/12] ntoskrnl.exe: Add get_registered_interface().
Alexander Morozov
=?iso-8859-1?q?amorozov_=CE=C1_etersoft=2Eru?=
Чт Май 21 17:53:40 MSD 2009
---
dlls/ntoskrnl.exe/ntoskrnl.c | 26 +++++++++++++++++---------
1 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index 2f7b34f..eab4f5b 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -280,6 +280,19 @@ static BOOL compare_ids( WCHAR *hardware_id, WCHAR *instance_id,
return TRUE;
}
+/* caller is responsible for proper locking to prevent modifying Interfaces list */
+static struct InterfaceInstance *get_registered_interface( WCHAR *name, USHORT len )
+{
+ struct InterfaceInstance *interf;
+
+ LIST_FOR_EACH_ENTRY( interf, &Interfaces, struct InterfaceInstance, entry )
+ {
+ if (!strncmpW( name, interf->link, len ))
+ return interf;
+ }
+ return NULL;
+}
+
static HANDLE get_device_manager(void)
{
static HANDLE device_manager;
@@ -1637,15 +1650,10 @@ NTSTATUS WINAPI IoSetDeviceInterfaceState( PUNICODE_STRING SymbolicLinkName,
/* create symbolic link if interface is registered */
status = STATUS_OBJECT_NAME_NOT_FOUND;
EnterCriticalSection( &cs );
- LIST_FOR_EACH_ENTRY( interf, &Interfaces, struct InterfaceInstance, entry )
- {
- if (!strncmpW( SymbolicLinkName->Buffer, interf->link,
- SymbolicLinkName->Length ))
- {
- status = IoCreateSymbolicLink( SymbolicLinkName, &interf->target );
- break;
- }
- }
+ interf = get_registered_interface( SymbolicLinkName->Buffer,
+ SymbolicLinkName->Length / sizeof(WCHAR) );
+ if (interf != NULL)
+ status = IoCreateSymbolicLink( SymbolicLinkName, &interf->target );
if (status != STATUS_SUCCESS)
{
LeaveCriticalSection( &cs );
--
1.6.2.5
Подробная информация о списке рассылки Wine-patches