8 instantiations of GCHandle
PresentationCore (1)
src\wpf\src\Microsoft.DotNet.Wpf\src\Shared\MS\Internal\CharacterBuffer.cs (1)
428gcHandle = new GCHandle();
System.Private.CoreLib (3)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\GCHandle.cs (3)
65public static GCHandle Alloc(object? value) => new GCHandle(value, GCHandleType.Normal); 72public static GCHandle Alloc(object? value, GCHandleType type) => new GCHandle(value, type); 161return new GCHandle(value);
System.Speech (4)
Internal\Synthesis\ConvertTextFrag.cs (2)
31sapiFrag.gcNext = fFirst ? new GCHandle() : sapiFragLast; 75sapiFrag.gcPhoneme = new GCHandle();
Internal\Synthesis\TTSEngineProxy.cs (1)
152GCHandle spvTextFragment = new();
Internal\Synthesis\TTSVoice.cs (1)
94GCHandle targetFormat = new();
589 references to GCHandle
aspire (5)
Processes\WindowsProcessInterop.cs (5)
398var pinnedHandles = GCHandle.Alloc(handles, GCHandleType.Pinned); 399var pinnedJobHandles = default(GCHandle); 420pinnedJobHandles = GCHandle.Alloc(jobHandles, GCHandleType.Pinned);
ILCompiler.ReadyToRun (5)
parent\parent\Common\JitInterface\CorInfoImpl.cs (4)
666private Dictionary<object, GCHandle> _pins = new Dictionary<object, GCHandle>(); 670GCHandle handle; 673handle = GCHandle.Alloc(obj, GCHandleType.Pinned);
TypeSystem\Mutable\MutableModule.cs (1)
276System.Runtime.InteropServices.GCHandle.Alloc(metadataArray, System.Runtime.InteropServices.GCHandleType.Pinned);
ILCompiler.RyuJit (4)
parent\parent\Common\JitInterface\CorInfoImpl.cs (4)
666private Dictionary<object, GCHandle> _pins = new Dictionary<object, GCHandle>(); 670GCHandle handle; 673handle = GCHandle.Alloc(obj, GCHandleType.Pinned);
libmscordaccore_universal (7)
Entrypoints.cs (7)
147GCHandle gcHandle = GCHandle.Alloc(new CdacHandle(target, new Lock())); 148*handle = GCHandle.ToIntPtr(gcHandle); 163GCHandle h = GCHandle.FromIntPtr(handle); 190CdacHandle? cdacHandle = GCHandle.FromIntPtr(handle).Target as CdacHandle; 234CdacHandle? cdacHandle = GCHandle.FromIntPtr(handle).Target as CdacHandle;
Microsoft.AspNetCore.Server.HttpSys (7)
RequestProcessing\ResponseBody.cs (7)
144Span<GCHandle> pinnedBuffers = default; 183private unsafe void BuildDataChunks(scoped ref UnmanagedBufferAllocator allocator, bool endOfRequest, ArraySegment<byte> data, out Span<HTTP_DATA_CHUNK> dataChunks, out Span<GCHandle> pins) 228pins = allocator.AllocAsSpan<GCHandle>(2); 272out GCHandle handle) 274handle = GCHandle.Alloc(buffer.Array, GCHandleType.Pinned); 292private static void FreeDataBuffers(Span<GCHandle> pinnedBuffers) 294foreach (var pin in pinnedBuffers)
Microsoft.AspNetCore.Server.IIS (15)
Core\IISHttpContext.cs (2)
62private GCHandle _thisHandle = default!; 159_thisHandle = GCHandle.Alloc(this);
Core\IISHttpServer.cs (7)
26private GCHandle _httpServerHandle; 98_httpServerHandle = GCHandle.Alloc(this); 157server = (IISHttpServer?)GCHandle.FromIntPtr(pvRequestContext).Target; 188server = (IISHttpServer?)GCHandle.FromIntPtr(pvRequestContext).Target; 212context = (IISHttpContext?)GCHandle.FromIntPtr(pvManagedHttpContext).Target; 234context = (IISHttpContext?)GCHandle.FromIntPtr(pvManagedHttpContext).Target; 259server = (IISHttpServer?)GCHandle.FromIntPtr(serverContext).Target;
Core\IO\WebSocketsAsyncIOEngine.Read.cs (3)
17var context = (WebSocketReadOperation)GCHandle.FromIntPtr(completionContext).Target!; 29private readonly GCHandle _thisHandle; 36_thisHandle = GCHandle.Alloc(this);
Core\IO\WebSocketsAsyncIOEngine.Write.cs (3)
16var context = (WebSocketWriteOperation)GCHandle.FromIntPtr(completionContext).Target!; 27private readonly GCHandle _thisHandle; 31_thisHandle = GCHandle.Alloc(this);
Microsoft.CSharp (5)
Microsoft\CSharp\RuntimeBinder\ComInterop\ComInvokeBinder.cs (3)
107get { return EnsureVariable(ref _dispIdsOfKeywordArgsPinned, typeof(GCHandle), "dispIdsOfKeywordArgsPinned"); } 377typeof(GCHandle).GetMethod(nameof(GCHandle.Free))
Microsoft\CSharp\RuntimeBinder\ComInterop\ComRuntimeHelpers.cs (2)
325public static IntPtr GetIdsOfNamedParameters(IDispatch dispatch, string[] names, int methodDispId, out GCHandle pinningHandle) 327pinningHandle = GCHandle.Alloc(null, GCHandleType.Pinned);
Microsoft.Diagnostics.DataContractReader.Legacy (71)
ClrDataMethodDefinition.cs (8)
223GCHandle gcHandle = GCHandle.FromIntPtr((IntPtr)(*handle)); 276GCHandle gcHandle = GCHandle.FromIntPtr((IntPtr)handle); 511GCHandle gcHandle = GCHandle.FromIntPtr((IntPtr)(*handle)); 560GCHandle gcHandle = GCHandle.FromIntPtr((IntPtr)handle);
ClrDataMethodInstance.cs (4)
638GCHandle gcHandle = GCHandle.FromIntPtr((IntPtr)(*handle)); 685GCHandle gcHandle = GCHandle.FromIntPtr((IntPtr)handle);
ClrDataModule.cs (4)
414GCHandle gcHandle = GCHandle.FromIntPtr((IntPtr)(*handle)); 470GCHandle gcHandle = GCHandle.FromIntPtr((IntPtr)handle);
ClrDataValue.cs (4)
786GCHandle gcHandle = GCHandle.FromIntPtr((IntPtr)(*handle)); 857GCHandle gcHandle = GCHandle.FromIntPtr((IntPtr)handle);
Dbi\DacDbiImpl.cs (20)
1874GCHandle gcHandle = GCHandle.FromIntPtr((nint)ppSFIHandle); 1906GCHandle gcHandle = GCHandle.FromIntPtr((nint)pSFIHandle); 1963GCHandle gcHandle = GCHandle.FromIntPtr((nint)pSFIHandle); 1997GCHandle gcHandle = GCHandle.FromIntPtr((nint)pSFIHandle); 2085GCHandle gcHandle = GCHandle.FromIntPtr((nint)pSFIHandle); 2572GCHandle gcHandle = GCHandle.FromIntPtr((nint)pSFIHandle); 4982GCHandle gcHandle = GCHandle.FromIntPtr((nint)handle); 5018GCHandle gcHandle = GCHandle.FromIntPtr((nint)handle); 5293GCHandle gcHandle = GCHandle.FromIntPtr((nint)handle); 5325GCHandle gcHandle = GCHandle.FromIntPtr((nint)handle);
Dbi\Helpers\StackWalkHandleData.cs (3)
49GCHandle gcHandle = GCHandle.Alloc(this); 50return (nuint)GCHandle.ToIntPtr(gcHandle);
IEnum.cs (3)
14GCHandle gcHandle = GCHandle.Alloc(this); 15return GCHandle.ToIntPtr(gcHandle).ToInt64();
MetaDataImportImpl.cs (7)
75GCHandle handle = GCHandle.Alloc(e); 76nint ptr = GCHandle.ToIntPtr(handle); 85GCHandle handle = GCHandle.FromIntPtr(hEnum); 121GCHandle handle = GCHandle.FromIntPtr(hEnum);
NativeStringHolder.cs (2)
22private readonly GCHandle _delegateHandle; 35_delegateHandle = GCHandle.Alloc(assignCopy);
SOSDacImpl.IXCLRDataProcess.cs (16)
492GCHandle gcHandle = GCHandle.FromIntPtr((IntPtr)(*handle)); 540GCHandle gcHandle = GCHandle.FromIntPtr((IntPtr)handle); 684GCHandle gcHandle = GCHandle.FromIntPtr((IntPtr)(*handle)); 732GCHandle gcHandle = GCHandle.FromIntPtr((IntPtr)handle); 1075GCHandle gcHandle = GCHandle.FromIntPtr((IntPtr)(*handle)); 1122GCHandle gcHandle = GCHandle.FromIntPtr((IntPtr)handle); 1713GCHandle gcHandle = GCHandle.FromIntPtr((IntPtr)(*handle)); 1778GCHandle gcHandle = GCHandle.FromIntPtr((IntPtr)handle);
Microsoft.ML.LightGbm (6)
WrappedLightGbmDataset.cs (6)
52GCHandle[] gcValues = new GCHandle[numCol]; 53GCHandle[] gcIndices = new GCHandle[numCol]; 60gcValues[i] = GCHandle.Alloc(sampleValuePerColumn[i], GCHandleType.Pinned); 62gcIndices[i] = GCHandle.Alloc(sampleIndicesPerColumn[i], GCHandleType.Pinned);
Microsoft.ML.Mkl.Components (12)
SymSgdClassificationTrainer.cs (12)
341public GCHandle GcHandle; 346GcHandle = GCHandle.Alloc(Buffer, GCHandleType.Pinned); 487public void GiveArrayOfSize(int size, out GCHandle? outGcHandle, out int outArrayStartIndex) 663public bool GiveNextInstance(out InstanceProperties? prop, out GCHandle? indicesGcHandle, out int indicesStartIndex, 664out GCHandle? valuesGcHandle, out int valuesStartIndex) 736GCHandle stateGCHandle = default; 739stateGCHandle = GCHandle.Alloc(state, GCHandleType.Pinned); 872int numThreads, bool tuneNumLocIter, ref int numLocIter, float tolerance, bool needShuffle, bool shouldInitialize, GCHandle stateGCHandle, ChannelCallBack info) 887while (inputDataManager.GiveNextInstance(out InstanceProperties? prop, out GCHandle? indicesGcHandle, out int indicesStartIndex, out GCHandle? valuesGcHandle, out int valuesStartIndex)) 926public static void MapBackWeightVector(Span<float> weightVector, GCHandle stateGCHandle) 935public static void DeallocateSequentially(GCHandle stateGCHandle)
Microsoft.ML.Vision (4)
ImageClassificationTrainer.cs (4)
975var featureBufferHandle = GCHandle.Alloc(featuresBuffer, GCHandleType.Pinned); 977var labelBufferHandle = GCHandle.Alloc(labelBuffer, GCHandleType.Pinned);
Microsoft.NET.StringTools (2)
WeakStringCache.cs (2)
36private GCHandle weakHandle; 80weakHandle = GCHandle.Alloc(str, GCHandleType.Weak);
Microsoft.Private.Windows.Core (17)
Windows\Win32\PInvokeCore.EnumChildWindows.cs (3)
23GCHandle gcHandle = GCHandle.Alloc(callback); 44return ((EnumChildWindowsCallback)((GCHandle)(nint)lParam).Target!)(hWnd);
Windows\Win32\PInvokeCore.EnumDisplayMonitors.cs (3)
19GCHandle gcHandle = GCHandle.Alloc(callBack); 39return ((EnumDisplayMonitorsCallback)((GCHandle)(nint)lParam).Target!)(monitor, hdc);
Windows\Win32\PInvokeCore.EnumThreadWindows.cs (3)
25GCHandle gcHandle = GCHandle.Alloc(callback); 48return ((EnumThreadWindowsCallback)((GCHandle)(nint)lParam).Target!)(hWnd);
Windows\Win32\PInvokeCore.EnumWindows.cs (3)
22GCHandle gcHandle = GCHandle.Alloc(callback); 42return ((EnumWindowsCallback)((GCHandle)(nint)lParam).Target!)(hWnd);
Windows\Win32\System\Com\Lifetime.cs (5)
31GCHandle.FromIntPtr((nint)lifetime->_handle).Free(); 44/// This creates a <see cref="GCHandle"/> to root the <paramref name="object"/> until ref 58wrapper->_handle = (void*)GCHandle.ToIntPtr(GCHandle.Alloc(@object)); 75return (TObject?)GCHandle.FromIntPtr((IntPtr)lifetime->_handle).Target;
Mono.Cecil.Pdb (2)
Mono.Cecil.Pdb\SymWriter.cs (2)
158 var handle = GCHandle.Alloc (metadata, GCHandleType.Pinned);
mscorlib (1)
parent\ref\mscorlib.cs (1)
691[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.InteropServices.GCHandle))]
netstandard (1)
netstandard.cs (1)
1696[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.InteropServices.GCHandle))]
PresentationCore (23)
MS\Internal\FontCache\FontSource.cs (2)
433_memoryHandle = GCHandle.Alloc(bits, GCHandleType.Pinned); 459private GCHandle _memoryHandle;
MS\Internal\Shaping\TypefaceMap.cs (1)
91GCHandle gcHandle;
src\wpf\src\Microsoft.DotNet.Wpf\src\Shared\MS\Internal\CharacterBuffer.cs (10)
39public abstract IntPtr PinAndGetCharacterPointer(int offset, out GCHandle gcHandle); 44public abstract void UnpinCharacterPointer(GCHandle gcHandle); 218public override unsafe IntPtr PinAndGetCharacterPointer(int offset, out GCHandle gcHandle) 220gcHandle = GCHandle.Alloc(_characterArray, GCHandleType.Pinned); 227public override void UnpinCharacterPointer(GCHandle gcHandle) 317public override unsafe IntPtr PinAndGetCharacterPointer(int offset, out GCHandle gcHandle) 319gcHandle = GCHandle.Alloc(_string, GCHandleType.Pinned); 326public override void UnpinCharacterPointer(GCHandle gcHandle) 426public override IntPtr PinAndGetCharacterPointer(int offset, out GCHandle gcHandle) 435public override void UnpinCharacterPointer(GCHandle gcHandle)
System\Windows\Media\EventProxy.cs (5)
31((System.Runtime.InteropServices.GCHandle)(pEPD.m_handle)).Free(); 34internal System.Runtime.InteropServices.GCHandle m_handle; 105System.Runtime.InteropServices.GCHandle handle = (System.Runtime.InteropServices.GCHandle)(epd.m_handle); 138m_handle = System.Runtime.InteropServices.GCHandle.Alloc(epw, System.Runtime.InteropServices.GCHandleType.Normal)
System\Windows\Media\StreamAsIStream.cs (5)
55((System.Runtime.InteropServices.GCHandle)(pSD.m_handle)).Free(); 58internal System.Runtime.InteropServices.GCHandle m_handle; 510System.Runtime.InteropServices.GCHandle handle = (System.Runtime.InteropServices.GCHandle)(sd.m_handle); 657sd.m_handle = System.Runtime.InteropServices.GCHandle.Alloc(sais, System.Runtime.InteropServices.GCHandleType.Normal);
PresentationFramework (12)
MS\Internal\WindowsRuntime\Generated\WinRT\Marshalers.cs (5)
16public static void Dispose(this GCHandle handle) 35public GCHandle _gchandle; 51m._gchandle = GCHandle.Alloc(value, GCHandleType.Pinned); 276public MarshalerArray(Array array) => _gchandle = GCHandle.Alloc(array, GCHandleType.Pinned); 279public GCHandle _gchandle;
System\Windows\Documents\WinEventHandler.cs (2)
33_gchThis = GCHandle.Alloc(_winEventProc); 162private GCHandle _gchThis;
System\Windows\Standard\MessageWindow.cs (5)
56GCHandle gcHandle = default(GCHandle); 59gcHandle = GCHandle.Alloc(this); 149GCHandle gcHandle = GCHandle.FromIntPtr(createStruct.lpCreateParams);
System.Data.OleDb (4)
ColumnBinding.cs (4)
46private GCHandle _pinnedBuffer; 700_pinnedBuffer = GCHandle.Alloc(value, GCHandleType.Pinned); 747_pinnedBuffer = GCHandle.Alloc(value, GCHandleType.Pinned); 766_pinnedBuffer = GCHandle.Alloc(value, GCHandleType.Pinned);
System.Diagnostics.EventLog (10)
System\Diagnostics\EventLog.cs (5)
889GCHandle[] handles = new GCHandle[insertionStrings.Length]; 890GCHandle stringsRoot = GCHandle.Alloc(addresses, GCHandleType.Pinned); 901handles[i] = GCHandle.Alloc(insertionStrings[i], GCHandleType.Pinned);
System\Diagnostics\EventLogInternal.cs (5)
1382GCHandle[] stringHandles = new GCHandle[strings.Length]; 1383GCHandle stringsRootHandle = GCHandle.Alloc(stringRoots, GCHandleType.Pinned); 1388stringHandles[strIndex] = GCHandle.Alloc(strings[strIndex], GCHandleType.Pinned);
System.DirectoryServices (3)
Interop\AdsValueHelper2.cs (3)
44private GCHandle _pinnedHandle; 265_pinnedHandle = GCHandle.Alloc(managedValue, GCHandleType.Pinned); 274_pinnedHandle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
System.Net.Http.WinHttpHandler (14)
System\Net\Http\WinHttpHandler.cs (2)
1310GCHandle pinnedHandle = GCHandle.Alloc(proxyInfo, GCHandleType.Pinned);
System\Net\Http\WinHttpRequestState.cs (12)
31private GCHandle _operationHandle; 49_operationHandle = GCHandle.Alloc(this); 55GCHandle stateHandle = GCHandle.FromIntPtr(gcHandle); 61return GCHandle.ToIntPtr(_operationHandle); 159private GCHandle _cachedReceivePinnedBuffer; 160private GCHandle _cachedSendPinnedBuffer; 171_cachedReceivePinnedBuffer = GCHandle.Alloc(buffer, GCHandleType.Pinned); 184_cachedSendPinnedBuffer = GCHandle.Alloc(buffer, GCHandleType.Pinned); 212_cachedReceivePinnedBuffer = default(GCHandle); 218_cachedSendPinnedBuffer = default(GCHandle); 224_operationHandle = default(GCHandle);
System.Net.Quic (34)
System\Net\Quic\Internal\MsQuicSafeHandle.cs (2)
91private GCHandle _context; 112public unsafe MsQuicContextSafeHandle(QUIC_HANDLE* handle, GCHandle context, SafeHandleType safeHandleType, MsQuicSafeHandle? parent = null)
System\Net\Quic\Internal\ResettableValueTaskSource.cs (5)
34private GCHandle _keepAlive; 102_keepAlive = GCHandle.Alloc(keepAlive); 324GCHandle handle = GCHandle.Alloc(keepAlive); 327((GCHandle)state!).Free();
System\Net\Quic\Internal\ValueTaskSource.cs (2)
28private GCHandle _keepAlive; 85_keepAlive = GCHandle.Alloc(keepAlive);
System\Net\Quic\QuicConnection.cs (10)
319GCHandle context = GCHandle.Alloc(this, GCHandleType.Weak); 326(void*)GCHandle.ToIntPtr(context), 353GCHandle context = GCHandle.Alloc(this, GCHandleType.Weak); 361(void*)GCHandle.ToIntPtr(context)); 575GCHandle keepObject = GCHandle.Alloc(this); 787GCHandle stateHandle = GCHandle.FromIntPtr((IntPtr)context);
System\Net\Quic\QuicListener.cs (7)
123GCHandle context = GCHandle.Alloc(this, GCHandleType.Weak); 130(void*)GCHandle.ToIntPtr(context), 182GCHandle keepObject = GCHandle.Alloc(this); 373GCHandle stateHandle = GCHandle.FromIntPtr((IntPtr)context);
System\Net\Quic\QuicStream.cs (8)
198GCHandle context = GCHandle.Alloc(this, GCHandleType.Weak); 206(void*)GCHandle.ToIntPtr(context), 240GCHandle context = GCHandle.Alloc(this, GCHandleType.Weak); 251(void*)GCHandle.ToIntPtr(context)); 716GCHandle stateHandle = GCHandle.FromIntPtr((IntPtr)context);
System.Net.Requests (2)
System\Net\TimerThread.cs (2)
207_thisHandle = (IntPtr)GCHandle.Alloc(this); 247((GCHandle)_thisHandle).Free();
System.Net.Security (6)
src\runtime\src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.OpenSsl.cs (4)
1294GCHandle gch = GCHandle.FromIntPtr(ptr); 1326GCHandle gch = GCHandle.FromIntPtr(ptr);
src\runtime\src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.SslCtx.cs (2)
84private GCHandle _gch; 172_gch = GCHandle.Alloc(this);
System.Net.Sockets (12)
System\Net\Sockets\SocketPal.Unix.cs (12)
299Span<GCHandle> handles = allocOnStack ? stackalloc GCHandle[IovStackThreshold] : new GCHandle[maxBuffers]; 311handles[i] = GCHandle.Alloc(buffer.Array, GCHandleType.Pinned); 411Span<GCHandle> handles = allocOnStack ? stackalloc GCHandle[IovStackThreshold] : new GCHandle[maxBuffers]; 425handles[i] = GCHandle.Alloc(buffer.Array, GCHandleType.Pinned); 553Span<GCHandle> handles = allocOnStack ? stackalloc GCHandle[IovStackThreshold] : new GCHandle[buffersCount]; 564handles[i] = GCHandle.Alloc(buffer.Array, GCHandleType.Pinned);
System.Numerics.Tensors (2)
System\Numerics\Tensors\netcore\Tensor_1.cs (2)
210GCHandle handle = GCHandle.Alloc(_values, GCHandleType.Pinned);
System.Private.CoreLib (132)
Internal\Runtime\CompilerServices\OpenMethodResolver.cs (4)
28private readonly GCHandle _readerGCHandle; 34public OpenMethodResolver(RuntimeTypeHandle declaringTypeOfSlot, int slot, GCHandle readerGCHandle, int handle) 45public OpenMethodResolver(RuntimeTypeHandle declaringTypeOfSlot, RuntimeMethodHandle gvmSlot, GCHandle readerGCHandle, int handle) 55public OpenMethodResolver(RuntimeTypeHandle declaringType, IntPtr codePointer, GCHandle readerGCHandle, int handle, short resolveType)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Buffers\MemoryHandle.cs (2)
14private GCHandle _handle; 25public MemoryHandle(void* pointer, GCHandle handle = default, IPinnable? pinnable = default)
src\runtime\src\libraries\System.Private.CoreLib\src\System\ComAwareWeakReference.cs (11)
86GCHandle.InternalFree(_weakHandle); 98GCHandle.InternalSet(_weakHandle, target); 103internal object? Target => GCHandle.InternalGet(_weakHandle); 115target = Unsafe.As<T>(GCHandle.InternalGet(_weakHandle)); 122GCHandle.InternalSet(_weakHandle, target); 136nint newHandle = GCHandle.InternalAlloc(newRef, GCHandleType.Normal); 145GCHandle.InternalFree(newHandle); 149return Unsafe.As<ComAwareWeakReference>(GCHandle.InternalGet(taggedHandle & ~HandleTagBits)!); 156return Unsafe.As<ComAwareWeakReference>(GCHandle.InternalGet(taggedHandle & ~HandleTagBits)!); 164Unsafe.As<ComAwareWeakReference>(GCHandle.InternalGet(taggedHandle & ~HandleTagBits)!); 174nint newHandle = GCHandle.InternalAlloc(comAwareRef, GCHandleType.Normal);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventProvider.cs (3)
600GCHandle[] rgGCHandle = new GCHandle[refObjIndex]; 605rgGCHandle[i] = GCHandle.Alloc(dataRefObj[i], GCHandleType.Pinned);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\TraceLogging\DataCollector.cs (5)
27private GCHandle* pinsEnd; 31private GCHandle* pins; 42GCHandle* pins, 312GCHandle* pinsTemp = this.pins; 327*pinsTemp = GCHandle.Alloc(value, GCHandleType.Pinned);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\TraceLogging\TraceLoggingEventSource.cs (5)
431GCHandle* pins = stackalloc GCHandle[pinCount]; 609GCHandle* pins = stackalloc GCHandle[pinCount]; 720private static unsafe void WriteCleanup(GCHandle* pPins, int cPins)
src\runtime\src\libraries\System.Private.CoreLib\src\System\IO\PinnedBufferMemoryStream.cs (2)
15private GCHandle _pinningHandle; 22_pinningHandle = GCHandle.Alloc(array, GCHandleType.Pinned);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Memory.cs (4)
401GCHandle handle = GCHandle.Alloc(tmpObject, GCHandleType.Pinned); 420GCHandle handle = GCHandle.Alloc(tmpObject, GCHandleType.Pinned);
src\runtime\src\libraries\System.Private.CoreLib\src\System\ReadOnlyMemory.cs (4)
316GCHandle handle = GCHandle.Alloc(tmpObject, GCHandleType.Pinned); 335GCHandle handle = GCHandle.Alloc(tmpObject, GCHandleType.Pinned);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\ComWrappers.cs (15)
230return Unsafe.As<ManagedObjectWrapperHolder>(GCHandle.FromIntPtr(handle).Target); 381GCHandle.InternalFree(handle); 521if (refCountedHandle != IntPtr.Zero && GCHandle.InternalGet(refCountedHandle) != null) 708internal GCHandle _nativeObjectWrapperWeakHandle; // mutable struct; do not make this readonly 740_nativeObjectWrapperWeakHandle = GCHandle.Alloc(this, GCHandleType.Weak); 1838internal sealed class GCHandleSet : IEnumerable<GCHandle> 1848public void Add(GCHandle handle) 1922public void Remove(GCHandle handle) 1951private static int GetBucket(GCHandle handle, int numBuckets) 1959IEnumerator<GCHandle> IEnumerable<GCHandle>.GetEnumerator() => GetEnumerator(); 1961IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable<GCHandle>)this).GetEnumerator(); 1966public GCHandle _value; 1969public struct Enumerator : IEnumerator<GCHandle> 1984public GCHandle Current
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\GCHandle.cs (13)
28public partial struct GCHandle : IEquatable<GCHandle> 65public static GCHandle Alloc(object? value) => new GCHandle(value, GCHandleType.Normal); 72public static GCHandle Alloc(object? value, GCHandleType type) => new GCHandle(value, type); 156public static explicit operator GCHandle(IntPtr value) => FromIntPtr(value); 158public static GCHandle FromIntPtr(IntPtr value) 165public static explicit operator IntPtr(GCHandle value) => ToIntPtr(value); 167public static IntPtr ToIntPtr(GCHandle value) => value._handle; 171public override readonly bool Equals([NotNullWhen(true)] object? o) => o is GCHandle other && Equals(other); 176public readonly bool Equals(GCHandle other) => _handle == other._handle; 178public static bool operator ==(GCHandle a, GCHandle b) => a._handle == b._handle; 180public static bool operator !=(GCHandle a, GCHandle b) => a._handle != b._handle;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\GCHandle.T.cs (9)
21/// <seealso cref="GCHandle" /> 35_handle = GCHandle.InternalAlloc(target, GCHandleType.Normal); 50GCHandle.CheckUninitialized(handle); 52return Unsafe.As<T>(GCHandle.InternalGet(handle)!); 57GCHandle.CheckUninitialized(handle); 58GCHandle.InternalSet(handle, value); 71/// interchangable with <see cref="GCHandle"/>. 83/// interchangable with <see cref="GCHandle"/>. 97GCHandle.InternalFree(handle);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Java\JavaMarshal.Unsupported.cs (7)
54/// with the handle and can be retrieved by the runtime via <see cref="GetContext(GCHandle)"/>. 57/// <returns>A <see cref="GCHandle"/> that represents the allocated reference-tracking handle.</returns> 60public static unsafe GCHandle CreateReferenceTrackingHandle(object obj, void* context) 69/// <param name="obj">The <see cref="GCHandle"/> whose context should be returned.</param> 77public static unsafe void* GetContext(GCHandle obj) 89/// <param name="unreachableObjectHandles">A span of <see cref="GCHandle"/> values that were determined to be unreachable from the native side.</param> 93ReadOnlySpan<GCHandle> unreachableObjectHandles)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\ObjectiveC\ObjectiveCMarshal.PlatformNotSupported.cs (2)
93/// The caller is responsible for freeing the returned <see cref="GCHandle"/>. 95public static GCHandle CreateReferenceTrackingHandle(
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\PinnedGCHandle.T.cs (9)
22/// <seealso cref="GCHandle" /> 37_handle = GCHandle.InternalAlloc(target, GCHandleType.Pinned); 52GCHandle.CheckUninitialized(handle); 54return Unsafe.As<T>(GCHandle.InternalGet(handle)!); 59GCHandle.CheckUninitialized(handle); 61GCHandle.InternalSet(handle, value); 105/// interchangable with <see cref="GCHandle"/>. 117/// interchangable with <see cref="GCHandle"/>. 131GCHandle.InternalFree(handle);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\TrackerObjectManager.cs (1)
74foreach (GCHandle weakNativeObjectWrapperHandle in s_referenceTrackerNativeObjectWrapperCache)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\WeakGCHandle.T.cs (9)
21/// <seealso cref="GCHandle" /> 36_handle = GCHandle.InternalAlloc(target, trackResurrection ? GCHandleType.WeakTrackResurrection : GCHandleType.Weak); 54GCHandle.CheckUninitialized(handle); 56T? obj = Unsafe.As<T>(GCHandle.InternalGet(handle)); 67GCHandle.CheckUninitialized(handle); 68GCHandle.InternalSet(handle, target); 80/// interchangable with <see cref="GCHandle"/>. 92/// interchangable with <see cref="GCHandle"/>. 106GCHandle.InternalFree(handle);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\Loader\AssemblyLoadContext.cs (6)
102var thisHandle = GCHandle.Alloc(this, IsCollectible ? GCHandleType.WeakTrackResurrection : GCHandleType.Normal); 103var thisHandlePtr = GCHandle.ToIntPtr(thisHandle); 148var thisStrongHandle = GCHandle.Alloc(this, GCHandleType.Normal); 149var thisStrongHandlePtr = GCHandle.ToIntPtr(thisStrongHandle);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\Overlapped.cs (6)
151(nuint)(sizeof(NativeOverlapped) + sizeof(nuint)) + handleCount * (nuint)sizeof(GCHandle)); 161GCHandleRef(pNativeOverlapped, 0) = GCHandle.Alloc(this); 171GCHandleRef(pNativeOverlapped, (nuint)(i + 1)) = GCHandle.Alloc(objArray[i], GCHandleType.Pinned); 177GCHandleRef(pNativeOverlapped, 1) = GCHandle.Alloc(userData, GCHandleType.Pinned); 222private static ref GCHandle GCHandleRef(NativeOverlapped* pNativeOverlapped, nuint index) 223=> ref *((GCHandle*)((nuint*)(pNativeOverlapped + 1) + 1) + index);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\WaitSubsystem.HandleManager.Unix.cs (4)
49IntPtr handle = GCHandle.ToIntPtr(GCHandle.Alloc(waitableObject, GCHandleType.Normal)); 66return (IWaitableObject)GCHandle.FromIntPtr(handle).Target!; 82GCHandle.FromIntPtr(handle).Free();
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\WaitSubsystem.Unix.cs (1)
105/// - <see cref="HandleManager"/> currently uses <see cref="Runtime.InteropServices.GCHandle"/> in the interest of
src\runtime\src\libraries\System.Private.CoreLib\src\System\WeakReference.cs (5)
83nint h = GCHandle.InternalAlloc(target, trackResurrection ? GCHandleType.WeakTrackResurrection : GCHandleType.Weak); 132bool result = GCHandle.InternalGet(wh) != null; 184target = GCHandle.InternalGet(th); 216GCHandle.InternalSet(th, value); 238GCHandle.InternalFree(handle);
src\runtime\src\libraries\System.Private.CoreLib\src\System\WeakReference.T.cs (3)
83nint h = GCHandle.InternalAlloc(target, trackResurrection ? GCHandleType.WeakTrackResurrection : GCHandleType.Weak); 120GCHandle.InternalSet(th, target); 159target = Unsafe.As<T>(GCHandle.InternalGet(th));
System\Runtime\InteropServices\TrackerObjectManager.NativeAot.cs (2)
157foreach (GCHandle weakNativeObjectWrapperHandle in s_referenceTrackerNativeObjectWrapperCache) 184foreach (GCHandle weakNativeObjectWrapperHandle in s_referenceTrackerNativeObjectWrapperCache)
System.Private.Reflection.Execution (2)
Internal\Reflection\Execution\ExecutionEnvironmentImplementation.MappingTables.cs (1)
269GCHandle reader = Internal.TypeSystem.LockFreeObjectInterner.GetInternedObjectHandle(methodHandle.Reader);
Internal\Reflection\Execution\MethodInvokers\InstanceMethodInvoker.cs (1)
137new OpenMethodResolver(_declaringTypeHandle, MethodInvokeInfo.LdFtnResult, default(GCHandle), 0, resolveType).ToIntPtr(),
System.Private.TypeLoader (12)
Internal\Runtime\TypeLoader\LockFreeObjectInterner.cs (12)
9public class LockFreeObjectInterner : LockFreeReaderHashtableOfPointers<object, GCHandle> 12public static GCHandle GetInternedObjectHandle(object obj) 29protected override int GetValueHashCode(GCHandle value) 38protected override bool CompareKeyToValue(object key, GCHandle value) 47protected override bool CompareValueToValue(GCHandle value1, GCHandle value2) 56protected override GCHandle CreateValueFromKey(object key) 58return GCHandle.Alloc(key); 64protected override IntPtr ConvertValueToIntPtr(GCHandle value) 66return GCHandle.ToIntPtr(value); 72protected override GCHandle ConvertIntPtrToValue(IntPtr pointer) 74return GCHandle.FromIntPtr(pointer);
System.Private.Windows.Core (19)
Windows\Win32\PInvokeCore.EnumChildWindows.cs (3)
23GCHandle gcHandle = GCHandle.Alloc(callback); 44return ((EnumChildWindowsCallback)((GCHandle)(nint)lParam).Target!)(hWnd);
Windows\Win32\PInvokeCore.EnumDisplayMonitors.cs (3)
19GCHandle gcHandle = GCHandle.Alloc(callBack); 39return ((EnumDisplayMonitorsCallback)((GCHandle)(nint)lParam).Target!)(monitor, hdc);
Windows\Win32\PInvokeCore.EnumThreadWindows.cs (3)
25GCHandle gcHandle = GCHandle.Alloc(callback); 48return ((EnumThreadWindowsCallback)((GCHandle)(nint)lParam).Target!)(hWnd);
Windows\Win32\PInvokeCore.EnumWindows.cs (3)
22GCHandle gcHandle = GCHandle.Alloc(callback); 42return ((EnumWindowsCallback)((GCHandle)(nint)lParam).Target!)(hWnd);
Windows\Win32\System\Com\Lifetime.cs (5)
31GCHandle.FromIntPtr((nint)lifetime->_handle).Free(); 44/// This creates a <see cref="GCHandle"/> to root the <paramref name="object"/> until ref 58wrapper->_handle = (void*)GCHandle.ToIntPtr(GCHandle.Alloc(@object)); 75return (TObject?)GCHandle.FromIntPtr((IntPtr)lifetime->_handle).Target;
Windows\Win32\System\Variant\VARIANT.cs (2)
272GCHandle pin = default; 276pin = GCHandle.Alloc(array, GCHandleType.Pinned);
System.Reflection.Metadata (5)
System\Reflection\Internal\Utilities\PinnedObject.cs (2)
13private GCHandle _handle; 28_handle = GCHandle.Alloc(obj, GCHandleType.Pinned);
System\Reflection\Metadata\Internal\VirtualHeap.cs (3)
24public GCHandle Handle; 28public PinnedBlob(GCHandle handle, int length) 103var blob = new PinnedBlob(GCHandle.Alloc(value, GCHandleType.Pinned), value.Length);
System.Resources.Extensions (2)
src\runtime\src\libraries\System.Private.CoreLib\src\System\IO\PinnedBufferMemoryStream.cs (2)
15private GCHandle _pinningHandle; 22_pinningHandle = GCHandle.Alloc(array, GCHandleType.Pinned);
System.Runtime (1)
src\runtime\artifacts\obj\System.Runtime\Release\net11.0\System.Runtime.Forwards.cs (1)
687[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.InteropServices.GCHandle))]
System.Runtime.Caching (2)
System\Runtime\Caching\SRef.cs (2)
31private GCHandle _handle; 36_handle = GCHandle.Alloc(t);
System.Runtime.InteropServices (1)
src\runtime\artifacts\obj\System.Runtime.InteropServices\Release\net11.0\System.Runtime.InteropServices.Forwards.cs (1)
91[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.InteropServices.GCHandle))]
System.Runtime.InteropServices.JavaScript (20)
System\Runtime\InteropServices\JavaScript\Interop\JavaScriptExports.CoreCLR.cs (4)
50GCHandle callback_gc_handle = (GCHandle)arg1.slot.GCHandle; 109GCHandle exception_gc_handle = (GCHandle)arg1.slot.GCHandle;
System\Runtime\InteropServices\JavaScript\JSHostImplementation.Types.cs (1)
26GCHandle = (IntPtr)InteropServices.GCHandle.Alloc(this, GCHandleType.Normal);
System\Runtime\InteropServices\JavaScript\JSProxyContext.cs (9)
344IntPtr result = (IntPtr)GCHandle.Alloc(obj, handleType); 379holder = (PromiseHolder)((GCHandle)gcHandle).Target!; 402GCHandle handle = (GCHandle)holderGCHandle; 443GCHandle handle = (GCHandle)gcHandle; 578GCHandle gcHandle = (GCHandle)gch; 603((GCHandle)holder.GCHandle).Free();
System\Runtime\InteropServices\JavaScript\Marshaling\JSMarshalerArgument.Byte.cs (1)
125var array = (byte[])((GCHandle)slot.GCHandle).Target!;
System\Runtime\InteropServices\JavaScript\Marshaling\JSMarshalerArgument.Double.cs (1)
131var array = (double[])((GCHandle)slot.GCHandle).Target!;
System\Runtime\InteropServices\JavaScript\Marshaling\JSMarshalerArgument.Exception.cs (1)
29value = (Exception)((GCHandle)slot.GCHandle).Target;
System\Runtime\InteropServices\JavaScript\Marshaling\JSMarshalerArgument.Int32.cs (1)
125var array = (int[])((GCHandle)slot.GCHandle).Target!;
System\Runtime\InteropServices\JavaScript\Marshaling\JSMarshalerArgument.Object.cs (1)
32value = ((GCHandle)slot.GCHandle).Target;
System\Runtime\InteropServices\JavaScript\Marshaling\JSMarshalerArgument.Single.cs (1)
131var array = (float[])((GCHandle)slot.GCHandle).Target!;
System.Security.Cryptography (2)
System\Security\Cryptography\CryptoStream.cs (2)
724GCHandle pinHandle = GCHandle.Alloc(rentedBuffer, GCHandleType.Pinned);
System.Security.Principal.Windows (3)
System\Security\Principal\SID.cs (3)
951GCHandle[] HandleArray = new GCHandle[sourceSids.Count]; 970HandleArray[currentSid] = GCHandle.Alloc(sid.BinaryForm, GCHandleType.Pinned);
System.ServiceProcess.ServiceController (2)
System\ServiceProcess\ServiceController.cs (2)
893GCHandle argPtrsHandle = default; 896argPtrsHandle = GCHandle.Alloc(argPtrs, GCHandleType.Pinned);
System.Speech (60)
Internal\SapiInterop\SapiRecoInterop.cs (9)
432internal static ISpPhrase CreatePhraseFromText(string phrase, CultureInfo culture, out GCHandle[] memHandles, out IntPtr coMem) 448internal static ISpPhrase CreatePhraseFromWordUnits(RecognizedWordUnit[] words, CultureInfo culture, out GCHandle[] memHandles, out IntPtr coMem) 454List<GCHandle> handles = new(); 476GCHandle handle = GCHandle.Alloc(word.Text, GCHandleType.Pinned); 483GCHandle handle = GCHandle.Alloc(word.LexicalForm, GCHandleType.Pinned); 494GCHandle handle = GCHandle.Alloc(word.Pronunciation, GCHandleType.Pinned);
Internal\Synthesis\AudioBase.cs (8)
55GCHandle gc = GCHandle.Alloc(buffer); 380GCHandle gc = GCHandle.Alloc(waveHeader, GCHandleType.Pinned); 403GCHandle gc = GCHandle.Alloc(waveHeader, GCHandleType.Pinned); 413GCHandle gc = GCHandle.Alloc(this, GCHandleType.Pinned);
Internal\Synthesis\AudioDeviceOut.cs (1)
146GCHandle waveHdr = waveHeader.WAVEHDR;
Internal\Synthesis\ConvertTextFrag.cs (6)
14internal static bool ToSapi(List<TextFragment> ssmlFrags, ref GCHandle sapiFragLast) 33sapiFrag.gcText = GCHandle.Alloc(textFragment.TextToSpeak, GCHandleType.Pinned); 67sapiFrag.gcPhoneme = GCHandle.Alloc(ssmlState.Phoneme, GCHandleType.Pinned); 109sapiFragLast = GCHandle.Alloc(sapiFrag, GCHandleType.Pinned); 120sapiFrag.gcSayAsCategory = GCHandle.Alloc(sFormat, GCHandleType.Pinned); 124internal static void FreeTextSegment(ref GCHandle fragment)
Internal\Synthesis\TTSEngineProxy.cs (5)
61GCHandle gc = GCHandle.Alloc(wfx, GCHandleType.Pinned); 148GCHandle gc = GCHandle.Alloc(wfx, GCHandleType.Pinned); 152GCHandle spvTextFragment = new();
Internal\Synthesis\TTSVoice.cs (2)
94GCHandle targetFormat = new(); 98targetFormat = GCHandle.Alloc(targetWaveFormat, GCHandleType.Pinned);
Internal\Synthesis\WaveHeader.cs (5)
20_gcHandle = GCHandle.Alloc(buffer, GCHandleType.Pinned); 66internal GCHandle WAVEHDR 79_gcHandleWaveHdr = GCHandle.Alloc(_waveHdr, GCHandleType.Pinned); 141private GCHandle _gcHandle; 143private GCHandle _gcHandleWaveHdr;
Recognition\RecognizerBase.cs (4)
1578GCHandle gcHandle = GCHandle.Alloc(data, GCHandleType.Pinned); 1894GCHandle[]? memHandles = null; 1916foreach (GCHandle memHandle in memHandles)
Result\RecognitionResult.cs (8)
156GCHandle gc = GCHandle.Alloc(_sapiAudioBlob, GCHandleType.Pinned); 296GCHandle gc = GCHandle.Alloc(sapiResultBlob, GCHandleType.Pinned); 357GCHandle gc = GCHandle.Alloc(_sapiAlternatesBlob, GCHandleType.Pinned); 484GCHandle gc = GCHandle.Alloc(_phraseBuffer, GCHandleType.Pinned);
Result\RecognizedPhrase.cs (8)
166GCHandle gc = GCHandle.Alloc(_phraseBuffer, GCHandleType.Pinned); 290GCHandle gc = GCHandle.Alloc(_phraseBuffer, GCHandleType.Pinned); 412GCHandle gc = GCHandle.Alloc(_phraseBuffer, GCHandleType.Pinned); 782GCHandle gc = GCHandle.Alloc(_phraseBuffer, GCHandleType.Pinned);
Synthesis\TTSEngine\SAPIEngineTypes.cs (4)
30public GCHandle gcText; 31public GCHandle gcNext; 32public GCHandle gcPhoneme; 33public GCHandle gcSayAsCategory;
System.Windows.Forms (22)
System\Windows\Forms\Components\Timer.cs (2)
25private GCHandle _timerRoot; 114_timerRoot = GCHandle.Alloc(this);
System\Windows\Forms\Control.ControlNativeWindow.cs (2)
13private GCHandle _rootRef; // We will root the control when we do not want to be eligible for garbage collection. 43_rootRef = GCHandle.Alloc(GetControl(), GCHandleType.Normal);
System\Windows\Forms\Dialogs\CommonDialogs\FolderBrowserDialog.cs (4)
453GCHandle handle = GCHandle.Alloc(this); 463GCHandle.ToIntPtr(handle)); 494var instance = (FolderBrowserDialog)GCHandle.FromIntPtr(lpData).Target!;
System\Windows\Forms\Dialogs\TaskDialog\TaskDialog.cs (4)
81/// The <see cref="IntPtr"/> of a <see cref="GCHandle"/> that represents this 276(((GCHandle)lpRefData).Target as TaskDialog)!.HandleTaskDialogCallback( 559var instanceHandle = GCHandle.Alloc(this);
System\Windows\Forms\NativeWindow.cs (8)
38private static readonly Dictionary<HWND, GCHandle> s_windowHandles = []; 245GCHandle root = GCHandle.Alloc(window, GCHandleType.Weak); 247if (s_windowHandles.TryGetValue(handle, out GCHandle oldRoot)) 561s_windowHandles.TryGetValue(handle, out GCHandle value) && value.IsAllocated 613foreach ((HWND handle, GCHandle gcHandle) in s_windowHandles) 708if (!s_windowHandles.TryGetValue(hwnd, out GCHandle root)) 735s_windowHandles[hwnd] = GCHandle.Alloc(window.PreviousWindow, GCHandleType.Weak);
System\Windows\Forms\NotifyIcon.NotifyIconNativeWindow.cs (2)
16private GCHandle _rootRef; // We will root the control when we do not want to be eligible for garbage collection. 43_rootRef = GCHandle.Alloc(_reference, GCHandleType.Normal);
System.Windows.Forms.Primitives (4)
Windows\Win32\PInvoke.SendMessageCallback.cs (4)
19GCHandle gcHandle = GCHandle.Alloc(callback); 28GCHandle gcHandle = (GCHandle)(nint)dwData;
UIAutomationClient (8)
MS\Internal\Automation\EventListenerClientSide.cs (2)
32_gch = GCHandle.Alloc(_callbackDelegate); 294private GCHandle _gch; // GCHandle to keep GCs from moving the callback
MS\Internal\Automation\HwndProxyElementProvider.cs (2)
1576GCHandle gch = GCHandle.Alloc(enumWindows);
MS\Internal\Automation\UiaCoreApi.cs (2)
1555private static GCHandle _gchandle; 1560_gchandle = GCHandle.Alloc(onGetProviderDelegate);
MS\Internal\Automation\WinEventWrap.cs (2)
240_gchThis = GCHandle.Alloc(_winEventProc); 280private GCHandle _gchThis; // GCHandle to keep GCs from moving this callback
UIAutomationClientSideProviders (6)
MS\Internal\AutomationProxies\Misc.cs (2)
349GCHandle gch = GCHandle.Alloc(enumToolTipWindows);
MS\Internal\AutomationProxies\MSAAWinEventWrap.cs (2)
171_gchThis = GCHandle.Alloc(_winEventProc); 221private GCHandle _gchThis; // GCHandle to keep GCs from moving this callback
MS\Internal\AutomationProxies\WinEventTracker.cs (2)
124internal GCHandle _procHookHandle; 173hp._procHookHandle = GCHandle.Alloc (proc);