Use proper IRP structure
authorAlex Ionescu <aionescu@gmail.com>
Sun, 31 Oct 2004 22:21:41 +0000 (22:21 +0000)
committerAlex Ionescu <aionescu@gmail.com>
Sun, 31 Oct 2004 22:21:41 +0000 (22:21 +0000)
svn path=/trunk/; revision=11515

reactos/include/ddk/iofuncs.h
reactos/include/ddk/iotypes.h
reactos/ntoskrnl/io/cleanup.c
reactos/ntoskrnl/io/irp.c

index 4ac000e..ab2ff91 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef _INCLUDE_DDK_IOFUNCS_H
 #define _INCLUDE_DDK_IOFUNCS_H
-/* $Id: iofuncs.h,v 1.45 2004/10/22 20:51:44 ekohl Exp $ */
+/* $Id: iofuncs.h,v 1.46 2004/10/31 22:21:41 ion Exp $ */
 
 #ifdef __NTOSKRNL__
 extern POBJECT_TYPE EXPORTED IoAdapterObjectType;
@@ -1042,14 +1042,8 @@ IoSetTopLevelIrp (
 USHORT
 IoSizeOfIrp (CCHAR StackSize)
  */
-#define IoSizeOfIrp(StackSize) \
-       ((USHORT)(sizeof(IRP)+(((StackSize)-1)*sizeof(IO_STACK_LOCATION))))
-
-/* original macro */
-/*
 #define IoSizeOfIrp(StackSize) \
        ((USHORT)(sizeof(IRP)+((StackSize)*sizeof(IO_STACK_LOCATION))))
-*/
 
 /*
  * FUNCTION: Dequeues the next IRP from the device's associated queue and
index ab0692c..1f88b42 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: iotypes.h,v 1.66 2004/10/23 23:43:23 ion Exp $
+/* $Id: iotypes.h,v 1.67 2004/10/31 22:21:41 ion Exp $
  *
  */
 
@@ -869,7 +869,6 @@ typedef struct _IRP
        KAPC Apc;
        ULONG CompletionKey;
      } Tail;
-   IO_STACK_LOCATION Stack[1];
 } IRP, *PIRP;
 
 #define VPB_MOUNTED                     0x00000001
index e88a15f..5390672 100644 (file)
@@ -190,7 +190,8 @@ IoSecondStageCompletion(
      InitializeListHead(&Irp->ThreadListEntry);
    }
    
-   IoStack = &Irp->Stack[(ULONG)Irp->CurrentLocation];
+   DPRINT("Tail Value %x, Irp Value %x\n", Irp->Tail.Overlay.CurrentStackLocation - (PIO_STACK_LOCATION)(Irp+1), Irp->CurrentLocation);
+   by 
    DeviceObject = IoStack->DeviceObject;
 
    DPRINT("IoSecondStageCompletion(Irp %x, PriorityBoost %d)\n", Irp, PriorityBoost);
index 22e7c35..88069be 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: irp.c,v 1.68 2004/10/22 20:25:53 ekohl Exp $
+/* $Id: irp.c,v 1.69 2004/10/31 22:21:41 ion Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -164,12 +164,14 @@ IoInitializeIrp(PIRP Irp,
 {
   ASSERT(Irp != NULL);
 
+  DPRINT("IoInitializeIrp(StackSize %x, Irp %x)\n",StackSize, Irp);
   memset(Irp, 0, PacketSize);
   Irp->Size = PacketSize;
   Irp->StackCount = StackSize;
   Irp->CurrentLocation = StackSize;
   InitializeListHead(&Irp->ThreadListEntry);
-  Irp->Tail.Overlay.CurrentStackLocation = &Irp->Stack[(ULONG)StackSize];
+  Irp->Tail.Overlay.CurrentStackLocation = (PIO_STACK_LOCATION)(Irp + 1) + StackSize;
+  DPRINT("Irp->Tail.Overlay.CurrentStackLocation %x\n", Irp->Tail.Overlay.CurrentStackLocation);
   Irp->ApcEnvironment =  KeGetCurrentThread()->ApcStateIndex;
 }
 
@@ -297,6 +299,7 @@ IofCompleteRequest(PIRP Irp,
    PDEVICE_OBJECT    DeviceObject;
    KIRQL             oldIrql;
    PMDL              Mdl;
+   PIO_STACK_LOCATION Stack = (PIO_STACK_LOCATION)(Irp + 1);
 
    DPRINT("IoCompleteRequest(Irp %x, PriorityBoost %d) Event %x THread %x\n",
       Irp,PriorityBoost, Irp->UserEvent, PsGetCurrentThread());
@@ -334,14 +337,14 @@ IofCompleteRequest(PIRP Irp,
          DeviceObject = NULL;
       }
 
-      if (Irp->Stack[i].CompletionRoutine != NULL &&
-         ((NT_SUCCESS(Irp->IoStatus.Status) && (Irp->Stack[i].Control & SL_INVOKE_ON_SUCCESS)) ||
-         (!NT_SUCCESS(Irp->IoStatus.Status) && (Irp->Stack[i].Control & SL_INVOKE_ON_ERROR)) ||
-         (Irp->Cancel && (Irp->Stack[i].Control & SL_INVOKE_ON_CANCEL))))
+      if (Stack[i].CompletionRoutine != NULL &&
+         ((NT_SUCCESS(Irp->IoStatus.Status) && (Stack[i].Control & SL_INVOKE_ON_SUCCESS)) ||
+         (!NT_SUCCESS(Irp->IoStatus.Status) && (Stack[i].Control & SL_INVOKE_ON_ERROR)) ||
+         (Irp->Cancel && (Stack[i].Control & SL_INVOKE_ON_CANCEL))))
       {
-         Status = Irp->Stack[i].CompletionRoutine(DeviceObject,
+         Status = Stack[i].CompletionRoutine(DeviceObject,
                                                   Irp,
-                                                  Irp->Stack[i].Context);
+                                                  Stack[i].Context);
 
          if (Status == STATUS_MORE_PROCESSING_REQUIRED)
          {