Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- size_t __cdecl fread(void *DstBuf, size_t ElementSize, size_t Count, FILE *File)
- {
- size_t result; // eax@2
- DWORD v5; // [sp+0h] [bp-24h]@15
- int bytesFilled; // [sp+4h] [bp-20h]@10
- int bufSIze; // [sp+8h] [bp-1Ch]@4
- int fHnd; // [sp+10h] [bp-14h]@17
- unsigned int v9; // [sp+14h] [bp-10h]@1
- unsigned int maxBytesFilled; // [sp+18h] [bp-Ch]@1
- void *bytesDestination; // [sp+1Ch] [bp-8h]@1
- int v12; // [sp+20h] [bp-4h]@22
- bytesDestination = DstBuf;
- v9 = Count * ElementSize;
- maxBytesFilled = Count * ElementSize;
- if ( Count * ElementSize )
- {
- if ( File->_flag & 0x10C )
- bufSIze = File->_bufsiz;
- else
- bufSIze = 4096;
- while ( maxBytesFilled )
- {
- if ( File->_flag & 0x10C && File->_cnt )
- {
- if ( maxBytesFilled >= File->_cnt )
- bytesFilled = File->_cnt;
- else
- bytesFilled = maxBytesFilled;
- memcpy(bytesDestination, File->_ptr, bytesFilled);
- maxBytesFilled -= bytesFilled;
- File->_cnt -= bytesFilled;
- File->_ptr += bytesFilled;
- bytesDestination = (char *)bytesDestination + bytesFilled;
- }
- else
- {
- if ( maxBytesFilled < bufSIze )
- {
- v12 = _filbuf(File);
- if ( v12 == -1 )
- return (v9 - maxBytesFilled) / ElementSize;
- *(_BYTE *)bytesDestination = v12;
- bytesDestination = (char *)bytesDestination + 1;
- --maxBytesFilled;
- bufSIze = File->_bufsiz;
- }
- else
- {
- if ( bufSIze )
- v5 = maxBytesFilled - maxBytesFilled % bufSIze;
- else
- v5 = maxBytesFilled;
- fHnd = _read(File->_file, (int)bytesDestination, v5);
- if ( !fHnd )
- {
- File->_flag |= 0x10u;
- return (v9 - maxBytesFilled) / ElementSize;
- }
- if ( fHnd == -1 )
- {
- File->_flag |= 0x20u;
- return (v9 - maxBytesFilled) / ElementSize;
- }
- maxBytesFilled -= fHnd;
- bytesDestination = (char *)bytesDestination + fHnd;
- }
- }
- }
- result = Count;
- }
- else
- {
- result = 0;
- }
- return result;
- }
Add Comment
Please, Sign In to add comment