首页 > 编程 > ASM > 正文

Win32 汇编语句模板

2019-11-08 03:12:06
字体:
来源:转载
供稿:网友
Win32 汇编语句模板

一 变量

;句柄hInstance     dd 0hWnd          dd 0hPen          dd 0hPend        dd 0oldPen        dd 0;过程变量hInst     :DWordhPRevInst :DWORDhWin:DWORDhDC:DWORDhParent:DWORDhCtl   :DWORDCmdLine   :DWORDCmdShow   :DWORDuMsg   :DWORDwParam :DWORDlParam :DWORDa:DWORDht:DWORDID:DWORD;本地LOCAL hDC:DWORDLOCAL mDC       :DWORDLOCAL hBrush    :DWORDLOCAL hOldBmp   :DWORDLOCAL hReturn   :DWORDLOCAL hOldBrush :DWORDLOCAL btn_hi   :DWORDLOCAL btn_lo   :DWORDLOCAL rct:RECTLOCAL ps:PAINTSTRUCTLOCAL wc   :WNDCLASSEXLOCAL msg  :MSGLOCAL Wtx  :DWORDLOCAL var    :DWORDLOCAL buffer1[128]:BYTE  ; these are two spare buffersLOCAL buffer2[128]:BYTE  ; for text manipulation etc..;自定义文本szText szClassName,"bmbtn_Class"szText icoMsg1,"Single Icon Button"szText icoBtnCl,"BUTTON"szText blnk1,0szText bmpBtnCl,"BUTTON"szText bmpMsg1,"Single Bitmap Button"

二 Mov

;句柄movmov hInstance,eaxmov  hWnd,eaxmov hDC,eaxmov hPen,eaxmov oldPen,eaxmov hIcon, eaxmov hBtn1, eaxmov lpBtnProc, eaxmov hBmp1, eaxmov lpfnbmpProc, eaxmov mDC,eaxmov hOldBrush,eaxmov hReturn,eaxmov hBrush,eaxmov hOldBmp,eax  mov eax,hReturn;mov到结构体mov wc.hIcon,eaxmov wc.hCursor,        eaxmov wc.cbSize,         sizeof WNDCLASSEXmov wc.style,          CS_HREDRAW or CS_VREDRAW /                             or CS_BYTEALIGNWINDOWmov wc.lpfnWndProc,    offset WndProcmov wc.cbClsExtra,     NULLmov wc.cbWndExtra,     NULLmov wc.hInstance,      hInstmov wc.hbrBackground,  COLOR_BTNFACE+1mov wc.lpszMenuName,   NULLmov wc.lpszClassName,  offset szClassName;变量movmov eax, wDimmov Wtx, eaxmov Wwd, 250mov Wht, 150mov CommandLine, eax

三 条件语句

;if语句.if uMsg == WM_COMMAND.if uMsg == WM_KEYDOWN.if wParam == 400;elseif语句.elseif uMsg == WM_CREATE.elseif uMsg == WM_PAINT.elseif uMsg == WM_SIZE.elseif uMsg == WM_CLOSE.elseif uMsg == WM_DESTROY.elseif uMsg == WM_KEYUP.elseif uMsg == WM_LBUTTONDOWN.elseif uMsg == WM_LBUTTONUP.elseif wParam == 401.endif

四 汇编指令

.386.code.model flat, stdcall  ; 32 bit memory modeloption casemap :none  ; case sensitivereturn 0 return sDimreturn msg.wParamshr sDim, 1shr wDim, 1sub sDim, eax jmp StartLoopje ExitLoopcmp eax,0xor eax,eaxprocret	endpend start

五 调用Win32 API

;模块和进程invoke GetModuleHandle,0invoke GetModuleHandle, NULLinvoke ExitProcess,eaxinvoke GetCommandLine;窗口invoke WinMain,hInstance,0,0,SW_SHOWDEFAULTinvoke WinMain,hInstance,NULL,CommandLine,SW_SHOWDEFAULTinvoke ShowWindow,hWnd,SW_SHOWNORMALinvoke UpdateWindow,hWndinvoke SetWindowLong,hBtn2,GWL_WNDPROC,BtnProcinvoke SetWindowLong,hBtn4,GWL_WNDPROC,bmpProcinvoke SetWindowExtEx,hDC,100,100,0invoke DefWindowProc,hWin,uMsg,wParam,lParaminvoke RegisterClassEx, ADDR wcinvoke CallWindowProc,lpfnbmpProc,hCtl,uMsg,wParam,lParaminvoke CallWindowProc,lpBtnProc,hCtl,uMsg,wParam,lParaminvoke MessageBox,hWin,ADDR icoMsg1,  ADDR szDisplayName,MB_OKinvoke MessageBox,hWin,ADDR bmpMsg1,  ADDR szDisplayName,MB_OKinvoke CreateWindowEx,WS_EX_LEFT,                      ADDR szClassName,                      ADDR szDisplayName,                      WS_OVERLAPPED or WS_SYSMENU,                      Wtx,Wty,Wwd,Wht,                      NULL,NULL,                      hInst,NULLinvoke CreateWindowEx,0,        ADDR icoBtnCl,ADDR blnk1,        WS_CHILD or WS_VISIBLE or BS_ICON,        a,b,wd,ht,hParent,ID,        hInstance,NULL    ;图标,位图,光标,菜单invoke LoadIcon,hInst,500invoke LoadIcon,hInstance,2invoke LoadCursor,0,IDC_ARROWinvoke LoadCursor,NULL,IDC_ARROWinvoke LoadBitmap,hInstance,10invoke LoadMenu,hInst,600  ; menu IDinvoke SetMenu,hWnd,eax;系统信息和度量invoke GetSystemMetrics,SM_CXSCREENinvoke GetSystemMetrics,SM_CYSCREENinvoke GetSysColor,COLOR_BTNHIGHLIGHTinvoke GetSysColor,COLOR_BTNSHADOWinvoke GetSysColor,COLOR_BTNFACEinvoke SetMapMode,hDC,MM_ANISOTROPIC  ;消息invoke GetMessage,ADDR msg,0,0,0invoke GetMessage,ADDR msg,NULL,0,0invoke TranslateMessage,ADDR msginvoke DispatchMessage,ADDR msginvoke SendMessage,hBtn1,BM_SETIMAGE,1,eaxinvoke SendMessage,hBtn3,BM_SETIMAGE,0,hBmp1invoke PostQuitMessage,0      ;设备描述表和画图invoke BeginPaint,hWin,ADDR Psinvoke EndPaint,hWin,ADDR psinvoke GetClientRect,hWin,ADDR rctinvoke SetViewportExtEx,hDC,rct.right,rct.bottom,0invoke SelectObject,hDC,hPeninvoke ExtCreatePen,PS_SOLID or PS_GEOMETRIC or PS_ENDCAP_ROUND or PS_JOIN_ROUND,10,ADDR lb,0,0invoke BeginPath,hDCinvoke MoveToEx,hDC,10,25,0invoke LineTo,hDC,20,75invoke EndPath,hDC   invoke CreateCompatibleDC,NULL    invoke SelectObject,mDC,hBitmap      invoke CreateSolidBrush,eaxinvoke SelectObject,mDC,hBrushinvoke GetPixel,mDC,1,1invoke ExtFloodFill,mDC,1,1,eax,FLOODFILLSURFACEinvoke DeleteObject,hBrushinvoke DeleteDC,mDC

六 调用自定义函数

invoke RoundedPath,hDC invoke IconButton,hWin,20,60,36,36,401invoke SetBmpColor,hBmp1invoke TopXY,Wwd,eax

七 标号

start:StartLoop:ExitLoop:
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选