不多废话, 下面是dump文件信息:
Microsoft (R) Windows Debugger Version 6.11.0001.404 X86
Copyright (c) Microsoft Corporation. All rights reserved.
Loading Dump File [C:\Users\Administrator\Desktop\Driver-Tools-admin\Dump\ysy-2014-01-06.dmp]
Mini Kernel Dump File: Only registers and stack trace are available
Symbol search path is: srv*F:\Driver-Debug\NtSymbol*http://msdl.microsoft.com/download/symbols;C:\Users\Administrator\Desktop\Driver-Tools-admin\Sys
Executable search path is: C:\Users\Administrator\Desktop\Driver-Tools-admin\Sys
Windows 7 Kernel Version 7601 (Service Pack 1) MP (4 procs) Free x86 compatible
Product: WinNt, suite: TerminalServer SingleUserTS
Built by: 7601.17514.x86fre.win7sp1_rtm.101119-1850
Machine Name:
Kernel base = 0x8400b000 PsLoadedModuleList = 0x84155850
Debug session time: Mon Jan 6 14:42:18.948 2014 (GMT+8)
System Uptime: 0 days 6:18:30.337
Loading Kernel Symbols
...............................................................
................................................................
.........
Loading User Symbols
Loading unloaded module list
..........
2: kd> !analyze -v
*******************************************************************************
* *
* Bugcheck Analysis *
* *
*******************************************************************************
PAGE_FAULT_IN_NONPAGED_AREA (50)
Invalid system memory was referenced. This cannot be protected by try-except,
it must be protected by a Probe. Typically the address is just plain bad or it
is pointing at freed memory.
Arguments:
Arg1: ce93d000, memory referenced.
Arg2: 00000001, value 0 = read operation, 1 = write operation.
Arg3: 840447f3, If non-zero, the instruction address which referenced the bad memory
address.
Arg4: 00000000, (reserved)
Debugging Details:
------------------
Unable to load image \??\C:\Windows\System32\drivers\Yb_Process.sys, Win32 error 0n2
*** WARNING: Unable to verify timestamp for Yb_Process.sys
*** WARNING: Unable to verify timestamp for TSKsp.sys
*** ERROR: Module load completed but symbols could not be loaded for TSKsp.sys
*** WARNING: Unable to verify timestamp for TsFltMgr.sys
*** ERROR: Module load completed but symbols could not be loaded for TsFltMgr.sys
WRITE_ADDRESS: GetPointerFromAddress: unable to read from 84175718
Unable to read MiSystemVaType memory at 841551a0
ce93d000
FAULTING_IP:
nt!memcpy+33
840447f3 f3a5 rep movs dword ptr es:[edi],dword ptr [esi]
MM_INTERNAL_CODE: 0
CUSTOMER_CRASH_COUNT: 6
DEFAULT_BUCKET_ID: COMMON_SYSTEM_FAULT
BUGCHECK_STR: 0x50
PROCESS_NAME: YBOSProtect.ex
CURRENT_IRQL: 0
TRAP_FRAME: a1891964 -- (.trap 0xffffffffa1891964)
ErrCode = 00000002
eax=892e85dc ebx=00000000 ecx=00000048 edx=00000000 esi=892e84bc edi=ce93d000
eip=840447f3 esp=a18919d8 ebp=a18919e0 iopl=0 nv up ei pl nz ac po nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00010212
nt!memcpy+0x33:
840447f3 f3a5 rep movs dword ptr es:[edi],dword ptr [esi]
Resetting default scope
LAST_CONTROL_TRANSFER: from 8404c3d8 to 8409941b
STACK_TEXT:
a189194c 8404c3d8 00000001 ce93d000 00000000 nt!MmAccessFault+0x106
a189194c 840447f3 00000001 ce93d000 00000000 nt!KiTrap0E+0xdc
a18919e0 a139cc46 ce93ce04 892e82c0 0000031c nt!memcpy+0x33
a1891a28 a139d3c6 8990e350 87657190 ce924000 Yb_Process!SfGetCurrentProcFile+0x1f6 [e:\ybworkspace\example\watchprocess\driverprocess\driverprocess.c @ 1363]
a1891a60 84042593 8990e350 87657190 87657190 Yb_Process!SfSetInterestFile+0x226 [e:\ybworkspace\example\watchprocess\driverprocess\driverprocess.c @ 1681]
a1891a78 8423699f 875d1878 87657190 87657200 nt!IofCallDriver+0x63
a1891a98 84239b71 8990e350 875d1878 00000000 nt!IopSynchronousServiceTail+0x1f8
a1891b34 842803f4 8990e350 87657190 00000000 nt!IopXxxControlFile+0x6aa
a1891b68 939b6a46 000002c8 00000000 00000000 nt!NtDeviceIoControlFile+0x2a
WARNING: Stack unwind information not available. Following frames may be wrong.
a1891bb0 8d53ff4e 000002c8 00000000 00000000 TSKsp+0x14a46
a1891c04 840491ea 000002c8 00000000 00000000 TsFltMgr+0x4f4e
a1891c04 778870b4 000002c8 00000000 00000000 nt!KiFastCallEntry+0x12a
01c1c618 00000000 00000000 00000000 00000000 0x778870b4
STACK_COMMAND: kb
FOLLOWUP_IP:
Yb_Process!SfGetCurrentProcFile+1f6 [e:\ybworkspace\example\watchprocess\driverprocess\driverprocess.c @ 1363]
a139cc46 ?? ???
FAULTING_SOURCE_CODE:
1359:
1360: IoCompleteRequest(pIrp, IO_NO_INCREMENT);
1361:
1362: return STATUS_SUCCESS;
> 1363: }
1364:
1365: NTSTATUS
1366: SfGetCurrentProcSection(PDEVICE_OBJECT DeviceObject, PIRP pIrp, PVOID pIoBuffer)
1367: {
1368: ULONG i = 0;
SYMBOL_STACK_INDEX: 3
SYMBOL_NAME: Yb_Process!SfGetCurrentProcFile+1f6
FOLLOWUP_NAME: MachineOwner
MODULE_NAME: Yb_Process
IMAGE_NAME: Yb_Process.sys
DEBUG_FLR_IMAGE_TIMESTAMP: 52c7617c
FAILURE_BUCKET_ID: 0x50_Yb_Process!SfGetCurrentProcFile+1f6
BUCKET_ID: 0x50_Yb_Process!SfGetCurrentProcFile+1f6
Followup: MachineOwner
---------
对应的SfGetCurrentProcFile的源码如下:
NTSTATUS
SfGetCurrentProcFile(PDEVICE_OBJECT DeviceObject, PIRP pIrp, PVOID pIoBuffer)
{
ULONG i = 0;
ULONG r = 0;
PUSER_FILE_DATA pUserFileData = (PUSER_FILE_DATA)pIoBuffer;
POP_FILE_SET_NODE pNode = g_p_opened_file_list->NodeHead;
PFILE_DATA_NODE pNodeFileData = NULL;
PCHAR pTempo = NULL;
__try
{
// 拷贝驱动层监控数据到上层数据缓存区
while (pNode != NULL)
{
pNodeFileData = pNode->FileOPSet.FileDataList.NodeHead;
while (pNodeFileData != NULL)
{
pTempo = strrchr((CHAR*)pNodeFileData->FileData.FilePath, '\\');
if (pTempo != NULL && (pTempo + 1) != NULL)
{
// "Office"系列软件会生成的临时文件不应该上传给上层
if (pTempo[1] == '~' && pTempo[2] == '$')
{
pNodeFileData = pNodeFileData->NodeNext;
continue;
}
}
// "Explore"打开的文件不应该上传给上层
// ...
// 已经上传的文件不用再次上传
if (pNodeFileData->FileData.Saved)
{
pNodeFileData = pNodeFileData->NodeNext;
continue;
}
// 置上传标志位
pNodeFileData->FileData.Saved = TRUE;
if (!MmIsAddressValid(pNodeFileData) ||
!MmIsAddressValid(&pUserFileData->FileObject[i]) ||
!MmIsAddressValid(&pNodeFileData->FileData))
{
DbgPrint(("YUBAN.FILEWATCH.DRIVER <<<<<< !SfGetCurrentProcFile ------ Check params is fails! ------ >>>>>>"));
goto Leave;
}
// 内存拷贝
RtlCopyMemory(&pUserFileData->FileObject[i], &pNodeFileData->FileData, sizeof(OP_FILE));
// 自增量
i++;
// 移向下一个数据节点
pNodeFileData = pNodeFileData->NodeNext;
r = r + sizeof(OP_FILE);
}
pNode = pNode->NodeNext;
}
pUserFileData->Count = i;
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
r = 0;
DbgPrint(("YUBAN.FILEWATCH.DRIVER <<<<<< !SfGetCurrentProcFile ------ Exception: Catch Error ------ >>>>>>"));
}
Leave:
pIrp->IoStatus.Status = STATUS_SUCCESS;
pIrp->IoStatus.Information = r;
IoCompleteRequest(pIrp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}
NTSTATUS
SfProcMonDispath(IN PDEVICE_OBJECT DeviceObject, IN PIRP pIrp)
{
PIO_STACK_LOCATION IrpStack;
PVOID InputBuffer;
PVOID OutputBuffer;
ULONG InputBufferLength;
ULONG OutputBufferLength;
ULONG IoControlCode;
PVOID pIoBuffer;
pIrp->IoStatus.Status = STATUS_SUCCESS;
pIrp->IoStatus.Information = 0;
IrpStack = IoGetCurrentIrpStackLocation(pIrp);
InputBuffer = pIrp->AssociatedIrp.SystemBuffer;
OutputBuffer = pIrp->AssociatedIrp.SystemBuffer;
InputBufferLength = IrpStack->Parameters.DeviceIoControl.InputBufferLength;
OutputBufferLength = IrpStack->Parameters.DeviceIoControl.OutputBufferLength;
IoControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode;
pIoBuffer = pIrp->AssociatedIrp.SystemBuffer;
switch (IrpStack->MajorFunction)
{
case IRP_MJ_DEVICE_CONTROL:
{
switch(IoControlCode)
{
case PROCDENY_PROCESS_MONITOR: // 取进程信息
{
// 取当前调用态
if (ExGetPreviousMode() == UserMode)
{
__try
{
// 判断用户态的对象是否可读
ProbeForRead(pIoBuffer, InputBufferLength, 1);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
DbgPrint(("YUBAN.FILEWATCH.DRIVER <<<<<< !PROCDENY_PROCESS_MONITOR ------ Exception: Pass It! ------ 0x%08x>>>>>>"), GetExceptionCode());
pIrp->IoStatus.Status = STATUS_SUCCESS;
pIrp->IoStatus.Information = 0;
IoCompleteRequest(pIrp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}
}
return SfGetCurrentProcSection(DeviceObject, pIrp, pIoBuffer);
}
case PROCDENY_FILE_MONITOR: // 取文件信息
{
// 取当前调用态
if (ExGetPreviousMode() == UserMode)
{
__try
{
// 判断用户态的对象是否可读
ProbeForRead(pIoBuffer, InputBufferLength, 1);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
DbgPrint(("YUBAN.FILEWATCH.DRIVER <<<<<< !PROCDENY_FILE_MONITOR ------ Exception: Pass It! ------ 0x%08x>>>>>>"), GetExceptionCode());
pIrp->IoStatus.Status = STATUS_SUCCESS;
pIrp->IoStatus.Information = 0;
IoCompleteRequest(pIrp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}
}
return SfGetCurrentProcFile(DeviceObject, pIrp, pIoBuffer);
}
case PROCDENY_PROCESS_FILTER: // 设置进程过滤列表
{
return SfSetProcessFilter(DeviceObject, pIrp, InputBuffer);
}
case PROCDENY_INTEREST_FILE: // 设置感兴趣的文件后缀名列表
{
return SfSetInterestFile(DeviceObject, pIrp, InputBuffer);
}
case PROCDENY_DENYPROCESS:
{
return SfDenyProcessMonter(DeviceObject, pIrp, pIoBuffer, InputBufferLength);
}
case PROCDENY_CANCELDENY:
{
return SfCancelProcessMonter(DeviceObject, pIrp, pIoBuffer);
}
case PROCDENY_PAUSE:
{
g_b_stop = TRUE; // 暂停
pIrp->IoStatus.Status = STATUS_SUCCESS;
pIrp->IoStatus.Information = 0;
DbgPrint(("YUBAN.FILEWATCH.DRIVER <<<<<< !PROCDENY_PAUSE ------ Set Pause! ------ >>>>>>"));
IoCompleteRequest(pIrp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}
case PROCDENY_RESUME: // 恢复
{
g_b_stop = FALSE;
pIrp->IoStatus.Status = STATUS_SUCCESS;
pIrp->IoStatus.Information = 0;
DbgPrint(("YUBAN.FILEWATCH.DRIVER <<<<<< !PROCDENY_PAUSE ------ Set Resume! ------ >>>>>>"));
IoCompleteRequest(pIrp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}
default:
{
break;
}
}
break;
}
case IRP_MJ_CREATE:
{
break;
}
case IRP_MJ_CLOSE:
{
DbgPrint(("YUBAN.FILEWATCH.DRIVER <<<<<< !SfProcMonDispath ------ Process is Closed ------ >>>>>>"));
break;
}
default:
{
break;
}
}
pIrp->IoStatus.Status = STATUS_SUCCESS;
pIrp->IoStatus.Information = 0;
IoCompleteRequest(pIrp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}
另外还有点很是疑惑, Yb_Process!SfSetInterestFile 这个我压根就没有在上层发Io消息, 怎么windbg分析出来, 它也在堆栈里?windbg 分析指向不明确, 找不到原因. 请高人分析下. 谢谢了.
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课
上传的附件: