Write to screen inside kernel driver

Hi, I’m developing a real time W2k/XP/Vista kernel mode driver that uses 100% of CPU (all cores!) and works for minutes/hours.
I would love to display a progress bar or anything simple on the screen/window so users can still know it’s working. (At the moment I’m just making a PC speaker sound by flipping the I/O port!)
Is there a way to show something simple on the screen, a pixel, a line, a progress bar, anything, generated from this driver? (The driver is real time, the Windows dispatcher is off, therefore cannot have a user mode thread)

I hope there is, if not, there must be a way to turn the screen into full screen text mode before entering the driver, same as the console does, and then just write ASCII characters directly to the display memory (good old days!).

Any advice will be much appreciated :slight_smile:

Michael.

Sounds like you need a RTOS instead of NT. What you are describing sounds a lot like the old InTime and such that ran NT entirely as a low-priority task within that other OS.

Is there no way to run this in user mode aty elevated priority and have a high-priority thread do the screen updates?

Greg

b@if0.com wrote:

From: b@if0.com
To: “Windows System Software Devs Interest List”
Subject: [ntdev] Write to screen inside kernel driver
Date: Wed, 9 Jun 2010 08:46:54 -0400 (EDT)

Hi, I’m developing a real time W2k/XP/Vista kernel mode driver that uses 100% of CPU (all cores!) and works for minutes/hours.
I would love to display a progress bar or anything simple on the screen/window so users can still know it’s working. (At the moment I’m just making a PC speaker sound by flipping the I/O port!)
Is there a way to show something simple on the screen, a pixel, a line, a progress bar, anything, generated from this driver? (The driver is real time, the Windows dispatcher is off, therefore cannot have a user mode thread)

I hope there is, if not, there must be a way to turn the screen into full screen text mode before entering the driver, same as the console does, and then just write ASCII characters directly to the display memory (good old days!).

Any advice will be much appreciated :slight_smile:

Michael.


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

You cannot write to the screen from the kernel, since the windowing
subsystem is not kernel based. Yes there are undocumented hacks for
flipping the screen into text mode, and functions for placing things
there, unfortunately it is not always reliable to put back the windowing
subsystem. Finally, you have to remember that it is becoming more
common to not access the system from the screen, and instead us remote
desktop or similar approaches,

The solution people use is to have a helper application that talks to
the driver, and displays the progress bar for it.

Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

-----Original Message-----
From: b@if0.com [mailto:b@if0.com]
Posted At: Wednesday, June 09, 2010 8:47 AM
Posted To: ntdev
Conversation: Write to screen inside kernel driver
Subject: Write to screen inside kernel driver

Hi, I’m developing a real time W2k/XP/Vista kernel mode driver that
uses 100%
of CPU (all cores!) and works for minutes/hours.
I would love to display a progress bar or anything simple on the
screen/window
so users can still know it’s working. (At the moment I’m just making a
PC
speaker sound by flipping the I/O port!) Is there a way to show
something
simple on the screen, a pixel, a line, a progress bar, anything,
generated
from this driver? (The driver is real time, the Windows dispatcher is
off,
therefore cannot have a user mode thread)

I hope there is, if not, there must be a way to turn the screen into
full
screen text mode before entering the driver, same as the console does,
and
then just write ASCII characters directly to the display memory (good
old
days!).

Any advice will be much appreciated :slight_smile:

Michael.

__________ Information from ESET Smart Security, version of virus
signature
database 5184 (20100609) __________

The message was checked by ESET Smart Security.

http://www.eset.com

There must be a way to access the display driver via IRPs and instruct it to display some pixels, the same way that a driver can access low level disk drivers.
Has anyone done this? :slight_smile:

To switch the screen into text mode, take a look at how blue screens are
produced (nt!KiDisplayBlueScreen) which uses the boot video functions
(nt!Inbv*). Of course this is all undocumented but the interface is simple
and straightforward, prototypes of these functions are floating around on
the net.

//Daniel

**wrote in message news:xxxxx@ntdev…

Hi, I’m developing a real time W2k/XP/Vista kernel mode driver that uses
100% of CPU (all cores!) and works for minutes/hours.
I would love to display a progress bar or anything simple on the
screen/window so users can still know it’s working. (At the moment I’m
just making a PC speaker sound by flipping the I/O port!)
Is there a way to show something simple on the screen, a pixel, a line, a
progress bar, anything, generated from this driver? (The driver is real
time, the Windows dispatcher is off, therefore cannot have a user mode
thread)

I hope there is, if not, there must be a way to turn the screen into full
screen text mode before entering the driver, same as the console does, and
then just write ASCII characters directly to the display memory (good old
days!).

Any advice will be much appreciated :slight_smile:

Michael.
**

The display driver interface is undocumented and not ironically based. It is private to win32k.sys.

d

dent from a phpne with no keynoard

-----Original Message-----
From: b@if0.com
Sent: June 09, 2010 7:14 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Write to screen inside kernel driver

There must be a way to access the display driver via IRPs and instruct it to display some pixels, the same way that a driver can access low level disk drivers.
Has anyone done this? :slight_smile:


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

Well it sounds like your driver is using all the system’s power to process much else.
I suggest putting a message in the begging telling the user that he might not be able to use his computer for some minutes or hours maybe and then start processing, instead of trying to put “real-time progress” of the activity for the user to see.
Is there a way you can suspend your work for a few seconds ?
If yes, just suspend your work from time to time, and instruct a user-mode exe to put something like the progress until then.

There are no IRP’s involved. As people have pointed out the crash dump
stuff for writing will work, but as I said in my last post it is highly
problematical if you can restore the display. People have been asking
how to do this from the kernel for 15 years that I know of and the
answer is still the same, do not do it.

Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

-----Original Message-----
From: b@if0.com [mailto:b@if0.com]
Posted At: Wednesday, June 09, 2010 10:17 AM
Posted To: ntdev
Conversation: Write to screen inside kernel driver
Subject: RE: Write to screen inside kernel driver

There must be a way to access the display driver via IRPs and instruct
it to
display some pixels, the same way that a driver can access low level
disk
drivers.
Has anyone done this? :slight_smile:

__________ Information from ESET Smart Security, version of virus
signature
database 5184 (20100609) __________

The message was checked by ESET Smart Security.

http://www.eset.com

On Wed, Jun 9, 2010 at 10:19 AM, Doron Holan wrote:

> The display driver interface is undocumented and not ironically based

spellcheck disaster?

Having tried to fathom the WDDM display driver documentation, I disagree, it
is obviously ironically based.

Mark Roddy

Damn xt9 on my phone

d

dent from a phpne with no keynoard


From: Mark Roddy
Sent: June 09, 2010 7:56 AM
To: Windows System Software Devs Interest List
Subject: Re: RE:[ntdev] Write to screen inside kernel driver

On Wed, Jun 9, 2010 at 10:19 AM, Doron Holan > wrote:
The display driver interface is undocumented and not ironically based

spellcheck disaster?

Having tried to fathom the WDDM display driver documentation, I disagree, it is obviously ironically based.

Mark Roddy

— 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

What!! An employee of Microsoft without Windows Mobile phone!?phone!? At least you could use graffiti!!

Gary G. Little
Sent via HTC Diamond on Sprint.

-----Original Message-----
From: Doron Holan
Sent: Wednesday, 09 June, 2010 10:05 AM
To: Windows System Software Devs Interest List
Subject: RE: RE:[ntdev] Write to screen inside kernel driver

Damn xt9 on my phone

d

dent from a phpne with no keynoard

________________________________
From: Mark Roddy
Sent: June 09, 2010 7:56 AM
To: Windows System Software Devs Interest List
Subject: Re: RE:[ntdev] Write to screen inside kernel driver

On Wed, Jun 9, 2010 at 10:19 AM, Doron Holan > wrote:
The display driver interface is undocumented and not ironically based

spellcheck disaster?

[The entire original message is not included]

It is a WM phone (an HD2) :stuck_out_tongue:

d

dent from a phpne with no keynoard

-----Original Message-----
From: Gary G. Little
Sent: June 09, 2010 8:19 AM
To: Windows System Software Devs Interest List
Subject: RE: RE:[ntdev] Write to screen inside kernel driver

What!! An employee of Microsoft without Windows Mobile phone!?phone!? At least you could use graffiti!!

Gary G. Little
Sent via HTC Diamond on Sprint.

-----Original Message-----
From: Doron Holan
Sent: Wednesday, 09 June, 2010 10:05 AM
To: Windows System Software Devs Interest List
Subject: RE: RE:[ntdev] Write to screen inside kernel driver

Damn xt9 on my phone

d

dent from a phpne with no keynoard

________________________________
From: Mark Roddy
Sent: June 09, 2010 7:56 AM
To: Windows System Software Devs Interest List
Subject: Re: RE:[ntdev] Write to screen inside kernel driver

On Wed, Jun 9, 2010 at 10:19 AM, Doron Holan > wrote:
The display driver interface is undocumented and not ironically based

spellcheck disaster?

[The entire original message is not included]


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

> There must be a way to access the display driver via IRPs and instruct it to display some pixels

There are no such ways, the display driver does not use IRPs for drawing.

Has anyone done this? :slight_smile:

Surely no.

Writing a helper app which will display the things using the usual GUI is by far easier and more logical way.


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

I’ve already deleted the OP, but what use case requires a driver to fully
utilize all CPU cores at full throttle for several seconds? Or is this
request coincidental with someone else who has approximately the same need?

Philip D. Barila

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
Sent: Wednesday, June 09, 2010 9:51 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Write to screen inside kernel driver

There must be a way to access the display driver via IRPs and instruct it
to display some pixels

There are no such ways, the display driver does not use IRPs for drawing.

Has anyone done this? :slight_smile:

Surely no.

Writing a helper app which will display the things using the usual GUI is by
far easier and more logical way.


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


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

You could potentially write a DirectX app that maps a display surface
bitmap. You could then pass the address of that surface into a driver and if
you write to it, the bitmap will show up as bits on the screen. You can’t
call any of the API’s, like for text output, so you need to deal with
bitmaps directly. This is not unlike a video capture preview window, where
the hardware DMA’s directly to a overlay surface. Not sure how any this will
interact with modern display technology like DirectX 10.

Jan

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-414091-
xxxxx@lists.osr.com] On Behalf Of b@if0.com
Sent: Wednesday, June 09, 2010 5:47 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Write to screen inside kernel driver

Hi, I’m developing a real time W2k/XP/Vista kernel mode driver that uses
100% of CPU (all cores!) and works for minutes/hours.
I would love to display a progress bar or anything simple on the
screen/window so users can still know it’s working. (At the moment I’m
just
making a PC speaker sound by flipping the I/O port!) Is there a way to
show
something simple on the screen, a pixel, a line, a progress bar, anything,
generated from this driver? (The driver is real time, the Windows
dispatcher
is off, therefore cannot have a user mode thread)

I hope there is, if not, there must be a way to turn the screen into full
screen
text mode before entering the driver, same as the console does, and then
just write ASCII characters directly to the display memory (good old
days!).

Any advice will be much appreciated :slight_smile:

Michael.


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

(getting both creative and insane…)

Is this some sort of embedded type system, where you can absolutely know the configuration in advance?

If it is, I suppose you could do something like directly accessing the video RAM to flip a few pixels, bypassing the graphics driver entirely.

Of course, I have no idea if that would even work on the graphics cards folks use these days,

Peter
OSR

On 6/9/2010 5:46 AM, b@if0.com wrote:

Hi, I’m developing a real time W2k/XP/Vista kernel mode driver that uses 100% of CPU (all cores!) and works for minutes/hours.
I would love to display a progress bar or anything simple on the screen/window so users can still know it’s working. (At the moment I’m just making a PC speaker sound by flipping the I/O port!)
Is there a way to show something simple on the screen, a pixel, a line, a progress bar, anything, generated from this driver? (The driver is real time, the Windows dispatcher is off, therefore cannot have a user mode thread)

If you have a user-mode helper, you can use DirectDraw to fetch a
pointer to the primary surface, and pass that address to your driver.
You’ll also have to pass information on the screen format.

As others have implied, it’s not general, but since you’re talking about
a laboratory situation, it’s workable.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

On 6/9/2010 7:55 AM, Mark Roddy wrote:

Having tried to fathom the WDDM display driver documentation, I
disagree, it is obviously ironically based.

Yes. WDDM is kind of a frustrating situation. On the surface, it
looks like there is a great deal of documentation. There are good pages
for each of the WDDM callbacks and structures, and the pages all seem to
have a goodly amount of detail. What’s lacking is the “practical
guide”. What’s critical, what’s important, what’s not, what’s the flow,
how did we get here, what can I ignore, etc. That’s the kind of thing
that’s usually covered in a DDK sample, but there IS no WDDM sample.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Hi Peter, no, I’m afraid, it has to work on any computer, Win2k, WinXP, or Vista. Not 7 yet thank God! :smiley:

I spent my day trying stuff of the sort of EngCreateBitmap, with no result.

Jan, I guess I will have to look into the DirectX memory window idea of yours, but will it work even on a plain Windows2k machine, without any additional DirectX installations?

Don, thanks, I might have to go the good old Text Mode way, and then reset the computer when finished, I have an Out port from the good old days that still seems to work, does a hardware reset :smiley:

Philip D. Barila, not sure what you mean about someone else. The system stays in Kernel mode for up to 1 hour, being 100% busy with the driver, nothing else works, no dispatcher, no other threads.

Not really being a DirectX developer, I don’t have a good sense on what
percentage of systems it will work on, my guess is almost anything except
perhaps the base VGA driver. Offscreen surfaces were a pretty basic feature.
I also don’t know if this is all now obsolete and possibly will no longer
work on a modern display adapter. You might have to adjust the type of
surface based on the display hardware capability. A fragment of code to do
this looks something like below (return code checking has been removed in
many cases to shorten the code posted here). I would find the docs for the
CreateSurface API, and find a simple sample that did all the right stuff. It
not really much more than below to get things set up enough to play with,
but you may need to do things like enumerate the available pixel format
types. I actually had a COM object that wrapped around all this and I called
it from a VBScript script, so it must not need a lot of fancy context to
work.

// Create the main DirectDraw object.
hRet = DirectDrawCreateEx(NULL, (LPVOID *)&dd,
IID_IDirectDraw7, NULL);

// Get normal mode.
hRet = dd->SetCooperativeLevel(NULL, DDSCL_NORMAL);

// create an offscreen surface in video memory
ZeroMemory( &ddsd, sizeof( ddsd ) );

ddsd.dwSize = sizeof( ddsd );
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT |
DDSD_PIXELFORMAT;
ddsd.ddpfPixelFormat.dwSize = sizeof( ddsd.ddpfPixelFormat
);
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
ddsd.ddpfPixelFormat.dwRGBBitCount = 32;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN |
DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM;

ddsd.dwWidth = 1024;
ddsd.dwHeight = (desiredSize / 4096);

hRet = dd->CreateSurface(&ddsd, &videoSurface, NULL );

hRet = videoSurface->Lock(NULL,&ddsd,
DDLOCK_SURFACEMEMORYPTR, NULL);

videoBuffer = (PVOID)ddsd.lpSurface;

You then take the virtual address of the display bitmap and pass it via an
ioctl to the driver, which maps it to system virtual addresses. Back in
about 2004 when I did this, you got a pointer to memory on the video card
with the display hardware programmed such that any changes to the bitmap
were displayed. You could pre-render some text/graphics into another bitmap
with a matching format and then all you need to do is copy from the memory
bitmap to the live display surface in your driver. This would be enough to
give some animated activity indicator. I actually had hardware DMA directly
to the display surface bitmap, and you could see on the screen when DMA
happened. It was part of a hardware testing application.

Jan

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-414160-
xxxxx@lists.osr.com] On Behalf Of b@if0.com
Sent: Wednesday, June 09, 2010 10:49 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Write to screen inside kernel driver

Hi Peter, no, I’m afraid, it has to work on any computer, Win2k, WinXP, or
Vista. Not 7 yet thank God! :smiley:

I spent my day trying stuff of the sort of EngCreateBitmap, with no
result.

Jan, I guess I will have to look into the DirectX memory window idea of
yours,
but will it work even on a plain Windows2k machine, without any additional
DirectX installations?

Don, thanks, I might have to go the good old Text Mode way, and then reset
the computer when finished, I have an Out port from the good old days that
still seems to work, does a hardware reset :smiley:

Philip D. Barila, not sure what you mean about someone else. The system
stays in Kernel mode for up to 1 hour, being 100% busy with the driver,
nothing else works, no dispatcher, no other threads.


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