0.604.0.6040508

This commit is contained in:
Max
2023-11-28 21:07:30 -06:00
parent 9f4f3bbf63
commit 4bac4d4f3e
17 changed files with 6548 additions and 5027 deletions

View File

@ -39,7 +39,7 @@ namespace RobloxFiles
public IReadOnlyDictionary<uint, SharedString> SharedStrings => SSTR?.Strings;
public bool HasSignatures => (SIGN != null);
public IReadOnlyList<Signature> Signatures => SIGN?.Signatures;
public IReadOnlyList<RbxSignature> Signatures => SIGN?.Signatures;
public BinaryRobloxFile()
{

View File

@ -74,7 +74,7 @@ namespace RobloxFiles.BinaryFormat.Chunks
var prop = new Property(instance, this);
props[i] = prop;
instance.AddProperty(ref prop);
instance.AddProperty(prop);
}
// Setup some short-hand functions for actions used during the read procedure.
@ -103,7 +103,7 @@ namespace RobloxFiles.BinaryFormat.Chunks
string value = reader.ReadString();
// Leave an access point for the original byte sequence, in case this is a BinaryString.
// This will allow the developer to read the sequence without any mangling from C# strings.
// This will allow the developer to read the sequence without any mangling from UTF-8.
byte[] buffer = reader.GetLastStringBuffer();
props[i].RawBuffer = buffer;
@ -132,6 +132,8 @@ namespace RobloxFiles.BinaryFormat.Chunks
if (memberType == typeof(byte[]))
result = buffer;
else if (memberType == typeof(ProtectedString) && File.HasSignatures)
result = new ProtectedString(buffer); // Very likely compiled.
return result;
}
@ -661,6 +663,12 @@ namespace RobloxFiles.BinaryFormat.Chunks
break;
}
case PropertyType.SecurityCapabilities:
{
var capabilities = reader.ReadInterleaved(instCount, BitConverter.ToUInt64);
readProperties(i => capabilities[i]);
break;
}
default:
{
RobloxFile.LogError($"Unhandled property type: {Type} in {this}!");
@ -1301,6 +1309,20 @@ namespace RobloxFiles.BinaryFormat.Chunks
break;
}
case PropertyType.SecurityCapabilities:
{
// FIXME: Verify this is correct once we know what SecurityCapabilities actually does.
var capabilities = new List<ulong>();
props.ForEach(prop =>
{
var value = prop.CastValue<ulong>();
capabilities.Add(value);
});
writer.WriteInterleaved(capabilities);
break;
}
default:
{
RobloxFile.LogError($"Unhandled property type: {Type} in {this}!");

View File

@ -3,35 +3,37 @@ using System.Text;
namespace RobloxFiles.BinaryFormat.Chunks
{
public struct Signature
public enum RbxSignatureType
{
public int Version;
public long Id;
Ed25519
}
public int Length;
public byte[] Data;
public struct RbxSignature
{
public RbxSignatureType SignatureType;
public long PublicKeyId;
public byte[] Value;
}
public class SIGN : IBinaryFileChunk
{
public Signature[] Signatures;
public RbxSignature[] Signatures;
public void Load(BinaryRobloxFileReader reader)
{
int numSignatures = reader.ReadInt32();
Signatures = new Signature[numSignatures];
Signatures = new RbxSignature[numSignatures];
for (int i = 0; i < numSignatures; i++)
{
var signature = new Signature
var signature = new RbxSignature
{
Version = reader.ReadInt32(),
Id = reader.ReadInt64(),
Length = reader.ReadInt32(),
SignatureType = (RbxSignatureType)reader.ReadInt32(),
PublicKeyId = reader.ReadInt64(),
};
signature.Data = reader.ReadBytes(signature.Length);
var length = reader.ReadInt32();
signature.Value = reader.ReadBytes(length);
Signatures[i] = signature;
}
@ -46,13 +48,12 @@ namespace RobloxFiles.BinaryFormat.Chunks
for (int i = 0; i < Signatures.Length; i++)
{
var signature = Signatures[i];
signature.Length = signature.Data.Length;
writer.Write(signature.Version);
writer.Write(signature.Id);
writer.Write((int)signature.SignatureType);
writer.Write(signature.PublicKeyId);
writer.Write(signature.Length);
writer.Write(signature.Data);
writer.Write(signature.Value.Length);
writer.Write(signature.Value);
}
}
@ -66,17 +67,14 @@ namespace RobloxFiles.BinaryFormat.Chunks
var signature = Signatures[i];
builder.AppendLine($"## Signature {i}");
var version = signature.Version;
builder.AppendLine($"- Version: {version}");
var version = Enum.GetName(typeof(RbxSignatureType), signature.SignatureType);
builder.AppendLine($"- SignatureType: {version}");
var id = signature.Id;
builder.AppendLine($"- Id: {id}");
var publicKeyId = signature.PublicKeyId;
builder.AppendLine($"- PublicKeyId: {publicKeyId}");
var length = signature.Length;
builder.AppendLine($"- Length: {length}");
var data = Convert.ToBase64String(signature.Data);
builder.AppendLine($"- Data: {data}");
var value = Convert.ToBase64String(signature.Value);
builder.AppendLine($"- Value: {value}");
}
}
}