[求助]win7 应用层打开驱动设备失败(在XP。vista上面可用)
发表于:
2010-7-14 14:28
4806
[求助]win7 应用层打开驱动设备失败(在XP。vista上面可用)
是一个网络防火墙驱动,驱动已经加载成功,能够拦截网络数据。win7为32位。
打开驱动设备代码:
HANDLE hDevice =
CreateFile("\\\\.\\Firewall",
GENERIC_READ | GENERIC_WRITE,
0, // share mode none
NULL, // no security
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL ); // no template
if (hDevice == INVALID_HANDLE_VALUE)
{
printf("Failed to obtain file handle to device: "
"%s with Win32 error code: %d\n",
"Firewall", GetLastError() );
return 1;
}
//返回代码为 2
(2 The system cannot find the file specified. ERROR_FILE_NOT_FOUND )
驱动符号链接代码:
RtlInitUnicodeString(&SymbolicLinkName,L"\\DosDevices\\Firewall6");
status = IoCreateSymbolicLink(
&SymbolicLinkName,
&usTempName);
if (!NT_SUCCESS(status))
{
KdPrint((" Couldn't create the Dos Device Object(0x%X)\n", status));
IoDeleteDevice(pFilterDeviceObject);
pFilterDeviceObject = NULL;
return( status );
}
这些代码在XP和vista上没有问题,在win7上面却打不开设备。
希望做过win7驱动的指点一下。多谢
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课