Hi,
When I use a struct with pre-initialized values, my app crashes. the struct is SHELLEXECUTEINFO
Thanks for help.
you might try using GetLastError after the ShellExecuteEx call to determine the cause of the error
Hi,
.data
shellinfo SHELLEXECUTEINFO <60,SEE_MASK_NOCLOSEPROCESS,0,0,firefox ,url,0,SW_MAXIMIZE,0,0,0,0,0,0,0>
This doesn't work. assembler error:
: error A2138: invalid data initializer
: error A2036: too many initial values for structure
.data
shellinfo dword 60,SEE_MASK_NOCLOSEPROCESS,0,0,firefox ,url,0,SW_MAXIMIZE,0,0,0,0,0,0,0
This works
Are firefox ,url defined?
Quote from: jj2007 on August 16, 2010, 04:58:22 PM
Are firefox ,url defined?
Yes
Bad
.data
shellinfo SHELLEXECUTEINFO <60,SEE_MASK_NOCLOSEPROCESS,0,0,firefox ,url,0,SW_MAXIMIZE,0,0,0,0,0,0,0>
url byte "http://www.masm32.com/board/index.php",0
firefox byte "C:\Program Files (x86)\Mozilla Firefox\firefox.exe",0
Good
.data
shellinfo dword 60,SEE_MASK_NOCLOSEPROCESS,0,0,firefox ,url,0,SW_MAXIMIZE,0,0,0,0,0,0,0
url byte "http://www.masm32.com/board/index.php",0
firefox byte "C:\Program Files (x86)\Mozilla Firefox\firefox.exe",0
it looks ok - i don't see the problem jumping out at me :P
i can think of a few things to verify or try
1) certainly, windows.inc must be included prior to any of the data defines (we assume you have that)
2) maybe url and firefox should be defined before shellinfo
3) if all else fails, punt :bg
shellinfo SHELLEXECUTEINFO <60,dword ptr SEE_MASK_NOCLOSEPROCESS,0,0,offset firefox,offset url,0,dword ptr SW_MAXIMIZE,0,0,0,0,0,0,0>
Quote from: dedndave on August 16, 2010, 05:32:20 PM
it looks ok - i don't see the problem jumping out at me :P
i can think of a few things to verify or try
1) certainly, windows.inc must be included prior to any of the data defines (we assume you have that)
2) maybe url and firefox should be defined before shellinfo
3) if all else fails, punt :bg
shellinfo SHELLEXECUTEINFO <60,dword ptr SEE_MASK_NOCLOSEPROCESS,0,0,offset firefox,offset url,0,dword ptr SW_MAXIMIZE,0,0,0,0,0,0,0>
.data?
shellinfo SHELLEXECUTEINFO <?>
This works. but then all members need to be filled by code.
windows.inc is included
defining url and firefox before shellinfo makes no difference.
I think I am doing something wrong. or is it a Masm bug?
It accepts 13 members for the struct. but the struct has 15 members. so
shellinfo SHELLEXECUTEINFO <60,SEE_MASK_NOCLOSEPROCESS,0,0,firefox ,url,0,SW_MAXIMIZE,0,0,0,0,0>
assembles.
I think it has to do with the
union
hIcon DWORD 0
hMonitor DWORD 0
ends
which is embedded within the struct.
we have used that union syntax on many other items
it would be strange if it was the problem
but, you can test your theory by temporarily modifying the structure definition
probably easiest to just define a new structure in your asm file, named something else, that has 15 dwords
what version of masm are you using ?
Quote from: usingMasm on August 16, 2010, 06:09:45 PM
I think it has to do with the
union
hIcon DWORD 0
hMonitor DWORD 0
ends
which is embedded within the struct.
Example without union:
include \masm32\include\masm32rt.inc
SHELLEXECUTEINFOX STRUCT
cbSize DWORD ?
fMask DWORD ?
hwnd DWORD ?
lpVerb DWORD ?
lpFile DWORD ?
lpParameters DWORD ?
lpDirectory DWORD ?
nShow DWORD ?
hInstApp DWORD ?
lpIDList DWORD ?
lpClass DWORD ?
hkeyClass DWORD ?
dwHotKey DWORD ? ; NO UNION
hIcon DWORD ?
hProcess DWORD ?
SHELLEXECUTEINFOX ENDS
.data
url byte "http://www.masm32.com/board/index.php",0
firefox byte "C:\Program Files (x86)\Mozilla Firefox\firefox.exe",0
shellinfo1 SHELLEXECUTEINFOX <60, SEE_MASK_NOCLOSEPROCESS, 0, 0, firefox, url, 0, SW_MAXIMIZE>
shellinfo2 SHELLEXECUTEINFOX <60, SEE_MASK_NOCLOSEPROCESS, 0, 0, firefox, url, 0, SW_MAXIMIZE, 0, 0, 0, 0, 0, 0, 0>
.code
start: inkey "OK"
exit
end start
Mysterious. Jwasm behaves the same. Apparently you can declare
less members.
don't suppose "shellinfo" or "url" are used elsewhere
Quote from: dedndave on August 16, 2010, 06:19:34 PM
we have used that union syntax on many other items
it would be strange if it was the problem
but, you can test your theory by temporarily modifying the structure definition
probably easiest to just define a new structure in your asm file, named something else, that has 15 dwords
what version of masm are you using ?
latest version.
I did a struct of my own with 15 members. didn't work.
Quote from: dedndave on August 16, 2010, 06:25:35 PM
don't suppose "shellinfo" or "url" are used elsewhere
no
It works without the UNION. Apparently M$ had that problem earlier and didn't fix it properly:
FIX: A2138, A2036 or Hang, Init Nested Structure Array (http://support.microsoft.com/kb/94912)
We may have never noticed this bug because most members don't use initialised structures.
Quote from: jj2007 on August 16, 2010, 06:57:06 PM
It works without the UNION. Apparently M$ had that problem earlier and didn't fix it properly:
FIX: A2138, A2036 or Hang, Init Nested Structure Array (http://support.microsoft.com/kb/94912)
We may have never noticed this bug because most members don't use initialised structures.
the fix has apparently not fixed it. I am using the latest masm. and the struct doesn't have any dup operator. it seems 13 is as many members as can be initialized.
it is worse than that. declaring "shellinfo SHELLEXECUTEINFO <>" in .data section and filling the members with code assembles but causes system crash. seems it is accessing some forbidden memory sections. only .data? section works.
Quote from: usingMasm on August 16, 2010, 07:08:33 PM
Quote from: jj2007 on August 16, 2010, 06:57:06 PM
It works without the UNION. Apparently M$ had that problem earlier and didn't fix it properly:
FIX: A2138, A2036 or Hang, Init Nested Structure Array (http://support.microsoft.com/kb/94912)
We may have never noticed this bug because most members don't use initialised structures.
the fix has apparently not fixed it. I am using the latest masm. and the struct doesn't have any dup operator. it seems 13 is as many members as can be initialized.
It works perfectly with 15 members if you redefine the structure without the UNION. Tested with ml 6.15, 9.0 and JWasm.
Quote from: jj2007 on August 16, 2010, 07:45:45 PM
Quote from: usingMasm on August 16, 2010, 07:08:33 PM
Quote from: jj2007 on August 16, 2010, 06:57:06 PM
It works without the UNION. Apparently M$ had that problem earlier and didn't fix it properly:
FIX: A2138, A2036 or Hang, Init Nested Structure Array (http://support.microsoft.com/kb/94912)
We may have never noticed this bug because most members don't use initialised structures.
the fix has apparently not fixed it. I am using the latest masm. and the struct doesn't have any dup operator. it seems 13 is as many members as can be initialized.
It works perfectly with 15 members if you redefine the structure without the UNION. Tested with ml 6.15, 9.0 and JWasm.
it assembles but ShellExecuteEx returns access denied.
Quote from: jj2007 on August 16, 2010, 06:57:06 PMmost members don't use initialised structures.
Speak for yourself please :snooty:
unions are initialized the same way as structures, see here (jj take notes :wink):
http://www.masm32.com/board/index.php?topic=10272.msg75289#msg75289
shellinfo SHELLEXECUTEINFO <60,SEE_MASK_NOCLOSEPROCESS,0,0,firefox,url,0,SW_MAXIMIZE,0,0,0,0,0,<0>,0>
Quote from: usingMasm on August 16, 2010, 09:07:39 PMit assembles but ShellExecuteEx returns access denied.
And you tried running it as an Administrator?
Quote from: drizz on August 16, 2010, 09:52:55 PM
Quote from: jj2007 on August 16, 2010, 06:57:06 PMmost members don't use initialised structures.
Speak for yourself please :snooty:
unions are initialized the same way as structures, see here (jj take notes :wink):
http://www.masm32.com/board/index.php?topic=10272.msg75289#msg75289
shellinfo SHELLEXECUTEINFO <60,SEE_MASK_NOCLOSEPROCESS,0,0,firefox,url,0,SW_MAXIMIZE,0,0,0,0,0,<0>,0>
Quote from: usingMasm on August 16, 2010, 09:07:39 PMit assembles but ShellExecuteEx returns access denied.
And you tried running it as an Administrator?
Thanks a lot.
shellinfo SHELLEXECUTEINFO <60,SEE_MASK_NOCLOSEPROCESS,0,0,firefox,url,0,SW_MAXIMIZE,0,0,0,0,0,<0>,0>
works perfect.
very cool Drizz - thanks for the help
i will take notes also :P