KsepStringConcatenate

NTSTATUS __stdcall KsepStringConcatenate(
        _UNICODE_STRING *ResultString,
        PWCHAR LeftString,
        PWCHAR RightString,
        UINT64 WithBackSlash){
  int v4; 
  __int64 v8; 
  __int64 v9; 
  unsigned __int64 v10; 
  __int64 v11; 
  __int64 v12; 
  unsigned __int64 v13; 
  wchar_t *Paged; 
  unsigned __int16 v15; 
  __int64 v17; 
  __int64 v18; 
  __int64 v19; 

  v4 = WithBackSlash;
  if( !ResultString )
  {
    v17 = ((unsigned __int8)_InterlockedExchangeAdd(&KsepHistoryErrorsIndex, 1u) + 1) & 0x3F;
    KsepHistoryErrors[2 * v17 + 1] = -1073740768;
    KsepHistoryErrors[2 * v17] = 197324;
    if( (KsepDebugFlag & 4) != 0 )
      RtlAssert("ResultString != NULL", "minkernel\\ntos\\kshim\\ksemisc.c", 716i64, 0i64);
  }
  if( !LeftString )
  {
    v18 = ((unsigned __int8)_InterlockedExchangeAdd(&KsepHistoryErrorsIndex, 1u) + 1) & 0x3F;
    KsepHistoryErrors[2 * v18 + 1] = -1073740768;
    KsepHistoryErrors[2 * v18] = 197325;
    if( (KsepDebugFlag & 4) != 0 )
      RtlAssert("LeftString != NULL", "minkernel\\ntos\\kshim\\ksemisc.c", 717i64, 0i64);
  }
  if( !RightString )
  {
    v19 = ((unsigned __int8)_InterlockedExchangeAdd(&KsepHistoryErrorsIndex, 1u) + 1) & 0x3F;
    KsepHistoryErrors[2 * v19 + 1] = -1073740768;
    KsepHistoryErrors[2 * v19] = 197326;
    if( (KsepDebugFlag & 4) != 0 )
      RtlAssert("RightString != NULL", "minkernel\\ntos\\kshim\\ksemisc.c", 718i64, 0i64);
  }
  v8 = -1i64;
  *ResultString = 0i64;
  v9 = -1i64;
  do
    ++v9;
  while( LeftString[v9] );
  v10 = 2 * v9;
  do
    ++v8;
  while( RightString[v8] );
  v11 = 2 * v8;
  v12 = -(__int64)(v4 != 0) & 2;
  v13 = v10 + v12 + v11;
  if( v13 + 1 > 0xFFFE )
    return -2147483643;
  Paged = (wchar_t *)KsepPoolAllocatePaged(v13 + 2);
  if( !Paged )
    return -1073741801;
  ResultString->Buffer = Paged;
  memmove(Paged, LeftString, v10);
  if( v4 )
    ResultString->Buffer[v10 >> 1] = 92;
  memmove(&ResultString->Buffer[(v12 + v10) >> 1], RightString, v11);
  v15 = v11 + v10 + v12;
  ResultString->Buffer[v13 >> 1] = 0;
  ResultString->Length = v15;
  ResultString->MaximumLength = v15 + 2;
  return 0;
}

Referenced by:

KsepLoadShimProvider
KsepRegistryOpenKey