Where do I find Microsoft's gexport.exe sample?

hi

I am looking for the Microsoft sample gexport.exe that shows you how to create a kernel export dll and import functions in it into a video driver. A old driver posting on the web said it was on an ftp site, but that was years ago.

Can somebody (maybe some Microsoft folks?) point me to where I can find it or send me a zip file?

I’ve found out the hard way that my driver fails to link because I’m calling things like ExAllocatePoolWithTag, and apparently calling HAL Functions from a video driver isn’t allowed, hence the export dll route.

thanks in advance…

I never heard about the gexport sample, but I beleive this article will be
sufficient:
http://www.wd-3.com/archive/KernelDlls.htm

Then again, I don’t know anything about video drivers, so maybe this is not
what you need…

Shahar

“S. Drasnin” wrote in message news:xxxxx@ntdev…
hi

I am looking for the Microsoft sample gexport.exe that shows you how to
create a kernel export dll and import functions in it into a video driver.
A old driver posting on the web said it was on an ftp site, but that was
years ago.

Can somebody (maybe some Microsoft folks?) point me to where I can find it
or send me a zip file?

I’ve found out the hard way that my driver fails to link because I’m calling
things like ExAllocatePoolWithTag, and apparently calling HAL Functions from
a video driver isn’t allowed, hence the export dll route.

thanks in advance…

By “Video Driver”, there are two very distinctive:

  1. MINIPORT driver (general kernel mode) that links to
    ntoskrnl/hal, videoprt.sys
  2. DISPLAY DRIVER (session based kernel mode) that
    only links to win32k.sys.

Which one do you mean? You can only call GDI
functions (EngXxx) in a kernel mode DISPLAY DRIVER and
exported DLL that’s going to be loaded by the DISPLAY
DRIVER. That’s to say, 1) if you call
ExAllocatePoolWithTag in a DISPLAY DRIVER, GDI won’t
load it. 2) If you call ExAllocatePoolWithTag in a
kernel mode DLL, your DISPLAY DRIVER can NOT load it
(EngLoadImage will fail.) These behaviors are by
design and are enforced by GDI loader.

On the flip side, calling GDI andor DISPLAY DRIVER
functions from MINIPORT drivers is bad in general. It
can be done safely in some cases with some additional
work. (Remember GDI is session based where MINIPORT
isn’t)

To allocate memory in DISPLAY DRIVER (GDI), use
EngAllocMem. To do it in MINIPORT driver, use
VideoPortAllocatePool. If you want to do something in
the display driver that GDI doesn’t facilitate, you
send an IOCTL to the miniport driver and let the
MINIPORT does it (if videoport allowed). Perhaps I
didn’t fully understand what you are trying to do?

Humble opinion from a former ATI Radeon Graphics
Driver developer.


Calvin Guan (Windows DDK MVP)
Staff SW Engineer NetXtreme MINIPORT
Broadcom Corp. Irvine, CA
www.broadcom.com

— “S. Drasnin” wrote:

> hi
>
> I am looking for the Microsoft sample gexport.exe
> that shows you how to create a kernel export dll and
> import functions in it into a video driver. A old
> driver posting on the web said it was on an ftp
> site, but that was years ago.
>
> Can somebody (maybe some Microsoft folks?) point me
> to where I can find it or send me a zip file?
>
> I’ve found out the hard way that my driver fails to
> link because I’m calling things like
> ExAllocatePoolWithTag, and apparently calling HAL
> Functions from a video driver isn’t allowed, hence
> the export dll route.
>
> thanks in advance…
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown
> lmsubst tag argument: ‘’
> To unsubscribe send a blank email to
xxxxx@lists.osr.com

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

hi Calvin:

I just posted another question but I see your email answered most of my questions - thank you for the detailed response. I was using the mirror driver and was trying to call ExAllocatePool with tag in the mirror driver’s display driver. I actually created a static library that wrapped the call to ExAllocatePool and linked against it (specified this lib TARGETLIB in the sources files of the display driver.)

I will try your suggestion of calling EngAllocMem.

Do you have a suggestion on how to recover my machine? When I ran with the driver with the call made to the export library that contained a function that wrapped ExAllocatePool, I got a nasty Message Box saying my viga driver was out of date and it was reverting back to a default vga driver. I uninstalled the mirror driver and whacked the mirror.dll and mirror.sys in my c:\windows\system32 and c:\windows\system32\drivers directories, rebooted, and reinstalled an old version of the driver that didn’t link to the export lib. But, things are very hosed. I never reach the DrvEscape function in the mirror display driver any longer. (I have KdPrints in there and an _asm int 3 and have a testapp that makes a driver escape call.)I guess the OS refuses to load it with the default vga driver it said it was going to run. I did try renaming mirror.dll and mirror.sys to mirror_0.dll and mirror_0.sys as well, but no luck.

I’m will try to locate the correct vga display driver for my PC (it’s really old) or resort to reimaging my PC, but hope you have some other suggestions. It’s a painful way to recover.

By the way, what does “session based” mean? This is the first time I’m doing anything with video drivers.

thanks for the helpful responses!

----- Original Message -----
From: Calvin Guan
To: Windows System Software Devs Interest List
Sent: Sunday, July 17, 2005 2:07 PM
Subject: Re: [ntdev] Where do I find Microsoft’s gexport.exe sample?

By “Video Driver”, there are two very distinctive:

  1. MINIPORT driver (general kernel mode) that links to
    ntoskrnl/hal, videoprt.sys
  2. DISPLAY DRIVER (session based kernel mode) that
    only links to win32k.sys.

Which one do you mean? You can only call GDI
functions (EngXxx) in a kernel mode DISPLAY DRIVER and
exported DLL that’s going to be loaded by the DISPLAY
DRIVER. That’s to say, 1) if you call
ExAllocatePoolWithTag in a DISPLAY DRIVER, GDI won’t
load it. 2) If you call ExAllocatePoolWithTag in a
kernel mode DLL, your DISPLAY DRIVER can NOT load it
(EngLoadImage will fail.) These behaviors are by
design and are enforced by GDI loader.

On the flip side, calling GDI andor DISPLAY DRIVER
functions from MINIPORT drivers is bad in general. It
can be done safely in some cases with some additional
work. (Remember GDI is session based where MINIPORT
isn’t)

To allocate memory in DISPLAY DRIVER (GDI), use
EngAllocMem. To do it in MINIPORT driver, use
VideoPortAllocatePool. If you want to do something in
the display driver that GDI doesn’t facilitate, you
send an IOCTL to the miniport driver and let the
MINIPORT does it (if videoport allowed). Perhaps I
didn’t fully understand what you are trying to do?

Humble opinion from a former ATI Radeon Graphics
Driver developer.


Calvin Guan (Windows DDK MVP)
Staff SW Engineer NetXtreme MINIPORT
Broadcom Corp. Irvine, CA
www.broadcom.com

— “S. Drasnin” wrote:

> hi
>
> I am looking for the Microsoft sample gexport.exe
> that shows you how to create a kernel export dll and
> import functions in it into a video driver. A old
> driver posting on the web said it was on an ftp
> site, but that was years ago.
>
> Can somebody (maybe some Microsoft folks?) point me
> to where I can find it or send me a zip file?
>
> I’ve found out the hard way that my driver fails to
> link because I’m calling things like
> ExAllocatePoolWithTag, and apparently calling HAL
> Functions from a video driver isn’t allowed, hence
> the export dll route.
>
> thanks in advance…
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown
> lmsubst tag argument: ‘’
> To unsubscribe send a blank email to
xxxxx@lists.osr.com

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@msn.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

I’ve not done mirror driver before I’m not sure if
your driver mirrors the VGA driver. If it did, then I
guess your mirror driver would have been loaded thus
you can’t simply overwrite the display driver (.DLL).
Again, I’m not very positive.

I would suggest you use .kdfiles (windbg command) to
replace your mirror display driver. See WinDbg doc for
more info.

By the way, what does “session based” mean?

Session space is a portion of kernel address space.
Each logged in user has their own session space. See
David and Mark’s Inside Windows 2000 for more
background info. Each session has their own instance
of GDI and display driver instances. If you trace the
init functions of the display driver
(DrvEnableDriver/Surface/AssertMode), you will see GDI
initializes display driver whenever a new user logged
in (a new session became active).

MINIPORT, like other KMDs, has only one driver
instance regardless how many sessions there are in the
system.


Calvin Guan (Windows DDK MVP)
Staff SW Engineer NetXtreme MINIPORT
Broadcom Corp. Irvine, CA
www.broadcom.com

— “S. Drasnin” wrote:

> hi Calvin:
>
> I just posted another question but I see your email
> answered most of my questions - thank you for the
> detailed response. I was using the mirror driver and
> was trying to call ExAllocatePool with tag in the
> mirror driver’s display driver. I actually created a
> static library that wrapped the call to
> ExAllocatePool and linked against it (specified this
> lib TARGETLIB in the sources files of the display
> driver.)
>
> I will try your suggestion of calling EngAllocMem.
>
> Do you have a suggestion on how to recover my
> machine? When I ran with the driver with the call
> made to the export library that contained a function
> that wrapped ExAllocatePool, I got a nasty Message
> Box saying my viga driver was out of date and it was
> reverting back to a default vga driver. I
> uninstalled the mirror driver and whacked the
> mirror.dll and mirror.sys in my c:\windows\system32
> and c:\windows\system32\drivers directories,
> rebooted, and reinstalled an old version of the
> driver that didn’t link to the export lib. But,
> things are very hosed. I never reach the DrvEscape
> function in the mirror display driver any longer. (I
> have KdPrints in there and an _asm int 3 and have a
> testapp that makes a driver escape call.)I guess the
> OS refuses to load it with the default vga driver it
> said it was going to run. I did try renaming
> mirror.dll and mirror.sys to mirror_0.dll and
> mirror_0.sys as well, but no luck.
>
> I’m will try to locate the correct vga display
> driver for my PC (it’s really old) or resort to
> reimaging my PC, but hope you have some other
> suggestions. It’s a painful way to recover.
>
> By the way, what does “session based” mean? This is
> the first time I’m doing anything with video
> drivers.
>
> thanks for the helpful responses!
>
>
> ----- Original Message -----
> From: Calvin Guan
> To: Windows System Software Devs Interest List
> Sent: Sunday, July 17, 2005 2:07 PM
> Subject: Re: [ntdev] Where do I find Microsoft’s
> gexport.exe sample?
>
>
> By “Video Driver”, there are two very distinctive:
> 1) MINIPORT driver (general kernel mode) that
> links to
> ntoskrnl/hal, videoprt.sys
> 2) DISPLAY DRIVER (session based kernel mode) that
> only links to win32k.sys.
>
> Which one do you mean? You can only call GDI
> functions (EngXxx) in a kernel mode DISPLAY DRIVER
> and
> exported DLL that’s going to be loaded by the
> DISPLAY
> DRIVER. That’s to say, 1) if you call
> ExAllocatePoolWithTag in a DISPLAY DRIVER, GDI
> won’t
> load it. 2) If you call ExAllocatePoolWithTag in a
> kernel mode DLL, your DISPLAY DRIVER can NOT load
> it
> (EngLoadImage will fail.) These behaviors are by
> design and are enforced by GDI loader.
>
> On the flip side, calling GDI andor DISPLAY DRIVER
> functions from MINIPORT drivers is bad in general.
> It
> can be done safely in some cases with some
> additional
> work. (Remember GDI is session based where
> MINIPORT
> isn’t)
>
> To allocate memory in DISPLAY DRIVER (GDI), use
> EngAllocMem. To do it in MINIPORT driver, use
> VideoPortAllocatePool. If you want to do something
> in
> the display driver that GDI doesn’t facilitate,
> you
> send an IOCTL to the miniport driver and let the
> MINIPORT does it (if videoport allowed). Perhaps I
> didn’t fully understand what you are trying to do?
>
>
> Humble opinion from a former ATI Radeon Graphics
> Driver developer.
>
> –
> Calvin Guan (Windows DDK MVP)
> Staff SW Engineer NetXtreme MINIPORT
> Broadcom Corp. Irvine, CA
> www.broadcom.com
>
>
> — “S. Drasnin” wrote:
>
> > hi
> >
> > I am looking for the Microsoft sample
> gexport.exe
> > that shows you how to create a kernel export dll
> and
> > import functions in it into a video driver. A
> old
> > driver posting on the web said it was on an ftp
> > site, but that was years ago.
> >
> > Can somebody (maybe some Microsoft folks?) point
> me
> > to where I can find it or send me a zip file?
> >
> > I’ve found out the hard way that my driver fails
> to
> > link because I’m calling things like
> > ExAllocatePoolWithTag, and apparently calling
> HAL
> > Functions from a video driver isn’t allowed,
> hence
> > the export dll route.
> >
> > thanks in advance…
> > —
> > Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as:
> unknown
> > lmsubst tag argument: ‘’
> > To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>
>
>
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam
> protection around
> http://mail.yahoo.com
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as:
> xxxxx@msn.com
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown
> lmsubst tag argument: ‘’
> To unsubscribe send a blank email to
xxxxx@lists.osr.com


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

You can always try to peek at the target component’s PE header,
get the address of the entry point you want, and call it
directly without the need to link to any library. It’s a tad to
the extreme end of the spectrum, but it works.

Alberto.

----- Original Message -----
From: “Calvin Guan”
To: “Windows System Software Devs Interest List”

Sent: Sunday, July 17, 2005 5:07 PM
Subject: Re: [ntdev] Where do I find Microsoft’s gexport.exe
sample?

> By “Video Driver”, there are two very distinctive:
> 1) MINIPORT driver (general kernel mode) that links to
> ntoskrnl/hal, videoprt.sys
> 2) DISPLAY DRIVER (session based kernel mode) that
> only links to win32k.sys.
>
> Which one do you mean? You can only call GDI
> functions (EngXxx) in a kernel mode DISPLAY DRIVER and
> exported DLL that’s going to be loaded by the DISPLAY
> DRIVER. That’s to say, 1) if you call
> ExAllocatePoolWithTag in a DISPLAY DRIVER, GDI won’t
> load it. 2) If you call ExAllocatePoolWithTag in a
> kernel mode DLL, your DISPLAY DRIVER can NOT load it
> (EngLoadImage will fail.) These behaviors are by
> design and are enforced by GDI loader.
>
> On the flip side, calling GDI andor DISPLAY DRIVER
> functions from MINIPORT drivers is bad in general. It
> can be done safely in some cases with some additional
> work. (Remember GDI is session based where MINIPORT
> isn’t)
>
> To allocate memory in DISPLAY DRIVER (GDI), use
> EngAllocMem. To do it in MINIPORT driver, use
> VideoPortAllocatePool. If you want to do something in
> the display driver that GDI doesn’t facilitate, you
> send an IOCTL to the miniport driver and let the
> MINIPORT does it (if videoport allowed). Perhaps I
> didn’t fully understand what you are trying to do?
>
>
> Humble opinion from a former ATI Radeon Graphics
> Driver developer.
>
> –
> Calvin Guan (Windows DDK MVP)
> Staff SW Engineer NetXtreme MINIPORT
> Broadcom Corp. Irvine, CA
> www.broadcom.com
>
>
> — “S. Drasnin” wrote:
>
>> hi
>>
>> I am looking for the Microsoft sample gexport.exe
>> that shows you how to create a kernel export dll and
>> import functions in it into a video driver. A old
>> driver posting on the web said it was on an ftp
>> site, but that was years ago.
>>
>> Can somebody (maybe some Microsoft folks?) point me
>> to where I can find it or send me a zip file?
>>
>> I’ve found out the hard way that my driver fails to
>> link because I’m calling things like
>> ExAllocatePoolWithTag, and apparently calling HAL
>> Functions from a video driver isn’t allowed, hence
>> the export dll route.
>>
>> thanks in advance…
>> —
>> Questions? First check the Kernel Driver FAQ at
>> http://www.osronline.com/article.cfm?id=256
>>
>> You are currently subscribed to ntdev as: unknown
>> lmsubst tag argument: ‘’
>> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection
> around
> http://mail.yahoo.com
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@ieee.org
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com

Well, if I really want, there are easier ways than
parsing the PE header. That’s not the point.


Calvin Guan (Windows DDK MVP)
Staff SW Engineer NetXtreme MINIPORT
Broadcom Corp. Irvine, CA
www.broadcom.com

— Alberto Moreira wrote:

> You can always try to peek at the target component’s
> PE header,
> get the address of the entry point you want, and
> call it
> directly without the need to link to any library.
> It’s a tad to
> the extreme end of the spectrum, but it works.
>
> Alberto.
>
> ----- Original Message -----
> From: “Calvin Guan”
> To: “Windows System Software Devs Interest List”
>
> Sent: Sunday, July 17, 2005 5:07 PM
> Subject: Re: [ntdev] Where do I find Microsoft’s
> gexport.exe
> sample?
>
>
> > By “Video Driver”, there are two very distinctive:
> > 1) MINIPORT driver (general kernel mode) that
> links to
> > ntoskrnl/hal, videoprt.sys
> > 2) DISPLAY DRIVER (session based kernel mode) that
> > only links to win32k.sys.
> >
> > Which one do you mean? You can only call GDI
> > functions (EngXxx) in a kernel mode DISPLAY DRIVER
> and
> > exported DLL that’s going to be loaded by the
> DISPLAY
> > DRIVER. That’s to say, 1) if you call
> > ExAllocatePoolWithTag in a DISPLAY DRIVER, GDI
> won’t
> > load it. 2) If you call ExAllocatePoolWithTag in a
> > kernel mode DLL, your DISPLAY DRIVER can NOT load
> it
> > (EngLoadImage will fail.) These behaviors are by
> > design and are enforced by GDI loader.
> >
> > On the flip side, calling GDI andor DISPLAY DRIVER
> > functions from MINIPORT drivers is bad in general.
> It
> > can be done safely in some cases with some
> additional
> > work. (Remember GDI is session based where
> MINIPORT
> > isn’t)
> >
> > To allocate memory in DISPLAY DRIVER (GDI), use
> > EngAllocMem. To do it in MINIPORT driver, use
> > VideoPortAllocatePool. If you want to do something
> in
> > the display driver that GDI doesn’t facilitate,
> you
> > send an IOCTL to the miniport driver and let the
> > MINIPORT does it (if videoport allowed). Perhaps I
> > didn’t fully understand what you are trying to do?
> >
> >
> > Humble opinion from a former ATI Radeon Graphics
> > Driver developer.
> >
> > –
> > Calvin Guan (Windows DDK MVP)
> > Staff SW Engineer NetXtreme MINIPORT
> > Broadcom Corp. Irvine, CA
> > www.broadcom.com
> >
> >
> > — “S. Drasnin” wrote:
> >
> >> hi
> >>
> >> I am looking for the Microsoft sample gexport.exe
> >> that shows you how to create a kernel export dll
> and
> >> import functions in it into a video driver. A
> old
> >> driver posting on the web said it was on an ftp
> >> site, but that was years ago.
> >>
> >> Can somebody (maybe some Microsoft folks?) point
> me
> >> to where I can find it or send me a zip file?
> >>
> >> I’ve found out the hard way that my driver fails
> to
> >> link because I’m calling things like
> >> ExAllocatePoolWithTag, and apparently calling HAL
> >> Functions from a video driver isn’t allowed,
> hence
> >> the export dll route.
> >>
> >> thanks in advance…
> >> —
> >> Questions? First check the Kernel Driver FAQ at
> >> http://www.osronline.com/article.cfm?id=256
> >>
> >> You are currently subscribed to ntdev as: unknown
> >> lmsubst tag argument: ‘’
> >> To unsubscribe send a blank email to
> > xxxxx@lists.osr.com
> >
> >
> >
> > Do You Yahoo!?
> > Tired of spam? Yahoo! Mail has the best spam
> protection
> > around
> > http://mail.yahoo.com
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as:
> xxxxx@ieee.org
> > To unsubscribe send a blank email to
> > xxxxx@lists.osr.com
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as:
> xxxxx@yahoo.ca
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

My point is we should always try to follow the rules.
I believe whoever made the rules didn’t dream up the
idea, there must be good reasons for that. Whoever
broke the rule, he’s marching to the uncharted
territory and on their own.

I did use a huge amount of unbelievable hacks for my
basement-grown test/debugging tools. When it comes to
developing commercial product, the story will be
totally different.

The companies I worked for usually have agreement with
major OEMs who use our chips/drivers. If there’s a
problem in our product because our poor design
(unsupported methods, hack), the company shall be
LIABLE to any lost.

Now consider my driver is running on hundreds of
millions of grandpa/granny’s systems and we are
shipping millions dies each quarter, I certainly don’t
want to be hero of doing anything close by “the end of
spectrum”.


Calvin Guan (Windows DDK MVP)
Staff SW Engineer NetXtreme MINIPORT
Broadcom Corp. Irvine, CA
www.broadcom.com

— Calvin Guan wrote:

> Well, if I really want, there are easier ways than
> parsing the PE header. That’s not the point.
>
> –
> Calvin Guan (Windows DDK MVP)
> Staff SW Engineer NetXtreme MINIPORT
> Broadcom Corp. Irvine, CA
> www.broadcom.com
>
>
> — Alberto Moreira wrote:
>
> > You can always try to peek at the target
> component’s
> > PE header,
> > get the address of the entry point you want, and
> > call it
> > directly without the need to link to any library.
> > It’s a tad to
> > the extreme end of the spectrum, but it works.
> >
> > Alberto.
> >
> > ----- Original Message -----
> > From: “Calvin Guan”
> > To: “Windows System Software Devs Interest List”
> >
> > Sent: Sunday, July 17, 2005 5:07 PM
> > Subject: Re: [ntdev] Where do I find Microsoft’s
> > gexport.exe
> > sample?
> >
> >
> > > By “Video Driver”, there are two very
> distinctive:
> > > 1) MINIPORT driver (general kernel mode) that
> > links to
> > > ntoskrnl/hal, videoprt.sys
> > > 2) DISPLAY DRIVER (session based kernel mode)
> that
> > > only links to win32k.sys.
> > >
> > > Which one do you mean? You can only call GDI
> > > functions (EngXxx) in a kernel mode DISPLAY
> DRIVER
> > and
> > > exported DLL that’s going to be loaded by the
> > DISPLAY
> > > DRIVER. That’s to say, 1) if you call
> > > ExAllocatePoolWithTag in a DISPLAY DRIVER, GDI
> > won’t
> > > load it. 2) If you call ExAllocatePoolWithTag in
> a
> > > kernel mode DLL, your DISPLAY DRIVER can NOT
> load
> > it
> > > (EngLoadImage will fail.) These behaviors are by
> > > design and are enforced by GDI loader.
> > >
> > > On the flip side, calling GDI andor DISPLAY
> DRIVER
> > > functions from MINIPORT drivers is bad in
> general.
> > It
> > > can be done safely in some cases with some
> > additional
> > > work. (Remember GDI is session based where
> > MINIPORT
> > > isn’t)
> > >
> > > To allocate memory in DISPLAY DRIVER (GDI), use
> > > EngAllocMem. To do it in MINIPORT driver, use
> > > VideoPortAllocatePool. If you want to do
> something
> > in
> > > the display driver that GDI doesn’t facilitate,
> > you
> > > send an IOCTL to the miniport driver and let the
> > > MINIPORT does it (if videoport allowed). Perhaps
> I
> > > didn’t fully understand what you are trying to
> do?
> > >
> > >
> > > Humble opinion from a former ATI Radeon Graphics
> > > Driver developer.
> > >
> > > –
> > > Calvin Guan (Windows DDK MVP)
> > > Staff SW Engineer NetXtreme MINIPORT
> > > Broadcom Corp. Irvine, CA
> > > www.broadcom.com
> > >
> > >
> > > — “S. Drasnin” wrote:
> > >
> > >> hi
> > >>
> > >> I am looking for the Microsoft sample
> gexport.exe
> > >> that shows you how to create a kernel export
> dll
> > and
> > >> import functions in it into a video driver. A
> > old
> > >> driver posting on the web said it was on an ftp
> > >> site, but that was years ago.
> > >>
> > >> Can somebody (maybe some Microsoft folks?)
> point
> > me
> > >> to where I can find it or send me a zip file?
> > >>
> > >> I’ve found out the hard way that my driver
> fails
> > to
> > >> link because I’m calling things like
> > >> ExAllocatePoolWithTag, and apparently calling
> HAL
> > >> Functions from a video driver isn’t allowed,
> > hence
> > >> the export dll route.
> > >>
> > >> thanks in advance…
> > >> —
> > >> Questions? First check the Kernel Driver FAQ at
> > >> http://www.osronline.com/article.cfm?id=256
> > >>
> > >> You are currently subscribed to ntdev as:
> unknown
> > >> lmsubst tag argument: ‘’
> > >> To unsubscribe send a blank email to
> > > xxxxx@lists.osr.com
> > >
> > >
> > >
>
> > > Do You Yahoo!?
> > > Tired of spam? Yahoo! Mail has the best spam
> > protection
> > > around
> > > http://mail.yahoo.com
> > >
> > > —
> > > Questions? First check the Kernel Driver FAQ at
> > > http://www.osronline.com/article.cfm?id=256
> > >
> > > You are currently subscribed to ntdev as:
> > xxxxx@ieee.org
> > > To unsubscribe send a blank email to
> > > xxxxx@lists.osr.com
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as:
> > xxxxx@yahoo.ca
> > To unsubscribe send a blank email to
> > xxxxx@lists.osr.com
> >
>
>
>

> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam
> protection around
> http://mail.yahoo.com
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as:
> xxxxx@yahoo.ca
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Thanks - all the information has helped me a lot!
----- Original Message -----
From: Calvin Guanmailto:xxxxx
To: Windows System Software Devs Interest Listmailto:xxxxx
Sent: Sunday, July 17, 2005 4:10 PM
Subject: Re: [ntdev] Where do I find Microsoft’s gexport.exe sample?

I’ve not done mirror driver before I’m not sure if
your driver mirrors the VGA driver. If it did, then I
guess your mirror driver would have been loaded thus
you can’t simply overwrite the display driver (.DLL).
Again, I’m not very positive.

I would suggest you use .kdfiles (windbg command) to
replace your mirror display driver. See WinDbg doc for
more info.

> By the way, what does “session based” mean?

Session space is a portion of kernel address space.
Each logged in user has their own session space. See
David and Mark’s Inside Windows 2000 for more
background info. Each session has their own instance
of GDI and display driver instances. If you trace the
init functions of the display driver
(DrvEnableDriver/Surface/AssertMode), you will see GDI
initializes display driver whenever a new user logged
in (a new session became active).

MINIPORT, like other KMDs, has only one driver
instance regardless how many sessions there are in the
system.


Calvin Guan (Windows DDK MVP)
Staff SW Engineer NetXtreme MINIPORT
Broadcom Corp. Irvine, CA
www.broadcom.comhttp:</http:>

— “S. Drasnin” > wrote:

> hi Calvin:
>
> I just posted another question but I see your email
> answered most of my questions - thank you for the
> detailed response. I was using the mirror driver and
> was trying to call ExAllocatePool with tag in the
> mirror driver’s display driver. I actually created a
> static library that wrapped the call to
> ExAllocatePool and linked against it (specified this
> lib TARGETLIB in the sources files of the display
> driver.)
>
> I will try your suggestion of calling EngAllocMem.
>
> Do you have a suggestion on how to recover my
> machine? When I ran with the driver with the call
> made to the export library that contained a function
> that wrapped ExAllocatePool, I got a nasty Message
> Box saying my viga driver was out of date and it was
> reverting back to a default vga driver. I
> uninstalled the mirror driver and whacked the
> mirror.dll and mirror.sys in my c:\windows\system32
> and c:\windows\system32\drivers directories,
> rebooted, and reinstalled an old version of the
> driver that didn’t link to the export lib. But,
> things are very hosed. I never reach the DrvEscape
> function in the mirror display driver any longer. (I
> have KdPrints in there and an _asm int 3 and have a
> testapp that makes a driver escape call.)I guess the
> OS refuses to load it with the default vga driver it
> said it was going to run. I did try renaming
> mirror.dll and mirror.sys to mirror_0.dll and
> mirror_0.sys as well, but no luck.
>
> I’m will try to locate the correct vga display
> driver for my PC (it’s really old) or resort to
> reimaging my PC, but hope you have some other
> suggestions. It’s a painful way to recover.
>
> By the way, what does “session based” mean? This is
> the first time I’m doing anything with video
> drivers.
>
> thanks for the helpful responses!
>
>
> ----- Original Message -----
> From: Calvin Guan
> To: Windows System Software Devs Interest List
> Sent: Sunday, July 17, 2005 2:07 PM
> Subject: Re: [ntdev] Where do I find Microsoft’s
> gexport.exe sample?
>
>
> By “Video Driver”, there are two very distinctive:
> 1) MINIPORT driver (general kernel mode) that
> links to
> ntoskrnl/hal, videoprt.sys
> 2) DISPLAY DRIVER (session based kernel mode) that
> only links to win32k.sys.
>
> Which one do you mean? You can only call GDI
> functions (EngXxx) in a kernel mode DISPLAY DRIVER
> and
> exported DLL that’s going to be loaded by the
> DISPLAY
> DRIVER. That’s to say, 1) if you call
> ExAllocatePoolWithTag in a DISPLAY DRIVER, GDI
> won’t
> load it. 2) If you call ExAllocatePoolWithTag in a
> kernel mode DLL, your DISPLAY DRIVER can NOT load
> it
> (EngLoadImage will fail.) These behaviors are by
> design and are enforced by GDI loader.
>
> On the flip side, calling GDI andor DISPLAY DRIVER
> functions from MINIPORT drivers is bad in general.
> It
> can be done safely in some cases with some
> additional
> work. (Remember GDI is session based where
> MINIPORT
> isn’t)
>
> To allocate memory in DISPLAY DRIVER (GDI), use
> EngAllocMem. To do it in MINIPORT driver, use
> VideoPortAllocatePool. If you want to do something
> in
> the display driver that GDI doesn’t facilitate,
> you
> send an IOCTL to the miniport driver and let the
> MINIPORT does it (if videoport allowed). Perhaps I
> didn’t fully understand what you are trying to do?
>
>
> Humble opinion from a former ATI Radeon Graphics
> Driver developer.
>
> –
> Calvin Guan (Windows DDK MVP)
> Staff SW Engineer NetXtreme MINIPORT
> Broadcom Corp. Irvine, CA
> www.broadcom.comhttp:</http:>
>
>
> — “S. Drasnin” > wrote:
>
> > hi
> >
> > I am looking for the Microsoft sample
> gexport.exe
> > that shows you how to create a kernel export dll
> and
> > import functions in it into a video driver. A
> old
> > driver posting on the web said it was on an ftp
> > site, but that was years ago.
> >
> > Can somebody (maybe some Microsoft folks?) point
> me
> > to where I can find it or send me a zip file?
> >
> > I’ve found out the hard way that my driver fails
> to
> > link because I’m calling things like
> > ExAllocatePoolWithTag, and apparently calling
> HAL
> > Functions from a video driver isn’t allowed,
> hence
> > the export dll route.
> >
> > thanks in advance…
> > —
> > Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256http:
> >
> > You are currently subscribed to ntdev as:
> unknown
> > lmsubst tag argument: ‘’
> > To unsubscribe send a blank email to
> xxxxx@lists.osr.commailto:xxxxx
>
>
>
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam
> protection around
> http://mail.yahoo.comhttp:</http:>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256http:
>
> You are currently subscribed to ntdev as:
> xxxxx@msn.commailto:xxxxx
> To unsubscribe send a blank email to
> xxxxx@lists.osr.commailto:xxxxx
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256http:
>
> You are currently subscribed to ntdev as: unknown
> lmsubst tag argument: ‘’
> To unsubscribe send a blank email to
xxxxx@lists.osr.commailto:xxxxx


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.comhttp:</http:>


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256http:

You are currently subscribed to ntdev as: xxxxx@msn.commailto:xxxxx
To unsubscribe send a blank email to xxxxx@lists.osr.commailto:xxxxx</mailto:xxxxx></mailto:xxxxx></http:></mailto:xxxxx></http:></mailto:xxxxx></mailto:xxxxx></http:></mailto:xxxxx></http:></mailto:xxxxx></mailto:xxxxx>

Calvin Guan wrote:

By “Video Driver”, there are two very distinctive:

  1. MINIPORT driver (general kernel mode) that links to
    ntoskrnl/hal, videoprt.sys
  2. DISPLAY DRIVER (session based kernel mode) that
    only links to win32k.sys.

Which one do you mean? You can only call GDI
functions (EngXxx) in a kernel mode DISPLAY DRIVER and
exported DLL that’s going to be loaded by the DISPLAY
DRIVER. That’s to say, 1) if you call
ExAllocatePoolWithTag in a DISPLAY DRIVER, GDI won’t
load it. 2) If you call ExAllocatePoolWithTag in a
kernel mode DLL, your DISPLAY DRIVER can NOT load it
(EngLoadImage will fail.) These behaviors are by
design and are enforced by GDI loader.

As a matter of fact, in a mirror driver, it’s perfectly legal to load a
kernel-mode DLL that links with Win32k.sys. I’ve done it, and that driver has
passed all relevant WHQL tests.

Burk.

You’ve got to read my post again.

As a matter of fact, in a mirror driver, it’s
perfectly legal to load a
kernel-mode DLL that links with Win32k.sys. I’ve
done it, and that driver has
passed all relevant WHQL tests.

Did I say “can’t load a kernel-mode DLL that links
with Win32k.sys” anywhere in my post?

I said one can’t call ExXxx function in such a DLL
linked to win32k.sys and loaded by the display driver.


Calvin Guan (Windows DDK MVP)
Staff SW Engineer NetXtreme MINIPORT
Broadcom Corp. Irvine, CA
www.broadcom.com

— Burkhard Daniel
wrote:

> Calvin Guan wrote:
> > By “Video Driver”, there are two very distinctive:
> > 1) MINIPORT driver (general kernel mode) that
> links to
> > ntoskrnl/hal, videoprt.sys
> > 2) DISPLAY DRIVER (session based kernel mode) that
> > only links to win32k.sys.
> >
> > Which one do you mean? You can only call GDI
> > functions (EngXxx) in a kernel mode DISPLAY DRIVER
> and
> > exported DLL that’s going to be loaded by the
> DISPLAY
> > DRIVER. That’s to say, 1) if you call
> > ExAllocatePoolWithTag in a DISPLAY DRIVER, GDI
> won’t
> > load it. 2) If you call ExAllocatePoolWithTag in a
> > kernel mode DLL, your DISPLAY DRIVER can NOT load
> it
> > (EngLoadImage will fail.) These behaviors are by
> > design and are enforced by GDI loader.
>
> As a matter of fact, in a mirror driver, it’s
> perfectly legal to load a
> kernel-mode DLL that links with Win32k.sys. I’ve
> done it, and that driver has
> passed all relevant WHQL tests.
>
> Burk.
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as:
> xxxxx@yahoo.ca
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

> As a matter of fact, in a mirror driver, it’s

perfectly legal to load a
kernel-mode DLL that links with Win32k.sys.

Is ice cold?
That’s what EngLoadImage is for. Many D3D drivers are
implemented as DLL loaded by display driver.

I said you CAN NOT call Non-GDI function such as
ExAllocatePoolWithTag in such a DLL otherwise
EngLoadImage refuses to load the DLL. Don’t believe
me? Just give it a spin.


Calvin Guan (Windows DDK MVP)
Staff SW Engineer NetXtreme MINIPORT
Broadcom Corp. Irvine, CA
www.broadcom.com


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Rules ? Whose from ? Please. I’ll follow my own rules, thank
you, and my software isn’t in the habit of croaking.

Alberto.

----- Original Message -----
From: “Calvin Guan”
To: “Windows System Software Devs Interest List”

Sent: Sunday, July 17, 2005 8:03 PM
Subject: Re: [ntdev] Where do I find Microsoft’s gexport.exe
sample?

> My point is we should always try to follow the rules.
> I believe whoever made the rules didn’t dream up the
> idea, there must be good reasons for that. Whoever
> broke the rule, he’s marching to the uncharted
> territory and on their own.
>
> I did use a huge amount of unbelievable hacks for my
> basement-grown test/debugging tools. When it comes to
> developing commercial product, the story will be
> totally different.
>
> The companies I worked for usually have agreement with
> major OEMs who use our chips/drivers. If there’s a
> problem in our product because our poor design
> (unsupported methods, hack), the company shall be
> LIABLE to any lost.
>
> Now consider my driver is running on hundreds of
> millions of grandpa/granny’s systems and we are
> shipping millions dies each quarter, I certainly don’t
> want to be hero of doing anything close by “the end of
> spectrum”.
>
> –
> Calvin Guan (Windows DDK MVP)
> Staff SW Engineer NetXtreme MINIPORT
> Broadcom Corp. Irvine, CA
> www.broadcom.com
>
>
> — Calvin Guan wrote:
>
>> Well, if I really want, there are easier ways than
>> parsing the PE header. That’s not the point.
>>
>> –
>> Calvin Guan (Windows DDK MVP)
>> Staff SW Engineer NetXtreme MINIPORT
>> Broadcom Corp. Irvine, CA
>> www.broadcom.com
>>
>>
>> — Alberto Moreira wrote:
>>
>> > You can always try to peek at the target
>> component’s
>> > PE header,
>> > get the address of the entry point you want, and
>> > call it
>> > directly without the need to link to any library.
>> > It’s a tad to
>> > the extreme end of the spectrum, but it works.
>> >
>> > Alberto.
>> >
>> > ----- Original Message -----
>> > From: “Calvin Guan”
>> > To: “Windows System Software Devs Interest List”
>> >
>> > Sent: Sunday, July 17, 2005 5:07 PM
>> > Subject: Re: [ntdev] Where do I find Microsoft’s
>> > gexport.exe
>> > sample?
>> >
>> >
>> > > By “Video Driver”, there are two very
>> distinctive:
>> > > 1) MINIPORT driver (general kernel mode) that
>> > links to
>> > > ntoskrnl/hal, videoprt.sys
>> > > 2) DISPLAY DRIVER (session based kernel mode)
>> that
>> > > only links to win32k.sys.
>> > >
>> > > Which one do you mean? You can only call GDI
>> > > functions (EngXxx) in a kernel mode DISPLAY
>> DRIVER
>> > and
>> > > exported DLL that’s going to be loaded by the
>> > DISPLAY
>> > > DRIVER. That’s to say, 1) if you call
>> > > ExAllocatePoolWithTag in a DISPLAY DRIVER, GDI
>> > won’t
>> > > load it. 2) If you call ExAllocatePoolWithTag in
>> a
>> > > kernel mode DLL, your DISPLAY DRIVER can NOT
>> load
>> > it
>> > > (EngLoadImage will fail.) These behaviors are by
>> > > design and are enforced by GDI loader.
>> > >
>> > > On the flip side, calling GDI andor DISPLAY
>> DRIVER
>> > > functions from MINIPORT drivers is bad in
>> general.
>> > It
>> > > can be done safely in some cases with some
>> > additional
>> > > work. (Remember GDI is session based where
>> > MINIPORT
>> > > isn’t)
>> > >
>> > > To allocate memory in DISPLAY DRIVER (GDI), use
>> > > EngAllocMem. To do it in MINIPORT driver, use
>> > > VideoPortAllocatePool. If you want to do
>> something
>> > in
>> > > the display driver that GDI doesn’t facilitate,
>> > you
>> > > send an IOCTL to the miniport driver and let the
>> > > MINIPORT does it (if videoport allowed). Perhaps
>> I
>> > > didn’t fully understand what you are trying to
>> do?
>> > >
>> > >
>> > > Humble opinion from a former ATI Radeon Graphics
>> > > Driver developer.
>> > >
>> > > –
>> > > Calvin Guan (Windows DDK MVP)
>> > > Staff SW Engineer NetXtreme MINIPORT
>> > > Broadcom Corp. Irvine, CA
>> > > www.broadcom.com
>> > >
>> > >
>> > > — “S. Drasnin” wrote:
>> > >
>> > >> hi
>> > >>
>> > >> I am looking for the Microsoft sample
>> gexport.exe
>> > >> that shows you how to create a kernel export
>> dll
>> > and
>> > >> import functions in it into a video driver. A
>> > old
>> > >> driver posting on the web said it was on an ftp
>> > >> site, but that was years ago.
>> > >>
>> > >> Can somebody (maybe some Microsoft folks?)
>> point
>> > me
>> > >> to where I can find it or send me a zip file?
>> > >>
>> > >> I’ve found out the hard way that my driver
>> fails
>> > to
>> > >> link because I’m calling things like
>> > >> ExAllocatePoolWithTag, and apparently calling
>> HAL
>> > >> Functions from a video driver isn’t allowed,
>> > hence
>> > >> the export dll route.
>> > >>
>> > >> thanks in advance…
>> > >> —
>> > >> Questions? First check the Kernel Driver FAQ at
>> > >> http://www.osronline.com/article.cfm?id=256
>> > >>
>> > >> You are currently subscribed to ntdev as:
>> unknown
>> > >> lmsubst tag argument: ‘’
>> > >> To unsubscribe send a blank email to
>> > > xxxxx@lists.osr.com
>> > >
>> > >
>> > >
>>
>> > > Do You Yahoo!?
>> > > Tired of spam? Yahoo! Mail has the best spam
>> > protection
>> > > around
>> > > http://mail.yahoo.com
>> > >
>> > > —
>> > > Questions? First check the Kernel Driver FAQ at
>> > > http://www.osronline.com/article.cfm?id=256
>> > >
>> > > You are currently subscribed to ntdev as:
>> > xxxxx@ieee.org
>> > > To unsubscribe send a blank email to
>> > > xxxxx@lists.osr.com
>> >
>> >
>> > —
>> > Questions? First check the Kernel Driver FAQ at
>> > http://www.osronline.com/article.cfm?id=256
>> >
>> > You are currently subscribed to ntdev as:
>> > xxxxx@yahoo.ca
>> > To unsubscribe send a blank email to
>> > xxxxx@lists.osr.com
>> >
>>
>>
>>

>> Do You Yahoo!?
>> Tired of spam? Yahoo! Mail has the best spam
>> protection around
>> http://mail.yahoo.com
>>
>> —
>> Questions? First check the Kernel Driver FAQ at
>> http://www.osronline.com/article.cfm?id=256
>>
>> You are currently subscribed to ntdev as:
>> xxxxx@yahoo.ca
>> To unsubscribe send a blank email to
>> xxxxx@lists.osr.com
>>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection
> around
> http://mail.yahoo.com
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@ieee.org
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com

Calvin Guan wrote:

You’ve got to read my post again.

>As a matter of fact, in a mirror driver, it’s

perfectly legal to load a

>kernel-mode DLL that links with Win32k.sys. I’ve

done it, and that driver has

>passed all relevant WHQL tests.
>

Did I say “can’t load a kernel-mode DLL that links
with Win32k.sys” anywhere in my post?

I said one can’t call ExXxx function in such a DLL
linked to win32k.sys and loaded by the display driver.

Well then I should be more specific. Yes, you can load a kernel-mode DLL that
links with Win32k.sys AND calls ExXxx functions in a MIRROR driver. I don’t
know about other display drivers, but in a mirror driver that is perfectly
legal and is no hindrance in getting your driver signed by MS.

And this I know for a fact, having done it myself on both W2K and XP.

In my specific case, I’m using the lookaside list functions in my kernel-mode
DLL which I load from my mirror driver, and that works like a charm.

Burk.

Hmmm, are you saying the mirror display driver
mirror_disp.DLL calls EngLoadImage to load export.dll
and the export.dll directly references ExXxxx??

Now you got me interested. This seems to contradict
their own design if it allowed a GDI driver to load a
DLL calls non-GDI functions).

I do remember this failed in a HW display driver
(Complaining something like entry point not found,
can’t remember the exact wording though.)

I don’t know anything about mirror driver but I don’t
think this should make a difference. Thank you for
letting me know, I’ll try it out on a mirror driver.


Calvin Guan (Windows DDK MVP)
Staff SW Engineer NetXtreme MINIPORT
Broadcom Corp. Irvine, CA
www.broadcom.com

— Burkhard Daniel
wrote:

> Calvin Guan wrote:
> > You’ve got to read my post again.
> >
> >
> >>As a matter of fact, in a mirror driver, it’s
> >
> > perfectly legal to load a
> >
> >>kernel-mode DLL that links with Win32k.sys. I’ve
> >
> > done it, and that driver has
> >
> >>passed all relevant WHQL tests.
> >>
> >
> >
> > Did I say “can’t load a kernel-mode DLL that links
> > with Win32k.sys” anywhere in my post?
> >
> > I said one can’t call ExXxx function in such a DLL
> > linked to win32k.sys and loaded by the display
> driver.
> >
>
> Well then I should be more specific. Yes, you can
> load a kernel-mode DLL that
> links with Win32k.sys AND calls ExXxx functions in a
> MIRROR driver. I don’t
> know about other display drivers, but in a mirror
> driver that is perfectly
> legal and is no hindrance in getting your driver
> signed by MS.
>
> And this I know for a fact, having done it myself on
> both W2K and XP.
>
> In my specific case, I’m using the lookaside list
> functions in my kernel-mode
> DLL which I load from my mirror driver, and that
> works like a charm.
>
> Burk.
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as:
> xxxxx@yahoo.ca
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Out of curiosity, for special drivers, such as video driver, does it matter whether you access an exported function from a DLL or from a static lib that the driver links statically against (TARGETLIBS = *.lib). Will both methods work and what are the general trade-offs?

thanks
----- Original Message -----
From: Calvin Guanmailto:xxxxx
To: Windows System Software Devs Interest Listmailto:xxxxx
Sent: Tuesday, July 19, 2005 3:05 AM
Subject: Re:[ntdev] Where do I find Microsoft’s gexport.exe sample?

Hmmm, are you saying the mirror display driver
mirror_disp.DLL calls EngLoadImage to load export.dll
and the export.dll directly references ExXxxx??

Now you got me interested. This seems to contradict
their own design if it allowed a GDI driver to load a
DLL calls non-GDI functions).

I do remember this failed in a HW display driver
(Complaining something like entry point not found,
can’t remember the exact wording though.)

I don’t know anything about mirror driver but I don’t
think this should make a difference. Thank you for
letting me know, I’ll try it out on a mirror driver.


Calvin Guan (Windows DDK MVP)
Staff SW Engineer NetXtreme MINIPORT
Broadcom Corp. Irvine, CA
www.broadcom.comhttp:</http:>

— Burkhard Daniel >
wrote:

> Calvin Guan wrote:
> > You’ve got to read my post again.
> >
> >
> >>As a matter of fact, in a mirror driver, it’s
> >
> > perfectly legal to load a
> >
> >>kernel-mode DLL that links with Win32k.sys. I’ve
> >
> > done it, and that driver has
> >
> >>passed all relevant WHQL tests.
> >>
> >
> >
> > Did I say “can’t load a kernel-mode DLL that links
> > with Win32k.sys” anywhere in my post?
> >
> > I said one can’t call ExXxx function in such a DLL
> > linked to win32k.sys and loaded by the display
> driver.
> >
>
> Well then I should be more specific. Yes, you can
> load a kernel-mode DLL that
> links with Win32k.sys AND calls ExXxx functions in a
> MIRROR driver. I don’t
> know about other display drivers, but in a mirror
> driver that is perfectly
> legal and is no hindrance in getting your driver
> signed by MS.
>
> And this I know for a fact, having done it myself on
> both W2K and XP.
>
> In my specific case, I’m using the lookaside list
> functions in my kernel-mode
> DLL which I load from my mirror driver, and that
> works like a charm.
>
> Burk.
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256http:
>
> You are currently subscribed to ntdev as:
> xxxxx@yahoo.camailto:xxxxx
> To unsubscribe send a blank email to
> xxxxx@lists.osr.commailto:xxxxx
>

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.comhttp:</http:>


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256http:

You are currently subscribed to ntdev as: xxxxx@msn.commailto:xxxxx
To unsubscribe send a blank email to xxxxx@lists.osr.commailto:xxxxx</mailto:xxxxx></mailto:xxxxx></http:></mailto:xxxxx></mailto:xxxxx></http:></mailto:xxxxx></mailto:xxxxx>

S. Drasnin wrote:

Out of curiosity, for special drivers, such as video driver, does it
matter whether you access an exported function from a DLL or from a
static lib that the driver links statically against (TARGETLIBS =
*.lib). Will both methods work and what are the general trade-offs?

The answer is “yes and no”. Yes, you can do it. No, it won’t matter.

Remember that the key limitation is that a GDI driver cannot dynamically
link to any kernel DLL other than WIN32K. It doesn’t matter how you do
it. If you call ExAllocPool from your display driver, it will not
load. Moving the call into a static library (.lib) makes absolutely no
difference in the final DLL: it will still be an import from your
display driver, and the driver will not load.

As Calvin said, my understanding was that a DLL loaded by EngLoadImage
also could not call ExAllocPool.

There are relatively easy ways around this in most cases. Your miniport
is allowed to call arbitrary kernel APIs. Your display driver can send
an ioctl to the miniport and have it return an array of function
pointers – like a COM interface – to provide arbitrary services to
your display driver.

However, you’d better have a good justification for doing it. The rules
are there are a reason.


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

Thanks for the helpful emails.

One more question. What is the equivalent IRP_MJ_CLEANUP handler in a video display driver?

I want to clean up allocated memory (allocated in the driver) that is shared between an app and the driver for the case in which the app hangs/crashes before it notifies the driver that it’s ok to release the allocated memory.

thanks
----- Original Message -----
From: Tim Robertsmailto:xxxxx
To: Windows System Software Devs Interest Listmailto:xxxxx
Sent: Tuesday, July 19, 2005 10:42 AM
Subject: Re: [ntdev] Where do I find Microsoft’s gexport.exe sample?

S. Drasnin wrote:

> Out of curiosity, for special drivers, such as video driver, does it
> matter whether you access an exported function from a DLL or from a
> static lib that the driver links statically against (TARGETLIBS =
> *.lib). Will both methods work and what are the general trade-offs?

The answer is “yes and no”. Yes, you can do it. No, it won’t matter.

Remember that the key limitation is that a GDI driver cannot dynamically
link to any kernel DLL other than WIN32K. It doesn’t matter how you do
it. If you call ExAllocPool from your display driver, it will not
load. Moving the call into a static library (.lib) makes absolutely no
difference in the final DLL: it will still be an import from your
display driver, and the driver will not load.

As Calvin said, my understanding was that a DLL loaded by EngLoadImage
also could not call ExAllocPool.

There are relatively easy ways around this in most cases. Your miniport
is allowed to call arbitrary kernel APIs. Your display driver can send
an ioctl to the miniport and have it return an array of function
pointers – like a COM interface – to provide arbitrary services to
your display driver.

However, you’d better have a good justification for doing it. The rules
are there are a reason.


Tim Roberts, xxxxx@probo.commailto:xxxxx
Providenza & Boekelheide, Inc.


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256http:

You are currently subscribed to ntdev as: xxxxx@msn.commailto:xxxxx
To unsubscribe send a blank email to xxxxx@lists.osr.commailto:xxxxx</mailto:xxxxx></mailto:xxxxx></http:></mailto:xxxxx></mailto:xxxxx></mailto:xxxxx>

S. Drasnin wrote:

Thanks for the helpful emails.

One more question. What is the equivalent IRP_MJ_CLEANUP handler in a
video display driver?
>
> I want to clean up allocated memory (allocated in the driver) that is
> shared between an app and the driver for the case in which the app
> hangs/crashes before it notifies the driver that it’s ok to release the
> allocated memory.

Check out EngCreateDriverObj and EngDeleteDriverObj. Those routines allow you
associate certain driver-managed resources with a process.

Burk.

S. Drasnin wrote:

Thanks for the helpful emails.

One more question. What is the equivalent IRP_MJ_CLEANUP handler in a
video display driver?

I want to clean up allocated memory (allocated in the driver) that is
shared between an app and the driver for the case in which the app
hangs/crashes before it notifies the driver that it’s ok to release
the allocated memory.

Not possible. IRPs (including IRP_MJ_CLEANUP) get sent to a driver
because an application has an open handle to that driver. There is no
direct connection between any application and the display driver. GDI
introduces a level of disconnect.

I can’t think of any really good solutions for this, other than having
the application allocate the memory, or allocate it in a separate driver
that the application opens.


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