第一章 Windows设备驱动程序设计Hello World
来源:互联网 发布:双11实时数据直播视频 编辑:程序博客网 时间:2024/05/22 14:27
int main()
{
printf("Hello World!/n");
return 0;
}
NTSTATUS
DriverEntry (
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
DbgPrint(("Hello World!/n"));
return STATUS_SUCCESS;
}
要编译,运行并且看到这个Hello World的结果就要麻烦一些了。首先你得有(Driver Develpment Kit)DDK,可以到网上下载,或者买光盘。DDK里面提供了丰富的例子,一般的驱动程序,可以参考DDK里面的例子。
将文件存为hello.c, 当然前面先要include ddk的头文件:
#include <ntddk.h>
要编译这个文件,需要建一个make文件和resource文件。在ddk里面,make文件可以都一样。
makefile的内容应该是如下:
#
# DO NOT EDIT THIS 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
一般不要更改这个文件,如果要加入源文件应该编辑sources文件。
简单的source文件如下:
TARGETNAME=hello
TARGETPATH=obj
TARGETTYPE=DRIVER
SOURCES=hello.c
有了这3个文件就可以编译出驱动程序hello.sys了。
首先进入编译环境,开始->Development Kits->DDK XXXX->build enviorenments->windows XP->Windows XP Checked Build Environment.
进入这三个文件的存放目录,执行build。编译完成后,目录下产生了objchk_wxp_x86/i386,下面有个文件hello.sys,这就是我们第一步的成果了。
REGEDIT4
[HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/hello]
"ErrorControl"=dword:00000001
#
# When to start the driver:
# At boot: Start=1
# Manually: Start=3
#
"Start"=dword:00000001
"Type"=dword:00000001
把我们编译好的hello.sys拷贝到系统的驱动程序目录下C:/WINDOWS/system32/drivers,然后重新启动操作系统,这个驱动就可以在启动的时候被加载了。要看到Hello World!可以按照debugview这个软件,这是简单好用的驱动调试工具,它可以显示DbgPrint打印出来的log。要选择debugview的capture菜单里面的log boot,可以buffer操作系统boot的时候的log。
重启之后可以从debugview里面看到log。
- 第一章 Windows设备驱动程序设计Hello World
- 第一章 Windows设备驱动程序设计Hello World
- Linux设备驱动程序0-hello world
- 初识设备驱动程序之Hello world
- Linux设备驱动程序学习(0)-Hello, world!模块
- Linux设备驱动程序学习(0)-Hello, world!模块
- ubuntu 字符设备驱动程序──hello world
- Linux设备驱动程序学习(0)-Hello, world!模块
- Linux设备驱动程序学习(0)-Hello, world!模块
- Linux设备驱动程序学习(一)入门必须的hello world
- Linux设备驱动程序学习(0)-Hello, world!模块
- Linux设备驱动程序学习(0)-Hello, world!模块
- Linux设备驱动程序学习(0)-Hello, world模块
- Linux设备驱动程序,个人学习,第一个模块hello world
- Linux设备驱动程序(第三版)读书笔记1,hello world
- Linux设备驱动程序(LDD)第二章:Hello World模块
- <linux设备驱动程序>hello world 模块——不用main函数的hello world
- 驱动程序hello world(转)
- 如果---BeanSprout
- EXCEL导入方法
- HTML 5删除开源视频编码Ogg 据称与苹果有关
- 2009年世界500强中国43家公司上榜(名单)
- sql注入攻击特效药
- 第一章 Windows设备驱动程序设计Hello World
- java程序开发的实质
- 第06讲 面向对象示例
- 怎么查看系统里所有用户对应拥有的权限?
- Page Layouts and Master Pages
- 第08讲 数组示例
- 101条计算机经典名言(英汉对照版)
- JQuery无废话系列教程(四) 实战篇下
- C# 验证码的三种做法[纯数字][纯汉字][字母/数字/汉字混合]