https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.safehandle.sethandle?view=netframework-4.8.1&viewFallbackFrom=net-10.0
SafeHandle.SetHandle(IntPtr) Method (System.Runtime.InteropServices) | Microsoft Learn
Sets the handle to the specified pre-existing handle.
methodsystemruntimemicrosoftlearn