PiDrvDbGetNodeSystemRoot

INT64 __fastcall PiDrvDbGetNodeSystemRoot(INT64 a1, _QWORD *a2){
  int ObjectProperty; 
  VOID *StringRoutine; 
  __int64 v6; 
  unsigned __int16 v7; 
  unsigned __int64 v8; 
  int v10; 
  ULONG v11; 
  ObjectProperty = 0;
  v10 = 0;
  v11 = 0;
  *a2 = 0i64;
  if( !*(_QWORD *)(a1 + 512) )
  {
    *(_WORD *)(a1 + 504) = 0;
    *(_WORD *)(a1 + 506) = 520;
    StringRoutine = ExpAllocateStringRoutine(0x208ui64);
    *(_QWORD *)(a1 + 512) = StringRoutine;
    if( !StringRoutine )
      return(unsigned int)-1073741670;
    ObjectProperty = PnpGetObjectProperty(
                       PiPnpRtlCtx,
                       *(_QWORD *)(a1 + 24),
                       7i64,
                       *(_QWORD *)(a1 + 72),
                       0i64,
                       (__int64)DEVPKEY_DriverDatabase_SystemRoot,
                       &v10,
                       (unsigned __int64)StringRoutine,
                       *(unsigned __int16 *)(a1 + 506),
                       &v11,
                       0);
    if( ObjectProperty < 0
      || v10 != 18
      || v11 <= 2
      || (v6 = *(_QWORD *)(a1 + 512), *(_WORD *)(v6 + 2 * ((unsigned __int64)v11 >> 1) - 2)) )
    {
      ObjectProperty = 0;
      **(_WORD **)(a1 + 512) = 0;
    }
    else
    {
      v7 = v11 - 2;
      *(_WORD *)(a1 + 504) = v11 - 2;
      if( v7 > 2u )
      {
        v8 = (unsigned __int64)v7 >> 1;
        if( *(_WORD *)(v6 + 2 * v8 - 2) == 92 )
        {
          *(_WORD *)(v6 + 2 * v8 - 2) = 0;
          *(_WORD *)(a1 + 504) -= 2;
        }
      }
    }
  }
  if( **(_WORD **)(a1 + 512) )
    *a2 = a1 + 504;
  else
    return(unsigned int)-1073741275;
  return(unsigned int)ObjectProperty;
}

Referenced by:

PiDrvDbQuerySystemPathWin32
PiDrvDbResolveKeyFilePaths
PiDrvDbResolveNodeFilePaths