天书夜读:从汇编语言到Windows内核编程笔记(3)

it2022-05-09  37

Windows 内核(一) .sys 放在 Drivers 目录下。运行在 R0 层。WDK 的相应环境中,进行相应代码目录, build. 一个内核程序被看作一个 PE 格式的 DLL ,它是被 Windows 整个内核调用的一个 DLL ,一旦加裁,就成为内核的组成部分。所有的内核内存空间是共享的。内核程序崩溃, Windows 系统也就崩溃了。 DriverEntry 是一个内核程序的入口,以 system 进程名出现。 编写内核的规则: 不能调用 Windows 应用层 API 函数,而应用内核 API 关于字符串,内存处理,打印等,参见前面 Rtl 函数 浮点数要特殊处理 在 Windows 中,不同类型设备的驱动有不同的安装方式, ini 文件。非 任何类型 的驱动程序,当作服务安装。(搜 服务安装驱动下载 net start 服务名) 调试 Windbg ( http://www.microsoft.com/whdc/devtools/debugging/installx86.mspx ) 我们用虚拟机进行调试 VMWare. 环境搭建: 1 虚拟机中 boot.ini ....... multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows Server 2003, Enterprise" /noexecute=optout /fastdetect multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows Server 2003, Enterprise" /noexecute=optout /fastdetect /debug /debugport=com1 /baudrate=9600 2 设置虚拟机 Hardward > Serial Port > Output to named pipe, 添入: \\.\pipe\com_1,this end is the server,the other end is an application. 3 Windbg 设置 Windbg (本机中)的启动参数: Windbg.exe -b -k com:port=\\.\pipe\com_1,baud=9600,pipe ( 整成快捷方式 ) 说明 1 :在虚拟中在调试模式下启动 windows 后,马上以以上参数启动 Windbg 说明 2 :我以指定波特率启动 WINDBG 时老是提示我参数出错,把指定波特项取消后可以成功。 4 设置代码路径和符号表位置,就可以调试了。 Symbol File Path 中, sys 的位置。多个路径以分号隔开。 用以下设置来下载符号表。 srv*c:\symbols* http://msdl.microsoft.com/download/symbols ( 关于说明,可见: http://www.microsoft.com/whdc/devtools/debugging/debugstart.mspx) 其它更进一步的关于汇编代码的分析,见 [6] 其它调试如同 VS 中。 C++ 写内核 需要自己写 new 操作符ecx 传递 this 指针对象的开头部分就是虚函数表地址 父类和子类各有一份虚函数表,没有共公部分。在子类的虚函数表中,没有重载的基类虚函数的地址和基类虚函数一样,而重载后有自己独特的地址。 参考 [1] http://www.cnblogs.com/phinecos/archive/2009/02/19/1393803.html [2] http://www.cnblogs.com/qsilence/archive/2009/06/11/1501511.html [3 http://msdn.microsoft.com/en-us/library/ff557565(VS.85).aspx [4] http://www.cnblogs.com/wanghao111/archive/2009/05/25/1489041.html [5] Windows 驱动编程基础教程 .doc [6] 天书夜读 - 从汇编语言到 windows 内核编程 ( http://download.csdn.net/source/2754275) [7] Windows DDK 推荐其它书籍 Programming the micfosoft windows Driver Model: 驱动开发 windows 环境下的 32 位汇编语言程序设计:汇编学习 软件调试,张银奎:软件调试

转载于:https://www.cnblogs.com/forlina/archive/2011/07/11/2103094.html

相关资源:各显卡算力对照表!

最新回复(0)