内核&驱动基础
WDK(Windows Driver Kit)
内核编程需要使用WDK
WDK 下载
windows xp wdk 下载地址
WDK 安装
勾选所有的安装项,避免错过一些例子
- 默认安装目录: C:\WinDDK
first驱动开发
源码 first.c
#include <ntddk.h>#define DEBUG/** 卸载函数*/
VOID DriverUnload(PDRIVER_OBJECT driver)
{DbgPrint("good bye my world...\r\n");
}/** 装载函数*/
NTSTATUS DriverEntry(PDRIVER_OBJECT driver, PUNICODE_STRING reg_path)
{
/** 在调试时使用int 3,正常运行时驱动运行int 3 会导致蓝屏*/
#ifdef DEBUG_asm int 3
#endifDbgPrint("despacito world... \r\n");driver->DriverUnload = DriverUnload;return STATUS_SUCCESS;
}
编译驱动
makefile
驱动编写需要Makefile,放在和源文件同级目录即可
#############################################################################
#
# Copyright (C) Microsoft Corporation 1998, 1999
# All Rights Reserved.
#
##############################################################################
# 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