Discussion:
Generating sound during boot sequence
(too old to reply)
JMRanger
2010-03-03 23:01:01 UTC
Permalink
I'm trying to generate sound as early as possible during the CE boot process.
To do so, I wrote a dummy driver that calls PlaySound during either its
DllEntry() or Init() call. My idea was to priorize audio drivers in the load
order, and load that dummy one afterward.

Code is simply
playRes = PlaySound(TEXT("\\Windows\\sound1.wav"), NULL, SND_ASYNC);

Apparently, this isn't a good idea. The call to PlaySound works (i.e. sound
is played), but PlaySond' return value is FALSE. In addition, the debug
console adds:

Exception 'Raised Exception' (-1): Thread-Id=01500002(pth=87f7da38),
Proc-Id=00400002(pprc=82631308) 'NK.EXE', VM-active=00400002(pprc=82631308)
'NK.EXE'
PC=c0033c34(k.coredll.dll+0x00013c34) RA=800a64c8(kernel.dll+0x000064c8)
SP=d02ae3a0, BVA=00000000

Trying to catch that with __try/__except changes nothing.

It seems to be specific to DllEntry/Init: placing the call in Open() works
fine - but too late for my purpose (unless there's a way to trigger that call
early that I'm unaware of ?)

Ideas ?

This is on CE 6.0 R3.

Thanks.
Luca Calligaris [eMVP]
2010-03-04 09:25:09 UTC
Permalink
Calling PlaySound from DllEntry is a bad idea. Check the docs:

Do not call LoadLibrary in the entry-point function, because you might
create dependency loops in the DLL load order. This can cause a DLL to be
used before the system executes its initialization code.
Similarly, do not call the FreeLibrary function in the entry-point function
on detach, because this can cause a DLL to be used after the system executes
its termination code.
Calling Microsoft® Win32® functions other than TLS, object-creation, and
file functions can cause problems that are difficult to diagnose.
For example, calling User, Shell, COM, and Windows Sockets functions (or
functions that call these functions) can cause access violation errors,
because their DLLs call LoadLibrary to load other system components.

About using it in init, what error you get calling GetLastError() when
Playsound returns FALSE?
--
Luca Calligaris (MVP-Windows Embedded)
***@eurotech.it.nospam
www.eurotech.it
Post by JMRanger
I'm trying to generate sound as early as possible during the CE boot process.
To do so, I wrote a dummy driver that calls PlaySound during either its
DllEntry() or Init() call. My idea was to priorize audio drivers in the load
order, and load that dummy one afterward.
Code is simply
playRes = PlaySound(TEXT("\\Windows\\sound1.wav"), NULL, SND_ASYNC);
Apparently, this isn't a good idea. The call to PlaySound works (i.e. sound
is played), but PlaySond' return value is FALSE. In addition, the debug
Exception 'Raised Exception' (-1): Thread-Id=01500002(pth=87f7da38),
Proc-Id=00400002(pprc=82631308) 'NK.EXE',
VM-active=00400002(pprc=82631308)
'NK.EXE'
PC=c0033c34(k.coredll.dll+0x00013c34) RA=800a64c8(kernel.dll+0x000064c8)
SP=d02ae3a0, BVA=00000000
Trying to catch that with __try/__except changes nothing.
It seems to be specific to DllEntry/Init: placing the call in Open() works
fine - but too late for my purpose (unless there's a way to trigger that call
early that I'm unaware of ?)
Ideas ?
This is on CE 6.0 R3.
Thanks.
JMRanger
2010-03-04 13:35:01 UTC
Permalink
Hello Luca,

I felt that it was wrongin DllEntry, and possibly wrong in Init(). Thanks
for clarifying.

Error code is 87. Per winerror.h, this is ERROR_INVALID_PARAMETER.

I'm still puzzled.

Jean-Marc
Post by Luca Calligaris [eMVP]
Do not call LoadLibrary in the entry-point function, because you might
create dependency loops in the DLL load order. This can cause a DLL to be
used before the system executes its initialization code.
Similarly, do not call the FreeLibrary function in the entry-point function
on detach, because this can cause a DLL to be used after the system executes
its termination code.
Calling Microsoft® Win32® functions other than TLS, object-creation, and
file functions can cause problems that are difficult to diagnose.
For example, calling User, Shell, COM, and Windows Sockets functions (or
functions that call these functions) can cause access violation errors,
because their DLLs call LoadLibrary to load other system components.
About using it in init, what error you get calling GetLastError() when
Playsound returns FALSE?
--
Luca Calligaris (MVP-Windows Embedded)
www.eurotech.it
Post by JMRanger
I'm trying to generate sound as early as possible during the CE boot process.
To do so, I wrote a dummy driver that calls PlaySound during either its
DllEntry() or Init() call. My idea was to priorize audio drivers in the load
order, and load that dummy one afterward.
Code is simply
playRes = PlaySound(TEXT("\\Windows\\sound1.wav"), NULL, SND_ASYNC);
Apparently, this isn't a good idea. The call to PlaySound works (i.e. sound
is played), but PlaySond' return value is FALSE. In addition, the debug
Exception 'Raised Exception' (-1): Thread-Id=01500002(pth=87f7da38),
Proc-Id=00400002(pprc=82631308) 'NK.EXE',
VM-active=00400002(pprc=82631308)
'NK.EXE'
PC=c0033c34(k.coredll.dll+0x00013c34) RA=800a64c8(kernel.dll+0x000064c8)
SP=d02ae3a0, BVA=00000000
Trying to catch that with __try/__except changes nothing.
It seems to be specific to DllEntry/Init: placing the call in Open() works
fine - but too late for my purpose (unless there's a way to trigger that call
early that I'm unaware of ?)
Ideas ?
This is on CE 6.0 R3.
Thanks.
.
Luca Calligaris [eMVP]
2010-03-04 17:57:02 UTC
Permalink
According to documentation you should set even SND_FILENAME in fdwSound
flags since the first arg is a filename. Maybe this is the reason for
ERROR_INVALID_PARAMETER
--
Luca Calligaris (MVP-Windows Embedded)
***@eurotech.it.nospam
www.eurotech.it
Post by JMRanger
Hello Luca,
I felt that it was wrongin DllEntry, and possibly wrong in Init(). Thanks
for clarifying.
Error code is 87. Per winerror.h, this is ERROR_INVALID_PARAMETER.
I'm still puzzled.
Jean-Marc
Post by Luca Calligaris [eMVP]
Do not call LoadLibrary in the entry-point function, because you might
create dependency loops in the DLL load order. This can cause a DLL to be
used before the system executes its initialization code.
Similarly, do not call the FreeLibrary function in the entry-point function
on detach, because this can cause a DLL to be used after the system executes
its termination code.
Calling Microsoft® Win32® functions other than TLS, object-creation, and
file functions can cause problems that are difficult to diagnose.
For example, calling User, Shell, COM, and Windows Sockets functions (or
functions that call these functions) can cause access violation errors,
because their DLLs call LoadLibrary to load other system components.
About using it in init, what error you get calling GetLastError() when
Playsound returns FALSE?
--
Luca Calligaris (MVP-Windows Embedded)
www.eurotech.it
Post by JMRanger
I'm trying to generate sound as early as possible during the CE boot process.
To do so, I wrote a dummy driver that calls PlaySound during either its
DllEntry() or Init() call. My idea was to priorize audio drivers in the load
order, and load that dummy one afterward.
Code is simply
playRes = PlaySound(TEXT("\\Windows\\sound1.wav"), NULL, SND_ASYNC);
Apparently, this isn't a good idea. The call to PlaySound works (i.e. sound
is played), but PlaySond' return value is FALSE. In addition, the debug
Exception 'Raised Exception' (-1): Thread-Id=01500002(pth=87f7da38),
Proc-Id=00400002(pprc=82631308) 'NK.EXE',
VM-active=00400002(pprc=82631308)
'NK.EXE'
PC=c0033c34(k.coredll.dll+0x00013c34)
RA=800a64c8(kernel.dll+0x000064c8)
SP=d02ae3a0, BVA=00000000
Trying to catch that with __try/__except changes nothing.
It seems to be specific to DllEntry/Init: placing the call in Open() works
fine - but too late for my purpose (unless there's a way to trigger
that
call
early that I'm unaware of ?)
Ideas ?
This is on CE 6.0 R3.
Thanks.
.
JMRanger
2010-03-04 19:46:01 UTC
Permalink
Hello Luca,

I caught that one too, but no change. BTW, what I read at
http://msdn.microsoft.com/en-us/library/aa909766.aspx and
http://msdn.microsoft.com/en-us/library/aa910379.aspx seems to indicate that
this flag is optional.

I also tried SND_RESOURCE (using the instance handle provided in DllEntry
and linking the wave file into the driver DLL) - same result: sound plays,
but error 87 and exception thrown.

Looks like
playRes = PlaySound(TEXT("beep"), hInst, SND_RESOURCE | SND_ASYNC);

I also tried SND_SYNC yesterday - same result.

Other ideas ? Thanks for your help.

Jean-Marc
Post by Luca Calligaris [eMVP]
According to documentation you should set even SND_FILENAME in fdwSound
flags since the first arg is a filename. Maybe this is the reason for
ERROR_INVALID_PARAMETER
--
Luca Calligaris (MVP-Windows Embedded)
www.eurotech.it
Post by JMRanger
Hello Luca,
I felt that it was wrongin DllEntry, and possibly wrong in Init(). Thanks
for clarifying.
Error code is 87. Per winerror.h, this is ERROR_INVALID_PARAMETER.
I'm still puzzled.
Jean-Marc
Post by Luca Calligaris [eMVP]
Do not call LoadLibrary in the entry-point function, because you might
create dependency loops in the DLL load order. This can cause a DLL to be
used before the system executes its initialization code.
Similarly, do not call the FreeLibrary function in the entry-point function
on detach, because this can cause a DLL to be used after the system executes
its termination code.
Calling Microsoft® Win32® functions other than TLS, object-creation, and
file functions can cause problems that are difficult to diagnose.
For example, calling User, Shell, COM, and Windows Sockets functions (or
functions that call these functions) can cause access violation errors,
because their DLLs call LoadLibrary to load other system components.
About using it in init, what error you get calling GetLastError() when
Playsound returns FALSE?
--
Luca Calligaris (MVP-Windows Embedded)
www.eurotech.it
Post by JMRanger
I'm trying to generate sound as early as possible during the CE boot process.
To do so, I wrote a dummy driver that calls PlaySound during either its
DllEntry() or Init() call. My idea was to priorize audio drivers in the load
order, and load that dummy one afterward.
Code is simply
playRes = PlaySound(TEXT("\\Windows\\sound1.wav"), NULL, SND_ASYNC);
Apparently, this isn't a good idea. The call to PlaySound works (i.e. sound
is played), but PlaySond' return value is FALSE. In addition, the debug
Exception 'Raised Exception' (-1): Thread-Id=01500002(pth=87f7da38),
Proc-Id=00400002(pprc=82631308) 'NK.EXE',
VM-active=00400002(pprc=82631308)
'NK.EXE'
PC=c0033c34(k.coredll.dll+0x00013c34)
RA=800a64c8(kernel.dll+0x000064c8)
SP=d02ae3a0, BVA=00000000
Trying to catch that with __try/__except changes nothing.
It seems to be specific to DllEntry/Init: placing the call in Open() works
fine - but too late for my purpose (unless there's a way to trigger
that
call
early that I'm unaware of ?)
Ideas ?
This is on CE 6.0 R3.
Thanks.
.
.
Loading...