@@ -48,7 +48,7 @@ public ResourceConverter(ModuleDefMD module, ResourceInfo[] infos) {
4848 }
4949
5050 public byte [ ] Convert ( ) {
51- var resources = new ResourceElementSet ( ) ;
51+ var resources = ResourceElementSet . CreateForResourceReader ( module ) ;
5252 foreach ( var info in infos )
5353 resources . Add ( Convert ( info ) ) ;
5454
@@ -145,7 +145,7 @@ ResourceElement Convert(ResourceInfo info) {
145145 break ;
146146
147147 case 31 : // binary
148- resourceData = dataCreator . CreateSerialized ( reader . ReadBytes ( info . length ) ) ;
148+ resourceData = dataCreator . CreateSerialized ( reader . ReadBytes ( info . length ) , SerializationFormat . BinaryFormatter , new UserResourceType ( "Binary" , ResourceTypeCode . ByteArray ) ) ;
149149 break ;
150150
151151 case 21 : // Point (CV doesn't restore this type)
@@ -166,7 +166,7 @@ class CharArrayResourceData : UserResourceData {
166166 public CharArrayResourceData ( UserResourceType type , char [ ] data ) : base ( type ) => this . data = data ;
167167 #pragma warning disable SYSLIB0011
168168 #warning "Insecure! Rewrite with custom parser https://learn.microsoft.com/en-us/dotnet/standard/serialization/binaryformatter-security-guide"
169- public override void WriteData ( BinaryWriter writer , IFormatter formatter ) => formatter . Serialize ( writer . BaseStream , data ) ;
169+ public override void WriteData ( ResourceBinaryWriter writer , IFormatter formatter ) => formatter . Serialize ( writer . BaseStream , data ) ;
170170 #pragma warning restore SYSLIB0011
171171 public override string ToString ( ) => $ "char[]: Length: { data . Length } ";
172172 }
@@ -177,7 +177,7 @@ class IconResourceData : UserResourceData {
177177 public IconResourceData ( UserResourceType type , byte [ ] data ) : base ( type ) => icon = new Icon ( new MemoryStream ( data ) ) ;
178178 #pragma warning disable SYSLIB0011
179179 #warning "Insecure! Rewrite with custom parser https://learn.microsoft.com/en-us/dotnet/standard/serialization/binaryformatter-security-guide"
180- public override void WriteData ( BinaryWriter writer , IFormatter formatter ) => formatter . Serialize ( writer . BaseStream , icon ) ;
180+ public override void WriteData ( ResourceBinaryWriter writer , IFormatter formatter ) => formatter . Serialize ( writer . BaseStream , icon ) ;
181181 #pragma warning restore SYSLIB0011
182182 public override string ToString ( ) => $ "Icon: { icon } ";
183183 }
@@ -188,7 +188,7 @@ class ImageResourceData : UserResourceData {
188188 public ImageResourceData ( UserResourceType type , byte [ ] data ) : base ( type ) => bitmap = new Bitmap ( Image . FromStream ( new MemoryStream ( data ) ) ) ;
189189 #pragma warning disable SYSLIB0011
190190 #warning "Insecure! Rewrite with custom parser https://learn.microsoft.com/en-us/dotnet/standard/serialization/binaryformatter-security-guide"
191- public override void WriteData ( BinaryWriter writer , IFormatter formatter ) => formatter . Serialize ( writer . BaseStream , bitmap ) ;
191+ public override void WriteData ( ResourceBinaryWriter writer , IFormatter formatter ) => formatter . Serialize ( writer . BaseStream , bitmap ) ;
192192 #pragma warning restore SYSLIB0011
193193 public override string ToString ( ) => "Bitmap" ;
194194 }
0 commit comments