flat assembler
Message board for the users of flat assembler.
![]() Goto page Previous 1, 2 |
Author |
|
mns 27 Dec 2019, 19:01
Thank you ProMiNick.I attached the original masm tutorial files and FASM converted and modified files.
|
|||||||||||||||||||||
![]() |
|
bitRAKE 28 Dec 2019, 00:33
There is nothing wrong with the coding per se. The error is in the order of resource items - all sub-directories need to be grouped after the main directory.
Please, look at examples within the fasm package: .\EXAMPLES\DIALOG.ASM .\EXAMPLES\MINIPAD.ASM .\SOURCE\IDE\FASMW\FASMW.ASM The last one is more complex and comprehensive example. |
|||
![]() |
|
Walter 28 Dec 2019, 01:09
This seems to work, if I understand what you are trying to do.
The INC file is at \Fasm\Include\Macro but might not be correct.
|
|||||||||||||||||||||
![]() |
|
mns 28 Dec 2019, 14:11
Thank you Walter and bitRAKE.
bitRAKE you mean, instead this directory RT_DIALOG,dialogs,\ RT_MENU,menus use this directory RT_MENU,menus,\ RT_DIALOG,dialogs ? Walter I replaced resource.inc file with your resource.inc file and it worked.Thank you again. ![]() |
|||
![]() |
|
ProMiNick 30 Dec 2019, 01:47
this one is worked too:
Code: format PE GUI 4.0 entry start include 'win32a.inc' macro menu ex,label,helpID,[extra] { common local data,size,items label dd RVA data,size,0,0 data: match ,ex \{ dw 0 macro menuitem string,id:0,option:0 \\{ dw option if option and MF_POPUP menu_level = menu_level +1 else dw id end if if option and MF_END menu_level = menu_level -1 end if match any,string \\\{ du string \\\} dw 0 \\} macro menuseparator option:0 \\{ dw option or MF_SEPARATOR ; direct separator if option and MF_POPUP menu_level = menu_level +1 else dw 0 end if if option and MF_END menu_level = menu_level -1 end if dw 0 ; no string - indirect separator \\} \} match any,ex \{ dw 1 macro menuitem string,id:0,resinfo:0,status:0,type:0 \\{ dd type and $36B64,status and $108B if (id and $FFFF) = id if id and $8000 dw id,$FFFF ;sign extention else dw id,0 ;sign extention end if else dd id ; id is trully dword - it is possible case too - not recommended, some(most of all) window messages ignores high part of it end if dw resinfo and $81 match any,string \\\{ du string \\\} dw 0 align 4 match any,resinfo \\\{ if resinfo and MFR_POPUP dd 0 ; helpID menu_level = menu_level +1 end if if resinfo and MFR_END menu_level = menu_level -1 end if \\\} \\} macro menuseparator resinfo:0 \\{ dd MFT_SEPARATOR,0,0 ; direct separator dw resinfo and $81,0 ; no string - indirect separator match any,resinfo \\\{ if resinfo and MFR_POPUP dd 0 ; helpID menu_level = menu_level +1 end if if resinfo and MFR_END menu_level = menu_level -1 end if \\\} \\} \} dw items-$-2 match any, extra \{ forward if extra eqtype '' db extra,0 align 4 else dd extra end if common \} match any,ex helpID \{ align 4 dd helpID+0 \} items: menu_size equ size = $ - data menu_level = 1 macro endmenu \{ if menu_level err unresolved internal menu structure end if menu_size purge menuitem, menuseparator, endmenu \} } macro dlgdefprop prop:''& { local ..done ..done = $ match any =, more,prop \{ du prop,0 \} if $ = ..done if prop eqtype '' if prop eq '' dw 0 else du prop,0 end if else if ~prop dw 0 else dw -1,prop end if end if end if } macro dlgdefchild class:''& { local ..done,tmpclass ..done = $ match any =, more,class \{ du class,0 \} if $ = ..done if class eqtype '' if class eq 'BUTTON' dw -1, 80h else if class eq 'EDIT' dw -1, 81h else if class eq 'STATIC' dw -1, 82h else if class eq 'LISTBOX' dw -1, 83h else if class eq 'SCROLLBAR' dw -1, 84h else if class eq 'COMBOBOX' dw -1, 85h else if class eq '' dw 0 else du class,0 end if else if (class and 1Fh) =10 | (class and 1Fh) =16 | (class-(class and 80h))>18h | class<0 .err unsupported classID = class end if dw -1,class end if end if } macro dialog label,class,title,x,y,cx,cy,style:0,exstyle:0,menu,fontname,fontsize:0 { local data,size,items label dd RVA data,size,0,0 data dd style,exstyle dw items,x,y,cx,cy dlgdefprop menu dlgdefprop class dlgdefprop title if style and DS_SETFONT if fontname eq du 8,'MS Sans Serif',0 else du fontsize,fontname,0 end if end if align 4 dialog_size equ size = $ - data dialog_items equ items = dialog_items_counter dialog_items_counter = 0 macro dlgitmxtrdata \{ local fin store word (fin-$) at $-2 macro enddlgitmxtrdata \\{ fin = $ \\} \} macro enddialog \{ dialog_items dialog_size purge dlgitmxtrdata,enddialog,enddlgitmxtrdata \} } ANSl_CHARSET = 0 DEFAULT_CHARSET = 1 SYMBOL_CHARSET = 2 MAC_CHARSET = 77 SHIFTJIS_CHARSET = 128 HANGEUL_CHARSET = 129 HANGUL_CHARSET = 129 JOHAB_CHARSET = 130 GB2312_CHARSET = 134 CHINESEBIG5_CHARSET = 136 GREEK_CHARSEO = 161 TURKISH_CHARSET = 162 VIETNAMESE_CHARSET = 163 HEBREW_CHARSET = 177 ARABIC_CHARSET = 178 BALTIC_CHARSET = 186 THAI_CHARSET = 222 EASTEUROPE_CHARSET = 238 RUSSIAN_CHARSET = 204 OEM_CHARSET = 255 macro dialogex label,class,title,x,y,cx,cy,style:0,exstyle:0,menu,helpID:0,fontname,fontsize:0,fontweight:0,italic:0,charset:1 { local data,size,items label dd RVA data,size,0,0 align 16 data dw 1,0FFFFh dd helpID dd exstyle,style dw items,x,y,cx,cy dlgdefprop menu dlgdefprop class dlgdefprop title ;fontweight=0..1000; 0=default=400; bold = 700 if style and DS_SETFONT ;or DS_SHELLFONT=DS_SETFONT or DS_FIXEDSYS if fontname eq dw 8,400 db italic, charset du 'MS Sans Serif',0 else dw fontsize,fontweight db italic, charset du fontname,0 end if end if align 4 dialog_size equ size = $ - data dialog_items equ items = dialog_items_counter dialog_items_counter = 0 macro dlgitmxtrdata \{ local fin store word (fin-$) at $-2 macro enddlgitmxtrdata \\{ fin = $ \\} \} macro enddialog \{ dialog_items dialog_size purge dlgitmxtrdata,enddialog,enddlgitmxtrdata \} } macro dialogitem class,title,id,x,y,cx,cy,style:0,exstyle:0 { align 4 dd style or WS_CHILD,exstyle dw x,y,cx,cy,id dlgdefchild class dlgdefprop title dw 0 dialog_items_counter = dialog_items_counter + 1 } macro dialogitemex class,title,id,x,y,cx,cy,style:0,exstyle:0,helpID:0 { align 4 dd helpID,exstyle,style or WS_CHILD dw x,y,cx,cy dd id ; against dialogitem here ID has dword size dlgdefchild class dlgdefprop title dw 0 dialog_items_counter = dialog_items_counter + 1 } IDM_GETTEXT equ 32000;1 IDM_CLEAR equ 32001;2 IDM_EXIT equ 32002;3 IDC_BUTTON equ 3001;4 IDC_EXIT equ 3002;5 IDC_EDIT equ 3000;6 IDC_MENU equ 100 IDC_DIALOG equ 200 size_of_buffer equ 512 section '.text' code readable executable start: invoke LoadIcon,0,IDI_APPLICATION mov [wc.hIcon],eax invoke LoadCursor,0,IDC_ARROW mov [wc.hCursor],eax invoke RegisterClassEx,wc test eax,eax jz error invoke CreateDialogParam,PE_IMAGE_BASE,IDC_DIALOG,NULL,NULL,NULL test eax,eax jz error mov [hdlg],eax invoke GetDlgItem,eax,IDC_EDIT invoke SetFocus,eax invoke ShowWindow,[hdlg],SW_SHOWNORMAL invoke UpdateWindow,[hdlg] msg_loop: invoke GetMessage,msg,NULL,0,0 cmp eax,1 jb end_loop jne msg_loop invoke IsDialogMessage,[hdlg],msg jnz msg_loop invoke TranslateMessage,msg invoke DispatchMessage,msg jmp msg_loop error: invoke MessageBox,NULL,_error,NULL,MB_ICONERROR+MB_OK end_loop: invoke ExitProcess,[msg.wParam] proc WindowProc uses ebx esi edi, hwnd,wmsg,wparam,lparam mov eax, [wmsg] cmp eax,WM_CREATE je .wmcreate cmp eax,WM_DESTROY je .wmdestroy cmp eax,WM_COMMAND je .wmcommand .defwndproc: invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam] jmp .finish .wmcreate: invoke SetDlgItemText,[hwnd],IDC_EDIT,_title xor eax,eax jmp .finish .wmdestroy: invoke PostQuitMessage,0 xor eax,eax jmp .finish .wmcommand: mov eax, [wparam] cmp [lparam], 0 jnz .notmenucmd cmp ax,IDM_GETTEXT jz .mnuGetText cmp ax,IDM_CLEAR jz .mnuClrText .mnuExit: invoke DestroyWindow,[hwnd] jmp .ret0 .mnuGetText: invoke GetDlgItemText,[hwnd],IDC_EDIT,_buffer,size_of_buffer invoke MessageBox,NULL,_buffer,_title,MB_OK jmp .ret0 .mnuClrText: invoke SetDlgItemText,[hwnd],IDC_EDIT,NULL jmp .ret0 .notmenucmd: cmp eax,BN_CLICKED shl 16 + IDC_EXIT jz .mnuExit cmp eax,BN_CLICKED shl 16 + IDC_BUTTON jnz .ret0 invoke SetDlgItemText,[hwnd],IDC_EDIT,_teststr .ret0: xor eax,eax .finish: ret endp section '.data' data readable writeable _class TCHAR 'FASMWIN32',0 _title TCHAR 'Win32 program template',0 _error TCHAR 'Startup failed.',0 _teststr TCHAR 'Wow! I''m in an edit box now',0 wc WNDCLASSEX sizeof.WNDCLASSEX,CS_HREDRAW or CS_VREDRAW,WindowProc,0,DLGWINDOWEXTRA,PE_IMAGE_BASE,NULL,NULL,COLOR_BTNFACE+1,IDC_MENU,_class hdlg dd ? msg MSG _buffer TCHAR size_of_buffer dup (?) section '.idata' import data readable writeable library kernel32,'KERNEL32.DLL',\ user32,'USER32.DLL' include 'os specific/windows/api/x86/kernel32.inc' include 'os specific/windows/api/x86/user32.inc' section '.rsrc' resource data readable directory RT_MENU,menus,\ RT_DIALOG,dialogs resource dialogs,IDC_DIALOG,LANG_ENGLISH+SUBLANG_DEFAULT,DIALOGEXS dialog DIALOGEXS,'FASMWIN32',"Iczelion Tutorial #10c: CreateDialogParam+WndProc+Class",10, 10, 230, 60,DS_CENTER or WS_CAPTION or WS_MINIMIZEBOX or WS_SYSMENU or WS_VISIBLE or WS_OVERLAPPED or DS_MODALFRAME or DS_3DLOOK or DS_SETFONT,,IDC_MENU,'Times New Roman',10 dialogitem 'EDIT','',IDC_EDIT,15,17,111,13,WS_VISIBLE or ES_LEFT or WS_TABSTOP or ES_AUTOHSCROLL dialogitem 'BUTTON',"Say Hello",IDC_BUTTON,141,10,52, 13,WS_VISIBLE or WS_TABSTOP dialogitem 'BUTTON',"E&xit",IDC_EXIT,141,26,52, 13,WS_VISIBLE or WS_TABSTOP enddialog resource menus,IDC_MENU,LANG_ENGLISH+SUBLANG_DEFAULT,mainMenu menu ,mainMenu menuitem "Test Controls",0,MF_POPUP+MF_END menuitem "Get Text",IDM_GETTEXT menuitem "Clear Text",IDM_CLEAR menuseparator menuitem 'E&xit',IDM_EXIT,MF_END endmenu |
|||
![]() |
|
mns 30 Dec 2019, 06:10
Thank you ProMiNick.It is working too.(and only I had to add "PE_IMAGE_BASE equ 400000h" as it wasn't defined in my files)
|
|||
![]() |
|
ProMiNick 30 Dec 2019, 06:26
I define PE_IMAGE_BASE as
Code: if used PE_IMAGE_BASE PE_IMAGE_BASE = $-rva $ end if that let me use it when it is needed (and in case of not PE - I never use it: absence of rva not cause error) - I include such definition in all win32|64|a|w.inc(s). It is more common than just $400000. |
|||
![]() |
|
mns 30 Dec 2019, 18:29
Thanks.
![]() |
|||
![]() |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.