您的位置:逆风者 汇编技术 正文
原作者:www.upwinder.com 添加时间:2007-09-01 原文发表:2007-08-31 人气:30 来源:未知

本文章共3419字,分3页,当前第1页,快速翻页:
 
驱动程序做出来后,怎么用呢?根据Four-F的说法,有三种方式:服务控制管理器(Service Control Manager (SCM).)
服务控制程序(Service Control Program (SCP).)和服务程序(service program).
下面我们就用服务控制程序(SCP)来实现驱动程序的动态加载,例子程序在 KmdKit\examples\simple\Beeper
逆@风@者
代码如下:
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;
;scp.asm
;
;ServiceControlProgramforbeeper.sysdriver
;
;WrittenbyFour-F(four-f@mail.ru)
;
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

.386
.modelflat,stdcall
optioncasemap:none

;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;INCLUDEFILES
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

include\masm32\include\windows.inc

include\masm32\include\kernel32.inc
include\masm32\include\user32.inc
include\masm32\include\advapi32.inc

includelib\masm32\lib\kernel32.lib
includelib\masm32\lib\user32.lib
includelib\masm32\lib\advapi32.lib

include\masm32\Macros\Strings.mac

;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;CODE
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

.code

startproc

localhSCManager:HANDLE
localhService:HANDLE
localacDriverPath[MAX_PATH]:CHAR

;OpenahandletotheSCManagerdatabase
invokeOpenSCManager,NULL,NULL,SC_MANAGER_CREATE_SERVICE
.ifeax!=NULL
movhSCManager,eax

pusheax
invokeGetFullPathName,$CTA0("beeper.sys"),sizeofacDriverPath,addracDriverPath,esp
popeax

;RegisterdriverinSCMactivedatabase
invokeCreateService,hSCManager,$CTA0("beeper"),$CTA0("NiceMelodyBeeper"),\
SERVICE_START DELETE,SERVICE_KERNEL_DRIVER,SERVICE_DEMAND_START,\
SERVICE_ERROR_IGNORE,addracDriverPath,NULL,NULL,NULL,NULL,NULL
.ifeax!=NULL
movhService,eax
invokeStartService,hService,0,NULL
;Heredriverbeeper.sysplaysitsnicemelody
;andreportserrortoberemovedfrommemory
;RemovedriverfromSCMdatabase
invokeDeleteService,hService
invokeCloseServiceHandle,hService
.else
invokeMessageBox,NULL,$CTA0("Can'tregisterdriver."),NULL,MB_ICONSTOP
.endif
invokeCloseServiceHandle,hSCManager
.else
invokeMessageBox,NULL,$CTA0("Can'tconnecttoServiceControlManager."),\
NULL,MB_ICONSTOP
.endif

invokeExitProcess,0

startendp

;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

endstart
;=============以下是驱动程序源码beeper.bat的内容===========
;@echooff
;gotomake

;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;
;beeper-KernelModeDriver
;Makesbeepthoroughcomputerspeaker
;
;WrittenbyFour-F(four-f@mail.ru)
;
;WARNING:TestedW2000&XPonly!
;
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

.386
.modelflat,stdcall
optioncasemap:none

;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;INCLUDEFILES
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
本文章更多内容1 - 2 - 3 - 下一页>>
相关文章

超类化
建立自己的动态链接库
关于div/idiv/mul/imul指令的用法
汇编语言的高级语言特性
实模式和任何特权级下可执行的指令
保护方式简介
仿FDISK及PQMAGIC列出分区逻辑盘符的prw.as
DEBUG命令详解
系统托盘中的快捷图标
只能在保护模式下执行的指令
用汇编编写屏幕保护程序
控制转移(2)
Win32编程中请慎用ebx/esi/edi
结构化程序方法在汇编语言中的应用
请求执行时间段与Shell函数
中断和异常的转移方法
驱动程序的编译和连接
Win32汇编的环境和基础
学写基于对话框的程序
字符串操作指令

相关评论


本文章所属分类:首页 汇编技术

  热门关键字:
进制数据输出的通用程序 2007-09-12
汇编源码--showmem 2007-08-31
汇编源码--CLEAN 2007-08-31
汇编源码--hdr 2007-08-31
汇编源码--basload 2007-08-31
汇编源码--CHAR 2007-08-31
汇编源码--fxn 2007-08-31
汇编源码--alarm 2007-08-31
汇编源码--getsect 2007-08-31
汇编源码--DEV 2007-08-31
汇编源码--getspace 2007-08-31
汇编源码--frespace 2007-08-31
CIH文件型病毒检测消除程序 2007-08-31
Mixer Volume Ctrler V1.0 2007-08-31
汇编源码--COMINT 2007-08-31
自己用汇编语言写的一个病毒(源码... 2007-08-31
汇编源码--col 2007-08-31
汇编源码--BURNOUT 2007-08-31