Exemplo n.º 1
0
        public void GetVersionInfo(ulong addr, out VersionInfo version)
        {
            version = new VersionInfo();

            uint  index;
            ulong baseAddr;
            int   hr = m_symbols.GetModuleByOffset(addr, 0, out index, out baseAddr);

            if (hr != 0)
            {
                return;
            }

            uint needed = 0;

            hr = GetModuleVersionInformation(index, baseAddr, "\\", null, 0, out needed);
            if (hr != 0)
            {
                return;
            }

            byte[] buffer = new byte[needed];
            hr = GetModuleVersionInformation(index, baseAddr, "\\", buffer, needed, out needed);
            if (hr != 0)
            {
                return;
            }

            version.Minor    = (ushort)Marshal.ReadInt16(buffer, 8);
            version.Major    = (ushort)Marshal.ReadInt16(buffer, 10);
            version.Patch    = (ushort)Marshal.ReadInt16(buffer, 12);
            version.Revision = (ushort)Marshal.ReadInt16(buffer, 14);

            return;
        }
Exemplo n.º 2
0
        private bool FindModuleIndex(ulong baseAddr, out uint index)
        {
            /* GetModuleByOffset returns the first module (from startIndex) which
             * includes baseAddr.
             * However when loading 64-bit dumps of 32-bit processes it seems that
             * the module sizes are sometimes wrong, which may cause a wrong module
             * to be found because it overlaps the beginning of the queried module,
             * so search until we find a module that actually has the correct
             * baseAddr*/
            uint nextIndex = 0;

            while (true)
            {
                int hr = _symbols.GetModuleByOffset(baseAddr, nextIndex, out index, out ulong claimedBaseAddr);
                if (hr != 0)
                {
                    index = 0;
                    return(false);
                }
                if (claimedBaseAddr == baseAddr)
                {
                    return(true);
                }
                nextIndex = index + 1;
            }
        }
Exemplo n.º 3
0
        public void GetVersionInfo(ulong addr, out VersionInfo version)
        {
            version = default;

            int hr = _symbols.GetModuleByOffset(addr, 0, out uint index, out ulong baseAddr);

            if (hr != 0)
            {
                return;
            }

            hr = GetModuleVersionInformation(index, baseAddr, "\\", null, 0, out uint needed);
            if (hr != 0)
            {
                return;
            }

            byte[] buffer = new byte[needed];
            hr = GetModuleVersionInformation(index, baseAddr, "\\", buffer, needed, out needed);
            if (hr != 0)
            {
                return;
            }

            int minor    = (ushort)Marshal.ReadInt16(buffer, 8);
            int major    = (ushort)Marshal.ReadInt16(buffer, 10);
            int patch    = (ushort)Marshal.ReadInt16(buffer, 12);
            int revision = (ushort)Marshal.ReadInt16(buffer, 14);

            version = new VersionInfo(major, minor, revision, patch);
        }