Page fault on a PCM_PARTIAL_RESOURCE_LIST pointer

Hi,

I have reused Walter Oney’s StartDevice routine implementation for my driver.
When I debugged this routine with SoftIce, it tells me a “page fault” on an
address assignation to a PCM_PARTIAL_RESOURCE_LIST pointer (see the code
please). When I looked into the values stored in that structure, i have
noticed that some are undefined. Is it because i didn’t initialize properly my
IO_STACK_LOCATION structure?

Thanks for helping me!

Chi-Truc =)

here’s my code so you can have an idea of what is wrong:

// This is the handler for IRP_MN_START_DEVICE:

NTSTATUS StartDeviceHandler( IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp )
{
PIO_STACK_LOCATION stack;
PCM_PARTIAL_RESOURCE_LIST raw, translated;
NTSTATUS status;
ULONG_PTR info;

Irp->IoStatus.Status = STATUS_SUCCESS;



stack = IoGetCurrentIrpStackLocation(Irp);

raw = &(stack->Parameters.StartDevice.AllocatedResources->List[0].
PartialResourceList);

translated = &(stack->Parameters.StartDevice.AllocatedResourcesTranslated->
List[0].PartialResourceList);

status = StartDevice(DeviceObject, raw, translated);


}

NTSTATUS StartDevice( PDEVICE_OBJECT DeviceObject,
PCM_PARTIAL_RESOURCE_LIST raw,
PCM_PARTIAL_RESOURCE_LIST translated)
{
PCM_PARTIAL_RESOURCE_DESCRIPTOR resource = NULL;
PDEVICE_EXTENSION pdx;
ULONG nres;
NTSTATUS status;

// local resources variables…
// Local Variables …

pdx = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;

// PAGE FAULT ON THE LINE ABOVE OR BELOW (It should be one of these two)
resource = translated->PartialDescriptors; // THIS line was highligthed
nres = translated->Count;



return STATUS_SUCCESS;
}

Chi Truc Dinh wrote:

I have reused Walter Oney’s StartDevice routine implementation for my driver.
When I debugged this routine with SoftIce, it tells me a “page fault” on an
address assignation to a PCM_PARTIAL_RESOURCE_LIST pointer (see the code
please). When I looked into the values stored in that structure, i have
noticed that some are undefined. Is it because i didn’t initialize properly my
IO_STACK_LOCATION structure?

It may be because you weren’t passed any resources, and you aren’t
checking for that. Walter’s implementation did.

NTSTATUS StartDeviceHandler( IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp )
{
PIO_STACK_LOCATION stack;
PCM_PARTIAL_RESOURCE_LIST raw, translated;
NTSTATUS status;
ULONG_PTR info;

Irp->IoStatus.Status = STATUS_SUCCESS;



stack = IoGetCurrentIrpStackLocation(Irp);

raw = NULL;
if( stack->Parameters.StartDevice.AllocatedResources )

raw = &(stack->Parameters.StartDevice.AllocatedResources->List[0].
PartialResourceList);

translated = NULL;
if( stack->Parameters.StartDevice.AllocatedResourcesTranslated )

translated = &(stack->Parameters.StartDevice.AllocatedResourcesTranslated->
List[0].PartialResourceList);

status = StartDevice(DeviceObject, raw, translated);


}

NTSTATUS StartDevice( PDEVICE_OBJECT DeviceObject,
PCM_PARTIAL_RESOURCE_LIST raw,
PCM_PARTIAL_RESOURCE_LIST translated)
{
PCM_PARTIAL_RESOURCE_DESCRIPTOR resource = NULL;
PDEVICE_EXTENSION pdx;
ULONG nres;
NTSTATUS status;

// local resources variables…
// Local Variables …

pdx = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;

// PAGE FAULT ON THE LINE ABOVE OR BELOW (It should be one of these two)

if( translated ) {

resource = translated->PartialDescriptors; // THIS line was highligthed
nres = translated->Count;

}




return STATUS_SUCCESS;
}



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