Example #1
0
        /// <summary>
        /// Gets the enumerator for the discovered pointers.
        /// </summary>
        /// <param name="startIndex">The start index at which to return non-null values.</param>
        /// <param name="endIndex">The end index at which to return non-null values.</param>
        /// <returns>The enumerator for the discovered pointers.</returns>
        private IEnumerator <PointerItem> EnumeratePointers(UInt64?startIndex = null, UInt64?endIndex = null)
        {
            PointerIndicies indicies = new PointerIndicies(startIndex, endIndex);

            foreach (PointerRoot root in this.PointerRoots)
            {
                foreach (PointerBranch branch in root)
                {
                    Stack <Int32> offsets = new Stack <Int32>();

                    foreach (PointerItem pointerItem in this.EnumerateBranches(root.BaseAddress, offsets, branch, indicies))
                    {
                        yield return(pointerItem);
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Enumerates the pointers of the specified pointer branch.
        /// </summary>
        /// <param name="baseAddress">The current base address.</param>
        /// <param name="offsets">The offsets leading to this branch.</param>
        /// <param name="branch">The current branch.</param>
        /// <param name="pointerIndicies">The indicies at which to return non-null values.</param>
        /// <returns>The full pointer path to the branch.</returns>
        private IEnumerable <PointerItem> EnumerateBranches(UInt64 baseAddress, Stack <Int32> offsets, PointerBranch branch, PointerIndicies pointerIndicies)
        {
            offsets.Push(branch.Offset);

            // End index reached
            if (pointerIndicies.Finished)
            {
                yield break;
            }

            if (branch.Branches.Count <= 0)
            {
                PointerItem pointerItem;

                // Only create pointer items when in the range of the selection indicies. This is an optimization to prevent creating unneeded objects.
                if (pointerIndicies.IterateNext())
                {
                    String moduleName;
                    UInt64 address = AddressResolver.GetInstance().AddressToModule(baseAddress, out moduleName);
                    pointerItem = new PointerItem(address.ToIntPtr(), DataTypes.Int32, "New Pointer", moduleName, offsets.ToArray().Reverse());
                }
                else
                {
                    pointerItem = null;
                }

                yield return(pointerItem);
            }
            else
            {
                foreach (PointerBranch childBranch in branch)
                {
                    foreach (PointerItem pointerItem in this.EnumerateBranches(baseAddress, offsets, childBranch, pointerIndicies))
                    {
                        yield return(pointerItem);
                    }
                }
            }

            offsets.Pop();
        }