WmipAddMofResource

__int64 __fastcall WmipAddMofResource(__int64 a1, const wchar_t *a2, char a3, const wchar_t *a4, char *a5){
  unsigned int inserted; 
  volatile signed __int64 *MRByNames; 
  INT64 v11; 
  char v12; 
  __int64 v13; 
  __int64 v14; 
  UINT64 v15; 
  UINT64 v16; 
  VOID *PoolWithTag; 
  WCHAR *v18; 
  __int64 v19; 
  volatile signed __int64 **v20; 
  inserted = 0;
  MRByNames = WmipFindMRByNames((__int64)a2, (__int64)a4);
  if( MRByNames )
  {
    v12 = 0;
  }
  else
  {
    v11 = WmipAllocEntry((INT64)&WmipMRChunkInfo);
    MRByNames = (volatile signed __int64 *)v11;
    if( !v11 )
      return(unsigned int)-1073741670;
    v12 = 1;
    if( a3 )
      *(_DWORD *)(v11 + 16) |= 1u;
    v13 = -1i64;
    v14 = -1i64;
    do
      ++v14;
    while( a2[v14] );
    v15 = 2 * v14 + 2;
    *((_QWORD *)MRByNames + 5) = ExAllocatePoolWithTag(PagedPool, v15, 0x70696D57ui64);
    do
      ++v13;
    while( a4[v13] );
    v16 = 2 * v13 + 2;
    PoolWithTag = ExAllocatePoolWithTag(PagedPool, v16, 0x70696D57ui64);
    v18 = (WCHAR *)*((_QWORD *)MRByNames + 5);
    *((_QWORD *)MRByNames + 6) = PoolWithTag;
    if( !v18 || !PoolWithTag )
    {
      inserted = -1073741670;
      goto LABEL_15;
    }
    RtlStringCbCopyW(v18, v15, (PWCHAR)a2);
    RtlStringCbCopyW(*((PWCHAR *)MRByNames + 6), v16, (PWCHAR)a4);
    KeWaitForSingleObject(&WmipSMMutex, Executive, 0, 0, 0i64);
    v19 = WmipMRHeadPtr;
    v20 = *(volatile signed __int64 ***)(WmipMRHeadPtr + 8);
    if( *v20 != (volatile signed __int64 *)WmipMRHeadPtr )
      __fastfail(3u);
    *((_QWORD *)MRByNames + 1) = v20;
    *MRByNames = v19;
    *v20 = MRByNames;
    *(_QWORD *)(v19 + 8) = MRByNames;
    KeReleaseMutex(&WmipSMMutex, 0);
  }
  *a5 = v12;
  if( a1 )
  {
    KeWaitForSingleObject(&WmipSMMutex, Executive, 0, 0, 0i64);
    inserted = WmipInsertMofResource(a1, (ULONG_PTR)MRByNames);
    KeReleaseMutex(&WmipSMMutex, 0);
LABEL_15:
    WmipUnreferenceEntry((__int64)&WmipMRChunkInfo, MRByNames);
  }
  return inserted;
}

Referenced by:

WmipAddDataSource
WmipInitializeDataStructs