📄 fasmw.asm
字号:
mov [font.lfPitchAndFamily],FIXED_PITCH+FF_DONTCARE
mov edi,font.lfFaceName
mov esi,_font_face
copy_font_face:
lodsb
stosb
or al,al
jnz copy_font_face
invoke GetSysColor,COLOR_WINDOWTEXT
mov [editor_colors],eax
invoke GetSysColor,COLOR_WINDOW
mov [editor_colors+4],eax
invoke GetSysColor,COLOR_HIGHLIGHTTEXT
mov [editor_colors+8],eax
invoke GetSysColor,COLOR_HIGHLIGHT
mov [editor_colors+12],eax
mov esi,editor_colors
mov edi,user_colors
mov ecx,8
rep movsd
mov [wp.length],sizeof.WINDOWPLACEMENT
invoke GetWindowPlacement,[hwnd],wp
stdcall GetIniInteger,ini_path,_section_compiler,_key_compiler_memory,compiler_memory
stdcall GetIniInteger,ini_path,_section_compiler,_key_compiler_priority,compiler_priority
stdcall GetIniBit,ini_path,_section_options,_key_options_securesel,asmedit_style,AES_SECURESEL
stdcall GetIniBit,ini_path,_section_options,_key_options_autobrackets,asmedit_style,AES_AUTOBRACKETS
stdcall GetIniBit,ini_path,_section_options,_key_options_autoindent,asmedit_style,AES_AUTOINDENT
stdcall GetIniBit,ini_path,_section_options,_key_options_smarttabs,asmedit_style,AES_SMARTTABS
stdcall GetIniBit,ini_path,_section_options,_key_options_optimalfill,asmedit_style,AES_OPTIMALFILL
stdcall GetIniBit,ini_path,_section_options,_key_options_revivedeadkeys,asmedit_style,AES_REVIVEDEADKEYS
stdcall GetIniBit,ini_path,_section_options,_key_options_consolecaret,asmedit_style,AES_CONSOLECARET
stdcall GetIniColor,ini_path,_section_colors,_key_color_text,editor_colors
stdcall GetIniColor,ini_path,_section_colors,_key_color_background,editor_colors+4
stdcall GetIniColor,ini_path,_section_colors,_key_color_seltext,editor_colors+8
stdcall GetIniColor,ini_path,_section_colors,_key_color_selbackground,editor_colors+12
stdcall GetIniColor,ini_path,_section_colors,_key_color_symbols,asm_syntax_colors
stdcall GetIniColor,ini_path,_section_colors,_key_color_numbers,asm_syntax_colors+4
stdcall GetIniColor,ini_path,_section_colors,_key_color_strings,asm_syntax_colors+8
stdcall GetIniColor,ini_path,_section_colors,_key_color_comments,asm_syntax_colors+12
invoke GetPrivateProfileString,_section_font,_key_font_face,font.lfFaceName,font.lfFaceName,32,ini_path
stdcall GetIniInteger,ini_path,_section_font,_key_font_height,font.lfHeight
stdcall GetIniInteger,ini_path,_section_font,_key_font_width,font.lfWidth
stdcall GetIniInteger,ini_path,_section_font,_key_font_weight,font.lfWeight
stdcall GetIniBit,ini_path,_section_font,_key_font_italic,font.lfItalic,1
stdcall GetIniByte,ini_path,_section_font,_key_font_charset,font.lfCharSet
stdcall GetIniInteger,ini_path,_section_window,_key_window_top,wp.rcNormalPosition.top
stdcall GetIniInteger,ini_path,_section_window,_key_window_left,wp.rcNormalPosition.left
stdcall GetIniInteger,ini_path,_section_window,_key_window_right,wp.rcNormalPosition.right
stdcall GetIniInteger,ini_path,_section_window,_key_window_bottom,wp.rcNormalPosition.bottom
stdcall GetIniBit,ini_path,_section_window,_key_window_maximized,wp.flags,WPF_RESTORETOMAXIMIZED
invoke GetPrivateProfileString,_section_help,_key_help_path,help_path,help_path,1000h,ini_path
mov [wp.showCmd],SW_HIDE
invoke SetWindowPlacement,[hwnd],wp
invoke CreateFontIndirect,font
mov [hfont],eax
invoke CreateStatusWindow,WS_CHILD+WS_VISIBLE+SBS_SIZEGRIP,NULL,[hwnd],0
or eax,eax
jz failed
mov [hwnd_status],eax
mov [param_buffer],48h
mov [param_buffer+4],90h
mov [param_buffer+8],-1
invoke SendMessage,eax,SB_SETPARTS,3,param_buffer
invoke CreateWindowEx,0,_listbox_class,NULL,WS_CHILD+LBS_HASSTRINGS,0,0,0,0,[hwnd],NULL,[hinstance],NULL
or eax,eax
jz failed
mov [hwnd_history],eax
invoke CreateWindowEx,0,_tabctrl_class,NULL,WS_VISIBLE+WS_CHILD+TCS_FOCUSNEVER+TCS_BOTTOM,0,0,0,0,[hwnd],NULL,[hinstance],NULL
or eax,eax
jz failed
mov [hwnd_tabctrl],eax
invoke SendMessage,[hwnd_tabctrl],TCM_SETITEMEXTRA,8,0
invoke SendMessage,[hwnd_status],WM_GETFONT,0,0
invoke SendMessage,[hwnd_tabctrl],WM_SETFONT,eax,FALSE
invoke LoadBitmap,[hinstance],IDB_ASSIGN
mov ebx,eax
invoke GetObject,ebx,sizeof.BITMAP,bm
invoke ImageList_Create,[bm.bmWidth],[bm.bmHeight],ILC_COLOR4,1,0
or eax,eax
jz failed
mov [himl],eax
invoke ImageList_Add,[himl],ebx,NULL
invoke DeleteObject,ebx
invoke SendMessage,[hwnd_tabctrl],TCM_SETIMAGELIST,0,[himl]
invoke SendMessage,[hwnd],FM_NEW,_untitled,0
cmp eax,-1
je failed
invoke DragAcceptFiles,[hwnd],TRUE
mov esi,[program_arguments]
find_argument:
lodsb
cmp al,20h
je find_argument
xor ecx,ecx
cmp al,22h
je quoted_argument
cmp al,0Dh
je command_line_ok
or al,al
jz command_line_ok
lea edx,[esi-1]
find_argument_end:
inc ecx
lodsb
cmp al,20h
je argument_end
cmp al,0Dh
je argument_end
or al,al
jz argument_end
jmp find_argument_end
quoted_argument:
mov edx,esi
find_quoted_argument_end:
lodsb
cmp al,22h
je quoted_argument_end
cmp al,0Dh
je quoted_argument_end
or al,al
jz quoted_argument_end
inc ecx
jmp find_quoted_argument_end
argument_end:
dec esi
quoted_argument_end:
push eax edx esi
mov esi,edx
mov edi,path_buffer
rep movsb
xor al,al
stosb
invoke GetFileTitle,path_buffer,name_buffer,100h
invoke SendMessage,[hwnd],FM_OPEN,name_buffer,path_buffer
cmp eax,-1
jne load_ok
cinvoke wsprintf,string_buffer,_loading_error,path_buffer
invoke MessageBox,[hwnd],string_buffer,_caption,MB_ICONERROR+MB_OK
load_ok:
pop esi edx eax
jmp find_argument
command_line_ok:
xor eax,eax
jmp finish
wmcopydata:
mov ebx,[lparam]
virtual at ebx
cmd COPYDATASTRUCT
end virtual
mov esi,[cmd.lpData]
jmp find_argument
wmgetminmaxinfo:
mov ebx,[lparam]
virtual at ebx
mmi MINMAXINFO
end virtual
mov [mmi.ptMinTrackSize.x],240
mov [mmi.ptMinTrackSize.y],160
jmp finish
wmsize:
invoke SendMessage,[hwnd_status],WM_SIZE,0,0
xor eax,eax
mov [rc.left],eax
mov [rc.top],eax
mov [rc.right],eax
mov [rc.bottom],eax
invoke SendMessage,[hwnd_tabctrl],TCM_ADJUSTRECT,TRUE,rc
mov esi,[rc.bottom]
sub esi,[rc.top]
invoke GetWindowRect,[hwnd_status],rc
mov ebx,[rc.bottom]
sub ebx,[rc.top]
invoke GetClientRect,[hwnd],rc
sub [rc.bottom],ebx
sub [rc.bottom],esi
invoke SetWindowPos,[hwnd_tabctrl],[hwnd_asmedit],0,[rc.bottom],[rc.right],esi,0
invoke GetSystemMetrics,SM_CYFIXEDFRAME
shl eax,1
add [rc.bottom],eax
invoke MoveWindow,[hwnd_asmedit],0,0,[rc.right],[rc.bottom],TRUE
jmp finish
wmsetfocus:
invoke SetFocus,[hwnd_asmedit]
jmp finish
fmnew:
invoke CreateWindowEx,WS_EX_STATICEDGE,_asmedit_class,NULL,WS_CHILD+WS_HSCROLL+WS_VSCROLL+ES_NOHIDESEL,0,0,0,0,[hwnd],NULL,[hinstance],NULL
or eax,eax
jz failed
mov [ei.header.mask],TCIF_TEXT+TCIF_PARAM
mov [ei.hwnd],eax
mov eax,[wparam]
mov [ei.header.pszText],eax
mov [ei.pszpath],0
invoke SendMessage,[hwnd_tabctrl],TCM_GETITEMCOUNT,0,0
invoke SendMessage,[hwnd_tabctrl],TCM_INSERTITEM,eax,ei
mov ebx,eax
invoke SendMessage,[hwnd_tabctrl],TCM_SETCURSEL,eax,0
invoke SendMessage,[hwnd],FM_SELECT,ebx,0
invoke SetFocus,[hwnd]
mov eax,ebx
jmp finish
fmopen:
invoke VirtualAlloc,0,1000h,MEM_COMMIT,PAGE_READWRITE
or eax,eax
jz failed
mov edi,eax
mov esi,[lparam]
mov [lparam],edi
copy_path_for_asmedit:
lodsb
stosb
or al,al
jnz copy_path_for_asmedit
xor ebx,ebx
check_if_already_loaded:
mov [ei.header.mask],TCIF_PARAM
invoke SendMessage,[hwnd_tabctrl],TCM_GETITEM,ebx,ei
or eax,eax
jz load_file
invoke lstrcmpi,[ei.pszpath],[lparam]
or eax,eax
jz show_already_loaded
inc ebx
jmp check_if_already_loaded
show_already_loaded:
invoke SendMessage,[hwnd_tabctrl],TCM_SETCURSEL,ebx,0
invoke SendMessage,[hwnd],FM_SELECT,ebx,0
xor eax,eax
jmp finish
load_file:
invoke CreateFile,[lparam],GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,0,0
cmp eax,-1
je open_failed
mov ebx,eax
invoke GetFileSize,ebx,NULL
inc eax
push eax
invoke VirtualAlloc,0,eax,MEM_COMMIT,PAGE_READWRITE
or eax,eax
jz load_out_of_memory
pop ecx
dec ecx
push MEM_RELEASE 0 eax
mov byte [eax+ecx],0
invoke ReadFile,ebx,eax,ecx,param_buffer,0
invoke CloseHandle,ebx
invoke SendMessage,[hwnd_tabctrl],TCM_GETITEMCOUNT,0,0
cmp eax,1
jne new_asmedit
mov [ei.header.mask],TCIF_PARAM
invoke SendMessage,[hwnd_tabctrl],TCM_GETITEM,0,ei
cmp [ei.pszpath],0
jne new_asmedit
invoke SendMessage,[ei.hwnd],EM_CANUNDO,0,0
or eax,eax
jnz new_asmedit
mov [ei.header.mask],TCIF_TEXT+TCIF_PARAM
mov eax,[wparam]
mov [ei.header.pszText],eax
mov eax,[lparam]
mov [ei.pszpath],eax
invoke SendMessage,[hwnd_tabctrl],TCM_SETITEM,0,ei
xor ebx,ebx
jmp set_asmedit_text
new_asmedit:
invoke SendMessage,[hwnd],FM_NEW,[wparam],0
cmp eax,-1
jne set_path
add esp,12
jmp open_failed
set_path:
mov ebx,eax
mov [ei.header.mask],TCIF_PARAM
invoke SendMessage,[hwnd_tabctrl],TCM_GETITEM,ebx,ei
mov eax,[lparam]
mov [ei.pszpath],eax
invoke SendMessage,[hwnd_tabctrl],TCM_SETITEM,ebx,ei
set_asmedit_text:
invoke SendMessage,[hwnd_asmedit],WM_SETTEXT,0,dword [esp]
call [VirtualFree]
mov eax,ebx
jmp finish
load_out_of_memory:
invoke CloseHandle,ebx
open_failed:
invoke VirtualFree,[lparam],0,MEM_RELEASE
jmp failed
fmsave:
mov [ei.header.mask],TCIF_PARAM
invoke SendMessage,[hwnd_tabctrl],TCM_GETITEM,[wparam],ei
or eax,eax
jz failed
mov eax,[ei.pszpath]
or eax,eax
jz failed
invoke CreateFile,eax,GENERIC_WRITE,0,0,CREATE_ALWAYS,0,0
cmp eax,-1
je failed
mov ebx,eax
invoke SendMessage,[ei.hwnd],WM_GETTEXTLENGTH,0,0
inc eax
mov [wparam],eax
invoke VirtualAlloc,0,eax,MEM_COMMIT,PAGE_READWRITE
or eax,eax
jz save_out_of_memory
mov [lparam],eax
invoke SendMessage,[ei.hwnd],WM_GETTEXT,[wparam],eax
invoke WriteFile,ebx,[lparam],eax,param_buffer,0
invoke CloseHandle,ebx
invoke VirtualFree,[lparam],0,MEM_RELEASE
invoke SendMessage,[ei.hwnd],EM_EMPTYUNDOBUFFER,0,0
invoke SendMessage,[hwnd_status],SB_SETTEXT,1,_null
xor eax,eax
jmp finish
save_out_of_memory:
invoke CloseHandle,ebx
jmp failed
fmcompile:
mov eax,[assigned_file]
push eax
cmp eax,-1
jne assigned_ok
invoke SendMessage,[hwnd_tabctrl],TCM_GETCURSEL,0,0
mov [assigned_file],eax
assigned_ok:
invoke SendMessage,[hwnd_main],FM_SAVE,eax,0
xor ebx,ebx
or eax,eax
jz save_all
invoke SendMessage,[hwnd_tabctrl],TCM_SETCURSEL,[assigned_file],0
invoke SendMessage,[hwnd_main],FM_SELECT,[assigned_file],0
invoke SendMessage,[hwnd_main],WM_COMMAND,IDM_SAVEAS,0
or eax,eax
jz save_all
or eax,-1
jmp compile_done
save_all:
mov [ei.header.mask],TCIF_PARAM
invoke SendMessage,[hwnd_tabctrl],TCM_GETITEM,ebx,ei
or eax,eax
jz do_compile
invoke SendMessage,[ei.hwnd],EM_CANUNDO,0,0
or eax,eax
jz save_next
invoke SendMessage,[hwnd_main],FM_SAVE,ebx,0
save_next:
inc ebx
jmp save_all
do_compile:
mov eax,[wparam]
mov [output_file],eax
invoke DialogBoxParam,[hinstance],IDD_COMPILE,[hwnd],CompileDialog,[assigned_file]
cmp eax,-1
je compile_done
push eax
cmp eax,2
je error_details
or eax,eax
jnz make_summary
cmp [lparam],FALSE
jne make_summary
invoke GlobalFree,[hmem_display]
jmp summary_done
make_summary:
invoke DialogBoxParam,[hinstance],IDD_SUMMARY,[hwnd],SummaryDialog,eax
jmp summary_done
error_details:
invoke DialogBoxParam,[hinstance],IDD_ERRORSUMMARY,[hwnd],SummaryDialog,eax
invoke GlobalFree,[hmem_error_data]
summary_done:
pop eax
compile_done:
pop edx
cmp edx,-1
jne finish
or [assigned_file],-1
jmp finish
fmselect:
mov [ei.header.mask],TCIF_PARAM
invoke SendMessage,[hwnd_tabctrl],TCM_GETITEM,[wparam],ei
invoke GetWindowLong,[hwnd_asmedit],GWL_STYLE
and eax,not WS_VISIBLE
invoke SetWindowLong,[hwnd_asmedit],GWL_STYLE,eax
mov ebx,[ei.hwnd]
mov [hwnd_asmedit],ebx
mov eax,WS_CHILD+WS_HSCROLL+WS_VSCROLL+ES_NOHIDESEL
or eax,[asmedit_style]
invoke SetWindowLong,ebx,GWL_STYLE,eax
invoke SendMessage,ebx,WM_SETFONT,[hfont],0
invoke SendMessage,ebx,AEM_SETTEXTCOLOR,[editor_colors],[editor_colors+4]
invoke SendMessage,ebx,AEM_SETSELCOLOR,[editor_colors+8],[editor_colors+12]
invoke SendMessage,ebx,AEM_SETSYNTAXHIGHLIGHT,asm_syntax_colors,fasm_syntax
invoke SendMessage,ebx,AEM_SETRIGHTCLICKMENU,[hmenu_edit],[hwnd]
invoke SendMessage,[hwnd],WM_SIZE,0,0
invoke ShowWindow,ebx,SW_SHOW
invoke UpdateWindow,ebx
invoke SetFocus,[hwnd]
jmp finish
fmassign:
mov eax,[wparam]
cmp [assigned_file],-1
je new_assign
push eax
mov [ei.header.mask],TCIF_IMAGE
mov [ei.header.iImage],-1
invoke SendMessage,[hwnd_tabctrl],TCM_SETITEM,[assigned_file],ei
pop eax
new_assign:
mov [assigned_file],eax
mov [ei.header.mask],TCIF_IMAGE
mov [ei.header.iImage],0
invoke SendMessage,[hwnd_tabctrl],TCM_SETITEM,eax,ei
or eax,eax
jnz fmgetassigned
or eax,-1
mov [assigned_file],eax
jmp finish
fmgetassigned:
mov eax,[assigned_file]
jmp finish
fmgetselected:
invoke SendMessage,[hwnd_tabctrl],TCM_GETCURSEL,0,0
jmp finish
fmgethandle:
mov [ei.header.mask],TCIF_PARAM
invoke SendMessage,[hwnd_tabctrl],TCM_GETITEM,[wparam],ei
or eax,eax
jz finish
mov eax,[ei.hwnd]
jmp finish
wminitmenu:
mov esi,[hwnd_asmedit]
invoke SendMessage,esi,EM_CANUNDO,0,0
or eax,eax
setz bl
neg bl
and ebx,MF_GRAYED
or ebx,MF_BYCOMMAND
invoke EnableMenuItem,[wparam],IDM_UNDO,ebx
invoke SendMessage,esi,AEM_GETPOS,aepos,0
mov eax,[aepos.selectionLine]
cmp eax,[aepos.caretLine]
sete bh
mov eax,[aepos.selectionPosition]
cmp eax,[aepos.caretPosition]
sete bl
and bl,bh
neg bl
and ebx,MF_GRAYED
or ebx,MF_BYCOMMAND
invoke EnableMenuItem,[wparam],IDM_CUT,ebx
invoke EnableMenuItem,[wparam],IDM_COPY,ebx
invoke EnableMenuItem,[wparam],IDM_DELETE,ebx
invoke IsClipboardFormatAvailable,CF_TEXT
neg al
not al
and eax,MF_GRAYED
or eax,MF_BYCOMMAND
invoke EnableMenuItem,[wparam],IDM_PASTE,eax
invoke SendMessage,esi,AEM_GETMODE,0,0
mov ebx,eax
test eax,AEMODE_VERTICALSEL
setnz al
neg al
and eax,MF_CHECKED
or eax,MF_BYCOMMAND
invoke CheckMenuItem,[wparam],IDM_VERTICAL,eax
invoke SendMessage,esi,AEM_CANFINDNEXT,0,0
or eax,eax
setz al
neg al
and eax,MF_GRAYED
or eax,MF_BYCOMMAND
invoke EnableMenuItem,[wparam],IDM_FINDNEXT,eax
test [asmedit_style],AES_SECURESEL
setnz al
neg al
and eax,MF_CHECKED
or eax,MF_BYCOMMAND
invoke CheckMenuItem,[wparam],IDM_SECURESEL,eax
test [asmedit_style],AES_AUTOBRACKETS
setnz al
neg al
and eax,MF_CHECKED
or eax,MF_BYCOMMAND
invoke CheckMenuItem,[wparam],IDM_AUTOBRACKETS,eax
test [asmedit_style],AES_AUTOINDENT
setnz al
neg al
and eax,MF_CHECKED
or eax,MF_BYCOMMAND
invoke CheckMenuItem,[wparam],IDM_AUTOINDENT,eax
test [asmedit_style],AES_SMARTTABS
setnz al
neg al
and eax,MF_CHECKED
or eax,MF_BYCOMMAND
invoke CheckMenuItem,[wparam],IDM_SMARTTABS,eax
test [asmedit_style],AES_OPTIMALFILL
setnz al
neg al
and eax,MF_CHECKED
or eax,MF_BYCOMMAND
invoke CheckMenuItem,[wparam],IDM_OPTIMALFILL,eax
test [asmedit_style],AES_REVIVEDEADKEYS
setnz al
neg al
and eax,MF_CHECKED
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -