📄 call.asm
字号:
; #########################################################################
.386
.model flat, stdcall
option casemap :none ; case sensitive
; #########################################################################
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib RWcmosDll.lib
; #########################################################################
MY_STRUCT STRUCT
Item1 dd ?
Item2 dd ?
Item3 db 16 dup(?)
MY_STRUCT ENDS
OpenIO proto :WORD,:DWORD
ReadNumBytes equ 03fh
.DATA
szStrFmt db "long is%d",0
szDllName db "ntoskrnl.exe",0
szIoSetFunc db "Ke386IoSetAccessProcess",0
szSetIoFunc db "Ke386SetIoAccessMap",0
Er_msg_loaddll db "load dll error",0
Er_msg_getfunc db "get function address ok!",0
Er_Msg_createfile db "create file error",0
Er_Msg_openerror db "open ip error",0
Er_Msg_error db "error",0
Ok_Msg_ok db "ok!",0
Ok_msg_loaddll db "load dll ok",0
Ok_msg_getfunc db "get function address error !",0
szFileName db "cmosnew.data",0
.data?
szBuffer db 128 dup(?)
hDll dd ?
hFunc_IoSet dd ?
hFunc_SetIo dd ?
dwProcessId dd ?
buffer db 128 dup(?)
hFile dd ?
dwWrited dd ?
.CODE
start:
invoke GetCurrentProcessId
mov dwProcessId, eax
mov bx,70h
invoke OpenIO,bx,dwProcessId
.IF eax == FALSE
invoke MessageBox,0,addr Er_Msg_openerror,0,0
jmp Exit_Program
.ELSE
; invoke MessageBox,0,addr Ok_Msg_ok,0,0
.ENDIF
invoke Sleep ,2000
mov bx,71h
invoke OpenIO,bx,dwProcessId
.IF eax == FALSE
invoke MessageBox,0,addr Er_Msg_openerror,0,0
jmp Exit_Program
.ELSE
invoke MessageBox,0,addr Ok_Msg_ok,0,0
.ENDIF
jmp Exit_Program
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; 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 dwWrited,0
invoke CloseHandle,hFile
.IF eax == TRUE
invoke MessageBox,0,addr Ok_Msg_ok,0,0
.ELSE
invoke MessageBox,0,addr Er_Msg_error,0,0
.ENDIF
Exit_Program:
push 0
call ExitProcess
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -