-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finish task and publish 2.7.710.0 version
Finish task and publish 2.7.710.0 version
- Loading branch information
1 parent
bd11ebb
commit 4bcad96
Showing
56 changed files
with
2,738 additions
and
302 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Collections.Generic; | ||
using WindowsTools.Extensions.PriExtract; | ||
|
||
namespace WindowsTools.Extensions.DataType.Enums | ||
{ | ||
public class Decision | ||
{ | ||
public ushort Index { get; set; } | ||
|
||
public IReadOnlyList<QualifierSet> QualifierSetsList { get; set; } | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
WindowsTools/Extensions/DataType/Enums/PriDescriptorFlags.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
|
||
namespace WindowsTools.Extensions.DataType.Enums | ||
{ | ||
[Flags] | ||
public enum PriDescriptorFlags : ushort | ||
{ | ||
AutoMerge = 1, | ||
IsDeploymentMergeable = 2, | ||
IsDeploymentMergeResult = 4, | ||
IsAutomergeMergeResult = 8 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace WindowsTools.Extensions.DataType.Enums | ||
{ | ||
public enum QualifierType | ||
{ | ||
Language, | ||
Contrast, | ||
Scale, | ||
HomeRegion, | ||
TargetSize, | ||
LayoutDirection, | ||
Theme, | ||
AlternateForm, | ||
DXFeatureLevel, | ||
Configuration, | ||
DeviceFamily, | ||
Custom | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
WindowsTools/Extensions/DataType/Enums/ResourceValueType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace WindowsTools.Extensions.DataType.Enums | ||
{ | ||
public enum ResourceValueType | ||
{ | ||
UnicodeString, | ||
UnicodePath, | ||
EmbeddedData, | ||
AsciiString, | ||
Utf8String, | ||
AsciiPath, | ||
Utf8Path | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
WindowsTools/Extensions/DataType/Methods/BinaryReaderExtension.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System.IO; | ||
using System.Text; | ||
|
||
namespace WindowsTools.Extensions.DataType.Methods | ||
{ | ||
/// <summary> | ||
/// BinaryReader 类的扩展方法 | ||
/// </summary> | ||
public static class BinaryReaderExtension | ||
{ | ||
public static void ExpectUInt16(this BinaryReader reader, ushort expectedValue) | ||
{ | ||
if (reader.ReadUInt16() != expectedValue) | ||
{ | ||
throw new InvalidDataException("Unexpected value read."); | ||
} | ||
} | ||
|
||
public static void ExpectUInt32(this BinaryReader reader, uint expectedValue) | ||
{ | ||
if (reader.ReadUInt32() != expectedValue) | ||
{ | ||
throw new InvalidDataException("Unexpected value read."); | ||
} | ||
} | ||
|
||
public static void ExpectString(this BinaryReader reader, string s) | ||
{ | ||
if (new string(reader.ReadChars(s.Length)) != s) | ||
{ | ||
throw new InvalidDataException("Unexpected value read."); | ||
} | ||
} | ||
|
||
public static string ReadString(this BinaryReader reader, Encoding encoding, int length) | ||
{ | ||
using BinaryReader r = new(reader.BaseStream, encoding, true); | ||
return new string(r.ReadChars(length)); | ||
} | ||
|
||
public static string ReadNullTerminatedString(this BinaryReader reader, Encoding encoding) | ||
{ | ||
using BinaryReader binaryReader = new(reader.BaseStream, encoding, true); | ||
StringBuilder result = new(); | ||
char c; | ||
while ((c = binaryReader.ReadChar()) != '\0') | ||
{ | ||
result.Append(c); | ||
} | ||
return result.ToString(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace WindowsTools.Extensions.PriExtract | ||
{ | ||
public class ByteSpan | ||
{ | ||
public long Offset { get; set; } | ||
|
||
public uint Length { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using WindowsTools.Extensions.DataType.Enums; | ||
|
||
namespace WindowsTools.Extensions.PriExtract | ||
{ | ||
public class Candidate | ||
{ | ||
public ushort QualifierSet { get; set; } | ||
|
||
public ResourceValueType Type { get; set; } | ||
|
||
public int? SourceFileIndex { get; set; } | ||
|
||
public Tuple<ushort, ushort> DataItemSectionAndIndex { get; set; } | ||
|
||
public ByteSpan Data { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using WindowsTools.Extensions.DataType.Enums; | ||
|
||
namespace WindowsTools.Extensions.PriExtract | ||
{ | ||
public class CandidateInfo | ||
{ | ||
public byte Type { get; set; } | ||
|
||
public ResourceValueType ResourceValueType { get; set; } | ||
|
||
public ushort SourceFileIndex { get; set; } | ||
|
||
public ushort DataItemIndex { get; set; } | ||
public ushort DataItemSection { get; set; } | ||
|
||
public ushort DataLength { get; set; } | ||
|
||
public uint DataOffset { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace WindowsTools.Extensions.PriExtract | ||
{ | ||
public class CandidateSet | ||
{ | ||
public Tuple<int, int> ResourceMapSectionAndIndex { get; set; } | ||
|
||
public ushort DecisionIndex { get; set; } | ||
|
||
public IReadOnlyList<Candidate> CandidatesList { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Text; | ||
using WindowsTools.Extensions.DataType.Methods; | ||
|
||
namespace WindowsTools.Extensions.PriExtract | ||
{ | ||
public class DataItemSection | ||
{ | ||
public uint SectionQualifier { get; private set; } | ||
|
||
public uint Flags { get; private set; } | ||
|
||
public uint SectionFlags { get; private set; } | ||
|
||
public uint SectionLength { get; private set; } | ||
|
||
public IReadOnlyList<ByteSpan> DataItemsList { get; private set; } | ||
|
||
public DataItemSection(string sectionIdentifier, BinaryReader binaryReader) | ||
{ | ||
if (new string(binaryReader.ReadChars(16)) != sectionIdentifier) | ||
{ | ||
throw new InvalidDataException("Unexpected section identifier."); | ||
} | ||
|
||
SectionQualifier = binaryReader.ReadUInt32(); | ||
Flags = binaryReader.ReadUInt16(); | ||
SectionFlags = binaryReader.ReadUInt16(); | ||
SectionLength = binaryReader.ReadUInt32(); | ||
binaryReader.ExpectUInt32(0); | ||
|
||
binaryReader.BaseStream.Seek(SectionLength - 16 - 24, SeekOrigin.Current); | ||
|
||
binaryReader.ExpectUInt32(0xDEF5FADE); | ||
binaryReader.ExpectUInt32(SectionLength); | ||
|
||
binaryReader.BaseStream.Seek(-8 - (SectionLength - 16 - 24), SeekOrigin.Current); | ||
|
||
using SubStream subStream = new(binaryReader.BaseStream, binaryReader.BaseStream.Position, (int)SectionLength - 16 - 24); | ||
using BinaryReader subBinaryReader = new(subStream, Encoding.ASCII); | ||
|
||
long sectionPosition = (binaryReader.BaseStream as SubStream)?.SubStreamPosition ?? 0; | ||
|
||
binaryReader.ExpectUInt32(0); | ||
ushort numStrings = binaryReader.ReadUInt16(); | ||
ushort numBlobs = binaryReader.ReadUInt16(); | ||
uint totalDataLength = binaryReader.ReadUInt32(); | ||
|
||
List<ByteSpan> dataItemsList = new(numStrings + numBlobs); | ||
|
||
long dataStartOffset = binaryReader.BaseStream.Position + | ||
numStrings * 2 * sizeof(ushort) + numBlobs * 2 * sizeof(uint); | ||
|
||
for (int i = 0; i < numStrings; i++) | ||
{ | ||
ushort stringOffset = binaryReader.ReadUInt16(); | ||
ushort stringLength = binaryReader.ReadUInt16(); | ||
dataItemsList.Add(new ByteSpan() | ||
{ | ||
Offset = sectionPosition + dataStartOffset + stringOffset, | ||
Length = stringLength | ||
}); | ||
} | ||
|
||
for (int i = 0; i < numBlobs; i++) | ||
{ | ||
uint blobOffset = binaryReader.ReadUInt32(); | ||
uint blobLength = binaryReader.ReadUInt32(); | ||
dataItemsList.Add(new ByteSpan() | ||
{ | ||
Offset = sectionPosition + dataStartOffset + blobOffset, | ||
Length = blobLength | ||
}); | ||
} | ||
|
||
DataItemsList = dataItemsList; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace WindowsTools.Extensions.PriExtract | ||
{ | ||
public class DecisionInfo | ||
{ | ||
public ushort FirstQualifierSetIndexIndex { get; set; } | ||
|
||
public ushort NumQualifierSetsInDecision { get; set; } | ||
} | ||
} |
Oops, something went wrong.