Can I Allocate a Memory In Driver that can be visisted by every app??

I Allocate a Memory in driver. and the virtual address is bigger thang
0x80000000.
I want to every app can visisted that memory .

how can do with it ?

Current my method is:

///////////////////////////////////////////////////////////////////////////

void* CalPFN(void * pBase, void* pAddr)
{
unsigned long lPFN;
lPFN = ((unsigned long)pAddr/(ONEPAGE))*4 + (unsigned long)pBase;
return (void*)lPFN;
}

void MakePageAvailable(void * pPageStart, void *pPageEnd)
{
const int nMapNum = 0xffffffff/(ONEPAGE)*4;
PEPROCESS pEPROCESS = NULL;
PHYSICAL_ADDRESS phyPFN ;
unsigned char * pCurPage = pPageStart;

unsigned char * pVIRPFN = NULL;
unsigned char * pucByte; //

if( pPageStart > pPageEnd)
{
return ;
}

pEPROCESS = PsGetCurrentProcess();
phyPFN.LowPart = *(unsigned long*)(((unsigned char*)pEPROCESS) + 0x18);
phyPFN.HighPart = 0 ;

pVIRPFN = (unsigned char*)MmMapIoSpace(phyPFN, nMapNum, FALSE);

do{
pucByte = (unsigned char*)CalPFN((void*)pVIRPFN, (void*)pCurPage);
*pucByte |= 0x4; // Set the Flags that can be visited by user mode
pCurPage += ONEPAGE;
}while( (void*)pCurPage < pPageEnd && (void*)pCurPage > pPageStart);

MmUnmapIoSpace(pVIRPFN, nMapNum);
}
///////////////////////////////////////////////////////////////////////////

I Called MakePageAvailable function in the Create process notify routine.

But when the app visisted that memory, there will be appear a Error.

say the meomoy can’t be read.

who can give me another meothod to solve it ?? very thanks.

In the psCreateNotifyRoutinue, i found that is not in the new created
process’s context.

so i can’t map the kernel address to the user address.

but the msdn is said

The driver’s process-creation notify routine runs at IRQL PASSIVE_LEVEL,
either in the context of the initial thread within a newly created process
or in the context of a system thread.

What do you mean by every app? Only yours, I guess.
So your app may ask your driver for shared mem (at least the thread
context is correct then).

There are also other methods for sharing mem between apps.

Give us some more background on why you do what you can't do.

Norbert.

"In matters of principle, stand like a rock. In matters of taste, swim
with the current."

---- snip ----

It is in the new processes context, your problem is that the context is
being built, at the time you are called there is no user-space so of course
you cannot mat to it.

Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting

----- Original Message -----
From:
To: “Windows System Software Developers Interest List”
Sent: Tuesday, August 05, 2003 10:16 AM
Subject: [ntdev] Re: Can I Allocate a Memory In Driver that can be visisted
by every app??

> In the psCreateNotifyRoutinue, i found that is not in the new created
> process’s context.
>
> so i can’t map the kernel address to the user address.
>
> but the msdn is said
>
> The driver’s process-creation notify routine runs at IRQL PASSIVE_LEVEL,
> either in the context of the initial thread within a newly created process
> or in the context of a system thread.
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@acm.org
> To unsubscribe send a blank email to xxxxx@lists.osr.com

Look at the MapMem sample that is in the NT 4.0 DDK. This shows you how
to do it.

Also just to let you know in case this is a Video Driver or Mirror Driver
you can use a VideoPortMapMem() function.

So look at the MapMem sample.