AV knows what I do even when I access underlying NTFS directly.

Hi All,

I’ve got an interesting but annoying situation. I’ve got a direct file
system access kernel driver (not filter driver).
What it does is simply create its own IRP(roll my own IRP) to access
files(SetInformationFile, QueryInformationFile, and QueryDirectory) with
underlying NTFS driver’s volume device object(VDO). I open the file using
IoCreateFileSpecifyDeviceObjectHint with retrieved NTFS VDO to bypass
filters. It seemed working fine till I found FileMon and FileSpy both
reported strange results when running with Norton AV and Sophos AV filters.

I issue IRP_MJ_DIRECTORY_CONTROL/IRP_MN_QUERY_DIRECTORY, and they report
IRP_MJ_CREATE, IRP_MJ_READ, FASTIO_QUERY_BASIC_INFO, etc. And I also found
when i issueed my IRP, NtCreateFile and NtCreateSection were also invoked. I
narrowed down the test scenario, but there were still a bunch of Major IRPs
and FASTIOs. Using IrpTracker, I found norton antivirus is involved with
this IRP flows. In conclusion, both AV service process in the background and
the original user process accessing files participated in sending these IRPs
to get the file information and scan the file.

My question is, ‘How does norton AV(as well as Sophos AV) filter driver know
what I’m doing?’.
Interestingly enough, neither IoCreateFileSpecifyDeviceObjectHint() nor
ZwClose() triggered any AV IRP activities. It obviously happens for
IRP_MJ_DIRECTORY_CONTROL/IRP_MN_QUERY_DIRECTORY. Remember this IRP is not
caught by FileMon and FileSpy. This just create another IRP dispatches by AV
because AV detects my attempt to enumerate the directory. The only
possibility they could detect my file access may be through IrpCompletion
routine. Because IrpCompletion routines are invoked for every filter
drivers, AV filter drivers would have seen my IRP’s existence even though
they couldn’t see it in IRP population stage along the filter stack.

Is my analysis plausible? If so, can someone tell me how to avoid using
completion routine in my driver? Or any other thoughts? I have to avoid
unnecessary interference with AVs for performance reasons.

Many thanks.

Kind Regards,
Sean

Oh my source code might be useful to find the problem.

NTSTATUS CDirectFile::QueryDirectoryFile(
HANDLE hFile,
FILE_INFORMATION_CLASS FileInformationClass,
PVOID Information,
ULONG InformationSize,
BOOLEAN RestartScan,
BOOLEAN ReturnSingleEntry
)
{
NTSTATUS status;
PIRP irp;
KEVENT event;
IO_STATUS_BLOCK iostatus;

if(IsWinXP())
{
//
// Get the File Object pointer from File Handle
//
PFILE_OBJECT FileObject;
status = ObReferenceObjectByHandle(
hFile,
FILE_READ_ACCESS,
*IoFileObjectType,
KernelMode,
(PVOID*)&FileObject,
0
);

if(!NT_SUCCESS(status))
return status;

// We got FileObject from hFile, so dereference it.
ObDereferenceObject(FileObject);

// Set up Base FS Device Object
// pBaseFsDeviceObject is initialized to underlying base
file
// system VDO through constructor. If it isn’t set, find
it out
// manually. (This class isn’t for remote file system,
// so Vpb is valid)
if(m_pBaseFsDeviceObject == NULL)
{
if(FileObject->DeviceObject->Vpb == NULL)
return STATUS_ACCESS_VIOLATION;

m_pBaseFsDeviceObject =
FileObject->DeviceObject->Vpb->DeviceObject;
}

// Allocate an irp for this request. This could also
come from a
// private pool, for instance.
irp = IoAllocateIrp(m_pBaseFsDeviceObject->StackSize,
FALSE);
if(!irp)
{
return STATUS_INSUFFICIENT_RESOURCES;
}

irp->UserBuffer = Information;
irp->UserEvent = &event;
irp->UserIosb = &iostatus;
irp->Tail.Overlay.Thread = PsGetCurrentThread();
irp->Tail.Overlay.OriginalFileObject = FileObject;
irp->RequestorMode = KernelMode;

// Initialize the event
KeInitializeEvent(&event, SynchronizationEvent, FALSE);

//
// Set up the I/O stack location.
//
PIO_STACK_LOCATION irpSp =
IoGetNextIrpStackLocation(irp);

irpSp->MajorFunction = IRP_MJ_DIRECTORY_CONTROL;
irpSp->MinorFunction = IRP_MN_QUERY_DIRECTORY;
irpSp->DeviceObject = m_pBaseFsDeviceObject;
irpSp->FileObject = FileObject;
irpSp->Parameters.QueryDirectory.FileInformationClass =
FileInformationClass;
irpSp->Parameters.QueryDirectory.Length =
InformationSize;

irpSp->Flags |= ReturnSingleEntry ?
SL_RETURN_SINGLE_ENTRY : 0;
irpSp->Flags |= RestartScan ? SL_RESTART_SCAN : 0;

//
// Set the completion routine.
//
IoSetCompletionRoutine(irp, LinkTo(IrpComplete), this,
TRUE, TRUE, TRUE);

//
// Send it to the FSD
//
IoCallDriver(m_pBaseFsDeviceObject, irp);

//
// Wait for the I/O
//
KeWaitForSingleObject(&event, Executive, KernelMode,
TRUE, 0);

status = iostatus.Status;
}
}

NTSTATUS CDirectFile::IrpComplete(
PDEVICE_OBJECT DeviceObject,
PIRP Irp,
PVOID Context
)
{
// Copy the status information back to IOSB.
*Irp->UserIosb = Irp->IoStatus;

// Set the user event - wakes up the mainline code doing this.
KeSetEvent(Irp->UserEvent, 0, FALSE);

// Free the IRP now that we are done with it.
IoFreeIrp(Irp);

return STATUS_MORE_PROCESSING_REQUIRED;
}

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Sean Park
Sent: Thursday, 12 January 2006 4:04 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] AV knows what I do even when I access underlying NTFS
directly.

Hi All,

I’ve got an interesting but annoying situation. I’ve got a direct file
system access kernel driver (not filter driver).
What it does is simply create its own IRP(roll my own IRP) to access
files(SetInformationFile, QueryInformationFile, and QueryDirectory) with

underlying NTFS driver’s volume device object(VDO). I open the file
using
IoCreateFileSpecifyDeviceObjectHint with retrieved NTFS VDO to bypass
filters. It seemed working fine till I found FileMon and FileSpy both
reported strange results when running with Norton AV and Sophos AV
filters.

I issue IRP_MJ_DIRECTORY_CONTROL/IRP_MN_QUERY_DIRECTORY, and they report

IRP_MJ_CREATE, IRP_MJ_READ, FASTIO_QUERY_BASIC_INFO, etc. And I also
found
when i issueed my IRP, NtCreateFile and NtCreateSection were also
invoked. I
narrowed down the test scenario, but there were still a bunch of Major
IRPs
and FASTIOs. Using IrpTracker, I found norton antivirus is involved with

this IRP flows. In conclusion, both AV service process in the background
and
the original user process accessing files participated in sending these
IRPs
to get the file information and scan the file.

My question is, ‘How does norton AV(as well as Sophos AV) filter driver
know
what I’m doing?’.
Interestingly enough, neither IoCreateFileSpecifyDeviceObjectHint() nor
ZwClose() triggered any AV IRP activities. It obviously happens for
IRP_MJ_DIRECTORY_CONTROL/IRP_MN_QUERY_DIRECTORY. Remember this IRP is
not
caught by FileMon and FileSpy. This just create another IRP dispatches
by AV
because AV detects my attempt to enumerate the directory. The only
possibility they could detect my file access may be through
IrpCompletion
routine. Because IrpCompletion routines are invoked for every filter
drivers, AV filter drivers would have seen my IRP’s existence even
though
they couldn’t see it in IRP population stage along the filter stack.

Is my analysis plausible? If so, can someone tell me how to avoid using
completion routine in my driver? Or any other thoughts? I have to avoid

unnecessary interference with AVs for performance reasons.

Many thanks.

Kind Regards,
Sean


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@pctools.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Hmmm…

On second thought, I realized other intermediate AV filter drivers’ IRP
completion routines won’t be called because there is no
IRP_STACK_LOCATION for them in the IRP. There must be another reason…

They can’t back-trace for ZwClose(). However, IRP_MJ_CLEANUP and
IRP_MJ_CLOSE for this customized IRP won’t be directed to intermediate
filter drivers because it checks VPB of the FileObject and sends to the
correct VDO, which is underlying base file system VDO.

Any thoughts?
I appreciate any comments.

Cheers,

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Sean Park
Sent: Thursday, 12 January 2006 4:22 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] AV knows what I do even when I access underlying
NTFS directly.

Oh my source code might be useful to find the problem.

NTSTATUS CDirectFile::QueryDirectoryFile(
HANDLE hFile,
FILE_INFORMATION_CLASS FileInformationClass,
PVOID Information,
ULONG InformationSize,
BOOLEAN RestartScan,
BOOLEAN ReturnSingleEntry
)
{
NTSTATUS status;
PIRP irp;
KEVENT event;
IO_STATUS_BLOCK iostatus;

if(IsWinXP())
{
//
// Get the File Object pointer from File Handle
//
PFILE_OBJECT FileObject;
status = ObReferenceObjectByHandle(
hFile,
FILE_READ_ACCESS,
*IoFileObjectType,
KernelMode,
(PVOID*)&FileObject,
0
);

if(!NT_SUCCESS(status))
return status;

// We got FileObject from hFile, so dereference it.
ObDereferenceObject(FileObject);

// Set up Base FS Device Object
// pBaseFsDeviceObject is initialized to underlying base
file
// system VDO through constructor. If it isn’t set, find
it out
// manually. (This class isn’t for remote file system,
// so Vpb is valid)
if(m_pBaseFsDeviceObject == NULL)
{
if(FileObject->DeviceObject->Vpb == NULL)
return STATUS_ACCESS_VIOLATION;

m_pBaseFsDeviceObject =
FileObject->DeviceObject->Vpb->DeviceObject;
}

// Allocate an irp for this request. This could also
come from a
// private pool, for instance.
irp = IoAllocateIrp(m_pBaseFsDeviceObject->StackSize,
FALSE);
if(!irp)
{
return STATUS_INSUFFICIENT_RESOURCES;
}

irp->UserBuffer = Information;
irp->UserEvent = &event;
irp->UserIosb = &iostatus;
irp->Tail.Overlay.Thread = PsGetCurrentThread();
irp->Tail.Overlay.OriginalFileObject = FileObject;
irp->RequestorMode = KernelMode;

// Initialize the event
KeInitializeEvent(&event, SynchronizationEvent, FALSE);

//
// Set up the I/O stack location.
//
PIO_STACK_LOCATION irpSp =
IoGetNextIrpStackLocation(irp);

irpSp->MajorFunction = IRP_MJ_DIRECTORY_CONTROL;
irpSp->MinorFunction = IRP_MN_QUERY_DIRECTORY;
irpSp->DeviceObject = m_pBaseFsDeviceObject;
irpSp->FileObject = FileObject;
irpSp->Parameters.QueryDirectory.FileInformationClass =
FileInformationClass;
irpSp->Parameters.QueryDirectory.Length =
InformationSize;

irpSp->Flags |= ReturnSingleEntry ?
SL_RETURN_SINGLE_ENTRY : 0;
irpSp->Flags |= RestartScan ? SL_RESTART_SCAN : 0;

//
// Set the completion routine.
//
IoSetCompletionRoutine(irp, LinkTo(IrpComplete), this,
TRUE, TRUE, TRUE);

//
// Send it to the FSD
//
IoCallDriver(m_pBaseFsDeviceObject, irp);

//
// Wait for the I/O
//
KeWaitForSingleObject(&event, Executive, KernelMode,
TRUE, 0);

status = iostatus.Status;
}
}

NTSTATUS CDirectFile::IrpComplete(
PDEVICE_OBJECT DeviceObject,
PIRP Irp,
PVOID Context
)
{
// Copy the status information back to IOSB.
*Irp->UserIosb = Irp->IoStatus;

// Set the user event - wakes up the mainline code doing this.
KeSetEvent(Irp->UserEvent, 0, FALSE);

// Free the IRP now that we are done with it.
IoFreeIrp(Irp);

return STATUS_MORE_PROCESSING_REQUIRED;
}

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Sean Park
Sent: Thursday, 12 January 2006 4:04 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] AV knows what I do even when I access underlying NTFS
directly.

Hi All,

I’ve got an interesting but annoying situation. I’ve got a direct file
system access kernel driver (not filter driver).
What it does is simply create its own IRP(roll my own IRP) to access
files(SetInformationFile, QueryInformationFile, and QueryDirectory) with

underlying NTFS driver’s volume device object(VDO). I open the file
using
IoCreateFileSpecifyDeviceObjectHint with retrieved NTFS VDO to bypass
filters. It seemed working fine till I found FileMon and FileSpy both
reported strange results when running with Norton AV and Sophos AV
filters.

I issue IRP_MJ_DIRECTORY_CONTROL/IRP_MN_QUERY_DIRECTORY, and they report

IRP_MJ_CREATE, IRP_MJ_READ, FASTIO_QUERY_BASIC_INFO, etc. And I also
found
when i issueed my IRP, NtCreateFile and NtCreateSection were also
invoked. I
narrowed down the test scenario, but there were still a bunch of Major
IRPs
and FASTIOs. Using IrpTracker, I found norton antivirus is involved with

this IRP flows. In conclusion, both AV service process in the background
and
the original user process accessing files participated in sending these
IRPs
to get the file information and scan the file.

My question is, ‘How does norton AV(as well as Sophos AV) filter driver
know
what I’m doing?’.
Interestingly enough, neither IoCreateFileSpecifyDeviceObjectHint() nor
ZwClose() triggered any AV IRP activities. It obviously happens for
IRP_MJ_DIRECTORY_CONTROL/IRP_MN_QUERY_DIRECTORY. Remember this IRP is
not
caught by FileMon and FileSpy. This just create another IRP dispatches
by AV
because AV detects my attempt to enumerate the directory. The only
possibility they could detect my file access may be through
IrpCompletion
routine. Because IrpCompletion routines are invoked for every filter
drivers, AV filter drivers would have seen my IRP’s existence even
though
they couldn’t see it in IRP population stage along the filter stack.

Is my analysis plausible? If so, can someone tell me how to avoid using
completion routine in my driver? Or any other thoughts? I have to avoid

unnecessary interference with AVs for performance reasons.

Many thanks.

Kind Regards,
Sean


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@pctools.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Sean,

Did you confirm they aren’t “stealing” the NTFS entry point? That is,
does the IRP_MJ_XXX handler point to a function inside NTFS?

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

Looking forward to seeing you at the next OSR File Systems class in
Boston, MA April 24-27, 2006.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Sean Park
Sent: Thursday, January 12, 2006 1:54 AM
To: ntfsd redirect
Subject: RE: [ntfsd] AV knows what I do even when I access underlying
NTFS directly.

Hmmm…

On second thought, I realized other intermediate AV filter drivers’ IRP
completion routines won’t be called because there is no
IRP_STACK_LOCATION for them in the IRP. There must be another reason…

They can’t back-trace for ZwClose(). However, IRP_MJ_CLEANUP and
IRP_MJ_CLOSE for this customized IRP won’t be directed to intermediate
filter drivers because it checks VPB of the FileObject and sends to the
correct VDO, which is underlying base file system VDO.

Any thoughts?
I appreciate any comments.

Cheers,

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Sean Park
Sent: Thursday, 12 January 2006 4:22 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] AV knows what I do even when I access underlying
NTFS directly.

Oh my source code might be useful to find the problem.

NTSTATUS CDirectFile::QueryDirectoryFile(
HANDLE hFile,
FILE_INFORMATION_CLASS FileInformationClass,
PVOID Information,
ULONG InformationSize,
BOOLEAN RestartScan,
BOOLEAN ReturnSingleEntry
)
{
NTSTATUS status;
PIRP irp;
KEVENT event;
IO_STATUS_BLOCK iostatus;

if(IsWinXP())
{
//
// Get the File Object pointer from File Handle
//
PFILE_OBJECT FileObject;
status = ObReferenceObjectByHandle(
hFile,
FILE_READ_ACCESS,
*IoFileObjectType,
KernelMode,
(PVOID*)&FileObject,
0
);

if(!NT_SUCCESS(status))
return status;

// We got FileObject from hFile, so dereference it.
ObDereferenceObject(FileObject);

// Set up Base FS Device Object
// pBaseFsDeviceObject is initialized to underlying base
file
// system VDO through constructor. If it isn’t set, find
it out
// manually. (This class isn’t for remote file system,
// so Vpb is valid)
if(m_pBaseFsDeviceObject == NULL)
{
if(FileObject->DeviceObject->Vpb == NULL)
return STATUS_ACCESS_VIOLATION;

m_pBaseFsDeviceObject =
FileObject->DeviceObject->Vpb->DeviceObject;
}

// Allocate an irp for this request. This could also
come from a
// private pool, for instance.
irp = IoAllocateIrp(m_pBaseFsDeviceObject->StackSize,
FALSE);
if(!irp)
{
return STATUS_INSUFFICIENT_RESOURCES;
}

irp->UserBuffer = Information;
irp->UserEvent = &event;
irp->UserIosb = &iostatus;
irp->Tail.Overlay.Thread = PsGetCurrentThread();
irp->Tail.Overlay.OriginalFileObject = FileObject;
irp->RequestorMode = KernelMode;

// Initialize the event
KeInitializeEvent(&event, SynchronizationEvent, FALSE);

//
// Set up the I/O stack location.
//
PIO_STACK_LOCATION irpSp =
IoGetNextIrpStackLocation(irp);

irpSp->MajorFunction = IRP_MJ_DIRECTORY_CONTROL;
irpSp->MinorFunction = IRP_MN_QUERY_DIRECTORY;
irpSp->DeviceObject = m_pBaseFsDeviceObject;
irpSp->FileObject = FileObject;
irpSp->Parameters.QueryDirectory.FileInformationClass =
FileInformationClass;
irpSp->Parameters.QueryDirectory.Length =
InformationSize;

irpSp->Flags |= ReturnSingleEntry ?
SL_RETURN_SINGLE_ENTRY : 0;
irpSp->Flags |= RestartScan ? SL_RESTART_SCAN : 0;

//
// Set the completion routine.
//
IoSetCompletionRoutine(irp, LinkTo(IrpComplete), this,
TRUE, TRUE, TRUE);

//
// Send it to the FSD
//
IoCallDriver(m_pBaseFsDeviceObject, irp);

//
// Wait for the I/O
//
KeWaitForSingleObject(&event, Executive, KernelMode,
TRUE, 0);

status = iostatus.Status;
}
}

NTSTATUS CDirectFile::IrpComplete(
PDEVICE_OBJECT DeviceObject,
PIRP Irp,
PVOID Context
)
{
// Copy the status information back to IOSB.
*Irp->UserIosb = Irp->IoStatus;

// Set the user event - wakes up the mainline code doing this.
KeSetEvent(Irp->UserEvent, 0, FALSE);

// Free the IRP now that we are done with it.
IoFreeIrp(Irp);

return STATUS_MORE_PROCESSING_REQUIRED;
}

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Sean Park
Sent: Thursday, 12 January 2006 4:04 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] AV knows what I do even when I access underlying NTFS
directly.

Hi All,

I’ve got an interesting but annoying situation. I’ve got a direct file
system access kernel driver (not filter driver).
What it does is simply create its own IRP(roll my own IRP) to access
files(SetInformationFile, QueryInformationFile, and QueryDirectory) with

underlying NTFS driver’s volume device object(VDO). I open the file
using
IoCreateFileSpecifyDeviceObjectHint with retrieved NTFS VDO to bypass
filters. It seemed working fine till I found FileMon and FileSpy both
reported strange results when running with Norton AV and Sophos AV
filters.

I issue IRP_MJ_DIRECTORY_CONTROL/IRP_MN_QUERY_DIRECTORY, and they report

IRP_MJ_CREATE, IRP_MJ_READ, FASTIO_QUERY_BASIC_INFO, etc. And I also
found
when i issueed my IRP, NtCreateFile and NtCreateSection were also
invoked. I
narrowed down the test scenario, but there were still a bunch of Major
IRPs
and FASTIOs. Using IrpTracker, I found norton antivirus is involved with

this IRP flows. In conclusion, both AV service process in the background
and
the original user process accessing files participated in sending these
IRPs
to get the file information and scan the file.

My question is, ‘How does norton AV(as well as Sophos AV) filter driver
know
what I’m doing?’.
Interestingly enough, neither IoCreateFileSpecifyDeviceObjectHint() nor
ZwClose() triggered any AV IRP activities. It obviously happens for
IRP_MJ_DIRECTORY_CONTROL/IRP_MN_QUERY_DIRECTORY. Remember this IRP is
not
caught by FileMon and FileSpy. This just create another IRP dispatches
by AV
because AV detects my attempt to enumerate the directory. The only
possibility they could detect my file access may be through
IrpCompletion
routine. Because IrpCompletion routines are invoked for every filter
drivers, AV filter drivers would have seen my IRP’s existence even
though
they couldn’t see it in IRP population stage along the filter stack.

Is my analysis plausible? If so, can someone tell me how to avoid using
completion routine in my driver? Or any other thoughts? I have to avoid

unnecessary interference with AVs for performance reasons.

Many thanks.

Kind Regards,
Sean


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@pctools.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

> They can’t back-trace for ZwClose(). However, IRP_MJ_CLEANUP and

IRP_MJ_CLOSE for this customized IRP won’t be directed to intermediate
filter drivers because it checks VPB of the FileObject and sends to the
correct VDO, which is underlying base file system VDO.

I am afraid CLEANUP and CLOSE will be sent through the whole
filter stack. Can’t this be the reason ? Does FileSpy catch some CLEANUPs
without appropriate CREATE ?

L.

They didn’t. I checked them out using my own tool. I can think of other nasty things such as NT kernel code inline hooking or even faking virtual memory using customised page fault handler. But I want find out a more plausible reason.

Thanks for your comment, Tony.

Regards,
Sean


From: xxxxx@lists.osr.com on behalf of Tony Mason
Sent: Thu 1/12/2006 6:26 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] AV knows what I do even when I access underlying NTFS directly.

Sean,

Did you confirm they aren’t “stealing” the NTFS entry point? That is,
does the IRP_MJ_XXX handler point to a function inside NTFS?

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

Looking forward to seeing you at the next OSR File Systems class in
Boston, MA April 24-27, 2006.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Sean Park
Sent: Thursday, January 12, 2006 1:54 AM
To: ntfsd redirect
Subject: RE: [ntfsd] AV knows what I do even when I access underlying
NTFS directly.

Hmmm…

On second thought, I realized other intermediate AV filter drivers’ IRP
completion routines won’t be called because there is no
IRP_STACK_LOCATION for them in the IRP. There must be another reason…

They can’t back-trace for ZwClose(). However, IRP_MJ_CLEANUP and
IRP_MJ_CLOSE for this customized IRP won’t be directed to intermediate
filter drivers because it checks VPB of the FileObject and sends to the
correct VDO, which is underlying base file system VDO.

Any thoughts?
I appreciate any comments.

Cheers,

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Sean Park
Sent: Thursday, 12 January 2006 4:22 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] AV knows what I do even when I access underlying
NTFS directly.

Oh my source code might be useful to find the problem.

NTSTATUS CDirectFile::QueryDirectoryFile(
HANDLE hFile,
FILE_INFORMATION_CLASS FileInformationClass,
PVOID Information,
ULONG InformationSize,
BOOLEAN RestartScan,
BOOLEAN ReturnSingleEntry
)
{
NTSTATUS status;
PIRP irp;
KEVENT event;
IO_STATUS_BLOCK iostatus;

if(IsWinXP())
{
//
// Get the File Object pointer from File Handle
//
PFILE_OBJECT FileObject;
status = ObReferenceObjectByHandle(
hFile,
FILE_READ_ACCESS,
*IoFileObjectType,
KernelMode,
(PVOID*)&FileObject,
0
);

if(!NT_SUCCESS(status))
return status;

// We got FileObject from hFile, so dereference it.
ObDereferenceObject(FileObject);

// Set up Base FS Device Object
// pBaseFsDeviceObject is initialized to underlying base
file
// system VDO through constructor. If it isn’t set, find
it out
// manually. (This class isn’t for remote file system,
// so Vpb is valid)
if(m_pBaseFsDeviceObject == NULL)
{
if(FileObject->DeviceObject->Vpb == NULL)
return STATUS_ACCESS_VIOLATION;

m_pBaseFsDeviceObject =
FileObject->DeviceObject->Vpb->DeviceObject;
}

// Allocate an irp for this request. This could also
come from a
// private pool, for instance.
irp = IoAllocateIrp(m_pBaseFsDeviceObject->StackSize,
FALSE);
if(!irp)
{
return STATUS_INSUFFICIENT_RESOURCES;
}

irp->UserBuffer = Information;
irp->UserEvent = &event;
irp->UserIosb = &iostatus;
irp->Tail.Overlay.Thread = PsGetCurrentThread();
irp->Tail.Overlay.OriginalFileObject = FileObject;
irp->RequestorMode = KernelMode;

// Initialize the event
KeInitializeEvent(&event, SynchronizationEvent, FALSE);

//
// Set up the I/O stack location.
//
PIO_STACK_LOCATION irpSp =
IoGetNextIrpStackLocation(irp);

irpSp->MajorFunction = IRP_MJ_DIRECTORY_CONTROL;
irpSp->MinorFunction = IRP_MN_QUERY_DIRECTORY;
irpSp->DeviceObject = m_pBaseFsDeviceObject;
irpSp->FileObject = FileObject;
irpSp->Parameters.QueryDirectory.FileInformationClass =
FileInformationClass;
irpSp->Parameters.QueryDirectory.Length =
InformationSize;

irpSp->Flags |= ReturnSingleEntry ?
SL_RETURN_SINGLE_ENTRY : 0;
irpSp->Flags |= RestartScan ? SL_RESTART_SCAN : 0;

//
// Set the completion routine.
//
IoSetCompletionRoutine(irp, LinkTo(IrpComplete), this,
TRUE, TRUE, TRUE);

//
// Send it to the FSD
//
IoCallDriver(m_pBaseFsDeviceObject, irp);

//
// Wait for the I/O
//
KeWaitForSingleObject(&event, Executive, KernelMode,
TRUE, 0);

status = iostatus.Status;
}
}

NTSTATUS CDirectFile::IrpComplete(
PDEVICE_OBJECT DeviceObject,
PIRP Irp,
PVOID Context
)
{
// Copy the status information back to IOSB.
*Irp->UserIosb = Irp->IoStatus;

// Set the user event - wakes up the mainline code doing this.
KeSetEvent(Irp->UserEvent, 0, FALSE);

// Free the IRP now that we are done with it.
IoFreeIrp(Irp);

return STATUS_MORE_PROCESSING_REQUIRED;
}

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Sean Park
Sent: Thursday, 12 January 2006 4:04 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] AV knows what I do even when I access underlying NTFS
directly.

Hi All,

I’ve got an interesting but annoying situation. I’ve got a direct file
system access kernel driver (not filter driver).
What it does is simply create its own IRP(roll my own IRP) to access
files(SetInformationFile, QueryInformationFile, and QueryDirectory) with

underlying NTFS driver’s volume device object(VDO). I open the file
using
IoCreateFileSpecifyDeviceObjectHint with retrieved NTFS VDO to bypass
filters. It seemed working fine till I found FileMon and FileSpy both
reported strange results when running with Norton AV and Sophos AV
filters.

I issue IRP_MJ_DIRECTORY_CONTROL/IRP_MN_QUERY_DIRECTORY, and they report

IRP_MJ_CREATE, IRP_MJ_READ, FASTIO_QUERY_BASIC_INFO, etc. And I also
found
when i issueed my IRP, NtCreateFile and NtCreateSection were also
invoked. I
narrowed down the test scenario, but there were still a bunch of Major
IRPs
and FASTIOs. Using IrpTracker, I found norton antivirus is involved with

this IRP flows. In conclusion, both AV service process in the background
and
the original user process accessing files participated in sending these
IRPs
to get the file information and scan the file.

My question is, ‘How does norton AV(as well as Sophos AV) filter driver
know
what I’m doing?’.
Interestingly enough, neither IoCreateFileSpecifyDeviceObjectHint() nor
ZwClose() triggered any AV IRP activities. It obviously happens for
IRP_MJ_DIRECTORY_CONTROL/IRP_MN_QUERY_DIRECTORY. Remember this IRP is
not
caught by FileMon and FileSpy. This just create another IRP dispatches
by AV
because AV detects my attempt to enumerate the directory. The only
possibility they could detect my file access may be through
IrpCompletion
routine. Because IrpCompletion routines are invoked for every filter
drivers, AV filter drivers would have seen my IRP’s existence even
though
they couldn’t see it in IRP population stage along the filter stack.

Is my analysis plausible? If so, can someone tell me how to avoid using
completion routine in my driver? Or any other thoughts? I have to avoid

unnecessary interference with AVs for performance reasons.

Many thanks.

Kind Regards,
Sean


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@pctools.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Thanks for your quick reply, L.

I tried not calling ZwClose() after query_directory. The situation didn’t change.

Regards,
Sean


From: xxxxx@lists.osr.com on behalf of Ladislav Zezula
Sent: Thu 1/12/2006 6:40 PM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] AV knows what I do even when I access underlying NTFS directly.

They can’t back-trace for ZwClose(). However, IRP_MJ_CLEANUP and
IRP_MJ_CLOSE for this customized IRP won’t be directed to intermediate
filter drivers because it checks VPB of the FileObject and sends to the
correct VDO, which is underlying base file system VDO.

I am afraid CLEANUP and CLOSE will be sent through the whole
filter stack. Can’t this be the reason ? Does FileSpy catch some CLEANUPs
without appropriate CREATE ?

L.


Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@pctools.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

> My question is, 'How does norton AV(as well as Sophos AV) filter driver

know what I’m doing?'.
Have you ever considered that the AVs you are talking about steal the
MajorFunction entries of the driver object, i.e. “detour” them?!

This is a quite safe procedure compared with other hooking techniques and
would allow for the described behavior.

You can easily verify this by comparing the function pointers for the
MajorFunction entries with the boundaries of all kernel modules. However,
standard values are not 0, as far as I know, but some pointer into NTOSKRNL
or somewhere else - being the “default handler” routine.

Cheers,

Oliver

May the source be with you, stranger :wink:

ICQ: #281645
URL: http://assarbad.net

If filesystem is NTFS then sure the handler address should be inside
ntfs.sys so lm mntfs in windbag is a friend …

“Oliver Schneider” wrote in message
news:xxxxx@ntfsd…
>> My question is, ‘How does norton AV(as well as Sophos AV) filter driver
>> know what I’m doing?’.
> Have you ever considered that the AVs you are talking about steal the
> MajorFunction entries of the driver object, i.e. “detour” them?!
>
> This is a quite safe procedure compared with other hooking techniques and
> would allow for the described behavior.
>
> You can easily verify this by comparing the function pointers for the
> MajorFunction entries with the boundaries of all kernel modules. However,
> standard values are not 0, as far as I know, but some pointer into
> NTOSKRNL
> or somewhere else - being the “default handler” routine.
>
> Cheers,
>
> Oliver
>
> –
> ---------------------------------------------------
> May the source be with you, stranger :wink:
>
> ICQ: #281645
> URL: http://assarbad.net
>
>

My tool shows the following major function + FastI/O dispatch
entrypoints.
As you can see, nt kernel is also tightly coupled with NTFS driver.

[1204] Ntfs.sys (bace6e37) IRP_MJ_CREATE
[1204] ntoskrnl.exe (804f4282) IRP_MJ_CREATE_NAMED_PIPE
[1204] Ntfs.sys (bace6320) IRP_MJ_CLOSE
[1204] Ntfs.sys (bacc3ee4) IRP_MJ_READ
[1204] Ntfs.sys (bacc2bca) IRP_MJ_WRITE
[1204] Ntfs.sys (bace74d1) IRP_MJ_QUERY_INFORMATION
[1204] Ntfs.sys (bacc4a58) IRP_MJ_SET_INFORMATION
[1204] Ntfs.sys (bace74d1) IRP_MJ_QUERY_EA
[1204] Ntfs.sys (bace74d1) IRP_MJ_SET_EA
[1204] Ntfs.sys (baceca68) IRP_MJ_FLUSH_BUFFERS
[1204] Ntfs.sys (bace761c) IRP_MJ_QUERY_VOLUME_INFORMATION
[1204] Ntfs.sys (bace761c) IRP_MJ_SET_VOLUME_INFORMATION
[1204] Ntfs.sys (bace92c3) IRP_MJ_DIRECTORY_CONTROL
[1204] Ntfs.sys (bacee6d5) IRP_MJ_FILE_SYSTEM_CONTROL
[1204] Ntfs.sys (bace761c) IRP_MJ_DEVICE_CONTROL
[1204] ntoskrnl.exe (804f4282) IRP_MJ_INTERNAL_DEVICE_CONTROL
[1204] Ntfs.sys (bacd5621) IRP_MJ_SHUTDOWN
[1204] Ntfs.sys (bad3ab11) IRP_MJ_LOCK_CONTROL
[1204] Ntfs.sys (bace6cee) IRP_MJ_CLEANUP
[1204] ntoskrnl.exe (804f4282) IRP_MJ_CREATE_MAILSLOT
[1204] Ntfs.sys (bace761c) IRP_MJ_QUERY_SECURITY
[1204] Ntfs.sys (bace761c) IRP_MJ_SET_SECURITY
[1204] ntoskrnl.exe (804f4282) IRP_MJ_POWER
[1204] ntoskrnl.exe (804f4282) IRP_MJ_SYSTEM_CONTROL
[1204] ntoskrnl.exe (804f4282) IRP_MJ_DEVICE_CHANGE
[1204] Ntfs.sys (bace74d1) IRP_MJ_QUERY_QUOTA
[1204] Ntfs.sys (bace74d1) IRP_MJ_SET_QUOTA
[1204] Ntfs.sys (bad05f3f) IRP_MJ_PNP

[1204] Ntfs.sys (bacfd5ac) FastIoCheckIfPossible
[1204] Ntfs.sys (bace1b85) FastIoRead
[1204] Ntfs.sys (baced097) FastIoWrite
[1204] Ntfs.sys (bace621a) FastIoQueryBasicInfo
[1204] Ntfs.sys (bace60ae) FastIoQueryStandardInfo
[1204] Ntfs.sys (baceda4d) FastIoLock
[1204] Ntfs.sys (bacedb53) FastIoUnlockSingle
[1204] Ntfs.sys (bad3a71c) FastIoUnlockAll
[1204] Ntfs.sys (bad3a861) FastIoUnlockAllByKey
[1204] (0) FastIoDeviceControl
[1204] Ntfs.sys (bace18ba) AcquireFileForNtCreateSection
[1204] Ntfs.sys (bace1901) ReleaseFileForNtCreateSection
[1204] (0) FastIoDetachDevice
[1204] Ntfs.sys (bad28e89) FastIoQueryNetworkOpenInfo
[1204] Ntfs.sys (baced855) AcquireForModWrite
[1204] Ntfs.sys (bad28f9d) MdlRead
[1204] ntoskrnl.exe (804e89c6) MdlReadComplete
[1204] Ntfs.sys (bad29317) PrepareMdlWrite
[1204] ntoskrnl.exe (8056aba4) MdlWriteComplete
[1204] (0) FastIoReadCompressed
[1204] (0) FastIoWriteCompressed
[1204] (0) MdlReadCompleteCompressed
[1204] (0) MdlWriteCompleteCompressed
[1204] Ntfs.sys (bace5ee8) FastIoQueryOpen
[1204] (0) ReleaseForModWrite
[1204] Ntfs.sys (bace1762) AcquireForCcFlush
[1204] Ntfs.sys (bace1788) ReleaseForCcFlush

Also the file system stack snapshot shows the following two for every
VDOs (for every drives):

\FileSystem\Ntfs
\Driver\SymEvent

SymEvent is Symantec filter driver and its Major and Fast I/O dispatch
entrypoints point to its own memory image.

In conclusion Norton doesn’t do any sort of He4Hook-style IRP hooking
although there is a possibility that it is doing shadow-walking style
virtual memory page hooking. So how come it still knows what I did last
night? (kind of spooky :))

One interesting fact is IRP_MJ_CREATE IRPs are generated for only PE
files (EXE,DLL) and HTMLs when I do QUERY_DIRETORY on a directory. And
NtCreateFile and NtCreateSection are invoked right after I do
QUERY_DIRECTORY for each of those files (I set ReturnSingleEntry bit),
which implicates Norton detects whenever my file access on the spot
instead of scanning the whole folder.

So that’s why I am suspicious of my QueryDirectoryFile() function that I
sent in the previous email.

Any ideas?

Cheers,

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Lyndon J Clarke
Sent: Thursday, 12 January 2006 11:18 PM
To: Windows File Systems Devs Interest List
Subject: Re:[ntfsd] AV knows what I do even when I access underlying
NTFS directly.

If filesystem is NTFS then sure the handler address should be inside
ntfs.sys so lm mntfs in windbag is a friend …

“Oliver Schneider” wrote in message
news:xxxxx@ntfsd…
>> My question is, ‘How does norton AV(as well as Sophos AV) filter
driver
>> know what I’m doing?’.
> Have you ever considered that the AVs you are talking about steal the
> MajorFunction entries of the driver object, i.e. “detour” them?!
>
> This is a quite safe procedure compared with other hooking techniques
and
> would allow for the described behavior.
>
> You can easily verify this by comparing the function pointers for the
> MajorFunction entries with the boundaries of all kernel modules.
However,
> standard values are not 0, as far as I know, but some pointer into
> NTOSKRNL
> or somewhere else - being the “default handler” routine.
>
> Cheers,
>
> Oliver
>
> –
> ---------------------------------------------------
> May the source be with you, stranger :wink:
>
> ICQ: #281645
> URL: http://assarbad.net
>
>


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@pctools.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

I can safely say that Norton does NOT implement any ShadowWalker style of
memory page hiding, guaranteed. Looking through their binaries, they are not
nearly this ‘sophisticated’.

I would simply walk down the stack in the debugger to see where the IRP is
actually going. When you send it down, step into the IoCallDriver() call and
you will be quickly put into the driver that is handling it.

Pete

Kernel Drivers
Windows Filesystem and Device Driver Consulting
www.KernelDrivers.com
(303)546-0300

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Sean Park
Sent: Thursday, January 12, 2006 4:11 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] AV knows what I do even when I access underlying NTFS
directly.

My tool shows the following major function + FastI/O dispatch
entrypoints.
As you can see, nt kernel is also tightly coupled with NTFS driver.

[1204] Ntfs.sys (bace6e37) IRP_MJ_CREATE
[1204] ntoskrnl.exe (804f4282) IRP_MJ_CREATE_NAMED_PIPE
[1204] Ntfs.sys (bace6320) IRP_MJ_CLOSE
[1204] Ntfs.sys (bacc3ee4) IRP_MJ_READ
[1204] Ntfs.sys (bacc2bca) IRP_MJ_WRITE
[1204] Ntfs.sys (bace74d1) IRP_MJ_QUERY_INFORMATION
[1204] Ntfs.sys (bacc4a58) IRP_MJ_SET_INFORMATION
[1204] Ntfs.sys (bace74d1) IRP_MJ_QUERY_EA
[1204] Ntfs.sys (bace74d1) IRP_MJ_SET_EA
[1204] Ntfs.sys (baceca68) IRP_MJ_FLUSH_BUFFERS
[1204] Ntfs.sys (bace761c) IRP_MJ_QUERY_VOLUME_INFORMATION
[1204] Ntfs.sys (bace761c) IRP_MJ_SET_VOLUME_INFORMATION
[1204] Ntfs.sys (bace92c3) IRP_MJ_DIRECTORY_CONTROL
[1204] Ntfs.sys (bacee6d5) IRP_MJ_FILE_SYSTEM_CONTROL
[1204] Ntfs.sys (bace761c) IRP_MJ_DEVICE_CONTROL
[1204] ntoskrnl.exe (804f4282) IRP_MJ_INTERNAL_DEVICE_CONTROL
[1204] Ntfs.sys (bacd5621) IRP_MJ_SHUTDOWN
[1204] Ntfs.sys (bad3ab11) IRP_MJ_LOCK_CONTROL
[1204] Ntfs.sys (bace6cee) IRP_MJ_CLEANUP
[1204] ntoskrnl.exe (804f4282) IRP_MJ_CREATE_MAILSLOT
[1204] Ntfs.sys (bace761c) IRP_MJ_QUERY_SECURITY
[1204] Ntfs.sys (bace761c) IRP_MJ_SET_SECURITY
[1204] ntoskrnl.exe (804f4282) IRP_MJ_POWER
[1204] ntoskrnl.exe (804f4282) IRP_MJ_SYSTEM_CONTROL
[1204] ntoskrnl.exe (804f4282) IRP_MJ_DEVICE_CHANGE
[1204] Ntfs.sys (bace74d1) IRP_MJ_QUERY_QUOTA
[1204] Ntfs.sys (bace74d1) IRP_MJ_SET_QUOTA
[1204] Ntfs.sys (bad05f3f) IRP_MJ_PNP

[1204] Ntfs.sys (bacfd5ac) FastIoCheckIfPossible
[1204] Ntfs.sys (bace1b85) FastIoRead
[1204] Ntfs.sys (baced097) FastIoWrite
[1204] Ntfs.sys (bace621a) FastIoQueryBasicInfo
[1204] Ntfs.sys (bace60ae) FastIoQueryStandardInfo
[1204] Ntfs.sys (baceda4d) FastIoLock
[1204] Ntfs.sys (bacedb53) FastIoUnlockSingle
[1204] Ntfs.sys (bad3a71c) FastIoUnlockAll
[1204] Ntfs.sys (bad3a861) FastIoUnlockAllByKey
[1204] (0) FastIoDeviceControl
[1204] Ntfs.sys (bace18ba) AcquireFileForNtCreateSection
[1204] Ntfs.sys (bace1901) ReleaseFileForNtCreateSection
[1204] (0) FastIoDetachDevice
[1204] Ntfs.sys (bad28e89) FastIoQueryNetworkOpenInfo
[1204] Ntfs.sys (baced855) AcquireForModWrite
[1204] Ntfs.sys (bad28f9d) MdlRead
[1204] ntoskrnl.exe (804e89c6) MdlReadComplete
[1204] Ntfs.sys (bad29317) PrepareMdlWrite
[1204] ntoskrnl.exe (8056aba4) MdlWriteComplete
[1204] (0) FastIoReadCompressed
[1204] (0) FastIoWriteCompressed
[1204] (0) MdlReadCompleteCompressed
[1204] (0) MdlWriteCompleteCompressed
[1204] Ntfs.sys (bace5ee8) FastIoQueryOpen
[1204] (0) ReleaseForModWrite
[1204] Ntfs.sys (bace1762) AcquireForCcFlush
[1204] Ntfs.sys (bace1788) ReleaseForCcFlush

Also the file system stack snapshot shows the following two for every
VDOs (for every drives):

\FileSystem\Ntfs
\Driver\SymEvent

SymEvent is Symantec filter driver and its Major and Fast I/O dispatch
entrypoints point to its own memory image.

In conclusion Norton doesn’t do any sort of He4Hook-style IRP hooking
although there is a possibility that it is doing shadow-walking style
virtual memory page hooking. So how come it still knows what I did last
night? (kind of spooky :))

One interesting fact is IRP_MJ_CREATE IRPs are generated for only PE
files (EXE,DLL) and HTMLs when I do QUERY_DIRETORY on a directory. And
NtCreateFile and NtCreateSection are invoked right after I do
QUERY_DIRECTORY for each of those files (I set ReturnSingleEntry bit),
which implicates Norton detects whenever my file access on the spot
instead of scanning the whole folder.

So that’s why I am suspicious of my QueryDirectoryFile() function that I
sent in the previous email.

Any ideas?

Cheers,

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Lyndon J Clarke
Sent: Thursday, 12 January 2006 11:18 PM
To: Windows File Systems Devs Interest List
Subject: Re:[ntfsd] AV knows what I do even when I access underlying
NTFS directly.

If filesystem is NTFS then sure the handler address should be inside
ntfs.sys so lm mntfs in windbag is a friend …

“Oliver Schneider” wrote in message
news:xxxxx@ntfsd…
>> My question is, ‘How does norton AV(as well as Sophos AV) filter
driver
>> know what I’m doing?’.
> Have you ever considered that the AVs you are talking about steal the
> MajorFunction entries of the driver object, i.e. “detour” them?!
>
> This is a quite safe procedure compared with other hooking techniques
and
> would allow for the described behavior.
>
> You can easily verify this by comparing the function pointers for the
> MajorFunction entries with the boundaries of all kernel modules.
However,
> standard values are not 0, as far as I know, but some pointer into
> NTOSKRNL
> or somewhere else - being the “default handler” routine.
>
> Cheers,
>
> Oliver
>
> –
> ---------------------------------------------------
> May the source be with you, stranger :wink:
>
> ICQ: #281645
> URL: http://assarbad.net
>
>


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@pctools.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Thanks for the reply, Pete.

I set a breakpoint in IRP_DIRECTY_CONTROL handler in NTFS. When it is
hit, the stack trace shows my QueryDirectoryFile() is right below the
NTFS handler and NTFS handler is on top. So I concluded this is not the
reason.

I actually kind of thought filesystem callbacks (those registered using
FsRtlRegisterFileSystemFilterCallbacks) might be the nasty little
functions that informed those AV filters of what I’m doing. However, it
seems like those callbacks are not invoked in my situation. It looks
like they have more to do with memory manager and cache manager.

It’s always difficult to find out the traitor.
I’m really stuck at this stage. Any help would be greatly appreciated.

Cheers,

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Peter Scott
Sent: Friday, 13 January 2006 11:43 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] AV knows what I do even when I access underlying
NTFS directly.

I can safely say that Norton does NOT implement any ShadowWalker style
of
memory page hiding, guaranteed. Looking through their binaries, they are
not
nearly this ‘sophisticated’.

I would simply walk down the stack in the debugger to see where the IRP
is
actually going. When you send it down, step into the IoCallDriver() call
and
you will be quickly put into the driver that is handling it.

Pete

Kernel Drivers
Windows Filesystem and Device Driver Consulting
www.KernelDrivers.com
(303)546-0300

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Sean Park
Sent: Thursday, January 12, 2006 4:11 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] AV knows what I do even when I access underlying
NTFS
directly.

My tool shows the following major function + FastI/O dispatch
entrypoints.
As you can see, nt kernel is also tightly coupled with NTFS driver.

[1204] Ntfs.sys (bace6e37) IRP_MJ_CREATE
[1204] ntoskrnl.exe (804f4282) IRP_MJ_CREATE_NAMED_PIPE
[1204] Ntfs.sys (bace6320) IRP_MJ_CLOSE
[1204] Ntfs.sys (bacc3ee4) IRP_MJ_READ
[1204] Ntfs.sys (bacc2bca) IRP_MJ_WRITE
[1204] Ntfs.sys (bace74d1) IRP_MJ_QUERY_INFORMATION
[1204] Ntfs.sys (bacc4a58) IRP_MJ_SET_INFORMATION
[1204] Ntfs.sys (bace74d1) IRP_MJ_QUERY_EA
[1204] Ntfs.sys (bace74d1) IRP_MJ_SET_EA
[1204] Ntfs.sys (baceca68) IRP_MJ_FLUSH_BUFFERS
[1204] Ntfs.sys (bace761c) IRP_MJ_QUERY_VOLUME_INFORMATION
[1204] Ntfs.sys (bace761c) IRP_MJ_SET_VOLUME_INFORMATION
[1204] Ntfs.sys (bace92c3) IRP_MJ_DIRECTORY_CONTROL
[1204] Ntfs.sys (bacee6d5) IRP_MJ_FILE_SYSTEM_CONTROL
[1204] Ntfs.sys (bace761c) IRP_MJ_DEVICE_CONTROL
[1204] ntoskrnl.exe (804f4282) IRP_MJ_INTERNAL_DEVICE_CONTROL
[1204] Ntfs.sys (bacd5621) IRP_MJ_SHUTDOWN
[1204] Ntfs.sys (bad3ab11) IRP_MJ_LOCK_CONTROL
[1204] Ntfs.sys (bace6cee) IRP_MJ_CLEANUP
[1204] ntoskrnl.exe (804f4282) IRP_MJ_CREATE_MAILSLOT
[1204] Ntfs.sys (bace761c) IRP_MJ_QUERY_SECURITY
[1204] Ntfs.sys (bace761c) IRP_MJ_SET_SECURITY
[1204] ntoskrnl.exe (804f4282) IRP_MJ_POWER
[1204] ntoskrnl.exe (804f4282) IRP_MJ_SYSTEM_CONTROL
[1204] ntoskrnl.exe (804f4282) IRP_MJ_DEVICE_CHANGE
[1204] Ntfs.sys (bace74d1) IRP_MJ_QUERY_QUOTA
[1204] Ntfs.sys (bace74d1) IRP_MJ_SET_QUOTA
[1204] Ntfs.sys (bad05f3f) IRP_MJ_PNP

[1204] Ntfs.sys (bacfd5ac) FastIoCheckIfPossible
[1204] Ntfs.sys (bace1b85) FastIoRead
[1204] Ntfs.sys (baced097) FastIoWrite
[1204] Ntfs.sys (bace621a) FastIoQueryBasicInfo
[1204] Ntfs.sys (bace60ae) FastIoQueryStandardInfo
[1204] Ntfs.sys (baceda4d) FastIoLock
[1204] Ntfs.sys (bacedb53) FastIoUnlockSingle
[1204] Ntfs.sys (bad3a71c) FastIoUnlockAll
[1204] Ntfs.sys (bad3a861) FastIoUnlockAllByKey
[1204] (0) FastIoDeviceControl
[1204] Ntfs.sys (bace18ba) AcquireFileForNtCreateSection
[1204] Ntfs.sys (bace1901) ReleaseFileForNtCreateSection
[1204] (0) FastIoDetachDevice
[1204] Ntfs.sys (bad28e89) FastIoQueryNetworkOpenInfo
[1204] Ntfs.sys (baced855) AcquireForModWrite
[1204] Ntfs.sys (bad28f9d) MdlRead
[1204] ntoskrnl.exe (804e89c6) MdlReadComplete
[1204] Ntfs.sys (bad29317) PrepareMdlWrite
[1204] ntoskrnl.exe (8056aba4) MdlWriteComplete
[1204] (0) FastIoReadCompressed
[1204] (0) FastIoWriteCompressed
[1204] (0) MdlReadCompleteCompressed
[1204] (0) MdlWriteCompleteCompressed
[1204] Ntfs.sys (bace5ee8) FastIoQueryOpen
[1204] (0) ReleaseForModWrite
[1204] Ntfs.sys (bace1762) AcquireForCcFlush
[1204] Ntfs.sys (bace1788) ReleaseForCcFlush

Also the file system stack snapshot shows the following two for every
VDOs (for every drives):

\FileSystem\Ntfs
\Driver\SymEvent

SymEvent is Symantec filter driver and its Major and Fast I/O dispatch
entrypoints point to its own memory image.

In conclusion Norton doesn’t do any sort of He4Hook-style IRP hooking
although there is a possibility that it is doing shadow-walking style
virtual memory page hooking. So how come it still knows what I did last
night? (kind of spooky :))

One interesting fact is IRP_MJ_CREATE IRPs are generated for only PE
files (EXE,DLL) and HTMLs when I do QUERY_DIRETORY on a directory. And
NtCreateFile and NtCreateSection are invoked right after I do
QUERY_DIRECTORY for each of those files (I set ReturnSingleEntry bit),
which implicates Norton detects whenever my file access on the spot
instead of scanning the whole folder.

So that’s why I am suspicious of my QueryDirectoryFile() function that I
sent in the previous email.

Any ideas?

Cheers,

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Lyndon J Clarke
Sent: Thursday, 12 January 2006 11:18 PM
To: Windows File Systems Devs Interest List
Subject: Re:[ntfsd] AV knows what I do even when I access underlying
NTFS directly.

If filesystem is NTFS then sure the handler address should be inside
ntfs.sys so lm mntfs in windbag is a friend …

“Oliver Schneider” wrote in message
news:xxxxx@ntfsd…
>> My question is, ‘How does norton AV(as well as Sophos AV) filter
driver
>> know what I’m doing?’.
> Have you ever considered that the AVs you are talking about steal the
> MajorFunction entries of the driver object, i.e. “detour” them?!
>
> This is a quite safe procedure compared with other hooking techniques
and
> would allow for the described behavior.
>
> You can easily verify this by comparing the function pointers for the
> MajorFunction entries with the boundaries of all kernel modules.
However,
> standard values are not 0, as far as I know, but some pointer into
> NTOSKRNL
> or somewhere else - being the “default handler” routine.
>
> Cheers,
>
> Oliver
>
> –
> ---------------------------------------------------
> May the source be with you, stranger :wink:
>
> ICQ: #281645
> URL: http://assarbad.net
>
>


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@pctools.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@pctools.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

It seems that you will have to set breakpoint into the
AV’s entry point of CREATE, then invoke your directory
control code and try to see where the CREATE request
appears from.

L.

Hello,

May be you see result of “File Change Notification Callback”? Your
access modifies access time of file or directory and explorer or something
other that request change notification for directory rescan directory. So
this rescan IOs are visible to AV Hook.

If something used FindFirstChangeNotification() with suitable parameters
than many your IO like “IRP_MJ_CREATE”, “IRP_MJ_READ” and other will lead to
file activity from context of process that waited for file change
notifications. So at leat part of your optimization will go away. :slight_smile:

Good Luck,
Igor Arsenin


http://www.iarsn.com

“Sean Park” wrote in message news:xxxxx@ntfsd…
> Hi All,
>
> I’ve got an interesting but annoying situation. I’ve got a direct file
> system access kernel driver (not filter driver).
> What it does is simply create its own IRP(roll my own IRP) to access
> files(SetInformationFile, QueryInformationFile, and QueryDirectory) with
> underlying NTFS driver’s volume device object(VDO). I open the file using
> IoCreateFileSpecifyDeviceObjectHint with retrieved NTFS VDO to bypass
> filters. It seemed working fine till I found FileMon and FileSpy both
> reported strange results when running with Norton AV and Sophos AV
filters.
>
> I issue IRP_MJ_DIRECTORY_CONTROL/IRP_MN_QUERY_DIRECTORY, and they report
> IRP_MJ_CREATE, IRP_MJ_READ, FASTIO_QUERY_BASIC_INFO, etc. And I also found
> when i issueed my IRP, NtCreateFile and NtCreateSection were also invoked.
I
> narrowed down the test scenario, but there were still a bunch of Major
IRPs
> and FASTIOs. Using IrpTracker, I found norton antivirus is involved with
> this IRP flows. In conclusion, both AV service process in the background
and
> the original user process accessing files participated in sending these
IRPs
> to get the file information and scan the file.
>
> My question is, ‘How does norton AV(as well as Sophos AV) filter driver
know
> what I’m doing?’.
> Interestingly enough, neither IoCreateFileSpecifyDeviceObjectHint() nor
> ZwClose() triggered any AV IRP activities. It obviously happens for
> IRP_MJ_DIRECTORY_CONTROL/IRP_MN_QUERY_DIRECTORY. Remember this IRP is not
> caught by FileMon and FileSpy. This just create another IRP dispatches by
AV
> because AV detects my attempt to enumerate the directory. The only
> possibility they could detect my file access may be through IrpCompletion
> routine. Because IrpCompletion routines are invoked for every filter
> drivers, AV filter drivers would have seen my IRP’s existence even though
> they couldn’t see it in IRP population stage along the filter stack.
>
> Is my analysis plausible? If so, can someone tell me how to avoid using
> completion routine in my driver? Or any other thoughts? I have to avoid
> unnecessary interference with AVs for performance reasons.
>
> Many thanks.
>
>
> Kind Regards,
> Sean
>
>
>

This actually sounded like the real reason that caused all this trouble.
I turned off last access time update in the registry, rebooted, and I
confirmed last access time didn’t change when I opened a file or directory.
Now AV doesn’t know what I’m doing!!!

Thanks a lot, Igor!!!

So it turns out AV sets up some kind of directory change notification even
on “last access time change”. Unless you disable LastAccessTimeUpdate in the
registry, this will happen. Would it be harmful to turn this setting off in
some applications or drivers? Guys, what do you think?

Cheers,

“Igor Arsenin” wrote in message
news:xxxxx@ntfsd…
> Hello,
>
> May be you see result of “File Change Notification Callback”? Your
> access modifies access time of file or directory and explorer or something
> other that request change notification for directory rescan directory. So
> this rescan IOs are visible to AV Hook.
>
> If something used FindFirstChangeNotification() with suitable
> parameters
> than many your IO like “IRP_MJ_CREATE”, “IRP_MJ_READ” and other will lead
> to
> file activity from context of process that waited for file change
> notifications. So at leat part of your optimization will go away. :slight_smile:
>
> Good Luck,
> Igor Arsenin
>
> -------------------------------------------------------
> http://www.iarsn.com
>
> “Sean Park” wrote in message news:xxxxx@ntfsd…
>> Hi All,
>>
>> I’ve got an interesting but annoying situation. I’ve got a direct file
>> system access kernel driver (not filter driver).
>> What it does is simply create its own IRP(roll my own IRP) to access
>> files(SetInformationFile, QueryInformationFile, and QueryDirectory) with
>> underlying NTFS driver’s volume device object(VDO). I open the file using
>> IoCreateFileSpecifyDeviceObjectHint with retrieved NTFS VDO to bypass
>> filters. It seemed working fine till I found FileMon and FileSpy both
>> reported strange results when running with Norton AV and Sophos AV
> filters.
>>
>> I issue IRP_MJ_DIRECTORY_CONTROL/IRP_MN_QUERY_DIRECTORY, and they report
>> IRP_MJ_CREATE, IRP_MJ_READ, FASTIO_QUERY_BASIC_INFO, etc. And I also
>> found
>> when i issueed my IRP, NtCreateFile and NtCreateSection were also
>> invoked.
> I
>> narrowed down the test scenario, but there were still a bunch of Major
> IRPs
>> and FASTIOs. Using IrpTracker, I found norton antivirus is involved with
>> this IRP flows. In conclusion, both AV service process in the background
> and
>> the original user process accessing files participated in sending these
> IRPs
>> to get the file information and scan the file.
>>
>> My question is, ‘How does norton AV(as well as Sophos AV) filter driver
> know
>> what I’m doing?’.
>> Interestingly enough, neither IoCreateFileSpecifyDeviceObjectHint() nor
>> ZwClose() triggered any AV IRP activities. It obviously happens for
>> IRP_MJ_DIRECTORY_CONTROL/IRP_MN_QUERY_DIRECTORY. Remember this IRP is not
>> caught by FileMon and FileSpy. This just create another IRP dispatches by
> AV
>> because AV detects my attempt to enumerate the directory. The only
>> possibility they could detect my file access may be through IrpCompletion
>> routine. Because IrpCompletion routines are invoked for every filter
>> drivers, AV filter drivers would have seen my IRP’s existence even though
>> they couldn’t see it in IRP population stage along the filter stack.
>>
>> Is my analysis plausible? If so, can someone tell me how to avoid using
>> completion routine in my driver? Or any other thoughts? I have to avoid
>> unnecessary interference with AVs for performance reasons.
>>
>> Many thanks.
>>
>>
>> Kind Regards,
>> Sean
>>
>>
>>
>
>
>

Most backups rely on last access time to decide whether or not to include the
file in the current backup.
The archive bit is also used, but it is not autoset always.

Sean Park wrote:

This actually sounded like the real reason that caused all this trouble.
I turned off last access time update in the registry, rebooted, and I
confirmed last access time didn’t change when I opened a file or directory.
Now AV doesn’t know what I’m doing!!!

Thanks a lot, Igor!!!

So it turns out AV sets up some kind of directory change notification even
on “last access time change”. Unless you disable LastAccessTimeUpdate in the
registry, this will happen. Would it be harmful to turn this setting off in
some applications or drivers? Guys, what do you think?


Kind regards, Dejan M.
http://www.alfasp.com E-mail: xxxxx@alfasp.com
Alfa Transparent File Encryptor - Transparent file encryption services.
Alfa File Protector - File protection and hiding library for Win32 developers.
Alfa File Monitor - File monitoring library for Win32 developers.

Backups use modification time really.

Access time is used by disk defragmenters to place files according last
time accessed. See Norton products for example.

Disabling it leads to higher performance of file system on “Read
Operations”.

Still when you will modify your files you will have the same problem as
before. May be you need not disable LastAccessTimeUpdate but simply close
all Explorer, FAR and other browser windows that see on Directories of your
attention. Most probably not AV request notifications but Windows Explorer
or other application with similar functionality. When something modified
Explorer tries to refresh Directory View (File icons, sizes and so on). So
really this refresh activity is visible to AV.

Good Luck,
Igor Arsenin

“Dejan Maksimovic” wrote in message news:xxxxx@ntfsd…
>
> Most backups rely on last access time to decide whether or not to
include the
> file in the current backup.
> The archive bit is also used, but it is not autoset always.
>
> Sean Park wrote:
>
> > This actually sounded like the real reason that caused all this trouble.
> > I turned off last access time update in the registry, rebooted, and I
> > confirmed last access time didn’t change when I opened a file or
directory.
> > Now AV doesn’t know what I’m doing!!!
> >
> > Thanks a lot, Igor!!!
> >
> > So it turns out AV sets up some kind of directory change notification
even
> > on “last access time change”. Unless you disable LastAccessTimeUpdate in
the
> > registry, this will happen. Would it be harmful to turn this setting off
in
> > some applications or drivers? Guys, what do you think?
>
> –
> Kind regards, Dejan M.
> http://www.alfasp.com E-mail: xxxxx@alfasp.com
> Alfa Transparent File Encryptor - Transparent file encryption services.
> Alfa File Protector - File protection and hiding library for Win32
developers.
> Alfa File Monitor - File monitoring library for Win32 developers.
>
>
>
>