internal static void ForwardWindowEvent(XEvent *xevent, bool isWmProtocolsEvent) { IntPtr userData; var dispatchProvider = Xlib.XlibDispatchProvider.Instance; if (isWmProtocolsEvent && (xevent->xclient.data.l[0] == (IntPtr)(void *)dispatchProvider.WindowProviderCreateWindowAtom)) { // We allow the WindowProviderCreateWindowAtom message to be forwarded to the Window instance // for xevent->xany.window. This allows some delayed initialization to occur since most of the // fields in Window are lazy. if (Environment.Is64BitProcess) { var lowerBits = unchecked ((uint)xevent->xclient.data.l[2].ToInt64()); var upperBits = unchecked ((ulong)(uint)xevent->xclient.data.l[3].ToInt64()); userData = (IntPtr)((upperBits << 32) | lowerBits); } else { var bits = xevent->xclient.data.l[1].ToInt32(); userData = (IntPtr)bits; } _ = XChangeProperty( xevent->xany.display, xevent->xany.window, dispatchProvider.WindowWindowProviderAtom, dispatchProvider.SystemIntPtrAtom, format: 8, PropModeReplace, (byte *)&userData, nelements: IntPtr.Size ); } else { UIntPtr actualTypeReturn; int actualFormatReturn; UIntPtr nitemsReturn; UIntPtr bytesAfterReturn; IntPtr *propReturn; ThrowExternalExceptionIfFailed(nameof(XGetWindowProperty), XGetWindowProperty( xevent->xany.display, xevent->xany.window, dispatchProvider.WindowWindowProviderAtom, long_offset: IntPtr.Zero, long_length: (IntPtr)IntPtr.Size, delete: False, dispatchProvider.SystemIntPtrAtom, &actualTypeReturn, &actualFormatReturn, &nitemsReturn, &bytesAfterReturn, (byte **)&propReturn )); userData = *propReturn; } XlibWindowProvider windowProvider = null !; Dictionary <UIntPtr, XlibWindow>?windows = null; var forwardMessage = false; XlibWindow?window = null; if (userData != IntPtr.Zero) { windowProvider = (XlibWindowProvider)GCHandle.FromIntPtr(userData).Target !; windows = windowProvider._windows.Value; forwardMessage = (windows?.TryGetValue(xevent->xany.window, out window)).GetValueOrDefault(); } if (forwardMessage) { Assert(windows != null, Resources.ArgumentNullExceptionMessage, nameof(windows)); Assert(window != null, Resources.ArgumentNullExceptionMessage, nameof(window)); window.ProcessWindowEvent(xevent, isWmProtocolsEvent); if (isWmProtocolsEvent && (xevent->xclient.data.l[0] == (IntPtr)(void *)dispatchProvider.WmDeleteWindowAtom)) { // We forward the WM_DELETE_WINDOW message to the corresponding Window instance // so that it can still be properly disposed of in the scenario that the // xevent->xany.window was destroyed externally. _ = RemoveWindow(windows, xevent->xany.display, xevent->xany.window, dispatchProvider); } } }
private void DeliveryReportCallbackImpl(IntPtr rk, IntPtr rkmessage, IntPtr opaque) { // Ensure registered handlers are never called as a side-effect of Dispose/Finalize (prevents deadlocks in common scenarios). if (ownedKafkaHandle.IsClosed) { return; } var msg = Util.Marshal.PtrToStructureUnsafe <rd_kafka_message>(rkmessage); // the msg._private property has dual purpose. Here, it is an opaque pointer set // by Topic.Produce to be an IDeliveryHandler. When Consuming, it's for internal // use (hence the name). if (msg._private == IntPtr.Zero) { // Note: this can occur if the ProduceAsync overload that accepts a DeliveryHandler // was used and the delivery handler was set to null. return; } var gch = GCHandle.FromIntPtr(msg._private); var deliveryHandler = (IDeliveryHandler)gch.Target; gch.Free(); Headers headers = null; if (this.enableDeliveryReportHeaders) { headers = new Headers(); Librdkafka.message_headers(rkmessage, out IntPtr hdrsPtr); if (hdrsPtr != IntPtr.Zero) { for (var i = 0; ; ++i) { var err = Librdkafka.header_get_all(hdrsPtr, (IntPtr)i, out IntPtr namep, out IntPtr valuep, out IntPtr sizep); if (err != ErrorCode.NoError) { break; } var headerName = Util.Marshal.PtrToStringUTF8(namep); byte[] headerValue = null; if (valuep != IntPtr.Zero) { headerValue = new byte[(int)sizep]; Marshal.Copy(valuep, headerValue, 0, (int)sizep); } headers.Add(headerName, headerValue); } } } IntPtr timestampType = (IntPtr)TimestampType.NotAvailable; long timestamp = 0; if (enableDeliveryReportTimestamp) { timestamp = Librdkafka.message_timestamp(rkmessage, out timestampType); } PersistenceStatus messageStatus = PersistenceStatus.PossiblyPersisted; if (enableDeliveryReportPersistedStatus) { messageStatus = Librdkafka.message_status(rkmessage); } deliveryHandler.HandleDeliveryReport( new DeliveryReport <Null, Null> { // Topic is not set here in order to avoid the marshalling cost. // Instead, the delivery handler is expected to cache the topic string. Partition = msg.partition, Offset = msg.offset, Error = KafkaHandle.CreatePossiblyFatalError(msg.err, null), Message = new Message <Null, Null> { Timestamp = new Timestamp(timestamp, (TimestampType)timestampType), Headers = headers } } ); }
/// <summary> /// ClassInit callback for managed classes. /// </summary> /// <param name="classPtr">Pointer to <see cref="Struct"/>.</param> /// <param name="userDataPtr">Pointer to user data from <see cref="TypeInfo"/>.</param> /// <remarks> /// This takes care of overriding the methods to make the managed type /// interop with the GObject type system. /// </remarks> static void UnmanagedInitManagedClass(IntPtr classPtr, IntPtr userDataPtr) { try { // Can't use type.GetGType () here since the type registration has // not finished. So, we get the GType this way instead. var gtype = Marshal.PtrToStructure <GType> (classPtr); var type = (Type)GCHandle.FromIntPtr(userDataPtr).Target; // override property native accessors Marshal.WriteIntPtr(classPtr, (int)setPropertyOffset, setPropertyPtr); Marshal.WriteIntPtr(classPtr, (int)getPropertyOffset, getPropertyPtr); Marshal.WriteIntPtr(classPtr, (int)notifyOffset, notifyPtr); // Install Properties uint propId = 1; // propId 0 is used internally, so we start with 1 foreach (var propInfo in type.GetProperties()) { if (propInfo.DeclaringType != type) { // only register properties declared in this type or in interfaces continue; } var name = propInfo.TryGetGPropertyName(); if (name == null) { // this property is not to be registered with the GObject type system continue; } // TODO: localize strings for nick and blurb var nick = propInfo.GetCustomAttribute <DisplayNameAttribute> (true) ?.DisplayName ?? name; var blurb = propInfo.GetCustomAttribute <DescriptionAttribute> (true) ?.Description ?? nick; var defaultValue = propInfo.GetCustomAttribute <DefaultValueAttribute> (true) ?.Value; // setup the flags var flags = default(ParamFlags); if (propInfo.CanRead) { flags |= ParamFlags.Readable; } if (propInfo.CanWrite) { flags |= ParamFlags.Writable; } // Construct properties don't work with managed types because they // require setting the property before the class has been instantiated. // So, we don't ever set ParamFlags.Construct or ParamFlags.ConstructOnly flags |= ParamFlags.StaticName; flags |= ParamFlags.StaticNick; flags |= ParamFlags.StaticBlurb; // Always explicit notify. Setting properties from managed code // must manually call notify, so if a property was set via // unmanaged code, it would result in double notification if // ExplicitNotify was not set. flags |= ParamFlags.ExplicitNotify; if (propInfo.GetCustomAttribute <ObsoleteAttribute> (true) != null) { flags |= ParamFlags.Deprecated; } // create the pspec instance based on type ParamSpec pspec; // TODO: Need to create special boxed type for non-GType objects var propertyGType = (GType)propInfo.PropertyType; var fundamentalGType = propertyGType.Fundamental; if (fundamentalGType == GType.Boolean) { pspec = new ParamSpecBoolean(name, nick, blurb, (bool)(defaultValue ?? default(bool)), flags); } else if (fundamentalGType == GType.Boxed) { pspec = new ParamSpecBoxed(name, nick, blurb, propertyGType, flags); } else if (fundamentalGType == GType.Char) { pspec = new ParamSpecChar(name, nick, blurb, sbyte.MinValue, sbyte.MaxValue, (sbyte)(defaultValue ?? default(sbyte)), flags); } else if (fundamentalGType == GType.UChar) { pspec = new ParamSpecUChar(name, nick, blurb, byte.MinValue, byte.MaxValue, (byte)(defaultValue ?? default(byte)), flags); } else if (fundamentalGType == GType.Double) { pspec = new ParamSpecDouble(name, nick, blurb, double.MinValue, double.MaxValue, (double)(defaultValue ?? default(double)), flags); } else if (fundamentalGType == GType.Float) { pspec = new ParamSpecFloat(name, nick, blurb, float.MinValue, float.MaxValue, (float)(defaultValue ?? default(float)), flags); } else if (fundamentalGType == GType.Enum) { pspec = new ParamSpecEnum(name, nick, blurb, propertyGType, (System.Enum)defaultValue, flags); } else if (fundamentalGType == GType.Flags) { pspec = new ParamSpecFlags(name, nick, blurb, propertyGType, (System.Enum)defaultValue, flags); } else if (fundamentalGType == GType.Int) { pspec = new ParamSpecInt(name, nick, blurb, int.MinValue, int.MaxValue, (int)(defaultValue ?? default(int)), flags); } else if (fundamentalGType == GType.UInt) { pspec = new ParamSpecUInt(name, nick, blurb, uint.MinValue, uint.MaxValue, (uint)(defaultValue ?? default(uint)), flags); } else if (fundamentalGType == GType.Int64) { pspec = new ParamSpecInt64(name, nick, blurb, long.MinValue, long.MaxValue, (long)(defaultValue ?? default(long)), flags); } else if (fundamentalGType == GType.UInt64) { pspec = new ParamSpecUInt64(name, nick, blurb, ulong.MinValue, ulong.MaxValue, (ulong)(defaultValue ?? default(ulong)), flags); } else if (fundamentalGType == GType.Long) { pspec = new ParamSpecLong(name, nick, blurb, nlong.MinValue, nlong.MaxValue, (nlong)(defaultValue ?? default(nlong)), flags); } else if (fundamentalGType == GType.ULong) { pspec = new ParamSpecULong(name, nick, blurb, nulong.MinValue, nulong.MaxValue, (nulong)(defaultValue ?? default(nulong)), flags); } else if (fundamentalGType == GType.Object) { pspec = new ParamSpecObject(name, nick, blurb, propertyGType, flags); } // TODO: do we need this one? // else if (fundamentalGType == GType.Param) { // pspec = new ParamSpecParam (name, nick, blurb, ?, flags); // } else if (fundamentalGType == GType.Pointer) { pspec = new ParamSpecPointer(name, nick, blurb, flags); } else if (fundamentalGType == GType.String) { pspec = new ParamSpecString(name, nick, blurb, (string)defaultValue, flags); } else if (fundamentalGType == GType.Type) { pspec = new ParamSpecGType(name, nick, blurb, propertyGType, flags); } else if (fundamentalGType == GType.Variant) { // TODO: need to pass variant type using attribute? // for now, always using any type var variantType = VariantType.Any; pspec = new ParamSpecVariant(name, nick, blurb, variantType, defaultValue == null ? null : (Variant)defaultValue, flags); } else { // TODO: Need more specific exception throw new Exception("unhandled GType"); } var methodInfo = propInfo.GetAccessors().First(); if (methodInfo.GetBaseDefinition() != methodInfo || propInfo.TryGetMatchingInterfacePropertyInfo() != null) { // if this type did not declare the property, the we know // we are overriding a property from a base class or interface var namePtr = GMarshal.StringToUtf8Ptr(name); g_object_class_override_property(classPtr, propId, namePtr); GMarshal.Free(namePtr); } else { g_object_class_install_property(classPtr, propId, pspec.Handle); GC.KeepAlive(pspec); } propId++; } foreach (var eventInfo in type.GetEvents()) { if (eventInfo.DeclaringType != type) { // only register events declared in this type continue; } var signalAttr = eventInfo.GetCustomAttribute <GSignalAttribute>(true); if (signalAttr == null) { // events without SignalAttribute are not installed continue; } // figure out the name var name = signalAttr.Name ?? eventInfo.Name; Signal.ValidateName(name); // figure out the flags var flags = default(SignalFlags); switch (signalAttr.When) { case EmissionStage.First: flags |= SignalFlags.RunFirst; break; case EmissionStage.Last: default: flags |= SignalFlags.RunLast; break; case EmissionStage.Cleanup: flags |= SignalFlags.RunCleanup; break; } if (signalAttr.NoRecurse) { flags |= SignalFlags.NoRecurse; } if (signalAttr.Detailed) { flags |= SignalFlags.Detailed; } if (signalAttr.Action) { flags |= SignalFlags.Action; } if (signalAttr.NoHooks) { flags |= SignalFlags.NoHooks; } if (eventInfo.GetCustomAttribute <ObsoleteAttribute> (true) != null) { flags |= SignalFlags.Deprecated; } // figure out the parameter types var methodInfo = eventInfo.EventHandlerType.GetMethod("Invoke"); var returnGType = methodInfo.ReturnType.GetGType(); var parameters = methodInfo.GetParameters(); var parameterGTypes = new GType[parameters.Length]; for (int i = 0; i < parameters.Length; i++) { parameterGTypes[i] = parameters[i].ParameterType.GetGType(); } // create a closure that will be called when the signal is emitted var fieldInfo = type.GetField(eventInfo.Name, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); var closure = new Closure((p) => { var eventDelegate = (MulticastDelegate)fieldInfo.GetValue(p[0]); return(eventDelegate?.DynamicInvoke(p.Skip(1).ToArray())); }); // register the signal var namePtr = GMarshal.StringToUtf8Ptr(name); var parameterGTypesPtr = GMarshal.CArrayToPtr <GType> (parameterGTypes, false); Signal.g_signal_newv(namePtr, gtype, flags, closure.Handle, null, IntPtr.Zero, null, returnGType, (uint)parameterGTypes.Length, parameterGTypesPtr); } } catch (Exception ex) { ex.LogUnhandledException(); } }
private unsafe int sensorListeningFunction(char *protocol, char *model, int id, int dataType, char *value, int timestamp, int callbackId, void *context) { string protocol2 = "Invalid data from Telldus API."; string model2 = "Invalid data from Telldus API."; string val = "Invalid data from Telldus API."; UnmanagedException ex = null; try { protocol2 = AsString(protocol, false); model2 = AsString(model, false); val = AsString(value, false); } catch (Exception innerException) { ex = new UnmanagedException("GetString failed during callback from Telldus API.", innerException); } foreach (SensorCallbackFunction current in sensorListenerList.Values) { if (context != null) { current(protocol2, model2, id, dataType, val, timestamp, callbackId, GCHandle.FromIntPtr((IntPtr)context).Target, ex); } else { current(protocol2, model2, id, dataType, val, timestamp, callbackId, null, ex); } } return(0); }
static void FreeGCHandle(IntPtr gchandle) { GCHandle.FromIntPtr(gchandle).Free(); }
private static void OnAuthenticatorCreateCb(IntPtr userData, IntPtr result, IntPtr app) { var(_, action) = BindingUtils.FromHandlePtr <(Action, Action <FfiResult, IntPtr, GCHandle>)>(userData, false); action(Marshal.PtrToStructure <FfiResult>(result), app, GCHandle.FromIntPtr(userData)); }
public static WinHttpRequestState FromIntPtr(IntPtr gcHandle) { GCHandle stateHandle = GCHandle.FromIntPtr(gcHandle); return((WinHttpRequestState)stateHandle.Target); }
public static WinHttpWebSocketState FromIntPtr(IntPtr gcHandle) { var stateHandle = GCHandle.FromIntPtr(gcHandle); return((WinHttpWebSocketState)stateHandle.Target); }
/// <summary> /// 初期化 /// </summary> /// <param name="name">トラックバーの名前</param> /// <param name="window">トラックバーの親ウィンドウ名</param> /// <param name="value">スライダの初期位置</param> /// <param name="max">スライダの最大値.最小値は常に 0.</param> /// <param name="callback">スライダの位置が変更されるたびに呼び出されるデリゲート</param> /// <param name="userdata"></param> #else /// <summary> /// Constructor /// </summary> /// <param name="name">Trackbar name</param> /// <param name="window">Window name</param> /// <param name="value">Initial slider position</param> /// <param name="max">The upper limit of the range this trackbar is working with. </param> /// <param name="callback">Callback handler</param> /// <param name="userdata"></param> #endif public CvTrackbar(string name, string window, int value, int max, CvTrackbarCallback2 callback, object?userdata) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException(nameof(name)); } if (string.IsNullOrEmpty(window)) { throw new ArgumentNullException(nameof(window)); } this.name = name; this.window = window; this.value = value; this.max = max; this.callback = callback ?? throw new ArgumentNullException(nameof(callback)); this.userdata = userdata; // userdataをIntPtrに変換 IntPtr userdataPtr; if (userdata != null) { gchUserdata = GCHandle.Alloc(userdata); userdataPtr = GCHandle.ToIntPtr(gchUserdata); } else { userdataPtr = IntPtr.Zero; } this.callback = callback; // コールバックdelegateを、userdataをobjectとするように変換 callbackNative = (pos, ud) => { if (ud == IntPtr.Zero) { callback(pos, null); } else { var gch = GCHandle.FromIntPtr(ud); callback(pos, gch.Target); } }; // コールバックdelegateをポインタに変換 gchCallback = GCHandle.Alloc(callback); gchCallbackNative = GCHandle.Alloc(callbackNative); var callbackPtr = Marshal.GetFunctionPointerForDelegate(callbackNative); //gchValue = GCHandle.Alloc(value, GCHandleType.Pinned); NativeMethods.HandleException( NativeMethods.highgui_createTrackbar(name, window, ref this.value, max, callbackPtr, userdataPtr, out result)); if (result == 0) { throw new OpenCvSharpException("Failed to create CvTrackbar."); } }
static unsafe void CopyHelper(BlockLiteral *dest, BlockLiteral *source) { dest->global_handle = (IntPtr)GCHandle.Alloc(GCHandle.FromIntPtr(dest->local_handle).Target); }
static unsafe void DisposeHelper(BlockLiteral *block) { GCHandle.FromIntPtr(block->global_handle).Free(); }
public unsafe void CleanupBlock() { GCHandle.FromIntPtr(local_handle).Free(); }
private static void TransferCallback(MonoUsbTransfer pTransfer) { ManualResetEvent completeEvent = GCHandle.FromIntPtr(pTransfer.PtrUserData).Target as ManualResetEvent; completeEvent.Set(); }
// This method is invoked by the VM when using the host-provided assembly load context // implementation. private static Assembly Resolve(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName) { AssemblyLoadContext context = (AssemblyLoadContext)(GCHandle.FromIntPtr(gchManagedAssemblyLoadContext).Target); return(context.ResolveUsingLoad(assemblyName)); }
private static VLInitCameraBehaviour GetInstance(IntPtr clientData) { return((VLInitCameraBehaviour)GCHandle.FromIntPtr(clientData).Target); }
static void update(IntPtr puser, int type, IntPtr database, IntPtr table, Int64 rowid) { SQLite3 instance = GCHandle.FromIntPtr(puser).Target as SQLite3; instance.update_callback(puser, type, database, table, rowid); }
private static void nativeEvent(IntPtr widget, IntPtr instanceHandle) { GCHandle handle = GCHandle.FromIntPtr(instanceHandle); (handle.Target as EventChangeCoord).nativeEvent(widget); }
static int commit(IntPtr puser) { SQLite3 instance = GCHandle.FromIntPtr(puser).Target as SQLite3; return(instance.commit_callback(puser)); }
public static double Update(IntPtr data) { GenericMeasure measure = (GenericMeasure)GCHandle.FromIntPtr(data).Target; return(measure.Update()); }
static void rollback(IntPtr puser) { SQLite3 instance = GCHandle.FromIntPtr(puser).Target as SQLite3; instance.rollback_callback(puser); }
private static unsafe uint NativeCallbackHandler( IntPtr listener, IntPtr context, ref ListenerEvent evt) { GCHandle gcHandle = GCHandle.FromIntPtr(context); Debug.Assert(gcHandle.IsAllocated); Debug.Assert(gcHandle.Target is not null); var state = (State)gcHandle.Target; if (evt.Type != QUIC_LISTENER_EVENT.NEW_CONNECTION) { return(MsQuicStatusCodes.InternalError); } SafeMsQuicConnectionHandle?connectionHandle = null; MsQuicConnection? msQuicConnection = null; try { ref NewConnectionInfo connectionInfo = ref *evt.Data.NewConnection.Info; IPEndPoint localEndPoint = MsQuicAddressHelpers.INetToIPEndPoint(ref *(SOCKADDR_INET *)connectionInfo.LocalAddress); IPEndPoint remoteEndPoint = MsQuicAddressHelpers.INetToIPEndPoint(ref *(SOCKADDR_INET *)connectionInfo.RemoteAddress); string targetHost = string.Empty; // compat with SslStream if (connectionInfo.ServerNameLength > 0 && connectionInfo.ServerName != IntPtr.Zero) { // TBD We should figure out what to do with international names. targetHost = Marshal.PtrToStringAnsi(connectionInfo.ServerName, connectionInfo.ServerNameLength); } SafeMsQuicConfigurationHandle?connectionConfiguration = state.ConnectionConfiguration; if (connectionConfiguration == null) { Debug.Assert(state.AuthenticationOptions.ServerCertificateSelectionCallback != null); try { // ServerCertificateSelectionCallback is synchronous. We will call it as needed when building configuration connectionConfiguration = SafeMsQuicConfigurationHandle.Create(state.ConnectionOptions, state.AuthenticationOptions, targetHost); } catch (Exception ex) { if (NetEventSource.Log.IsEnabled()) { NetEventSource.Error(state, $"[Listener#{state.GetHashCode()}] Exception occurred during creating configuration in connection callback: {ex}"); } } if (connectionConfiguration == null) { // We don't have safe handle yet so MsQuic will cleanup new connection. return(MsQuicStatusCodes.InternalError); } } connectionHandle = new SafeMsQuicConnectionHandle(evt.Data.NewConnection.Connection); uint status = MsQuicApi.Api.ConnectionSetConfigurationDelegate(connectionHandle, connectionConfiguration); if (MsQuicStatusHelper.SuccessfulStatusCode(status)) { msQuicConnection = new MsQuicConnection(localEndPoint, remoteEndPoint, state, connectionHandle, state.AuthenticationOptions.ClientCertificateRequired, state.AuthenticationOptions.CertificateRevocationCheckMode, state.AuthenticationOptions.RemoteCertificateValidationCallback); msQuicConnection.SetNegotiatedAlpn(connectionInfo.NegotiatedAlpn, connectionInfo.NegotiatedAlpnLength); if (!state.PendingConnections.TryAdd(connectionHandle.DangerousGetHandle(), msQuicConnection)) { msQuicConnection.Dispose(); } return(MsQuicStatusCodes.Success); } // If we fall-through here something wrong happened. }
private static void nativeEvent(IntPtr widget, IntPtr name, IntPtr instanceHandle) { GCHandle handle = GCHandle.FromIntPtr(instanceHandle); (handle.Target as EventWindowButtonPressedTranslator).nativeEvent(widget, name); }
internal static unsafe T ToShadow <T>(IntPtr thisPtr) where T : CppObjectShadow { return((T)GCHandle.FromIntPtr(((IntPtr *)(void *)thisPtr)[1]).Target); }
// This method is invoked by the VM to resolve a native library using the ResolvingUnmanagedDll event // after trying all other means of resolution. private static IntPtr ResolveUnmanagedDllUsingEvent(string unmanagedDllName, Assembly assembly, IntPtr gchManagedAssemblyLoadContext) { AssemblyLoadContext context = (AssemblyLoadContext)(GCHandle.FromIntPtr(gchManagedAssemblyLoadContext).Target) !; return(context.GetResolvedUnmanagedDll(assembly, unmanagedDllName)); }
private static void ProcFree(IntPtr context, ref IntPtr data) { GCHandle.FromIntPtr(data).Free(); data = IntPtr.Zero; }
// This method is invoked by the VM when using the host-provided assembly load context // implementation. private static IntPtr ResolveUnmanagedDll(string unmanagedDllName, IntPtr gchManagedAssemblyLoadContext) { AssemblyLoadContext context = (AssemblyLoadContext)(GCHandle.FromIntPtr(gchManagedAssemblyLoadContext).Target) !; return(context.LoadUnmanagedDll(unmanagedDllName)); }
static void ReleaseBytesCallback(IntPtr releaseRefCon, IntPtr baseAddress) { GCHandle handle = GCHandle.FromIntPtr(releaseRefCon); handle.Free(); }
public static GCHandle GetHandle(this IntPtr ptr) { return(GCHandle.FromIntPtr(ptr)); }
public static void Reload(IntPtr data, IntPtr rm, ref double maxValue) { Measure measure = (Measure)GCHandle.FromIntPtr(data).Target; measure.Reload(new Rainmeter.API(rm), ref maxValue); }
public static void OnDownloadSuccess(IntPtr callback, uint taskId) { DownloadCallBack.mCBImp = (IIPSMobileDownloadCallbackInterface)GCHandle.FromIntPtr(callback).get_Target(); DownloadCallBack.mCBImp.OnDownloadSuccess(taskId); }