📄 debug.c
字号:
/*
This is a romfs file system driver for Windows NT/2000/XP.
Copyright (C) 1999, 2000, 2001, 2002 Bo Brant閚.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "ntifs.h"
#include "fsd.h"
#if DBG
static PUCHAR IrpMjStrings[] = {
"CREATE",
"CREATE_NAMED_PIPE",
"CLOSE",
"READ",
"WRITE",
"QUERY_INFORMATION",
"SET_INFORMATION",
"QUERY_EA",
"SET_EA",
"FLUSH_BUFFERS",
"QUERY_VOLUME_INFORMATION",
"SET_VOLUME_INFORMATION",
"DIRECTORY_CONTROL",
"FILE_SYSTEM_CONTROL",
"DEVICE_CONTROL",
"INTERNAL_DEVICE_CONTROL",
"SHUTDOWN",
"LOCK_CONTROL",
"CLEANUP",
"CREATE_MAILSLOT",
"QUERY_SECURITY",
"SET_SECURITY",
"POWER",
"SYSTEM_CONTROL",
"DEVICE_CHANGE",
"QUERY_QUOTA",
"SET_QUOTA",
"PNP"
};
static PUCHAR FileInformationClassStrings[] = {
"Unknown FileInformationClass 0",
"Directory",
"FullDirectory",
"BothDirectory",
"Basic",
"Standard",
"Internal",
"Ea",
"Access",
"Name",
"Rename",
"Link",
"Names",
"Disposition",
"Position",
"FullEa",
"Mode",
"Alignment",
"All",
"Allocation",
"EndOfFile",
"AlternateName",
"Stream",
"Pipe",
"PipeLocal",
"PipeRemote",
"MailslotQuery",
"MailslotSet",
"Compression",
"ObjectId",
"Completion",
"MoveCluster",
"Quota",
"ReparsePoint",
"NetworkOpen",
"AttributeTag",
"Tracking",
"IdBothDirectory",
"IdFullDirectory",
"ValidDataLength",
"ShortName"
};
static PUCHAR FsInformationClassStrings[] = {
"Unknown FsInformationClass 0",
"Volume",
"Label",
"Size",
"Device",
"Attribute",
"Control",
"FullSize",
"ObjectId",
"DriverPath"
};
#define SYSTEM_PROCESS_NAME "System"
ULONG ProcessNameOffset;
ULONG
FsdGetProcessNameOffset (
VOID
)
{
PEPROCESS Process;
ULONG i;
Process = PsGetCurrentProcess();
for(i = 0; i < PAGE_SIZE; i++)
{
if(!strncmp(
SYSTEM_PROCESS_NAME,
(PCHAR) Process + i,
strlen(SYSTEM_PROCESS_NAME)
))
{
return i;
}
}
KdPrint((DRIVER_NAME ": *** FsdGetProcessNameOffset failed ***\n"));
return 0;
}
VOID
FsdDbgPrintCall (
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
)
{
PIO_STACK_LOCATION IrpSp;
PFILE_OBJECT FileObject;
PUCHAR FileName;
PFSD_FCB Fcb;
FILE_INFORMATION_CLASS FileInformationClass;
FS_INFORMATION_CLASS FsInformationClass;
IrpSp = IoGetCurrentIrpStackLocation(Irp);
FileObject = IrpSp->FileObject;
FileName = "Unknown";
if (DeviceObject == FsdGlobalData.DeviceObject)
{
FileName = "\\" DRIVER_NAME;
}
else if (FileObject && FileObject->FsContext)
{
Fcb = (PFSD_FCB) FileObject->FsContext;
if (Fcb->Identifier.Type == VCB)
{
FileName = "\\Volume";
}
else if (Fcb->Identifier.Type == FCB && Fcb->AnsiFileName.Buffer)
{
FileName = Fcb->AnsiFileName.Buffer;
}
}
switch (IrpSp->MajorFunction)
{
case IRP_MJ_CREATE:
FileName = NULL;
if (DeviceObject == FsdGlobalData.DeviceObject)
{
FileName = "\\" DRIVER_NAME;
}
else if (IrpSp->FileObject->FileName.Length == 0)
{
FileName = "\\Volume";
}
if (FileName)
{
DbgPrint(
DRIVER_NAME ": %-16.16s %-31s %s\n",
FsdGetCurrentProcessName(),
IrpMjStrings[IrpSp->MajorFunction],
FileName
);
}
else if (IrpSp->FileObject->FileName.Buffer)
{
DbgPrint(
DRIVER_NAME ": %-16.16s %-31s %S\n",
FsdGetCurrentProcessName(),
IrpMjStrings[IrpSp->MajorFunction],
IrpSp->FileObject->FileName.Buffer
);
}
else
{
DbgPrint(
DRIVER_NAME ": %-16.16s %-31s %s\n",
FsdGetCurrentProcessName(),
IrpMjStrings[IrpSp->MajorFunction],
"Unknown"
);
}
break;
case IRP_MJ_CLOSE:
DbgPrint(
DRIVER_NAME ": %-16.16s %-31s %s\n",
FsdGetCurrentProcessName(),
IrpMjStrings[IrpSp->MajorFunction],
FileName
);
break;
case IRP_MJ_READ:
if (IrpSp->MinorFunction & IRP_MN_COMPLETE)
{
DbgPrint(
DRIVER_NAME ": %-16.16s %-31s %s IRP_MN_COMPLETE\n",
FsdGetCurrentProcessName(),
IrpMjStrings[IrpSp->MajorFunction],
FileName
);
}
else
{
DbgPrint(
DRIVER_NAME ": %-16.16s %-31s %s\n",
FsdGetCurrentProcessName(),
IrpMjStrings[IrpSp->MajorFunction],
FileName
);
DbgPrint(
DRIVER_NAME ": %-16.16s Offset: %I64u Length: %u Key: %u %s%s%s%s%s%s\n",
FsdGetCurrentProcessName(),
IrpSp->Parameters.Read.ByteOffset.QuadPart,
IrpSp->Parameters.Read.Length,
IrpSp->Parameters.Read.Key,
(IrpSp->MinorFunction & IRP_MN_DPC ? "IRP_MN_DPC " : ""),
(IrpSp->MinorFunction & IRP_MN_MDL ? "IRP_MN_MDL " : ""),
(IrpSp->MinorFunction & IRP_MN_COMPRESSED ? "IRP_MN_COMPRESSED " : ""),
(Irp->Flags & IRP_PAGING_IO ? "IRP_PAGING_IO " : ""),
(Irp->Flags & IRP_NOCACHE ? "IRP_NOCACHE " : ""),
(FileObject->Flags & FO_SYNCHRONOUS_IO ? "FO_SYNCHRONOUS_IO " : "")
);
}
break;
case IRP_MJ_QUERY_INFORMATION:
FileInformationClass =
IrpSp->Parameters.QueryFile.FileInformationClass;
if (FileInformationClass <= FileMaximumInformation)
{
DbgPrint(
DRIVER_NAME ": %-16.16s %-31s %s %s\n",
FsdGetCurrentProcessName(),
IrpMjStrings[IrpSp->MajorFunction],
FileName,
FileInformationClassStrings[FileInformationClass]
);
}
else
{
DbgPrint(
DRIVER_NAME
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -