• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# SafeHandle类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中SafeHandle的典型用法代码示例。如果您正苦于以下问题:C# SafeHandle类的具体用法?C# SafeHandle怎么用?C# SafeHandle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SafeHandle类属于命名空间,在下文中一共展示了SafeHandle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CheckValidOpenSslHandle

 internal static void CheckValidOpenSslHandle(SafeHandle handle)
 {
     if (handle == null || handle.IsInvalid)
     {
         throw CreateOpenSslCryptographicException();
     }
 }
开发者ID:rainersigwald,项目名称:corefx,代码行数:7,代码来源:Interop.ERR.cs


示例2: Poll

        /// <summary>
        /// Polls a File Descriptor for the passed in flags.
        /// </summary>
        /// <param name="fd">The descriptor to poll</param>
        /// <param name="events">The events to poll for</param>
        /// <param name="timeout">The amount of time to wait; -1 for infinite, 0 for immediate return, and a positive number is the number of milliseconds</param>
        /// <param name="triggered">The events that were returned by the poll call. May be PollEvents.POLLNONE in the case of a timeout.</param>
        /// <returns>An error or Error.SUCCESS.</returns>
        internal static unsafe Error Poll(SafeHandle fd, PollEvents events, int timeout, out PollEvents triggered)
        {
            bool gotRef = false;
            try
            {
                fd.DangerousAddRef(ref gotRef);

                var pollEvent = new PollEvent
                {
                    FileDescriptor = fd.DangerousGetHandle().ToInt32(),
                    Events = events,
                };

                uint unused;
                Error err = Poll(&pollEvent, 1, timeout, &unused);
                triggered = pollEvent.TriggeredEvents;
                return err;
            }
            finally
            {
                if (gotRef)
                {
                    fd.DangerousRelease();
                }
            }
        }
开发者ID:Czapek83,项目名称:corefx,代码行数:34,代码来源:Interop.Poll.cs


示例3: VirtualAlloc

 public static IntPtr VirtualAlloc(
         SafeHandle baseAddress,
         UIntPtr size,
         int allocationType,
         int protection)
 {
     return Interop.mincore.VirtualAllocFromApp(baseAddress, size, allocationType, protection);
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:8,代码来源:Interop.Windows.NETCore50.cs


示例4: TransmitFile

 internal static extern unsafe bool TransmitFile(
     SafeHandle socket,
     SafeHandle fileHandle,
     int numberOfBytesToWrite,
     int numberOfBytesPerSend,
     SafeHandle overlapped,
     TransmitFileBuffers* buffers,
     TransmitFileOptions flags);
开发者ID:chcosta,项目名称:corefx,代码行数:8,代码来源:Interop.TransmitFile.cs


示例5: VirtualAlloc

 public static IntPtr VirtualAlloc(
         SafeHandle baseAddress,
         UIntPtr size,
         int allocationType,
         int protection)
 {
     return Interop.Kernel32.VirtualAlloc(baseAddress, size, allocationType, protection);
 }
开发者ID:dotnet,项目名称:corefx,代码行数:8,代码来源:Interop.Windows.cs


示例6: DuplicateHandle

 internal static extern bool DuplicateHandle(
     SafeProcessHandle hSourceProcessHandle,
     SafeHandle hSourceHandle,
     SafeProcessHandle hTargetProcess,
     out SafeWaitHandle targetHandle,
     int dwDesiredAccess,
     bool bInheritHandle,
     int dwOptions
 );
开发者ID:noahfalk,项目名称:corefx,代码行数:9,代码来源:Interop.DuplicateHandle_SafeProcessHandle.cs


示例7: GetBytesAvailable

 internal static unsafe Error GetBytesAvailable(SafeHandle socket, int* available)
 {
     bool release = false;
     try
     {
         socket.DangerousAddRef(ref release);
         return DangerousGetBytesAvailable((int)socket.DangerousGetHandle(), available);
     }
     finally
     {
         if (release)
         {
             socket.DangerousRelease();
         }
     }
 }
开发者ID:benpye,项目名称:corefx,代码行数:16,代码来源:Interop.GetBytesAvailable.cs


示例8: GetSocketErrorOption

 internal static unsafe Error GetSocketErrorOption(SafeHandle socket, Error* socketError)
 {
     bool release = false;
     try
     {
         socket.DangerousAddRef(ref release);
         return DangerousGetSocketErrorOption((int)socket.DangerousGetHandle(), socketError);
     }
     finally
     {
         if (release)
         {
             socket.DangerousRelease();
         }
     }
 }
开发者ID:benpye,项目名称:corefx,代码行数:16,代码来源:Interop.GetSocketErrorOption.cs


示例9: SendMessage

 internal static unsafe Error SendMessage(SafeHandle socket, MessageHeader* messageHeader, SocketFlags flags, long* sent)
 {
     bool release = false;
     try
     {
         socket.DangerousAddRef(ref release);
         return DangerousSendMessage((int)socket.DangerousGetHandle(), messageHeader, flags, sent);
     }
     finally
     {
         if (release)
         {
             socket.DangerousRelease();
         }
     }
 }
开发者ID:benpye,项目名称:corefx,代码行数:16,代码来源:Interop.SendMessage.cs


示例10: SetSockOpt

 internal static unsafe Error SetSockOpt(SafeHandle socket, SocketOptionLevel optionLevel, SocketOptionName optionName, byte* optionValue, int optionLen)
 {
     bool release = false;
     try
     {
         socket.DangerousAddRef(ref release);
         return DangerousSetSockOpt((int)socket.DangerousGetHandle(), optionLevel, optionName, optionValue, optionLen);
     }
     finally
     {
         if (release)
         {
             socket.DangerousRelease();
         }
     }
 }
开发者ID:benpye,项目名称:corefx,代码行数:16,代码来源:Interop.SetSockOpt.cs


示例11: GetSockName

 internal static unsafe Error GetSockName(SafeHandle socket, byte* socketAddress, int* socketAddressLen)
 {
     bool release = false;
     try
     {
         socket.DangerousAddRef(ref release);
         return DangerousGetSockName((int)socket.DangerousGetHandle(), socketAddress, socketAddressLen);
     }
     finally
     {
         if (release)
         {
             socket.DangerousRelease();
         }
     }
 }
开发者ID:benpye,项目名称:corefx,代码行数:16,代码来源:Interop.GetSockName.cs


示例12: SetReceiveTimeout

 internal static unsafe Error SetReceiveTimeout(SafeHandle socket, int millisecondsTimeout)
 {
     bool release = false;
     try
     {
         socket.DangerousAddRef(ref release);
         return DangerousSetReceiveTimeout((int)socket.DangerousGetHandle(), millisecondsTimeout);
     }
     finally
     {
         if (release)
         {
             socket.DangerousRelease();
         }
     }
 }
开发者ID:benpye,项目名称:corefx,代码行数:16,代码来源:Interop.SetReceiveTimeout.cs


示例13: Shutdown

 internal static Error Shutdown(SafeHandle socket, SocketShutdown how)
 {
     bool release = false;
     try
     {
         socket.DangerousAddRef(ref release);
         return DangerousShutdown((int)socket.DangerousGetHandle(), how);
     }
     finally
     {
         if (release)
         {
             socket.DangerousRelease();
         }
     }
 }
开发者ID:benpye,项目名称:corefx,代码行数:16,代码来源:Interop.Shutdown.cs


示例14: TryChangeSocketEventRegistration

 internal static Error TryChangeSocketEventRegistration(int port, SafeHandle socket, SocketEvents currentEvents, SocketEvents newEvents, IntPtr data)
 {
     bool release = false;
     try
     {
         socket.DangerousAddRef(ref release);
         return DangerousTryChangeSocketEventRegistration(port, (int)socket.DangerousGetHandle(), currentEvents, newEvents, data);
     }
     finally
     {
         if (release)
         {
             socket.DangerousRelease();
         }
     }
 }
开发者ID:benpye,项目名称:corefx,代码行数:16,代码来源:Interop.SocketEvent.cs


示例15: Accept

 internal static unsafe Error Accept(SafeHandle socket, byte* socketAddress, int* socketAddressLen, int* acceptedFd)
 {
     bool release = false;
     try
     {
         socket.DangerousAddRef(ref release);
         return DangerousAccept((int)socket.DangerousGetHandle(), socketAddress, socketAddressLen, acceptedFd);
     }
     finally
     {
         if (release)
         {
             socket.DangerousRelease();
         }
     }
 }
开发者ID:benpye,项目名称:corefx,代码行数:16,代码来源:Interop.Accept.cs


示例16: Listen

 internal static Error Listen(SafeHandle socket, int backlog)
 {
     bool release = false;
     try
     {
         socket.DangerousAddRef(ref release);
         return DangerousListen((int)socket.DangerousGetHandle(), backlog);
     }
     finally
     {
         if (release)
         {
             socket.DangerousRelease();
         }
     }
 }
开发者ID:benpye,项目名称:corefx,代码行数:16,代码来源:Interop.Listen.cs


示例17: GetIPv6MulticastOption

 internal static unsafe Error GetIPv6MulticastOption(SafeHandle socket, MulticastOption multicastOption, IPv6MulticastOption* option)
 {
     bool release = false;
     try
     {
         socket.DangerousAddRef(ref release);
         return DangerousGetIPv6MulticastOption((int)socket.DangerousGetHandle(), multicastOption, option);
     }
     finally
     {
         if (release)
         {
             socket.DangerousRelease();
         }
     }
 }
开发者ID:benpye,项目名称:corefx,代码行数:16,代码来源:Interop.MulticastOption.cs


示例18: Write

    public static bool Write(SafeHandle fileHandle, Option options, ExceptionInfo exceptionInfo)
    {
        Process currentProcess = Process.GetCurrentProcess();

        IntPtr currentProcessHandle = currentProcess.Handle;

        uint currentProcessId = (uint)currentProcess.Id;

        MiniDumpExceptionInformation exp;

        exp.ThreadId = GetCurrentThreadId();

        exp.ClientPointers = false;

        exp.ExceptionPointers = IntPtr.Zero;

        if (exceptionInfo == ExceptionInfo.Present)
        {

            exp.ExceptionPointers = System.Runtime.InteropServices.Marshal.GetExceptionPointers();

        }

        bool bRet = false;

        if (exp.ExceptionPointers == IntPtr.Zero)
        {

            bRet = MiniDumpWriteDump(currentProcessHandle, currentProcessId, fileHandle, (uint)options, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);

        }

        else
        {

            bRet = MiniDumpWriteDump(currentProcessHandle, currentProcessId, fileHandle, (uint)options, ref exp, IntPtr.Zero, IntPtr.Zero);

        }

        return bRet;
    }
开发者ID:lavender1213,项目名称:ShipGirlBot,代码行数:41,代码来源:Minidump.cs


示例19: GetProcessRuntimes

    public static IEnumerable<string> GetProcessRuntimes(ICLRMetaHost host, SafeHandle hProcess)
    {
        if (host != null)
        {
            var buffer = new StringBuilder(1024);
            IEnumUnknown ppEnumerator = host.EnumerateLoadedRuntimes(hProcess.DangerousGetHandle());
            return ppEnumerator.Cast<ICLRRuntimeInfo>().Select(rti =>
            {
                var bufferLength = (uint)buffer.Capacity;
                rti.GetVersionString(buffer, ref bufferLength);
                return buffer.ToString(0, (int)bufferLength - 1);
            }).ToList();
        }
        else
        {
            string buffer = GetVersionFromProcess(hProcess);
            if (buffer != null)
            {
                return new[] { buffer };
            }
        }

        return Enumerable.Empty<string>();
    }
开发者ID:jmelosegui,项目名称:pinvoke,代码行数:24,代码来源:MSCorEEFacts.cs


示例20: Persist

 protected virtual void Persist(SafeHandle handle, AccessControlSections includeSections);
开发者ID:scott156,项目名称:corefx-progress,代码行数:1,代码来源:System.Security.AccessControl.cs



注:本文中的SafeHandle类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SafeHashHandle类代码示例发布时间:2022-05-24
下一篇:
C# SafeFreeCredentials类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap