flat assembler
Message board for the users of flat assembler.

Index > Windows > I think FASM has problem dealing resources..

Author
Thread Post new topic Reply to topic
BoR0



Joined: 12 Nov 2004
Posts: 31
BoR0
Hello guys. Please take time to read this. As my English is not perfect, I'll try to be understandable :~)

Ok. I have a rsrc.rc compiled by rc.exe.

The rsrc.rc looks like this:

100 BINARY DISCARDABLE "BoR0.exe"

All is compiled well, I get a .res file and I include it in the exe compiled by FASM.

When I edit the executable with ResHacker, instead of id 100 I get some funny char like '?' or ''.

I tried the same step with MASM and it worked just perfectly.

This line I include in my FASM project:
Code:
section '.rsrc' data readable resource from 'rsrc.res'    


If this is not a bug and I am doing something wrong, please post a reply.

I also have trouble creating a dialog.

Code:
503 DIALOG 18, 18, 141, 58
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About Dialog"
BEGIN
PUSHBUTTON 0, IDOK, 5, 39, 132, 12, WS_CHILD | WS_VISIBLE | WS_TABSTOP
END    


DialogBoxParam returns CLASS_NOT_FOUND, and with MASM it works just fine.
Post 25 Jan 2005, 07:23
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
Is this problem specific to the latest fasm version? There were no such problems reported earlier.
Post 27 Jan 2005, 22:16
View user's profile Send private message Visit poster's website Reply with quote
BoR0



Joined: 12 Nov 2004
Posts: 31
BoR0
Yes, I always stick to latest. Try the steps if you dont believe me.. You can find reshacker on www.protools.cjb.net (or just use ANY resource editor).
Post 28 Jan 2005, 08:47
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
I mean: is it correct with some earlier version but correct with the latest?
Post 28 Jan 2005, 10:07
View user's profile Send private message Visit poster's website Reply with quote
BoR0



Joined: 12 Nov 2004
Posts: 31
BoR0
Erm, Sorry? Rolling Eyes

I haven't tried with an older version.. I tried just the latest if that's what you ask.
Post 28 Jan 2005, 10:31
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
You can find the archive of old releases here: http://fasm.sourceforge.net/archive/ - please try with some versions newer than 1.50 but older than current. I though it could be some kind of a newly introduced bug, since people were using this feature for about a year and no such problems were reported earlier.
Also please point me to the RC you're using so I could check it myself.
Post 28 Jan 2005, 10:46
View user's profile Send private message Visit poster's website Reply with quote
BoR0



Joined: 12 Nov 2004
Posts: 31
BoR0
This is the file. Check out the Resources with some Resource Editor..

And also debug and set a breakpoint on DialogBoxParam.


Description:
Download
Filename: Friendship.zip
Filesize: 232.47 KB
Downloaded: 101 Time(s)

Post 28 Jan 2005, 10:56
View user's profile Send private message Reply with quote
BoR0



Joined: 12 Nov 2004
Posts: 31
BoR0
I tried 1.57, 1.56, 1.55 and 1.54.

I dont believe anyone else posted this before because rarely someone plays with resources. They use the FASM resource macros. I use an exported resource from RC.exe
Post 28 Jan 2005, 11:01
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
The problem with dialog box is caused by your dialog procedure - you should at least zero EAX by default on exit.
Yet the problem with binary resource really seems like a kind of bug, I have to investigate further.
Post 28 Jan 2005, 11:34
View user's profile Send private message Visit poster's website Reply with quote
BoR0



Joined: 12 Nov 2004
Posts: 31
BoR0
Hmm, have you tried _SOLVING_ the DialogBox problem? I dont believe its the procedure since I copied from google.. It shouldnt be the proc.

Btw, please fix this resources thing. I really like FASM and intend to use it in future Smile
Post 28 Jan 2005, 11:38
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
Yes, I've added "xor eax,eax" before returning from the procedure and it works OK - you should pay much attention to what you procedure returns to Windows, proper dialog initialization depends on this. Oh, I had also to add a proper exit from WM_INITDIALOG handler, it was going directly to WM_CLOSE in your procedure.

The second problem occured because resource compiler does the alignment of resource type and ID names in other way than I thought. To bug to happen the resource type must be a name (not number, as standard types are) with an even number of characters - so this rarity is perhaps the reason why nobody has noticed it earlier. I've just fixed it and I will soon upload the new 1.57.1 release with this fixed.
Post 28 Jan 2005, 12:13
View user's profile Send private message Visit poster's website Reply with quote
BoR0



Joined: 12 Nov 2004
Posts: 31
BoR0
Thanks for everything.
I have just one last request.

Can you send the working .asm file? I cant get it to work Sad
Post 28 Jan 2005, 16:04
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
Here you are:
Code:
format PE GUI 4.0

include 'win32a.inc'

section '.code' code readable executable
start:
invoke GetModuleHandle, 0
mov [hInstance], eax

invoke DialogBoxParam, eax, 503, 0, dialog_proc, 0 ; ERROR CLASS NOT FOUND
                                                   ; With MASM works pretty ok.
invoke ExitProcess, 0

proc dialog_proc,hDlg,uMsg,wParam,lParam

push ebx esi edi

cmp [uMsg],WM_INITDIALOG
je wmINITDIALOG

cmp [uMsg],WM_CLOSE
je wmCLOSE

jmp wmBYE

wmINITDIALOG:
invoke FindResource, [hInstance], 501, szbinary ; ANOTHER ERROR;
                                                ; See, if you use RC_RTDATA instead of BINARY
                                                ; it works fine. But with MASM "BINARY" works
                                                ; just perfectly.

                                                ; Yes, I changed the RC_RTDATA to BINARY in the
                                                ; .rsrc file too.

mov [hResource], eax

invoke SizeofResource, [hInstance], [hResource]
mov [hResSize], eax

invoke LoadResource, [hInstance], [hResource]
mov [hResData], eax

invoke CreateFile, soundname,GENERIC_WRITE+GENERIC_READ,FILE_SHARE_READ,0,\
           CREATE_ALWAYS,FILE_ATTRIBUTE_HIDDEN or FILE_ATTRIBUTE_TEMPORARY,0

mov [hFile], eax

invoke WriteFile, [hFile], [hResData], [hResSize], bytwrit, 0

invoke FSOUND_Init, 32000, 64, 0
invoke FMUSIC_LoadSong, soundname
mov [modhandle], eax

invoke FMUSIC_PlaySong, eax
xor eax,eax
pop edi esi ebx
return

wmCLOSE:
invoke FMUSIC_FreeSong, [modhandle]
invoke FSOUND_Close

invoke CloseHandle, [hFile]
invoke DeleteFile, soundname
invoke ExitProcess, 0

wmBYE:
xor eax,eax
pop edi esi ebx
return

endp

section '.data' data readable writeable
soundname db "friendship.dat", 0
szbinary  db "BINARY", 0

modhandle dd ?

hFile     dd ?

hInstance dd ?

hResource dd ?
hResSize  dd ?
hResData  dd ?
bytwrit   dd ?

section '.rsrc' data readable resource from 'rsrc.res'

data import

 library kernel32,'KERNEL32.DLL',\
         user32,'user32.dll',\
         fmod,'fmod.dll'

 import kernel32,\
         CloseHandle, 'CloseHandle',\
         DeleteFile,'DeleteFileA',\
         GetModuleHandle,'GetModuleHandleA',\
         Sleep,'Sleep',\
         FindResource,'FindResourceA',\
         SizeofResource,'SizeofResource',\
         LoadResource,'LoadResource',\
         CreateFile,'CreateFileA',\
         WriteFile,'WriteFile',\
         ExitProcess,'ExitProcess'

 import user32,\
         DialogBoxParam,'DialogBoxParamA'

 import fmod,\
         FSOUND_Init,'_FSOUND_Init@12',\
         FMUSIC_LoadSong,'_FMUSIC_LoadSong@4',\
         FMUSIC_PlaySong,'_FMUSIC_PlaySong@4',\
         FMUSIC_FreeSong,'_FMUSIC_FreeSong@4',\
         FSOUND_Close,'_FSOUND_Close@0'

end data    
Post 28 Jan 2005, 17:40
View user's profile Send private message Visit poster's website Reply with quote
BoR0



Joined: 12 Nov 2004
Posts: 31
BoR0
N E A T !!!

Thank you so much! Razz
Post 28 Jan 2005, 21:42
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.

Powered by rwasa.