看了《加密与解密》第19章觉得手痒所以做了这个。废话少说,直奔主题。
这里采用的是增加接口的方法,一共分为3步:
1.编写DLL
2.添加导入函数
3.修改和添加代码
1.编写DLL
实现全屏的代码如下:
.386
.model flat, stdcall
option casemap:none
include windows.inc
include user32.inc
include gdi32.inc
include kernel32.inc
includelib user32.lib
includelib gdi32.lib
includelib kernel32.lib
.data
szErrlWinMode db "set window window mode faild", 0
szErrlFullScr db "set window full screen mode faild", 0
szCaption db "Info",0
bIsFullMode dword FALSE
stOriginPos WINDOWPLACEMENT <0>
ESC_HOTKEY equ 1
F11_HOTKEY equ 2
.code
DllEntry proc _hInstance, _dwReason, _dwReserved
mov eax, TRUE
ret
DllEntry endp
SetFullScr proc _hWnd
local @hDC
local @dwHorzres
local @dwVertres
invoke GetWindowPlacement, _hWnd, addr stOriginPos
invoke GetWindowLong, _hWnd, GWL_STYLE
xor eax, WS_CAPTION
invoke SetWindowLong, _hWnd, GWL_STYLE, eax ;去掉标题栏
invoke GetDC, _hWnd
mov @hDC, eax
invoke GetDeviceCaps, @hDC, HORZRES
mov @dwHorzres, eax
invoke GetDeviceCaps, @hDC, VERTRES
mov @dwVertres, eax
xor eax, eax
invoke SetWindowPos, _hWnd, HWND_TOPMOST, eax, eax, @dwHorzres, @dwVertres, SWP_SHOWWINDOW ;全屏显示
ret
SetFullScr endp
SetWinMode proc _hWnd
xor eax, eax
invoke SetWindowPos, _hWnd, HWND_NOTOPMOST, eax, eax, eax, eax, SWP_NOSIZE ;添加此两行,修正bug
invoke GetWindowLong, _hWnd, GWL_STYLE
or eax, WS_CAPTION
invoke SetWindowLong, _hWnd, GWL_STYLE, eax ;恢复标题栏
invoke ShowWindow, _hWnd, SW_HIDE
invoke SetWindowPlacement, _hWnd, addr stOriginPos
ret
SetWinMode ENDP
SwitchMode proc _hWnd
.if bIsFullMode == TRUE
invoke SetWinMode, _hWnd
.IF eax==0
invoke MessageBox, _hWnd, addr szErrlWinMode, addr szCaption, MB_ICONERROR
ret
.ENDIF
mov bIsFullMode, FALSE
.else
invoke SetFullScr, _hWnd
.IF eax==0
invoke MessageBox, _hWnd, addr szErrlFullScr, addr szCaption, MB_ICONERROR
ret
.ENDIF
mov bIsFullMode, TRUE
.endif
ret
SwitchMode endp
WndProc proc C dwReserved, hWnd, uMsg, wParam, lParam
mov eax, uMsg
.if eax == WM_HOTKEY
.if wParam == ESC_HOTKEY && bIsFullMode == TRUE
invoke SwitchMode, hWnd
.elseif wParam == F11_HOTKEY && bIsFullMode == FALSE
invoke SwitchMode, hWnd
.endif
.elseif eax == WM_CREATE
invoke RegisterHotKey, hWnd, F11_HOTKEY, 0, VK_F11
invoke RegisterHotKey, hWnd, ESC_HOTKEY, 0, VK_ESCAPE
.elseif eax == WM_DESTROY
invoke UnregisterHotKey, hWnd, F11_HOTKEY
invoke UnregisterHotKey, hWnd, ESC_HOTKEY
.endif
ret
WndProc endp
end DllEntry
00435CDE . E8 69980700 call <jmp.&USER32.RegisterClassA> ; \RegisterClassA
00435C6A . C785 94F6FFFF>mov dword ptr [ebp-96C], OI.004323D4 ; 入口地址
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课