PnpGetServiceStartType

INT64 __stdcall PnpGetServiceStartType(const WCHAR *ServiceName, PVOID ServiceKey, UINT64 *StartType){
  int v6; 
  __int64 v8; 
  __int64 v9; 
  int v10; 
  __int64 v11; 
  __int64 v12; 
  int v13; 
  HANDLE Handle; 
  int v15; 
  __int64 v16; 
  v15 = 0;
  Handle = 0i64;
  *(_DWORD *)StartType = 4;
  if( (ExpManufacturingInformation & 1) != 0 )
  {
    v8 = qword_140CF5110;
    if( qword_140CF5110 )
    {
      if( qword_140CF5110 == -1 )
        goto LABEL_2;
      v10 = 0;
    }
    else
    {
      if( PiPnpRtlCtx )
        v9 = *(_QWORD *)(PiPnpRtlCtx + 224);
      else
        v9 = 0i64;
      v10 = SysCtxRegOpenKey(
              v9,
              (char *)0x80000002i64,
              L"System\\CurrentControlSet\\Control\\ManufacturingMode\\Current\\Services\\",
              0,
              0x20019u,
              (void **)&qword_140CF5110);
      if( v10 == -1073741772 )
      {
        v8 = -1i64;
        qword_140CF5110 = -1i64;
      }
      else
      {
        v8 = qword_140CF5110;
      }
    }
    if( v10 >= 0 )
    {
      if( PiPnpRtlCtx )
        v11 = *(_QWORD *)(PiPnpRtlCtx + 224);
      else
        v11 = 0i64;
      if( (int)SysCtxRegOpenKey(v11, (char *)v8, ServiceName, 0, 0x20019u, &Handle) >= 0 )
      {
        LODWORD(v16) = 4;
        v6 = RegRtlQueryValue(Handle, L"Start", &v15, StartType, (__int64)&v16);
        if( v6 >= 0 && v15 == 4 )
          goto LABEL_5;
      }
      v12 = (__int64)qword_140CF5118;
      if( qword_140CF5118 )
      {
        if( qword_140CF5118 == (HANDLE)-1i64 )
          goto LABEL_2;
        v13 = 0;
      }
      else
      {
        if( PiPnpRtlCtx )
          v12 = *(_QWORD *)(PiPnpRtlCtx + 224);
        v13 = SysCtxRegOpenKey(v12, (char *)qword_140CF5110, L"*Driver", 0, 0x20019u, &qword_140CF5118);
        if( v13 == -1073741772 )
        {
          v12 = -1i64;
          qword_140CF5118 = (HANDLE)-1i64;
        }
        else
        {
          v12 = (__int64)qword_140CF5118;
        }
      }
      if( v13 >= 0 )
      {
        LODWORD(v16) = 4;
        v6 = RegRtlQueryValue((HANDLE)v12, L"Start", &v15, StartType, (__int64)&v16);
        if( v6 >= 0 && v15 == 4 )
          goto LABEL_5;
      }
    }
  }
LABEL_2:
  LODWORD(v16) = 4;
  v6 = RegRtlQueryValue(ServiceKey, L"Start", &v15, StartType, (__int64)&v16);
  if( v6 >= 0 && v15 != 4 )
  {
    v6 = -1073741772;
    *(_DWORD *)StartType = 4;
  }
LABEL_5:
  if( Handle )
    ZwClose(Handle);
  return(unsigned int)v6;
}

Referenced by:

PipCallDriverAddDeviceQueryRoutine