コード例 #1
0
        /// <summary>
        /// Indicate that a virtual region has been mapped, and which physical region it has been mapped to.
        /// Should be called after the mapping is complete.
        /// </summary>
        /// <param name="va">Virtual memory address</param>
        /// <param name="size">Size to be mapped</param>
        public void Map(ulong va, ulong size)
        {
            // A mapping may mean we need to re-evaluate each VirtualRegion's affected area.
            // Find all handles that overlap with the range, we need to recalculate their physical regions

            lock (TrackingLock)
            {
                var results = _virtualResults;
                int count   = _virtualRegions.FindOverlapsNonOverlapping(va, size, ref results);

                for (int i = 0; i < count; i++)
                {
                    VirtualRegion region = results[i];

                    // If the region has been fully remapped, signal that it has been mapped again.
                    bool remapped = _memoryManager.IsRangeMapped(region.Address, region.Size);
                    if (remapped)
                    {
                        region.SignalMappingChanged(true);
                    }

                    region.UpdateProtection();
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Indicate that a virtual region has been unmapped.
        /// Should be called before the unmapping is complete.
        /// </summary>
        /// <param name="va">Virtual memory address</param>
        /// <param name="size">Size to be unmapped</param>
        public void Unmap(ulong va, ulong size)
        {
            // An unmapping may mean we need to re-evaluate each VirtualRegion's affected area.
            // Find all handles that overlap with the range, we need to notify them that the region was unmapped.

            lock (TrackingLock)
            {
                var results = _virtualResults;
                int count   = _virtualRegions.FindOverlapsNonOverlapping(va, size, ref results);

                for (int i = 0; i < count; i++)
                {
                    VirtualRegion region = results[i];

                    region.SignalMappingChanged(false);
                }
            }
        }