NTSTATUS
SendDownStreamIrp(
IN PDEVICE_OBJECT Pdo,
IN ULONG Ioctl,
IN PVOID InputBuffer,
IN ULONG InputSize,
IN PVOID OutputBuffer,
IN ULONG OutputSize
)
{
IO_STATUS_BLOCK ioBlock;
KEVENT myIoctlEvent;
NTSTATUS status;
PIRP irp;
// Initialize an event to wait on
KeInitializeEvent(&myIoctlEvent, SynchronizationEvent, FALSE);
// Build the request
irp = IoBuildDeviceIoControlRequest(
Ioctl,
Pdo,
InputBuffer,
InputSize,
OutputBuffer,
OutputSize,
FALSE,
&myIoctlEvent,
&ioBlock);
if (!irp) {
return STATUS_INSUFFICIENT_RESOURCES;
}
// Pass request to Pdo, always wait for completion routine
status = IoCallDriver(Pdo, irp);
if (status == STATUS_PENDING) {
// Wait for the IRP to be completed, then grab the real status code
KeWaitForSingleObject(
&myIoctlEvent,
Executive,
KernelMode,
FALSE,
NULL);
status = ioBlock.Status;
}
return status;
}
Драйвер ACPI
Вот исходник отправки IRP:
Код:
А вот где я вызываю SendDownStreamIrp:
Код:
PACPI_METHOD_ARGUMENT argument;
ACPI_EVAL_INPUT_BUFFER InputBuffer;
ACPI_EVAL_OUTPUT_BUFFER OutputBuffer;
RtlZeroMemory( &InputBuffer, sizeof(ACPI_EVAL_INPUT_BUFFER) );
RtlZeroMemory( &OutputBuffer, sizeof(ACPI_EVAL_OUTPUT_BUFFER) );
InputBuffer.MethodNameAsUlong = ACPI_METHOD__TMP;
InputBuffer.Signature = ACPI_EVAL_INPUT_BUFFER_SIGNATURE;
status = SendDownStreamIrp(
dx->pLowerDevice,
IOCTL_ACPI_EVAL_METHOD,
&InputBuffer,
sizeof(ACPI_EVAL_INPUT_BUFFER),
&OutputBuffer,
sizeof(ACPI_EVAL_OUTPUT_BUFFER)
);
//
// if not successful, the control method probably does not
// exists or APM mode is being used
//
if( NT_SUCCESS( status))
{
// Sanity check the data
if ((OutputBuffer.Signature != _EVAL_OUTPUT_BUFFER_SIGNATURE) || (OutputBuffer.Count == 0)) {
status = STATUS_ACPI_INVALID_DATA;
}
else
{
// Grab the argument
argument = OutputBuffer.Argument;
//
// make sure we received the correct data type back
//
........
}
}
ACPI_EVAL_INPUT_BUFFER InputBuffer;
ACPI_EVAL_OUTPUT_BUFFER OutputBuffer;
RtlZeroMemory( &InputBuffer, sizeof(ACPI_EVAL_INPUT_BUFFER) );
RtlZeroMemory( &OutputBuffer, sizeof(ACPI_EVAL_OUTPUT_BUFFER) );
InputBuffer.MethodNameAsUlong = ACPI_METHOD__TMP;
InputBuffer.Signature = ACPI_EVAL_INPUT_BUFFER_SIGNATURE;
status = SendDownStreamIrp(
dx->pLowerDevice,
IOCTL_ACPI_EVAL_METHOD,
&InputBuffer,
sizeof(ACPI_EVAL_INPUT_BUFFER),
&OutputBuffer,
sizeof(ACPI_EVAL_OUTPUT_BUFFER)
);
//
// if not successful, the control method probably does not
// exists or APM mode is being used
//
if( NT_SUCCESS( status))
{
// Sanity check the data
if ((OutputBuffer.Signature != _EVAL_OUTPUT_BUFFER_SIGNATURE) || (OutputBuffer.Count == 0)) {
status = STATUS_ACPI_INVALID_DATA;
}
else
{
// Grab the argument
argument = OutputBuffer.Argument;
//
// make sure we received the correct data type back
//
........
}
}
Подскажите пожалуйста кто-нить какому устройству нужно отправлять IRP.