Calling user32 APIs from UMDF driver

We are developing a UMDF driver, in addition to communicating with a device it also needs to call win32 APIs specially: EnumWindowsProc.

But a call to EnumWindowsProc from UMDF driver always fails, similar is the behaviour for other APIs from USer32.lib.

Is it possible to call these user32 APIs from UMDF driver?

Regards,
Pratima

Basically we are calling ::EnumWindows to enumerate all active windows, callback always returns TRUE. But o/p for EnumWindows API is always FALSE.

Refering to UMDF documentation it is possible to call Win32 APIs from UMDF driver…does this includes functions from user32.ib as well?

Thanks in advance,
Pratima

Are you trying to enumerate windows in the correct session and desktop?
Session 0 on Vista and 7 tends to be devoid of such user mode things.
How will you cope with Fast User Switching?

Tim Green
Development Engineer
DisplayLink (UK) Limited
Registered in England No. 04811048

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@hotmail.com
Sent: 01 May 2009 10:22
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Calling user32 APIs from UMDF driver

Basically we are calling ::EnumWindows to enumerate all
active windows, callback always returns TRUE. But o/p for
EnumWindows API is always FALSE.

Refering to UMDF documentation it is possible to call Win32
APIs from UMDF driver…does this includes functions from
user32.ib as well?

Thanks in advance,
Pratima


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online
at http://www.osronline.com/page.cfm?name=ListServer

We are trying it on Windows XP. Calling EnumWindows from UMDF driver seems to be issue with us, because when we shift same code to user mode EXE it starts working fine.

Thanks,
Pratima

> Basically we are calling ::EnumWindows to enumerate all active windows

You cannot enumerate windows from the UMDF driver.

It runs in a special process running in a special security sandbox, which has no access to any UI at all, be it local console or Remote Desktop.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

> We are trying it on Windows XP. Calling EnumWindows from UMDF driver seems to be issue with

us, because when we shift same code to user mode EXE it starts working fine.

Correct. The usual EXE started by CMD or Explorer runs in usual interactive user security context (Windows session+logon session), and has access to the UI of its session.

Do not attempt to touch any UI from the driver, be it kernel- or user- mode. This is a violation of the general principles of the OS architecture, and opens some security holes (windows on the same desktop have no security checks in WM_xxx flow between them).

Nothing strange MS have closed this hole in their OSes starting from Vista.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

Thanks, it clears my doubt.