Commit 92d8ec79 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

ntoskrnl.exe: Make the driver object accessible by name while in its entry point.

parent 32b24976
......@@ -1413,10 +1413,15 @@ NTSTATUS WINAPI IoCreateDriver( UNICODE_STRING *name, PDRIVER_INITIALIZE init )
for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
driver->driver_obj.MajorFunction[i] = unhandled_irp;
EnterCriticalSection( &drivers_cs );
if (wine_rb_put( &wine_drivers, &driver->driver_obj.DriverName, &driver->entry ))
ERR( "failed to insert driver %s in tree\n", debugstr_us(name) );
LeaveCriticalSection( &drivers_cs );
status = driver->driver_obj.DriverInit( &driver->driver_obj, &driver->driver_extension.ServiceKeyName );
if (status)
{
ObDereferenceObject( driver );
IoDeleteDriver( &driver->driver_obj );
return status;
}
......@@ -1426,10 +1431,6 @@ NTSTATUS WINAPI IoCreateDriver( UNICODE_STRING *name, PDRIVER_INITIALIZE init )
driver->driver_obj.MajorFunction[i] = unhandled_irp;
}
EnterCriticalSection( &drivers_cs );
if (wine_rb_put( &wine_drivers, &driver->driver_obj.DriverName, &driver->entry ))
ERR( "failed to insert driver %s in tree\n", debugstr_us(name) );
LeaveCriticalSection( &drivers_cs );
return STATUS_SUCCESS;
}
......
......@@ -56,7 +56,7 @@ static int running_under_wine;
static int winetest_debug;
static int winetest_report_success;
static POBJECT_TYPE *pExEventObjectType, *pIoFileObjectType, *pPsThreadType;
static POBJECT_TYPE *pExEventObjectType, *pIoFileObjectType, *pPsThreadType, *pIoDriverObjectType;
static PEPROCESS *pPsInitialSystemProcess;
static void *create_caller_thread;
......@@ -1887,8 +1887,12 @@ static VOID WINAPI driver_Unload(DRIVER_OBJECT *driver)
NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, PUNICODE_STRING registry)
{
static const WCHAR IoDriverObjectTypeW[] = {'I','o','D','r','i','v','e','r','O','b','j','e','c','t','T','y','p','e',0};
static const WCHAR driver_nameW[] = {'\\','D','r','i','v','e','r',
'\\','W','i','n','e','T','e','s','t','D','r','i','v','e','r',0};
UNICODE_STRING nameW, linkW;
NTSTATUS status;
void *obj;
DbgPrint("loading driver\n");
......@@ -1903,6 +1907,19 @@ NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, PUNICODE_STRING registry)
driver->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = driver_FlushBuffers;
driver->MajorFunction[IRP_MJ_CLOSE] = driver_Close;
RtlInitUnicodeString(&nameW, IoDriverObjectTypeW);
pIoDriverObjectType = MmGetSystemRoutineAddress(&nameW);
RtlInitUnicodeString(&nameW, driver_nameW);
if ((status = ObReferenceObjectByName(&nameW, 0, NULL, 0, *pIoDriverObjectType, KernelMode, NULL, &obj)))
return status;
if (obj != driver)
{
ObDereferenceObject(obj);
return STATUS_UNSUCCESSFUL;
}
ObDereferenceObject(obj);
RtlInitUnicodeString(&nameW, device_name);
RtlInitUnicodeString(&linkW, driver_link);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment