public static bool GetThreadInfo(
            UInt32 profilerThreadInfoId,
            ref UInt64 clrThreadId,
            ref UInt32 osThreadId,
            ref IntPtr osThreadHandle,
            StringBuilder threadNameBuff,
            UInt32 threadNameBuffSize,
            ref UInt32 actualThreadNameLen)
        {
            bool success = false;

            if (Environment.Is64BitProcess)
            {
                if (!TryGetThreadInfo_x64(
                        profilerThreadInfoId,
                        ref clrThreadId,
                        ref osThreadId,
                        ref osThreadHandle,
                        threadNameBuff,
                        threadNameBuffSize,
                        ref actualThreadNameLen,
                        ref success))
                {
                    ClrShutdownException.Throw("TryGetThreadInfo");
                }
            }
            else
            {
                if (!TryGetThreadInfo_x86(
                        profilerThreadInfoId,
                        ref clrThreadId,
                        ref osThreadId,
                        ref osThreadHandle,
                        threadNameBuff,
                        threadNameBuffSize,
                        ref actualThreadNameLen,
                        ref success))
                {
                    ClrShutdownException.Throw("TryGetThreadInfo");
                }
            }

            return(success);
        }
        public static bool ResolveAppDomainInfoSymbols(
            UInt64 profilerAppDomainId,
            UInt32 appDomainNameBuffSize,
            ref UInt32 actualAppDomainNameLen,
            StringBuilder appDomainNameBuff,
            ref UInt64 appDomainProcessId)
        {
            bool success = false;

            if (Environment.Is64BitProcess)
            {
                if (!TryResolveAppDomainInfoSymbols_x64(
                        profilerAppDomainId,
                        appDomainNameBuffSize,
                        ref actualAppDomainNameLen,
                        appDomainNameBuff,
                        ref appDomainProcessId,
                        ref success))
                {
                    ClrShutdownException.Throw("TryResolveAppDomainInfoSymbols is called AFTER CLR shutdown");
                }

                return(success);
            }
            else
            {
                if (!TryResolveAppDomainInfoSymbols_x86(
                        profilerAppDomainId,
                        appDomainNameBuffSize,
                        ref actualAppDomainNameLen,
                        appDomainNameBuff,
                        ref appDomainProcessId,
                        ref success))
                {
                    ClrShutdownException.Throw("TryResolveAppDomainInfoSymbols is called AFTER CLR shutdown");
                }

                return(success);
            }
        }
 public static void TryResolveStackFrameSymbols(
     StackFrameCodeKind frameCodeKind,
     UInt64 frameInfoCode,
     ref IntPtr pFunctionName,
     ref IntPtr pContainingTypeName,
     ref IntPtr pContainingAssemblyName)
 {
     if (Environment.Is64BitProcess)
     {
         if (!TryResolveStackFrameSymbols_x64(frameCodeKind, frameInfoCode, ref pFunctionName, ref pContainingTypeName, ref pContainingAssemblyName))
         {
             ClrShutdownException.Throw("TryResolveStackFrameSymbols is called AFTER CLR shutdown");
         }
     }
     else
     {
         if (!TryResolveStackFrameSymbols_x86(frameCodeKind, frameInfoCode, ref pFunctionName, ref pContainingTypeName, ref pContainingAssemblyName))
         {
             ClrShutdownException.Throw("TryResolveStackFrameSymbols is called AFTER CLR shutdown");
         }
     }
 }
        // Note that the defaut calling convention is StdCall. That is what we use.
        // Although this is already the default, we still explicitly specify it for readability.

        // --------------------------------------------------------
        // TryCompleteCurrentWriteSegment
        public static bool TryCompleteCurrentWriteSegment()
        {
            bool success = false;

            if (Environment.Is64BitProcess)
            {
                if (!TryCompleteCurrentWriteSegment_x64(ref success))
                {
                    ClrShutdownException.Throw("TryCompleteCurrentWriteSegment is called AFTER CLR shutdown");
                }

                return(success);
            }
            else
            {
                if (!TryCompleteCurrentWriteSegment_x86(ref success))
                {
                    ClrShutdownException.Throw("TryCompleteCurrentWriteSegment is called AFTER CLR shutdown");
                }

                return(success);
            }
        }
        // --------------------------------------------------------
        // TryMakeSegmentAvailableForWrite
        public static bool TryMakeSegmentAvailableForWrite(IntPtr segment)
        {
            bool isReleased = false;

            if (Environment.Is64BitProcess)
            {
                if (!TryMakeSegmentAvailableForWrite_x64(segment, ref isReleased))
                {
                    ClrShutdownException.Throw("TryMakeSegmentAvailableForWrite is called AFTER CLR shutdown");
                }

                return(isReleased);
            }
            else
            {
                if (!TryMakeSegmentAvailableForWrite_x86(segment, ref isReleased))
                {
                    ClrShutdownException.Throw("TryMakeSegmentAvailableForWrite is called AFTER CLR shutdown");
                }

                return(isReleased);
            }
        }