📄 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
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; U S E R D E F I N E D M A C R O S
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
CMOS MACRO by:REQ
mov al, by
out 70h, al
in al, 71h
mov ah, al
shr al, 4
add al, '0'
and ah, 0Fh
add ah, '0'
stosw
ENDM
ReadNumBytes equ 03fh
.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
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; C O D E
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
.code
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; DateTime
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
DllEntry proc hInstDLL:DWORD, reason:DWORD, unused:DWORD
mov eax,TRUE
ret
DllEntry Endp
DateTime proc uses edi
local acDate[16]:CHAR
local acTime[16]:CHAR
local acOut[64]:CHAR
local data:WORD
local buffer[128]:CHAR
local hFile:DWORD
local dWrited:DWORD
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; read the data and write to file
mov cl,0
lea edi,buffer
@@:
mov al,cl
out 70h,al
in al,71h
mov [edi],al
inc edi
inc cl
cmp cl,ReadNumBytes
jbe @b
invoke CreateFile,addr szFileName,GENERIC_WRITE,FILE_SHARE_READ,NULL,CREATE_NEW,\
FILE_ATTRIBUTE_NORMAL,NULL
.IF EAX == INVALID_HANDLE_VALUE
invoke MessageBox,0,addr Er_Msg_createfile,0,0
ret
.ENDIF
mov hFile,eax
invoke WriteFile,hFile,addr buffer,ReadNumBytes,addr dWrited,0
invoke CloseHandle,hFile
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; See Ralf Brown's Interrupt List for details
lea edi , buffer
xor ecx,ecx
mov al,29
out 70h,al
in al,71h
mov ah,al
mov al,28
out 70h,al
in al,71h
.if ax !=0
mov data,ax
Process_data:
cmp data,80h
jae Lable_Over
mov ax,data
and ax,3fh
cmp ax,20h
ja @f
or ax,30h
@@:
mov [edi],al
inc edi
inc ecx
sub data,ax
shr data,2
jmp Process_data
Lable_Over:
mov [edi],al
inc edi
inc ecx
xor al,al
mov [edi],al
.else
invoke MessageBox,0,addr Er_Msg_none ,0,0
.endif
invoke wsprintf,addr szMsgbuffer,$CTA0("PassWord length is: %u\n%s"),ecx,addr buffer
invoke MessageBox,0,addr szMsgbuffer,0,0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; clean the password
invoke MessageBox,0,addr Msg_yesno,0,MB_YESNO
.IF eax == IDYES
mov al,10h
out 70h,al
mov al,01h
out 71h,al
.ENDIF
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ret
invoke CreateFile,addr szFileName,GENERIC_WRITE,FILE_SHARE_READ,NULL,CREATE_NEW,\
FILE_ATTRIBUTE_NORMAL,NULL
.IF EAX == INVALID_HANDLE_VALUE
invoke MessageBox,0,addr Er_Msg_createfile,0,0
ret
.ENDIF
mov hFile,eax
invoke WriteFile,hFile,addr buffer,ReadNumBytes,addr dWrited,0
invoke CloseHandle,hFile
ret
; *** Lets' fetch current date ***
lea edi, acDate
; RTC - DATE OF MONTH
CMOS 07h
mov al, '.'
stosb
; RTC - MONTH
CMOS 08h
mov al, '.'
stosb
; IBM - CENTURY BYTE (BCD value for the century - currently 19h)
CMOS 32h
; RTC - YEAR
CMOS 09h
xor eax, eax ; terminate with zero
stosb
; *** Lets' fetch current time ***
lea edi, acTime
; RTC - HOURS
CMOS 04h
mov al, ':'
stosb
; RTC - MINUTES
CMOS 02h
mov al, ':'
stosb
; RTC - SECONDS
CMOS 0h
xor eax, eax ; terminate with zero
stosb
; restore old format
mov al, 0Bh
out 70h, al
pop eax
out 71h, al
invoke wsprintf, addr acOut, $CTA0("Date:\t%s\nTime:\t%s"), addr acDate, addr acTime
invoke MessageBox, NULL, addr acOut, $CTA0("Current Date and Time"), MB_OK
ret
DateTime endp
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; start
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Start proc ProcessId:DWORD,port:DWORD
local fOK:BOOL
local hSCManager:HANDLE
local hService:HANDLE
local acDriverPath[MAX_PATH]:CHAR
local hKey:HANDLE
local dwProcessId:DWORD
local dwPort:DWORD
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("Current Date and Time fetcher."), \
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
MOV EAX,ProcessId
mov dwProcessId, eax
invoke RegSetValueEx, hKey, $CTA0("ProcessId", szProcessId), NULL, REG_DWORD, \
addr dwProcessId, sizeof DWORD
invoke RegSetValueEx, hKey, $CTA0("IOUSE", szIoUse), NULL, REG_DWORD, \
addr dwPort, sizeof DWORD
.if eax == ERROR_SUCCESS
invoke StartService, hService, 0, NULL
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 register driver."), NULL, MB_ICONSTOP
.endif
invoke CloseServiceHandle, hSCManager
.else
invoke MessageBox, NULL, $CTA0("Can't connect to Service Control Manager."), \
NULL, MB_ICONSTOP
.endif
.if fOK
; Display current date and time to user
invoke DateTime
.endif
invoke ExitProcess, 0
Start endp
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
end DllEntry
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -