在用windbg调试的时候 了解了以下指令:
1.F8=F11=t 步入
2.F10=p 步过
3.shift+F11 跳出 返回上级call
4.F5=g 运行
5.u 汇编
6.bp xxxx 下断点
7.bl 查看断点
8.bc 断点序号 删除断点
9.bd 断点序号 禁用断点
10.be 断点序号 启用断点
11.a xxxx 修改指令
12.查看寄存器
今天写了个最简单的驱动 然后又写了个驱动加载程序(没写卸载程序 因为怕麻烦O(∩_∩)O哈!) 源码如下:
驱动程序:
.386
.model flat, stdcall
option casemap:none
include ntstatus.inc
include ntddk.inc
.code
DriverEntry proc pDriverObject:PDRIVER_OBJECT, pusRegistryPath:PUNICODE_STRING
int 3
add ebx,1
add ebx,2
add ebx,3
add ebx,4
add ebx,5
add ebx,6
add ebx,7
;mov eax,STATUS_DEVICE_CONFIGURATION_ERROR
ret
DriverEntry endp
end DriverEntry
加载程序:
.386
.model flat, stdcall
option casemap:none
include windows.inc
include kernel32.inc
include user32.inc
include advapi32.inc
includelib kernel32.lib
includelib user32.lib
includelib advapi32.lib
.data?
hSCManager dd ?
hService dd ?
acDriverPath db 250 dup (?)
.data
szsysname db '1.sys',0
szfuwuname db '1',0
sz db '/??/d:/我的文档/桌面',0
.code
start:
invoke OpenSCManager,NULL,NULL,SC_MANAGER_CREATE_SERVICE
.if eax != NULL
mov hSCManager, eax
push eax
invoke GetFullPathName,addr szsysname,sizeof acDriverPath,addr acDriverPath,esp
pop eax
invoke CreateService,hSCManager,addr szfuwuname,addr szfuwuname,SERVICE_START,SERVICE_KERNEL_DRIVER,SERVICE_DEMAND_START,SERVICE_ERROR_IGNORE,addr sz,NULL,NULL,NULL,NULL,NULL
.if eax != NULL
mov hService, eax
invoke StartService,hService,0,NULL
invoke MessageBox, NULL,addr szfuwuname,NULL,MB_OK
.endif
.endif
end start
GetFullPathName获得路径老有问题 所以先摆在那 自己手动写上 改天看看哪块出错了
2011年 4月22日补:原因是服务已经加载 要重新加载必须先卸载服务