Windows 驱动开发笔记(一)
Windows驱动开发较unix类的驱动开发要复杂一些。最近,在学windows开发。现在把学到的知识整理一下。做做笔记。
1. 我使用的资料:《深入解析windows操作系统》《Programming the microsoft windows Driver Model》《Windows 2000/xp WDM 设备 驱动开发》武安河著《Linux 驱动开发》
2. 开发环境VPC2004 、Windows2003、Windows DDK
首先是环境安装。资料很多自己做了。
在VPC中安装好windows2000。使用windbg作为调试工具。
环境安装完成后,就可以一边学习一边做试验了。我比较喜欢这种方式。
现在开始进入主题。
概念(一):系统模式和应用模式。
系统模式是指工作在一个管理级别的状态。这个状态具有没有约束的权利。所以这样的代码如果工作不正常就会给系统带来灾难!驱动程序通常工作在系统级。应用模式(或称用户模式)。这一模式受到操作系统的管理。一个应用程序崩溃通常不回给整个系统带来灾难。要正确理解模式的概念。我的经验是看一看unix原理的书。可以较好的理解这一含义。
概念(二):多任务。
Windows是一个多任务的操作系统。CPU的使用是影响系统性能的重要因素。任务之间要同时进行就必须要有很好的CPU调度策略。Windows的任务调度给驱动程序的编写带来了一些麻烦。一个驱动程序不能长时间的独占CPU时间。通常把驱动程序划分成可以被中断的和不可以被中断的。必须要独占CPU的就是不能被中断的。反之,是可被中断的。在WINDOWS的系统中通过中断级别(IRQL)来标记一段代码是否可以被中断。如果引入中断就有可能带来重入问题。这个问题会带来资源的调度问题。这个我不多说了。可以参考操作系统的书籍。
概念(三):驱动程序的调用。
驱动程序的代码是为应用服务的。所以,他的调用通常都是被动的。因为,你不知道用户什么时间使用哪个功能。所以,驱动程序的代码多数是些片段(通常就是完成某个功能的函数)。不象应用程序一样自己知道下一步该干啥了。就会没有整体感。只要,函数完成一个规定的功能就可以了。不用管他什么时间被调用。既然是被调用。就要让系统知道你的函数在哪里。这就需要告诉系统你的函数的指针。这就需要注册你的函数指针。怎么样注册呢?一种方法是写个固定名称的函数。就像C中的main一样。不能瞎起名字。第二种就是指针登记。这需要填写DriverObject这个数据结构的相应功能的项目。如:
DriverObject->MajorFunction[IRP_MJ_PNP]=CharSamplePnpDispatch;
这个代码就完成了CharSamplePnpDispatch这个函数的注册了。
概念(四):IRP
IRP是一个不好理解的概念。IRP就是I/O请求包的称为。I/O请求包是什么呢?上面说了驱动是一些等待被调用的独立函数。用户请求读一个设备时,通常需要多个步骤来完成。这就要有一个完成该功能的一个函数的调用列表。这个任务列表就是IRP结构的一部分内容。当用户发出一个请求时,系统就根据请求产生一个IRP。然或系统就依照这个IRP的指示去调用相应的函数功能。
概念(五):过滤驱动(过滤层、过滤函数)
Windows的WDM模型采用了分层的设计方法。这样的设计可以实现灵活的任务组织。上面说了驱动是一些等待被调用的独立功能函数。一段功能代码只完成有限的功能。在调用时在进行任务的组合。过滤函数是一些主要功能任务的补充功能。在一个主要功能前调用的是上层调用。在主要功能后调用的是下层调用。而且,可以是多层的。如我们写了一个读U盘的驱动。这个U盘有一个特殊的功能是对数据进行加密。我们就可以在读写物理设备前后加入一个过滤驱动完成这个操作。
相关推荐
Windows usb驱动开发.zip
该例子详细介绍了windows usb驱动开发。关于usb如何编写驱动程序和windows下设备编程如何实现。
windows内核驱动开发(WDK环境搭建)
windows内核驱动开发环境搭建
Windows驱动开发集合(PDF+笔记+随书源码+CHM帮助)
Microsoft Windows驱动程序模型设计 Windows驱动学习笔记 Windows文件系统过滤驱动开发教程(第二版) WDMdriver3随书附带光盘 WIN2000驱动程序设计 windows驱动模型 驱动程序超级宝典 笔记及Driverstudio
Windows驱动开发(一)
总结来说,WDM是早期的Windows驱动开发模型,需要开发人员直接操作底层硬件资源,而WDF是在WDM之上的高级和抽象的驱动程序开发框架,提供了更简化和自动化的开发方式。注意:在极少数情况下,你需要编写注意到 PnP 或电源事件的软件驱动程序,并且驱动程序需要访问无法通过 KMDF 获取的数据,你必须使用 WDM。WDF提供了更多的自动化和简化功能,减少了驱动程序开发的复杂性和错误,提高了开发效率和稳定性。WDM驱动程序以核心驱动程序、功能驱动程序和过滤器驱动程序为基础,涵盖了广泛的硬件设备类型。
基于因果推理的LLM去毒:精准定位注意力头实现高效干预
在大型语言模型(LLM)的部署与应用中,模型安全与可控性是核心挑战之一。传统方法如全参数微调成本高昂,且可能损害模型通用能力。本文聚焦于一种基于因果推理的精准干预技术,其原理在于利用因果发现算法定位Transformer模型中与“毒性”输出存在强因果关联的特定注意力头。该技术通过分析注意力头的激活模式与生成文本毒性分数之间的因果关系,识别出关键责任单元,而非依赖传统的相关性分析。其技术价值在于实现了轻量级、高可解释性的模型行为修正,能以极低的参数改动代价有效降低模型在敏感话题上的有害输出。在应用场景上,该方
关于使用CMT2300A FIFO缓存区间设置为64Byte的问题
帮助你解决在使用CMT2300A 时遇到的各种问题,若有需要,请及时与我交流
Windows打印机驱动开发笔记(一)
在Windows中,打印机驱动的作用是编写一组接口。应用程序调用的GDI函数会变成相应的DDI函数,打印机驱动提供的这组接口负责将DDI函数转变为打印机识别的的指令。至于是通过网口、串口等接口与真实打印机相连接,这是Printer Moniter的职责,而不是Printer Driver的职责。打印机驱动一般分为两个部分。1.printer graphics DLL 2.Printer Inter...
C#里用HttpListener实现WEB API接口服务端
本文介绍了一个基于WinForm的HTTP服务实现方案。该方案使用HttpListener类创建了一个支持JSON POST请求处理的轻量级Web服务器,主要特点包括:1) 纯线程方式实现请求监听和处理;2) 提供标准化的JSON响应格式;3) 支持自定义请求处理逻辑;4) 包含完整的日志记录功能。代码示例展示了如何初始化服务、处理不同类型的请求(包括JSON POST),并提供了线程安全的UI更新机制。该实现适用于需要简单HTTP接口的Windows桌面应用程序,可作为程序间通信的基础设施。
[笔记]windows驱动开发入门《一》helloworld 以及双机调试配置
[vs2019+wdk10开发xp,win7,win10驱动]https://blog.csdn.net/Kwansy/article/details/111051265
科研绘图系列:基因突变瀑布图统计以及可视化
科研绘图系列:基因突变瀑布图统计以及可视化
【局部规划模块曲线算法】曲线平滑介绍
本文先对轨迹平滑问题做个简单的介绍,具体内容后续再更,其他模块可以参考去我其他文章提示:以下是本篇文章正文内容(1)适合给移动机器人运动的路径【满足运动学,高阶平滑】(2)高阶的运动学不能够突变的【至少三阶的加速度不能突变,最好四阶的jerk和五阶的snap也不能突变】(3)在转弯的地方不会停下来(4)加减速均衡,节省能量(5)节省时间的。
Windows驱动开发最新教程笔记2025(一)名词解释
此篇主要是对驱动开发过程中遇到的各种名词做出解释,在开发之前先有抽象概念。大部分内容节取自微软文档,修复了部分机器翻译导致的歧义,以及笔者自己添加了一些备注和重点概念标记。
华为OD机考双机位C卷 - 敌情监控 (Java & Python& JS & C/C++ & GO )
华为OD机考双机位C卷 - 敌情监控 (OD上机考试双机位C卷)。提供在线OJ刷题。Java、C++、Python、GO语言、C语言、JavaScript题解,并提供完整思路讲解。
《Windows驱动开发技术详解》读书笔记(一)
首先需要安装DDK,这里我选择Microsoft Windows Server 2003 SP1 DDK Windows驱动分成两类,一类是不支持即插即用的NT式驱动,一类是支持即插即用的WDM驱动. 首先来看一个最简单的NT式驱动。 <!--<br /><br />Code highlighting produced by Actipro CodeHighl...
蓝牙配对鉴权过程深度剖析:Just Works/Numeric Comparison/Passkey Entry/OOB 协议流程
当你新买的智能手表与手机配对时,是否遇到过这样的情况:有时只需在手机上点击 "确认" 即可完成配对,有时却需要在手表上输入手机显示的 6 位数字,而连接车载蓝牙时可能又需要输入固定密码?这些差异背后,是蓝牙配对鉴权机制在默默工作。蓝牙配对鉴权是设备间建立安全连接的核心环节,直接关系到数据传输的保密性和设备身份的真实性。
【Unity大规模RTS/攻城战框架】Large Scale Combat System - RTS Sieges深度解析
本文介绍了Unity专业级大规模RTS战斗框架Large Scale Combat System(LSCS)。该系统通过Job System+Burst技术解决了万人级单位的性能问题,提供完整的RTS操作体系、动态阵型系统、战术AI和攻城战功能。其亮点包括可破坏城门、行走城墙、战术AI配置系统,支持URP渲染管线,适用于Total War风格的大规模兵团对战项目。LSCS不仅提供核心战斗系统,还包含UI、小地图等配套模块,是Unity中少有的专业级RTS解决方案,特别适合需要深度战术玩法和大规模战斗的开发者
Windows驱动开发学习笔记(一)—— 环境配置&第一个驱动程序
Windows驱动开发学习笔记(一)—— 环境配置&第一个驱动程序前言环境配置第一个驱动程序 前言 一、学习自滴水编程达人中级班课程,官网:https://bcdaren.com 二、海东老师牛逼! 环境配置 安装VS2010:https://pan.baidu.com/s/1uZWWxCtB60QPaqlf4ICWVQ 提取码:qqro 安装WDK7600:https://pan.b...
NTscan扫描工具
ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。
windows驱动开发技术详细读书笔记(一)
这本书已经买了有两个多月了,终于有时间安下心来看书了。首先是DDK的安装,之前我装的是vista操作系统,但vista系统没有专用的DDK,也是使用winxp的DDK,经试验可以正常编译出驱动,但是在vista下专用的驱动加载工具好像并不好用,有些问题,不能正常将驱动程序加载。因此,无奈之下又重新安装了XP操作系统,目前的系统环境跟张帆老师在书中提到的一样,驱动可以正常加载了。 一个
温度PID控制PLC程序
温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值
深度学习工具包 DeepLearningToolbox
深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[](https://bitdeli.com/free "Bitdeli Badge")
windows驱动开发学习笔记一双向链表LIST_ENTRY
LIST_ENTRY定义如下: typedef struct _LIST_ENTRY { struct _LIST_ENTRY *Flink; // 指向下一个节点 struct _LIST_ENTRY *Blink; // 指向前一个节点 } LIST_ENTRY, *PLIST_ENTRY; 由LIST_ENTRY的定义可以知道这是一个双向链表结构,通常
全球国家地区城市数据
MySQL全球国家地区城市数据报。。。。。。。。。。。。
5304




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



