PopProcessWakeSourceWork

NTSTATUS __stdcall PopProcessWakeSourceWork(
        POP_WAKE_SOURCE_WORK *WakeSourceWork,
        POP_WAKE_SOURCE **NewWakeSource,
        POP_WAKE_SOURCE **RemoveWakeSource){
  _DEVICE_OBJECT *v3; 
  POP_WAKE_SOURCE *v4; 
  _DEVICE_NODE *DeviceNode; 
  unsigned int Level; 
  _QWORD **v7; 
  _QWORD *v8; 
  _QWORD *v9; 
  NTSTATUS v10; 
  _DEVICE_NODE *i; 
  _DEVICE_NODE *v12; 
  _POP_WAKE_SOURCE *v13; 
  _POP_WAKE_SOURCE *v14; 
  VOID **PoolWithTag; 

  v3 = (_DEVICE_OBJECT *)*((_QWORD *)WakeSourceWork + 2);
  v4 = 0i64;
  if( v3 )
    DeviceNode = (_DEVICE_NODE *)v3->DeviceObjectExtension->DeviceNode;
  else
    DeviceNode = 0i64;
  Level = DeviceNode->Level;
  v7 = (_QWORD **)(*((_QWORD *)WakeSourceWork + 3) + 24i64);
  v8 = *v7;
  while( v8 != v7 )
  {
    v9 = v8;
    v8 = (_QWORD *)*v8;
    if( !*((_DWORD *)v9 + 4) )
    {
      if( *((_DWORD *)v9 + 18) <= Level )
      {
        if( *((_DWORD *)v9 + 18) < Level )
        {
          for( i = DeviceNode->Parent; ; i = v12->Parent )
          {
            v12 = 0i64;
            if( i != (_DEVICE_NODE *)*(&PnpReplaceEvent + 831) )
              v12 = i;
            if( !v12 )
              break;
            if( v12->InstancePath.Length == *((_WORD *)v9 + 12)
              && !wcsncmp(
                    v12->InstancePath.Buffer,
                    (const WCHAR *)v9[4],
                    (unsigned __int64)v12->InstancePath.Length >> 1) )
            {
              v4 = (POP_WAKE_SOURCE *)v9;
              goto LABEL_20;
            }
          }
        }
      }
      else if( PopWakeSourceIsParent(DeviceNode, (_UNICODE_STRING *)(v9 + 3)) )
      {
        v10 = -1073741823;
LABEL_24:
        v4 = 0i64;
        v14 = 0i64;
        goto LABEL_26;
      }
    }
  }
LABEL_20:
  v13 = PopNewWakeSource(0i64);
  v14 = v13;
  if( !v13 )
  {
    v10 = -1073741670;
    goto LABEL_24;
  }
  v13[18] = Level;
  PoolWithTag = ExAllocatePoolWithTag(1ui64, DeviceNode->InstancePath.Length, 544040269i64);
  *((_QWORD *)v14 + 4) = PoolWithTag;
  if( !PoolWithTag )
  {
    v10 = -1073741670;
    PopFreeWakeSource(v14);
    goto LABEL_24;
  }
  *((_WORD *)v14 + 13) = DeviceNode->InstancePath.Length;
  RtlCopyUnicodeString((PUNICODE_STRING)(v14 + 6), &DeviceNode->InstancePath);
  PopWakeSourceGetDeviceProperty((_UNICODE_STRING *)(v14 + 10), 9, v3);
  PopWakeSourceGetDeviceProperty((_UNICODE_STRING *)(v14 + 14), 0, v3);
  v10 = 0;
LABEL_26:
  *NewWakeSource = v14;
  *RemoveWakeSource = v4;
  return v10;
}

Referenced by:

PopUpdateWakeSourceWorker