1b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal//===-- WindowsResource.h ---------------------------------------*- C++-*-===//
2b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal//
3b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal//                     The LLVM Compiler Infrastructure
4b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal//
5b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal// This file is distributed under the University of Illinois Open Source
6b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal// License. See LICENSE.TXT for details.
7b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal//
8b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal//===---------------------------------------------------------------------===//
9b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal//
10b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal// This file declares the .res file class.  .res files are intermediate
11b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal// products of the typical resource-compilation process on Windows.  This
12b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal// process is as follows:
13b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal//
14b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal// .rc file(s) ---(rc.exe)---> .res file(s) ---(cvtres.exe)---> COFF file
15b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal//
16031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal// .rc files are human-readable scripts that list all resources a program uses.
17b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal//
18b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal// They are compiled into .res files, which are a list of the resources in
19b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal// binary form.
20ed2d2bcbb8541eb811615638e6bcf93524c2b333Sunny Goyal//
21b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal// Finally the data stored in the .res is compiled into a COFF file, where it
2276e2775bb638757216fcaa96f8a62654fb56b19aSunny Goyal// is organized in a directory tree structure for optimized access by the
23b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal// program during runtime.
24b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal//
25b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal// Ref: msdn.microsoft.com/en-us/library/windows/desktop/ms648007(v=vs.85).aspx
26b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal//
27b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal//===---------------------------------------------------------------------===//
28b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal
29b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal#ifndef LLVM_INCLUDE_LLVM_OBJECT_RESFILE_H
30031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal#define LLVM_INCLUDE_LLVM_OBJECT_RESFILE_H
31031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal
32b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal#include "llvm/ADT/ArrayRef.h"
33031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal#include "llvm/BinaryFormat/COFF.h"
34b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal#include "llvm/Object/Binary.h"
35b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal#include "llvm/Object/Error.h"
36031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal#include "llvm/Support/BinaryByteStream.h"
37b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal#include "llvm/Support/BinaryStreamReader.h"
3831fbd4c08ba9257ea2f85732c4d00b127d65875cTony#include "llvm/Support/ConvertUTF.h"
3931fbd4c08ba9257ea2f85732c4d00b127d65875cTony#include "llvm/Support/Endian.h"
4031fbd4c08ba9257ea2f85732c4d00b127d65875cTony#include "llvm/Support/Error.h"
4131fbd4c08ba9257ea2f85732c4d00b127d65875cTony#include "llvm/Support/ScopedPrinter.h"
4205a3bbdef8c328370a51e045db12d67e62956b3fSunny Goyal
4305a3bbdef8c328370a51e045db12d67e62956b3fSunny Goyal#include <map>
4405a3bbdef8c328370a51e045db12d67e62956b3fSunny Goyal
4505a3bbdef8c328370a51e045db12d67e62956b3fSunny Goyalnamespace llvm {
4605a3bbdef8c328370a51e045db12d67e62956b3fSunny Goyalnamespace object {
4705a3bbdef8c328370a51e045db12d67e62956b3fSunny Goyal
4831fbd4c08ba9257ea2f85732c4d00b127d65875cTonyclass WindowsResource;
4931fbd4c08ba9257ea2f85732c4d00b127d65875cTony
50031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyalconst size_t WIN_RES_MAGIC_SIZE = 16;
51031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyalconst size_t WIN_RES_NULL_ENTRY_SIZE = 16;
52031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyalconst uint32_t WIN_RES_HEADER_ALIGNMENT = 4;
53031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyalconst uint32_t WIN_RES_DATA_ALIGNMENT = 4;
5431fbd4c08ba9257ea2f85732c4d00b127d65875cTonyconst uint16_t WIN_RES_PURE_MOVEABLE = 0x0030;
55b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal
56b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyalstruct WinResHeaderPrefix {
57b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  support::ulittle32_t DataSize;
58b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  support::ulittle32_t HeaderSize;
59b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal};
60b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal
61b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal// Type and Name may each either be an integer ID or a string.  This struct is
62b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal// only used in the case where they are both IDs.
63031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyalstruct WinResIDs {
64b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  uint16_t TypeFlag;
65ed2d2bcbb8541eb811615638e6bcf93524c2b333Sunny Goyal  support::ulittle16_t TypeID;
6631fbd4c08ba9257ea2f85732c4d00b127d65875cTony  uint16_t NameFlag;
67ed2d2bcbb8541eb811615638e6bcf93524c2b333Sunny Goyal  support::ulittle16_t NameID;
6831fbd4c08ba9257ea2f85732c4d00b127d65875cTony
6931fbd4c08ba9257ea2f85732c4d00b127d65875cTony  void setType(uint16_t ID) {
70b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal    TypeFlag = 0xffff;
71b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal    TypeID = ID;
7231fbd4c08ba9257ea2f85732c4d00b127d65875cTony  }
73b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal
74b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  void setName(uint16_t ID) {
755bc6b6f14c676e7528be62e1355a4dec3d783524Sunny Goyal    NameFlag = 0xffff;
76031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal    NameID = ID;
77b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  }
78ed2d2bcbb8541eb811615638e6bcf93524c2b333Sunny Goyal};
79ed2d2bcbb8541eb811615638e6bcf93524c2b333Sunny Goyal
80ed2d2bcbb8541eb811615638e6bcf93524c2b333Sunny Goyalstruct WinResHeaderSuffix {
81ed2d2bcbb8541eb811615638e6bcf93524c2b333Sunny Goyal  support::ulittle32_t DataVersion;
82ed2d2bcbb8541eb811615638e6bcf93524c2b333Sunny Goyal  support::ulittle16_t MemoryFlags;
8331fbd4c08ba9257ea2f85732c4d00b127d65875cTony  support::ulittle16_t Language;
8431fbd4c08ba9257ea2f85732c4d00b127d65875cTony  support::ulittle32_t Version;
8531fbd4c08ba9257ea2f85732c4d00b127d65875cTony  support::ulittle32_t Characteristics;
8631fbd4c08ba9257ea2f85732c4d00b127d65875cTony};
8731fbd4c08ba9257ea2f85732c4d00b127d65875cTony
8831fbd4c08ba9257ea2f85732c4d00b127d65875cTonyclass EmptyResError : public GenericBinaryError {
8931fbd4c08ba9257ea2f85732c4d00b127d65875cTonypublic:
9031fbd4c08ba9257ea2f85732c4d00b127d65875cTony  EmptyResError(Twine Msg, object_error ECOverride)
9131fbd4c08ba9257ea2f85732c4d00b127d65875cTony      : GenericBinaryError(Msg, ECOverride) {}
9231fbd4c08ba9257ea2f85732c4d00b127d65875cTony};
9331fbd4c08ba9257ea2f85732c4d00b127d65875cTony
9431fbd4c08ba9257ea2f85732c4d00b127d65875cTonyclass ResourceEntryRef {
9531fbd4c08ba9257ea2f85732c4d00b127d65875cTonypublic:
9631fbd4c08ba9257ea2f85732c4d00b127d65875cTony  Error moveNext(bool &End);
9731fbd4c08ba9257ea2f85732c4d00b127d65875cTony  bool checkTypeString() const { return IsStringType; }
98ed2d2bcbb8541eb811615638e6bcf93524c2b333Sunny Goyal  ArrayRef<UTF16> getTypeString() const { return Type; }
99ed2d2bcbb8541eb811615638e6bcf93524c2b333Sunny Goyal  uint16_t getTypeID() const { return TypeID; }
100b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  bool checkNameString() const { return IsStringName; }
101b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  ArrayRef<UTF16> getNameString() const { return Name; }
102031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal  uint16_t getNameID() const { return NameID; }
103031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal  uint16_t getDataVersion() const { return Suffix->DataVersion; }
104031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal  uint16_t getLanguage() const { return Suffix->Language; }
105031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal  uint16_t getMemoryFlags() const { return Suffix->MemoryFlags; }
106de5535a1ecb38c6251010583b70c70cee4aedab4Sunny Goyal  uint16_t getMajorVersion() const { return Suffix->Version >> 16; }
107de5535a1ecb38c6251010583b70c70cee4aedab4Sunny Goyal  uint16_t getMinorVersion() const { return Suffix->Version; }
108de5535a1ecb38c6251010583b70c70cee4aedab4Sunny Goyal  uint32_t getCharacteristics() const { return Suffix->Characteristics; }
109de5535a1ecb38c6251010583b70c70cee4aedab4Sunny Goyal  ArrayRef<uint8_t> getData() const { return Data; }
110b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal
111b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyalprivate:
112b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  friend class WindowsResource;
113b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal
114b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  ResourceEntryRef(BinaryStreamRef Ref, const WindowsResource *Owner);
115b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  Error loadNext();
116b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal
117b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  static Expected<ResourceEntryRef> create(BinaryStreamRef Ref,
118b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal                                           const WindowsResource *Owner);
119b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal
120b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  BinaryStreamReader Reader;
121b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  bool IsStringType;
122b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  ArrayRef<UTF16> Type;
123b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  uint16_t TypeID;
124b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  bool IsStringName;
125b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  ArrayRef<UTF16> Name;
126b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  uint16_t NameID;
127b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  const WinResHeaderSuffix *Suffix = nullptr;
128b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  ArrayRef<uint8_t> Data;
129031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal  const WindowsResource *OwningRes = nullptr;
130031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal};
131031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal
132031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyalclass WindowsResource : public Binary {
133031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyalpublic:
134031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal  Expected<ResourceEntryRef> getHeadEntry();
135031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal
136031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal  static bool classof(const Binary *V) { return V->isWinRes(); }
137031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal
138031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal  static Expected<std::unique_ptr<WindowsResource>>
139031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal  createWindowsResource(MemoryBufferRef Source);
140031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal
141031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyalprivate:
142031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal  friend class ResourceEntryRef;
143b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal
144b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  WindowsResource(MemoryBufferRef Source);
145b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal
146b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  BinaryByteStream BBS;
147031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal};
148031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal
149031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyalclass WindowsResourceParser {
150031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyalpublic:
151b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  class TreeNode;
152031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal  WindowsResourceParser();
153031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal  Error parse(WindowsResource *WR);
154b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  void printTree(raw_ostream &OS) const;
155031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal  const TreeNode &getTree() const { return Root; }
156031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal  const ArrayRef<std::vector<uint8_t>> getData() const { return Data; }
157b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  const ArrayRef<std::vector<UTF16>> getStringTable() const {
158b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal    return StringTable;
159b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  }
160b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal
161b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  class TreeNode {
162b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  public:
163b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal    template <typename T>
164b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal    using Children = std::map<T, std::unique_ptr<TreeNode>>;
165b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal
166b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal    void print(ScopedPrinter &Writer, StringRef Name) const;
167b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal    uint32_t getTreeSize() const;
168b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal    uint32_t getStringIndex() const { return StringIndex; }
169b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal    uint32_t getDataIndex() const { return DataIndex; }
170b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal    uint16_t getMajorVersion() const { return MajorVersion; }
171b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal    uint16_t getMinorVersion() const { return MinorVersion; }
172b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal    uint32_t getCharacteristics() const { return Characteristics; }
173b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal    bool checkIsDataNode() const { return IsDataNode; }
174b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal    const Children<uint32_t> &getIDChildren() const { return IDChildren; }
175b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal    const Children<std::string> &getStringChildren() const {
176b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal      return StringChildren;
177b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal    }
178b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal
179b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  private:
180b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal    friend class WindowsResourceParser;
181b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal
182b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal    static uint32_t StringCount;
183b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal    static uint32_t DataCount;
184b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal
185b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal    static std::unique_ptr<TreeNode> createStringNode();
186b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal    static std::unique_ptr<TreeNode> createIDNode();
187b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal    static std::unique_ptr<TreeNode> createDataNode(uint16_t MajorVersion,
188b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal                                                    uint16_t MinorVersion,
18931fbd4c08ba9257ea2f85732c4d00b127d65875cTony                                                    uint32_t Characteristics);
19031fbd4c08ba9257ea2f85732c4d00b127d65875cTony
19131fbd4c08ba9257ea2f85732c4d00b127d65875cTony    explicit TreeNode(bool IsStringNode);
19231fbd4c08ba9257ea2f85732c4d00b127d65875cTony    TreeNode(uint16_t MajorVersion, uint16_t MinorVersion,
19331fbd4c08ba9257ea2f85732c4d00b127d65875cTony             uint32_t Characteristics);
19431fbd4c08ba9257ea2f85732c4d00b127d65875cTony
19531fbd4c08ba9257ea2f85732c4d00b127d65875cTony    void addEntry(const ResourceEntryRef &Entry, bool &IsNewTypeString,
19631fbd4c08ba9257ea2f85732c4d00b127d65875cTony                  bool &IsNewNameString);
19731fbd4c08ba9257ea2f85732c4d00b127d65875cTony    TreeNode &addTypeNode(const ResourceEntryRef &Entry, bool &IsNewTypeString);
19831fbd4c08ba9257ea2f85732c4d00b127d65875cTony    TreeNode &addNameNode(const ResourceEntryRef &Entry, bool &IsNewNameString);
19931fbd4c08ba9257ea2f85732c4d00b127d65875cTony    TreeNode &addLanguageNode(const ResourceEntryRef &Entry);
20031fbd4c08ba9257ea2f85732c4d00b127d65875cTony    TreeNode &addChild(uint32_t ID, bool IsDataNode = false,
20131fbd4c08ba9257ea2f85732c4d00b127d65875cTony                       uint16_t MajorVersion = 0, uint16_t MinorVersion = 0,
20231fbd4c08ba9257ea2f85732c4d00b127d65875cTony                       uint32_t Characteristics = 0);
20331fbd4c08ba9257ea2f85732c4d00b127d65875cTony    TreeNode &addChild(ArrayRef<UTF16> NameRef, bool &IsNewString);
20431fbd4c08ba9257ea2f85732c4d00b127d65875cTony
20531fbd4c08ba9257ea2f85732c4d00b127d65875cTony    bool IsDataNode = false;
20631fbd4c08ba9257ea2f85732c4d00b127d65875cTony    uint32_t StringIndex;
20731fbd4c08ba9257ea2f85732c4d00b127d65875cTony    uint32_t DataIndex;
20831fbd4c08ba9257ea2f85732c4d00b127d65875cTony    Children<uint32_t> IDChildren;
209fa6cbbe15b4c2d698b20e10a28efc95e1fe8ada4Tony Wickham    Children<std::string> StringChildren;
210fa6cbbe15b4c2d698b20e10a28efc95e1fe8ada4Tony Wickham    uint16_t MajorVersion = 0;
211fa6cbbe15b4c2d698b20e10a28efc95e1fe8ada4Tony Wickham    uint16_t MinorVersion = 0;
212fa6cbbe15b4c2d698b20e10a28efc95e1fe8ada4Tony Wickham    uint32_t Characteristics = 0;
213031022029b1cc5731d85327f5bd4e183a72cfb3cSunny Goyal  };
214b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal
215b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyalprivate:
216b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal  TreeNode Root;
21731fbd4c08ba9257ea2f85732c4d00b127d65875cTony  std::vector<std::vector<uint8_t>> Data;
21831fbd4c08ba9257ea2f85732c4d00b127d65875cTony  std::vector<std::vector<UTF16>> StringTable;
21931fbd4c08ba9257ea2f85732c4d00b127d65875cTony};
220b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal
221b871c13ee3391d69a8df10448c4cc414b51dc185Sunny GoyalExpected<std::unique_ptr<MemoryBuffer>>
222b871c13ee3391d69a8df10448c4cc414b51dc185Sunny GoyalwriteWindowsResourceCOFF(llvm::COFF::MachineTypes MachineType,
223b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal                         const WindowsResourceParser &Parser);
224b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal
225b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal} // namespace object
226b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal} // namespace llvm
227b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal
228b871c13ee3391d69a8df10448c4cc414b51dc185Sunny Goyal#endif
22976e2775bb638757216fcaa96f8a62654fb56b19aSunny Goyal