-
-
[求助]磁盘过滤时读裸盘失败。
-
发表于: 2012-9-27 11:43 3411
-
要做的是读取一个卷的第一个扇区,代码如下:
Status = CvfReadDevice(PhysicalDevice, BootSector, Offset, SECTOR_SIZE);
if (!NT_SUCCESS(Status))
{
KdPrint(("读取前512字节失败\n"));
gsRead512Failed++;
gsFailedReason = Status;
break;
}
其中 CvfReadDevice 是这样写的:
static
NTSTATUS
CvfReadWriteDevice(
__in BOOLEAN Write,
__in PDEVICE_OBJECT DeviceObject,
__inout PVOID Buffer,
__in LARGE_INTEGER Offset,
__in ULONG Length
)
{
NTSTATUS Status;
IO_STATUS_BLOCK IoStatusBlock;
PIRP Irp = NULL;
KEVENT CompletionEvent;
KeInitializeEvent(&CompletionEvent, NotificationEvent, FALSE);
Irp = IoBuildSynchronousFsdRequest(
Write ? IRP_MJ_WRITE : IRP_MJ_READ,
DeviceObject,
Buffer,
Length,
&Offset,
&CompletionEvent,
&IoStatusBlock
);
if (!Irp)
{
return STATUS_INSUFFICIENT_RESOURCES;
}
ObReferenceObject(DeviceObject);
Status = IoCallDriver(DeviceObject, Irp);
if (Status == STATUS_PENDING)
{
Status = KeWaitForSingleObject(&CompletionEvent, Executive, KernelMode, FALSE, NULL);
if (NT_SUCCESS(Status))
{
Status = IoStatusBlock.Status;
}
}
ObDereferenceObject(DeviceObject);
return Status;
}
NTSTATUS
CvfReadDevice(
__in PDEVICE_OBJECT DeviceObject,
__out PVOID Buffer,
__in LARGE_INTEGER Offset,
__in ULONG Length
)
{
return CvfReadWriteDevice(FALSE, DeviceObject, Buffer, Offset, Length);
}
在XP,WIN7和我另一台WIN764位虚拟机上都可以成功读取。
但在一台64位真实机上, CvfReadDevice 返回值是 0xc0000010
查了下DDK头文件,定义为:
//
// MessageId: ISCSI_ERR_INVALID_KEY_DURING_CHAP
//
// MessageText:
//
// An invalid key was received during CHAP negotiation. The key=value pair is given in the dump data.
//
#define ISCSI_ERR_INVALID_KEY_DURING_CHAP ((NTSTATUS)0xC0000010L)
完全不能理解,求高人指点这个错误是为什么,感激不尽。
Status = CvfReadDevice(PhysicalDevice, BootSector, Offset, SECTOR_SIZE);
if (!NT_SUCCESS(Status))
{
KdPrint(("读取前512字节失败\n"));
gsRead512Failed++;
gsFailedReason = Status;
break;
}
其中 CvfReadDevice 是这样写的:
static
NTSTATUS
CvfReadWriteDevice(
__in BOOLEAN Write,
__in PDEVICE_OBJECT DeviceObject,
__inout PVOID Buffer,
__in LARGE_INTEGER Offset,
__in ULONG Length
)
{
NTSTATUS Status;
IO_STATUS_BLOCK IoStatusBlock;
PIRP Irp = NULL;
KEVENT CompletionEvent;
KeInitializeEvent(&CompletionEvent, NotificationEvent, FALSE);
Irp = IoBuildSynchronousFsdRequest(
Write ? IRP_MJ_WRITE : IRP_MJ_READ,
DeviceObject,
Buffer,
Length,
&Offset,
&CompletionEvent,
&IoStatusBlock
);
if (!Irp)
{
return STATUS_INSUFFICIENT_RESOURCES;
}
ObReferenceObject(DeviceObject);
Status = IoCallDriver(DeviceObject, Irp);
if (Status == STATUS_PENDING)
{
Status = KeWaitForSingleObject(&CompletionEvent, Executive, KernelMode, FALSE, NULL);
if (NT_SUCCESS(Status))
{
Status = IoStatusBlock.Status;
}
}
ObDereferenceObject(DeviceObject);
return Status;
}
NTSTATUS
CvfReadDevice(
__in PDEVICE_OBJECT DeviceObject,
__out PVOID Buffer,
__in LARGE_INTEGER Offset,
__in ULONG Length
)
{
return CvfReadWriteDevice(FALSE, DeviceObject, Buffer, Offset, Length);
}
在XP,WIN7和我另一台WIN764位虚拟机上都可以成功读取。
但在一台64位真实机上, CvfReadDevice 返回值是 0xc0000010
查了下DDK头文件,定义为:
//
// MessageId: ISCSI_ERR_INVALID_KEY_DURING_CHAP
//
// MessageText:
//
// An invalid key was received during CHAP negotiation. The key=value pair is given in the dump data.
//
#define ISCSI_ERR_INVALID_KEY_DURING_CHAP ((NTSTATUS)0xC0000010L)
完全不能理解,求高人指点这个错误是为什么,感激不尽。
赞赏
他的文章
- [求助]求有经验的文件重定向驱动开发者帮助 6971
- [求助]AFD HOOK的问题 5129
- [求助]磁盘过滤时读裸盘失败。 3412
- [原创]只能写个贪食蛇的垃圾实力 7029
看原图
赞赏
雪币:
留言: