PfSnGetPrefetchInstructions
__int64 __fastcall PfSnGetPrefetchInstructions(__int64 a1, int a2, _QWORD *a3){
__int64 v3;
int v6;
VOID **v7;
_ETHREAD *CurrentThread;
unsigned int v9;
VOID **PoolWithTag;
NTSTATUS v11;
ULONG Length;
VOID **v13;
_DWORD *v14;
UINT64 ShareAccess;
UINT64 OpenOptions;
VOID *DecompressedBufferOut;
UINT64 DecompressedSizeOut;
VOID *FileHandle;
UINT64 MaxDecompressedSize;
UINT64 FailedCheck;
_IO_STATUS_BLOCK IoStatusBlock;
_UNICODE_STRING DestinationString;
_SM_COMPRESSION_CALLBACKS Callbacks[2];
void(__fastcall *v26)(void *);
_OBJECT_ATTRIBUTES ObjectAttributes;
__int128 FileInformation;
__int64 v29;
LODWORD(FailedCheck) = 0;
DestinationString = 0i64;
v29 = 0i64;
v3 = -1i64;
memset(&ObjectAttributes, 0, sizeof(ObjectAttributes));
FileHandle = 0i64;
v6 = HIDWORD(a1);
LODWORD(DecompressedSizeOut) = 0;
v7 = 0i64;
IoStatusBlock = 0i64;
DecompressedBufferOut = 0i64;
FileInformation = 0i64;
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
--CurrentThread->Tcb.KernelApcDisable;
ExAcquirePushLockSharedEx(&stru_140C4FFF8, 0i64);
do
++v3;
while( word_140C4FE90[v3] );
v9 = 2 * v3 + 102;
PoolWithTag = ExAllocatePoolWithTag(1ui64, v9, 1179673411i64);
if( !PoolWithTag )
{
v11 = -1073741670;
if( _InterlockedCompareExchange64(&stru_140C4FFF8._bf_0, 0i64, 17i64) != 17 )
ExfReleasePushLockShared(&stru_140C4FFF8);
KeAbPostRelease(&stru_140C4FFF8);
KeLeaveCriticalRegion();
goto LABEL_25;
}
HIDWORD(ShareAccess) = v6;
RtlStringCbPrintfW((WCHAR *)PoolWithTag, v9, (WCHAR *)L"%s\\%ws-%08X.%ws");
if( _InterlockedCompareExchange64(&stru_140C4FFF8._bf_0, 0i64, 17i64) != 17 )
ExfReleasePushLockShared(&stru_140C4FFF8);
KeAbPostRelease(&stru_140C4FFF8);
KeLeaveCriticalRegion();
RtlInitUnicodeString(&DestinationString, (PCWSTR)PoolWithTag);
LODWORD(OpenOptions) = 32;
ObjectAttributes.ObjectName = &DestinationString;
ObjectAttributes.Length = 48;
ObjectAttributes.RootDirectory = 0i64;
ObjectAttributes.Attributes = 576;
LODWORD(ShareAccess) = 0;
*(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
v11 = NtOpenFile(&FileHandle, 0x80100000ui64, &ObjectAttributes, &IoStatusBlock, ShareAccess, OpenOptions);
if( v11 < 0
|| (v11 = NtQueryInformationFile(FileHandle, &IoStatusBlock, &FileInformation, 0x18ui64, FileStandardInformation),
v11 < 0) )
{
LABEL_25:
v14 = DecompressedBufferOut;
goto LABEL_16;
}
Length = DWORD2(FileInformation);
LODWORD(MaxDecompressedSize) = 0x10000000;
if( (unsigned int)(DWORD2(FileInformation) - 1) > 0xFFFFFFF || HIDWORD(FileInformation) )
{
v11 = -1073741823;
goto LABEL_25;
}
v13 = ExAllocatePoolWithTag(1ui64, DWORD2(FileInformation), 1884316483i64);
v7 = v13;
if( !v13 )
{
v11 = -1073741670;
goto LABEL_25;
}
v11 = NtReadFile((_HANDLE)FileHandle, 0, 0i64, 0i64, &IoStatusBlock, v13, Length, 0i64, 0i64);
if( v11 < 0 )
goto LABEL_25;
*(_QWORD *)Callbacks = PfSnScenarioAlloc;
v26 = SC_ENV::Free;
v11 = SmDecompressBuffer(v7, Length, &DecompressedBufferOut, &DecompressedSizeOut, &MaxDecompressedSize, Callbacks);
if( v11 < 0 )
goto LABEL_25;
v14 = DecompressedBufferOut;
if( (unsigned __int8)PfVerifyScenarioBuffer(
(PF_SCENARIO_HEADER *)DecompressedBufferOut,
(unsigned int)DecompressedSizeOut,
&FailedCheck) )
{
if( v14[20] == a2 )
{
*a3 = v14;
v11 = 0;
v14 = 0i64;
}
else
{
v11 = -1073741823;
}
}
else
{
v11 = -1073741701;
}
LABEL_16:
if( FileHandle )
NtClose((UINT64)FileHandle);
if( PoolWithTag )
ExFreePoolWithTag(PoolWithTag, 0);
if( v7 )
ExFreePoolWithTag(v7, 0);
if( v14 )
ExFreePoolWithTag(v14, 0);
return(unsigned int)v11;
}Referenced by:
PfSnBeginScenario