__int64 __fastcall ClfsEncodeBlockPrivate(_CLFS_LOG_BLOCK_HEADER *hdr, unsigned int TotalSectorCount, char a3, unsigned __int8 a4)
{
int TotalSectorCounNow; // eax
unsigned __int8 val10; // bl
unsigned int TotalSectorCountRef; // esi
_CLFS_LOG_BLOCK_HEADER *that; // r10
signed int v8; // ecx
unsigned int SignaturesOffset; // ecx
unsigned int SectorCount; // edi
unsigned int SignaturesOffseEndRet; // ecx
ULONG preflag; // er9
_CLFS_LOG_BLOCK_HEADER *thisref; // r10
__int64 SignaturesOffsetAddr; // r11
unsigned int Sectoridx; // edx
char flag1; // cl
char flag2; // al
char flagall; // cl
__int64 sectorbase; // rax
unsigned int SignaturesOffseEnd; // [rsp+20h] [rbp-18h]
USHORT flagsig; // [rsp+40h] [rbp+8h]
TotalSectorCounNow = hdr->TotalSectorCount;
val10 = a4;
TotalSectorCountRef = TotalSectorCount;
SignaturesOffseEnd = 0;
that = hdr;
if ( !(_WORD)TotalSectorCounNow
|| hdr->ValidSectorCount < (unsigned __int16)TotalSectorCounNow
|| TotalSectorCounNow << 9 > TotalSectorCount )
{
return 0xC01A000Ai64;
}
if ( a4 > 0x10u )
return 0xC000000Di64;
v8 = 65809;
if ( !_bittest(&v8, a4) )
return 0xC000000Di64;
if ( that->Flags & 1 )
return 0xC01A000Ai64;
SignaturesOffset = that->SignaturesOffset;
SectorCount = TotalSectorCount >> 9;
that->Usn = a3;
HIBYTE(flagsig) = a3;
if ( (signed int)ULongAdd(SignaturesOffset, 2 * (TotalSectorCount >> 9), &SignaturesOffseEnd) < 0
|| SignaturesOffseEnd < SignaturesOffseEndRet
|| SignaturesOffseEndRet & 7
|| SignaturesOffseEnd > TotalSectorCountRef )
{
return 0xC01A000Ai64;
}
Sectoridx = 0;
if ( SectorCount )
{
do
{
// SignaturesOffsetAddr=(ULONGLONG)that+that->SignaturesOffset;
SignaturesOffsetAddr += 2i64;
flag1 = 0x20;
flag2 = 0x40;
if ( thisref->TotalSectorCount - 1 != Sectoridx )
flag1 = 0;
if ( Sectoridx )
flag2 = 0;
flagall = flag2 | flag1;
sectorbase = Sectoridx << 9;
LOBYTE(flagsig) = val10 | flagall;
++Sectoridx;
// signature array是个数组会和SignaturesOffset相交如果SignaturesOffset=0x50
*(_WORD *)(SignaturesOffsetAddr - 2) = *(USHORT *)((char *)&thisref->sig + sectorbase);
*(USHORT *)((char *)&thisref->sig + (unsigned int)sectorbase) = flagsig;
}
while ( Sectoridx < SectorCount );
preflag = thisref->Flags;
}
thisref->Flags = preflag & 0xFFFFFFFD | 1;
return 0i64;
}