mirror of
https://github.com/reactos/reactos.git
synced 2025-06-27 20:09:44 +00:00
[NTOSKRNL]
Fix some code indentation and a DPRINT. svn path=/trunk/; revision=59794
This commit is contained in:
parent
3d31c7014a
commit
e48a0068d6
1 changed files with 130 additions and 130 deletions
|
@ -1822,169 +1822,169 @@ IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject,
|
||||||
VOID NTAPI
|
VOID NTAPI
|
||||||
IopLoadUnloadDriver(PLOAD_UNLOAD_PARAMS LoadParams)
|
IopLoadUnloadDriver(PLOAD_UNLOAD_PARAMS LoadParams)
|
||||||
{
|
{
|
||||||
RTL_QUERY_REGISTRY_TABLE QueryTable[3];
|
RTL_QUERY_REGISTRY_TABLE QueryTable[3];
|
||||||
UNICODE_STRING ImagePath;
|
UNICODE_STRING ImagePath;
|
||||||
UNICODE_STRING ServiceName;
|
UNICODE_STRING ServiceName;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ULONG Type;
|
ULONG Type;
|
||||||
PDEVICE_NODE DeviceNode;
|
PDEVICE_NODE DeviceNode;
|
||||||
PDRIVER_OBJECT DriverObject;
|
PDRIVER_OBJECT DriverObject;
|
||||||
PLDR_DATA_TABLE_ENTRY ModuleObject;
|
PLDR_DATA_TABLE_ENTRY ModuleObject;
|
||||||
PVOID BaseAddress;
|
PVOID BaseAddress;
|
||||||
WCHAR *cur;
|
WCHAR *cur;
|
||||||
|
|
||||||
/* Check if it's an unload request */
|
/* Check if it's an unload request */
|
||||||
if (LoadParams->DriverObject)
|
if (LoadParams->DriverObject)
|
||||||
{
|
{
|
||||||
(*LoadParams->DriverObject->DriverUnload)(LoadParams->DriverObject);
|
(*LoadParams->DriverObject->DriverUnload)(LoadParams->DriverObject);
|
||||||
|
|
||||||
/* Return success and signal the event */
|
/* Return success and signal the event */
|
||||||
LoadParams->Status = STATUS_SUCCESS;
|
LoadParams->Status = STATUS_SUCCESS;
|
||||||
(VOID)KeSetEvent(&LoadParams->Event, 0, FALSE);
|
KeSetEvent(&LoadParams->Event, 0, FALSE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlInitUnicodeString(&ImagePath, NULL);
|
RtlInitUnicodeString(&ImagePath, NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the service name from the registry key name.
|
* Get the service name from the registry key name.
|
||||||
*/
|
*/
|
||||||
ASSERT(LoadParams->ServiceName->Length >= sizeof(WCHAR));
|
ASSERT(LoadParams->ServiceName->Length >= sizeof(WCHAR));
|
||||||
|
|
||||||
ServiceName = *LoadParams->ServiceName;
|
ServiceName = *LoadParams->ServiceName;
|
||||||
cur = LoadParams->ServiceName->Buffer +
|
cur = LoadParams->ServiceName->Buffer +
|
||||||
(LoadParams->ServiceName->Length / sizeof(WCHAR)) - 1;
|
(LoadParams->ServiceName->Length / sizeof(WCHAR)) - 1;
|
||||||
while (LoadParams->ServiceName->Buffer != cur)
|
while (LoadParams->ServiceName->Buffer != cur)
|
||||||
{
|
{
|
||||||
if(*cur == L'\\')
|
if (*cur == L'\\')
|
||||||
{
|
{
|
||||||
ServiceName.Buffer = cur + 1;
|
ServiceName.Buffer = cur + 1;
|
||||||
ServiceName.Length = LoadParams->ServiceName->Length -
|
ServiceName.Length = LoadParams->ServiceName->Length -
|
||||||
(USHORT)((ULONG_PTR)ServiceName.Buffer -
|
(USHORT)((ULONG_PTR)ServiceName.Buffer -
|
||||||
(ULONG_PTR)LoadParams->ServiceName->Buffer);
|
(ULONG_PTR)LoadParams->ServiceName->Buffer);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cur--;
|
cur--;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get service type.
|
* Get service type.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RtlZeroMemory(&QueryTable, sizeof(QueryTable));
|
RtlZeroMemory(&QueryTable, sizeof(QueryTable));
|
||||||
|
|
||||||
RtlInitUnicodeString(&ImagePath, NULL);
|
RtlInitUnicodeString(&ImagePath, NULL);
|
||||||
|
|
||||||
QueryTable[0].Name = L"Type";
|
QueryTable[0].Name = L"Type";
|
||||||
QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_REQUIRED;
|
QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_REQUIRED;
|
||||||
QueryTable[0].EntryContext = &Type;
|
QueryTable[0].EntryContext = &Type;
|
||||||
|
|
||||||
QueryTable[1].Name = L"ImagePath";
|
QueryTable[1].Name = L"ImagePath";
|
||||||
QueryTable[1].Flags = RTL_QUERY_REGISTRY_DIRECT;
|
QueryTable[1].Flags = RTL_QUERY_REGISTRY_DIRECT;
|
||||||
QueryTable[1].EntryContext = &ImagePath;
|
QueryTable[1].EntryContext = &ImagePath;
|
||||||
|
|
||||||
Status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE,
|
Status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE,
|
||||||
LoadParams->ServiceName->Buffer, QueryTable, NULL, NULL);
|
LoadParams->ServiceName->Buffer,
|
||||||
|
QueryTable, NULL, NULL);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("RtlQueryRegistryValues() failed (Status %lx)\n", Status);
|
DPRINT("RtlQueryRegistryValues() failed (Status %lx)\n", Status);
|
||||||
if (ImagePath.Buffer)
|
if (ImagePath.Buffer) ExFreePool(ImagePath.Buffer);
|
||||||
ExFreePool(ImagePath.Buffer);
|
LoadParams->Status = Status;
|
||||||
LoadParams->Status = Status;
|
KeSetEvent(&LoadParams->Event, 0, FALSE);
|
||||||
(VOID)KeSetEvent(&LoadParams->Event, 0, FALSE);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Normalize the image path for all later processing.
|
* Normalize the image path for all later processing.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Status = IopNormalizeImagePath(&ImagePath, &ServiceName);
|
Status = IopNormalizeImagePath(&ImagePath, &ServiceName);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("IopNormalizeImagePath() failed (Status %x)\n", Status);
|
DPRINT("IopNormalizeImagePath() failed (Status %x)\n", Status);
|
||||||
LoadParams->Status = Status;
|
LoadParams->Status = Status;
|
||||||
(VOID)KeSetEvent(&LoadParams->Event, 0, FALSE);
|
KeSetEvent(&LoadParams->Event, 0, FALSE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("FullImagePath: '%wZ'\n", &ImagePath);
|
DPRINT("FullImagePath: '%wZ'\n", &ImagePath);
|
||||||
DPRINT("Type: %lx\n", Type);
|
DPRINT("Type: %lx\n", Type);
|
||||||
|
|
||||||
/* Get existing DriverObject pointer (in case the driver has
|
/* Get existing DriverObject pointer (in case the driver has
|
||||||
already been loaded and initialized) */
|
already been loaded and initialized) */
|
||||||
Status = IopGetDriverObject(
|
Status = IopGetDriverObject(
|
||||||
&DriverObject,
|
&DriverObject,
|
||||||
&ServiceName,
|
&ServiceName,
|
||||||
(Type == 2 /* SERVICE_FILE_SYSTEM_DRIVER */ ||
|
(Type == 2 /* SERVICE_FILE_SYSTEM_DRIVER */ ||
|
||||||
Type == 8 /* SERVICE_RECOGNIZER_DRIVER */));
|
Type == 8 /* SERVICE_RECOGNIZER_DRIVER */));
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Load the driver module
|
* Load the driver module
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DPRINT("Loading module from %wZ\n", &ImagePath);
|
DPRINT("Loading module from %wZ\n", &ImagePath);
|
||||||
Status = MmLoadSystemImage(&ImagePath, NULL, NULL, 0, (PVOID)&ModuleObject, &BaseAddress);
|
Status = MmLoadSystemImage(&ImagePath, NULL, NULL, 0, (PVOID)&ModuleObject, &BaseAddress);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("MmLoadSystemImage() failed (Status %lx)\n", Status);
|
DPRINT("MmLoadSystemImage() failed (Status %lx)\n", Status);
|
||||||
LoadParams->Status = Status;
|
LoadParams->Status = Status;
|
||||||
(VOID)KeSetEvent(&LoadParams->Event, 0, FALSE);
|
KeSetEvent(&LoadParams->Event, 0, FALSE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the driver module if it's loaded for the first time
|
* Initialize the driver module if it's loaded for the first time
|
||||||
*/
|
*/
|
||||||
Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &ServiceName, &DeviceNode);
|
Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &ServiceName, &DeviceNode);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("IopCreateDeviceNode() failed (Status %lx)\n", Status);
|
DPRINT1("IopCreateDeviceNode() failed (Status %lx)\n", Status);
|
||||||
MmUnloadSystemImage(ModuleObject);
|
MmUnloadSystemImage(ModuleObject);
|
||||||
LoadParams->Status = Status;
|
LoadParams->Status = Status;
|
||||||
(VOID)KeSetEvent(&LoadParams->Event, 0, FALSE);
|
KeSetEvent(&LoadParams->Event, 0, FALSE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IopDisplayLoadingMessage(&DeviceNode->ServiceName);
|
IopDisplayLoadingMessage(&DeviceNode->ServiceName);
|
||||||
|
|
||||||
Status = IopInitializeDriverModule(DeviceNode,
|
Status = IopInitializeDriverModule(DeviceNode,
|
||||||
ModuleObject,
|
ModuleObject,
|
||||||
&DeviceNode->ServiceName,
|
&DeviceNode->ServiceName,
|
||||||
(Type == 2 /* SERVICE_FILE_SYSTEM_DRIVER */ ||
|
(Type == 2 /* SERVICE_FILE_SYSTEM_DRIVER */ ||
|
||||||
Type == 8 /* SERVICE_RECOGNIZER_DRIVER */),
|
Type == 8 /* SERVICE_RECOGNIZER_DRIVER */),
|
||||||
&DriverObject);
|
&DriverObject);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("IopInitializeDriver() failed (Status %lx)\n", Status);
|
DPRINT1("IopInitializeDriverModule() failed (Status %lx)\n", Status);
|
||||||
MmUnloadSystemImage(ModuleObject);
|
MmUnloadSystemImage(ModuleObject);
|
||||||
IopFreeDeviceNode(DeviceNode);
|
IopFreeDeviceNode(DeviceNode);
|
||||||
LoadParams->Status = Status;
|
LoadParams->Status = Status;
|
||||||
(VOID)KeSetEvent(&LoadParams->Event, 0, FALSE);
|
KeSetEvent(&LoadParams->Event, 0, FALSE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize and start device */
|
/* Initialize and start device */
|
||||||
IopInitializeDevice(DeviceNode, DriverObject);
|
IopInitializeDevice(DeviceNode, DriverObject);
|
||||||
Status = IopStartDevice(DeviceNode);
|
Status = IopStartDevice(DeviceNode);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DPRINT("DriverObject already exist in ObjectManager\n");
|
DPRINT("DriverObject already exist in ObjectManager\n");
|
||||||
Status = STATUS_IMAGE_ALREADY_LOADED;
|
Status = STATUS_IMAGE_ALREADY_LOADED;
|
||||||
|
|
||||||
/* IopGetDriverObject references the DriverObject, so dereference it */
|
/* IopGetDriverObject references the DriverObject, so dereference it */
|
||||||
ObDereferenceObject(DriverObject);
|
ObDereferenceObject(DriverObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pass status to the caller and signal the event */
|
/* Pass status to the caller and signal the event */
|
||||||
LoadParams->Status = Status;
|
LoadParams->Status = Status;
|
||||||
(VOID)KeSetEvent(&LoadParams->Event, 0, FALSE);
|
KeSetEvent(&LoadParams->Event, 0, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue