Example #1
0
        //
        // Note: This method is expected to be called under lock
        //
        private unsafe static IntPtr AllocateThunksTemplateMapFromMapping(IntPtr thunkMap, IntPtr commonStubAddress, LowLevelList <ThunksTemplateMap> mappings)
        {
            // Update the last pointer value in the thunks data section with the value of the common stub address
            *((IntPtr *)(thunkMap + PAGE_SIZE * 2 - IntPtr.Size)) = commonStubAddress;
            Debug.Assert(*((IntPtr *)(thunkMap + PAGE_SIZE * 2 - IntPtr.Size)) != IntPtr.Zero);

            ThunksTemplateMap newMapping = new ThunksTemplateMap(thunkMap);

            mappings.Add(newMapping);

            // Always call GetNextThunk before returning the result, so that the ThunksTemplateMap can
            // correctly keep track of used/unused thunks
            IntPtr thunkStub = newMapping.GetNextThunk();

            Debug.Assert(thunkStub == thunkMap);    // First thunk always at the begining of the mapping

            return(thunkStub);
        }
Example #2
0
        //
        // Note: This method is expected to be called under lock
        //
        private unsafe static IntPtr AllocateThunksTemplateMapFromMapping(IntPtr thunkMap, IntPtr commonStubAddress, LowLevelList<ThunksTemplateMap> mappings)
        {
            // Update the last pointer value in the thunks data section with the value of the common stub address
            *((IntPtr*)(thunkMap + PAGE_SIZE * 2 - IntPtr.Size)) = commonStubAddress;
            Debug.Assert(*((IntPtr*)(thunkMap + PAGE_SIZE * 2 - IntPtr.Size)) != IntPtr.Zero);

            ThunksTemplateMap newMapping = new ThunksTemplateMap(thunkMap);
            mappings.Add(newMapping);

            // Always call GetNextThunk before returning the result, so that the ThunksTemplateMap can
            // correctly keep track of used/unused thunks
            IntPtr thunkStub = newMapping.GetNextThunk();
            Debug.Assert(thunkStub == thunkMap);    // First thunk always at the begining of the mapping

            return thunkStub;
        }