驱动程序做出来后,怎么用呢?根据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 - 下一页>> |