CmpDoFileWrite
__int64 __fastcall CmpDoFileWrite(_HANDLE a1, __int64 a2, __int64 a3, _LOOKASIDE_LIST_EX *a4, char a5){
int v6;
unsigned int v7;
char *TransientPoolWithTag;
char *v9;
unsigned int v10;
_DWORD *v11;
char *Buffer;
unsigned int v13;
char *v14;
NTSTATUS Event;
ULONG Length;
unsigned int v17;
PADAPTER_OBJECT *v18;
unsigned int v20;
NTSTATUS *v21;
unsigned int v22;
IO_PRIORITY_HINT IoPriority;
unsigned int Priority;
_LARGE_INTEGER ByteOffset;
char *v26;
char v28;
unsigned int v29;
UINT8 RespectIoPriority;
v29 = (unsigned int)a4;
ByteOffset.QuadPart = 0i64;
v28 = 0;
Priority = 0;
IoPriority = IoPriorityVeryLow;
v6 = (int)a4;
v7 = 0;
TransientPoolWithTag = (char *)CmpAllocateTransientPoolWithTag(0x200ui64, 0x1400ui64);
v9 = TransientPoolWithTag;
if( TransientPoolWithTag )
{
memset(TransientPoolWithTag, 0i64, 0x1400u);
if( (a5 & 1) != 0 )
{
IoPriority = CmpSetIoPriorityThread((ETHREAD *)KeGetCurrentThread(), IoPriorityVeryLow);
Priority = CmpSetPriorityThread(KeGetCurrentThread(), 4i64);
v28 = 1;
}
RespectIoPriority = CmpSetRespectIoPriorityThread((ETHREAD *)KeGetCurrentThread(), 1u);
v10 = 0;
v22 = 0;
if( v6 )
{
v11 = (_DWORD *)(a3 + 16);
while( 1 )
{
Buffer = (char *)*((_QWORD *)v11 - 1);
v13 = *v11;
ByteOffset.QuadPart = (unsigned int)*(v11 - 4);
v26 = Buffer;
if( v13 )
break;
LABEL_16:
++v10;
v11 += 6;
v22 = v10;
if( v10 >= v29 )
goto LABEL_17;
}
while( 1 )
{
v14 = &v9[8 * v7];
if( !*(_QWORD *)v14 )
{
Event = CmpCreateEvent(SynchronizationEvent, (PVOID *)&v9[8 * v7], (_KEVENT **)&v9[8 * v7 + 512]);
if( Event < 0 )
goto LABEL_18;
Buffer = v26;
}
Length = 0x100000;
if( v13 < 0x100000 )
Length = v13;
if( ZwWriteFile(
a1,
*(_QWORD *)v14,
0i64,
0i64,
(PIO_STATUS_BLOCK)&v9[16 * v7 + 4096],
Buffer,
Length,
&ByteOffset,
0i64) < 0 )
{
Length = 0x10000;
if( v13 < 0x10000 )
Length = v13;
Event = ZwWriteFile(
a1,
*(_QWORD *)v14,
0i64,
0i64,
(PIO_STATUS_BLOCK)&v9[16 * v7 + 4096],
Buffer,
Length,
&ByteOffset,
0i64);
if( Event < 0 )
goto LABEL_18;
Buffer = v26;
}
v13 -= Length;
ByteOffset.QuadPart += Length;
Buffer += Length;
++v7;
v26 = Buffer;
if( v7 == 64 )
break;
LABEL_14:
if( !v13 )
{
v10 = v22;
goto LABEL_16;
}
}
KeWaitForMultipleObjects(0x40ui64, (VOID **)v9 + 64, WaitAll, Executive, 0, 0, 0i64, (_KWAIT_BLOCK *)(v9 + 1024));
v20 = 0;
v21 = (NTSTATUS *)(v9 + 4096);
v7 = 0;
while( 1 )
{
Event = *v21;
if( *v21 < 0 )
break;
++v20;
v21 += 4;
if( v20 >= 0x40 )
{
Buffer = v26;
goto LABEL_14;
}
}
}
else
{
LABEL_17:
Event = 0;
LABEL_18:
if( v7 )
KeWaitForMultipleObjects(v7, (VOID **)v9 + 64, WaitAll, Executive, 0, 0, 0i64, (_KWAIT_BLOCK *)(v9 + 1024));
}
if( v28 )
{
CmpSetIoPriorityThread((ETHREAD *)KeGetCurrentThread(), IoPriority);
CmpSetPriorityThread(KeGetCurrentThread(), Priority);
}
CmpSetRespectIoPriorityThread((ETHREAD *)KeGetCurrentThread(), RespectIoPriority);
v17 = 0;
v18 = (PADAPTER_OBJECT *)v9;
do
{
if( !*v18 )
break;
HalPutDmaAdapter(v18[64]);
ZwClose((_HANDLE)*v18);
++v17;
++v18;
}
while( v17 < 0x40 );
CmSiFreeMemory((PPRIVILEGE_SET)v9);
}
else
{
return(unsigned int)-1073741670;
}
return(unsigned int)Event;
}Referenced by:
CmpFileWrite
CmpWriteOffsetArrayToFile