return ntStatus;
}
VOID HelloWorldUnLoad (IN PDRIVER_OECT DriverObject)
{
UNICODE_STRING DeviceLinkString;
PDEVICE_OECT DeviceObjectTemp1=NULL;
PDEVICE_OECT DeviceObjectTemp2=NULL;
#ifdef DEBUGMSG
DbgPrint("Starting HelloWorldUnLoad()\n");
#endif
RtlInitUnicodeString(&DeviceLinkString,DOS_DEVICE_NAME);
IoDeleteSymbolicLink(&DeviceLinkString); //删除符号连接
if (DriverObject)
{
DeviceObjectTemp1=DriverObject->DeviceObject;
//删除设备
while (DeviceObjectTemp1)

{
DeviceObjectTemp2=DeviceObjectTemp1;
DeviceObjectTemp1=DeviceObjectTemp1->NextDevice;
IoDeleteDevice(DeviceObjectTemp2);
}
}
}
#endif
=======================================================================================
=============
驱动程序的编译需要使用DDK中的build实用程序,它是一个命令行程序,使用不是很方便。VC知识库有
一篇在VC++ 6.0中编译驱动的文章,有兴趣可以去看看。
1,makefile
编译驱动程序,首先应该准备一个makefile,这个文件很简单,只有一句代码:
#
# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
# file to this component. This file merely indirects to the real make file
# that is shared by all the driver components of the Windows NT DDK
#
!INCLUDE $(NTMAKEENV)\makefile.def
正如描述的那样,不要修改这个文件---它是通用的!
2,sources
准备的第二个文件就是sources,它描述了一些编译的细节。针对本文的程序,sources文件的内容是这
样的:
TARGETNAME=HelloWorld //驱动名称
TARGETPATH=. //编译后SYS的路径
TARGETTYPE=DRIVER //类型为驱动程序
SOURCES= HelloWorld.c //只有一个源文件
有了这2个文件后,就可以使用build进行编译了。进入「开始」菜单\程序\Development Kits\Windows
2000 DDK,
分别有3个CMD程序:1)Checked 64 Bit Build Environment,“Debug”的64位版本;2)Checked
Build Environment
“Debug”的32位版本;3)Free Build
Environment,“Release”的32位版本。不用说,肯定是使用Free Build Environment。
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/tongxinshuyu/article-47708-3.html
正因为如此
台湾如果敢宣布独立
风险大小
老美不跑等着喂鱼吗
没有马云也会有张云李云