using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Runtime.InteropServices; namespace Vestris.ResourceLib { /// /// A generic resource. /// public class GenericResource : Resource { /// /// Raw resource data. /// protected byte[] _data = null; /// /// Raw resource data. /// public byte[] Data { get { return _data; } set { _data = value; } } /// /// An unstructured generic resource embedded in an executable module. /// /// Module handle. /// Resource handle. /// Type of resource. /// Resource name. /// Language id. /// Resource size. public GenericResource(IntPtr hModule, IntPtr hResource, ResourceId type, ResourceId name, UInt16 language, int size) : base(hModule, hResource, type, name, language, size) { } /// /// A generic resource. /// /// Resource name. /// Resource type. /// Resource language. public GenericResource(ResourceId type, ResourceId name, UInt16 language) { _type = type; _name = name; _language = language; } /// /// Read a generic resource. /// /// Module handle. /// Pointer to the beginning of a resource. /// Pointer to the end of the resource. internal override IntPtr Read(IntPtr hModule, IntPtr lpRes) { if (_size > 0) { _data = new byte[_size]; Marshal.Copy(lpRes, _data, 0, _data.Length); } return new IntPtr(lpRes.ToInt32() + _size); } /// /// Write the resource to a binary stream. /// /// Binary stream. internal override void Write(BinaryWriter w) { w.Write(_data); } } }