コード例 #1
0
        private static unsafe IList <WaitChainNode> BytesToWaitChainNodeInfoList(Byte[] bytes)
        {
            List <WaitChainNode> chain = new List <WaitChainNode>();

            for (Int32 index = 0; index < bytes.Length; index += c_SizeOfWaitChainNode)
            {
                WctObjectType   type   = (WctObjectType)BitConverter.ToInt32(bytes, index + 0);
                WctObjectStatus status = (WctObjectStatus)BitConverter.ToInt32(bytes, index + 4);

                WaitChainNode wcni;
                switch (type)
                {
                case WctObjectType.CriticalSection:
                case WctObjectType.Mutex:
                    String name = null;
                    fixed(Byte *pb = &bytes[index + 8])
                    {
                        Char *pc = (Char *)pb;

                        // Find the first 0 character in the name
                        Int32 length = 0;

                        for (; (pc[length] != 0) && (length < c_ObjectNameLength); length++)
                        {
                            ;
                        }
                        if (length > 0)
                        {
                            name = new String(pc, 0, length);
                        }
                    }

                    Int64   timeout   = BitConverter.ToInt64(bytes, index + 8 + (c_ObjectNameLength * 2));
                    Boolean alertable = BitConverter.ToBoolean(bytes, index + 8 + (c_ObjectNameLength * 2) + 8);
                    wcni = new WaitChainNode(type, status, name, timeout, alertable);
                    break;

                default:
                    Int32 processId       = BitConverter.ToInt32(bytes, index + 8);
                    Int32 threadId        = BitConverter.ToInt32(bytes, index + 12); // Can be 0
                    Int32 waitTime        = BitConverter.ToInt32(bytes, index + 16);
                    Int32 contextSwitches = BitConverter.ToInt32(bytes, index + 20);
                    wcni = new WaitChainNode(type, status, processId, threadId, waitTime, contextSwitches);
                    break;
                }
                chain.Add(wcni);
            }
            return(chain);
        }
コード例 #2
0
        private static unsafe IList<WaitChainNode> BytesToWaitChainNodeInfoList(Byte[] bytes) {
            List<WaitChainNode> chain = new List<WaitChainNode>();
            for (Int32 index = 0; index < bytes.Length; index += c_SizeOfWaitChainNode) {
                WctObjectType type = (WctObjectType)BitConverter.ToInt32(bytes, index + 0);
                WctObjectStatus status = (WctObjectStatus)BitConverter.ToInt32(bytes, index + 4);

                WaitChainNode wcni;
                switch (type) {
                    case WctObjectType.CriticalSection:
                    case WctObjectType.Mutex:
                        String name = null;
                        fixed (Byte* pb = &bytes[index + 8]) {
                            Char* pc = (Char*)pb;

                            // Find the first 0 character in the name
                            Int32 length = 0;
                            for (; (pc[length] != 0) && (length < c_ObjectNameLength); length++) ;
                            if (length > 0) name = new String(pc, 0, length);
                        }
                        Int64 timeout = BitConverter.ToInt64(bytes, index + 8 + (c_ObjectNameLength * 2));
                        Boolean alertable = BitConverter.ToBoolean(bytes, index + 8 + (c_ObjectNameLength * 2) + 8);
                        wcni = new WaitChainNode(type, status, name, timeout, alertable);
                        break;

                    default:
                        Int32 processId = BitConverter.ToInt32(bytes, index + 8);
                        Int32 threadId = BitConverter.ToInt32(bytes, index + 12);   // Can be 0
                        Int32 waitTime = BitConverter.ToInt32(bytes, index + 16);
                        Int32 contextSwitches = BitConverter.ToInt32(bytes, index + 20);
                        wcni = new WaitChainNode(type, status, processId, threadId, waitTime, contextSwitches);
                        break;
                }
                chain.Add(wcni);
            }
            return chain;
        }