flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Strange thing about resources [bug?]

Author
Thread Post new topic Reply to topic
AsmER



Joined: 25 Mar 2006
Posts: 64
Location: England
AsmER
I have just found something pretty strange.
When I create resources for my application, using separate section like this:
Code:
section 'rs' resource readable writeable
        directory RT_MENU,menus,\
                RT_DIALOG, dialogs,\
                RT_ICON,icons,\
                RT_GROUP_ICON,group_icons


        resource menus,\
                IDM_MainMenu,LANG_ENGLISH,main_menu

        resource dialogs,\
                IDD_Options, LANG_ENGLISH, Options_Dlg

        resource icons,\
                1,LANG_NEUTRAL,icon_data

        resource group_icons,\
                IDI_MainIcon,LANG_NEUTRAL,main_icon

        menu main_menu
                menuitem '&Window',0,MFR_POPUP
                        menuitem '&Options',IDC_Options
                        menuseparator
                        menuitem 'E&xit',IDC_Exit,MFR_END
                menuitem '&About',IDC_About, MFR_END

        icon main_icon,icon_data,'WMIcon.ico'

        dialog Options_Dlg, 'Options', 0, 0, 300, 215, WS_VISIBLE+WS_CAPTION+DS_3DLOOK+WS_SYSMENU, WS_EX_TOPMOST+WS_EX_TOOLWINDOW
                dialogitem 'LISTBOX', '', IDOC_Programs, 10, 10, 120, 80, WS_VISIBLE+LBS_NOINTEGRALHEIGHT+WS_BORDER+WS_HSCROLL+WS_VSCROLL+LBS_NOTIFY
                dialogitem 'BUTTON', '',IDOC_Assign, 10, 95, 120, 15, WS_VISIBLE+BS_VCENTER
                dialogitem 'LISTBOX', '', IDOC_Commands, 140, 10, 150, 80, WS_VISIBLE+LBS_NOINTEGRALHEIGHT+WS_BORDER
                dialogitem 'BUTTON', 'Remove Task', IDOC_Remove, 140, 95, 150, 15, WS_VISIBLE
                dialogitem 'BUTTON','NEW TASK', 0, 10, 115, 280, 5, WS_VISIBLE+BS_GROUPBOX+WS_DISABLED
                dialogitem 'STATIC','', IDOC_CtrlName, 10, 130, 120, 35, WS_VISIBLE+WS_BORDER
                dialogitem 'BUTTON','Find Menu', IDOC_Find, 10, 165, 120, 15, WS_VISIBLE
                dialogitem 'BUTTON', 'Add Task', IDOC_Add, 140, 145, 150, 15, WS_VISIBLE
                dialogitem 'BUTTON','', IDOC_Progress, 140, 165, 150, 15, WS_VISIBLE+BS_VCENTER+BS_FLAT+WS_DISABLED
                dialogitem 'STATIC','Every', 1, 140, 130, 40, 15, WS_VISIBLE
                dialogitem 'EDIT','',IDOC_Delay, 165, 130, 30, 10, WS_VISIBLE+ES_NUMBER+WS_BORDER
                dialogitem 'STATIC','min', 0, 200, 130, 30, 10, WS_VISIBLE
                dialogitem 'BUTTON','CLOSE',IDOC_Close, 130, 190, 40, 15, WS_VISIBLE
        enddialog
    

Everything works perfectly [my application have its menu and all resources working after start].
But when I create just the same resources using data resource directive, and recompile my app. menu is not visible anymore [resource viewers state that resources section in invalid/corrupted]:
Code:
data resource
;section 'rs' resource readable writeable
        directory RT_MENU,menus,\
                RT_DIALOG, dialogs,\
                RT_ICON,icons,\
                RT_GROUP_ICON,group_icons


        resource menus,\
                IDM_MainMenu,LANG_ENGLISH,main_menu

        resource dialogs,\
                IDD_Options, LANG_ENGLISH, Options_Dlg

        resource icons,\
                1,LANG_NEUTRAL,icon_data

        resource group_icons,\
                IDI_MainIcon,LANG_NEUTRAL,main_icon

        menu main_menu
                menuitem '&Window',0,MFR_POPUP
                        menuitem '&Options',IDC_Options
                        menuseparator
                        menuitem 'E&xit',IDC_Exit,MFR_END
                menuitem '&About',IDC_About, MFR_END

        icon main_icon,icon_data,'WMIcon.ico'

        dialog Options_Dlg, 'Options', 0, 0, 300, 215, WS_VISIBLE+WS_CAPTION+DS_3DLOOK+WS_SYSMENU, WS_EX_TOPMOST+WS_EX_TOOLWINDOW
                dialogitem 'LISTBOX', '', IDOC_Programs, 10, 10, 120, 80, WS_VISIBLE+LBS_NOINTEGRALHEIGHT+WS_BORDER+WS_HSCROLL+WS_VSCROLL+LBS_NOTIFY
                dialogitem 'BUTTON', '',IDOC_Assign, 10, 95, 120, 15, WS_VISIBLE+BS_VCENTER
                dialogitem 'LISTBOX', '', IDOC_Commands, 140, 10, 150, 80, WS_VISIBLE+LBS_NOINTEGRALHEIGHT+WS_BORDER
                dialogitem 'BUTTON', 'Remove Task', IDOC_Remove, 140, 95, 150, 15, WS_VISIBLE
                dialogitem 'BUTTON','NEW TASK', 0, 10, 115, 280, 5, WS_VISIBLE+BS_GROUPBOX+WS_DISABLED
                dialogitem 'STATIC','', IDOC_CtrlName, 10, 130, 120, 35, WS_VISIBLE+WS_BORDER
                dialogitem 'BUTTON','Find Menu', IDOC_Find, 10, 165, 120, 15, WS_VISIBLE
                dialogitem 'BUTTON', 'Add Task', IDOC_Add, 140, 145, 150, 15, WS_VISIBLE
                dialogitem 'BUTTON','', IDOC_Progress, 140, 165, 150, 15, WS_VISIBLE+BS_VCENTER+BS_FLAT+WS_DISABLED
                dialogitem 'STATIC','Every', 1, 140, 130, 40, 15, WS_VISIBLE
                dialogitem 'EDIT','',IDOC_Delay, 165, 130, 30, 10, WS_VISIBLE+ES_NUMBER+WS_BORDER
                dialogitem 'STATIC','min', 0, 200, 130, 30, 10, WS_VISIBLE
                dialogitem 'BUTTON','CLOSE',IDOC_Close, 130, 190, 40, 15, WS_VISIBLE
        enddialog
        ; might as well be here [won't change anything]
        ; icon main_icon,icon_data,'WMIcon.ico'

end data
    


and now the strangest thing for me: after moving the line which defines the icon, like this:
Code:
data resource
...
        resource group_icons,\
                IDI_MainIcon,LANG_NEUTRAL,main_icon

        ;---now its here---
        icon main_icon,icon_data,'WMIcon.ico'     

        menu main_menu
                menuitem '&Window',0,MFR_POPUP
                        menuitem '&Options',IDC_Options
                        menuseparator
                        menuitem 'E&xit',IDC_Exit,MFR_END
                menuitem '&About',IDC_About, MFR_END 
...
end data
    

IT WORKS AGAIN o_O?! I don't know why. Can't find anything in help file about order of definitions that can cause trouble [well, it cant really. it worked before, didn't it?Wink + when I leave icon main_icon,icon_data,'WMIcon.ico' there and use section directive again, it still works]
If i missed anything please infor me ;]

_________________
;\\ http://theasmer.spaces.live.com \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Post 04 Jan 2008, 01:41
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17349
Location: In your JS exploiting you and your system
revolution
Check the alignment of the resources.
Code:
align 16
data resources
...    
might help. This is just my guess. I haven't tried it.
Post 04 Jan 2008, 06:47
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
I always use "align 4" and works but I have no references, it was just a trial an error (and since I used 4 in my first attempt there was no errors Laughing)
Post 04 Jan 2008, 14:24
View user's profile Send private message Reply with quote
AsmER



Joined: 25 Mar 2006
Posts: 64
Location: England
AsmER
Yeah, I have tried align 4 as well and worked too Very Happy
However I'm not too sure about why it works straight away with section directive... does it add align automatically? Hmmm, I guess I will really need to learn something more about all the things I do not always treat as important x) Thanks for your replays.
-would be nice if fasm could find out whenever such alignment is required or not, and inform about it or just add alignment automatically ;]
Post 04 Jan 2008, 14:32
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Yes, a section is aligned to a page boundary so it is ultra hyper aligned to 4 as well Razz

http://flatassembler.net/docs.php?article=manual#2.4.2 wrote:
section directive defines a new section, it should be followed by quoted string defining the name of section, then one or more section flags can follow. Available flags are: code, data, readable, writeable, executable, shareable, discardable, notpageable. The origin of section is aligned to page (4096 bytes). Example declaration of PE section:

section '.text' code readable executable

Post 04 Jan 2008, 14:37
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.