📄 rwcmosdll.asm
字号:
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;
; DateTime.asm
;
; Service Control Program for giveio.sys driver
;
; Written by Four-F (four-f@mail.ru)
;
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
.386
.model flat, stdcall
option casemap:none
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; I N C L U D E F I L E S
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
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
.data
Er_Msg_none db "no data",0
Er_Msg_createfile db "create file error",0
Msg_yesno db "Do you Want to clean the password ?",0
szMsgbuffer db 128 dup(0)
szFileName db "Cmos.dat",0
Er_Msg_deleteservice db "delete service error",0
Ok_Msg_deleteservice db "delete service ok!",0
Er_Msg_openservice db "open service error",0
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; C O D E
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
.code
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; start
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
DllEntry proc hInstDLL:DWORD, reason:DWORD, unused:DWORD
mov eax,TRUE
ret
DllEntry Endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; OpenIO can make user open one IOport
;; if sucess return TRUE else return FALSE
OpenIO proc port:WORD,ProcessId:DWORD
local fOK:BOOL
local hSCManager:HANDLE
local hService:HANDLE
local acDriverPath[MAX_PATH]:CHAR
local dwProcessId:DWORD
local hKey:HANDLE
and fOK, 0 ; assume an error
; Open a handle to the SC Manager database
invoke OpenSCManager, NULL, NULL, SC_MANAGER_CREATE_SERVICE
.if eax != NULL
mov hSCManager, eax
push eax
invoke GetFullPathName, $CTA0("giveio.sys"), sizeof acDriverPath, addr acDriverPath, esp
pop eax
; Register driver in SCM active database
invoke CreateService, hSCManager, $CTA0("giveio"), $CTA0("Make you can Read/Write IO port"), \
SERVICE_START + DELETE, SERVICE_KERNEL_DRIVER, SERVICE_DEMAND_START, \
SERVICE_ERROR_IGNORE, addr acDriverPath, NULL, NULL, NULL, NULL, NULL
.if eax != NULL
mov hService, eax
invoke RegOpenKeyEx, HKEY_LOCAL_MACHINE, \
$CTA0("SYSTEM\\CurrentControlSet\\Services\\giveio"), \
0, KEY_CREATE_SUB_KEY + KEY_SET_VALUE, addr hKey
.IF eax == ERROR_SUCCESS
PUSH ProcessId
pop dwProcessId
invoke RegSetValueEx, hKey, $CTA0("ProcessId", szProcessId), NULL, REG_DWORD, \
addr dwProcessId, sizeof DWORD
movzx eax,port
mov dwProcessId,eax
invoke RegSetValueEx, hKey, $CTA0("IOUSE", szIOUSE), NULL, REG_DWORD, \
addr dwProcessId, sizeof DWORD
.IF eax == ERROR_SUCCESS
invoke StartService, hService, 0, NULL
;invoke MessageBox,0,$CTA0("look regedit"),0,0
inc fOK ; set flag
invoke RegDeleteValue, hKey, addr szProcessId
invoke RegDeleteValue, hKey, addr szIOUSE
.ELSE
invoke MessageBox, NULL, $CTA0("Can't add Process ID into registry."), \
NULL, MB_ICONSTOP
.ENDIF
invoke RegCloseKey, hKey
.ELSE
invoke MessageBox, NULL, $CTA0("Can't open registry."), NULL, MB_ICONSTOP
.ENDIF
; Remove driver from SCM database
invoke DeleteService, hService
invoke CloseServiceHandle, hService
.ELSE
invoke MessageBox, NULL, $CTA0("Can't regist driver ,Delete it?."), NULL, MB_ICONSTOP or MB_YESNO
.IF eax == IDYES
invoke OpenService,hSCManager,$CTA0("giveio"),SERVICE_ALL_ACCESS
.IF eax != NULL
mov hService,eax
invoke DeleteService,hService
.IF eax == 0 ;error
invoke MessageBox,0,addr Er_Msg_deleteservice,0,0
.ELSE
invoke MessageBox,0,addr Ok_Msg_deleteservice,0,0
.ENDIF
invoke CloseServiceHandle,hService
.ELSE
invoke MessageBox,0,addr Er_Msg_openservice,0,0
.ENDIF
.ENDIF
.ENDIF
invoke CloseServiceHandle, hSCManager
.else
invoke MessageBox, NULL, $CTA0("Can't connect to Service Control Manager."), \
NULL, MB_ICONSTOP
.endif
.IF fOK
mov eax,TRUE
.ELSE
mov eax,FALSE
.ENDIF
ret
OpenIO endp
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
end DllEntry
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -