.586
.model flat,stdcall
option casemap:none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include windows.inc
include kernel32.inc
include gdi32.inc
include user32.inc
include mfmplayer.inc ;xm播放支持
includelib user32.lib
includelib kernel32.lib
includelib gdi32.lib
includelib user32.lib
includelib mfmplayer.lib ;xm播放支持庫(kù)
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
IDD_MAINDLG equ 1000
IDC_EDT1 equ 1003
IDC_EDT2 equ 1004
IDM_MUSIC equ 50 ;聲音資源
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Windowproc proto :HWND,:UINT,:WPARAM,:LPARAM
GetRegistKey proto
Color macro Red,Green,Blue ;宏,方便后面顏色設(shè)置
xor eax,eax
mov ah,Blue
shl eax,8
mov ah,Green
mov al,Red
endm
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data
String db 'Keygen Template with XM Music ',0dh,0ah
db ' ========================== ',0dh,0ah,0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data?
hInstance HINSTANCE ?
hWnd HINSTANCE ?
NameBuffer db 32 dup(?)
;音樂(lè)
nMusicSize DWORD ?
pMusic LPVOID ?
;滾動(dòng)字幕
hDc DWORD ?
hMemoryDc1 DWORD ?
hMemoryDc2 DWORD ?
hBrush DWORD ?
TextOutX DWORD ?
TextOutY DWORD ?
TextOutCY DWORD ?
LogFont LOGFONT <?>
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
start:
invoke GetModuleHandle,0
mov hInstance,eax
invoke DialogBoxParam,hInstance,IDD_MAINDLG,0,offset Windowproc,0
invoke ExitProcess,0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Windowproc PROC hWin:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
LOCAL hBitMapMDc:HDC
LOCAL ps:PAINTSTRUCT
LOCAL rect:RECT
LOCAL TextSizeCX:dword
LOCAL TextSizeCY:dword
mov eax,uMsg
.if eax == WM_PAINT
invoke BeginPaint,hWin,addr ps
mov hDc,eax
Color 0,0,0
invoke BitBlt,hDc,0h,0h,100h,40h,hMemoryDc1,0,0,eax ;將全黑位圖從設(shè)備場(chǎng)景hMemoryDc1復(fù)制到hDc
invoke EndPaint,hWin,addr ps
.elseif eax == WM_INITDIALOG
;---------------------------------------------------------- ;==加載音樂(lè),播放==
push esi
invoke FindResource,hInstance,IDM_MUSIC,RT_RCDATA ;在模塊中查找指定的資源,這里是xm文件
push eax
invoke SizeofResource,hInstance,eax
mov nMusicSize, eax
pop eax
invoke LoadResource,hInstance,eax
invoke LockResource,eax
mov esi,eax
mov eax,nMusicSize
add eax,sizeof nMusicSize
invoke GlobalAlloc,GPTR,eax
mov pMusic,eax
mov ecx,nMusicSize
mov dword ptr[eax],ecx
add eax,sizeof nMusicSize
mov edi,eax
rep movsb
pop esi
invoke mfmPlay,pMusic ;mfmPlay.lib中播放XM的函數(shù)
;----------------------------------------------------------- ;==實(shí)現(xiàn)滾動(dòng)字幕==
invoke SetTimer,hWin,200h,45h,NULL
invoke GetDC,hWin
mov hDc,eax
invoke CreateCompatibleDC,hDc ;創(chuàng)建作為大背景的內(nèi)存設(shè)備環(huán)境
mov hMemoryDc1,eax
invoke CreateCompatibleBitmap,hDc,100h,40h ;創(chuàng)建位圖,以供內(nèi)存設(shè)備環(huán)境調(diào)用作大背景
mov hBitMapMDc,eax
invoke SelectObject,hMemoryDc1,hBitMapMDc ;選入剛創(chuàng)建的位圖到內(nèi)存設(shè)備環(huán)境
Color 0,0,0 ;設(shè)置畫(huà)刷的顏色
invoke CreateSolidBrush,eax
mov hBrush,eax
mov rect.top,0h ;設(shè)置矩形大小
mov rect.left,0h
mov rect.right,100h
mov rect.bottom,100h
invoke FillRect,hMemoryDc1,addr rect,hBrush ;用畫(huà)刷以矩形大小填充內(nèi)大背景
invoke DeleteObject,hBrush
invoke CreateCompatibleDC,hDc ;創(chuàng)建一個(gè)帶文字的內(nèi)存設(shè)備
mov hMemoryDc2,eax
Color 255,0,0 ;設(shè)置字體顏色
invoke SetTextColor,hMemoryDc2,eax
invoke SetBkMode,hMemoryDc2,TRANSPARENT ;指定空隙的填充方式-TRANSPARENT-透明處理
invoke CreateFontIndirect,addr LogFont ;創(chuàng)建可以被選入的文字
invoke SelectObject,hMemoryDc2,eax
invoke CreateCompatibleBitmap,hDc,100h,80h ;可顯示的文字范圍
invoke SelectObject,hMemoryDc2,eax
Color 0,0,0 ;@1--設(shè)置畫(huà)刷的顏色
invoke CreateSolidBrush,eax
mov hBrush,eax
mov rect.top,0h ;設(shè)置矩形大小
mov rect.left,0h
mov rect.right,100h
mov rect.bottom,100h
invoke FillRect,hMemoryDc2,addr rect,hBrush ;填充文字背景,單色時(shí),從@1到這里的代碼可以不用
invoke DeleteObject,hBrush
mov TextOutX,22h
mov TextOutY,30h
lea esi,String
mov al,byte ptr [esi]
.while al
.if al == 0dh
add TextOutY,10h ;設(shè)置行間距
mov TextOutX,22h ;換行
add esi,2h
.else
invoke GetTextExtentPoint32,hMemoryDc2,esi,1,addr TextSizeCX
invoke TextOut,hMemoryDc2,TextOutX,TextOutY,esi,1h
mov eax,TextSizeCX
add TextOutX,eax
inc esi
.endif
mov al,byte ptr [esi]
.endw
invoke ReleaseDC,hWin,hDc
.elseif eax == WM_TIMER
invoke GetDC,hWin
mov hDc,eax
invoke BitBlt,hMemoryDc1,0h,8h,100h,40h,hMemoryDc2,0,TextOutCY,0cc0020h
inc TextOutCY
.if TextOutCY == 70h
mov TextOutCY,0
.endif
invoke BitBlt,hDc,0h,0h,100h,38h,hMemoryDc1,0,0,0cc0020h
invoke ReleaseDC,hWin,hDc
.elseif eax == WM_CLOSE
invoke EndDialog,hWin,0
invoke mfmPlay,0 ;停止音樂(lè)的播放
invoke GlobalFree, pMusic ;釋放背景音樂(lè)使用的內(nèi)存
.elseif eax == WM_COMMAND
mov eax,wParam
.if eax ==IDOK
push hWin
pop hWnd
invoke GetRegistKey ;自定義算碼函數(shù)
.endif
.else
mov eax,0
ret
.endif
mov eax,1
ret
Windowproc endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
GetRegistKey proc
invoke GetDlgItemText,hWnd,IDC_EDT1,offset NameBuffer,sizeof NameBuffer
invoke SetDlgItemText,hWnd,IDC_EDT2,addr NameBuffer
ret
GetRegistKey endp
end start
聯(lián)系客服