I want to printing all filename,when i intercept IRP_MJ_CREATE request in
my MySfCreate routine.
It’s work well,but when the current file is KERNEL.DLL the system crash.Who
can tell me this is why?
My MySfCreate routine code is below:
RtlInitUnicodeString( &sourceName, L"KERNEL32.DLL"); // For example
KERNEL.DLL or other system file
sprintf( chSourcePathName, “%ws”, sourceName.Buffer);
if ( savedFileObject->FileName.Buffer && !(savedFileObject->Flags &
FO_DIRECT_DEVICE_OPEN ) )
{
RtlCopyUnicodeString( &name, &savedFileObject->FileName);
sprintf(chDestPathName, “%ws”, (&name)->Buffer );
if ( strstr(chDestPathName, chSourcePathName) != NULL )
{
sprintf(pszTmp, “sfilter - SfCreate: File Name: %ws\n”, (&name)
->Buffer );
WriteToLine(pszTmp, strlen(pszTmp)); // print the current
filename to log file.
}
//
// Print all Creating or Openning filename
//
sprintf(pszTmp, “File Name: %ws\n”, (&name)->Buffer );
WriteToLine(pszTmp, strlen(pszTmp));
}
WriteToLine use ZwCreateFile,ZwWriteFile function to Create,Write log file.
When impletment ZwCreateFile,the system crash.
BugCheck code is UNEXPECTED_HERNEL_MODE_TRAP(0x00000008,
0x00000000,0x00000000,0x00000000)
Who can help me ?
Best Regards
Ken Wang