PiDrvDbRegisterNode

NTSTATUS __stdcall PiDrvDbRegisterNode(WCHAR *Name, UINT64 Flags, INT64 a3, INT64 a4){
  unsigned int v4; 
  VOID **PoolWithTag; 
  PI_DRVDB_NODE **v7; 
  NTSTATUS Node; 
  UINT64 v9; 
  WCHAR *v10; 
  UINT8 v11; 
  int v12; 
  __int64 v14; 
  char *UnicodeSubstring; 
  unsigned __int16 i; 
  _UNICODE_STRING String2; 
  _UNICODE_STRING DestinationString; 
  _UNICODE_STRING v19; 

  v4 = Flags;
  String2 = 0i64;
  PoolWithTag = 0i64;
  DestinationString = 0i64;
  v19 = 0i64;
  RtlInitUnicodeString(&DestinationString, 0i64);
  Node = PiDrvDbCreateNode(Name, v4, v7);
  if( Node < 0 )
    goto LABEL_7;
  if( (MEMORY[0x40] & 1) != 0 )
  {
    v12 = v4 & 8;
  }
  else
  {
    v9 = MEMORY[0x20] + 32i64;
    PoolWithTag = ExAllocatePoolWithTag(1ui64, v9, 1650749520i64);
    if( !PoolWithTag )
    {
      Node = -1073741670;
      goto LABEL_7;
    }
    Node = RtlStringCchPrintfW((WCHAR *)PoolWithTag, v9 >> 1, (WCHAR *)L"%wZ\\%ws");
    if( Node < 0 )
      goto LABEL_7;
    v12 = v4 & 8;
    Node = DrvDbRegisterDatabase(v10, Name, v11, PoolWithTag);
    if( Node < 0 )
      goto LABEL_7;
  }
  if( v12 )
  {
    Node = PnpSetObjectProperty(
             *(&stru_140CF2E80 + 607),
             MEMORY[0x18],
             7u,
             MEMORY[0x48],
             0i64,
             (__int64)&DEVPKEY_DriverDatabase_FilePath,
             18,
             MEMORY[0x38],
             (unsigned int)MEMORY[0x30] + 2,
             0);
    if( Node >= 0 )
    {
      v14 = MEMORY[0x38];
      String2.Buffer = (wchar_t *)MEMORY[0x38];
      RtlInitUnicodeString(&v19, L"\\System32\\config\\");
      UnicodeSubstring = RtlFindUnicodeSubstring((unsigned __int16 *)0x30, &v19.Length, 1);
      if( UnicodeSubstring )
      {
        i = 2 * ((__int64)(unsigned int)((_DWORD)UnicodeSubstring - MEMORY[0x38]) >> 1);
      }
      else
      {
        String2.Length = MEMORY[0x30];
        for( i = MEMORY[0x30]; i > 2u; String2.Length = i )
        {
          if( *(_WORD *)(v14 + 2 * ((unsigned __int64)i >> 1) - 2) == 92 )
            break;
          i -= 2;
        }
        if( i <= 2u || *(_WORD *)(v14 + 2 * ((unsigned __int64)i >> 1) - 2) != 92 )
          goto LABEL_22;
        i -= 2;
      }
      String2.Length = i;
LABEL_22:
      String2.MaximumLength = i;
      if( PiDrvDbQuerySystemPathWin32(&String2, &DestinationString) >= 0 )
        Node = PnpSetObjectProperty(
                 *(&stru_140CF2E80 + 607),
                 MEMORY[0x18],
                 7u,
                 MEMORY[0x48],
                 0i64,
                 (__int64)&DEVPKEY_DriverDatabase_SystemPath,
                 18,
                 (__int64)DestinationString.Buffer,
                 (unsigned int)DestinationString.Length + 2,
                 0);
      else
        Node = 0;
    }
  }
LABEL_7:
  RtlFreeAnsiString(&DestinationString);
  if( PoolWithTag )
    ExFreePoolWithTag(PoolWithTag, 0);
  return Node;
}

Referenced by:

PiDrvDbInit
PiDrvDbRegisterNodeCallback