Fixed access to non-existent device extension.
authorEric Kohl <eric.kohl@reactos.org>
Thu, 18 Jul 2002 00:29:19 +0000 (00:29 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Thu, 18 Jul 2002 00:29:19 +0000 (00:29 +0000)
svn path=/trunk/; revision=3250

reactos/drivers/dd/beep/beep.c

index 612b042..a26a49a 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: beep.c,v 1.10 2001/08/27 01:25:17 ekohl Exp $
+/* $Id: beep.c,v 1.11 2002/07/18 00:29:19 ekohl Exp $
  *
  * COPYRIGHT:            See COPYING in the top level directory
  * PROJECT:              ReactOS kernel
@@ -32,7 +32,6 @@ typedef struct _BEEP_DEVICE_EXTENSION
 
 /* FUNCTIONS ***************************************************************/
 
-
 static VOID STDCALL
 BeepDPC(PKDPC Dpc,
        PVOID DeferredContext,
@@ -245,26 +244,15 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
   UNICODE_STRING SymlinkName;
   NTSTATUS Status;
 
-  DbgPrint("Beep Device Driver 0.0.3\n");
+  DPRINT("Beep Device Driver 0.0.3\n");
 
+  DriverObject->Flags = 0;
   DriverObject->MajorFunction[IRP_MJ_CREATE] = BeepCreate;
   DriverObject->MajorFunction[IRP_MJ_CLOSE] = BeepClose;
   DriverObject->MajorFunction[IRP_MJ_CLEANUP] = BeepCleanup;
   DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = BeepDeviceControl;
   DriverObject->DriverUnload = BeepUnload;
 
-  /* set up device extension */
-  DeviceExtension = DeviceObject->DeviceExtension;
-  DeviceExtension->BeepOn = FALSE;
-
-  KeInitializeDpc(&DeviceExtension->Dpc,
-                 BeepDPC,
-                 DeviceExtension);
-  KeInitializeTimer(&DeviceExtension->Timer);
-  KeInitializeEvent(&DeviceExtension->Event,
-                   SynchronizationEvent,
-                   FALSE);
-
   RtlInitUnicodeString(&DeviceName,
                       L"\\Device\\Beep");
   Status = IoCreateDevice(DriverObject,
@@ -277,6 +265,19 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
   if (!NT_SUCCESS(Status))
     return Status;
 
+  /* set up device extension */
+  DeviceExtension = DeviceObject->DeviceExtension;
+  DeviceExtension->BeepOn = FALSE;
+
+  KeInitializeDpc(&DeviceExtension->Dpc,
+                 BeepDPC,
+                 DeviceExtension);
+  KeInitializeTimer(&DeviceExtension->Timer);
+  KeInitializeEvent(&DeviceExtension->Event,
+                   SynchronizationEvent,
+                   FALSE);
+
+  /* Create the dos device link */
   RtlInitUnicodeString(&SymlinkName,
                       L"\\??\\Beep");
   IoCreateSymbolicLink(&SymlinkName,