This is from SFilter. Does this work alsways … or else we have to handle
any error condition ?
DBGSTATIC
NTSTATUS
SfCreateCompletion(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
IN PVOID Context
)
/*++
Routine Description:
This function is the create/open completion routine for this filter
file system driver. If debugging is enabled, then this function prints
the name of the file that was successfully opened/created by the file
system as a result of the specified I/O request.
Arguments:
DeviceObject - Pointer to the device on which the file was created.
Irp - Pointer to the I/O Request Packet the represents the operation.
Context - This driver’s context parameter - unused;
Return Value:
The function value is STATUS_SUCCESS.
–*/
{
#define BUFFER_SIZE 1024
PIO_STACK_LOCATION irpSp = IoGetCurrentIrpStackLocation( Irp );
PDEVICE_EXTENSION deviceExtension = DeviceObject->DeviceExtension;
NTSTATUS status;
POBJECT_NAME_INFORMATION nameInfo;
ULONG size;
//
// If any debugging level is enabled, attempt to capture the name of the
// file that was just created/opened.
//
if (SfDebug) {
if (nameInfo = ExAllocatePool( NonPagedPool, BUFFER_SIZE )) {
//
// A buffer was successfully allocated. Attempt to determine
// whether this was a volume or a file open, based on the length
// of the file’s name. If it was a volume open, then simply
// query the name of the device. Note that it is not legal to
// perform a relative file open using a NULL name to obtain
another
// handle to the same file, so checking the RelatedFileObject
field
// is unnecessary.
//
if (irpSp->FileObject->FileName.Length) {
status = ObQueryNameString(
irpSp->FileObject,
nameInfo,
BUFFER_SIZE,
&size
);
}
else {
status = ObQueryNameString(
irpSp->FileObject->DeviceObject,
nameInfo,
BUFFER_SIZE,
&size
);
}
//
// If querying the name was successful, actually print the name
// on the debug terminal.
//
if (NT_SUCCESS( status )) {
if (SfDebug & 2) {
if (irpSp->Parameters.Create.Options &
FILE_OPEN_BY_FILE_ID) {
DbgPrint( “SFILTER: Opened %ws\(FID)\n”,
nameInfo->Name.Buffer );
}
else {
DbgPrint( “SFILTER: Opened %ws\n”,
nameInfo->Name.Buffer );
}
}
}
else {
DbgPrint( “SFILTER: Could not get the name for %x\n”,
irpSp->FileObject );
if (!(SfDebug & 4)) {
DbgBreakPoint();
}
}
ExFreePool( nameInfo );
}
}
//
// Propogate the IRP pending flag.
//
if (Irp->PendingReturned) {
IoMarkIrpPending( Irp );
}
return STATUS_SUCCESS;
}
Regards,
Satish K.S
----- Original Message -----
From: “Dejan Maksimovic”
To: “File Systems Developers”
Sent: Tuesday, May 01, 2001 12:00 PM
Subject: [ntfsd] Re: Best Method to get FullPathName
>
> Which doesn’t mean it’s correct-
> Just a note on ObQueryNameString - it returns \Device\harddisk…
> format of the filename! Parsing is needed to bring it back to human
> readable form.
>
> Regards, Dejan.
>
> Satish wrote:
>
> > In SFilter sample they are using FileObject->FileName.Buffer
> > field. Regards,Satish K.S
> >
> > It should. In that case you can’t even determine the
> > filename from the FileObject->FileName.Buffer because
> > theoretically this buffer can be destroyed at the time you
> > are in your completion routine.
> >
> > There is also an undocumented function ObQueryNameString. I
> > don’t know if it exist in NT, but it does exist in Win2000
> > and WinXP. You might consider using that one.
> >
> > Maybe there is some info on this API in the archives, I’s
> > not sure.
> >
> > Bartjan.
> >
> > At 07:22 PM 4/27/01 +0530, you wrote:
> >
> >
> > > I will Query the file name After success of Open/Create by
> > > Setting I/O Completion routine like SFilter sample. Does
> > > this always works ?
> >
> > —
> > You are currently subscribed to ntfsd as:
> > xxxxx@aalayance.com
> > To unsubscribe send a blank email to
> > leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com
> >
> > —
> > You are currently subscribed to ntfsd as: xxxxx@ptt.yu
> > To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
> –
> Kind regards, Dejan M. CEO Alfa Co. www.alfaunits.co.yu and
> www.register.co.yu
> E-mail : xxxxx@ptt.yu, xxxxx@register.co.yu and
> xxxxx@alfaunits.co.yu
> ICQ# : 56570367
> Professional file&system related components and libraries for Win32
> developers.
> Alfa File Monitor - #1 file monitoring system for Win32 developers.
> Alfa File Protector - #1 file protection and hiding system for Win32
> developers.
> Alfa Units - #1 file and system handling units for Delphi.
>
>
>
> —
> You are currently subscribed to ntfsd as: xxxxx@aalayance.com
> To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
—
You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com