コード例 #1
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));
        }
コード例 #2
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());

                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);
        }
コード例 #3
0
        /// <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));
        }
コード例 #4
0
        internal IntPtr ReadControls(IntPtr lpRes)
        {
            for (int i = 0; i < ControlCount; i++)
            {
                lpRes = ResourceUtil.Align(lpRes);
                lpRes = AddControl(lpRes);
            }

            return(lpRes);
        }
コード例 #5
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 = (Kernel32.RESOURCE_HEADER)Marshal.PtrToStructure(
                lpRes, typeof(Kernel32.RESOURCE_HEADER));

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

            _key = Marshal.PtrToStringUni(pBlockKey);

            return(ResourceUtil.Align(pBlockKey.ToInt32() + (_key.Length + 1) * Marshal.SystemDefaultCharSize));
        }
コード例 #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));
        }
コード例 #7
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.ToInt32() < (lpRes.ToInt32() + _header.wLength))
            {
                StringTableEntry res = new StringTableEntry(pChild);
                _strings.Add(res.Key, res);
                pChild = ResourceUtil.Align(pChild.ToInt32() + res.Header.wLength);
            }

            return(new IntPtr(lpRes.ToInt32() + _header.wLength));
        }
コード例 #8
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.ToInt32() + Marshal.SizeOf(_header));

            _key = Marshal.PtrToStringUni(pKey);

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

            _value = ((_header.wValueLength > 0)
                ? Marshal.PtrToStringUni(pValue, _header.wValueLength)
                : null);
        }