summaryrefslogtreecommitdiff
path: root/src/zap/zapreadytorun.h
blob: cf7ad0677b7ac6b8a5cf0f47f6aa84112224c068 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
//
// ZapReadyToRun.h
//

//
// Zapping of ready-to-run specific structures
// 
// ======================================================================================

#ifndef __ZAPREADYTORUN_H__
#define __ZAPREADYTORUN_H__

#include "readytorun.h"

class ZapReadyToRunHeader : public ZapNode
{
    struct Section
    {
        DWORD       type;
        ZapNode *   pSection;
    };

    SArray<Section> m_Sections;

    static int __cdecl SectionCmp(const void* a_, const void* b_)
    {
        return ((Section*)a_)->type - ((Section*)b_)->type;
    }

public:
    ZapReadyToRunHeader(ZapImage * pImage)
    {
    }

    void RegisterSection(DWORD type, ZapNode * pSection)
    {
        Section section;
        section.type = type;
        section.pSection = pSection;
        m_Sections.Append(section);
    }

    virtual DWORD GetSize()
    {
        return sizeof(READYTORUN_HEADER) + sizeof(READYTORUN_SECTION) * m_Sections.GetCount();
    }

    virtual UINT GetAlignment()
    {
        return sizeof(DWORD);
    }

    virtual ZapNodeType GetType()
    {
        return ZapNodeType_NativeHeader;
    }

    virtual void Save(ZapWriter * pZapWriter);
};

#endif // __ZAPREADYTORUN_H__