views:

57

answers:

1

Can this codes cause a problem?(PAGE_FAULT_IN_NONPAGED_AREA)

KEVENT waitEvent; //allocate on stack
LARGE_INTEGER timeout;

KeInitializeEvent(&waitEvent, NotificationEvent, FALSE);
KeResetEvent(&waitEvent);
timeout.QuadPart = -(100 * 10000); // 100 ms

while(pDataChannel->useCount)
{
    KeWaitForSingleObject(&waitEvent, Executive, KernelMode, FALSE, &timeout);
}

Can the waitEvent valiable be paged-out? Is the variable must allocated on a non-paged pool?

+1  A: 

Is pDataChannel valid? Or are you running at DISPATCH_LEVEL?

These can lead to the error you have.

Christopher
Thanks Christopher.pDataChannel was allocated at NonPagedPool and it wasn't null.And IRQL was PASSIVE_LEVEL at that moment.
Benjamin