Add Stream resource type

This commit is contained in:
de4dot 2013-11-17 20:24:55 +01:00
parent 8521f7baac
commit b7eb39203a
4 changed files with 8 additions and 0 deletions

View File

@ -109,6 +109,7 @@ namespace de4dot.code.resources {
break;
case ResourceTypeCode.ByteArray:
case ResourceTypeCode.Stream:
var ary = (byte[])data;
writer.Write(ary.Length);
writer.Write(ary);
@ -143,6 +144,7 @@ namespace de4dot.code.resources {
return string.Format("{0}: '{1}'", code, data);
case ResourceTypeCode.ByteArray:
case ResourceTypeCode.Stream:
var ary = data as byte[];
if (ary != null)
return string.Format("{0}: Length: {1}", code, ary.Length);

View File

@ -112,6 +112,10 @@ namespace de4dot.code.resources {
return new BuiltInResourceData(ResourceTypeCode.ByteArray, value);
}
public BuiltInResourceData CreateStream(byte[] value) {
return new BuiltInResourceData(ResourceTypeCode.Stream, value);
}
public CharArrayResourceData Create(char[] value) {
return new CharArrayResourceData(CreateUserResourceType(CharArrayResourceData.typeName), value);
}

View File

@ -139,6 +139,7 @@ namespace de4dot.code.resources {
case ResourceTypeCode.DateTime: return resourceDataCreator.Create(new DateTime(reader.ReadInt64()));
case ResourceTypeCode.TimeSpan: return resourceDataCreator.Create(new TimeSpan(reader.ReadInt64()));
case ResourceTypeCode.ByteArray: return resourceDataCreator.Create(reader.ReadBytes(reader.ReadInt32()));
case ResourceTypeCode.Stream: return resourceDataCreator.CreateStream(reader.ReadBytes(reader.ReadInt32()));
default:
int userTypeIndex = (int)(code - (uint)ResourceTypeCode.UserTypes);
if (userTypeIndex < 0 || userTypeIndex >= userTypes.Count)

View File

@ -37,6 +37,7 @@ namespace de4dot.code.resources {
DateTime,
TimeSpan,
ByteArray = 0x20,
Stream = 0x21,
UserTypes = 0x40,
}
}