Fill HardwareDatabase, DriverStart and DriverSize fields before calling init routine

svn path=/trunk/; revision=27120
This commit is contained in:
Hervé Poussineau 2007-06-10 16:15:16 +00:00
parent 65c877d142
commit db153659fe
3 changed files with 22 additions and 14 deletions

View file

@ -806,6 +806,8 @@ NTAPI
IopCreateDriver(IN PUNICODE_STRING DriverName OPTIONAL,
IN PDRIVER_INITIALIZE InitializationFunction,
IN PUNICODE_STRING RegistryPath,
IN PVOID DllBase,
IN ULONG SizeOfImage,
OUT PDRIVER_OBJECT *pDriverObject);
VOID

View file

@ -411,25 +411,26 @@ IopInitializeDriverModule(
RtlInitUnicodeString(&DriverName, NameBuffer);
DPRINT("Driver name: '%wZ'\n", &DriverName);
Status = IopCreateDriver(&DriverName, DriverEntry, &RegistryKey, &Driver);
}
else
{
Status = IopCreateDriver(NULL, DriverEntry, &RegistryKey, &Driver);
}
DriverName.Length = 0;
Status = IopCreateDriver(
DriverName.Length > 0 ? &DriverName : NULL,
DriverEntry,
&RegistryKey,
ModuleObject->DllBase,
ModuleObject->SizeOfImage,
&Driver);
RtlFreeUnicodeString(&RegistryKey);
*DriverObject = Driver;
if (!NT_SUCCESS(Status))
{
DPRINT1("IopCreateDriver() failed (Status 0x%08lx)\n", Status);
DPRINT("IopCreateDriver() failed (Status 0x%08lx)\n", Status);
return Status;
}
Driver->HardwareDatabase = &IopHardwareDatabaseKey;
Driver->DriverStart = ModuleObject->DllBase;
Driver->DriverSize = ModuleObject->SizeOfImage;
/* Set the driver as initialized */
Driver->Flags |= DRVO_INITIALIZED;
DeviceObject = Driver->DeviceObject;
@ -1093,6 +1094,8 @@ NTAPI
IopCreateDriver(IN PUNICODE_STRING DriverName OPTIONAL,
IN PDRIVER_INITIALIZE InitializationFunction,
IN PUNICODE_STRING RegistryPath,
IN PVOID DllBase,
IN ULONG SizeOfImage,
OUT PDRIVER_OBJECT *pDriverObject)
{
WCHAR NameBuffer[100];
@ -1225,6 +1228,10 @@ try_again:
/* Close the extra handle */
ZwClose(hDriver);
DriverObject->HardwareDatabase = &IopHardwareDatabaseKey;
DriverObject->DriverStart = DllBase;
DriverObject->DriverSize = SizeOfImage;
/* Finally, call its init function */
DPRINT("RegistryKey: %wZ\n", RegistryKey);
DPRINT("Calling driver entrypoint at %p\n", InitializationFunction);
@ -1256,7 +1263,7 @@ IoCreateDriver(IN PUNICODE_STRING DriverName OPTIONAL,
IN PDRIVER_INITIALIZE InitializationFunction)
{
PDRIVER_OBJECT DriverObject;
return IopCreateDriver(DriverName, InitializationFunction, NULL, &DriverObject);
return IopCreateDriver(DriverName, InitializationFunction, NULL, 0, 0, &DriverObject);
}
/*

View file

@ -2022,7 +2022,6 @@ IopActionInterrogateDeviceStack(PDEVICE_NODE DeviceNode,
DPRINT("IopInitiatePnpIrp() failed (Status %x)\n", Status);
}
DPRINT("Sending IRP_MN_QUERY_DEVICE_TEXT.DeviceTextDescription to device stack\n");
Stack.Parameters.QueryDeviceText.DeviceTextType = DeviceTextDescription;
@ -2275,7 +2274,7 @@ IopActionConfigureChildServices(PDEVICE_NODE DeviceNode,
if (!NT_SUCCESS(Status))
{
/* FIXME: Log the error */
DPRINT1("Could not retrieve configuration for device %wZ (Status 0x%08x)\n",
DPRINT("Could not retrieve configuration for device %wZ (Status 0x%08x)\n",
&DeviceNode->InstancePath, Status);
IopDeviceNodeSetFlag(DeviceNode, DNF_DISABLED);
return STATUS_SUCCESS;
@ -2297,7 +2296,7 @@ IopActionConfigureChildServices(PDEVICE_NODE DeviceNode,
return STATUS_SUCCESS;
}
DPRINT1("Got Service %S\n", Service->Buffer);
DPRINT("Got Service %S\n", Service->Buffer);
}
return STATUS_SUCCESS;
@ -3315,7 +3314,7 @@ PnpInit(VOID)
* Create root device node
*/
Status = IopCreateDriver(NULL, PnpDriverInitializeEmpty, NULL, &IopRootDriverObject);
Status = IopCreateDriver(NULL, PnpDriverInitializeEmpty, NULL, 0, 0, &IopRootDriverObject);
if (!NT_SUCCESS(Status))
{
CPRINT("IoCreateDriverObject() failed\n");