mirror of
https://github.com/reactos/reactos.git
synced 2024-08-04 18:40:59 +00:00
[ntoskrnl/io]
- Modify IopCreateDriver to accept the PLDR_DATA_TABLE_ENTRY instead of the DllBase and SizeOfImage from this structure. - Set the DriverObject->DriverSection before calling the DriverEntry routine. - If the DriverEntry routine fails then set the DriverObject->DriverSection back to NULL so that IopDeleteDriver doesnt attempt to unload the ModuleObject, after it was already unloaded by the caller. svn path=/trunk/; revision=48738
This commit is contained in:
parent
0daaf9da75
commit
bd0767f9fd
|
@ -996,8 +996,7 @@ NTAPI
|
||||||
IopCreateDriver(IN PUNICODE_STRING DriverName OPTIONAL,
|
IopCreateDriver(IN PUNICODE_STRING DriverName OPTIONAL,
|
||||||
IN PDRIVER_INITIALIZE InitializationFunction,
|
IN PDRIVER_INITIALIZE InitializationFunction,
|
||||||
IN PUNICODE_STRING RegistryPath,
|
IN PUNICODE_STRING RegistryPath,
|
||||||
IN PVOID DllBase,
|
PLDR_DATA_TABLE_ENTRY ModuleObject,
|
||||||
IN ULONG SizeOfImage,
|
|
||||||
OUT PDRIVER_OBJECT *pDriverObject);
|
OUT PDRIVER_OBJECT *pDriverObject);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
|
|
@ -481,8 +481,7 @@ IopInitializeDriverModule(
|
||||||
DriverName.Length > 0 ? &DriverName : NULL,
|
DriverName.Length > 0 ? &DriverName : NULL,
|
||||||
DriverEntry,
|
DriverEntry,
|
||||||
&RegistryKey,
|
&RegistryKey,
|
||||||
ModuleObject->DllBase,
|
ModuleObject,
|
||||||
ModuleObject->SizeOfImage,
|
|
||||||
&Driver);
|
&Driver);
|
||||||
RtlFreeUnicodeString(&RegistryKey);
|
RtlFreeUnicodeString(&RegistryKey);
|
||||||
|
|
||||||
|
@ -1388,8 +1387,7 @@ NTAPI
|
||||||
IopCreateDriver(IN PUNICODE_STRING DriverName OPTIONAL,
|
IopCreateDriver(IN PUNICODE_STRING DriverName OPTIONAL,
|
||||||
IN PDRIVER_INITIALIZE InitializationFunction,
|
IN PDRIVER_INITIALIZE InitializationFunction,
|
||||||
IN PUNICODE_STRING RegistryPath,
|
IN PUNICODE_STRING RegistryPath,
|
||||||
IN PVOID DllBase,
|
PLDR_DATA_TABLE_ENTRY ModuleObject,
|
||||||
IN ULONG SizeOfImage,
|
|
||||||
OUT PDRIVER_OBJECT *pDriverObject)
|
OUT PDRIVER_OBJECT *pDriverObject)
|
||||||
{
|
{
|
||||||
WCHAR NameBuffer[100];
|
WCHAR NameBuffer[100];
|
||||||
|
@ -1451,7 +1449,7 @@ try_again:
|
||||||
DriverObject->DriverExtension = (PDRIVER_EXTENSION)(DriverObject + 1);
|
DriverObject->DriverExtension = (PDRIVER_EXTENSION)(DriverObject + 1);
|
||||||
DriverObject->DriverExtension->DriverObject = DriverObject;
|
DriverObject->DriverExtension->DriverObject = DriverObject;
|
||||||
DriverObject->DriverInit = InitializationFunction;
|
DriverObject->DriverInit = InitializationFunction;
|
||||||
|
DriverObject->DriverSection = ModuleObject;
|
||||||
/* Loop all Major Functions */
|
/* Loop all Major Functions */
|
||||||
for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
|
for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
|
||||||
{
|
{
|
||||||
|
@ -1525,8 +1523,8 @@ try_again:
|
||||||
ZwClose(hDriver);
|
ZwClose(hDriver);
|
||||||
|
|
||||||
DriverObject->HardwareDatabase = &IopHardwareDatabaseKey;
|
DriverObject->HardwareDatabase = &IopHardwareDatabaseKey;
|
||||||
DriverObject->DriverStart = DllBase;
|
DriverObject->DriverStart = ModuleObject ? ModuleObject->DllBase : 0;
|
||||||
DriverObject->DriverSize = SizeOfImage;
|
DriverObject->DriverSize = ModuleObject ? ModuleObject->SizeOfImage : 0;
|
||||||
|
|
||||||
/* Finally, call its init function */
|
/* Finally, call its init function */
|
||||||
DPRINT("RegistryKey: %wZ\n", RegistryPath);
|
DPRINT("RegistryKey: %wZ\n", RegistryPath);
|
||||||
|
@ -1536,6 +1534,7 @@ try_again:
|
||||||
{
|
{
|
||||||
/* If it didn't work, then kill the object */
|
/* If it didn't work, then kill the object */
|
||||||
DPRINT1("'%wZ' initialization failed, status (0x%08lx)\n", DriverName, Status);
|
DPRINT1("'%wZ' initialization failed, status (0x%08lx)\n", DriverName, Status);
|
||||||
|
DriverObject->DriverSection = NULL;
|
||||||
ObMakeTemporaryObject(DriverObject);
|
ObMakeTemporaryObject(DriverObject);
|
||||||
ObDereferenceObject(DriverObject);
|
ObDereferenceObject(DriverObject);
|
||||||
}
|
}
|
||||||
|
@ -1581,7 +1580,7 @@ IoCreateDriver(IN PUNICODE_STRING DriverName OPTIONAL,
|
||||||
IN PDRIVER_INITIALIZE InitializationFunction)
|
IN PDRIVER_INITIALIZE InitializationFunction)
|
||||||
{
|
{
|
||||||
PDRIVER_OBJECT DriverObject;
|
PDRIVER_OBJECT DriverObject;
|
||||||
return IopCreateDriver(DriverName, InitializationFunction, NULL, 0, 0, &DriverObject);
|
return IopCreateDriver(DriverName, InitializationFunction, NULL, NULL, &DriverObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1895,6 +1894,7 @@ IopLoadUnloadDriver(PLOAD_UNLOAD_PARAMS LoadParams)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Status = MmLoadSystemImage(&ImagePath, NULL, NULL, 0, (PVOID)&ModuleObject, &BaseAddress);
|
Status = MmLoadSystemImage(&ImagePath, NULL, NULL, 0, (PVOID)&ModuleObject, &BaseAddress);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status) && Status != STATUS_IMAGE_ALREADY_LOADED)
|
if (!NT_SUCCESS(Status) && Status != STATUS_IMAGE_ALREADY_LOADED)
|
||||||
{
|
{
|
||||||
DPRINT("MmLoadSystemImage() failed (Status %lx)\n", Status);
|
DPRINT("MmLoadSystemImage() failed (Status %lx)\n", Status);
|
||||||
|
@ -1934,9 +1934,6 @@ IopLoadUnloadDriver(PLOAD_UNLOAD_PARAMS LoadParams)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Store its DriverSection, so that it could be unloaded */
|
|
||||||
DriverObject->DriverSection = ModuleObject;
|
|
||||||
|
|
||||||
/* Initialize and start device */
|
/* Initialize and start device */
|
||||||
IopInitializeDevice(DeviceNode, DriverObject);
|
IopInitializeDevice(DeviceNode, DriverObject);
|
||||||
Status = IopStartDevice(DeviceNode);
|
Status = IopStartDevice(DeviceNode);
|
||||||
|
|
Loading…
Reference in a new issue