PpCheckInDriverDatabase

NTSTATUS __stdcall PpCheckInDriverDatabase(
        _UNICODE_STRING *KeyName,
        PVOID KeyHandle,
        PVOID ImageBase,
        UINT64 ImageSize,
        UINT64 IsFilter,
        _GUID *EntryGuid){
  unsigned int v6; 
  INT64 v8; 
  INT64 v9; 
  int v10; 
  INT64 v11; 
  _ETHREAD *CurrentThread; 
  _GUID *v13; 
  int v14; 
  _UNICODE_STRING FullPath; 
  _UNICODE_STRING DestinationString; 

  FullPath = 0i64;
  v6 = ImageSize;
  if( InitIsWinPEMode || !PpBootDDBInitialized )
    return 0;
  v10 = IopBuildFullDriverPath(KeyName, KeyHandle, &FullPath);
  if( v10 < 0 )
  {
    if( (PiLoggedErrorEventsMask & 8) == 0 )
    {
      PiLoggedErrorEventsMask |= 8u;
      DestinationString = 0i64;
      RtlInitUnicodeString(&DestinationString, L"BUILD DRIVER PATH FAILED");
      PnpLogEvent((const VOID **)&DestinationString, 0i64, -1073740947, 0i64, 0);
    }
  }
  else
  {
    CurrentThread = (_ETHREAD *)KeGetCurrentThread();
    --CurrentThread->Tcb.KernelApcDisable;
    ExAcquireResourceExclusiveLite((UINT64)&PnpReplaceEvent + 5792, 1, v11);
    v10 = PiLookupInDDBCache(&FullPath, ImageBase, v13);
    if( v10 == -1073741823 )
    {
      PiLookupInDDB(&FullPath, ImageBase, v6, EntryGuid);
      v10 = v14;
    }
    if( v10 == -1073740948 && !(_DWORD)IsFilter )
      v10 = -1073740949;
    ExReleaseResourceLite((PERESOURCE)((char *)&PnpReplaceEvent + 5792));
    KeLeaveCriticalRegionThread(KeGetCurrentThread());
    ExFreePoolWithTag(FullPath.Buffer, 0);
  }
  if( (unsigned int)(v10 + 1073740949) > 1 )
    return 0;
  if( (byte_140C130BA & 2) != 0 )
    McTemplateK0j_EtwWriteTransfer(v9, v8, v11, (INT64)EntryGuid);
  return v10;
}

Referenced by:

PnpPrepareDriverLoading