static HexSpan?TryGetFileSpan(HexBufferFile file, HexPosition position, FileOffsetData offsetData, UInt32Data sizeData) { if (!offsetData.Span.Span.Contains(position)) { return(null); } var peHeaders = file.GetHeaders <PeHeaders>(); if (peHeaders is null) { return(null); } uint offset = offsetData.ReadValue(); if (offset == 0) { return(null); } uint size = sizeData.ReadValue(); if (size == 0) { return(null); } var pos = peHeaders.FilePositionToBufferPosition(offset); if (pos + size > file.Span.End) { return(new HexSpan(pos, 0)); } return(new HexSpan(pos, size)); }
static HexSpan?TryGetRvaSpan(HexBufferFile file, HexPosition position, RvaData rvaData, UInt32Data sizeData) { if (!rvaData.Span.Span.Contains(position)) { return(null); } var peHeaders = file.GetHeaders <PeHeaders>(); if (peHeaders is null) { return(null); } uint rva = rvaData.ReadValue(); if (rva == 0) { return(null); } uint size = sizeData.ReadValue(); if (size == 0) { return(null); } var pos = peHeaders.RvaToBufferPosition(rva); if (pos + size > file.Span.End) { return(new HexSpan(pos, 0)); } return(new HexSpan(pos, size)); }
HexSpan?TryGetSpan(FatMethodBody fatBody, HexPosition position, UInt32Data offsetData, UInt32Data lengthData) { if (!offsetData.Span.Span.Contains(position)) { return(null); } return(TryGetSpan(fatBody, offsetData.ReadValue(), lengthData.ReadValue())); }