/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
+#include <ddk/wdmguid.h>
#define NDEBUG
#include <internal/debug.h>
BOOLEAN
IopCreateUnicodeString(
- PUNICODE_STRING Destination,
+ PUNICODE_STRING Destination,
PWSTR Source,
POOL_TYPE PoolType)
{
DPRINT("ParentNode %x PhysicalDeviceObject %x\n",
ParentNode, PhysicalDeviceObject);
- Node = (PDEVICE_NODE)ExAllocatePool(PagedPool, sizeof(DEVICE_NODE));
+ Node = (PDEVICE_NODE)ExAllocatePool(NonPagedPool, sizeof(DEVICE_NODE));
if (!Node)
{
return STATUS_INSUFFICIENT_RESOURCES;
}
wcsncpy (KeyBuffer, Path, MAX_PATH-1);
- RtlInitUnicodeString (&KeyName, KeyBuffer);
/* Skip \\Registry\\ */
- Current = KeyName.Buffer;
- Current = wcschr (Current, '\\') + 1;
- Current = wcschr (Current, '\\') + 1;
+ Current = KeyBuffer;
+ Current = wcschr (Current, L'\\') + 1;
+ Current = wcschr (Current, L'\\') + 1;
while (TRUE)
{
- Next = wcschr (Current, '\\');
+ Next = wcschr (Current, L'\\');
if (Next == NULL)
{
/* The end */
*Next = 0;
}
+ RtlInitUnicodeString (&KeyName, KeyBuffer);
InitializeObjectAttributes (&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
DPRINT("Create '%S'\n", KeyName.Buffer);
- Status = NtCreateKey (&KeyHandle,
+ Status = ZwCreateKey (&KeyHandle,
KEY_ALL_ACCESS,
&ObjectAttributes,
0,
NULL);
if (!NT_SUCCESS (Status))
{
- DPRINT ("NtCreateKey() failed with status %x\n", Status);
+ DPRINT ("ZwCreateKey() failed with status %x\n", Status);
return Status;
}
}
else
{
- NtClose (KeyHandle);
+ ZwClose (KeyHandle);
*Next = L'\\';
}
OBJ_CASE_INSENSITIVE,
InstanceKey,
NULL);
- Status = NtCreateKey(&LogConfKey,
+ Status = ZwCreateKey(&LogConfKey,
KEY_ALL_ACCESS,
&ObjectAttributes,
0,
RtlInitUnicodeString(&KeyName,
L"BootConfig");
- Status = NtSetValueKey(LogConfKey,
+ Status = ZwSetValueKey(LogConfKey,
&KeyName,
0,
REG_RESOURCE_LIST,
{
RtlInitUnicodeString(&KeyName,
L"BasicConfigVector");
- Status = NtSetValueKey(LogConfKey,
+ Status = ZwSetValueKey(LogConfKey,
&KeyName,
0,
REG_RESOURCE_REQUIREMENTS_LIST,
DeviceNode->ResourceRequirements->ListSize);
}
- NtClose(LogConfKey);
+ ZwClose(LogConfKey);
}
DPRINT("IopSetDeviceInstanceData() done\n");
/* Set 'Capabilities' value */
RtlInitUnicodeString(&ValueName,
L"Capabilities");
- Status = NtSetValueKey(InstanceKey,
+ Status = ZwSetValueKey(InstanceKey,
&ValueName,
0,
REG_DWORD,
{
RtlInitUnicodeString(&ValueName,
L"UINumber");
- Status = NtSetValueKey(InstanceKey,
+ Status = ZwSetValueKey(InstanceKey,
&ValueName,
0,
REG_DWORD,
RtlInitUnicodeString(&ValueName,
L"HardwareID");
- Status = NtSetValueKey(InstanceKey,
+ Status = ZwSetValueKey(InstanceKey,
&ValueName,
0,
REG_MULTI_SZ,
(TotalLength + 1) * sizeof(WCHAR));
if (!NT_SUCCESS(Status))
{
- DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status);
+ DPRINT1("ZwSetValueKey() failed (Status %lx)\n", Status);
}
}
else
RtlInitUnicodeString(&ValueName,
L"CompatibleIDs");
- Status = NtSetValueKey(InstanceKey,
+ Status = ZwSetValueKey(InstanceKey,
&ValueName,
0,
REG_MULTI_SZ,
(TotalLength + 1) * sizeof(WCHAR));
if (!NT_SUCCESS(Status))
{
- DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status);
+ DPRINT1("ZwSetValueKey() failed (Status %lx)\n", Status);
}
}
else
{
RtlInitUnicodeString(&ValueName,
L"DeviceDesc");
- Status = NtSetValueKey(InstanceKey,
+ Status = ZwSetValueKey(InstanceKey,
&ValueName,
0,
REG_SZ,
(wcslen((PWSTR)IoStatusBlock.Information) + 1) * sizeof(WCHAR));
if (!NT_SUCCESS(Status))
{
- DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status);
+ DPRINT1("ZwSetValueKey() failed (Status %lx)\n", Status);
}
}
else
DPRINT("LocationInformation: %S\n", (PWSTR)IoStatusBlock.Information);
RtlInitUnicodeString(&ValueName,
L"LocationInformation");
- Status = NtSetValueKey(InstanceKey,
+ Status = ZwSetValueKey(InstanceKey,
&ValueName,
0,
REG_SZ,
(wcslen((PWSTR)IoStatusBlock.Information) + 1) * sizeof(WCHAR));
if (!NT_SUCCESS(Status))
{
- DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status);
+ DPRINT1("ZwSetValueKey() failed (Status %lx)\n", Status);
}
}
else
IopSetDeviceInstanceData(InstanceKey, DeviceNode);
}
- NtClose(InstanceKey);
+ ZwClose(InstanceKey);
DeviceNode->Flags |= DNF_PROCESSED;
+ /* Report the device to the user-mode pnp manager */
+ IopQueueTargetDeviceEvent(&GUID_DEVICE_ARRIVAL,
+ &DeviceNode->InstancePath);
+
return STATUS_SUCCESS;
}
NULL,
NULL);
- Status = NtOpenFile(
+ Status = ZwOpenFile(
&Handle,
FILE_ALL_ACCESS,
&ObjectAttributes,
&IoStatusBlock,
0,
0);
-
- BootDrivers = NT_SUCCESS(Status) ? FALSE : TRUE;
-
- NtClose(Handle);
+ if(NT_SUCCESS(Status))
+ {
+ BootDrivers = FALSE;
+ ZwClose(Handle);
+ }
+ else
+ BootDrivers = TRUE;
/*
* Initialize services for discovered children. Only boot drivers will
KEBUGCHECKEX(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0);
}
+ if (!IopCreateUnicodeString(&IopRootDeviceNode->InstancePath,
+ L"HTREE\\Root\\0",
+ PagedPool))
+ {
+ CPRINT("Failed to create the instance path!\n");
+ KEBUGCHECKEX(PHASE1_INITIALIZATION_FAILED, STATUS_UNSUCCESSFUL, 0, 0, 0);
+ }
+
+ /* Report the device to the user-mode pnp manager */
+ IopQueueTargetDeviceEvent(&GUID_DEVICE_ARRIVAL,
+ &IopRootDeviceNode->InstancePath);
+
IopRootDeviceNode->PhysicalDeviceObject->Flags |= DO_BUS_ENUMERATED_DEVICE;
PnpRootDriverEntry(IopRootDriverObject, NULL);
IopRootDriverObject->DriverExtension->AddDevice(