;==============dlltab.asm=====================================
.386
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
include kernel32.inc
include comctl32.inc
includelib user32.lib
includelib kernel32.lib
includelib comctl32.lib
include dlltab.Inc
.code
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL msg:MSG
invoke InitCommonControls
invoke CreateDialogParam,hInst,IDD_TABTEST,NULL,addr DlgProc,NULL
mov hDlg,eax
invoke ShowWindow,hDlg,SW_SHOWDEFAULT
invoke UpdateWindow,hDlg
;------设置输入焦点
;invoke GetDlgItem,hDlg,IDC_BUTTON_ADD
;invoke SetFocus,eax
;------非模式对话框的消息循环
.WHILE TRUE
invoke GetMessage,ADDR msg,NULL,0,0
.BREAK .IF(!eax)
invoke IsDialogMessage,hDlg,ADDR msg
.IF eax==FALSE
invoke TranslateMessage,ADDR msg
invoke DispatchMessage,ADDR msg
.endif
.endw
mov eax,msg.wParam
ret
WinMain endp
_WinMain proc
invoke WinMain,hInstance,NULL,NULL,SW_SHOWDEFAULT
ret
_WinMain endp
DllEntry proc _hInstance,_dwReason,_dwReserved
local @dwThreadID
mov eax,_dwReason
.if eax == DLL_PROCESS_ATTACH
;保存hInstDll 和初始化操作
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK
;invoke GetModuleHandle, NULL
;mov hInstance, eax
push _hInstance
pop hInstance
invoke CreateThread,NULL,0,offset _WinMain,NULL,\
NULL,addr @dwThreadID
invoke CloseHandle,eax
;invoke ExitProcess,eax
mov eax,TRUE
.elseif eax == DLL_THREAD_ATTACH
;为新线程分配资源
mov eax,TRUE
ret
.elseif eax == DLL_THREAD_DETACH
;线程释放资源
mov eax,TRUE
ret
.elseif eax == DLL_PROCESS_DETACH
;释放库使用的资源
mov eax,TRUE
ret
.endif
ret
DllEntry endp
HookProc proc _dwCode,_wParam,_lParam
local @szKeyState[256]:byte
invoke CallNextHookEx,hHook,_dwCode,_wParam,_lParam
invoke GetKeyboardState,addr @szKeyState
invoke GetKeyState,VK_SHIFT
mov @szKeyState + VK_SHIFT,al ; 不太清楚这句是什么意思
mov ecx,_lParam
shr ecx,16
invoke ToAscii,_wParam,ecx,addr @szKeyState,addr szAscii,0
mov byte ptr szAscii [eax],0
invoke SendMessage,hWnd,dwMessage,dword ptr szAscii,NULL
xor eax,eax
ret
HookProc endp
InstallHook proc _hWnd,_dwMessage
push _hWnd
pop hWnd
push _dwMessage
pop dwMessage
invoke SetWindowsHookEx,WH_KEYBOARD,addr HookProc,hInstance,NULL
mov hHook,eax
ret
InstallHook endp
UninstallHook proc
invoke UnhookWindowsHookEx,hHook
ret
UninstallHook endp
Tab1Proc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
.if uMsg==WM_INITDIALOG
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
Tab1Proc endp
Tab2Proc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
.if uMsg==WM_INITDIALOG
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
Tab2Proc endp
Tab3Proc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
.if uMsg==WM_INITDIALOG
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
Tab3Proc endp
DlgProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL ts:TC_ITEM
mov eax,uMsg
.if eax==WM_COMMAND
mov eax,wParam
mov edx,eax
and eax,0FFFFh
shr edx,16
.if edx==BN_CLICKED
.if eax==IDCANCEL
invoke SendMessage,hWin,WM_CLOSE,0,0
.elseif eax==IDOK
invoke SendMessage,hWin,WM_CLOSE,0,0
.endif
.endif
.elseif eax==WM_NOTIFY
mov eax,lParam
mov eax,[eax].NMHDR.code
.if eax==TCN_SELCHANGE
;Tab selection
invoke SendMessage,hTab,TCM_GETCURSEL,0,0
.if eax!=SelTab
push eax
mov eax,SelTab
invoke ShowWindow,[hTabDlg+eax*4],SW_HIDE
pop eax
mov SelTab,eax
invoke ShowWindow,[hTabDlg+eax*4],SW_SHOWDEFAULT
.endif
.endif
.elseif eax==WM_INITDIALOG
;Create the tabs
invoke GetDlgItem,hWin,IDC_TAB1
mov hTab,eax
mov ts.imask,TCIF_TEXT
mov ts.lpReserved1,0
mov ts.lpReserved2,0
mov ts.iImage,-1
mov ts.lParam,0
mov ts.pszText,offset TabTitle1
mov ts.cchTextMax,sizeof TabTitle1
invoke SendMessage,hTab,TCM_INSERTITEM,0,addr ts
mov ts.pszText,offset TabTitle2
mov ts.cchTextMax,sizeof TabTitle2
invoke SendMessage,hTab,TCM_INSERTITEM,1,addr ts
mov ts.pszText,offset TabTitle3
mov ts.cchTextMax,sizeof TabTitle3
invoke SendMessage,hTab,TCM_INSERTITEM,2,addr ts
;Create the tab dialogs
invoke CreateDialogParam,hInstance,IDD_TAB1,hTab,addr Tab1Proc,0
mov hTabDlg,eax
invoke CreateDialogParam,hInstance,IDD_TAB2,hTab,addr Tab2Proc,0
mov hTabDlg[4],eax
invoke CreateDialogParam,hInstance,IDD_TAB3,hTab,addr Tab3Proc,0
mov hTabDlg[8],eax
.elseif eax==WM_CLOSE
;invoke DestroyWindow,hWnd
invoke EndDialog,hWin,NULL
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
DlgProc endp
end DllEntry
;============================================================================================
;----dlltab.inc
DlgProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
.const
IDD_TABTEST equ 1000
IDC_TAB1 equ 1001
IDD_TAB1 equ 2000
IDD_TAB2 equ 3000
IDD_TAB3 equ 4000
szCaption db '恭喜',0
szText db '当您看到这个信息的时候,您已经可以编译Win32汇编程序了!',0
.data
TabTitle1 db "Tab1",0
TabTitle2 db "Tab2",0
TabTitle3 db "Tab3",0
.data?
hInstance dd ?
hTab dd ?
hTabDlg dd 3 dup(?)
SelTab dd ?
hDlg dd ?
.data?
hWnd dd ?
hHook dd ?
dwMessage dd ?
szAscii db 4 dup (?)
#define IDD_TABTEST 1000
#define IDC_TAB1 1001
#define IDC_GRP1 1002
IDD_TABTEST DIALOGEX 6,0,197,121
FONT 9,"宋体",400,0,134
STYLE 0x10CC0000
EXSTYLE 0x00000080
BEGIN
CONTROL "",IDC_TAB1,"SysTabControl32",0x50018000,0,0,200,124,0x00000000
CONTROL "IDC_GRP",IDC_GRP1,"Button",0x50000007,80,-14,18,14,0x00000000
END
#define IDD_TAB1 2000
#define IDC_EDT1 2001
IDD_TAB1 DIALOGEX 1,14,200,110
FONT 9,"宋体",400,0,134
STYLE 0x50000000
EXSTYLE 0x00000000
BEGIN
CONTROL "",IDC_EDT1,"Edit",0x50010000,24,20,54,26,0x00000200
END
#define IDD_TAB2 3000
#define IDC_EDT1 3001
IDD_TAB2 DIALOGEX 0,14,196,106
FONT 9,"宋体",400,0,134
STYLE 0x500D0000
EXSTYLE 0x00000000
BEGIN
CONTROL "",IDC_EDT1,"Edit",0x50010000,50,18,78,28,0x00000200
END
#define IDD_TAB3 4000
#define IDC_EDT1 4001
IDD_TAB3 DIALOGEX 0,14,196,106
FONT 9,"宋体",400,0,134
STYLE 0x500F0000
EXSTYLE 0x00000000
BEGIN
CONTROL "",IDC_EDT1,"Edit",0x50010000,28,54,62,26,0x00000200
END
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)