Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DEV_BROADCAST_HANDLE / DEV_BROADCAST_HANDLE64 ?

308 views
Skip to first unread message

Uwe Sieber

unread,
Oct 8, 2007, 12:22:15 PM10/8/07
to

Receiving DBT_CUSTOMEVENT, DBT_DEVICEQUERYREMOVE and some
others works fine under W2K to Vista32.
In a DEV_BROADCAST_HANDLE structure there are dbch_handle
with the handle of the disk device I've registered for and
in dbch_hdevnotify I get the notify handle returned by
RegisterDeviceNotification.

Running the Win32 service under Vista x64 I get
DEV_BROADCAST_HANDLE as expected but both, dbch_handle and
dbch_hdevnotify contain always NULL, so I've no chance to
determine the device the message is send for.


In dbt.h there is defined a 64bit version of DEV_BROADCAST_HANDLE
too, called DEV_BROADCAST_HANDLE64 but I've not found any further
information. dbch_handle and dbch_hdevnotify are defined here as
ULONG64 instead of ULONG32.
But the structure send under WOW64 is obviousely DEV_BROADCAST_HANDLE
because the GUID starts where is should do in DEV_BROADCAST_HANDLE.
The only information I've found is the comment in dtb.h above
DEV_BROADCAST_HANDLE and DEV_BROADCAST_HANDLE64:
// Define 32-bit and 64-bit versions of the DEV_BROADCAST_HANDLE
// structure for WOW64. These must be kept in sync with the above
// structure.

So, what is the correct way for a Win32 service under WOW64 to
get this notification with the correct handle values?

Uwe


Jeffrey Tan[MSFT]

unread,
Oct 9, 2007, 5:36:54 AM10/9/07
to
Hi Uwe,

I will perform some research on this issue and get back to you ASAP. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jeffrey Tan[MSFT]

unread,
Oct 9, 2007, 10:32:48 PM10/9/07
to
Hi Uwe,

Sorry for letting you wait.

> So, what is the correct way for a Win32 service under WOW64 to get this
notification with the correct handle values?

Well, it should work. There is a thunk defined for WM_DEVICECHANGE message
that takes care of thunking DEV_BROADCAST_HANDLE. It could be a corner case
though. Do you have an easy and detailed repro?

Uwe Sieber

unread,
Oct 10, 2007, 6:56:31 AM10/10/07
to
Jeffrey Tan[MSFT] wrote:
> Hi Uwe,
>
> Sorry for letting you wait.
>
>> So, what is the correct way for a Win32 service under WOW64 to get this
> notification with the correct handle values?
>
> Well, it should work. There is a thunk defined for WM_DEVICECHANGE message
> that takes care of thunking DEV_BROADCAST_HANDLE. It could be a corner case
> though. Do you have an easy and detailed repro?


Ok, I've made simple demo project with VS6:
http://www.uwe-sieber.de/sourcecode/medianotify_src.zip
(26KB).

It's a single thread console app which creates a window for
receiving the notifications.
Debug output is made into the console window. The program
stops when the window is closed.
A release EXE is included.

As commandline param a single drive letter is expected, as
medianotify X

It registers then for a handle to the disk or cdrom device
of this volume.
When a media is removed or inserted it receives DBT_CUSTOMEVENT
with GUID_IO_MEDIA_REMOVAL or GUID_IO_MEDIA_ARRIVAL.

It shows the handles used for RegsiterDeviceNotification and
the handles received with DBT_CUSTOMEVENT in the
DEV_BROADCAST_HANDLE struct.

Unfortunally I have no Vista x64 here. It works under XP and
Vista32.
The drive letter must be of a drive with removable media,
best a flash card reader, an CDROM drive works too.
Floppy drives do not work because of missing media notification
support.

If it should work under Vista x64 then the problem may
occur only in a Win32 service. I'll change the app then
into a Win32.


Uwe

Uwe Sieber

unread,
Oct 10, 2007, 12:26:10 PM10/10/07
to
Uwe Sieber wrote:
> Jeffrey Tan[MSFT] wrote:
>> Hi Uwe,
>>
>> Sorry for letting you wait.
>>> So, what is the correct way for a Win32 service under WOW64 to get this
>> notification with the correct handle values?
>>
>> Well, it should work. There is a thunk defined for WM_DEVICECHANGE
>> message that takes care of thunking DEV_BROADCAST_HANDLE. It could be
>> a corner case though. Do you have an easy and detailed repro?
>
>
> Ok, I've made simple demo project with VS6:
> http://www.uwe-sieber.de/sourcecode/medianotify_src.zip
> (26KB).
>
> It's a single thread console app which creates a window for
> receiving the notifications.
> Debug output is made into the console window. The program
> stops when the window is closed.
> A release EXE is included.
>
> As commandline param a single drive letter is expected, as
> medianotify X
>
>
> If it should work under Vista x64 then the problem may
> occur only in a Win32 service. I'll change the app then
> into a Win32.

I've got feedback that the demo app works under Vista x64.

I'll now transform it into a Win32 service and will be
back when it's finished.


Uwe


Uwe Sieber

unread,
Oct 10, 2007, 2:48:06 PM10/10/07
to

It's done and my helpful tester with Vista x64 confirmed
that the handles are NULL now while they are correct under
XP and Vista 32.
RegisterDeviceNotification is called now for getting
notifications in the service's HandlerEx.
http://www.uwe-sieber.de/sourcecode/medianotifysvc_src.zip

The test app can be called with -debug, it runs as simple
application then. For running as service it must be installed
thru the _install.cmd found in DEBUG and RELEASE folder.
The drive letter must be set now in the MediaNotifySvc.ini.


Uwe


Uwe Sieber

unread,
Oct 10, 2007, 3:11:29 PM10/10/07
to

Forgot to mention that the debug output is done by means of
OutPutDebugString, so you need a tool like DebugView to see
them.

Uwe

Jeffrey Tan[MSFT]

unread,
Oct 10, 2007, 10:51:09 PM10/10/07
to
Hi Uwe ,

Thanks for your effect on this sample project!

I am current working with some Microsoft driver developers on this issue. I
will get back to you ASAP. Thanks.

Jeffrey Tan[MSFT]

unread,
Oct 14, 2007, 11:30:00 PM10/14/07
to
Hi Uwe,

Sorry for the late response.

By working with the driver engineer, we are able to repro the problem using
a tool he wrote and hence we did not need to use the program from you.
Thanks.

We've found the issue and now we are investigating if we can take the fix
in SP1. Thank you very much for reporting it!

Now, I am creating a record in database to track this issue and assigning
it to the driver engineer to fix it.

In the meanwhile, the workaround would be to track the handle passed in to
RegisterDeviceNotification() (which would be the same as dbch_handle) and
the handle received from the API (which would be the same as
dbch_hdevnotify).

Thanks again for your patient and reporting!

Uwe Sieber

unread,
Oct 16, 2007, 12:32:34 PM10/16/07
to

Hi Jeffrey,

thanks four you help. Do you have information if the
problem exists under XP-64 and W2K3-64 too?


Thanks,

Uwe

Jeffrey Tan[MSFT]

unread,
Oct 17, 2007, 5:55:47 AM10/17/07
to
Hi Uwe ,

Not yet. I will talk with the bug owner to get this information. I will get

back to you ASAP. Thanks.

Best regards,

Jeffrey Tan[MSFT]

unread,
Oct 17, 2007, 10:42:32 PM10/17/07
to
Hi Uwe,

Sorry for letting you wait.

After discussing, as far as we can tell by looking at the code, this
problem should not exist on XP-64 and W2K3-64. It's a regression in Vista.
Let me know though if you have issues using the API on other 64-bit
platforms and we will surely take a closer look.

Thanks.

Jeffrey Tan[MSFT]

unread,
Oct 21, 2007, 11:25:14 PM10/21/07
to
Hi Uwe,

Have you reviewed my last confirmation to you? Is your problem fully
resolved? If you still need any help or have any concern, please feel free
to post, thanks.

Uwe Sieber

unread,
Oct 22, 2007, 8:51:46 AM10/22/07
to

Hi Jeffrey,

it's a shame but I've still no 64bit hardware. So, I rely
on user's feedback. So far I got no reports about XP-64
and W2K3-64 at all...
For now, when running under Vista64, I use an invisible
window to receive the messages with correct handle values.
This works fine.


Thanks and Greetings from Germany

Uwe

Jeffrey Tan[MSFT]

unread,
Oct 24, 2007, 10:41:31 PM10/24/07
to
Hi Uwe,

Thank you for confirming the current status and solution.

Ok, if you need further help, please feel free to post, thanks.

boro...@hotmail.com

unread,
Nov 19, 2007, 5:12:01 AM11/19/07
to

Hi Uwe

Thank you very much for the example. We have try to solve this issue
for 3, 4 days without luck. You just save our life :).
The next step is some how get this code into manage world.

/Ngoc Tri Nguyen

Uwe Sieber

unread,
Nov 20, 2007, 8:41:17 AM11/20/07
to


Thanks, then the demo wasn't made in vain :-)


Uwe

0 new messages