public unsafe void ReadExternalAttribute( Win32API.NONRESIDENT_ATTRIBUTE *attr, UInt64 vcn, ulong count, IntPtr buffer) { UInt64 lcn = 0, runcount = 0; ulong readcount, left; byte * bytes = (byte *)(buffer.ToPointer()); for (left = count; left > 0; left -= readcount) { FindRun(attr, vcn, ref lcn, ref runcount); readcount = (Math.Min(runcount, left)); ulong n = readcount * bootb.BytesPerSector * bootb.SectorsPerCluster; if (lcn == 0) { //memset(bytes, 0, n); Win32API.ZeroMemory(new IntPtr(bytes), (int)n); } else { ReadLCN(lcn, readcount, (IntPtr)bytes); } vcn += readcount; bytes += n; } //buffer = new IntPtr(bytes); }
public unsafe bool FindRun(Win32API.NONRESIDENT_ATTRIBUTE *attr, UInt64 vcn, ref UInt64 lcn, ref UInt64 count) { byte *run = null; lcn = 0; ulong baseoff = attr->LowVCN; if (vcn < attr->LowVCN || vcn > attr->HighVCN) { return(false); } for (run = (byte *)((byte *)(attr) + attr->RunArrayOffset); *run != 0; run += RunLength(run)) { lcn += RunLCN(run); count = RunCount(run); if (baseoff <= vcn && vcn < baseoff + count) { lcn = RunLCN(run) == 0 ? 0 : lcn + vcn - baseoff; count -= (vcn - baseoff); return(true); } else { baseoff += count; } } return(false); }
public unsafe void ReadVCN(Win32API.FILE_RECORD_HEADER *file, Win32API.AttributeType type, UInt64 vcn, ulong count, IntPtr buffer) { Win32API.NONRESIDENT_ATTRIBUTE *attr = (Win32API.NONRESIDENT_ATTRIBUTE *)FindAttribute(file, type, null); ReadExternalAttribute(attr, vcn, count, buffer); }