Display Mirror Driver Problem

N

Nadav

Hi,

I am trying to write a Display mirror driver based on the sample provided
with the DDK, I am trying to add some C++ classes to the sample. Defining a
class at global scope ( statically ) without calling any of it's functions
causes the driver to stop loading. no exception is being cached by WinDbg,
or NuMegas Visual SoftIce, I really want to use C++ with my driver... I
guess the problem related to the way the class is allocated in memory (
global scope ) as defining the class in a function scope doesn't produce the
problem. What may cause this problem? how could this problem be resolved?
any clues pointers or directions will be appreciated.

Nadav.
 
B

Brian Catlin

Nadav said:
Hi,

I am trying to write a Display mirror driver based on the sample provided
with the DDK, I am trying to add some C++ classes to the sample. Defining a
class at global scope ( statically ) without calling any of it's functions
causes the driver to stop loading. no exception is being cached by WinDbg,
or NuMegas Visual SoftIce, I really want to use C++ with my driver... I
guess the problem related to the way the class is allocated in memory (
global scope ) as defining the class in a function scope doesn't produce the
problem. What may cause this problem? how could this problem be resolved?
any clues pointers or directions will be appreciated.


The use of C++ in drivers is unsupported

-Brian

Brian Catlin, Sannas Consulting 310-944-9492
Windows Network, Video, WDM Device Driver Training & Consulting
See WWW.AZIUS.COM.bad for courses and scheduling
REMOVE .BAD FROM EMAIL AND WEB ADDRESS
 
N

Nadav

Well, NuMegas DriverWorks include a whole bunch of C++ classes for driver
development... although no classes that provide video driver infer are
included.
 
P

Philip Taylor [ATI]

thats a separate product from the DDK.

one products requirements are most definitely not anothers.
 
N

Nadav

So.. Please Fix me if I am wrong, Development of Video mirror drivers cannot be done with C++ while other drivers can be written using C++.
 
B

Brian Catlin

You may get it to work, but you will get absolutely no support from Microsoft. If you are determined to use C++, talk to NuMega, and see what kind of support they can give you - especially for video drivers

-Brian


So.. Please Fix me if I am wrong, Development of Video mirror drivers cannot be done with C++ while other drivers can be written using C++.
 
D

DemoForge.com

So.. Please Fix me if I am wrong, Development of Video mirror
drivers cannot be done with C++ while other drivers can be written using
C++.

You can't use unrestricted C++ in kernel environment anyway.
For example one can employ C++ exceptions and RTTI neither in regular
NT device driver nor in display driver.

Display drivers world imposes additional restrictions on what you can do.
May be you remember the restriction of global variables. You cant use them
in display driver. This is a matter of security. When the display (PDEV)
is switched, than no state from the previous display can be attributed
to the newly activated one. It is substantial architectural issue. If you
were allowed to have global vars, you easily could make a mistake in your
driver that probably compromise the system security.
Another restriction is that you are not allowed to link to anything
except win32k. The reason is alike.
These restrictions are not just words. They are enforced.
The loader of display drivers behaves differently compared to regular
driver modules. This loader will not bind the display driver
to anything except win32k. It also does not perform the full
initialization prescribed by complier.
It only does what is allowed. It seems that it loads nothing
except .idata, .text and win32k import sections.

So, the loader will silently refuse to load your driver if it references
things outside win32k. It also will not call the ctors/dtors of the global
objects. It will not initialize vtables of your classes. If you decide to
use virtual methods in display driver, you're out of luck. There are
other restrictions as well.

So you may use C++ only as better C. Usual classes w/o virtual methods,
single inheritance, overloading, templates are all allowed.
The understanding of how C++ complier works
will be of much help.
Just FYI, I do use C++ in mirror drivers. It performs perfectly
when used with care.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top