FopReadCmapTable

NTSTATUS __fastcall FopReadCmapTable(_FILE_IMAGE *FileHandle, UINT64 a2, UINT64 **a3){
  int v4; 
  int BytesAtOffset; 
  unsigned __int16 v6; 
  UINT64 v7; 
  unsigned int v8; 
  unsigned int *Memory; 
  unsigned int v10; 
  unsigned int v11; 
  unsigned int v12; 
  unsigned int *v13; 
  __int64 Buffer; 
  int v17; 

  Buffer = 0i64;
  v17 = 0;
  v4 = a2;
  BytesAtOffset = FioFwReadBytesAtOffset(FileHandle, a2, 4ui64, &Buffer);
  if( BytesAtOffset >= 0 )
  {
    v6 = __ROR2__(WORD1(Buffer), 8);
    LOWORD(Buffer) = __ROR2__(Buffer, 8);
    WORD1(Buffer) = v6;
    if( (_WORD)Buffer )
    {
      return -1073741701;
    }
    else
    {
      v7 = 12i64;
      if( v6 )
      {
        v8 = 8 * v6 + 4;
        if( v8 < 0xC )
          return -1073741675;
        v7 = v8;
        BytesAtOffset = 0;
      }
      Memory = (unsigned int *)BgpFwAllocateMemory(v7);
      if( Memory )
      {
        v10 = v4 + 4;
        v11 = v6;
        v12 = 0;
        *Memory = Buffer;
        if( v6 )
        {
          v13 = Memory + 2;
          while( 1 )
          {
            BytesAtOffset = FioFwReadBytesAtOffset(FileHandle, v10, 8ui64, v13 - 1);
            if( BytesAtOffset >= 0 )
            {
              *((_WORD *)v13 - 2) = __ROR2__(*((_WORD *)v13 - 2), 8);
              *((_WORD *)v13 - 1) = __ROR2__(*((_WORD *)v13 - 1), 8);
              BytesAtOffset = 0;
              *v13 = _byteswap_ulong(*v13);
            }
            if( BytesAtOffset < 0 )
              break;
            ++v12;
            v13 += 2;
            v10 += 8;
            if( v12 >= v11 )
              goto LABEL_13;
          }
          BgpFwFreeMemory(Memory);
        }
        else
        {
LABEL_13:
          *a3 = (UINT64 *)Memory;
        }
      }
      else
      {
        return -1073741801;
      }
    }
  }
  return BytesAtOffset;
}

Referenced by:

FopReadMappingTable