I have wrote an ACPI Driver with will evluate ASL method and accept ASL?s notify from BIOS?the problem now is when I try to get the ACPI Driver Interface, then 0x0A BSOD occour when windows xp starting bar is running, I post some code to reference,please kindly helps!
NTSTATUS HelloWDMAddDevice(IN PDRIVER_OBJECT DriverObject,
IN PDEVICE_OBJECT PhysicalDeviceObject)
{
ACPI_INTERFACE_STANDARD2 AcpiInterface;
// PVOID AbcdDevice=NULL;
CM_ABCD_DEV AbcdDevice;
PAGED_CODE();
#if DBG
KdPrint((“Enter HelloWDMAddDevice\n”));
#endif
NTSTATUS status;
PDEVICE_OBJECT fdo;
UNICODE_STRING devName;
RtlInitUnicodeString(&devName,L"\Device\MyWDMDevice");
status = IoCreateDevice(
DriverObject,
sizeof(DEVICE_EXTENSION),
&(UNICODE_STRING)devName,
FILE_DEVICE_UNKNOWN,
0,
FALSE,
&fdo);
if( !NT_SUCCESS(status))
return status;
PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION)fdo->DeviceExtension;
pdx->fdo = fdo;
pdx->NextStackDevice = IoAttachDeviceToDeviceStack(fdo, PhysicalDeviceObject);
UNICODE_STRING symLinkName;
RtlInitUnicodeString(&symLinkName,L"\DosDevices\TEST0001");
pdx->ustrDeviceName = devName;
pdx->ustrSymLinkName = symLinkName;
status = IoCreateSymbolicLink(&(UNICODE_STRING)symLinkName,&(UNICODE_STRING)devName);
if( !NT_SUCCESS(status))
{
IoDeleteSymbolicLink(&pdx->ustrSymLinkName);
status = IoCreateSymbolicLink(&symLinkName,&devName);
if( !NT_SUCCESS(status))
{
return status;
}
}
fdo->Flags |= DO_BUFFERED_IO | DO_POWER_PAGABLE;
fdo->Flags &= ~DO_DEVICE_INITIALIZING;
GetAbcdData(fdo,0);
status = GetAcpiInterfaces(PhysicalDeviceObject,&AcpiInterface);
if (!NT_SUCCESS(status))
{
#if DBG
KdPrint((“GetAcpiInterfaces failed\n”));
KdPrint((“NTSTATUS=%x\n”,status));
#endif
return status;
}
//
// Register the notify handler for this device with ACPI
//
status = AcpiInterface.RegisterForDeviceNotifications (
PhysicalDeviceObject,
AbcdDeviceNotifyHandler,
NULL);
if (!NT_SUCCESS(status))
{
#if DBG
KdPrint((“RegisterForDeviceNotifications failed\n”));
KdPrint((“NTSTATUS=%x\n”,status));
#endif
return status;
}
return STATUS_SUCCESS;
}
NTSTATUS
GetAcpiInterfaces(
IN PDEVICE_OBJECT Pdo,
OUT PACPI_INTERFACE_STANDARD2 AcpiInterfaces
)
/*
Routine Description:
Call ACPI driver to get the direct-call interfaces. It does
this the first time it is called, no more.
Arguments:
None.
Return Value:
Status
*/
{
NTSTATUS Status = STATUS_SUCCESS;
PIRP Irp;
PIO_STACK_LOCATION IrpSp;
PDEVICE_OBJECT LowerPdo=NULL;
// PDEVICE_EXTENSION data1;
// data1 = (PDEVICE_EXTENSION) Pdo->DeviceExtension;
// Only need to do this once
if(!LowerPdo){
LowerPdo = IoGetAttachedDeviceReference (Pdo);
// Allocate an IRP for below
Irp = IoAllocateIrp(LowerPdo->StackSize, FALSE); // Get stack size from
// PDO
// .
// .
// .
IrpSp = IoGetNextIrpStackLocation(Irp);
//
// Use QUERY_INTERFACE to get the address of the direct-
// call ACPI interfaces.
//
IrpSp->MajorFunction = IRP_MJ_PNP;
IrpSp->MinorFunction = IRP_MN_QUERY_INTERFACE;
IrpSp->Parameters.QueryInterface.InterfaceType=(LPGUID)&GUID_ACPI_INTERFACE_STANDARD2;
IrpSp->Parameters.QueryInterface.Version = 1;
IrpSp->Parameters.QueryInterface.Size = sizeof (AcpiInterfaces);
//IrpSp->Parameters.QueryInterface.Interface = (PINTERFACE) &AcpiInterfaces;
IrpSp->Parameters.QueryInterface.Interface = (PINTERFACE) AcpiInterfaces;
IrpSp->Parameters.QueryInterface.InterfaceSpecificData = NULL;
IoSetCompletionRoutine(Irp,AbcdDriverSynchronousRequest,NULL,TRUE, TRUE, TRUE);
Status = IoCallDriver (LowerPdo, Irp); ???BSOD at here???
//IoFreeIrp (Irp);
}
return Status;
}
NTSTATUS
AbcdDriverSynchronousRequest (
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
IN PVOID Context
)
{
// PDEVICE_EXTENSION data;
// data = (PDEVICE_EXTENSION) Context;
Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information =0; // no bytes xfered
IoCompleteRequest( Irp, IO_NO_INCREMENT );
// IoReleaseRemoveLock (&data->RemoveLock, Irp);
IoFreeIrp (Irp);
return STATUS_SUCCESS;
}