Ejemplo n.º 1
0
        public PyTypeObject LoadType(IPythonMemoryReader MemoryReader)
        {
            if (ob_type.HasValue)
            {
                TypeObject = MemoryReader.TypeFromAddress(ob_type.Value);
            }

            return(TypeObject);
        }
Ejemplo n.º 2
0
        PyTypeObject IPythonMemoryReader.TypeFromAddress(uint TypeObjectAddress)
        {
            PyTypeObject TypeObject;

            if (CacheTypeObject.TryGetValue(TypeObjectAddress, out TypeObject))
            {
                return(TypeObject);
            }

            TypeObject = new PyTypeObject(TypeObjectAddress, MemoryReader);

            CacheTypeObject[TypeObjectAddress] = TypeObject;

            return(TypeObject);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// enumerates the subset of Addresses that satisfy this condition:
        /// +interpreted as the Address of a Python Type Object, the tp_name of this Object Equals <paramref name="tp_name"/>
        /// </summary>
        /// <param name="TypeObjectAddresses"></param>
        /// <param name="MemoryReader"></param>
        /// <param name="tp_name"></param>
        /// <returns></returns>
        static public IEnumerable <PyTypeObject> TypeObjectAddressesFilterByTpName(
            IEnumerable <UInt32> TypeObjectAddresses,
            IMemoryReader MemoryReader,
            string tp_name)
        {
            if (null == TypeObjectAddresses || null == MemoryReader)
            {
                yield break;
            }

            foreach (var CandidateTypeAddress in TypeObjectAddresses)
            {
                var PyType = new PyTypeObject(CandidateTypeAddress, MemoryReader);

                if (!string.Equals(PyType.tp_name_Val, tp_name))
                {
                    continue;
                }

                yield return(PyType);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// the enumerated set contains all addresses of Python Objects of the type with the given <paramref name="tp_name"/>.
        ///
        /// the addresses are only filtered for appropriate ob_type.
        /// </summary>
        /// <param name="MemoryReader"></param>
        /// <param name="tp_name"></param>
        /// <returns></returns>
        static public IEnumerable <UInt32> EnumeratePossibleAddressesOfInstancesOfPythonTypeFilteredByObType(
            IMemoryReader MemoryReader,
            string tp_name)
        {
            var CandidatesTypeObjectType = PyTypeObject.FindCandidatesTypeObjectTypeAddress(MemoryReader);

            var TypeObjectType = PyTypeObject.TypeObjectAddressesFilterByTpName(CandidatesTypeObjectType, MemoryReader, "type").FirstOrDefault();

            if (null == TypeObjectType)
            {
                yield break;
            }

            //	finds candidate Addresses for Objects of type "type" with only requiring them to have a appropriate value for ob_type.
            var TypeCandidateAddressesPlus4 =
                MemoryReader.AddressesHoldingValue32Aligned32((UInt32)TypeObjectType.BaseAddress, 0, Int32.MaxValue)
                .ToArray();

            var TypeCandidateAddresses =
                TypeCandidateAddressesPlus4
                .Select((Address) => (UInt32)(Address - 4))
                .ToArray();

            var TypeObjectsWithProperName =
                PyTypeObject.TypeObjectAddressesFilterByTpName(TypeCandidateAddresses, MemoryReader, tp_name)
                .ToArray();

            foreach (var TypeObject in TypeObjectsWithProperName)
            {
                //	finds candidate Addresses for Objects of type tp_name with only requiring them to have a appropriate value for ob_type.

                foreach (var CandidateForObjectOfTypeAddressPlus4 in MemoryReader.AddressesHoldingValue32Aligned32((UInt32)TypeObject.BaseAddress, 0, Int32.MaxValue))
                {
                    yield return((UInt32)(CandidateForObjectOfTypeAddressPlus4 - 4));
                }
            }
        }