NTSTATUS __stdcall PoCallDriver(PDEVICE_OBJECT DeviceObject, PIRP Irp)
{
KIRQL v3; // al MAPDST
_DEVOBJ_EXTENSION *v4; // ebx
_IO_STACK_LOCATION *v5; // esi
bool v6; // zf
ULONG v7; // ecx
UCHAR v9; // al
int v10; // eax
_LIST_ENTRY *v11; // ecx
LIST_ENTRY *v12; // eax MAPDST
_LIST_ENTRY *v13; // ecx
int v15; // eax
_LIST_ENTRY *v16; // ecx
PVOID CallersAddress; // [esp+Ch] [ebp-8h]
PVOID CallersCaller; // [esp+10h] [ebp-4h]
int retaddr; // [esp+18h] [ebp+4h]
if ( !DeviceObject )
RtlAssert("DeviceObject", "d:\\srvrtm\\base\\ntos\\po\\pocall.c", 0x65u, 0);
if ( !Irp )
RtlAssert("Irp", "d:\\srvrtm\\base\\ntos\\po\\pocall.c", 0x66u, 0);
if ( KeGetCurrentIrql() > DISPATCH_LEVEL )
RtlAssert("KeGetCurrentIrql()<=DISPATCH_LEVEL", "d:\\srvrtm\\base\\ntos\\po\\pocall.c", 0x67u, 0);
v3 = KfAcquireSpinLock(&PopIrpSerialLock);
v4 = DeviceObject->DeviceObjectExtension;
v5 = Irp->Tail.Overlay.CurrentStackLocation - 1;
v6 = v5->MajorFunction == IRP_MJ_POWER;
v5->DeviceObject = DeviceObject;
if ( !v6 )
RtlAssert("irpsp->MajorFunction == IRP_MJ_POWER", "d:\\srvrtm\\base\\ntos\\po\\pocall.c", 0x6Fu, 0);
RtlGetCallersAddress(&CallersAddress, &CallersCaller);
PoPowerTracePrint(1, CallersAddress, CallersCaller, DeviceObject, Irp, v5);
v7 = DeviceObject->Flags;
if ( (v7 & 0x8000) != 0 )
{
Irp->IoStatus.Status = 0;
Irp->IoStatus.Information = 0;
IofCompleteRequest(Irp, 0);
KfReleaseSpinLock(&PopIrpSerialLock, v3);
return 0;
}
v9 = v5->MinorFunction;
if ( v9 == IRP_MN_SET_POWER )
{
if ( v5->Parameters.Power.Type == DevicePowerState
&& v5->Parameters.Power.State.DeviceState == PowerDeviceD0
&& (v4->PowerFlags & 0xF0) != 16
&& v7 & DO_POWER_INRUSH )
{
if ( PopInrushIrpPointer == Irp )
{
if ( (v5->Parameters.Power.SystemContext & PowerSystemHibernate) != PowerSystemHibernate )
RtlAssert(
"(irpsp->Parameters.Power.SystemContext & POP_INRUSH_CONTEXT) == POP_INRUSH_CONTEXT",
"d:\\srvrtm\\base\\ntos\\po\\pocall.c",
0x9Fu,
0);
if ( ++PopInrushIrpReferenceCount > 256 )
{
PopInternalAddToDumpFile(DeviceObject, 0, 0, 0);
KeBugCheckEx(0xA0u, 0x400u, 1u, v5, DeviceObject);
}
}
else
{
if ( PopInrushIrpPointer || PopInrushPending )
{
v4->PowerFlags |= 0x800u;
v5->Parameters.Power.SystemContext = PowerSystemHibernate;
v13 = PopIrpSerialList.Blink;
v12 = &Irp->Tail.Overlay.ListEntry;
v12->Flink = &PopIrpSerialList;
v12->Blink = v13;
v13->Flink = &Irp->Tail.Overlay.ListEntry;
++PopIrpSerialListLength;
PopIrpSerialList.Blink = &Irp->Tail.Overlay.ListEntry;
if ( PopIrpSerialListLength > 0xA )
DbgPrint("WARNING: PopIrpSerialListLength > 10!!!\n");
if ( PopIrpSerialListLength > 0x64 )
{
DbgPrint("WARNING: PopIrpSerialListLength > **100**!!!\n");
PopInternalAddToDumpFile(DeviceObject, 0, 0, 0);
KeBugCheckEx(0xA0u, 0x401u, 2u, &PopIrpSerialList, DeviceObject);
}
PopInrushPending = 1;
goto LABEL_41;
}
PopInrushIrpPointer = Irp;
PopInrushIrpReferenceCount = 1;
v5->Parameters.Power.SystemContext = PowerSystemHibernate;
PopPerfHandleInrush(1);
}
}
}
else if ( v9 != IRP_MN_QUERY_POWER )
{
KfReleaseSpinLock(&PopIrpSerialLock, v3);
return IofCallDriverSpecifyReturn(DeviceObject, Irp, retaddr);
}
if ( v5->Parameters.Power.Type == SystemPowerState )
{
v10 = v4->PowerFlags;
if ( v10 & 0x100 )
{
v4->PowerFlags = v10 | 0x200;
v11 = PopIrpSerialList.Blink;
v12 = &Irp->Tail.Overlay.ListEntry;
v12->Flink = &PopIrpSerialList;
v12->Blink = v11;
v11->Flink = &Irp->Tail.Overlay.ListEntry;
++PopIrpSerialListLength;
PopIrpSerialList.Blink = &Irp->Tail.Overlay.ListEntry;
if ( PopIrpSerialListLength > 0xA )
DbgPrint("WARNING: PopIrpSerialListLength > 10!!!\n");
if ( PopIrpSerialListLength > 0x64 )
{
DbgPrint("WARNING: PopIrpSerialListLength > **100**!!!\n");
PopInternalAddToDumpFile(DeviceObject, 0, 0, 0);
KeBugCheckEx(0xA0u, 0x402u, 3u, &PopIrpSerialList, DeviceObject);
}
LABEL_41:
KfReleaseSpinLock(&PopIrpSerialLock, v3);
return 259;
}
v4->PowerFlags = v10 | 0x100;
}
if ( v5->Parameters.Power.Type == DevicePowerState )
{
v15 = v4->PowerFlags;
if ( v15 & 0xC00 )
{
v4->PowerFlags = v15 | 0x800;
v16 = PopIrpSerialList.Blink;
v12 = &Irp->Tail.Overlay.ListEntry;
v12->Flink = &PopIrpSerialList;
v12->Blink = v16;
v16->Flink = &Irp->Tail.Overlay.ListEntry;
++PopIrpSerialListLength;
PopIrpSerialList.Blink = (&Irp->Tail.CompletionKey + 6);
if ( PopIrpSerialListLength > 0xA )
DbgPrint("WARNING: PopIrpSerialListLength > 10!!!\n");
if ( PopIrpSerialListLength > 0x64 )
{
DbgPrint("WARNING: PopIrpSerialListLength > **100**!!!\n");
PopInternalAddToDumpFile(DeviceObject, 0, 0, 0);
KeBugCheckEx(0xA0u, 0x403u, 4u, &PopIrpSerialList, DeviceObject);
}
goto LABEL_41;
}
v4->PowerFlags = v15 | 0x400;
}
if ( !(v5->DeviceObject->DeviceObjectExtension->PowerFlags & 0x500) )
RtlAssert(
"irpsp->DeviceObject->DeviceObjectExtension->PowerFlags & (POPF_DEVICE_ACTIVE | POPF_SYSTEM_ACTIVE)",
"d:\\srvrtm\\base\\ntos\\po\\pocall.c",
0x13Eu,
0);
KfReleaseSpinLock(&PopIrpSerialLock, v3);
return PopPresentIrp(v5, Irp, retaddr);
}