下载此文档

Windows驱动编程基础教程.doc


文档分类:IT计算机 | 页数:约28页 举报非法文档有奖
1/28
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/28 下载此文档
文档列表 文档介绍
Windows驱动编程基础教程-谭文-代码整理
代码全部测试通过,测试环境:WinDDK chk x86 WXP
教程上有很详细非常详细的讲解,偶就偷懒不写注释了
代码中有些应该考虑应该实现的东西偶不会,就省了。。。不会完善,能跑就行。。。
1 字符串使用
2 内存的分配与释放
3 LIST_ENTRY
4 LARGE_INTEGER
5 KSPIN_LOCK
6 文件操作
7 注册表读写
8 时间与定时
未完待续。。。
makefile
#
# DO NOT EDIT THIS FILE!!!  Edit .\sources. if you want to add a new source
# file to ponent.  This file merely indirects to the real make file
# that is shared by all the ponents of the Windows NT DDK
#
!INCLUDE $(NTMAKEENV)\
sources
TARGETNAME=study
TARGETPATH=OBJ
TARGETTYPE=DRIVER
SOURCES=    
1 字符串使用
/*
 *《Windows驱动编程基础教程-谭文》-字符串使用
 *测试环境:WinDDK  chk x86 WXP
 *小默 整理
*/
#include<>
#include<>
DRIVER_UNLOAD StudyUnload;
NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject,PUNICODE_STRING RegistryPath)
{
    PAGED_CODE();
    
    DriverObject->DriverUnload = StudyUnload;
    
    return ESS;
}
VOID StudyUnload(PDRIVER_OBJECT DriverObject)
{
    UNICODE_STRING str1;
    UNICODE_STRING dst;
    WCHAR dst_buf[256];
    UNICODE_STRING src = RTL_CONSTANT_STRING(L"source string"); //Init a UNICODE_STRING
    NTSTATUS status;
    PAGED_CODE();
    DbgPrint("Study:Our driver is unloading\r\n");
    //Init a UNICODE_STRING
    RtlInitUnicodeString(&str1,L"Init the string str1");
    KdPrint(("Init a UNICODE_STRING:%wZ\r\n",&str1));
    //把dst初始化成拥有缓冲区长度为256的UNICODE_STRING空串
    //!!! copy 之前一定要先给dst分配空间!!!
    RtlInitEmptyUnicodeString(&dst,dst_buf,256*sizeof(WCHAR));
    //copy a UNICODE_STRING
    RtlCopyUnicodeString(&dst,&src);
    KdPrint(("Copy a UNICODE_STRING:%wZ\r\n",&dst));
    //append a UNICODE_STRING
    status = RtlAppendUnicodeToString(&dst,L"|append string.");
    KdPrint(("Append a UNICODE_STRING:%wZ\r\n",&dst));
    return;
}
2 内存的分配与释放
/*
 *《Windows驱动编程基础教程-谭文》-内存的分配与释放
 *测试环境:WinDDK  chk x86 WXP
 *小默 整理
*/
#include<>
#include<>
//定义一个内存分配标记
#define MEM_TAG "CG"
DRIVER_UNLOAD StudyUn

Windows驱动编程基础教程 来自淘豆网www.taodocs.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数28
  • 收藏数0 收藏
  • 顶次数0
  • 上传人rjmy2261
  • 文件大小59 KB
  • 时间2018-06-04