IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 C++ Discussion :

FileSystem Filter Driver


Sujet :

C++

  1. #1
    Membre du Club
    Inscrit en
    Mai 2008
    Messages
    125
    Détails du profil
    Informations personnelles :
    Âge : 41

    Informations forums :
    Inscription : Mai 2008
    Messages : 125
    Points : 45
    Points
    45
    Par défaut FileSystem Filter Driver
    Bonjour à tous,

    Je débute dans la programmation C++ et tout particulièrement dans la création de drivers.

    j'ai commencé à suivre des tutos sur l'apprentissage et la compréhension et jusque la, tout va bien.

    Après, je me suis attaqué à un test avec l'article situé ici : http://support.microsoft.com/kb/319447/en-us

    J'ai compilé, et là, j'ai obtenu plusieurs erreurs de variables non définies.
    J'ai donc tenté de résoudre les erreurs, et au bout de quelques jours, la compilation s'effectue sans erreurs.

    Sauf que, lorsque j'essai d'installer le driver avec loaddrv.exe, j'ai un écran bleu avec l'erreur : MULTIPLE_IRP_COMPLETE_REQUESTS

    Je pense (et c'est surement le cas) avoir fait une erreur, mais bon, la je sèche...

    Voici le code en question :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
     
    #include "ntddk.h"
    //////////////////////////////////////////////////////////////////////////
    // Structures
    typedef struct _FSFILTER_DEVICE_EXTENSION
    {
        PDEVICE_OBJECT AttachedToDeviceObject;
    } FSFILTER_DEVICE_EXTENSION, *PFSFILTER_DEVICE_EXTENSION;
    /////////////////////////////////////////////////////////////////////////
    VOID Unload ( IN PDRIVER_OBJECT DriverObject)
    {
        DbgPrint("Driver déchargé !");
    }
    NTSTATUS DriverEntry (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
    {
     PIO_STACK_LOCATION IrpSp;
     PUNICODE_STRING  FileName;
     PVOID   FileNameBuffer;
     UNICODE_STRING  NewFileName;
     BOOLEAN   bRedirectFileOpen = TRUE;
     PDEVICE_OBJECT   FsDeviceObject;
     PDEVICE_OBJECT   AttachedToDeviceObject;
     PFSFILTER_DEVICE_EXTENSION pDevExt;
     // 
     //  If the device being opened is the primary device object instead of a
     //  filter device object, just indicate that the operation worked.
     // 
     
     FsDeviceObject = DeviceObject;
     if (DeviceObject == FsDeviceObject)
     {
      // 
      //  Allow users to open the device that represents our driver.
      // 
      Irp->IoStatus.Status = STATUS_SUCCESS;
      Irp->IoStatus.Information = FILE_OPENED;
      IoCompleteRequest( Irp, IO_NO_INCREMENT );
      return STATUS_SUCCESS;
     }
     
     IrpSp = IoGetCurrentIrpStackLocation(Irp);
     // 
     // At this point, you must determine whether you want to redirect
     // the file open/create for this particular file.
     // Beware that the file name from the FILE_OBJECT in the current
     // IRP stack location is not always the file name with the full
     // path, nor the long file name or even a name. The way the file is
      // opened (with full path, relatively to another file, with short 
     // or long file name, by ID, ...) affects this name.
     // 
     // TODO: Put your code here to check whether you have to redirect the operation.
     // If so, set bRedirectFileOpen to TRUE and initialize the NewFileName
     // UNICODE_STRING to the full file name of the destination file.
     // 
     RtlInitUnicodeString(&NewFileName, L"<a href="file://\\??\\C:\\test.txt" target="_blank">\\??\\C:\\test.txt</a>");
     if ( bRedirectFileOpen )
     {
      FileName = &(IrpSp->FileObject->FileName);
      FileNameBuffer = ExAllocatePool( NonPagedPool, NewFileName.MaximumLength );
      if (!FileNameBuffer)
      {
       // 
       // Not enough resources. Complete the IRP with the appropriate status.
       // 
       Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
       Irp->IoStatus.Information = 0;
       IoCompleteRequest( Irp, IO_NO_INCREMENT );
       return STATUS_INSUFFICIENT_RESOURCES;
      }
      ExFreePool( FileName->Buffer );
      FileName->Buffer = FileNameBuffer;
      FileName->MaximumLength = NewFileName.MaximumLength;
      RtlCopyUnicodeString( FileName, &NewFileName );
      // 
      // Instruct the IO Manager to reparse this file.
      // 
      Irp->IoStatus.Status = STATUS_REPARSE;
      Irp->IoStatus.Information = IO_REPARSE;
      IoCompleteRequest( Irp, IO_NO_INCREMENT );
      return STATUS_REPARSE;
     }
     else
     {
      // 
      // Pass the request "as is" down the device stack.
      // 
      // 
      // The next driver will get the IO_STACK_LOCATION
      // that you received.
      // 
      IoSkipCurrentIrpStackLocation( Irp );
     
          // 
      // Call the appropriate file system driver with the request.
      // 
      // TODO: Replace AttachedToDeviceObject by the device
      // object pointer your device object is attached to (the
      // lower device object in the stack).
      // Typically, this device object pointer is saved by your
      // filter in your device extension.
      // 
      //return IoCallDriver( AttachedToDeviceObject, Irp );
       pDevExt = DeviceObject->DeviceExtension;
      return IoCallDriver(pDevExt->AttachedToDeviceObject, Irp);
     
     }
    }
    Merci a tous pour vos réponses !

    PS: j'ai mis le resultat de WinDbg en pièce jointe, peut être que ça pourra aider dans le debugage...
    Images attachées Images attachées  

Discussions similaires

  1. DDK et Driver filter
    Par [Mel] dans le forum Windows
    Réponses: 0
    Dernier message: 28/05/2009, 14h35
  2. URGENT DRIVER ODBC
    Par Casp dans le forum Débuter
    Réponses: 3
    Dernier message: 28/04/2003, 16h24
  3. [PostgreSQL] PB de drivers JAVA
    Par koundelitch dans le forum Administration
    Réponses: 5
    Dernier message: 14/03/2003, 15h09
  4. [MFC] Utilisation Drivers
    Par LAPLACE dans le forum MFC
    Réponses: 4
    Dernier message: 21/12/2002, 10h29
  5. CFileDialog Filter
    Par Patrick Beaudoin dans le forum MFC
    Réponses: 4
    Dernier message: 07/09/2002, 09h51

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo