As a general rule for miniport driver, you don’t mess
with that much of kernel routines unless there’s
absolutely no other way around. Miniport is supposed
to use only the facilities the wrapper provides. If
you intend to ship your product with Windows, you may
need a WHQL wavier to get your driver signed. My
previous employer has a very close relationship with
MSFT, so getting a wavier is generally not a big deal.
–
Calvin Guan Windows DDK MVP
Staff SW Engineer, NetXtreme MINIPORT
Enterprise Network Controller Engineering
Broadcom Corporation www.broadcom.com
— Lei Zhang wrote:
> I think the DirectX staff doesn’t work for me,
> because mirror driver
> doesn’t support directX. I will try
> PsSetCreateProcessNotifyRoutine().
> Thanks.
>
> But why you said it is the worst case? Is it very
> slow?
>
> Lei
>
> On 6/2/05, Calvin Guan wrote:
> > No, it’s not explicitly mentioned in the manual.
> It
> > has something to do with DirectDraw/Direct3D init
> and
> > exit.
> >
> > If you have an ATI powered graphics card, set a
> bp at
> > MmUnmapLockedPages, launch and kill a ddraw and/or
> d3d
> > apps. You may find something, there will be a lot
> of
> > hits though. Well, I should had mentioned that
> only
> > works for specific type of apps. But usually,
> these
> > kind of apps (demanding a huge amount of memory
> for
> > rendering texture) need such mapping.
> >
> > Well, in the worst case,
> > PsSetCreateProcessNotifyRoutine is aways there.
> >
> > Calvin Guan Windows DDK MVP
> > Staff SW Engineer, NetXtreme MINIPORT
> > Enterprise Network Controller Engineering
> > Broadcom Corporation www.broadcom.com
> >
> >
> >
> > — Lei Zhang wrote:
> >
> > > You information is very helpful.
> > > Is there any docments that tells how to catch
> that
> > > event?
> > >
> > > Lei
> > >
> > > On 6/1/05, Calvin Guan
> > > wrote:
> > > > You isolate all functions referencing kernel
> > > routines into a file and
> > > > include ntddk.h in that file.
> > > > The pseudo code may look like:
> > > > PVOID
> > > > MapBufferToUserMode(buffer)
> > > > {
> > > > PVOID address = NULL;
> > > > // allocate mdl for the buffer
> > > > mdl = IoAllocateMdl();
> > > > if ( NULL==mdl ) return NULL;
> > > > if (buffer is from paged pool) {
> > > > try {
> > > >
> > > >
> > >
> MmProbeAndLockPages(mdl,UserMode,IoModifyAccess);
> > > >
> > > > }except (EXCEPTION_EXECUTE_HANDLER){
> > > > // bail out
> > > > IoFreeMdl(mdl);
> > > > return NULL;
> > > > }
> > > > } else {
> > > > // buffer is from NpagedPool
> > > > MmBuildMdlForNonPagedPool(mdl);
> > > > }
> > > >
> > > > try {
> > > >
> > > > address =
> > > MmMapLockedPagesSpecifyCache(mdl,UserMode,…);
> > > >
> > > > } except (EXCEPTION_EXECUTE_HANDLER) {
> > > > // bail…
> > > > if (Buffer from paged pool) {
> > > > MmUnmapLockedPages(buffer,mdl);
> > > > }
> > > > IoFreeMdl(mdl);
> > > > return NULL;
> > > > }
> > > > return address;
> > > > }
> > > >
> > > > The tricky part is you must unmap the memory
> upon
> > > the target process
> > > > termination, otherwise system bugchecks when
> it
> > > frees the process address
> > > > space. Unfortunately, you can’t handle
> > > IRP_MJ_CLEANUP in a video miniport
> > > > driver. There’s at least one reliable way to
> catch
> > > process termination event
> > > > from the display driver side (GDI) but I don’t
> > > remember how to do it. Too
> > > > bad I must have left my work log somewhere in
> > > Toronto-:(.
> > > >
> > > > Bottom line is, don’t use mapping until you
> figure
> > > out how to unmap. You’ve
> > > > been warned-
> > > >
> > > > HTH, at least partially
> > > >
> > > > –
> > > > Calvin Guan Windows DDK MVP
> > > > Staff SW Engineer, NetXtreme MINIPORT
> > > > Enterprise Network Controller Engineering
> > > > Broadcom Corporation www.broadcom.com
> > > >
> > > >
> > > >
> > > >
> > > > ----- Original Message -----
> > > > From: “Lei Zhang”
> > > > To: “Windows System Software Devs Interest
> List”
> > >
> > > > Sent: Wednesday, June 01, 2005 6:39 PM
> > > > Subject: Re: [ntdev] memory mapping in display
> > > driver
> > > >
> > > >
> > > > Thanks. I am working on a mirror driver. Could
> you
> > > tell me how to call
> > > > IoXxx/MmXxx routines? I don’t know how to do
> it. I
> > > think the miniport
> > > > driver cannot include ntddk.h.
> > > >
> > > > Lei
> > > > On 6/1/05, Calvin Guan
> > > wrote:
> > > > > Yes, you can do this but not in the display
> > > driver,
> > > > > rather, send an IOCTL along with the buffer
> to
> > > the
> > > > > miniport driver, let the miniport do the
> > > mapping. You
> > > > > will have to call IoXxx/MmXxx routines since
> > > video
> > > > > port doesn’t expose such ability to
> miniports.
> > > > >
> > > > > Our of curiosity, what graphics HW are you
> > > working on?
> > > > >
> > > > >
> > > > > HTH,
> > > > > Calvin
> > > > > –
> > > > > Calvin Guan Windows DDK MVP
> > > > > Staff SW Engineer, NetXtreme MINIPORT
> > > > > Enterprise Network Controller Engineering
> > > > > Broadcom Corporation www.broadcom.com
> > > > >
> > > > >
> > > > >
> > > > > — Lei Zhang wrote:
> > > > >
> > > > > > Can I map the system memory allocated in
> > > display
> > > > > > driver to the virtual
> > > > > > space of the user mode process? i.e.
> mapping
> > > the
> > > > > > meomry block in upper
> > > > > > 2GB space to the lower 2GB space. I saw
> that
> > > > > > miniport driver can do
> > > > > > memory mapping. But it could only deal
> with
> > > the
> > > > > > physical memory.
> > > > > >
> > > > > > Thanks,
> > > > > >
> > > > > > Lei
> > > > > >
> > > > > > —
> > > > > > Questions? First check the Kernel Driver
> FAQ
> > > at
>
=== message truncated ===
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com