Send service name to pnproot driver (not used yet)

svn path=/trunk/; revision=26153
This commit is contained in:
Hervé Poussineau 2007-03-22 17:13:14 +00:00
parent fed3766e68
commit cc526db47b
5 changed files with 38 additions and 27 deletions

View file

@ -480,6 +480,7 @@ NTSTATUS
IopCreateDeviceNode(
IN PDEVICE_NODE ParentNode,
IN PDEVICE_OBJECT PhysicalDeviceObject,
IN PUNICODE_STRING ServiceName,
OUT PDEVICE_NODE *DeviceNode
);
@ -781,6 +782,7 @@ PnpRootDriverEntry(
NTSTATUS
PnpRootCreateDevice(
IN PUNICODE_STRING ServiceName,
IN OUT PDEVICE_OBJECT *PhysicalDeviceObject
);

View file

@ -726,7 +726,9 @@ IopInitializeBuiltinDriver(IN PLDR_DATA_TABLE_ENTRY LdrEntry)
PWCHAR FileNameWithoutPath;
LPWSTR FileExtension;
PUNICODE_STRING ModuleName = &LdrEntry->BaseDllName;
UNICODE_STRING ServiceName;
#if 1 // Disable for FreeLDR 2.5
UNICODE_STRING ServiceNameWithExtension;
PLDR_DATA_TABLE_ENTRY ModuleObject;
#endif
@ -735,18 +737,6 @@ IopInitializeBuiltinDriver(IN PLDR_DATA_TABLE_ENTRY LdrEntry)
*/
IopDisplayLoadingMessage(ModuleName->Buffer, TRUE);
/*
* Determine the right device object
*/
/* Use IopRootDeviceNode for now */
Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &DeviceNode);
if (!NT_SUCCESS(Status))
{
CPRINT("Driver '%wZ' load failed, status (%x)\n", ModuleName, Status);
return(Status);
}
/*
* Generate filename without path (not needed by freeldr)
*/
@ -763,13 +753,11 @@ IopInitializeBuiltinDriver(IN PLDR_DATA_TABLE_ENTRY LdrEntry)
/*
* Load the module.
*/
RtlCreateUnicodeString(&DeviceNode->ServiceName, FileNameWithoutPath);
#if 1 // Remove for FreeLDR 2.5.
Status = LdrProcessDriverModule(LdrEntry, &DeviceNode->ServiceName, &ModuleObject);
RtlCreateUnicodeString(&ServiceNameWithExtension, FileNameWithoutPath);
Status = LdrProcessDriverModule(LdrEntry, &ServiceNameWithExtension, &ModuleObject);
if (!NT_SUCCESS(Status))
{
IopFreeDeviceNode(DeviceNode);
CPRINT("Driver '%wZ' load failed, status (%x)\n", ModuleName, Status);
return Status;
}
@ -778,13 +766,26 @@ IopInitializeBuiltinDriver(IN PLDR_DATA_TABLE_ENTRY LdrEntry)
/*
* Strip the file extension from ServiceName
*/
FileExtension = wcsrchr(DeviceNode->ServiceName.Buffer, '.');
RtlCreateUnicodeString(&ServiceName, FileNameWithoutPath);
FileExtension = wcsrchr(ServiceName.Buffer, '.');
if (FileExtension != NULL)
{
DeviceNode->ServiceName.Length -= wcslen(FileExtension) * sizeof(WCHAR);
ServiceName.Length -= wcslen(FileExtension) * sizeof(WCHAR);
FileExtension[0] = 0;
}
/*
* Determine the right device object
*/
/* Use IopRootDeviceNode for now */
Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &ServiceName, &DeviceNode);
if (!NT_SUCCESS(Status))
{
CPRINT("Driver '%wZ' load failed, status (%x)\n", ModuleName, Status);
return(Status);
}
DeviceNode->ServiceName = ServiceName;
/*
* Initialize the driver
*/
@ -793,7 +794,7 @@ IopInitializeBuiltinDriver(IN PLDR_DATA_TABLE_ENTRY LdrEntry)
if (!NT_SUCCESS(Status))
{
IopFreeDeviceNode(DeviceNode);
IopFreeDeviceNode(DeviceNode);
CPRINT("Driver '%wZ' load failed, status (%x)\n", ModuleName, Status);
return Status;
}
@ -830,7 +831,7 @@ IopInitializeBootDrivers(VOID)
NTSTATUS Status;
/* Use IopRootDeviceNode for now */
Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &DeviceNode);
Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, NULL, &DeviceNode);
if (!NT_SUCCESS(Status)) return;
/* Setup the module object for the RAW FS Driver */
@ -1577,7 +1578,7 @@ NtLoadDriver(IN PUNICODE_STRING DriverServiceName)
*/
/* Use IopRootDeviceNode for now */
Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &DeviceNode);
Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &ServiceName, &DeviceNode);
if (!NT_SUCCESS(Status))
{

View file

@ -789,14 +789,15 @@ Quickie:
NTSTATUS
IopCreateDeviceNode(PDEVICE_NODE ParentNode,
PDEVICE_OBJECT PhysicalDeviceObject,
PUNICODE_STRING ServiceName,
PDEVICE_NODE *DeviceNode)
{
PDEVICE_NODE Node;
NTSTATUS Status;
KIRQL OldIrql;
DPRINT("ParentNode 0x%p PhysicalDeviceObject 0x%p\n",
ParentNode, PhysicalDeviceObject);
DPRINT("ParentNode 0x%p PhysicalDeviceObject 0x%p ServiceName %wZ\n",
ParentNode, PhysicalDeviceObject, ServiceName);
Node = (PDEVICE_NODE)ExAllocatePool(NonPagedPool, sizeof(DEVICE_NODE));
if (!Node)
@ -808,7 +809,7 @@ IopCreateDeviceNode(PDEVICE_NODE ParentNode,
if (!PhysicalDeviceObject)
{
Status = PnpRootCreateDevice(&PhysicalDeviceObject);
Status = PnpRootCreateDevice(ServiceName, &PhysicalDeviceObject);
if (!NT_SUCCESS(Status))
{
ExFreePool(Node);
@ -2386,7 +2387,8 @@ IopActionInitChildServices(PDEVICE_NODE DeviceNode,
DeviceNode->ServiceName.Buffer, Status);
}
}
} else
}
else
{
DPRINT("Service %S is disabled or already initialized\n",
DeviceNode->ServiceName.Buffer);
@ -2531,6 +2533,7 @@ IopInvalidateDeviceRelations(
Status = IopCreateDeviceNode(
DeviceNode,
DeviceRelations->Objects[i],
NULL,
&ChildDeviceNode);
DeviceNode->Flags |= DNF_ENUMERATED;
if (!NT_SUCCESS(Status))
@ -3297,7 +3300,7 @@ PnpInit(VOID)
KEBUGCHECKEX(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0);
}
Status = IopCreateDeviceNode(NULL, Pdo, &IopRootDeviceNode);
Status = IopCreateDeviceNode(NULL, Pdo, NULL, &IopRootDeviceNode);
if (!NT_SUCCESS(Status))
{
CPRINT("Insufficient resources\n");

View file

@ -45,8 +45,12 @@ IoReportDetectedDevice(
Pdo = *DeviceObject;
else
{
UNICODE_STRING ServiceName;
ServiceName.Buffer = DriverObject->DriverName.Buffer + sizeof(DRIVER_ROOT_NAME) / sizeof(WCHAR) - 1;
ServiceName.Length = ServiceName.MaximumLength = DriverObject->DriverName.Length - sizeof(DRIVER_ROOT_NAME) + sizeof(WCHAR);
/* create a new PDO and return it in *DeviceObject */
Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &DeviceNode);
Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &ServiceName, &DeviceNode);
if (!NT_SUCCESS(Status))
{
DPRINT("IopCreateDeviceNode() failed (Status 0x%08lx)\n", Status);

View file

@ -108,6 +108,7 @@ PDEVICE_OBJECT PnpRootDeviceObject;
NTSTATUS
PnpRootCreateDevice(
PUNICODE_STRING ServiceName,
PDEVICE_OBJECT *PhysicalDeviceObject)
{
PPNPROOT_PDO_DEVICE_EXTENSION PdoDeviceExtension;