public byte[] Process(byte[] encryptData) { byte[] decryptData = null; ResourceHeader resourceHeader = new ResourceHeader(); MemoryStream ms = new MemoryStream(encryptData); if (!resourceHeader.Unserial(ms)) { //Debug.Log(String.Format("[ResourceManager Process] Unserial file header error")); //Unity.Debug.Log(String.Format("[ResourceManager Process] Unserial file header error")); return(null); } if (resourceHeader.herderVersion == ResourceHeader.HEADER_VERSION && (ResourceHeader.FILE_TYPE)resourceHeader.fileType == ResourceHeader.FILE_TYPE.SCRIPT && resourceHeader.fileSize == ms.Length - resourceHeader.headerSize) { decryptData = new byte[resourceHeader.fileSize]; ms.Read(decryptData, 0, resourceHeader.fileSize); ProcessNor(decryptData, resourceHeader.encryptKey); } return(decryptData); }
public static void scheduler_LayoutViewInfoCustomizingResourceHeaders(object sender, LayoutViewInfoCustomizingEventArgs e) { if (e.Kind == LayoutElementKind.ResourceHeader) { ResourceHeader header = e.ViewInfo as ResourceHeader; header.Caption = header.Resource.Caption + "\r\nNew long text line"; e.ShouldRecalculateLayout = true; } }
/// <summary> /// Read the resource header, return a pointer to the end of it. /// </summary> /// <param name="lpRes">Top of header.</param> /// <returns>End of header, after the key, aligned at a 32 bit boundary.</returns> internal virtual IntPtr Read(IntPtr lpRes) { _header = (ResourceHeader)Marshal.PtrToStructure(lpRes, typeof(ResourceHeader)); var pBlockKey = new IntPtr(lpRes.ToInt32() + Marshal.SizeOf(_header)); _key = Marshal.PtrToStringUni(pBlockKey); return(ResourceUtil.Align(pBlockKey.ToInt32() + (_key.Length + 1) * Marshal.SystemDefaultCharSize)); }
private void schedulerControl1_CustomDrawResourceHeader(object sender, CustomDrawObjectEventArgs e) { ResourceHeader rh = e.ObjectInfo as ResourceHeader; if (rh != null) { TimeInterval visTime = schedulerControl1.ActiveView.GetVisibleIntervals().Interval; int appointments_Count = CountAppointmentsByCriteria(rh, visTime); rh.Caption = rh.Resource.Caption + " has " + appointments_Count.ToString() + " apts"; } }
/// <summary> /// Read a string resource. /// </summary> /// <param name="lpRes">Pointer to the beginning of a string resource.</param> internal void Read(IntPtr lpRes) { _header = (ResourceHeader)Marshal.PtrToStructure(lpRes, typeof(ResourceHeader)); var pKey = new IntPtr(lpRes.ToInt32() + Marshal.SizeOf(_header)); _key = Marshal.PtrToStringUni(pKey); var pValue = ResourceUtil.Align(pKey.ToInt32() + (_key.Length + 1) * Marshal.SystemDefaultCharSize); _value = ((_header.wValueLength > 0) ? Marshal.PtrToStringUni(pValue, _header.wValueLength) : null); }
/// <summary> /// Deserializes this structure from binary data. /// </summary> /// <param name="reader">The <see cref="BinaryReader"/> to read the data from.</param> /// <param name="header">Optional <see cref="FileHeader"/> that specifies padding to skip after reading.</param> /// <exception cref="ArgumentNullException"><paramref name="reader"/> is null.</exception> public virtual void ReadFrom(BinaryReader reader, FileHeader header = null) { if (reader == null) { throw new ArgumentNullException("reader"); } _header = new ResourceHeader(); _header.ReadFrom(reader, header); _data = reader.ReadBytes(checked ((int)_header.Size)); }
/// <summary> /// Creates a new instance of <see cref="Resource"/> with specified <see cref="TinyResourceKind"/> and existing data. /// </summary> /// <param name="kind"></param> /// <param name="data"></param> public Resource(TinyResourceKind kind, byte[] data) { if (data == null) { throw new ArgumentNullException("data"); } _header = new ResourceHeader(kind); _header.Size = (uint)data.Length; _data = data; }
private void horizontalResourceHeaders1_CustomDrawResourceHeader(object sender, CustomDrawObjectEventArgs e) { ResourceHeader header = (ResourceHeader)e.ObjectInfo; SchedulerColorSchema schema = this.GetResourceColorSchema(header.Resource); header.Appearance.HeaderCaption.BackColor = schema.CellLight; header.Appearance.HeaderCaption.BackColor2 = schema.Cell; Color color = schema.CellBorderDark; header.Appearance.HeaderCaption.ForeColor = TransformColor(color, 0.6); header.Appearance.HeaderCaption.Font = e.Cache.GetFont(header.Appearance.HeaderCaption.Font, FontStyle.Bold); e.DrawDefault(); e.Handled = true; }
/// <summary> /// Creates a new instance of <see cref="Resource"/> with existing <see cref="ResourceHeader"/> and data. /// </summary> /// <param name="header"></param> /// <param name="data"></param> public Resource(ResourceHeader header, byte[] data) { if (header == null) { throw new ArgumentNullException("header"); } if (data == null) { throw new ArgumentNullException("data"); } _header = header; _data = data; }
public static void scheduler_CustomDrawResourceHeader(object sender, DevExpress.XtraScheduler.CustomDrawObjectEventArgs e) { ResourceHeader header = (ResourceHeader)e.ObjectInfo; // Get the resource information from custom fields. string postcode = (header.Resource.CustomFields["PostCode"] != null) ? header.Resource.CustomFields["PostCode"].ToString() : String.Empty; string address = (header.Resource.CustomFields["Address"] != null) ? header.Resource.CustomFields["Address"].ToString() : String.Empty; // Specify the header caption and appearance. header.Appearance.HeaderCaption.ForeColor = Color.Blue; header.Caption = header.Resource.Caption + System.Environment.NewLine + address + System.Environment.NewLine + postcode; header.Appearance.HeaderCaption.Font = e.Cache.GetFont(header.Appearance.HeaderCaption.Font, FontStyle.Bold); // Draw the header using default methods. e.DrawDefault(); e.Handled = true; }
public override void OnMouseDown(MouseEventArgs e) { SchedulerControl control = _schedulerProvider as SchedulerControl; SchedulerHitInfo hitInfo = control.ActiveView.ViewInfo.CalcHitInfo(e.Location, false); if (hitInfo.HitTest == SchedulerHitTest.ResourceHeader) { ResourceHeader resHeader = hitInfo.ViewInfo as ResourceHeader; Rectangle rect = new Rectangle(resHeader.Bounds.X + 2, resHeader.Bounds.Y + 2, 16, 16); if (rect.Contains(e.Location)) { return; } } base.OnMouseDown(e); }
private void schedulerControl1_CustomDrawResourceHeader(object sender, CustomDrawObjectEventArgs e) { ResourceHeader rh = (ResourceHeader)e.ObjectInfo; StringFormat sf = rh.Appearance.HeaderCaption.TextOptions.GetStringFormat(); string newcaption = rh.Resource.Caption + "\n Total:" + CalcCurrentTotals(rh.Interval, rh.Resource).ToString("C"); if (schedulerControl1.ActiveViewType == SchedulerViewType.Timeline) { e.Cache.DrawVString(newcaption, rh.Appearance.HeaderCaption.Font, Brushes.Black, e.Bounds, sf, 270); } else { e.Cache.DrawString(newcaption, rh.Appearance.HeaderCaption.Font, Brushes.Black, e.Bounds, sf); } e.Handled = true; }
public Parser(slice <byte> msg = default, header header = default, section section = default, long off = default, long index = default, bool resHeaderValid = default, ResourceHeader resHeader = default) { this.msg = msg; this.header = header; this.section = section; this.off = off; this.index = index; this.resHeaderValid = resHeaderValid; this.resHeader = resHeader; }
/// <summary> /// Read the resource header, return a pointer to the end of it. /// </summary> /// <param name="lpRes">Top of header.</param> /// <returns>End of header, after the key, aligned at a 32 bit boundary.</returns> internal virtual IntPtr Read(IntPtr lpRes) { _header = (ResourceHeader)Marshal.PtrToStructure(lpRes, typeof (ResourceHeader)); var pBlockKey = new IntPtr(lpRes.ToInt32() + Marshal.SizeOf(_header)); _key = Marshal.PtrToStringUni(pBlockKey); return ResourceUtil.Align(pBlockKey.ToInt32() + (_key.Length + 1)*Marshal.SystemDefaultCharSize); }
public override void Reload() { _resources.Clear(); // the RES format is quite simple, it's just a concatenated list of Resource Data instances, all with their header info _stream.Seek(0, SeekOrigin.Begin); BinaryReader rdr = new BinaryReader(_stream, System.Text.Encoding.Unicode); while (rdr.BaseStream.Position < rdr.BaseStream.Length) { /////////////////////////////// // Read the RESOURCEHEADER Int64 start = rdr.BaseStream.Position; ResourceHeader header = new ResourceHeader(rdr); Int64 stop = rdr.BaseStream.Position; Int32 headerSize = (int)(stop - start); ResResource res = new ResResource(); res.DataOffset = rdr.BaseStream.Position; res.DataLength = (int)header.DataSize; // HACK: this might cause problems for resources larger than 2GB res.HeaderOffset = start; res.HeaderLength = header.HeaderSize; // Read past the Resource data _stream.Seek(header.DataSize, SeekOrigin.Current); // don't do anything if it's empty if (!(header.Type is String)) { Int32 headerType = Convert.ToInt32(header.Type, Cult.InvariantCulture); if (headerType == 0) { rdr.Align4(); continue; } } /////////////////////////////// // Create ResourceType, Name, and Lang instance ResourceTypeIdentifier typeId = header.Type is String ? new ResourceTypeIdentifier((String)header.Type) : new ResourceTypeIdentifier(Convert.ToInt32(header.Type, Cult.InvariantCulture)); ResourceType type = UnderlyingFind(t => t.Identifier.Equals(typeId)); if (type == null) { type = new ResourceType(typeId, this); UnderlyingAdd(type); } /////////////////////////////////////////////////////////// ResourceIdentifier nameId = header.Name is String ? new ResourceIdentifier((String)header.Name) : new ResourceIdentifier(Convert.ToInt32(header.Name, Cult.InvariantCulture)); ResourceName name = UnderlyingFind(type, n => n.Identifier.Equals(nameId)); if (name == null) { name = new ResourceName(nameId, type); UnderlyingAdd(type, name); } /////////////////////////////////////////////////////////// // TODO: Maybe do some validation to ensure the same lang hasn't been added twice? ResourceLang lang = new ResourceLang(header.LanguageId, name); UnderlyingAdd(name, lang); /////////////////////////////////////////////////////////// res.Lang = lang; _resources.Add(res); rdr.Align4(); } }
public Resource(ResourceHeader Header = default, ResourceBody Body = default) { this.Header = Header; this.Body = Body; }
/// <summary> /// Read a string resource. /// </summary> /// <param name="lpRes">Pointer to the beginning of a string resource.</param> internal void Read(IntPtr lpRes) { _header = (ResourceHeader)Marshal.PtrToStructure(lpRes, typeof (ResourceHeader)); var pKey = new IntPtr(lpRes.ToInt32() + Marshal.SizeOf(_header)); Key = Marshal.PtrToStringUni(pKey); var pValue = ResourceUtil.Align(pKey.ToInt32() + (Key.Length + 1)*Marshal.SystemDefaultCharSize); _value = ((_header.wValueLength > 0) ? Marshal.PtrToStringUni(pValue, _header.wValueLength) : null); }
/// <summary>Initializes this instance.</summary> void Init() { _header = new ResourceHeader(); byte[] tmp = new byte[4]; _rsrcStream.Seek(0, SeekOrigin.Begin); _rsrcStream.Read(tmp, 0, 4); _header.ResourceDataOff = BitConverter.ToInt32(tmp.Reverse().ToArray(), 0); _rsrcStream.Read(tmp, 0, 4); _header.ResourceMapOff = BitConverter.ToInt32(tmp.Reverse().ToArray(), 0); _rsrcStream.Read(tmp, 0, 4); _header.ResourceDataLen = BitConverter.ToInt32(tmp.Reverse().ToArray(), 0); _rsrcStream.Read(tmp, 0, 4); _header.ResourceMapLen = BitConverter.ToInt32(tmp.Reverse().ToArray(), 0); if (_header.ResourceDataOff <= 0 || _header.ResourceMapOff <= 0 || _header.ResourceDataLen <= 0 || _header.ResourceMapLen <= 0) { throw new InvalidCastException("Not a resource fork"); } if (_header.ResourceDataOff + _header.ResourceDataLen > _rsrcStream.Length || _header.ResourceMapOff + _header.ResourceMapLen > _rsrcStream.Length) { throw new InvalidCastException("Not a resource fork"); } _map = new ResourceMap { Header = new ResourceHeader() }; _rsrcStream.Seek(_header.ResourceMapOff, SeekOrigin.Begin); _rsrcStream.Read(tmp, 0, 4); _map.Header.ResourceDataOff = BitConverter.ToInt32(tmp.Reverse().ToArray(), 0); _rsrcStream.Read(tmp, 0, 4); _map.Header.ResourceMapOff = BitConverter.ToInt32(tmp.Reverse().ToArray(), 0); _rsrcStream.Read(tmp, 0, 4); _map.Header.ResourceDataLen = BitConverter.ToInt32(tmp.Reverse().ToArray(), 0); _rsrcStream.Read(tmp, 0, 4); _map.Header.ResourceMapLen = BitConverter.ToInt32(tmp.Reverse().ToArray(), 0); if (_map.Header.ResourceDataOff != _header.ResourceDataOff || _map.Header.ResourceDataLen != _header.ResourceDataLen || _map.Header.ResourceMapOff != _header.ResourceMapOff || _map.Header.ResourceMapLen != _header.ResourceMapLen) { throw new InvalidCastException("Header copy is not same as header."); } _rsrcStream.Read(tmp, 0, 4); _map.HandleToNextMap = BitConverter.ToUInt32(tmp.Reverse().ToArray(), 0); tmp = new byte[2]; _rsrcStream.Read(tmp, 0, 2); _map.FileRefNo = BitConverter.ToUInt16(tmp.Reverse().ToArray(), 0); _rsrcStream.Read(tmp, 0, 2); _map.Attributes = BitConverter.ToUInt16(tmp.Reverse().ToArray(), 0); _rsrcStream.Read(tmp, 0, 2); _map.TypeListOff = BitConverter.ToInt16(tmp.Reverse().ToArray(), 0); _rsrcStream.Read(tmp, 0, 2); _map.NameListOff = BitConverter.ToInt16(tmp.Reverse().ToArray(), 0); // Number of types is part of the resource type list not of the map _rsrcStream.Seek(_header.ResourceMapOff + _map.TypeListOff, SeekOrigin.Begin); _rsrcStream.Read(tmp, 0, 2); _map.NumberOfTypes = BitConverter.ToUInt16(tmp.Reverse().ToArray(), 0); _resourceTypeList = new Dictionary <uint, ResourceTypeListItem>(); _osTypes = new List <uint>(); for (int i = 0; i <= _map.NumberOfTypes; i++) { ResourceTypeListItem typeList = new(); tmp = new byte[4]; _rsrcStream.Read(tmp, 0, 4); typeList.Type = BitConverter.ToUInt32(tmp.Reverse().ToArray(), 0); tmp = new byte[2]; _rsrcStream.Read(tmp, 0, 2); typeList.Resources = BitConverter.ToUInt16(tmp.Reverse().ToArray(), 0); _rsrcStream.Read(tmp, 0, 2); typeList.ReferenceOff = BitConverter.ToInt16(tmp.Reverse().ToArray(), 0); _resourceTypeList.Add(typeList.Type, typeList); _osTypes.Add(typeList.Type); } _resourceCache = new Dictionary <uint, Resource>(); }
public Resource( ResourceHeader header, byte[] data ) { this.header = header; this.data = data; }