blob: 527d042515d59e8d2c51ebe83aa56c654572b9df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using System;
using Mono.Cecil.PE;
namespace Mono.Cecil.Metadata {
sealed class BlobHeap : Heap {
public BlobHeap (Section section, uint start, uint size)
: base (section, start, size)
{
}
public byte [] Read (uint index)
{
if (index == 0 || index > Size - 1)
return Empty<byte>.Array;
var data = Section.Data;
int position = (int) (index + Offset);
int length = (int) data.ReadCompressedUInt32 (ref position);
var buffer = new byte [length];
Buffer.BlockCopy (data, position, buffer, 0, length);
return buffer;
}
}
}
|