Esempio n. 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));
        }
        internal IntPtr ReadControls(IntPtr lpRes)
        {
            for (int i = 0; i < ControlCount; i++)
            {
                lpRes = ResourceUtil.Align(lpRes);
                lpRes = AddControl(lpRes);
            }

            return(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.ToInt32() + Marshal.SizeOf(_header));

            _key = Marshal.PtrToStringUni(pBlockKey);

            return(ResourceUtil.Align(pBlockKey.ToInt32() + (_key.Length + 1) * Marshal.SystemDefaultCharSize));
        }
        /// <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();
            IntPtr pChild = base.Read(lpRes);

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

            return(new IntPtr(lpRes.ToInt32() + _header.wLength));
        }
Esempio n. 5
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);
        }
Esempio n. 6
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);
        }