Beispiel #1
0
        /// <summary>
        ///     Read the menu item collection.
        /// </summary>
        /// <param name="lpRes">Address in memory.</param>
        /// <returns>End of the menu item structure.</returns>
        internal IntPtr Read(IntPtr lpRes)
        {
            while (true)
            {
                lpRes = ResourceUtil.Align(lpRes.ToInt32());

                var childItem = (MenuExItemTemplate)Marshal.PtrToStructure(lpRes, typeof(MenuExItemTemplate));

                MenuExTemplateItem childMenu = null;
                if ((childItem.bResInfo & (uint)MenuResourceType.Sub) > 0)
                {
                    childMenu = new MenuExTemplateItemPopup();
                }
                else
                {
                    childMenu = new MenuExTemplateItemCommand();
                }

                lpRes = childMenu.Read(lpRes);
                Add(childMenu);

                if ((childItem.bResInfo & (uint)MenuResourceType.Last) > 0)
                {
                    break;
                }
            }

            return(lpRes);
        }
Beispiel #2
0
        /// <summary>
        ///     Read a version resource from a previously loaded module.
        /// </summary>
        /// <param name="hModule">Module handle.</param>
        /// <param name="lpRes">Pointer to the beginning of the resource.</param>
        /// <returns>Pointer to the end of the resource.</returns>
        internal override IntPtr Read(IntPtr hModule, IntPtr lpRes)
        {
            _resources.Clear();

            var pFixedFileInfo = _header.Read(lpRes);

            if (_header.Header.wValueLength != 0)
            {
                _fixedfileinfo = new FixedFileInfo();
                _fixedfileinfo.Read(pFixedFileInfo);
            }

            var pChild = ResourceUtil.Align(pFixedFileInfo.ToInt32() + _header.Header.wValueLength);

            while (pChild.ToInt32() < (lpRes.ToInt32() + _header.Header.wLength))
            {
                var rc = new ResourceTableHeader(pChild);
                switch (rc.Key)
                {
                case "StringFileInfo":
                    var sr = new StringFileInfo(pChild);
                    rc = sr;
                    break;

                default:
                    rc = new VarFileInfo(pChild);
                    break;
                }

                _resources.Add(rc.Key, rc);
                pChild = ResourceUtil.Align(pChild.ToInt32() + rc.Header.wLength);
            }

            return(new IntPtr(lpRes.ToInt32() + _header.Header.wLength));
        }
        /// <summary>
        ///     Read the menu template.
        /// </summary>
        /// <param name="lpRes">Address in memory.</param>
        internal override IntPtr Read(IntPtr lpRes)
        {
            _header = (Api.Structures.MenuExTemplate)Marshal.PtrToStructure(lpRes, typeof(Api.Structures.MenuExTemplate));

            var lpMenuItem = ResourceUtil.Align(lpRes.ToInt32() + Marshal.SizeOf(_header) + _header.wOffset);

            return(_menuItems.Read(lpMenuItem));
        }
        /// <summary>
        ///     Read an extended popup menu item.
        /// </summary>
        /// <param name="lpRes">Address in memory.</param>
        /// <returns>End of the menu item structure.</returns>
        internal override IntPtr Read(IntPtr lpRes)
        {
            lpRes = base.Read(lpRes);

            lpRes     = ResourceUtil.Align(lpRes);
            _dwHelpId = (UInt32)Marshal.ReadInt32(lpRes);
            lpRes     = new IntPtr(lpRes.ToInt32() + 4);

            return(_subMenuItems.Read(lpRes));
        }
        internal IntPtr ReadControls(IntPtr lpRes)
        {
            for (var i = 0; i < ControlCount; i++)
            {
                lpRes = ResourceUtil.Align(lpRes);
                lpRes = AddControl(lpRes);
            }

            return(lpRes);
        }
Beispiel #6
0
        /// <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));
        }
        /// <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);
        }
Beispiel #8
0
        /// <summary>
        ///     Read an existing string file-version resource.
        /// </summary>
        /// <param name="lpRes">Pointer to the beginning of a string file-version resource.</param>
        /// <returns>Pointer to the end of the string file-version resource.</returns>
        internal override IntPtr Read(IntPtr lpRes)
        {
            _strings.Clear();
            var pChild = base.Read(lpRes);

            while (pChild.ToInt32() < (lpRes.ToInt32() + _header.wLength))
            {
                var res = new StringTable(pChild);
                _strings.Add(res.Key, res);
                pChild = ResourceUtil.Align(pChild.ToInt32() + res.Header.wLength);
            }

            return(new IntPtr(lpRes.ToInt32() + _header.wLength));
        }