SmKmStoreFileGetExtents

__int64 __fastcall SmKmStoreFileGetExtents(
        HANDLE FileHandle,
        __int64 a2,
        _QWORD *a3,
        unsigned int a4,
        int a5,
        int a6,
        int a7,
        __int64 a8,
        __int64 a9,
        __int64 a10){
  struct _PRIVILEGE_SET *v11; 
  unsigned __int64 v14; 
  unsigned int v15; 
  UINT8 v16; 
  __int64 v17; 
  __int64 *v18; 
  NTSTATUS Status; 
  int v20; 
  __int64 v21; 
  unsigned int v22; 
  __int64 v23; 
  __int64 v24; 
  __int64 v25; 
  __int64 v26; 
  unsigned __int64 v27; 
  unsigned __int64 v28; 
  int v29; 
  __int64 v30; 
  UINT8 v32; 
  PVOID P; 
  UINT64 EntryCountMax; 
  PVOID Array; 
  __int64 v36; 
  _QWORD *v37; 
  _DWORD *v38; 
  _QWORD *v39; 
  _DWORD *v40; 
  struct _IO_STATUS_BLOCK IoStatusBlock; 
  __int64 v42; 
  __int128 v43; 
  __int64 v44; 
  P = 0i64;
  v38 = (_DWORD *)a8;
  v11 = 0i64;
  v39 = (_QWORD *)a9;
  v14 = a4;
  v15 = 0x10000;
  v40 = (_DWORD *)a10;
  HIDWORD(EntryCountMax) = a4;
  v37 = a3;
  IoStatusBlock = 0i64;
  Array = 0i64;
  v16 = IoSetThreadHardErrorMode(0);
  v32 = v16;
  if( a7 )
  {
    v17 = *a3;
    v18 = &v42;
    v44 = 0i64;
    v43 = 0i64;
    v42 = v17;
    P = &v42;
  }
  else
  {
    Status = ZwFsControlFile(FileHandle, 0i64, 0i64, 0i64, &IoStatusBlock, 0x9003Bu, a3, 8u, &P, 8u);
    if( Status == 259 )
    {
      KeWaitForSingleObject((PVOID)(a2 + 152), Executive, 0, 0, 0i64);
      Status = IoStatusBlock.Status;
    }
    v18 = (__int64 *)P;
    if( Status < 0 )
      goto LABEL_29;
  }
  LODWORD(EntryCountMax) = 0;
  v20 = 0;
  v21 = *v18;
  v22 = 0;
  v23 = 0i64;
  if( *v18 )
  {
    while( 1 )
    {
      v24 = v18[1];
      v23 += v21;
      if( v24 < 0 )
        break;
      if( v15 )
      {
        if( v21 >= v15 )
          v25 = v15;
        else
          v25 = *(unsigned int *)v18;
        v24 += v25;
        v15 -= v25;
        v21 -= v25;
        v18[1] = v24;
        *v18 = v21;
      }
      if( v21 >= (__int64)v14 )
      {
        v26 = (unsigned int)a5 - ((unsigned int)(a5 - 1) & (v24 + (unsigned int)a5 - 1i64));
        v36 = v26 + v24 - 1;
        v27 = (v21 + 1 - v26) % v14;
        v28 = (v21 + 1 - v26) / v14;
        if( (_DWORD)v28 )
        {
          v29 = SmArrayGrow(v22, v27, &EntryCountMax, &Array);
          v11 = (struct _PRIVILEGE_SET *)Array;
          if( !v29 )
          {
            Status = -1073741670;
            goto LABEL_24;
          }
          v20 += v28;
          v30 = 2i64 * v22++;
          *((_QWORD *)Array + v30 + 1) = v36;
          *(&v11->PrivilegeCount + 2 * v30) = v28;
        }
      }
      v18 += 2;
      v21 = *v18;
      if( !*v18 )
      {
        v18 = (__int64 *)P;
        goto LABEL_21;
      }
      v14 = HIDWORD(EntryCountMax);
    }
    Status = -1073741453;
LABEL_24:
    v18 = (__int64 *)P;
    goto LABEL_25;
  }
LABEL_21:
  if( v23 < *v37 )
  {
    Status = -1073741453;
LABEL_25:
    v16 = v32;
    goto LABEL_29;
  }
  v16 = v32;
  if( v20 )
  {
    *v38 = v20;
    *v39 = v11;
    v11 = 0i64;
    *v40 = v22;
    Status = 0;
  }
  else
  {
    Status = -1073741672;
  }
LABEL_29:
  if( v18 && v18 != &v42 )
    ExFreePoolWithTag(v18, 0);
  if( v11 )
    CmSiFreeMemory(v11);
  IoSetThreadHardErrorMode(v16);
  return(unsigned int)Status;
}

Referenced by:

SmKmStoreFileCreate