2010-04-02 17:57:33 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS Kernel
|
|
|
|
* LICENSE: BSD - See COPYING.ARM in the top level directory
|
|
|
|
* FILE: ntoskrnl/io/pnpmgr/pnpinit.c
|
|
|
|
* PURPOSE: PnP Initialization Code
|
|
|
|
* PROGRAMMERS: ReactOS Portable Systems Group
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *******************************************************************/
|
|
|
|
|
|
|
|
#include <ntoskrnl.h>
|
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
/* GLOBALS ********************************************************************/
|
|
|
|
|
|
|
|
PUNICODE_STRING PiInitGroupOrderTable;
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
USHORT PiInitGroupOrderTableCount;
|
2010-04-11 21:25:50 +00:00
|
|
|
INTERFACE_TYPE PnpDefaultInterfaceType;
|
2020-06-24 16:34:44 +00:00
|
|
|
BOOLEAN PnPBootDriversLoaded = FALSE;
|
2020-12-22 17:52:20 +00:00
|
|
|
BOOLEAN PnPBootDriversInitialized = FALSE;
|
2010-04-11 21:25:50 +00:00
|
|
|
|
2020-03-26 14:45:59 +00:00
|
|
|
ARBITER_INSTANCE IopRootBusNumberArbiter;
|
|
|
|
ARBITER_INSTANCE IopRootIrqArbiter;
|
|
|
|
ARBITER_INSTANCE IopRootDmaArbiter;
|
|
|
|
ARBITER_INSTANCE IopRootMemArbiter;
|
|
|
|
ARBITER_INSTANCE IopRootPortArbiter;
|
|
|
|
|
2020-06-24 16:34:44 +00:00
|
|
|
extern KEVENT PiEnumerationFinished;
|
|
|
|
|
2020-03-26 14:45:59 +00:00
|
|
|
NTSTATUS NTAPI IopPortInitialize(VOID);
|
|
|
|
NTSTATUS NTAPI IopMemInitialize(VOID);
|
|
|
|
NTSTATUS NTAPI IopDmaInitialize(VOID);
|
|
|
|
NTSTATUS NTAPI IopIrqInitialize(VOID);
|
|
|
|
NTSTATUS NTAPI IopBusNumberInitialize(VOID);
|
|
|
|
|
2010-04-02 17:57:33 +00:00
|
|
|
/* FUNCTIONS ******************************************************************/
|
|
|
|
|
2010-04-11 21:25:50 +00:00
|
|
|
INTERFACE_TYPE
|
|
|
|
NTAPI
|
|
|
|
IopDetermineDefaultInterfaceType(VOID)
|
|
|
|
{
|
|
|
|
/* FIXME: ReactOS doesn't support MicroChannel yet */
|
|
|
|
return Isa;
|
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
IopInitializeArbiters(VOID)
|
|
|
|
{
|
2020-03-26 14:45:59 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
Status = IopPortInitialize();
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("IopPortInitialize() return %X\n", Status);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = IopMemInitialize();
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("IopMemInitialize() return %X\n", Status);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = IopDmaInitialize();
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("IopDmaInitialize() return %X\n", Status);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = IopIrqInitialize();
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("IopIrqInitialize() return %X\n", Status);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = IopBusNumberInitialize();
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("IopBusNumberInitialize() return %X\n", Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Status;
|
2010-04-11 21:25:50 +00:00
|
|
|
}
|
|
|
|
|
2020-03-26 14:45:59 +00:00
|
|
|
|
2020-10-06 19:44:01 +00:00
|
|
|
CODE_SEG("INIT")
|
2010-04-02 17:57:33 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
PiInitCacheGroupInformation(VOID)
|
|
|
|
{
|
|
|
|
HANDLE KeyHandle;
|
|
|
|
NTSTATUS Status;
|
|
|
|
PKEY_VALUE_FULL_INFORMATION KeyValueInformation;
|
|
|
|
PUNICODE_STRING GroupTable;
|
|
|
|
ULONG Count;
|
|
|
|
UNICODE_STRING GroupString =
|
|
|
|
RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet"
|
|
|
|
L"\\Control\\ServiceGroupOrder");
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-02 17:57:33 +00:00
|
|
|
/* Open the registry key */
|
|
|
|
Status = IopOpenRegistryKeyEx(&KeyHandle,
|
|
|
|
NULL,
|
|
|
|
&GroupString,
|
|
|
|
KEY_READ);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Get the list */
|
|
|
|
Status = IopGetRegistryValue(KeyHandle, L"List", &KeyValueInformation);
|
|
|
|
ZwClose(KeyHandle);
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-02 17:57:33 +00:00
|
|
|
/* Make sure we got it */
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Make sure it's valid */
|
|
|
|
if ((KeyValueInformation->Type == REG_MULTI_SZ) &&
|
|
|
|
(KeyValueInformation->DataLength))
|
|
|
|
{
|
|
|
|
/* Convert it to unicode strings */
|
|
|
|
Status = PnpRegMultiSzToUnicodeStrings(KeyValueInformation,
|
|
|
|
&GroupTable,
|
|
|
|
&Count);
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-02 17:57:33 +00:00
|
|
|
/* Cache it for later */
|
|
|
|
PiInitGroupOrderTable = GroupTable;
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
PiInitGroupOrderTableCount = (USHORT)Count;
|
2010-04-02 17:57:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Fail */
|
|
|
|
Status = STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-02 17:57:33 +00:00
|
|
|
/* Free the information */
|
|
|
|
ExFreePool(KeyValueInformation);
|
|
|
|
}
|
|
|
|
}
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-02 17:57:33 +00:00
|
|
|
/* Return status */
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
USHORT
|
|
|
|
NTAPI
|
|
|
|
PpInitGetGroupOrderIndex(IN HANDLE ServiceHandle)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
PKEY_VALUE_FULL_INFORMATION KeyValueInformation;
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
USHORT i;
|
2010-04-02 17:57:33 +00:00
|
|
|
PVOID Buffer;
|
|
|
|
UNICODE_STRING Group;
|
|
|
|
PAGED_CODE();
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-02 17:57:33 +00:00
|
|
|
/* Make sure we have a cache */
|
|
|
|
if (!PiInitGroupOrderTable) return -1;
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-02 17:57:33 +00:00
|
|
|
/* If we don't have a handle, the rest is easy -- return the count */
|
|
|
|
if (!ServiceHandle) return PiInitGroupOrderTableCount + 1;
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-02 17:57:33 +00:00
|
|
|
/* Otherwise, get the group value */
|
|
|
|
Status = IopGetRegistryValue(ServiceHandle, L"Group", &KeyValueInformation);
|
|
|
|
if (!NT_SUCCESS(Status)) return PiInitGroupOrderTableCount;
|
|
|
|
|
|
|
|
/* Make sure we have a valid string */
|
|
|
|
ASSERT(KeyValueInformation->Type == REG_SZ);
|
|
|
|
ASSERT(KeyValueInformation->DataLength);
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-02 17:57:33 +00:00
|
|
|
/* Convert to unicode string */
|
|
|
|
Buffer = (PVOID)((ULONG_PTR)KeyValueInformation + KeyValueInformation->DataOffset);
|
|
|
|
PnpRegSzToString(Buffer, KeyValueInformation->DataLength, &Group.Length);
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
Group.MaximumLength = (USHORT)KeyValueInformation->DataLength;
|
2010-04-02 17:57:33 +00:00
|
|
|
Group.Buffer = Buffer;
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-02 17:57:33 +00:00
|
|
|
/* Loop the groups */
|
|
|
|
for (i = 0; i < PiInitGroupOrderTableCount; i++)
|
|
|
|
{
|
|
|
|
/* Try to find a match */
|
|
|
|
if (RtlEqualUnicodeString(&Group, &PiInitGroupOrderTable[i], TRUE)) break;
|
|
|
|
}
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-02 17:57:33 +00:00
|
|
|
/* We're done */
|
|
|
|
ExFreePool(KeyValueInformation);
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
USHORT
|
|
|
|
NTAPI
|
|
|
|
PipGetDriverTagPriority(IN HANDLE ServiceHandle)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
HANDLE KeyHandle = NULL;
|
|
|
|
PKEY_VALUE_FULL_INFORMATION KeyValueInformation = NULL;
|
|
|
|
PKEY_VALUE_FULL_INFORMATION KeyValueInformationTag;
|
|
|
|
PKEY_VALUE_FULL_INFORMATION KeyValueInformationGroupOrderList;
|
|
|
|
PVOID Buffer;
|
|
|
|
UNICODE_STRING Group;
|
|
|
|
PULONG GroupOrder;
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
ULONG Count, Tag = 0;
|
|
|
|
USHORT i = -1;
|
2010-04-02 17:57:33 +00:00
|
|
|
UNICODE_STRING GroupString =
|
|
|
|
RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet"
|
|
|
|
L"\\Control\\ServiceGroupOrder");
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-02 17:57:33 +00:00
|
|
|
/* Open the key */
|
|
|
|
Status = IopOpenRegistryKeyEx(&KeyHandle, NULL, &GroupString, KEY_READ);
|
|
|
|
if (!NT_SUCCESS(Status)) goto Quickie;
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-02 17:57:33 +00:00
|
|
|
/* Read the group */
|
|
|
|
Status = IopGetRegistryValue(ServiceHandle, L"Group", &KeyValueInformation);
|
|
|
|
if (!NT_SUCCESS(Status)) goto Quickie;
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-02 17:57:33 +00:00
|
|
|
/* Make sure we have a group */
|
|
|
|
if ((KeyValueInformation->Type == REG_SZ) &&
|
|
|
|
(KeyValueInformation->DataLength))
|
|
|
|
{
|
|
|
|
/* Convert to unicode string */
|
|
|
|
Buffer = (PVOID)((ULONG_PTR)KeyValueInformation + KeyValueInformation->DataOffset);
|
|
|
|
PnpRegSzToString(Buffer, KeyValueInformation->DataLength, &Group.Length);
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
Group.MaximumLength = (USHORT)KeyValueInformation->DataLength;
|
2010-04-02 17:57:33 +00:00
|
|
|
Group.Buffer = Buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now read the tag */
|
|
|
|
Status = IopGetRegistryValue(ServiceHandle, L"Tag", &KeyValueInformationTag);
|
|
|
|
if (!NT_SUCCESS(Status)) goto Quickie;
|
|
|
|
|
|
|
|
/* Make sure we have a tag */
|
|
|
|
if ((KeyValueInformationTag->Type == REG_DWORD) &&
|
|
|
|
(KeyValueInformationTag->DataLength))
|
|
|
|
{
|
|
|
|
/* Read it */
|
|
|
|
Tag = *(PULONG)((ULONG_PTR)KeyValueInformationTag +
|
|
|
|
KeyValueInformationTag->DataOffset);
|
|
|
|
}
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-02 17:57:33 +00:00
|
|
|
/* We can get rid of this now */
|
|
|
|
ExFreePool(KeyValueInformationTag);
|
|
|
|
|
|
|
|
/* Now let's read the group's tag order */
|
|
|
|
Status = IopGetRegistryValue(KeyHandle,
|
|
|
|
Group.Buffer,
|
|
|
|
&KeyValueInformationGroupOrderList);
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-02 17:57:33 +00:00
|
|
|
/* We can get rid of this now */
|
|
|
|
Quickie:
|
|
|
|
if (KeyValueInformation) ExFreePool(KeyValueInformation);
|
|
|
|
if (KeyHandle) NtClose(KeyHandle);
|
|
|
|
if (!NT_SUCCESS(Status)) return -1;
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-02 17:57:33 +00:00
|
|
|
/* We're on the success path -- validate the tag order*/
|
|
|
|
if ((KeyValueInformationGroupOrderList->Type == REG_BINARY) &&
|
|
|
|
(KeyValueInformationGroupOrderList->DataLength))
|
|
|
|
{
|
|
|
|
/* Get the order array */
|
|
|
|
GroupOrder = (PULONG)((ULONG_PTR)KeyValueInformationGroupOrderList +
|
|
|
|
KeyValueInformationGroupOrderList->DataOffset);
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-02 17:57:33 +00:00
|
|
|
/* Get the count */
|
|
|
|
Count = *GroupOrder;
|
|
|
|
ASSERT(((Count + 1) * sizeof(ULONG)) <=
|
|
|
|
KeyValueInformationGroupOrderList->DataLength);
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-02 17:57:33 +00:00
|
|
|
/* Now loop each tag */
|
|
|
|
GroupOrder++;
|
|
|
|
for (i = 1; i <= Count; i++)
|
|
|
|
{
|
|
|
|
/* If we found it, we're out */
|
|
|
|
if (Tag == *GroupOrder) break;
|
|
|
|
|
|
|
|
/* Try the next one */
|
|
|
|
GroupOrder++;
|
|
|
|
}
|
|
|
|
}
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-02 17:57:33 +00:00
|
|
|
/* Last buffer to free */
|
|
|
|
ExFreePool(KeyValueInformationGroupOrderList);
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2020-10-06 19:44:01 +00:00
|
|
|
CODE_SEG("INIT")
|
2010-04-11 21:25:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
IopInitializePlugPlayServices(VOID)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
ULONG Disposition;
|
2012-02-20 11:30:51 +00:00
|
|
|
HANDLE KeyHandle, EnumHandle, ParentHandle, TreeHandle, ControlHandle;
|
2010-04-11 21:25:50 +00:00
|
|
|
UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET");
|
2013-08-23 21:03:37 +00:00
|
|
|
UNICODE_STRING PnpManagerDriverName = RTL_CONSTANT_STRING(DRIVER_ROOT_NAME L"PnpManager");
|
2010-04-11 21:25:50 +00:00
|
|
|
PDEVICE_OBJECT Pdo;
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-11 21:25:50 +00:00
|
|
|
/* Initialize locks and such */
|
|
|
|
KeInitializeSpinLock(&IopDeviceTreeLock);
|
2017-12-17 21:53:01 +00:00
|
|
|
KeInitializeSpinLock(&IopDeviceActionLock);
|
|
|
|
InitializeListHead(&IopDeviceActionRequestList);
|
2020-06-24 16:34:44 +00:00
|
|
|
KeInitializeEvent(&PiEnumerationFinished, NotificationEvent, TRUE);
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-11 21:25:50 +00:00
|
|
|
/* Get the default interface */
|
|
|
|
PnpDefaultInterfaceType = IopDetermineDefaultInterfaceType();
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-11 21:25:50 +00:00
|
|
|
/* Initialize arbiters */
|
|
|
|
Status = IopInitializeArbiters();
|
|
|
|
if (!NT_SUCCESS(Status)) return Status;
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-11 21:25:50 +00:00
|
|
|
/* Setup the group cache */
|
|
|
|
Status = PiInitCacheGroupInformation();
|
|
|
|
if (!NT_SUCCESS(Status)) return Status;
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-11 21:25:50 +00:00
|
|
|
/* Open the current control set */
|
|
|
|
Status = IopOpenRegistryKeyEx(&KeyHandle,
|
|
|
|
NULL,
|
|
|
|
&KeyName,
|
|
|
|
KEY_ALL_ACCESS);
|
|
|
|
if (!NT_SUCCESS(Status)) return Status;
|
2012-02-20 11:30:51 +00:00
|
|
|
|
|
|
|
/* Create the control key */
|
|
|
|
RtlInitUnicodeString(&KeyName, L"Control");
|
|
|
|
Status = IopCreateRegistryKeyEx(&ControlHandle,
|
|
|
|
KeyHandle,
|
|
|
|
&KeyName,
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
&Disposition);
|
|
|
|
if (!NT_SUCCESS(Status)) return Status;
|
|
|
|
|
|
|
|
/* Check if it's a new key */
|
|
|
|
if (Disposition == REG_CREATED_NEW_KEY)
|
|
|
|
{
|
|
|
|
HANDLE DeviceClassesHandle;
|
|
|
|
|
|
|
|
/* Create the device classes key */
|
|
|
|
RtlInitUnicodeString(&KeyName, L"DeviceClasses");
|
|
|
|
Status = IopCreateRegistryKeyEx(&DeviceClassesHandle,
|
|
|
|
ControlHandle,
|
|
|
|
&KeyName,
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
&Disposition);
|
|
|
|
if (!NT_SUCCESS(Status)) return Status;
|
|
|
|
|
|
|
|
ZwClose(DeviceClassesHandle);
|
|
|
|
}
|
|
|
|
|
|
|
|
ZwClose(ControlHandle);
|
|
|
|
|
2010-04-11 21:25:50 +00:00
|
|
|
/* Create the enum key */
|
|
|
|
RtlInitUnicodeString(&KeyName, REGSTR_KEY_ENUM);
|
|
|
|
Status = IopCreateRegistryKeyEx(&EnumHandle,
|
|
|
|
KeyHandle,
|
|
|
|
&KeyName,
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
&Disposition);
|
|
|
|
if (!NT_SUCCESS(Status)) return Status;
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-11 21:25:50 +00:00
|
|
|
/* Check if it's a new key */
|
|
|
|
if (Disposition == REG_CREATED_NEW_KEY)
|
|
|
|
{
|
|
|
|
/* FIXME: DACLs */
|
|
|
|
}
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-11 21:25:50 +00:00
|
|
|
/* Create the root key */
|
|
|
|
ParentHandle = EnumHandle;
|
|
|
|
RtlInitUnicodeString(&KeyName, REGSTR_KEY_ROOTENUM);
|
|
|
|
Status = IopCreateRegistryKeyEx(&EnumHandle,
|
|
|
|
ParentHandle,
|
|
|
|
&KeyName,
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
&Disposition);
|
|
|
|
NtClose(ParentHandle);
|
|
|
|
if (!NT_SUCCESS(Status)) return Status;
|
|
|
|
NtClose(EnumHandle);
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-11 21:25:50 +00:00
|
|
|
/* Open the root key now */
|
|
|
|
RtlInitUnicodeString(&KeyName, L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET\\ENUM");
|
|
|
|
Status = IopOpenRegistryKeyEx(&EnumHandle,
|
|
|
|
NULL,
|
|
|
|
&KeyName,
|
|
|
|
KEY_ALL_ACCESS);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Create the root dev node */
|
|
|
|
RtlInitUnicodeString(&KeyName, REGSTR_VAL_ROOT_DEVNODE);
|
|
|
|
Status = IopCreateRegistryKeyEx(&TreeHandle,
|
|
|
|
EnumHandle,
|
|
|
|
&KeyName,
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
NULL);
|
|
|
|
NtClose(EnumHandle);
|
|
|
|
if (NT_SUCCESS(Status)) NtClose(TreeHandle);
|
|
|
|
}
|
2012-02-20 11:30:51 +00:00
|
|
|
|
2010-04-11 21:25:50 +00:00
|
|
|
/* Create the root driver */
|
2012-08-15 22:29:11 +00:00
|
|
|
Status = IoCreateDriver(&PnpManagerDriverName, PnpRootDriverEntry);
|
2010-04-11 21:25:50 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("IoCreateDriverObject() failed\n");
|
|
|
|
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0);
|
|
|
|
}
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-11 21:25:50 +00:00
|
|
|
/* Create the root PDO */
|
|
|
|
Status = IoCreateDevice(IopRootDriverObject,
|
2023-06-25 22:47:40 +00:00
|
|
|
0,
|
2010-04-11 21:25:50 +00:00
|
|
|
NULL,
|
|
|
|
FILE_DEVICE_CONTROLLER,
|
|
|
|
0,
|
|
|
|
FALSE,
|
|
|
|
&Pdo);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("IoCreateDevice() failed\n");
|
|
|
|
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0);
|
|
|
|
}
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-11 21:25:50 +00:00
|
|
|
/* This is a bus enumerated device */
|
|
|
|
Pdo->Flags |= DO_BUS_ENUMERATED_DEVICE;
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-11 21:25:50 +00:00
|
|
|
/* Create the root device node */
|
|
|
|
IopRootDeviceNode = PipAllocateDeviceNode(Pdo);
|
|
|
|
|
|
|
|
/* Set flags */
|
2020-12-10 00:19:31 +00:00
|
|
|
IopRootDeviceNode->Flags |= DNF_MADEUP | DNF_ENUMERATED |
|
|
|
|
DNF_IDS_QUERIED | DNF_NO_RESOURCE_REQUIRED;
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-11 21:25:50 +00:00
|
|
|
/* Create instance path */
|
2021-06-17 14:38:32 +00:00
|
|
|
if (!RtlCreateUnicodeString(&IopRootDeviceNode->InstancePath, REGSTR_VAL_ROOT_DEVNODE))
|
|
|
|
{
|
|
|
|
DPRINT1("RtlCreateUnicodeString() failed\n");
|
|
|
|
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0);
|
|
|
|
}
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2023-06-25 22:47:40 +00:00
|
|
|
PnpRootInitializeDevExtension();
|
2010-04-11 21:25:50 +00:00
|
|
|
|
2020-12-10 00:19:31 +00:00
|
|
|
PiSetDevNodeState(IopRootDeviceNode, DeviceNodeStarted);
|
|
|
|
|
2010-04-11 21:25:50 +00:00
|
|
|
/* Initialize PnP-Event notification support */
|
|
|
|
Status = IopInitPlugPlayEvents();
|
|
|
|
if (!NT_SUCCESS(Status)) return Status;
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-11 21:25:50 +00:00
|
|
|
/* Initialize the Bus Type GUID List */
|
|
|
|
PnpBusTypeGuidList = ExAllocatePool(PagedPool, sizeof(IO_BUS_TYPE_GUID_LIST));
|
|
|
|
RtlZeroMemory(PnpBusTypeGuidList, sizeof(IO_BUS_TYPE_GUID_LIST));
|
|
|
|
ExInitializeFastMutex(&PnpBusTypeGuidList->Lock);
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2020-12-10 00:19:31 +00:00
|
|
|
/* Initialize PnP root relations (this is a syncronous operation) */
|
2023-06-25 22:47:40 +00:00
|
|
|
PiQueueDeviceAction(Pdo, PiActionEnumRootDevices, NULL, NULL);
|
2020-12-10 00:19:31 +00:00
|
|
|
|
2010-04-11 21:25:50 +00:00
|
|
|
/* Launch the firmware mapper */
|
|
|
|
Status = IopUpdateRootKey();
|
|
|
|
if (!NT_SUCCESS(Status)) return Status;
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2010-04-11 21:25:50 +00:00
|
|
|
/* Close the handle to the control set */
|
|
|
|
NtClose(KeyHandle);
|
2014-10-22 19:34:46 +00:00
|
|
|
|
2020-06-24 16:34:44 +00:00
|
|
|
/* Initialize PnP root relations (this is a syncronous operation) */
|
2023-06-25 22:47:40 +00:00
|
|
|
PiQueueDeviceAction(Pdo, PiActionEnumRootDevices, NULL, NULL);
|
2020-06-24 16:34:44 +00:00
|
|
|
|
2010-04-11 21:25:50 +00:00
|
|
|
/* We made it */
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2010-04-02 17:57:33 +00:00
|
|
|
/* EOF */
|