Ejemplo n.º 1
0
 /// <summary>
 /// Helper function to count the number of leaves on a pointer tree branch.
 /// </summary>
 /// <param name="count">The current number of leaves.</param>
 /// <param name="branch">The current pointer tree branch.</param>
 private void CountLeaves(ref UInt64 count, PointerBranch branch)
 {
     if (branch.Branches.Count <= 0)
     {
         count = count + 1;
     }
     else
     {
         foreach (PointerBranch childBranch in branch)
         {
             this.CountLeaves(ref count, childBranch);
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Helper function to count the number of leaves on a pointer tree branch.
        /// </summary>
        /// <param name="count">The count so far.</param>
        /// <param name="branch">The current pointer tree branch.</param>
        /// <returns>The count updated with the number of leaves from this branch.</returns>
        private UInt64 CountLeaves(UInt64 count, PointerBranch branch)
        {
            if (branch.Branches.Count <= 0)
            {
                return(count + 1);
            }
            else
            {
                foreach (PointerBranch childBranch in branch)
                {
                    count = this.CountLeaves(count, childBranch);
                }

                return(count);
            }
        }
Ejemplo n.º 3
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>
        /// <returns>The full pointer path to the branch.</returns>
        private IEnumerable <PointerItem> EnumerateBranches(UInt64 baseAddress, Stack <Int32> offsets, PointerBranch branch)
        {
            offsets.Push(branch.Offset);

            if (branch.Branches.Count <= 0)
            {
                PointerItem pointerItem = new PointerItem(baseAddress.ToIntPtr(), typeof(Int32), "New Pointer", null, offsets.ToArray().Reverse());

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

            offsets.Pop();
        }
Ejemplo n.º 4
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();
        }