1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4
5#ifndef _MD_DATA_TARGET_READER_
6#define _MD_DATA_TARGET_READER_
7
8#include "cor.h"
9#include "cordebug.h"
10
11class DataTargetReader;
12
13class TargetObject
14{
15public:
16 virtual HRESULT ReadFrom(DataTargetReader & reader) = 0;
17};
18
19class DataTargetReader
20{
21public:
22 DataTargetReader(CORDB_ADDRESS remoteAddressCursor, ICorDebugDataTarget* pDataTarget, DWORD targetDefines, DWORD mdStructuresVersion);
23 DataTargetReader(const DataTargetReader & otherReader);
24 DataTargetReader & operator=(const DataTargetReader & rhs);
25 ~DataTargetReader();
26
27 HRESULT Read(TargetObject* pTargetObjectValue);
28 HRESULT ReadPointer(TargetObject* pTargetObjectValue);
29 HRESULT ReadPointer(CORDB_ADDRESS* pPointerValue);
30 HRESULT SkipPointer();
31 HRESULT Read8(BYTE* pByteValue);
32 HRESULT Skip8();
33 HRESULT Read32(ULONG32* pUlong32Value);
34 HRESULT Skip32();
35 HRESULT Read64(ULONG64* pUlong64Value);
36 HRESULT Skip64();
37 HRESULT ReadBytes(BYTE* pBuffer, DWORD cbBuffer);
38 HRESULT SkipBytes(DWORD cbBuffer);
39 void Align(DWORD alignmentBytes);
40 void AlignBase();
41
42 DataTargetReader CreateReaderAt(CORDB_ADDRESS remoteAddressCursor);
43
44 DWORD GetMDStructuresVersion();
45 BOOL IsDefined(DWORD define);
46
47
48private:
49 HRESULT GetRemotePointerSize(ULONG32* pPointerSize);
50 ICorDebugDataTarget* m_pDataTarget;
51 ULONG32 m_remotePointerSize;
52 CORDB_ADDRESS m_remoteAddressCursor;
53 ULONG32 m_currentStructureAlign;
54 DWORD m_targetDefines;
55 DWORD m_mdStructuresVersion;
56};
57
58#endif // _MD_DATA_TARGET_READER_
59