.386
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
include kernel32.inc
includelib user32.lib
includelib kernel32.lib
include gdi32.inc
includelib gdi32.lib
include Winmm.inc
includelib Winmm.lib
include comdlg32.inc
includelib comdlg32.lib
include comctl32.inc
includelib comctl32.lib
INCLUDE shell32.inc
includelib shell32.lib
IDI_ICON1 equ 104
IDI_ICON2 equ 105
IDC_CURSOR1 equ 106
IDR_MENU1 equ 101
IDR_ACCELERATOR1 equ 103
IDM_OPEN equ 40001
IDM_SAVE equ 40002
IDM_PRINT equ 40003
IDM_CLOSE equ 40004
IDM_FONT equ 40005
IDM_COLOR equ 40006
IDM_FIND equ 40007
IDM_REPLACE equ 40008
IDM_CONTROL equ 40009
IDM_TIMER equ 40010
IDM_SETFILETIME equ 40011
IDM_GETFILETIME equ 40012
IDM_GETFILESIZE equ 40013
IDM_B equ 40014
IDM_C equ 40015
IDM_ALTB equ 40016
IDM_ALTC equ 40017
IDM_GRAY equ 40018
IDM_UNABLE equ 40019
IDM_ENABLE equ 40020
IDM_CHECKED equ 40021
IDM_ICON1 equ 40022
IDM_ICON2 equ 40023
IDM_CURSOR1 equ 40024
IDM_CURSOR2 equ 40025
IDD_DIALOG1 equ 107
IDB_BITMAP1 equ 108
IDB_BITMAP2 equ 109
IDC_CHECK1 equ 1000
IDC_CHECK2 equ 1001
IDC_RADIO1 equ 1002
IDC_RADIO2 equ 1003
IDC_COMBO1 equ 1004
IDC_EDIT1 equ 1005
IDC_INFORMATION equ 1006
IDC_CUSTOM1 equ 1007
IDC_NUM equ 1008
IDC_BUTTON1 equ 1009
IDC_BUTTON2 equ 1010
IDC_LIST1 equ 1011
IDC_LIST2 equ 1012
IDC_BUTTON3 equ 1013
IDC_BUTTON4 equ 1014
IDC_BITMAP equ 1015
IDR_UWMA1 equ 110
IDM_SUB equ 40026
IDM_SUPER equ 40027
IDD_DIALOG2 EQU 111
IDC_EDIT2 equ 1006
IDD_DIALOG3 equ 112
IDC_USER1 equ 1016
IDC_USER2 equ 1017
IDC_USER3 equ 1018
IDM_WEB equ 40034
IDM_MAILTO equ 40035
IDM_DIRECTORY equ 40036
IDM_RUN equ 40037
IDM_PROCESS equ 40038
IDM_CLOSEPROCESS equ 40039
IDM_RUN2 equ 40040
IDM_OPENPROCESS equ 40041
IDM_SNAPSHOT equ 40042
IDM_TEMP equ 40043
IDM_CURRENT equ 40044
IDM_WINDOWS equ 40045
IDD_DIALOG4 equ 113
IDD_DIALOG5 equ 114
_PROCVAR2 typedef proto :DWORD,:DWORD
_PROCVAR0 typedef proto
PROCVAR2 typedef ptr _PROCVAR2
PROCVAR0 typedef ptr _PROCVAR0
.data?
hInstance dword ?
hWinMain dword ?
hAccelerator dword ?
hMenu dword ?
hSubMenu dword ?
hSysMenu dword ?
hIcon1 dword ?
hIcon2 dword ?
hCur1 dword ?
hCur2 dword ?
szBuf byte 1024 dup(?)
szBuf2 byte 1024 dup(?)
szBuf3 byte 1024 dup(?)
hBit1 dword ?
hBit2 dword ?
dwPos dword ?
ID_TIME1 equ 1
ID_TIME2 equ 2
ID_TIME3 equ 3
dwTime dword ?
stTime SYSTEMTIME <?>
hResource dword ?
stFindReplace FINDREPLACE <?>
uvMsg dword ?
szFile byte MAX_PATH DUP(?)
dwColor dword ?
stLogFONT LOGFONT <?>
hStatus dword ?
stFileTime FILETIME <?>
hEdit1 dword ?
lpOldProc dword ?
hFile dword ?
hMap dword ?
lpView dword ?
hWndEdit dword ?
lpInstall PROCVAR2 ?
lpUninstall PROCVAR0 ?
hDll dword ?
WM_HOOK EQU WM_USER+200H
szAscii byte 4 dup(?)
hThread dword ?
hThread2 DWORD ?
hProcess dword ?
dwProcess dword ?
stStartup STARTUPINFO <?>
stProcess PROCESS_INFORMATION <?>
hEvent dword ?
stProcessEntry PROCESSENTRY32 <?>
hSnapshot dword ?
.data
szClassName byte 'classanem',0
szTitle byte 'title',0
szCur2 byte '1.ANI',0
szKey byte '按下的值是%08x',0
szUser byte '自定义',0
szPath byte '*.*',0
szAll byte '你选择的有如下几项:'
szEnter byte 0dh,0ah,0
szTimer byte '%02d:%02d:%02d',0
szType byte 'UWMA',0
szFINDTEXT byte 'commdlg_FindReplace',0
szFilter byte 'all txt doc',0,'*.txt;*.doc',0,'all',0,'*.*',0,0
szDef byte 'txt',0
szFont byte '选择的字体是%s 大小是%d 字体颜色是%08x',0
szColor byte '你选择的颜色是%d',0
CustColor dword 16 dup(?)
szPart dword 40,150,170,-1
szChar byte '0123456789abcdefABCDEF',0
szClass byte 'HEXINT',0
szEdit byte 'EDIT',0
szText byte '1.txt',0
szDll byte 'hook.dll',0
szInstall byte 'InstallHook',0
szUninstall byte 'UninstallHook',0
szNumThread byte '数值:%d',0
szStillThread byte '线程正在运行状态,将被强行终止',0
szNoStill byte '线程已经终止,不能再进行操作,线程退出码是%d',0
szWeb byte 'http://user.qzone.qq.com/37261550',0
szExplore byte 'explore',0
szMailto byte 'mailto:37261550@qq.com',0
szCurrent byte '1.exe',0
szErr1 byte '打开窗口句柄失败',0
szErr2 byte '打开进程失败,权限不够',0
.code
_message proc _wParam
pushad
invoke wsprintf,offset szBuf,offset szKey,_wParam
invoke MessageBox,hWinMain,offset szBuf,0,MB_OK
popad
ret
_message endp
_timeu proc hWnd,uMsg,_id,_time
mov eax,_id
.if eax==dwTime
;invoke _message,_id
.elseif eax==ID_TIME2
;invoke _message,_id
.endif
ret
_timeu endp
_diaProc proc uses ebx esi edi hWnd,uMsg,wParam,lParam
local @dwCount
mov eax,uMsg
.if eax==WM_INITDIALOG
;invoke CheckDlgButton,hWnd,IDC_CHECK1,BST_CHECKED
invoke CheckDlgButton,hWnd,IDC_CHECK2,BST_CHECKED
invoke CheckRadioButton,hWnd,IDC_RADIO1,IDC_RADIO2,IDC_RADIO1
;invoke SendDlgItemMessage,hWnd,IDC_CHECK1,BM_GETCHECK,0,0
;invoke CheckDlgButton,hWnd,IDC_CHECK2,EAX
invoke SendDlgItemMessage,hWnd,IDC_EDIT1,EM_SETLIMITTEXT,10,0
invoke SendDlgItemMessage,hWnd,IDC_EDIT1,EM_SETREADONLY,TRUE,0
invoke SendDlgItemMessage,hWnd,IDC_COMBO1,CB_ADDSTRING,0,addr szClassName
invoke SendDlgItemMessage,hWnd,IDC_COMBO1,CB_SETITEMDATA,eax,1
invoke SendDlgItemMessage,hWnd,IDC_COMBO1,CB_ADDSTRING,0,addr szTitle
invoke SendDlgItemMessage,hWnd,IDC_COMBO1,CB_SETITEMDATA,eax,2
invoke SendDlgItemMessage,hWnd,IDC_COMBO1,CB_ADDSTRING,0,addr szUser
invoke SendDlgItemMessage,hWnd,IDC_COMBO1,CB_SETITEMDATA,eax,3
invoke SendDlgItemMessage,hWnd,IDC_COMBO1,CB_SETCURSEL,0,0
invoke LoadBitmap,hInstance,IDB_BITMAP1
mov hBit1,eax
invoke SendDlgItemMessage,hWnd,IDC_BITMAP,STM_SETIMAGE,IMAGE_BITMAP,eax
invoke LoadBitmap,hInstance,IDB_BITMAP2
mov hBit2,eax
invoke SendDlgItemMessage,hWnd,IDC_LIST1,LB_ADDSTRING,0,addr szClassName
invoke SendDlgItemMessage,hWnd,IDC_LIST1,LB_SETITEMDATA,eax,1
invoke SendDlgItemMessage,hWnd,IDC_LIST1,LB_ADDSTRING,0,addr szTitle
invoke SendDlgItemMessage,hWnd,IDC_LIST1,LB_SETITEMDATA,eax,2
invoke SendDlgItemMessage,hWnd,IDC_LIST1,LB_ADDSTRING,0,addr szUser
invoke SendDlgItemMessage,hWnd,IDC_LIST1,LB_SETITEMDATA,eax,3
invoke SendDlgItemMessage,hWnd,IDC_LIST2,LB_DIR,DDL_DRIVES OR DDL_ARCHIVE ,addr szPath
;invoke SendDlgItemMessage,hWnd,IDC_LIST2,LB_RESETCONTENT,0,0;清除所有
invoke SendDlgItemMessage,hWnd,IDC_CUSTOM1,SBM_SETRANGE,0,100
invoke SetTimer,hWnd,ID_TIME1,1000,NULL ;1
invoke SetTimer,hWnd,ID_TIME3,2000,NULL ;1
invoke SetTimer,NULL,NULL,1000,addr _timeu ;2
mov dwTime,eax
invoke SetTimer,hWnd,ID_TIME2,4000,addr _timeu ;2
invoke FindResource,hInstance,IDR_UWMA1,addr szType
.if eax
mov hResource,eax
invoke SizeofResource,hMenu,hResource
invoke LoadResource,hInstance,hResource
.if eax
invoke LockResource,eax
invoke sndPlaySound,eax,SND_ASYNC OR SND_MEMORY
;invoke _message,wParam
.ENDIF
.endif
.elseif eax==WM_COMMAND
mov eax,wParam
.if ax==IDC_CHECK1
invoke IsDlgButtonChecked,hWnd,IDC_CHECK1
.if eax==BST_CHECKED
invoke SetWindowPos,hWnd,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE OR SWP_NOMOVE
.else
invoke SetWindowPos,hWnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOSIZE OR SWP_NOMOVE
.endif
.elseif ax==IDC_CHECK2
invoke IsDlgButtonChecked,hWnd,IDC_CHECK2
.if eax==BST_CHECKED
invoke GetDlgItem,hWnd,IDC_BITMAP
invoke ShowWindow,eax,SW_SHOW
.else
invoke GetDlgItem,hWnd,IDC_BITMAP
invoke ShowWindow,eax,SW_HIDE
.endif
.elseif ax==IDC_RADIO1
invoke GetDlgItem,hWnd,IDC_BUTTON1
invoke ShowWindow,eax,SW_SHOW
.elseif ax==IDC_RADIO2
invoke GetDlgItem,hWnd,IDC_BUTTON1
INVOKE ShowWindow,eax,SW_HIDE
.elseif ax==IDC_EDIT1
invoke GetDlgItemText,hWnd,IDC_EDIT1,addr szBuf,sizeof szBuf
invoke SetWindowText,hWnd,addr szBuf
.elseif ax==IDC_COMBO1
shr eax,16
.if eax==CBN_SELENDOK
invoke SendDlgItemMessage,hWnd,IDC_COMBO1,CB_GETCURSEL,0,0
mov ebx,eax
invoke SendDlgItemMessage,hWnd,IDC_COMBO1,CB_GETLBTEXT,eax,addr szBuf
invoke SendDlgItemMessage,hWnd,IDC_COMBO1,CB_GETITEMDATA,ebx,0
.if eax==3
invoke SendDlgItemMessage,hWnd,IDC_EDIT1,EM_SETREADONLY,FALSE,0
.else
invoke SetDlgItemText,hWnd,IDC_INFORMATION,addr szBuf
invoke SetWindowText,hWnd,addr szBuf
invoke SendDlgItemMessage,hWnd,IDC_EDIT1,EM_SETREADONLY,TRUE,0
invoke SendDlgItemMessage,hWnd,IDC_COMBO1,CB_GETITEMDATA,ebx,0
invoke SetDlgItemInt,hWnd,IDC_EDIT1,eax,FALSE
.endif
.endif
.elseif ax==IDC_BUTTON1
mov eax,hBit1
xchg hBit2,eax
mov hBit1,eax
invoke SendDlgItemMessage,hWnd,IDC_BITMAP,STM_SETIMAGE,IMAGE_BITMAP,hBit1
.elseif ax==IDC_BUTTON2
invoke DeleteObject,hBit1
invoke DeleteObject,hBit2
invoke EndDialog,hWnd,NULL
.elseif ax==IDC_BUTTON3
invoke SendDlgItemMessage,hWnd,IDC_LIST2,LB_GETSELCOUNT,0,0
mov @dwCount,eax
invoke SendDlgItemMessage,hWnd,IDC_LIST2,LB_GETSELITEMS,50,addr szBuf2
invoke lstrcpy,offset szBuf,offset szAll
mov esi,offset szBuf2
cld
.while @dwCount
lodsd
invoke SendDlgItemMessage,hWnd,IDC_LIST2,LB_GETTEXT,eax,addr szBuf3
invoke lstrcat,offset szBuf,offset szBuf3
invoke lstrcat,offset szBuf,offset szEnter
dec @dwCount
.endw
invoke MessageBox,hWnd,addr szBuf,0,MB_OK
.elseif ax==IDC_BUTTON4
invoke SendDlgItemMessage,hWnd,IDC_LIST2,LB_SETSEL,TRUE,-1
.elseif ax==IDC_LIST1
shr eax,16
.if eax==LBN_DBLCLK
invoke SendDlgItemMessage,hWnd,IDC_LIST1,LB_GETCURSEL,0,0
invoke SendDlgItemMessage,hWnd,IDC_LIST1,LB_GETTEXT,eax,addr szBuf
invoke MessageBox,hWnd,addr szBuf,0,MB_OK
.elseif eax==LBN_SELCHANGE
invoke SendDlgItemMessage,hWnd,IDC_LIST1,LB_GETCURSEL,0,0
invoke SendDlgItemMessage,hWnd,IDC_LIST1,LB_GETITEMDATA,eax,0
invoke SetDlgItemInt,hWnd,IDC_INFORMATION,eax,FALSE
.endif
.endif
.elseif eax==WM_HSCROLL
invoke KillTimer,hWnd,ID_TIME2
mov ebx,lParam
invoke GetDlgItem,hWnd,IDC_CUSTOM1
.if eax==ebx
mov eax,wParam
.if ax==SB_LINELEFT
dec dwPos
.elseif ax==SB_PAGELEFT
sub dwPos,10
.elseif ax==SB_LINERIGHT
inc dwPos
.elseif ax==SB_PAGERIGHT
add dwPos,10
.elseif ax==SB_THUMBPOSITION || ax==SB_THUMBTRACK
SHR eax,16
mov dwPos,eax
.endif
cmp dwPos,0
jge @F
mov dwPos,0
@@:
cmp dwPos,100
jle @F
mov dwPos,100
@@:
invoke SendDlgItemMessage,hWnd,IDC_CUSTOM1,SBM_SETPOS,dwPos,TRUE
invoke SetDlgItemInt,hWnd,IDC_NUM,dwPos,FALSE
.endif
.elseif eax==WM_TIMER
mov eax,wParam
.if eax==ID_TIME1
invoke GetLocalTime,offset stTime
movzx eax,stTime.wHour
movzx ebx,stTime.wMinute
movzx ecx,stTime.wSecond
invoke wsprintf,offset szBuf,offset szTimer,eax,ebx,ecx
invoke SetDlgItemText,hWnd,IDC_INFORMATION,addr szBuf
.elseif eax==ID_TIME3
invoke MessageBeep,MB_ABORTRETRYIGNORE
.endif
.elseif eax==WM_CLOSE
invoke KillTimer,hWnd,ID_TIME1
invoke KillTimer,hWnd,ID_TIME3
invoke KillTimer,hWnd,ID_TIME2
invoke KillTimer,NULL,dwTime
invoke DeleteObject,hBit1
invoke DeleteObject,hBit2
invoke EndDialog,hWnd,NULL
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
_diaProc endp
_open proc
local @st:OPENFILENAME
invoke RtlZeroMemory,addr @st,sizeof @st
mov @st.lStructSize,sizeof @st
push hWinMain
pop @st.hwndOwner
mov @st.Flags,OFN_FILEMUSTEXIST OR OFN_PATHMUSTEXIST
mov @st.lpstrFilter,offset szFilter
mov @st.lpstrFile,offset szFile
mov @st.nMaxFile,sizeof szFile
mov @st.lpstrTitle,offset szAll
invoke GetOpenFileName,addr @st
.if eax
invoke MessageBox,hWinMain,addr szFile,0,MB_OK
.endif
ret
_open endp
_save proc
LOCAL @st:OPENFILENAME
invoke RtlZeroMemory,addr @st,sizeof @st
mov @st.lStructSize,sizeof @st
push hWinMain
pop @st.hwndOwner
mov @st.Flags,OFN_PATHMUSTEXIST
mov @st.lpstrFilter,offset szFilter
mov @st.lpstrFile,offset szFile
mov @st.nMaxFile,sizeof szFile
mov @st.lpstrDefExt,offset szDef
invoke GetSaveFileName,addr @st
.if eax
invoke MessageBox,hWinMain,addr szFile,0,MB_OK
.endif
ret
_save endp
_font proc
local @st:CHOOSEFONTA
invoke RtlZeroMemory,addr @st,sizeof @st
mov @st.lStructSize,sizeof @st
push hWinMain
pop @st.hwndOwner
push dwColor
pop @st.rgbColors
mov @st.Flags,CF_INITTOLOGFONTSTRUCT or CF_SCREENFONTS or CF_EFFECTS
mov @st.lpLogFont,offset stLogFONT
invoke ChooseFont,addr @st
.if eax
mov ebx,@st.iPointSize
shl ebx,1
push @st.rgbColors
pop dwColor
invoke wsprintf,offset szBuf,offset szFont,offset stLogFONT.lfFaceName,ebx,dwColor
invoke MessageBox,hWinMain,offset szBuf,0,MB_OK
.endif
ret
_font endp
_color proc
local @st:CHOOSECOLORA
invoke RtlZeroMemory,addr @st,sizeof @st
mov @st.lStructSize,sizeof @st
push hWinMain
pop @st.hwndOwner
push dwColor
pop @st.rgbResult
mov @st.lpCustColors,offset CustColor
mov @st.Flags,CC_RGBINIT or CC_FULLOPEN
invoke ChooseColor,addr @st
.if eax
push @st.rgbResult
pop dwColor
invoke wsprintf,offset szBuf,offset szColor,dwColor
invoke MessageBox,hWinMain,offset szBuf,0,MB_OK
.endif
ret
_color endp
_edit proc uses ebx esi edi hWnd,uMsg,wParam,lParam
mov eax,uMsg
.if eax==WM_CHAR
mov eax,wParam
mov edi,offset szChar
cld
mov ecx,sizeof szChar
repnz scasb
.if ZERO?
cmp al,'9'
jbe @F
and al,11011111B
@@:
invoke CallWindowProc,lpOldProc,hWnd,uMsg,eax,lParam
.endif
.else
invoke CallWindowProc,lpOldProc,hWnd,uMsg,wParam,lParam
ret
.endif
ret
_edit endp
_diaProc2 proc uses ebx esi edi hWnd,uMsg,wParam,lParam
mov eax,uMsg
.if eax==WM_INITDIALOG
invoke GetDlgItem,hWnd,IDC_EDIT1
mov hEdit1,eax
invoke SetWindowLong,eax,GWL_WNDPROC,addr _edit
mov lpOldProc,eax
.elseif eax==WM_COMMAND
mov eax,wParam
.if !dwPos
mov dwPos,0
.if ax==IDC_EDIT1
;invoke _message,wParam
.elseif ax==IDC_EDIT2
;invoke _message,wParam
.endif
inc dwPos
.endif
.elseif eax==WM_CLOSE
invoke EndDialog,hWnd,NULL
.else
mov eax,FALSE
RET
.endif
mov eax,TRUE
ret
_diaProc2 endp
_diaProc3 proc uses ebx esi edi hWnd,uMsg,wParam,lParam
mov eax,uMsg
.if eax==WM_INITDIALOG
.elseif eax==WM_CLOSE
invoke EndDialog,hWnd,NULL
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
_diaProc3 endp
_reSize proc
local @stRect:RECT,@stRect1:RECT
pushad
invoke MoveWindow,hStatus,0,0,0,0,TRUE;状态栏不需要设置宽度位置,它会自己调整
invoke GetWindowRect,hStatus,addr @stRect
invoke GetClientRect,hWinMain,addr @stRect1
mov ebx,@stRect1.right
sub ebx,@stRect1.left
mov ecx,@stRect1.bottom
sub ecx,@stRect1.top
mov edx,@stRect.bottom
sub edx,@stRect.top
sub ecx,edx
invoke MoveWindow,hWndEdit,0,0,ebx,ecx,TRUE
popad
ret
_reSize endp
_thread proc uses ebx esi edi _lParam
.while TRUE
invoke WaitForSingleObject,hEvent,INFINITE
inc dwPos
invoke wsprintf,addr szBuf,addr szNumThread,dwPos
invoke SendMessage,hStatus,SB_SETTEXT,3,addr szBuf
invoke SetEvent,hEvent
.endw
ret
_thread endp
_diaProc4 proc uses ebx esi edi hWnd,uMsg,wParam,lParam
local @processId,@hwnd
mov eax,uMsg
.if eax==WM_INITDIALOG
.elseif eax==WM_COMMAND
mov eax,wParam
.if ax==IDC_BUTTON1
invoke GetDlgItemText,hWnd,IDC_EDIT1,addr szBuf,sizeof szBuf
.if eax==0
INVOKE _message,wParam
.else
invoke FindWindow,NULL,offset szBuf
.if eax
mov @hwnd,eax
invoke GetWindowThreadProcessId,@hwnd,addr @processId
invoke OpenProcess,PROCESS_TERMINATE,FALSE,@processId;注意这里不是指针。上面才是指针
.if eax
mov ebx,eax
invoke TerminateProcess,eax,-1
invoke CloseHandle,ebx
.else
invoke MessageBox,hWnd,addr szErr2,0,MB_OK
.endif
.else
invoke MessageBox,hWnd,addr szErr1,0,MB_OK
.endif
.endif
.elseif ax==IDC_EDIT1
invoke GetDlgItemText,hWnd,IDC_EDIT1,addr szBuf,sizeof szBuf
.endif
.elseif eax==WM_CLOSE
invoke EndDialog,hWnd,NULL
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
_diaProc4 endp
_list proc hWnd
invoke SendDlgItemMessage,hWnd,IDC_LIST1,LB_RESETCONTENT,0,0
invoke CreateToolhelp32Snapshot,TH32CS_SNAPPROCESS,NULL
mov hSnapshot,eax
mov stProcessEntry.dwSize,sizeof stProcessEntry
invoke Process32First,hSnapshot,offset stProcessEntry
.while eax
invoke SendDlgItemMessage,hWnd,IDC_LIST1,LB_ADDSTRING,0,addr stProcessEntry.szExeFile
invoke SendDlgItemMessage,hWnd,IDC_LIST1,LB_SETITEMDATA,EAX,stProcessEntry.th32ProcessID
invoke Process32Next,hSnapshot,offset stProcessEntry
.endw
invoke CloseHandle,hSnapshot
ret
_list endp
_diaProc5 proc uses ebx esi edi hWnd,uMsg,wParam,lParam
mov eax,uMsg
.if eax==WM_INITDIALOG
invoke _list,hWnd
.elseif eax==WM_COMMAND
mov eax,wParam
.if ax==IDC_BUTTON1
invoke _list,hWnd
.elseif ax==IDC_BUTTON2
invoke SendDlgItemMessage,hWnd,IDC_LIST1,LB_GETCURSEL,0,0
invoke SendDlgItemMessage,hWnd,IDC_LIST1,LB_GETITEMDATA,EAX,0
invoke OpenProcess,PROCESS_ALL_ACCESS,FALSE,eax
.if eax
invoke TerminateProcess,eax,-1
.else
.endif
.endif
.elseif eax==WM_CLOSE
invoke EndDialog,hWnd,NULL
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
_diaProc5 endp
_wndProc proc uses ebx esi edi hWnd,uMsg,wParam,lParam
local @pt:POINT,@rect:RECT,@wc:WNDCLASSEX,@dwThread
local @l1,@l2,@l3,@h1,@h2,@h3
mov eax,uMsg
.if eax==WM_CLOSE
invoke CloseHandle,hEvent
INVOKE lpUninstall
invoke FreeLibrary,hDll
invoke UnmapViewOfFile,lpView
invoke CloseHandle,hMap
invoke DestroyWindow,hWnd
invoke PostQuitMessage,-1
.elseif eax==WM_COMMAND
;invoke _message,wParam
mov eax,wParam
.if ax==IDM_CHECKED
invoke GetMenuState,hMenu,IDM_CHECKED,MF_BYCOMMAND
.if eax==MF_CHECKED
mov eax,MF_UNCHECKED
.else
mov eax,MF_CHECKED
.endif
invoke CheckMenuItem,hMenu,IDM_CHECKED,EAX
.elseif ax==IDM_SUB
invoke DialogBoxParam,hInstance,IDD_DIALOG2,hWnd,addr _diaProc2,NULL
.elseif ax==IDM_SUPER
mov @wc.cbSize,sizeof @wc;首先要初始化这个结构大小
invoke GetClassInfoEx,NULL,addr szEdit,addr @wc;再取edit类的结构,如果是系统则此则数为null
push @wc.lpfnWndProc
pop lpOldProc;保存类原来的过程。我们这里超类化只是改更过程别的不做
mov @wc.lpfnWndProc,offset _edit
push hInstance
pop @wc.hInstance;子类化完成后必须更改hInstance和lpszClassName
mov @wc.lpszClassName,offset szClass
invoke RegisterClassEx,addr @wc;只需要注册。CreateWindowEx部份对话框自己完成,
;invoke CreateWindowEx,NULL,addr @wc,addr szTitle,WS_VISIBLE OR WS_CHILD,0,0,100,50,hWnd,NULL,hInstance,NULL
invoke DialogBoxParam,hInstance,IDD_DIALOG3,hWnd,addr _diaProc3,NULL
.elseif ax==IDM_TIMER;创建线程
invoke SetEvent,hEvent
invoke CreateThread,NULL,0,addr _thread,NULL,NULL,addr @dwThread
mov hThread,eax
invoke CreateThread,NULL,0,addr _thread,NULL,NULL,addr @dwThread
mov hThread2,eax
.elseif ax==IDM_SETFILETIME;暂停线程
invoke GetExitCodeThread,hThread,addr dwColor
.if dwColor==STILL_ACTIVE
invoke SuspendThread,hThread
invoke SuspendThread,hThread2
.ELSE
invoke wsprintf,addr szBuf3,addr szNoStill,dwColor
invoke MessageBox,hWnd,addr szBuf3,0,MB_OK
.ENDIF
.elseif ax==IDM_GETFILETIME;继续线程
.if dwColor==STILL_ACTIVE
invoke ResumeThread,hThread
invoke ResumeThread,hThread2
.ELSE
invoke wsprintf,addr szBuf3,addr szNoStill,dwColor
invoke MessageBox,hWnd,addr szBuf3,0,MB_OK
.ENDIF
.elseif ax==IDM_GETFILESIZE;终止线程
invoke GetExitCodeThread,hThread,addr dwColor
.if dwColor==STILL_ACTIVE
invoke MessageBox,hWnd,addr szStillThread,0,MB_OK
invoke TerminateThread,hThread,-1
invoke TerminateThread,hThread2,-1
.else
invoke wsprintf,addr szBuf3,addr szNoStill,dwColor
invoke MessageBox,hWnd,addr szBuf3,0,MB_OK
.endif
.elseif ax==IDM_WEB
invoke ShellExecute,NULL,NULL,addr szWeb,NULL,NULL,SW_SHOW
.elseif ax==IDM_MAILTO
invoke ShellExecute,NULL,NULL,offset szMailto,NULL,NULL,SW_SHOW
.elseif ax==IDM_RUN
INVOKE WinExec,offset szCurrent,SW_SHOW
.elseif ax==IDM_RUN2
invoke ShellExecute,NULL,NULL,offset szCurrent,NULL,NULL,SW_SHOW
.elseif ax==IDM_DIRECTORY
invoke GetSystemDirectory,offset szBuf2,sizeof szBuf2
invoke ShellExecute,hWnd,offset szExplore,offset szBuf2,NULL,NULL,SW_SHOW
.elseif ax==IDM_TEMP
INVOKE GetTempPath,sizeof szBuf2,offset szBuf2
invoke ShellExecute,NULL,offset szExplore,offset szBuf2,NULL,NULL,SW_SHOW
.elseif ax==IDM_CURRENT
INVOKE GetCurrentDirectory,sizeof szBuf2,offset szBuf2
invoke ShellExecute,NULL,offset szExplore,offset szBuf2,NULL,NULL,SW_SHOW
.elseif ax==IDM_WINDOWS
INVOKE GetWindowsDirectory,offset szBuf2,sizeof szBuf2
invoke ShellExecute,NULL,offset szExplore,offset szBuf2,NULL,NULL,SW_SHOW
.elseif ax==IDM_PROCESS
invoke GetStartupInfo,offset stStartup
invoke CreateProcess,NULL,offset szCurrent,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,offset stStartup,offset stProcess
.if !eax
invoke _message,wParam
.endif
.elseif ax==IDM_CLOSEPROCESS
invoke TerminateProcess,stProcess.hProcess,0
.if !eax
invoke _message,wParam
.endif
invoke CloseHandle,stProcess.hProcess
invoke CloseHandle,stProcess.hThread
.elseif ax==IDM_OPENPROCESS
invoke DialogBoxParam,hInstance,IDD_DIALOG4,hWnd,addr _diaProc4,NULL
.elseif ax==IDM_SNAPSHOT
invoke DialogBoxParam,hInstance,IDD_DIALOG5,hWnd,addr _diaProc5,NULL
.elseif ax==IDM_OPEN
call _open
.elseif ax==IDM_SAVE
call _save
.elseif ax==IDM_FONT
call _font
.elseif ax==IDM_COLOR
call _color
.elseif ax==IDM_REPLACE
invoke ReplaceText,offset stFindReplace
.elseif ax==IDM_FIND
invoke FindText,offset stFindReplace
.elseif ax==IDM_B || AX==IDM_C || AX==IDM_ALTB || AX==IDM_ALTC
invoke _message,wParam
.elseif ax==IDM_ICON1 || AX==IDM_ICON2
mov eax,hIcon1
xchg hIcon2,eax
mov hIcon1,eax
invoke SendMessage,hWinMain,WM_SETICON,ICON_BIG,hIcon1
;invoke _message,wParam
invoke CheckMenuRadioItem,hMenu,IDM_ICON1,IDM_ICON2,IDM_ICON2,MF_BYCOMMAND
.elseif ax==IDM_CURSOR1 || AX==IDM_CURSOR2
mov eax,hCur1
xchg hCur2,eax
mov hCur1,eax
invoke SetClassLong,hWinMain,GCL_HCURSOR,hCur1
.elseif ax==IDM_CONTROL
invoke DialogBoxParam,hInstance,IDD_DIALOG1,hWnd,addr _diaProc,NULL
.elseif ax==IDM_GETFILETIME
;invoke GetFileTime,hFile,addr stFileTime,NULL,NULL;前面的hFile需要自己去取一个文件句柄。这里就不写了
;invoke FileTimeToSystemTime,addr stFileTime,addr stTime
.elseif ax==IDM_SETFILETIME
;invoke SystemTimeToFileTime,addr stTime,addr stFileTime
;invoke SetFileTime,hFile,addr stFileTime,NULL,NULL
.elseif ax==IDM_GETFILESIZE
;invoke GetFileSize,hFile,NULL;
.endif
.elseif eax==uvMsg
.if stFindReplace.Flags & FR_FINDNEXT
invoke _message,wParam
.elseif stFindReplace.Flags & FR_REPLACE
invoke _message,wParam
.elseif stFindReplace.Flags & FR_REPLACEALL
invoke _message,wParam
.ENDIF
.elseif eax==WM_SIZE
CALL _reSize
.elseif eax==WM_NOTIFY
mov eax,wParam
.if ax==1
mov al,[ebp+1]
mov bl,[ebp+3]
mov bl,[ebp+20]
lea eax,lParam
mov ebx,lParam
assume ebx:ptr NMHDR
mov eax,[ebx].hwndFrom
.if eax==hStatus
;invoke _message,wParam
invoke GetClientRect,hStatus,addr @rect
invoke GetCursorPos,addr @pt
mov eax,@rect.left
mov ebx,eax
add eax,40
add ebx,150
.if @pt.x>eax && @pt.x<ebx
invoke _message,wParam
.endif
.endif
assume ebx:nothing
.endif
.elseif eax==WM_HOOK
mov eax,wParam
.if al==0dh
mov ax,0a0dh
.endif
mov dword ptr szAscii,eax
invoke SendMessage,hWndEdit,EM_REPLACESEL,TRUE,addr szAscii
;INVOKE MessageBox,hWnd,addr szAscii,0,MB_OK
.elseif eax==WM_CREATE
invoke CreateEvent,NULL,FALSE,FALSE,NULL
mov hEvent,eax
invoke SetEvent,hEvent
invoke LoadLibrary,offset szDll
.if eax
mov hDll,eax
invoke GetProcAddress,hDll,offset szInstall
mov lpInstall,eax
invoke GetProcAddress,hDll,offset szUninstall
mov lpUninstall,eax
invoke lpInstall,hWnd,WM_HOOK
.endif
invoke CreateWindowEx,WS_EX_CLIENTEDGE,offset szEdit,NULL,WS_VISIBLE OR WS_CHILD OR ES_MULTILINE OR ES_WANTRETURN OR WS_VSCROLL OR ES_AUTOHSCROLL,0,0,0,0,hWnd,1,hInstance,NULL
mov hWndEdit,eax
CALL _reSize
invoke GlobalAlloc,GMEM_FIXED OR GMEM_ZEROINIT,1000;固定内存块
mov @l1,eax
invoke lstrcpy,@l1,offset szFont
;invoke MessageBox,hWnd,@l1,0,MB_OK
invoke GlobalFree,@l1
invoke GlobalReAlloc,@l1,2000,GMEM_MOVEABLE OR GMEM_ZEROINIT
mov @l1,eax
;invoke lstrcpy,@l1,offset szFont
;invoke MessageBox,hWnd,@l1,0,MB_OK
invoke GlobalAlloc,GMEM_MOVEABLE OR GMEM_ZEROINIT,1000;移动内存块
mov @h1,eax
;invoke GlobalAlloc,GMEM_FIXED OR GMEM_ZEROINIT,1000;这里有了这段,下面的将会是失败的,因为数据将要移动,地址会改变
invoke GlobalReAlloc,@h1,20000,GMEM_MOVEABLE OR GMEM_ZEROINIT
mov @h2,eax
invoke GlobalLock,@h2
mov @l2,eax
;invoke GlobalLock,@h1
;mov @l1,eax
;invoke wsprintf,@l1,offset szColor,@l1
;invoke MessageBox,hWnd,@l1,0,MB_OK
;invoke wsprintf,@l2,offset szColor,@l2
;invoke MessageBox,hWnd,@l2,0,MB_OK
invoke GlobalFree,@h2
invoke GlobalAlloc,GMEM_MOVEABLE OR GMEM_ZEROINIT OR GMEM_DISCARDED,1000;可丢弃内存块,如果内存不足将会被丢弃
invoke GlobalFree,eax
invoke HeapCreate,HEAP_NO_SERIALIZE OR HEAP_GENERATE_EXCEPTIONS,200,1000;创建堆
.if eax && (eax<0c0000000H);因为上面指定了产生失败的原因
mov @h1,eax
.endif
invoke HeapAlloc,@h1,HEAP_ZERO_MEMORY,200
mov @l1,eax
invoke wsprintf,@l1,offset szColor,@l1
;invoke MessageBox,hWnd,@l1,0,MB_OK
invoke HeapAlloc,@h1,HEAP_ZERO_MEMORY,200
mov @l2,eax
invoke HeapReAlloc,@h1,HEAP_ZERO_MEMORY,@l1,500
mov @l1,eax
;invoke wsprintf,@l1,offset szColor,@l1
;invoke MessageBox,hWnd,@l1,0,MB_OK ;移动扩大后的内存数据中的数据是不会变的。
;invoke wsprintf,@l2,offset szColor,@l2
;invoke MessageBox,hWnd,@l2,0,MB_OK
invoke HeapFree,@h1,HEAP_NO_SERIALIZE,@l1
invoke HeapFree,@h1,HEAP_NO_SERIALIZE,@l2
invoke HeapDestroy,@h1
invoke VirtualAlloc,NULL,40960,MEM_RESERVE,PAGE_NOACCESS;保存一块内存块
mov @l1,eax
invoke VirtualAlloc,@l1,4096,MEM_COMMIT,PAGE_READWRITE;提交内存
mov @l2,eax
;invoke wsprintf,@l2,offset szColor,@l2
;invoke MessageBox,hWnd,@l2,0,MB_OK
;invoke VirtualProtect,@l2,4096,PAGE_READONLY,addr dwColor;这里把虚拟内存页改为了只读,下面的读句就会出错
;invoke wsprintf,@l2,offset szColor,@l2
;invoke MessageBox,hWnd,@l2,0,MB_OK
invoke VirtualFree,@l2,4096,MEM_DECOMMIT
invoke VirtualFree,@l1,40960,MEM_RELEASE
invoke CreateFile,addr szText,GENERIC_WRITE OR GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,0
.if eax!=INVALID_HANDLE_VALUE
mov hFile,eax
.endif
;invoke SetFilePointer,hFile,55,NULL,FILE_END
;invoke SetEndOfFile,hFile
;invoke SetFilePointer,hFile,0,NULL,FILE_CURRENT
;invoke wsprintf,addr szBuf,offset szColor,eax
;invoke MessageBox,hWnd,addr szBuf,0,MB_OK
INVOKE CreateFileMapping,hFile,NULL,PAGE_READWRITE,0,4096,NULL;本身文件自己所拥有的只有2K。所以最好这里指定一下大小,不然写不了大数据
.if eax
mov hMap,eax
.endif
invoke MapViewOfFile,hMap,FILE_MAP_READ OR FILE_MAP_WRITE,0,0,0
.if eax
mov lpView,eax
.endif
mov al,'b'
mov ecx,500
mov edi,lpView
rep stosb
;mov [edi],al
invoke FlushViewOfFile,lpView,NULL
invoke UnmapViewOfFile,lpView
invoke CloseHandle,hMap
invoke CloseHandle,hFile
invoke OpenFileMapping,FILE_MAP_READ OR FILE_MAP_WRITE,0,offset szChar;内存映射实现数据共享,每打开一次就会向这块内存写入新的数据
.if !eax
invoke CreateFileMapping,NULL,NULL,PAGE_READWRITE,0,4096,offset szChar
.endif
mov hMap,eax
invoke MapViewOfFile,hMap,FILE_MAP_READ OR FILE_MAP_WRITE,0,0,0
mov lpView,eax
invoke lstrcat,lpView,offset szChar
;invoke MessageBox,hWnd,lpView,0,MB_OK ;这块的释放工作放在WM_CLOSE里面。如果马上释放后面的文件就打不开映射,又只能创建
invoke GetTempPath,sizeof szBuf,offset szBuf;取临时文件夹路径
;invoke MessageBox,hWnd,offset szBuf,0,MB_OK
invoke GetCurrentDirectory,sizeof szBuf,offset szBuf;对当前文件路径
;invoke MessageBox,hWnd,offset szBuf,0,MB_OK
invoke GetSystemDirectory,offset szBuf,sizeof szBuf;取系统路径
;invoke MessageBox,hWnd,offset szBuf,0,MB_OK
invoke GetWindowsDirectory,offset szBuf,sizeof szBuf;取windows路径
;invoke MessageBox,hWnd,offset szBuf,0,MB_OK
invoke CreateStatusWindow,WS_VISIBLE OR WS_CHILD,addr szFilter,hWnd,1
mov hStatus,eax
INVOKE SendMessage,hStatus,SB_SETPARTS,4,addr szPart
INVOKE SendMessage,hStatus,SB_SETTEXT,1,addr szFilter
mov stFindReplace.lStructSize,sizeof stFindReplace
push hWnd
pop stFindReplace.hwndOwner
mov stFindReplace.Flags,FR_DOWN
mov stFindReplace.lpstrFindWhat,offset szBuf
mov stFindReplace.wFindWhatLen,sizeof szBuf
mov stFindReplace.lpstrReplaceWith,offset szBuf2
mov stFindReplace.wReplaceWithLen,sizeof szBuf2
invoke RegisterWindowMessage,addr szFINDTEXT
mov uvMsg,eax
invoke GetSystemMenu,hWnd,FALSE
mov hSysMenu,eax
invoke AppendMenu,hSysMenu,MF_BYCOMMAND,IDM_C,addr szKey
invoke AppendMenu,hSysMenu,MF_BYCOMMAND,IDM_B,ADDR szTitle
;invoke DeleteMenu,hSysMenu,0,MF_BYPOSITION
;invoke RemoveMenu,hSysMenu,0,MF_BYPOSITION
invoke ModifyMenu,hSysMenu,0,MF_BYPOSITION,IDM_ALTB,addr szTitle
invoke EnableMenuItem,hMenu,IDM_UNABLE,MF_BYCOMMAND OR MF_DISABLED
invoke EnableMenuItem,hMenu,IDM_UNABLE,MF_BYCOMMAND OR MF_DISABLED
invoke EnableMenuItem,hMenu,IDM_ENABLE,MF_BYCOMMAND OR MF_ENABLED
invoke EnableMenuItem,hMenu,IDM_GRAY,MF_BYCOMMAND OR MF_GRAYED
invoke CheckMenuItem,hMenu,IDM_CHECKED,MF_BYCOMMAND OR MF_CHECKED
invoke CheckMenuRadioItem,hMenu,IDM_ICON1,IDM_ICON2,IDM_ICON1,MF_BYCOMMAND
invoke CheckMenuRadioItem,hMenu,IDM_CURSOR1,IDM_CURSOR2,IDM_CURSOR1,MF_BYCOMMAND
;invoke EnableMenuItem,hMenu,IDM_OPEN, MF_DISABLED
.elseif eax==WM_RBUTTONDOWN
invoke GetSubMenu,hMenu,1
mov hSubMenu,eax
invoke GetCursorPos,addr @pt
invoke TrackPopupMenu,hSubMenu,TPM_LEFTALIGN,@pt.x,@pt.y,NULL,hWnd,NULL
.elseif eax==WM_SYSCOMMAND
mov eax,wParam
.if ax==IDM_C || AX==IDM_B || AX==IDM_ALTB
invoke _message,wParam
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
.endif
ret
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
xor eax,eax;返回码
ret
_wndProc endp
_winMain proc
local @wc:WNDCLASSEX
local @uMsg:MSG
invoke RtlZeroMemory,addr @wc,sizeof @wc
invoke GetModuleHandle,NULL
mov hInstance,eax
mov @wc.hInstance,eax
mov @wc.cbSize,sizeof @wc
mov @wc.cbClsExtra,0
mov @wc.cbWndExtra,0
mov @wc.lpszClassName,offset szClassName
mov @wc.lpszMenuName,0
mov @wc.hbrBackground,COLOR_WINDOW+1
mov @wc.style,CS_VREDRAW OR CS_HREDRAW OR CS_DBLCLKS
mov @wc.lpfnWndProc,offset _wndProc
invoke LoadAccelerators,hInstance,IDR_ACCELERATOR1
mov hAccelerator,eax
invoke LoadMenu,hInstance,IDR_MENU1
mov hMenu,eax
invoke LoadIcon,hInstance,IDI_ICON1
mov hIcon1,eax
mov @wc.hIcon,eax
invoke LoadIcon,hInstance,IDI_ICON2
mov hIcon2,eax
invoke LoadCursor,hInstance,IDC_CURSOR1
.if eax
mov hCur1,eax
mov @wc.hCursor,eax
.endif
invoke LoadCursorFromFile,addr szCur2
mov hCur2,eax
invoke RegisterClassEx,addr @wc
invoke CreateWindowEx,WS_EX_OVERLAPPEDWINDOW,addr szClassName,addr szTitle,WS_OVERLAPPEDWINDOW,0,0,600,500,NULL,hMenu,hInstance,NULL
mov hWinMain,eax
invoke ShowWindow,hWinMain,SW_SHOWNORMAL
invoke UpdateWindow,hWinMain
.while TRUE
invoke GetMessage,addr @uMsg,NULL,0,0
.break .if !eax
invoke TranslateAccelerator,hWinMain,hAccelerator,addr @uMsg
.if !eax
invoke TranslateMessage,addr @uMsg
invoke DispatchMessage,addr @uMsg
.endif
.endw
ret
_winMain endp
start:
invoke InitCommonControls
call _winMain
invoke ExitProcess,-1
end start
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!