I am new to driver development and would appreciate
any assistance with this particular issue with a
driver running on Xp Embedded. The driver will have
the infamous Blue Screen around 10 percent of the time
on all machines that have the driver installed. This
ONLY happens on reboot or powerup. I have never had
this happen during normal operation. Using WinDbg
during this scenario I get a Bugcheck
PAGE_FAULT_IN_NON_PAGED_AREA (50). After this, I used
the !analyze -v command in WinDbg to get more details.
It appears that my driver is the cause as seen in the
analyze data.
*** Fatal System Error: 0x00000050
(0xE195E068,0x00000001,0xFC7D4BFF,0x00000001)
kd> !analyze -v
PAGE_FAULT_IN_NONPAGED_AREA (50)
Invalid system memory was referenced. This cannot be
protected by try-except,
it must be protected by a Probe. Typically the
address is just plain bad or it
is pointing at freed memory.
Arguments:
Arg1: e195e068, memory referenced.
Arg2: 00000001, value 0 = read operation, 1 = write
operation.
Arg3: fc7d4bff, If non-zero, the instruction address
which referenced the bad memory
address.
Arg4: 00000001, (reserved)
WRITE_ADDRESS: e195e068 Paged pool
FAULTING_IP:
sciecp!EcpGetHardwareInfo+10f
[c:\sciecp_latest\autocon.c @ 599]
fc7d4bff 66c704500000 mov word ptr
[eax+edx*2],0x0
MM_INTERNAL_CODE: 1
DEFAULT_BUCKET_ID: DRIVER_FAULT
BUGCHECK_STR: 0x50
LAST_CONTROL_TRANSFER: from fc7d44c2 to fc7d4bff
TRAP_FRAME: fc91376c – (.trap fffffffffc91376c)
ErrCode = 00000002
eax=e195df90 ebx=00000000 ecx=e195df90 edx=0000006c
esi=81dff6e8 edi=e195cb68
eip=fc7d4bff esp=fc9137e0 ebp=fc9137fc iopl=0
nv up ei pl zr na po nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000
efl=00010246
sciecp!EcpGetHardwareInfo+0x10f:
fc7d4bff 66c704500000 mov word ptr
[eax+edx*2],0x0
Resetting default scope
STACK_TEXT:
fc9137fc fc7d44c2 81dd2000 fc91380c e195c978
sciecp!EcpGetHardwareInfo+0x10f
[c:\sciecp_latest\autocon.c @ 599]
fc913820 80b3368a 81dff6e8 81dd2000 00000000
sciecp!DriverEntry+0x22 [c:\sciecp_latest\init.c @ 92]
FOLLOWUP_IP:
sciecp!EcpGetHardwareInfo+10f
[c:\sciecp_latest\autocon.c @ 599]
fc7d4bff 66c704500000 mov word ptr
[eax+edx*2],0x0
SYMBOL_STACK_INDEX: 0
FOLLOWUP_NAME: MachineOwner
SYMBOL_NAME: sciecp!EcpGetHardwareInfo+10f
MODULE_NAME: sciecp
IMAGE_NAME: sciecp.sys
DEBUG_FLR_IMAGE_TIMESTAMP: 46fc163f
STACK_COMMAND: .trap fffffffffc91376c ; kb
FAILURE_BUCKET_ID:
0x50_W_sciecp!EcpGetHardwareInfo+10f
BUCKET_ID: 0x50_W_sciecp!EcpGetHardwareInfo+10f
The failure seems to be in my driver sciecp.sys
autocon.c file where I allocate around 110 bytes of
PagedPool for holding the Registry key for use in
detecting hardware. Most of the time this works.
Here is a snippet of code.
// Make a copy of the Registry path name
// and be sure it has a terminator at the
// end…
//
TempString.Length = 0;
TempString.MaximumLength =
RegistryPath->Length +
sizeof( UNICODE_NULL );
if(( TempString.Buffer = ExAllocatePool( PagedPool,
TempString.MaximumLength )) == NULL ){
*ConfigList = NULL;
ExFreePool( ConfigArray );
return STATUS_INSUFFICIENT_RESOURCES;
}
RtlCopyUnicodeString( &TempString, RegistryPath );
TempString.Buffer[TempString.Length] =
UNICODE_NULL; // THIS IS WHERE WE GET THE BUGCHECK
The Bugcheck is generated when adding the UNICODE_NULL
chars a the end of the Registry key string. Next I
ran the !pool command from WinDbg with these results
displayed.
kd> !pool e195e068
Pool page e195e068 region is Paged pool
e195e000 is not a valid small pool allocation,
checking large pool…
e195e000 is freed (or corrupt) pool
Bad allocation size @e195e000, too large
Then I ran !poolval with these results.
kd> !poolval e195e000
Pool page e195e000 region is Paged pool
Validating Pool headers for pool page: e195e000
Pool page [e195e000] is __inVALID.
Analyzing linked list…
Scanning for single bit errors…
None found
I have seen that this function in my handed down
driver code ExAllocatePool() seems to pass every time
even though I read that it is an obsolete function.
If the memory is freed, how did it pass the
ExAllocatePool() check before writing the UNICODE_NULL
chars to the Registry String? Or could this be a byte
alignment / page boundary issue? Any ideas? Thanks in
advance.
Robert
Need a vacation? Get great deals
to amazing places on Yahoo! Travel.
http://travel.yahoo.com/