KsepStringSplitMultiString

VOID __fastcall KsepStringSplitMultiString(
        WCHAR *Buffer,
        UINT64 BufferLength,
        INT64 a3,
        INT64 a4,
        _UNICODE_STRING **Strings,
        UINT64 *StringsCount){
  UINT64 v7; 
  __int64 v8; 
  _UNICODE_STRING *Paged; 
  unsigned int v12; 
  unsigned int v13; 
  __int64 v14; 
  unsigned int v15; 
  __int64 v16; 
  unsigned int v17; 
  int v18; 
  unsigned int v19; 
  unsigned __int64 v20; 
  __int64 v21; 
  __int64 v22; 
  _UNICODE_STRING *v23; 

  v7 = BufferLength >> 1;
  v8 = 0i64;
  Paged = 0i64;
  if( Buffer && (BufferLength & 1) == 0 && a3 && a4 )
  {
    if( v7 >= 3 && !Buffer[v7 - 1] && !Buffer[v7 - 2] )
    {
      v12 = 0;
      v13 = 0;
      v14 = 0i64;
      do
      {
        v15 = v12 + 1;
        if( Buffer[v14] )
          v15 = v12;
        v14 = ++v13;
        v12 = v15;
      }
      while( v13 < v7 );
      if( v15 < 2 )
      {
        v16 = ((unsigned __int8)_InterlockedExchangeAdd(&KsepHistoryErrorsIndex, 1u) + 1) & 0x3F;
        KsepHistoryErrors[2 * v16 + 1] = -1073740768;
        KsepHistoryErrors[2 * v16] = 197557;
        if( (KsepDebugFlag & 4) != 0 )
          RtlAssert("NullCount >= 2", "minkernel\\ntos\\kshim\\ksemisc.c", 949i64, 0i64);
      }
      v8 = v12 - 1;
      Paged = (_UNICODE_STRING *)KsepPoolAllocatePaged(16i64 * (unsigned int)v8);
      if( Paged )
      {
        v17 = 0;
        v18 = 0;
        v19 = 0;
        v20 = v7 - 1;
        if( v20 )
        {
          v21 = 0i64;
          do
          {
            if( !Buffer[v21] )
            {
              if( KsepStringDuplicate(&Paged[v18], &Buffer[v17]) < 0 )
                goto LABEL_28;
              v17 = v19 + 1;
              ++v18;
            }
            v21 = ++v19;
          }
          while( v19 < v20 );
        }
        if( v18 != (_DWORD)v8 )
        {
          v22 = ((unsigned __int8)_InterlockedExchangeAdd(&KsepHistoryErrorsIndex, 1u) + 1) & 0x3F;
          KsepHistoryErrors[2 * v22 + 1] = -1073740768;
          KsepHistoryErrors[2 * v22] = 197597;
          if( (KsepDebugFlag & 4) != 0 )
            RtlAssert("Count == StringsVectorSize", "minkernel\\ntos\\kshim\\ksemisc.c", 989i64, 0i64);
        }
        *(_QWORD *)a3 = Paged;
        *(_DWORD *)a4 = v8;
      }
    }
  }
  else
  {
LABEL_28:
    if( Paged )
    {
      if( (_DWORD)v8 )
      {
        v23 = Paged;
        do
        {
          KsepStringFree(v23++);
          --v8;
        }
        while( v8 );
      }
      KsepPoolFreePaged(Paged);
    }
  }
}

Referenced by:

KsepEngineGetShimsFromRegistry