RtlGenerate8dot3Name

NTSTATUS __stdcall RtlGenerate8dot3Name(
        const _UNICODE_STRING *Name,
        UINT8 AllowExtendedCharacters,
        _GENERATE_NAME_CONTEXT *Context,
        _UNICODE_STRING *Name8dot3){
  char v7; 
  unsigned int v8; 
  UINT8 v9; 
  unsigned int v10; 
  WCHAR NextWchar; 
  WCHAR v12; 
  __int64 v13; 
  __int64 NameLength; 
  unsigned int v15; 
  WCHAR v16; 
  __int64 v17; 
  __int64 ExtensionLength; 
  ULONG v19; 
  unsigned int v20; 
  char v21; 
  __int64 v22; 
  char v23; 
  __int16 v24; 
  int v25; 
  __int64 v26; 
  __int16 *v27; 
  unsigned __int16 v28; 
  unsigned __int16 v29; 
  ULONG v30; 
  USHORT v32; 
  int v33; 
  USHORT v34; 
  __int64 v35; 
  WCHAR *v36; 
  __int16 v37; 
  unsigned __int16 v38; 
  USHORT v39; 
  USHORT v40; 
  unsigned int i; 
  __int16 v42; 
  __int64 v43; 
  WCHAR v44; 
  int v45; 
  int v46; 
  unsigned int v47; 
  unsigned int v48; 
  unsigned int v49; 
  __int64 v50; 
  int v51; 
  UINT64 CurrentIndex; 
  _UNICODE_STRING *v53; 
  __int16 v54[8]; 

  v53 = Name8dot3;
  if( !AllowExtendedCharacters || (v7 = 1, !(_BYTE)NlsMbOemCodePageTag) )
    v7 = 0;
  if( !Context->NameLength )
  {
    v8 = -1;
    LODWORD(CurrentIndex) = 0;
    if( !Name->Length || (v9 = 1, *Name->Buffer != 46) )
      v9 = 0;
    v10 = 0;
    while( 1 )
    {
      NextWchar = GetNextWchar(Name, &CurrentIndex, v9, AllowExtendedCharacters);
      if( !NextWchar )
        break;
      v9 = 0;
      if( NextWchar == 46 )
        v8 = CurrentIndex;
    }
    if( v8 == Name->Length >> 1 )
      v8 = -1;
    HIDWORD(CurrentIndex) = v8;
    LODWORD(CurrentIndex) = 0;
    for( Context->NameLength = 0; ; ++Context->NameLength )
    {
      v12 = GetNextWchar(Name, &CurrentIndex, 1u, AllowExtendedCharacters);
      v13 = v12;
      if( !v12 )
        break;
      if( (unsigned int)CurrentIndex >= v8 )
        break;
      NameLength = Context->NameLength;
      if( (unsigned __int8)NameLength >= 6u )
        break;
      if( v7 )
      {
        if( v12 <= 0x7Fu || (v45 = 2, !*(_BYTE *)(NlsUnicodeToMbOemData + 2 * v13 + 1)) )
          v45 = 1;
        v10 += v45;
        if( v10 > 6 )
          break;
      }
      Context->NameBuffer[NameLength] = v13;
    }
    if( !v7 )
      v10 = Context->NameLength;
    if( v10 <= 2 )
    {
      v39 = RtlComputeLfnChecksum((_UNICODE_STRING *)Name);
      Context->Checksum = v39;
      v40 = v39;
      for( i = 0; i < 4; ++i )
      {
        v42 = 48;
        if( (v40 & 0xFu) > 9 )
          v42 = 55;
        v43 = i + Context->NameLength;
        v44 = (v40 & 0xF) + v42;
        v40 >>= 4;
        Context->NameBuffer[v43] = v44;
      }
      Context->NameLength += 4;
      Context->ChecksumInserted = 1;
    }
    if( v8 == -1 )
    {
      Context->ExtensionLength = 0;
    }
    else
    {
      Context->ExtensionBuffer[0] = 46;
      v15 = 1;
      for( Context->ExtensionLength = 1; ; ++Context->ExtensionLength )
      {
        v16 = GetNextWchar(Name, (UINT64 *)((char *)&CurrentIndex + 4), 1u, AllowExtendedCharacters);
        v17 = v16;
        if( !v16 )
          break;
        ExtensionLength = Context->ExtensionLength;
        if( (unsigned int)ExtensionLength >= 4 )
          goto LABEL_48;
        if( v7 )
        {
          if( v16 <= 0x7Fu || (v46 = 2, !*(_BYTE *)(NlsUnicodeToMbOemData + 2 * v17 + 1)) )
            v46 = 1;
          v15 += v46;
          if( v15 > 4 )
          {
LABEL_48:
            if( FsRtlSafeExtensions )
              Context->ExtensionBuffer[(unsigned int)(ExtensionLength - 1)] = 126;
            break;
          }
        }
        Context->ExtensionBuffer[ExtensionLength] = v17;
      }
    }
  }
  v19 = Context->LastIndexValue + 1;
  Context->LastIndexValue = v19;
  if( v19 > 4 && !Context->ChecksumInserted )
  {
    v32 = RtlComputeLfnChecksum((_UNICODE_STRING *)Name);
    Context->Checksum = v32;
    v34 = v32;
    if( 2 - v33 < (unsigned int)(6 - v33) )
    {
      v35 = 4i64;
      v36 = &Context->NameBuffer[2 - v33];
      do
      {
        v37 = 48;
        v38 = v34 & 0xF;
        if( v38 > 9u )
          v37 = 55;
        v34 >>= 4;
        *v36++ = v38 + v37;
        --v35;
      }
      while( v35 );
    }
    Context->LastIndexValue = 1;
    Context->NameLength = 6 - v33;
    v19 = 1;
    Context->ChecksumInserted = 1;
  }
  v20 = 1;
  v21 = 1;
  do
  {
    if( !v19 )
      break;
    v22 = 8 - v20++;
    v23 = 0;
    v24 = v19 % 0xA + 48;
    v19 /= 0xAu;
    v54[v22] = v24;
    if( v24 == 57 )
      v23 = v21;
    v21 = v23;
  }
  while( v20 <= 7 );
  v25 = Context->NameLength;
  v26 = (__int64)v53;
  v27 = &v54[8 - v20];
  *v27 = 126;
  if( (unsigned __int8)(v25 - 1) > 0xBu )
  {
    v28 = 0;
  }
  else
  {
    memmove(*(VOID **)(v26 + 8), Context->NameBuffer, 2 * v25);
    v28 = 2 * Context->NameLength;
  }
  *(_WORD *)v26 = v28;
  memmove((VOID *)(*(_QWORD *)(v26 + 8) + 2 * ((unsigned __int64)v28 >> 1)), v27, 2 * v20);
  v29 = *(_WORD *)v26 + 2 * v20;
  *(_WORD *)v26 = v29;
  v30 = Context->ExtensionLength;
  if( v30 )
  {
    memmove((VOID *)(*(_QWORD *)(v26 + 8) + 2 * ((unsigned __int64)v29 >> 1)), Context->ExtensionBuffer, 2 * v30);
    *(_WORD *)v26 += 2 * LOWORD(Context->ExtensionLength);
  }
  if( !v21 )
    return 0;
  v47 = Context->NameLength;
  if( v7 )
  {
    v48 = 0;
    v49 = 0;
    if( (_BYTE)v47 )
    {
      do
      {
        v50 = Context->NameBuffer[v48];
        if( (unsigned int)v50 <= 0x7F || (v51 = 2, !*(_BYTE *)(NlsUnicodeToMbOemData + 2 * v50 + 1)) )
          v51 = 1;
        v49 += v51;
        if( v49 > 7 - v20 )
          break;
        ++v48;
      }
      while( v48 < v47 );
    }
  }
  else
  {
    LOBYTE(v48) = v47 - 1;
  }
  Context->NameLength = v48;
  if( (_BYTE)v48 )
    return 0;
  else
    return -1073740761;
}

Referenced by:

No references.