/// <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.ToInt64());

                User32.MENUEXITEMTEMPLATE childItem = (User32.MENUEXITEMTEMPLATE)Marshal.PtrToStructure(
                    lpRes, typeof(User32.MENUEXITEMTEMPLATE));

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

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

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

            return(lpRes);
        }
Example #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();

            IntPtr pFixedFileInfo = _header.Read(lpRes);

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

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

            while (pChild.ToInt32() < (lpRes.ToInt32() + _header.Header.wLength))
            {
                ResourceTableHeader rc = new ResourceTableHeader(pChild);
                switch (rc.Key)
                {
                case "StringFileInfo":
                    StringFileInfo 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));
        }
Example #3
0
        internal IntPtr ReadControls(IntPtr lpRes)
        {
            for (int i = 0; i < ControlCount; i++)
            {
                lpRes = ResourceUtil.Align(lpRes);
                lpRes = AddControl(lpRes);
            }

            return(lpRes);
        }
        /// <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));
        }
        /// <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 = (Kernel32.RESOURCE_HEADER)Marshal.PtrToStructure(
                lpRes, typeof(Kernel32.RESOURCE_HEADER));

            IntPtr pBlockKey = new IntPtr(lpRes.ToInt64() + Marshal.SizeOf(_header));

            _key = Marshal.PtrToStringUni(pBlockKey);

            return(ResourceUtil.Align(pBlockKey.ToInt64() + (_key.Length + 1) * Marshal.SystemDefaultCharSize));
        }
Example #6
0
        /// <summary>
        /// Read the menu template.
        /// </summary>
        /// <param name="lpRes">Address in memory.</param>
        internal override IntPtr Read(IntPtr lpRes)
        {
            _header = (User32.MENUEXTEMPLATE)Marshal.PtrToStructure(
                lpRes, typeof(User32.MENUEXTEMPLATE));

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

            return(_menuItems.Read(lpMenuItem));
        }
Example #7
0
        /// <summary>
        /// Read a hardware independent dictionary of language and code page identifier tables.
        /// </summary>
        /// <param name="lpRes">Pointer to the beginning of data.</param>
        /// <returns>Pointer to the end of data.</returns>
        internal override IntPtr Read(IntPtr lpRes)
        {
            _vars.Clear();
            IntPtr pChild = base.Read(lpRes);

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

            return(new IntPtr(lpRes.ToInt32() + _header.wLength));
        }
Example #8
0
        /// <summary>
        /// Read a string table.
        /// </summary>
        /// <param name="lpRes">Pointer to the beginning of the string table.</param>
        /// <returns>Pointer to the end of the string table.</returns>
        internal override IntPtr Read(IntPtr lpRes)
        {
            _strings.Clear();
            IntPtr pChild = base.Read(lpRes);

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

            return(new IntPtr(lpRes.ToInt64() + _header.wLength));
        }
Example #9
0
        /// <summary>
        /// Read a string resource.
        /// </summary>
        /// <param name="lpRes">Pointer to the beginning of a string resource.</param>
        internal void Read(IntPtr lpRes)
        {
            _header = (Kernel32.RESOURCE_HEADER)Marshal.PtrToStructure(
                lpRes, typeof(Kernel32.RESOURCE_HEADER));

            IntPtr pKey = new IntPtr(lpRes.ToInt64() + Marshal.SizeOf(_header));

            _key = Marshal.PtrToStringUni(pKey);

            IntPtr pValue = ResourceUtil.Align(pKey.ToInt64() + (_key.Length + 1) * Marshal.SystemDefaultCharSize);

            _value = ((_header.wValueLength > 0)
                ? Marshal.PtrToStringUni(pValue, _header.wValueLength)
                : null);
        }
Example #10
0
        /// <summary>
        /// Read the menu item.
        /// </summary>
        /// <param name="lpRes">Address in memory.</param>
        /// <returns>End of the menu item structure.</returns>
        internal virtual IntPtr Read(IntPtr lpRes)
        {
            _header = (User32.MENUEXITEMTEMPLATE)Marshal.PtrToStructure(
                lpRes, typeof(User32.MENUEXITEMTEMPLATE));

            lpRes = new IntPtr(lpRes.ToInt32() + Marshal.SizeOf(_header));

            switch ((UInt32)Marshal.ReadInt32(lpRes))
            {
            case 0:
                lpRes = ResourceUtil.Align(lpRes.ToInt32() + 2);
                break;

            default:
                _menuString = Marshal.PtrToStringUni(lpRes);
                lpRes       = ResourceUtil.Align(lpRes.ToInt32() +
                                                 (_menuString.Length + 1) * Marshal.SystemDefaultCharSize);
                break;
            }

            return(lpRes);
        }