21 #include <system_error> 29 #define RETURN_IF_ERROR(X) \ 33 #define UNWRAP_REF_OR_RETURN(Name, Expr) \ 34 auto Name##OrErr = Expr; \ 36 return Name##OrErr.takeError(); \ 37 const auto &Name = *Name##OrErr; 39 #define UNWRAP_OR_RETURN(Name, Expr) \ 40 auto Name##OrErr = Expr; \ 42 return Name##OrErr.takeError(); \ 43 auto Name = *Name##OrErr; 62 return make_error<GenericBinaryError>(
66 return std::move(Ret);
71 return make_error<EmptyResError>(
getFileName() +
" contains no entries",
78 : Reader(Ref), Owner(Owner) {}
83 if (
auto E = Ref.loadNext())
90 if (Reader.bytesRemaining() == 0) {
103 IsString = IDFlag != 0xffff;
116 Error ResourceEntryRef::loadNext() {
121 return make_error<GenericBinaryError>(Owner->
getFileName() +
122 ": header size too small",
141 : Root(
false), MinGW(MinGW) {}
145 case 1: OS <<
"CURSOR (ID 1)";
break;
146 case 2: OS <<
"BITMAP (ID 2)";
break;
147 case 3: OS <<
"ICON (ID 3)";
break;
148 case 4: OS <<
"MENU (ID 4)";
break;
149 case 5: OS <<
"DIALOG (ID 5)";
break;
150 case 6: OS <<
"STRINGTABLE (ID 6)";
break;
151 case 7: OS <<
"FONTDIR (ID 7)";
break;
152 case 8: OS <<
"FONT (ID 8)";
break;
153 case 9: OS <<
"ACCELERATOR (ID 9)";
break;
154 case 10: OS <<
"RCDATA (ID 10)";
break;
155 case 11: OS <<
"MESSAGETABLE (ID 11)";
break;
156 case 12: OS <<
"GROUP_CURSOR (ID 12)";
break;
157 case 14: OS <<
"GROUP_ICON (ID 14)";
break;
158 case 16: OS <<
"VERSIONINFO (ID 16)";
break;
159 case 17: OS <<
"DLGINCLUDE (ID 17)";
break;
160 case 19: OS <<
"PLUGPLAY (ID 19)";
break;
161 case 20: OS <<
"VXD (ID 20)";
break;
162 case 21: OS <<
"ANICURSOR (ID 21)";
break;
163 case 22: OS <<
"ANIICON (ID 22)";
break;
164 case 23: OS <<
"HTML (ID 23)";
break;
165 case 24: OS <<
"MANIFEST (ID 24)";
break;
166 default: OS <<
"ID " <<
TypeID;
break;
174 std::vector<UTF16> EndianCorrectedSrc;
175 EndianCorrectedSrc.resize(Src.
size() + 1);
186 OS <<
"duplicate resource:";
192 UTF8 =
"(failed conversion from UTF16)";
193 OS <<
'\"' << UTF8 <<
'\"';
201 UTF8 =
"(failed conversion from UTF16)";
202 OS <<
'\"' << UTF8 <<
'\"';
207 OS <<
"/language " << Entry.
getLanguage() <<
", in " << File1 <<
" and in " 218 UTF8 =
"(failed conversion from UTF16)";
219 OS <<
'\"' << UTF8 <<
'\"';
229 const std::vector<WindowsResourceParser::StringOrID> &
Context,
234 OS <<
"duplicate resource:";
236 if (Context.size() >= 1) {
241 if (Context.size() >= 2) {
246 if (Context.size() >= 3) {
250 OS <<
", in " << File1 <<
" and in " << File2;
264 std::vector<std::string> &Duplicates) {
265 auto TypeIt = Root.IDChildren.find( 24);
266 if (TypeIt == Root.IDChildren.end())
269 TreeNode *TypeNode = TypeIt->second.get();
271 TypeNode->IDChildren.find( 1);
272 if (NameIt == TypeNode->IDChildren.end())
275 TreeNode *NameNode = NameIt->second.get();
276 if (NameNode->IDChildren.size() <= 1)
281 auto LangZeroIt = NameNode->IDChildren.find(0);
282 if (LangZeroIt != NameNode->IDChildren.end() &&
283 LangZeroIt->second->IsDataNode) {
284 uint32_t RemovedIndex = LangZeroIt->second->DataIndex;
285 NameNode->IDChildren.erase(LangZeroIt);
286 Data.erase(Data.begin() + RemovedIndex);
287 Root.shiftDataIndexDown(RemovedIndex);
290 if (NameNode->IDChildren.size() <= 1)
295 auto FirstIt = NameNode->IDChildren.begin();
296 uint32_t FirstLang = FirstIt->first;
297 TreeNode *FirstNode = FirstIt->second.get();
298 auto LastIt = NameNode->IDChildren.rbegin();
300 TreeNode *LastNode = LastIt->second.get();
301 Duplicates.push_back(
302 (
"duplicate non-default manifests with languages " +
Twine(FirstLang) +
303 " in " + InputFilenames[FirstNode->Origin] +
" and " +
Twine(LastLang) +
304 " in " + InputFilenames[LastNode->Origin])
312 bool WindowsResourceParser::shouldIgnoreDuplicate(
321 bool WindowsResourceParser::shouldIgnoreDuplicate(
322 const std::vector<StringOrID> &
Context)
const {
323 return MinGW && Context.size() == 3 && !Context[0].IsString &&
324 Context[0].ID == 24 && !Context[1].IsString &&
325 Context[1].ID == 1 &&
326 !Context[2].IsString && Context[2].ID == 0;
330 std::vector<std::string> &Duplicates) {
333 auto E = EntryOrErr.takeError();
348 uint32_t Origin = InputFilenames.size();
354 bool IsNewNode = Root.addEntry(Entry, Origin, Data, StringTable, Node);
356 if (!shouldIgnoreDuplicate(Entry))
358 Entry, InputFilenames[Node->Origin], WR->
getFileName()));
368 std::vector<std::string> &Duplicates) {
370 uint32_t Origin = InputFilenames.size();
371 InputFilenames.push_back(Filename);
372 std::vector<StringOrID>
Context;
373 return addChildren(Root, RSR, BaseTable, Origin, Context, Duplicates);
378 Root.
print(Writer,
"Resource Tree");
381 bool WindowsResourceParser::TreeNode::addEntry(
383 std::vector<std::vector<uint8_t>> &Data,
384 std::vector<std::vector<UTF16>> &StringTable,
TreeNode *&Result) {
385 TreeNode &TypeNode = addTypeNode(Entry, StringTable);
386 TreeNode &NameNode = TypeNode.addNameNode(Entry, StringTable);
387 return NameNode.addLanguageNode(Entry, Origin, Data, Result);
394 std::vector<StringOrID> &Context,
395 std::vector<std::string> &Duplicates) {
402 if (Entry.Offset.isSubDir()) {
407 Child = &Node.addNameChild(NameString, StringTable);
410 Child = &Node.addIDChild(Entry.Identifier.ID);
411 Context.push_back(
StringOrID(Entry.Identifier.ID));
416 addChildren(*Child, RSR, NextTable, Origin, Context, Duplicates);
426 "unexpected string key for data object");
431 Context.push_back(
StringOrID(Entry.Identifier.ID));
432 bool Added = Node.addDataChild(Entry.Identifier.ID, Table.
MajorVersion,
434 Origin, Data.size(), Child);
438 reinterpret_cast<const uint8_t *>(Contents.data()),
441 if (!shouldIgnoreDuplicate(Context))
443 Context, InputFilenames[Child->Origin], InputFilenames.back()));
452 WindowsResourceParser::TreeNode::TreeNode(
uint32_t StringIndex)
453 : StringIndex(StringIndex) {}
455 WindowsResourceParser::TreeNode::TreeNode(
uint16_t MajorVersion,
459 : IsDataNode(
true), DataIndex(DataIndex), MajorVersion(MajorVersion),
463 std::unique_ptr<WindowsResourceParser::TreeNode>
464 WindowsResourceParser::TreeNode::createStringNode(
uint32_t Index) {
465 return std::unique_ptr<TreeNode>(
new TreeNode(Index));
468 std::unique_ptr<WindowsResourceParser::TreeNode>
469 WindowsResourceParser::TreeNode::createIDNode() {
470 return std::unique_ptr<TreeNode>(
new TreeNode(0));
473 std::unique_ptr<WindowsResourceParser::TreeNode>
474 WindowsResourceParser::TreeNode::createDataNode(
uint16_t MajorVersion,
479 return std::unique_ptr<TreeNode>(
new TreeNode(
480 MajorVersion, MinorVersion, Characteristics, Origin, DataIndex));
485 std::vector<std::vector<UTF16>> &StringTable) {
494 std::vector<std::vector<UTF16>> &StringTable) {
501 bool WindowsResourceParser::TreeNode::addLanguageNode(
503 std::vector<std::vector<uint8_t>> &Data,
TreeNode *&Result) {
506 Origin, Data.size(), Result);
508 Data.push_back(Entry.
getData());
512 bool WindowsResourceParser::TreeNode::addDataChild(
516 auto NewChild = createDataNode(MajorVersion, MinorVersion, Characteristics,
518 auto ElementInserted = IDChildren.emplace(ID, std::move(NewChild));
519 Result = ElementInserted.first->second.get();
520 return ElementInserted.second;
525 auto Child = IDChildren.find(ID);
526 if (Child == IDChildren.end()) {
527 auto NewChild = createIDNode();
529 IDChildren.emplace(ID, std::move(NewChild));
532 return *(Child->second);
536 ArrayRef<UTF16> NameRef, std::vector<std::vector<UTF16>> &StringTable) {
537 std::string NameString;
540 auto Child = StringChildren.find(NameString);
541 if (Child == StringChildren.end()) {
542 auto NewChild = createStringNode(StringTable.size());
543 StringTable.push_back(NameRef);
545 StringChildren.emplace(NameString, std::move(NewChild));
548 return *(Child->second);
554 for (
auto const &Child : StringChildren) {
555 Child.second->print(Writer, Child.first);
557 for (
auto const &Child : IDChildren) {
558 Child.second->print(Writer,
to_string(Child.first));
566 uint32_t Size = (IDChildren.size() + StringChildren.size()) *
579 for (
auto const &Child : StringChildren) {
580 Size += Child.second->getTreeSize();
582 for (
auto const &Child : IDChildren) {
583 Size += Child.second->getTreeSize();
590 void WindowsResourceParser::TreeNode::shiftDataIndexDown(
uint32_t Index) {
591 if (IsDataNode && DataIndex >= Index) {
594 for (
auto &Child : IDChildren)
595 Child.second->shiftDataIndexDown(Index);
596 for (
auto &Child : StringChildren)
597 Child.second->shiftDataIndexDown(Index);
608 void performFileLayout();
609 void performSectionOneLayout();
610 void performSectionTwoLayout();
611 void writeCOFFHeader(
uint32_t TimeDateStamp);
612 void writeFirstSectionHeader();
613 void writeSecondSectionHeader();
614 void writeFirstSection();
615 void writeSecondSection();
618 void writeDirectoryTree();
619 void writeDirectoryStringTable();
620 void writeFirstSectionRelocations();
621 std::unique_ptr<WritableMemoryBuffer> OutputBuffer;
623 uint64_t CurrentOffset = 0;
635 std::vector<uint32_t> StringTableOffsets;
636 std::vector<uint32_t> DataOffsets;
637 std::vector<uint32_t> RelocationAddresses;
643 : MachineType(MachineType), Resources(Parser.
getTree()),
648 FileSize,
"internal .obj file created from .res files");
651 void WindowsResourceCOFFWriter::performFileLayout() {
658 performSectionOneLayout();
659 performSectionTwoLayout();
662 SymbolTableOffset = FileSize;
670 void WindowsResourceCOFFWriter::performSectionOneLayout() {
671 SectionOneOffset = FileSize;
674 uint32_t CurrentStringOffset = SectionOneSize;
676 for (
auto const &String : StringTable) {
677 StringTableOffsets.push_back(CurrentStringOffset);
679 CurrentStringOffset += StringSize;
680 TotalStringTableSize += StringSize;
685 SectionOneRelocations = FileSize + SectionOneSize;
686 FileSize += SectionOneSize;
689 FileSize =
alignTo(FileSize, SECTION_ALIGNMENT);
692 void WindowsResourceCOFFWriter::performSectionTwoLayout() {
695 SectionTwoOffset = FileSize;
697 for (
auto const &Entry : Data) {
698 DataOffsets.push_back(SectionTwoSize);
699 SectionTwoSize +=
alignTo(Entry.size(),
sizeof(uint64_t));
701 FileSize += SectionTwoSize;
702 FileSize =
alignTo(FileSize, SECTION_ALIGNMENT);
705 std::unique_ptr<MemoryBuffer>
707 BufferStart = OutputBuffer->getBufferStart();
709 writeCOFFHeader(TimeDateStamp);
710 writeFirstSectionHeader();
711 writeSecondSectionHeader();
713 writeSecondSection();
717 return std::move(OutputBuffer);
724 "Src is not larger than COFF::NameSize");
725 strncpy(Dest, Src.
data(), (size_t)COFF::NameSize);
728 void WindowsResourceCOFFWriter::writeCOFFHeader(
uint32_t TimeDateStamp) {
732 Header->NumberOfSections = 2;
733 Header->TimeDateStamp = TimeDateStamp;
734 Header->PointerToSymbolTable = SymbolTableOffset;
736 Header->NumberOfSymbols = Data.
size() + 5;
737 Header->SizeOfOptionalHeader = 0;
742 void WindowsResourceCOFFWriter::writeFirstSectionHeader() {
745 auto *SectionOneHeader =
746 reinterpret_cast<coff_section *
>(BufferStart + CurrentOffset);
748 SectionOneHeader->VirtualSize = 0;
749 SectionOneHeader->VirtualAddress = 0;
750 SectionOneHeader->SizeOfRawData = SectionOneSize;
751 SectionOneHeader->PointerToRawData = SectionOneOffset;
752 SectionOneHeader->PointerToRelocations = SectionOneRelocations;
753 SectionOneHeader->PointerToLinenumbers = 0;
754 SectionOneHeader->NumberOfRelocations = Data.
size();
755 SectionOneHeader->NumberOfLinenumbers = 0;
760 void WindowsResourceCOFFWriter::writeSecondSectionHeader() {
763 auto *SectionTwoHeader =
764 reinterpret_cast<coff_section *
>(BufferStart + CurrentOffset);
766 SectionTwoHeader->VirtualSize = 0;
767 SectionTwoHeader->VirtualAddress = 0;
768 SectionTwoHeader->SizeOfRawData = SectionTwoSize;
769 SectionTwoHeader->PointerToRawData = SectionTwoOffset;
770 SectionTwoHeader->PointerToRelocations = 0;
771 SectionTwoHeader->PointerToLinenumbers = 0;
772 SectionTwoHeader->NumberOfRelocations = 0;
773 SectionTwoHeader->NumberOfLinenumbers = 0;
778 void WindowsResourceCOFFWriter::writeFirstSection() {
782 writeDirectoryTree();
783 writeDirectoryStringTable();
784 writeFirstSectionRelocations();
786 CurrentOffset =
alignTo(CurrentOffset, SECTION_ALIGNMENT);
789 void WindowsResourceCOFFWriter::writeSecondSection() {
791 for (
auto const &RawDataEntry : Data) {
792 llvm::copy(RawDataEntry, BufferStart + CurrentOffset);
793 CurrentOffset +=
alignTo(RawDataEntry.size(),
sizeof(uint64_t));
796 CurrentOffset =
alignTo(CurrentOffset, SECTION_ALIGNMENT);
799 void WindowsResourceCOFFWriter::writeSymbolTable() {
805 Symbol->SectionNumber = 0xffff;
808 Symbol->NumberOfAuxSymbols = 0;
815 Symbol->SectionNumber = 1;
818 Symbol->NumberOfAuxSymbols = 1;
822 Aux->
Length = SectionOneSize;
823 Aux->NumberOfRelocations = Data.
size();
824 Aux->NumberOfLinenumbers = 0;
826 Aux->NumberLowPart = 0;
834 Symbol->SectionNumber = 2;
837 Symbol->NumberOfAuxSymbols = 1;
841 Aux->
Length = SectionTwoSize;
842 Aux->NumberOfRelocations = 0;
843 Aux->NumberOfLinenumbers = 0;
845 Aux->NumberLowPart = 0;
850 for (
unsigned i = 0; i < Data.
size(); i++) {
853 coffnamecpy(Symbol->Name.ShortName, RelocationName);
854 Symbol->Value = DataOffsets[i];
855 Symbol->SectionNumber = 2;
858 Symbol->NumberOfAuxSymbols = 0;
863 void WindowsResourceCOFFWriter::writeStringTable() {
865 auto COFFStringTable =
reinterpret_cast<void *
>(BufferStart + CurrentOffset);
866 memset(COFFStringTable, 0, 4);
869 void WindowsResourceCOFFWriter::writeDirectoryTree() {
872 std::queue<const WindowsResourceParser::TreeNode *> Queue;
873 Queue.push(&Resources);
878 std::vector<const WindowsResourceParser::TreeNode *> DataEntriesTreeOrder;
881 while (!Queue.empty()) {
882 auto CurrentNode = Queue.front();
890 auto &IDChildren = CurrentNode->getIDChildren();
891 auto &StringChildren = CurrentNode->getStringChildren();
898 for (
auto const &Child : StringChildren) {
901 Entry->Identifier.setNameOffset(
902 StringTableOffsets[Child.second->getStringIndex()]);
903 if (Child.second->checkIsDataNode()) {
904 Entry->Offset.DataEntryOffset = NextLevelOffset;
906 DataEntriesTreeOrder.push_back(Child.second.get());
908 Entry->Offset.SubdirOffset = NextLevelOffset + (1 << 31);
910 (Child.second->getStringChildren().size() +
911 Child.second->getIDChildren().size()) *
913 Queue.push(Child.second.get());
918 for (
auto const &Child : IDChildren) {
921 Entry->Identifier.ID = Child.first;
922 if (Child.second->checkIsDataNode()) {
923 Entry->Offset.DataEntryOffset = NextLevelOffset;
925 DataEntriesTreeOrder.push_back(Child.second.get());
927 Entry->Offset.SubdirOffset = NextLevelOffset + (1 << 31);
929 (Child.second->getStringChildren().size() +
930 Child.second->getIDChildren().size()) *
932 Queue.push(Child.second.get());
939 RelocationAddresses.resize(Data.
size());
941 for (
auto DataNodes : DataEntriesTreeOrder) {
944 RelocationAddresses[DataNodes->getDataIndex()] = CurrentRelativeOffset;
946 Entry->DataSize = Data[DataNodes->getDataIndex()].
size();
954 void WindowsResourceCOFFWriter::writeDirectoryStringTable() {
957 for (
auto &String : StringTable) {
961 auto *Start =
reinterpret_cast<UTF16 *
>(BufferStart + CurrentOffset);
963 CurrentOffset += Length *
sizeof(
UTF16);
964 TotalStringTableSize += Length *
sizeof(
UTF16) +
sizeof(
uint16_t);
967 alignTo(TotalStringTableSize,
sizeof(
uint32_t)) - TotalStringTableSize;
970 void WindowsResourceCOFFWriter::writeFirstSectionRelocations() {
976 for (
unsigned i = 0; i < Data.
size(); i++) {
980 Reloc->SymbolTableIndex = NextSymbolIndex++;
981 switch (MachineType) {
1008 return std::move(E);
1009 return Writer.
write(TimeDateStamp);
coff_symbol< support::ulittle16_t > coff_symbol16
const size_t WIN_RES_NULL_ENTRY_SIZE
support::ulittle16_t MajorVersion
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
An implementation of BinaryStream which holds its entire data set in a single contiguous buffer...
This class represents lattice values for constants.
Error readInteger(T &Dest)
Read an integer of the specified endianness into Dest and update the stream's offset.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
Expected< std::unique_ptr< MemoryBuffer > > writeWindowsResourceCOFF(llvm::COFF::MachineTypes MachineType, const WindowsResourceParser &Parser, uint32_t TimeDateStamp)
bool checkNameString() const
Error readWideString(ArrayRef< UTF16 > &Dest)
Similar to readCString, however read a null-terminated UTF16 string instead.
StringRef getFileName() const
#define UNWRAP_OR_RETURN(Name, Expr)
auto formatv(const char *Fmt, Ts &&... Vals) -> formatv_object< decltype(std::make_tuple(detail::build_format_adapter(std::forward< Ts >(Vals))...))>
No complex type; simple scalar variable.
constexpr bool IsBigEndianHost
static std::string makeDuplicateResourceError(const ResourceEntryRef &Entry, StringRef File1, StringRef File2)
Machine is based on a 32bit word architecture.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
const uint32_t SECTION_ALIGNMENT
void write16le(void *P, uint16_t V)
support::ulittle16_t NumberOfNameEntries
const Children< uint32_t > & getIDChildren() const
The access may reference the value stored in memory.
TypeID
Definitions of all of the base types for the Type system.
#define UNI_UTF16_BYTE_ORDER_MARK_SWAPPED
Tagged union holding either a T or a Error.
uint32_t getOffset() const
uint16_t getNameID() const
static void coffnamecpy(char(&Dest)[COFF::NameSize], StringRef Src)
static std::unique_ptr< WritableMemoryBuffer > getNewMemBuffer(size_t Size, const Twine &BufferName="")
Allocate a new zero-initialized MemoryBuffer of the specified size.
LLVM_NODISCARD size_t size() const
size - Get the string size.
static void printStringOrID(const WindowsResourceParser::StringOrID &S, raw_string_ostream &OS, bool IsType, bool IsID)
static Expected< std::unique_ptr< WindowsResource > > createWindowsResource(MemoryBufferRef Source)
Expected< ResourceEntryRef > getHeadEntry()
Expected< StringRef > getContents(const coff_resource_data_entry &Entry)
uint16_t getMinorVersion() const
const uint32_t MIN_HEADER_SIZE
uint32_t getCharacteristics() const
std::unique_ptr< MemoryBuffer > write(uint32_t TimeDateStamp)
support::ulittle16_t NumberOfIDEntries
size_t getBufferSize() const
WindowsResourceCOFFWriter(COFF::MachineTypes MachineType, const WindowsResourceParser &Parser, Error &E)
The instances of the Type class are immutable: once they are created, they are never changed...
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Expected< const coff_resource_data_entry & > getEntryData(const coff_resource_dir_entry &Entry)
support::ulittle16_t MinorVersion
ArrayRef< uint8_t > getData() const
ArrayRef< UTF16 > getTypeString() const
static Error readStringOrId(BinaryStreamReader &Reader, uint16_t &ID, ArrayRef< UTF16 > &Str, bool &IsString)
static void write(bool isBE, void *P, T V)
void printTree(raw_ostream &OS) const
void consumeError(Error Err)
Consume a Error without doing anything.
support::ulittle32_t VirtualAddress
std::string & str()
Flushes the stream contents to the target string and returns the string's reference.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Error moveNext(bool &End)
void setOffset(uint32_t Off)
const ArrayRef< std::vector< UTF16 > > getStringTable() const
static ErrorSuccess success()
Create a success value.
const uint32_t WIN_RES_HEADER_ALIGNMENT
const ArrayRef< std::vector< uint8_t > > getData() const
Expected< const coff_resource_dir_table & > getEntrySubDir(const coff_resource_dir_entry &Entry)
bool checkTypeString() const
Expected< ArrayRef< UTF16 > > getEntryNameString(const coff_resource_dir_entry &Entry)
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
void cleanUpManifests(std::vector< std::string > &Duplicates)
uint16_t getMajorVersion() const
StringRef getBufferIdentifier() const
Expected< const coff_resource_dir_entry & > getTableEntry(const coff_resource_dir_table &Table, uint32_t Index)
bool convertUTF16ToUTF8String(ArrayRef< char > SrcBytes, std::string &Out)
Converts a stream of raw bytes assumed to be UTF16 into a UTF8 std::string.
const size_t WIN_RES_MAGIC_SIZE
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
static void writeSymbolTable(raw_ostream &Out, object::Archive::Kind Kind, bool Deterministic, ArrayRef< MemberData > Members, StringRef StringTable)
Expected< const coff_resource_dir_table & > getBaseTable()
uint32_t getTreeSize() const
WindowsResourceParser(bool MinGW=false)
Error parse(WindowsResource *WR, std::vector< std::string > &Duplicates)
COFFYAML::WeakExternalCharacteristics Characteristics
support::ulittle32_t TimeDateStamp
static void writeStringTable(std::vector< uint8_t > &B, ArrayRef< const std::string > Strings)
uint32_t getLength() override
Return the number of bytes of data in this stream.
static bool convertUTF16LEToUTF8String(ArrayRef< UTF16 > Src, std::string &Out)
ArrayRef< UTF16 > getNameString() const
void printResourceTypeName(uint16_t TypeID, raw_ostream &OS)
const std::string to_string(const T &Value)
uint16_t getTypeID() const
support::ulittle32_t Length
const uint32_t WIN_RES_DATA_ALIGNMENT
LLVM_NODISCARD const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A raw_ostream that writes to an std::string.
#define RETURN_IF_ERROR(X)
uint16_t getLanguage() const
Lightweight error class with error context and mandatory checking.
#define UNWRAP_REF_OR_RETURN(Name, Expr)
This class implements an extremely fast bulk output stream that can only output to a stream...
void print(ScopedPrinter &Writer, StringRef Name) const
Provides read only access to a subclass of BinaryStream.
StringRef - Represent a constant reference to a string, i.e.
friend class ResourceEntryRef
support::ulittle32_t Characteristics
const TreeNode & getTree() const
OutputIt copy(R &&Range, OutputIt Out)
const Children< std::string > & getStringChildren() const
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.