LdrpGetResourceFileName

NTSTATUS __stdcall LdrpGetResourceFileName(
        _KLDR_DATA_TABLE_ENTRY *KrnlTableEntry,
        WCHAR *LangName,
        _UNICODE_STRING *ResourceFileName){
  WCHAR *v3; 
  WCHAR *v4; 
  char v6; 
  __int64 Length; 
  unsigned int v9; 
  unsigned __int64 v10; 
  __int64 v11; 
  unsigned __int64 v12; 
  WCHAR *v13; 
  NTSTATUS result; 
  __int64 v15; 
  __int16 *v16; 
  _WORD v17[2]; 
  __int16 Source[264]; 
  _UNICODE_STRING *Destination; 

  v4 = v3;
  v6 = (char)LangName;
  if( !KrnlTableEntry || !Destination || !v3 )
    return -1073741811;
  Length = KrnlTableEntry->BaseDllName.Length;
  v9 = KrnlTableEntry->FullDllName.Length;
  v10 = v9 - Length;
  if( v10 >= 0x208 || (unsigned __int16)v9 <= (unsigned __int16)Length )
    return -1073020927;
  v11 = (unsigned int)v10;
  memmove(Source, KrnlTableEntry->FullDllName.Buffer, v10);
  v12 = v11 & 0xFFFFFFFFFFFFFFFEui64;
  if( v12 >= 0x208 )
    _report_rangecheckfailure();
  *(__int16 *)((char *)Source + v12) = 0;
  if( !v6 )
  {
    v13 = (WCHAR *)Source;
    goto LABEL_9;
  }
  v15 = -1i64;
  do
    ++v15;
  while( Source[v15] );
  v16 = &v17[(unsigned int)v15];
  if( v16 <= Source )
    return -1073741686;
  do
  {
    if( *v16 == 92 )
      break;
    --v16;
  }
  while( v16 > Source );
  if( v16 <= Source )
    return -1073741686;
  v16[1] = 0;
  result = RtlAppendUnicodeToString(Destination, (WCHAR *)Source);
  if( result >= 0 )
  {
    v13 = L"SystemResources\\";
LABEL_9:
    result = RtlAppendUnicodeToString(Destination, v13);
    if( result >= 0 )
    {
      if( !v6 )
      {
        RtlAppendUnicodeToString(Destination, v4);
        RtlAppendUnicodeToString(Destination, (WCHAR *)L"\\");
      }
      result = RtlAppendUnicodeToString(Destination, KrnlTableEntry->BaseDllName.Buffer);
      if( result >= 0 )
      {
        if( ResourceFileName )
          return RtlAppendUnicodeToString(Destination, &ResourceFileName->Length);
      }
    }
  }
  return result;
}

Referenced by:

LdrLoadAlternateResourceModuleEx