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.