iczelion tut35[9]

[入库:2005年8月19日] [更新:2007年3月24日]

本文简介:选择自 jimgreen 的 blog

.if eax!=invalid_handle_value @@: mov hfile,eax mov editstream.dwcookie,eax mov editstream.pfncallback,offset streamoutproc invoke sendmessage,hwndrichedit,em_streamout,sf_text,addr editstream invoke sendmessage,hwndrichedit,em_setmodify,false,0 invoke closehandle,hfile .else invoke messagebox,hwnd,addr openfilefail,addr appname,mb_ok or mb_iconerror .endif .elseif ax==idm_copy invoke sendmessage,hwndrichedit,wm_copy,0,0 .elseif ax==idm_cut invoke sendmessage,hwndrichedit,wm_cut,0,0 .elseif ax==idm_paste invoke sendmessage,hwndrichedit,wm_paste,0,0 .elseif ax==idm_delete invoke sendmessage,hwndrichedit,em_replacesel,true,0 .elseif ax==idm_selectall mov chrg.cpmin,0 mov chrg.cpmax,-1 invoke sendmessage,hwndrichedit,em_exsetsel,0,addr chrg .elseif ax==idm_undo invoke sendmessage,hwndrichedit,em_undo,0,0 .elseif ax==idm_redo invoke sendmessage,hwndrichedit,em_redo,0,0 .elseif ax==idm_option invoke dialogboxparam,hinstance,idd_optiondlg,hwnd,addr optionproc,0 .elseif ax==idm_saveas invoke rtlzeromemory,addr ofn,sizeof ofn mov ofn.lstructsize,sizeof ofn push hwnd pop ofn.hwndowner push hinstance pop ofn.hinstance mov ofn.lpstrfilter,offset asmfilterstring mov ofn.lpstrfile,offset alternatefilename mov byte ptr [alternatefilename],0 mov ofn.nmaxfile,sizeof alternatefilename mov ofn.flags,ofn_filemustexist or ofn_hidereadonly or ofn_pathmustexist invoke getsavefilename,addr ofn .if eax!=0 invoke createfile,addr alternatefilename,generic_write,file_share_read,null,create_always,file_attribute_normal,0 .if eax!=invalid_handle_value jmp @b .endif .endif .elseif ax==idm_find .if hsearch==0 invoke createdialogparam,hinstance,idd_finddlg,hwnd,addr searchproc,0 .endif .elseif ax==idm_replace .if hsearch==0 invoke createdialogparam,hinstance,idd_replacedlg,hwnd,addr replaceproc,0 .endif .elseif ax==idm_gotoline .if hsearch==0 invoke createdialogparam,hinstance,idd_gotodlg,hwnd,addr gotoproc,0 .endif .elseif ax==idm_findnext invoke lstrlen,addr findbuffer .if eax!=0 invoke sendmessage,hwndrichedit,em_exgetsel,0,addr findtext.chrg mov eax,findtext.chrg.cpmin .if eax!=findtext.chrg.cpmax push findtext.chrg.cpmax pop findtext.chrg.cpmin .endif mov findtext.chrg.cpmax,-1 mov findtext.lpstrtext,offset findbuffer invoke sendmessage,hwndrichedit,em_findtextex,fr_down,addr findtext .if eax!=-1 invoke sendmessage,hwndrichedit,em_exsetsel,0,addr findtext.chrgtext .endif .endif .elseif ax==idm_findprev invoke lstrlen,addr findbuffer .if eax!=0 invoke sendmessage,hwndrichedit,em_exgetsel,0,addr findtext.chrg mov findtext.chrg.cpmax,0 mov findtext.lpstrtext,offset findbuffer invoke sendmessage,hwndrichedit,em_findtextex,0,addr findtext .if eax!=-1 invoke sendmessage,hwndrichedit,em_exsetsel,0,addr findtext.chrgtext .endif .endif .elseif ax==idm_exit invoke sendmessage,hwnd,wm_close,0,0 .endif .endif .elseif umsg==wm_close invoke checkmodifystate,hwnd .if eax==true invoke destroywindow,hwnd .endif .elseif umsg==wm_size mov eax,lparam mov edx,eax and eax,0ffffh shr edx,16 invoke movewindow,hwndrichedit,0,0,eax,edx,true .elseif umsg==wm_destroy invoke postquitmessage,null .else invoke defwindowproc,hwnd,umsg,wparam,lparam ret .endif xor eax,eax ret wndproc endp end start

analysis:

the first action before calling winmain to to call fillhiliteinfo. this function reads the content of wordfile.txt and parses the content.

fillhiliteinfo proc uses edi
	local buffer[1024]:byte
	local ptemp:dword
	local blocksize:dword
	invoke rtlzeromemory,addr asmsyntaxarray,sizeof asmsyntaxarray

initialize asmsyntaxarray to zero.

	invoke getmodulefilename,hinstance,addr buffer,sizeof buffer
	invoke lstrlen,addr buffer
	mov ecx,eax
	dec ecx
	lea edi,buffer
	add edi,ecx
	std
	mov al,"\"
	repne scasb
	cld
	inc edi
	mov byte ptr [edi],0
	invoke lstrcat,addr buffer,addr wordfilename

construct the full path name of wordfile.txt: i assume that it's always in the same folder as the program.

本文关键:iczelion asm
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top