1.下载安装wdk
此过程省略
2.编写第一个c文件
命名为first.c,已表示这是我们编写的第一个讷河编程文件,
#include "ntddk.h"
VOID DriverUnload(PDRIVER_OBJECT driver)
{
DbgPrint("first: our driver is unload\r\n");
}
NTSTATUS DriverEntry(PDRIVER_OBJECT driver,PUNICODE_STRING reg_path)
{
DbgPrint("hello: our driver is run\r\n");
driver->DriverUnload=DriverUnload;
return STATUS_SUCCESS;
}
vs2010配置编译环境如下
生成-配置管理器-新建-从此处复制设置-debug
视图切换到属性管理器-找到刚刚复制的编译选项右击-添加新项目属性表-xxx.prop
eries
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<ExecutablePath>C:\WinDDK\7600.16385.1\bin\x86;$(ExecutablePath)</ExecutablePath>
</PropertyGroup>
<PropertyGroup>
<IncludePath>C:\WinDDK\7600.16385.1\inc\api;C:\WinDDK\7600.16385.1\inc\ddk;C:\WinDDK\7600.16385.1\inc\crt;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup>
<LibraryPath>C:\WinDDK\7600.16385.1\lib\wxp\i386;$(LibraryPath)</LibraryPath>
<TargetExt>.sys</TargetExt>
<LinkIncremental>false</LinkIncremental>
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>_X86_;DBG</PreprocessorDefinitions>
<CallingConvention>StdCall</CallingConvention>
<ExceptionHandling>false</ExceptionHandling>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<BufferSecurityCheck>false</BufferSecurityCheck>
<CompileAs>Default</CompileAs>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>ntoskrnl.lib;wdm.lib;wdmsec.lib;wmilib.lib;ndis.lib;Hal.lib;MSVCRT.LIB;LIBCMT.LIB;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<EnableUAC>false</EnableUAC>
<SubSystem>Native</SubSystem>
<EntryPointSymbol>DriverEntry</EntryPointSymbol>
<BaseAddress>0x10000</BaseAddress>
<RandomizedBaseAddress>
</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<GenerateDebugInformation>true</GenerateDebugInformation>
<Driver>Driver</Driver>
</Link>
</ItemDefinitionGroup>
<ItemGroup />
</Project>
自行更改以上配置
第二步:
用新配置的编译项编译first.c,成功后将driver.sys拷贝到虚拟机xp系统中,使用driver加载工具加载使用(使用步骤自行百度)
第一个driver程序完成

被折叠的 条评论
为什么被折叠?



