Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
End Users
Pocket PCActiveSyncMultimediaEBooksWirelessSmartPhones
Developers
Windows MobileSmartPhonesWinCE ProgrammingVB for WinCEVC++ for WinCEPlatform BuilderTest Tools
PocketPC DirectoryFree SoftwareWeb Resources
Related Topics
PalmMobile PhonesMore Topics ...

Pocket PC Forum / Developers / WinCE Programming / July 2008

Tip: Looking for answers? Try searching our database.

COM Library calls in Kernel mode Drivers in WinCE 6

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
M.Essadouni - 16 Jul 2008 13:32 GMT
Hi All,
I'm trying to make calls to COM library functions in a kernel mode
driver and I got some troubles.

I've tried three things:

1) When I call CoInitializeEx directly in XXX_Init, the driver can't
load anymore. The DllEntry isn't even called anymore. I noted that the
driver is correctly loaded when I comment the call to CoInitializeEx.

2) I create a DLL in which I a function calling CoInitializeEx and in
an IOCTL of my kernel driver I call LoadLibrary of my new DLL and it
fail with error ERROR_BAD_EXE_FORMAT. I also noted that the library is
correctly loaded when I comment the call to CoInitializeEx.

3) When I call CoInitializeEx and other COM functions directly in an
EXE project, everything works fine.

So my questions are :
Is it possible to make calls to COM Library functions in a kernel mode
driver?
Am I missing some OS Component?
John Spaith [MS] - 17 Jul 2008 17:59 GMT
CoInitialize is not safe to be called from a PSL thread because COM uses
TLS.
http://blogs.msdn.com/cenet/archive/2007/01/05/avoid-tls-calls-in-services-devic
e-drivers-while-processing-ipc-calls-on-wince.aspx
.
Services.exe actually spins up a worker thread that it calls xxx_Init() on
to make sure you're not hit with this, but the kernel does not.

The next problem is that ole32.dll and oleaut32.dll have not been marked as
kernel safe, so the kernel will refuse to load them, which I think explains
(2).    There is a way you can get a minimal OLE32 for the kernel (it could
do CoCreateInstance() and bare essentials), but I'd rather not take you down
that path and because it's not officially supported it may not be available
in future OS versions.

Do you have to be using COM in the kernel in 1st place?  Is there any chance
you can move your component out to services.exe, or is there an easy split
to get the COM stuff into services DLL and kernel driver that needs kernel
access to be COM free?

Signature

John Spaith
Senior Software Design Engineer
Windows CE Networking
Microsoft Corporation

http://blogs.msdn.com/cenet/.

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2007 Microsoft Corporation. All rights
reserved.

> Hi All,
> I'm trying to make calls to COM library functions in a kernel mode
[quoted text clipped - 18 lines]
> driver?
> Am I missing some OS Component?
M.Essadouni - 18 Jul 2008 12:51 GMT
Hi John,

Thanks for your help.
How is Daisy? ;-)

I've read the article you mentionned and I've found it very
interesting.
The explanations you give came to me very clear.

Making those calls in my kernel driver was just my first idea.
Thank you for your guidance, I'll make it another way.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.