22using namespace object;
27#define RETURN_IF_ERROR(X) \
31#define UNWRAP_REF_OR_RETURN(Name, Expr) \
32 auto Name##OrErr = Expr; \
34 return Name##OrErr.takeError(); \
35 const auto &Name = *Name##OrErr;
37#define UNWRAP_OR_RETURN(Name, Expr) \
38 auto Name##OrErr = Expr; \
40 return Name##OrErr.takeError(); \
41 auto Name = *Name##OrErr;
60 return make_error<GenericBinaryError>(
61 Source.getBufferIdentifier() +
": too small to be a resource file",
62 object_error::invalid_file_type);
64 return std::move(Ret);
69 return make_error<EmptyResError>(
getFileName() +
" contains no entries",
70 object_error::unexpected_eof);
76 : Reader(
Ref), Owner(Owner) {}
81 if (
auto E =
Ref.loadNext())
101 IsString = IDFlag != 0xffff;
114Error ResourceEntryRef::loadNext() {
119 return make_error<GenericBinaryError>(Owner->
getFileName() +
120 ": header size too small",
139 : Root(
false), MinGW(MinGW) {}
143 case 1:
OS <<
"CURSOR (ID 1)";
break;
144 case 2:
OS <<
"BITMAP (ID 2)";
break;
145 case 3:
OS <<
"ICON (ID 3)";
break;
146 case 4:
OS <<
"MENU (ID 4)";
break;
147 case 5:
OS <<
"DIALOG (ID 5)";
break;
148 case 6:
OS <<
"STRINGTABLE (ID 6)";
break;
149 case 7:
OS <<
"FONTDIR (ID 7)";
break;
150 case 8:
OS <<
"FONT (ID 8)";
break;
151 case 9:
OS <<
"ACCELERATOR (ID 9)";
break;
152 case 10:
OS <<
"RCDATA (ID 10)";
break;
153 case 11:
OS <<
"MESSAGETABLE (ID 11)";
break;
154 case 12:
OS <<
"GROUP_CURSOR (ID 12)";
break;
155 case 14:
OS <<
"GROUP_ICON (ID 14)";
break;
156 case 16:
OS <<
"VERSIONINFO (ID 16)";
break;
157 case 17:
OS <<
"DLGINCLUDE (ID 17)";
break;
158 case 19:
OS <<
"PLUGPLAY (ID 19)";
break;
159 case 20:
OS <<
"VXD (ID 20)";
break;
160 case 21:
OS <<
"ANICURSOR (ID 21)";
break;
161 case 22:
OS <<
"ANIICON (ID 22)";
break;
162 case 23:
OS <<
"HTML (ID 23)";
break;
163 case 24:
OS <<
"MANIFEST (ID 24)";
break;
164 default:
OS <<
"ID " <<
TypeID;
break;
172 std::vector<UTF16> EndianCorrectedSrc;
173 EndianCorrectedSrc.resize(Src.size() + 1);
174 llvm::copy(Src, EndianCorrectedSrc.begin() + 1);
184 OS <<
"duplicate resource:";
187 if (Entry.checkTypeString()) {
190 UTF8 =
"(failed conversion from UTF16)";
191 OS <<
'\"' <<
UTF8 <<
'\"';
196 if (Entry.checkNameString()) {
199 UTF8 =
"(failed conversion from UTF16)";
200 OS <<
'\"' <<
UTF8 <<
'\"';
202 OS <<
"ID " << Entry.getNameID();
205 OS <<
"/language " << Entry.getLanguage() <<
", in " << File1 <<
" and in "
216 UTF8 =
"(failed conversion from UTF16)";
217 OS <<
'\"' <<
UTF8 <<
'\"';
227 const std::vector<WindowsResourceParser::StringOrID> &Context,
232 OS <<
"duplicate resource:";
248 OS <<
", in " << File1 <<
" and in " << File2;
262 std::vector<std::string> &Duplicates) {
263 auto TypeIt = Root.IDChildren.find( 24);
264 if (TypeIt == Root.IDChildren.end())
267 TreeNode *TypeNode = TypeIt->second.get();
269 TypeNode->IDChildren.find( 1);
270 if (NameIt == TypeNode->IDChildren.end())
273 TreeNode *NameNode = NameIt->second.get();
274 if (NameNode->IDChildren.size() <= 1)
279 auto LangZeroIt = NameNode->IDChildren.find(0);
280 if (LangZeroIt != NameNode->IDChildren.end() &&
281 LangZeroIt->second->IsDataNode) {
282 uint32_t RemovedIndex = LangZeroIt->second->DataIndex;
283 NameNode->IDChildren.erase(LangZeroIt);
284 Data.erase(Data.begin() + RemovedIndex);
285 Root.shiftDataIndexDown(RemovedIndex);
288 if (NameNode->IDChildren.size() <= 1)
293 auto FirstIt = NameNode->IDChildren.begin();
294 uint32_t FirstLang = FirstIt->first;
295 TreeNode *FirstNode = FirstIt->second.get();
296 auto LastIt = NameNode->IDChildren.rbegin();
298 TreeNode *LastNode = LastIt->second.get();
299 Duplicates.push_back(
300 (
"duplicate non-default manifests with languages " +
Twine(FirstLang) +
301 " in " + InputFilenames[FirstNode->Origin] +
" and " +
Twine(LastLang) +
302 " in " + InputFilenames[LastNode->Origin])
310bool WindowsResourceParser::shouldIgnoreDuplicate(
312 return MinGW && !Entry.checkTypeString() &&
313 Entry.getTypeID() == 24 &&
314 !Entry.checkNameString() &&
315 Entry.getNameID() == 1 &&
316 Entry.getLanguage() == 0;
319bool WindowsResourceParser::shouldIgnoreDuplicate(
320 const std::vector<StringOrID> &Context)
const {
328 std::vector<std::string> &Duplicates) {
331 auto E = EntryOrErr.takeError();
346 uint32_t Origin = InputFilenames.size();
347 InputFilenames.push_back(std::string(WR->
getFileName()));
352 bool IsNewNode = Root.addEntry(Entry, Origin, Data, StringTable, Node);
354 if (!shouldIgnoreDuplicate(Entry))
356 Entry, InputFilenames[Node->Origin], WR->
getFileName()));
366 std::vector<std::string> &Duplicates) {
368 uint32_t Origin = InputFilenames.size();
369 InputFilenames.push_back(std::string(Filename));
370 std::vector<StringOrID>
Context;
371 return addChildren(Root, RSR, BaseTable, Origin,
Context, Duplicates);
376 Root.
print(Writer,
"Resource Tree");
379bool WindowsResourceParser::TreeNode::addEntry(
381 std::vector<std::vector<uint8_t>> &
Data,
382 std::vector<std::vector<UTF16>> &StringTable, TreeNode *&Result) {
383 TreeNode &TypeNode = addTypeNode(Entry, StringTable);
384 TreeNode &NameNode = TypeNode.addNameNode(Entry, StringTable);
385 return NameNode.addLanguageNode(Entry, Origin, Data, Result);
388Error WindowsResourceParser::addChildren(TreeNode &Node,
392 std::vector<StringOrID> &Context,
393 std::vector<std::string> &Duplicates) {
400 if (Entry.Offset.isSubDir()) {
405 Child = &Node.addNameChild(NameString, StringTable);
406 Context.push_back(StringOrID(NameString));
408 Child = &
Node.addIDChild(Entry.Identifier.ID);
409 Context.push_back(StringOrID(Entry.Identifier.ID));
414 addChildren(*Child, RSR, NextTable, Origin, Context, Duplicates);
424 "unexpected string key for data object");
429 Context.push_back(StringOrID(Entry.Identifier.ID));
432 Origin, Data.size(), Child);
436 reinterpret_cast<const uint8_t *
>(Contents.data()),
439 if (!shouldIgnoreDuplicate(Context))
441 Context, InputFilenames[Child->Origin], InputFilenames.back()));
450WindowsResourceParser::TreeNode::TreeNode(
uint32_t StringIndex)
451 : StringIndex(StringIndex) {}
453WindowsResourceParser::TreeNode::TreeNode(
uint16_t MajorVersion,
457 : IsDataNode(
true), DataIndex(DataIndex), MajorVersion(MajorVersion),
461std::unique_ptr<WindowsResourceParser::TreeNode>
462WindowsResourceParser::TreeNode::createStringNode(
uint32_t Index) {
463 return std::unique_ptr<TreeNode>(
new TreeNode(
Index));
466std::unique_ptr<WindowsResourceParser::TreeNode>
467WindowsResourceParser::TreeNode::createIDNode() {
468 return std::unique_ptr<TreeNode>(
new TreeNode(0));
471std::unique_ptr<WindowsResourceParser::TreeNode>
472WindowsResourceParser::TreeNode::createDataNode(
uint16_t MajorVersion,
477 return std::unique_ptr<TreeNode>(
new TreeNode(
483 std::vector<std::vector<UTF16>> &StringTable) {
484 if (Entry.checkTypeString())
485 return addNameChild(Entry.getTypeString(), StringTable);
487 return addIDChild(Entry.getTypeID());
492 std::vector<std::vector<UTF16>> &StringTable) {
493 if (Entry.checkNameString())
494 return addNameChild(Entry.getNameString(), StringTable);
496 return addIDChild(Entry.getNameID());
499bool WindowsResourceParser::TreeNode::addLanguageNode(
501 std::vector<std::vector<uint8_t>> &Data, TreeNode *&Result) {
502 bool Added = addDataChild(Entry.getLanguage(), Entry.getMajorVersion(),
503 Entry.getMinorVersion(), Entry.getCharacteristics(),
504 Origin, Data.size(), Result);
506 Data.push_back(Entry.getData());
510bool WindowsResourceParser::TreeNode::addDataChild(
514 auto NewChild = createDataNode(MajorVersion, MinorVersion,
Characteristics,
516 auto ElementInserted = IDChildren.emplace(
ID, std::move(NewChild));
517 Result = ElementInserted.first->second.get();
518 return ElementInserted.second;
523 auto Child = IDChildren.find(
ID);
524 if (Child == IDChildren.end()) {
525 auto NewChild = createIDNode();
527 IDChildren.emplace(
ID, std::move(NewChild));
530 return *(Child->second);
534 ArrayRef<UTF16> NameRef, std::vector<std::vector<UTF16>> &StringTable) {
535 std::string NameString;
538 auto Child = StringChildren.find(NameString);
539 if (Child == StringChildren.end()) {
540 auto NewChild = createStringNode(StringTable.size());
541 StringTable.push_back(NameRef);
543 StringChildren.emplace(NameString, std::move(NewChild));
546 return *(Child->second);
552 for (
auto const &Child : StringChildren) {
553 Child.second->print(Writer, Child.first);
555 for (
auto const &Child : IDChildren) {
556 Child.second->print(Writer,
to_string(Child.first));
564 uint32_t Size = (IDChildren.size() + StringChildren.size()) *
577 for (
auto const &Child : StringChildren) {
578 Size += Child.second->getTreeSize();
580 for (
auto const &Child : IDChildren) {
581 Size += Child.second->getTreeSize();
588void WindowsResourceParser::TreeNode::shiftDataIndexDown(
uint32_t Index) {
589 if (IsDataNode && DataIndex >=
Index) {
592 for (
auto &Child : IDChildren)
593 Child.second->shiftDataIndexDown(
Index);
594 for (
auto &Child : StringChildren)
595 Child.second->shiftDataIndexDown(
Index);
606 void performFileLayout();
607 void performSectionOneLayout();
608 void performSectionTwoLayout();
609 void writeCOFFHeader(
uint32_t TimeDateStamp);
610 void writeFirstSectionHeader();
611 void writeSecondSectionHeader();
612 void writeFirstSection();
613 void writeSecondSection();
616 void writeDirectoryTree();
617 void writeDirectoryStringTable();
618 void writeFirstSectionRelocations();
619 std::unique_ptr<WritableMemoryBuffer> OutputBuffer;
633 std::vector<uint32_t> StringTableOffsets;
634 std::vector<uint32_t> DataOffsets;
635 std::vector<uint32_t> RelocationAddresses;
646 FileSize,
"internal .obj file created from .res files");
649void WindowsResourceCOFFWriter::performFileLayout() {
656 performSectionOneLayout();
657 performSectionTwoLayout();
660 SymbolTableOffset = FileSize;
668void WindowsResourceCOFFWriter::performSectionOneLayout() {
669 SectionOneOffset = FileSize;
672 uint32_t CurrentStringOffset = SectionOneSize;
674 for (
auto const &
String : StringTable) {
675 StringTableOffsets.push_back(CurrentStringOffset);
677 CurrentStringOffset += StringSize;
678 TotalStringTableSize += StringSize;
683 SectionOneRelocations = FileSize + SectionOneSize;
684 FileSize += SectionOneSize;
690void WindowsResourceCOFFWriter::performSectionTwoLayout() {
693 SectionTwoOffset = FileSize;
695 for (
auto const &Entry : Data) {
696 DataOffsets.push_back(SectionTwoSize);
699 FileSize += SectionTwoSize;
703std::unique_ptr<MemoryBuffer>
705 BufferStart = OutputBuffer->getBufferStart();
707 writeCOFFHeader(TimeDateStamp);
708 writeFirstSectionHeader();
709 writeSecondSectionHeader();
711 writeSecondSection();
715 return std::move(OutputBuffer);
722 "Src is larger than COFF::NameSize");
724 "Dest not zeroed upon initialization");
725 memcpy(Dest, Src.data(), Src.size());
728void WindowsResourceCOFFWriter::writeCOFFHeader(
uint32_t TimeDateStamp) {
731 Header->Machine = MachineType;
732 Header->NumberOfSections = 2;
733 Header->TimeDateStamp = TimeDateStamp;
734 Header->PointerToSymbolTable = SymbolTableOffset;
736 Header->NumberOfSymbols = Data.size() + 5;
737 Header->SizeOfOptionalHeader = 0;
742void 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;
760void 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;
778void WindowsResourceCOFFWriter::writeFirstSection() {
782 writeDirectoryTree();
783 writeDirectoryStringTable();
784 writeFirstSectionRelocations();
789void WindowsResourceCOFFWriter::writeSecondSection() {
791 for (
auto const &RawDataEntry : Data) {
792 llvm::copy(RawDataEntry, BufferStart + CurrentOffset);
799void 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++) {
854 Symbol->Value = DataOffsets[i];
855 Symbol->SectionNumber = 2;
858 Symbol->NumberOfAuxSymbols = 0;
863void WindowsResourceCOFFWriter::writeStringTable() {
865 auto COFFStringTable =
reinterpret_cast<void *
>(BufferStart + CurrentOffset);
866 memset(COFFStringTable, 0, 4);
869void 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 (
const auto *DataNodes : DataEntriesTreeOrder) {
944 RelocationAddresses[DataNodes->getDataIndex()] = CurrentRelativeOffset;
946 Entry->DataSize = Data[DataNodes->getDataIndex()].size();
954void WindowsResourceCOFFWriter::writeDirectoryStringTable() {
957 for (
auto &
String : StringTable) {
961 auto *Start =
reinterpret_cast<UTF16 *
>(BufferStart + CurrentOffset);
967 alignTo(TotalStringTableSize,
sizeof(
uint32_t)) - TotalStringTableSize;
970void WindowsResourceCOFFWriter::writeFirstSectionRelocations() {
976 for (
unsigned i = 0; i < Data.size(); i++) {
980 Reloc->SymbolTableIndex = NextSymbolIndex++;
981 switch (MachineType) {
1010 return std::move(
E);
1011 return Writer.
write(TimeDateStamp);
static void writeSymbolTable(raw_ostream &Out, object::Archive::Kind Kind, bool Deterministic, ArrayRef< MemberData > Members, StringRef StringTable, uint64_t MembersOffset, unsigned NumSyms, uint64_t PrevMemberOffset=0, uint64_t NextMemberOffset=0, bool Is64Bit=false)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define RETURN_IF_ERROR(Expr)
COFFYAML::WeakExternalCharacteristics Characteristics
static Expected< StringRef > getFileName(const DebugStringTableSubsectionRef &Strings, const DebugChecksumsSubsectionRef &Checksums, uint32_t FileID)
#define UNI_UTF16_BYTE_ORDER_MARK_SWAPPED
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
#define UNWRAP_OR_RETURN(Name, Expr)
#define UNWRAP_REF_OR_RETURN(Name, Expr)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
An implementation of BinaryStream which holds its entire data set in a single contiguous buffer.
Provides read only access to a subclass of BinaryStream.
Error readObject(const T *&Dest)
Get a pointer to an object of type T from the underlying stream, as if by memcpy, and store the resul...
Error readWideString(ArrayRef< UTF16 > &Dest)
Similar to readCString, however read a null-terminated UTF16 string instead.
Error readInteger(T &Dest)
Read an integer of the specified endianness into Dest and update the stream's offset.
uint64_t bytesRemaining() const
uint64_t getOffset() const
Error padToAlignment(uint32_t Align)
void setOffset(uint64_t Off)
Error readArray(ArrayRef< T > &Array, uint32_t NumElements)
Get a reference to a NumElements element array of objects of type T from the underlying stream as if ...
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
StringRef - Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
TypeID
Definitions of all of the base types for the Type system.
static std::unique_ptr< WritableMemoryBuffer > getNewMemBuffer(size_t Size, const Twine &BufferName="")
Allocate a new zero-initialized MemoryBuffer of the specified size.
StringRef getFileName() const
Error moveNext(bool &End)
Expected< const coff_resource_dir_table & > getBaseTable()
Expected< const coff_resource_dir_table & > getEntrySubDir(const coff_resource_dir_entry &Entry)
Expected< const coff_resource_data_entry & > getEntryData(const coff_resource_dir_entry &Entry)
Expected< ArrayRef< UTF16 > > getEntryNameString(const coff_resource_dir_entry &Entry)
Expected< StringRef > getContents(const coff_resource_data_entry &Entry)
Expected< const coff_resource_dir_entry & > getTableEntry(const coff_resource_dir_table &Table, uint32_t Index)
WindowsResourceCOFFWriter(COFF::MachineTypes MachineType, const WindowsResourceParser &Parser, Error &E)
std::unique_ptr< MemoryBuffer > write(uint32_t TimeDateStamp)
const Children< std::string > & getStringChildren() const
uint32_t getTreeSize() const
const Children< uint32_t > & getIDChildren() const
void print(ScopedPrinter &Writer, StringRef Name) const
void cleanUpManifests(std::vector< std::string > &Duplicates)
const TreeNode & getTree() const
void printTree(raw_ostream &OS) const
ArrayRef< std::vector< uint8_t > > getData() const
WindowsResourceParser(bool MinGW=false)
ArrayRef< std::vector< UTF16 > > getStringTable() const
Error parse(WindowsResource *WR, std::vector< std::string > &Duplicates)
Expected< ResourceEntryRef > getHeadEntry()
static Expected< std::unique_ptr< WindowsResource > > createWindowsResource(MemoryBufferRef Source)
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an std::string.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ IMAGE_FILE_MACHINE_ARM64
@ IMAGE_FILE_MACHINE_AMD64
@ IMAGE_FILE_MACHINE_ARM64EC
@ IMAGE_FILE_MACHINE_I386
@ IMAGE_FILE_MACHINE_ARM64X
@ IMAGE_FILE_MACHINE_ARMNT
@ IMAGE_SCN_CNT_INITIALIZED_DATA
@ IMAGE_REL_ARM64_ADDR32NB
@ IMAGE_REL_AMD64_ADDR32NB
@ IMAGE_SYM_CLASS_STATIC
Static.
@ IMAGE_FILE_32BIT_MACHINE
Machine is based on a 32bit word architecture.
@ IMAGE_SYM_DTYPE_NULL
No complex type; simple scalar variable.
const uint32_t MIN_HEADER_SIZE
static void printStringOrID(const WindowsResourceParser::StringOrID &S, raw_string_ostream &OS, bool IsType, bool IsID)
Expected< std::unique_ptr< MemoryBuffer > > writeWindowsResourceCOFF(llvm::COFF::MachineTypes MachineType, const WindowsResourceParser &Parser, uint32_t TimeDateStamp)
const size_t WIN_RES_NULL_ENTRY_SIZE
const uint32_t WIN_RES_DATA_ALIGNMENT
void printResourceTypeName(uint16_t TypeID, raw_ostream &OS)
const uint32_t WIN_RES_HEADER_ALIGNMENT
static std::string makeDuplicateResourceError(const ResourceEntryRef &Entry, StringRef File1, StringRef File2)
static void coffnamecpy(char(&Dest)[COFF::NameSize], StringRef Src)
const size_t WIN_RES_MAGIC_SIZE
static void writeStringTable(std::vector< uint8_t > &B, ArrayRef< const std::string > Strings)
static Error readStringOrId(BinaryStreamReader &Reader, uint16_t &ID, ArrayRef< UTF16 > &Str, bool &IsString)
static bool convertUTF16LEToUTF8String(ArrayRef< UTF16 > Src, std::string &Out)
coff_symbol< support::ulittle16_t > coff_symbol16
const uint32_t SECTION_ALIGNMENT
void write16le(void *P, uint16_t V)
constexpr bool IsBigEndianHost
This is an optimization pass for GlobalISel generic memory operations.
auto formatv(const char *Fmt, Ts &&... Vals) -> formatv_object< decltype(std::make_tuple(detail::build_format_adapter(std::forward< Ts >(Vals))...))>
std::string to_string(const T &Value)
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Error write(MCStreamer &Out, ArrayRef< std::string > Inputs, OnCuIndexOverflow OverflowOptValue)
bool convertUTF16ToUTF8String(ArrayRef< char > SrcBytes, std::string &Out)
Converts a stream of raw bytes assumed to be UTF16 into a UTF8 std::string.
@ Ref
The access may reference the value stored in memory.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
OutputIt copy(R &&Range, OutputIt Out)
void consumeError(Error Err)
Consume a Error without doing anything.
support::ulittle32_t Length
support::ulittle32_t VirtualAddress
support::ulittle16_t NumberOfNameEntries
support::ulittle32_t Characteristics
support::ulittle16_t NumberOfIDEntries
support::ulittle32_t TimeDateStamp
support::ulittle16_t MinorVersion
support::ulittle16_t MajorVersion