KdPullRemoteFileEx

__int64 __fastcall KdPullRemoteFileEx(
        unsigned __int16 *a1,
        __int64 (__fastcall *a2)(__int64, unsigned __int16 *, unsigned __int64),
        __int64 (__fastcall *a3)(__int64, __int64, PVOID, _QWORD),
        void (__fastcall *a4)(__int64, _QWORD),
        __int64 a5){
  VOID *PoolWithTag; 
  int v10; 
  unsigned __int64 v11; 
  UINT64 v12; 
  VOID *v13; 
  UINT64 v14; 
  __int64 v15; 
  UINT64 Completed; 
  VOID *Handle; 
  UINT64 Length[2]; 
  Length[0] = 0i64;
  Handle = 0i64;
  if( !(_BYTE)KdDebuggerEnabled || (_BYTE)KdDebuggerNotPresent || KdPitchDebugger )
    return 3221226324i64;
  PoolWithTag = ExAllocatePoolWithTag(NonPagedPoolNx, 0x2000ui64, 0x6F49644Bui64);
  if( !PoolWithTag )
    return 3221225495i64;
  v10 = KdpCreateRemoteFile(&Handle, Length, (UNICODE_STRING *)a1);
  if( v10 >= 0
    && (memmove((UINT8 *)PoolWithTag, *((UINT8 **)a1 + 1), *a1),
        *((_WORD *)PoolWithTag + ((unsigned __int64)*a1 >> 1)) = 0,
        v11 = Length[0],
        DbgPrintEx(
          0,
          0,
          "KdPullRemoteFile(%p): About to overwrite %ls and preallocate to %I64x\n",
          KeGetCurrentThread(),
          (const wchar_t *)PoolWithTag,
          Length[0]),
        v10 = a2(a5, a1, v11),
        v10 >= 0)
    && (v12 = 0i64, v11) )
  {
    v13 = Handle;
    do
    {
      LODWORD(Completed) = 0;
      v14 = (unsigned int)v11;
      if( v11 > 0x2000 )
        v14 = 0x2000i64;
      v10 = KdpReadRemoteFile(v13, v12, PoolWithTag, v14, &Completed);
      if( v10 < 0 )
        break;
      v15 = (unsigned int)Completed;
      if( !(_DWORD)Completed )
        break;
      v10 = a3(a5, v12, PoolWithTag, (unsigned int)Completed);
      if( v10 < 0 )
        break;
      v12 += v15;
      v11 -= v15;
    }
    while( v11 );
  }
  else
  {
    v13 = Handle;
  }
  if( v13 )
    KdpCloseRemoteFile(v13);
  a4(a5, (unsigned int)v10);
  ExFreePoolWithTag(PoolWithTag, 0);
  return(unsigned int)v10;
}

Referenced by:

KdPullRemoteFile