diff --git a/reactos/include/ntos/rtl.h b/reactos/include/ntos/rtl.h index df7c4c2aeea..8ce78c8e4f6 100755 --- a/reactos/include/ntos/rtl.h +++ b/reactos/include/ntos/rtl.h @@ -1,7 +1,6 @@ -/* $Id: rtl.h,v 1.23 2004/01/18 22:28:48 gdalsnes Exp $ +/* $Id: rtl.h,v 1.24 2004/01/23 18:00:53 navaraf Exp $ * */ - #ifndef __DDK_RTL_H #define __DDK_RTL_H @@ -13,7 +12,7 @@ #endif /* __NTOSKRNL__ || __NTDRIVER__ || __NTHAL__ || __NTDLL__ || __NTAPP__ */ #include - +#include #ifndef __USE_W32API @@ -991,6 +990,13 @@ RtlFillMemoryUlong ( ULONG Fill ); +NTSTATUS +STDCALL +RtlStringFromGUID ( + IN REFGUID Guid, + OUT PUNICODE_STRING GuidString + ); + ULONG STDCALL RtlFindClearBits ( @@ -1732,7 +1738,7 @@ RtlSizeHeap ( { \ *((PUSHORT)(Address))=(USHORT)(Value); \ } - + BOOLEAN STDCALL RtlTimeFieldsToTime ( diff --git a/reactos/lib/ntdll/stubs/stubs.c b/reactos/lib/ntdll/stubs/stubs.c index 079ab0f078d..fa1e8ab8d1d 100644 --- a/reactos/lib/ntdll/stubs/stubs.c +++ b/reactos/lib/ntdll/stubs/stubs.c @@ -879,19 +879,6 @@ RtlMergeRangeLists( return(FALSE); } -/* - * @unimplemented - */ -NTSTATUS -STDCALL -RtlStringFromGUID( - IN REFGUID Guid, - OUT PUNICODE_STRING GuidString - ) -{ - return(FALSE); -} - /* * @unimplemented */ diff --git a/reactos/ntoskrnl/io/deviface.c b/reactos/ntoskrnl/io/deviface.c index e91df741d04..1e9a064be70 100644 --- a/reactos/ntoskrnl/io/deviface.c +++ b/reactos/ntoskrnl/io/deviface.c @@ -4,8 +4,9 @@ * FILE: ntoskrnl/io/pnpmgr/devintrf.c * PURPOSE: Device interface functions * PROGRAMMER: Filip Navara (xnavara@volny.cz) + * Matthew Brace (ismarc@austin.rr.com) * UPDATE HISTORY: - * 22/09/2003 FiN Created + * 22/09/2003 FiN Created */ /* INCLUDES ******************************************************************/ @@ -26,10 +27,13 @@ DEFINE_GUID(GUID_CLASS_COMPORT, 0x86e0d1e0L, 0x8089, 0x11d0, 0x9c, 0xe4 DEFINE_GUID(GUID_SERENUM_BUS_ENUMERATOR, 0x4D36E978L, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18); #endif // DEFINE_GUID + /* FUNCTIONS *****************************************************************/ /* - * @unimplemented + * @implemented + * + * returns a key to a specific device interface */ NTSTATUS STDCALL @@ -38,12 +42,30 @@ IoOpenDeviceInterfaceRegistryKey( IN ACCESS_MASK DesiredAccess, OUT PHANDLE DeviceInterfaceKey) { - DPRINT("IoOpenDeviceInterfaceRegistryKey called (UNIMPLEMENTED)\n"); - return STATUS_NOT_IMPLEMENTED; + NTSTATUS Status; + POBJECT_ATTRIBUTES ObjectAttributes; + + InitializeObjectAttributes( ObjectAttributes, + SymbolicLinkName, + OBJ_CASE_INSENSITIVE, + NULL, + NULL ); + + Status = ZwOpenKey( DeviceInterfaceKey, + DesiredAccess, + ObjectAttributes ); + + if( !NT_SUCCESS( Status ) ) + { + DPRINT( "ZwOpenKey() failed" ); + return Status; + } + + return STATUS_SUCCESS; } /* - * @unimplemented + * @implemented */ NTSTATUS STDCALL @@ -52,8 +74,124 @@ IoGetDeviceInterfaceAlias( IN CONST GUID *AliasInterfaceClassGuid, OUT PUNICODE_STRING AliasSymbolicLinkName) { - DPRINT("IoGetDeviceInterfaceAlias called (UNIMPLEMENTED)\n"); - return STATUS_NOT_IMPLEMENTED; + PUNICODE_STRING GuidString; + PUNICODE_STRING BaseKeyName; + PUNICODE_STRING AliasKeyName; + PUNICODE_STRING bipName; + PUNICODE_STRING InLinkName; + + PHANDLE InterfaceKey; + BOOLEAN CaseInsensitive = TRUE; + + PKEY_FULL_INFORMATION fip; + PKEY_BASIC_INFORMATION bip; + + PWCHAR pdest; + + LONG status; + NTSTATUS Status; + + ULONG Size; + ULONG i = 0; + + PWCHAR BaseKeyString = L"\\HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control\\Class\\"; + PWCHAR BaseInterfaceString = L"\\HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\"; + + + status = RtlStringFromGUID( AliasInterfaceClassGuid, GuidString ); + if( !status ) + { + DPRINT( "RtlStringFromGUID() Failed.\n" ); + return STATUS_INVALID_HANDLE; + } + RtlInitUnicodeString( BaseKeyName, BaseKeyString ); + RtlInitUnicodeString( AliasKeyName, BaseInterfaceString ); + + BaseKeyName->MaximumLength += sizeof( GuidString ); + RtlAppendUnicodeStringToString( BaseKeyName, GuidString ); + + Status = IoOpenDeviceInterfaceRegistryKey( BaseKeyName, + GENERIC_READ, + InterfaceKey); + + if( !NT_SUCCESS( Status ) ) + { + DPRINT( "IoGetDeviceInterfaceKey() failed.\n" ); + return Status; + } + + Status = ZwQueryKey( InterfaceKey, + KeyFullInformation, + NULL, + 0, + &Size ); + + if( !NT_SUCCESS( Status) ) + { + DPRINT( "ZwQueryKey() failed.\n" ); + return Status; + } + + fip = (PKEY_FULL_INFORMATION) ExAllocatePool(PagedPool, Size); + + ZwQueryKey( InterfaceKey, + KeyFullInformation, + fip, + Size, + &Size ); + + while( i < fip->SubKeys ) + { + i++; + ZwEnumerateKey( InterfaceKey, + i, + KeyBasicInformation, + NULL, + 0, + &Size ); + bip = (PKEY_BASIC_INFORMATION) ExAllocatePool(PagedPool, Size); + + ZwEnumerateKey( InterfaceKey, + i, + KeyBasicInformation, + bip, + Size, + &Size ); + //check bip->Name + RtlInitUnicodeString( bipName, NULL ); + RtlInitUnicodeString( InLinkName, NULL ); + + bipName->Length = wcslen(bip->Name); + bipName->MaximumLength = wcslen(bip->Name); + bipName->Buffer = bip->Name; + + AliasKeyName->MaximumLength += sizeof(bipName); + RtlAppendUnicodeStringToString( AliasKeyName, bipName ); + + pdest = wcsstr( SymbolicLinkName->Buffer, L"Services\\" ); + + InLinkName->Length = wcslen(pdest); + InLinkName->MaximumLength = wcslen(pdest); + InLinkName->Buffer = pdest; + + status = 1; + status = RtlCompareUnicodeString( bipName, + InLinkName, + CaseInsensitive ); + + if( status == 0 ) + { + AliasSymbolicLinkName = AliasKeyName; + return STATUS_SUCCESS; + } + + + ExFreePool(bip); + } + + ExFreePool(fip); + + return STATUS_INVALID_HANDLE; } /* diff --git a/reactos/ntoskrnl/rtl/unicode.c b/reactos/ntoskrnl/rtl/unicode.c index 81ccc86c93e..07d9d771f8b 100644 --- a/reactos/ntoskrnl/rtl/unicode.c +++ b/reactos/ntoskrnl/rtl/unicode.c @@ -1,4 +1,4 @@ -/* $Id: unicode.c,v 1.34 2003/12/30 18:52:06 fireball Exp $ +/* $Id: unicode.c,v 1.35 2004/01/23 18:00:53 navaraf Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -1052,6 +1052,40 @@ RtlPrefixUnicodeString(IN PUNICODE_STRING String1, return FALSE; } +/* + * @implemented + */ +NTSTATUS +STDCALL +RtlStringFromGUID( + IN REFGUID Guid, + OUT PUNICODE_STRING GuidString + ) +{ + if( Guid == NULL ) + { + return FALSE; + } + PWCHAR Buffer; + PWCHAR String4; + PWCHAR String4a; + PWCHAR String4b; + + wcsncpy( String4a, String4, 4 ); + wcsncpy( String4b, String4+4, wcslen(String4) ); + + swprintf( Buffer, L"{%X-%X-%X-%X-%X}", + Guid->Data1, + Guid->Data2, + Guid->Data3, + String4a, + String4b ); + + RtlInitUnicodeString( GuidString, Buffer ); + + return(TRUE); +} + /* * @implemented