Example #1
0
        public static void ShowAlert(string CharName, string Msg, MSG_Type MSG)
        {
            //info.Image = Properties.Resources.Info;
            //info.Image = Properties.Resources.Exit;
            //info.Image = Properties.Resources.apply_16x16;

            DevExpress.XtraBars.Alerter.AlertInfo info = new DevExpress.XtraBars.Alerter.AlertInfo(CharName, Msg);
            switch (MSG)
            {
                case MSG_Type.Connect:
                    if (!Properties.Settings.Default.Alert_Connect_Disconnect)
                        return;
                    info.Image = Properties.Resources.apply_16x16;
                    break;
                case MSG_Type.Disconnect:
                    if (!Properties.Settings.Default.Alert_Connect_Disconnect)
                        return;
                    info.Image = Properties.Resources.Exit;
                    break;
                case MSG_Type.Died:
                    if (!Properties.Settings.Default.Alert_Died)
                        return;
                    info.Image = Properties.Resources.Info;
                    break;
                case MSG_Type.UnknownBotLogin:
                    info.Image = Properties.Resources.Exit;
                    break;
                default:
                    break;
            }
            if (Application.OpenForms.Count == 0)
                return;
            Application.OpenForms[0].Invoke(new MethodInvoker(() => { Alert.Show(Application.OpenForms[0], info); }));
        }
Example #2
0
        /// <summary>
        /// Process a Standard Message
        /// </summary>
        /// <param name="msgType"></param>
        /// <param name="mcb"></param>
        /// <param name="chunkReady"></param>
        /// <param name="offloadHandling"></param>
        /// <returns></returns>
        public int StandardMessage(MSG_Type msgType, IManagedCommunicationBlock mcb, Action <int, IManagedCommunicationBlock> chunkReady, Action <ManagedBufferBlock> offloadHandling)
        {
            IntPtr pinnedMemory = mcb.PinnedDataCommunication.AddrOfPinnedObject();
            var    writeSize    = 0;

            switch (msgType)
            {
            case MSG_Type.MSG_TrackAssembly:
                writeSize = HandleTrackAssemblyMessage(pinnedMemory);
                break;

            case MSG_Type.MSG_GetSequencePoints:
                writeSize = HandleGetSequencePointsMessage(pinnedMemory, mcb, chunkReady);
                break;

            case MSG_Type.MSG_GetBranchPoints:
                writeSize = HandleGetBranchPointsMessage(pinnedMemory, mcb, chunkReady);
                break;

            case MSG_Type.MSG_TrackMethod:
                writeSize = HandleTrackMethodMessage(pinnedMemory);
                break;

            case MSG_Type.MSG_AllocateMemoryBuffer:
                writeSize = HandleAllocateBufferMessage(offloadHandling, pinnedMemory);
                break;

            case MSG_Type.MSG_CloseChannel:
                writeSize = HandleCloseChannelMessage(pinnedMemory);
                break;

            case MSG_Type.MSG_TrackProcess:
                writeSize = HandleTrackProcessMessage(pinnedMemory);
                break;

            default:
                throw new InvalidOperationException();
            }
            return(writeSize);
        }
Example #3
0
        /// <summary>
        /// Process a Standard Message
        /// </summary>
        /// <param name="msgType"></param>
        /// <param name="mcb"></param>
        /// <param name="chunkReady"></param>
        /// <param name="offloadHandling"></param>
        /// <returns></returns>
        public int StandardMessage(MSG_Type msgType, IManagedCommunicationBlock mcb, Action<int, IManagedCommunicationBlock> chunkReady, Action<ManagedBufferBlock> offloadHandling)
        {
            IntPtr pinnedMemory = mcb.PinnedDataCommunication.AddrOfPinnedObject();
            var writeSize = 0;
            switch (msgType)
            {
                case MSG_Type.MSG_TrackAssembly:
                    writeSize = HandleTrackAssemblyMessage(pinnedMemory);
                    break;

                case MSG_Type.MSG_GetSequencePoints:
                    writeSize = HandleGetSequencePointsMessage(pinnedMemory, mcb, chunkReady);
                    break;

                case MSG_Type.MSG_GetBranchPoints:
                    writeSize = HandleGetBranchPointsMessage(pinnedMemory, mcb, chunkReady);
                    break;

                case MSG_Type.MSG_TrackMethod:
                    writeSize = HandleTrackMethodMessage(pinnedMemory);
                    break;

                case MSG_Type.MSG_AllocateMemoryBuffer:
                    writeSize = HandleAllocateBufferMessage(offloadHandling, pinnedMemory);
                    break;

                case MSG_Type.MSG_CloseChannel:
                    writeSize = HandleCloseChannelMessage(pinnedMemory);
                    break;

                case MSG_Type.MSG_TrackProcess:
                    writeSize = HandleTrackProcessMessage(pinnedMemory);
                    break;
                default:
                    throw new InvalidOperationException();

            }
            return writeSize;                
        }
Example #4
0
        public int StandardMessage(MSG_Type msgType, IntPtr pinnedMemory, Action<int> chunkReady)
        {
            var writeSize = 0;
            switch (msgType)
            {
                case MSG_Type.MSG_TrackAssembly:
                    {
                        var msgTA = _marshalWrapper.PtrToStructure<MSG_TrackAssembly_Request>(pinnedMemory);
                        var responseTA = new MSG_TrackAssembly_Response();
                        responseTA.track = _profilerCommunication.TrackAssembly(msgTA.modulePath, msgTA.assemblyName);
                        _marshalWrapper.StructureToPtr(responseTA, pinnedMemory, false);
                        writeSize = Marshal.SizeOf(typeof (MSG_TrackAssembly_Response));
                    }
                    break;

                case MSG_Type.MSG_GetSequencePoints:
                    {
                        var msgGSP = _marshalWrapper.PtrToStructure<MSG_GetSequencePoints_Request>(pinnedMemory);
                        InstrumentationPoint[] origPoints;
                        var responseCSP = new MSG_GetSequencePoints_Response();
                        _profilerCommunication.GetSequencePoints(msgGSP.modulePath, msgGSP.assemblyName,
                                                                 msgGSP.functionToken, out origPoints);
                        var num = origPoints == null ? 0 : origPoints.Length;

                        var index = 0;
                        var chunk = Marshal.SizeOf(typeof (MSG_SequencePoint));
                        do
                        {
                            writeSize = Marshal.SizeOf(typeof (MSG_GetSequencePoints_Response));
                            responseCSP.more = num > GSP_BufSize;
                            responseCSP.count = num > GSP_BufSize ? GSP_BufSize : num;
                            _marshalWrapper.StructureToPtr(responseCSP, pinnedMemory, false);
                            for (var i = 0; i < responseCSP.count; i++)
                            {
                                var point = new MSG_SequencePoint();
                                point.Offset = origPoints[index].Offset;
                                point.UniqueId = origPoints[index].UniqueSequencePoint;

                                _marshalWrapper.StructureToPtr(point, pinnedMemory + writeSize, false);
                                writeSize += chunk;
                                index++;
                            }

                            if (responseCSP.more)
                            {
                                chunkReady(writeSize);
                                num -= GSP_BufSize;
                            }
                        } while (responseCSP.more);
                    }
                    break;

                case MSG_Type.MSG_GetBranchPoints:
                    {
                        var msgGBP = _marshalWrapper.PtrToStructure<MSG_GetBranchPoints_Request>(pinnedMemory);
                        BranchPoint[] origPoints;
                        var responseCSP = new MSG_GetBranchPoints_Response();
                        _profilerCommunication.GetBranchPoints(msgGBP.modulePath, msgGBP.assemblyName,
                                                                 msgGBP.functionToken, out origPoints);
                        var num = origPoints == null ? 0 : origPoints.Length;

                        var index = 0;
                        var chunk = Marshal.SizeOf(typeof (MSG_BranchPoint));
                        do
                        {
                            writeSize = Marshal.SizeOf(typeof (MSG_GetBranchPoints_Response));
                            responseCSP.more = num > GBP_BufSize;
                            responseCSP.count = num > GBP_BufSize ? GBP_BufSize : num;
                            _marshalWrapper.StructureToPtr(responseCSP, pinnedMemory, false);
                            for (var i = 0; i < responseCSP.count; i++)
                            {
                                var point = new MSG_BranchPoint();
                                point.Offset = origPoints[index].Offset;
                                point.UniqueId = origPoints[index].UniqueSequencePoint;
                                point.Path = origPoints[index].Path;

                                _marshalWrapper.StructureToPtr(point, pinnedMemory + writeSize, false);
                                writeSize += chunk;
                                index++;
                            }

                            if (responseCSP.more)
                            {
                                chunkReady(writeSize);
                                num -= GBP_BufSize;
                            }
                        } while (responseCSP.more);
                    }
                    break;
            }
            return writeSize;
        }
Example #5
0
        // TODO: change pinnedMemory to an byte[], pass in mcb as well
        public int StandardMessage(MSG_Type msgType, IManagedCommunicationBlock mcb, Action<int, IManagedCommunicationBlock> chunkReady, Action<ManagedBufferBlock> offloadHandling)
        {
            IntPtr pinnedMemory = mcb.PinnedDataCommunication.AddrOfPinnedObject();
            var writeSize = 0;
            switch (msgType)
            {
                case MSG_Type.MSG_TrackAssembly:
                    {
                        var msgTA = _marshalWrapper.PtrToStructure<MSG_TrackAssembly_Request>(pinnedMemory);
                        var responseTA = new MSG_TrackAssembly_Response();
                        responseTA.track = _profilerCommunication.TrackAssembly(msgTA.modulePath, msgTA.assemblyName);
                        _marshalWrapper.StructureToPtr(responseTA, pinnedMemory, false);
                        writeSize = Marshal.SizeOf(typeof (MSG_TrackAssembly_Response));
                    }
                    break;

                case MSG_Type.MSG_GetSequencePoints:
                    {
                        var responseGSP = new MSG_GetSequencePoints_Response();
                        try
                        {
                            var msgGSP = _marshalWrapper.PtrToStructure<MSG_GetSequencePoints_Request>(pinnedMemory);
                            InstrumentationPoint[] origPoints;
                            _profilerCommunication.GetSequencePoints(msgGSP.modulePath, msgGSP.assemblyName,
                                msgGSP.functionToken, out origPoints);
                            var num = origPoints == null ? 0 : origPoints.Length;

                            var index = 0;
                            var chunk = Marshal.SizeOf(typeof (MSG_SequencePoint));
                            do
                            {
                                writeSize = Marshal.SizeOf(typeof (MSG_GetSequencePoints_Response));
                                responseGSP.more = num > GSP_BufSize;
                                responseGSP.count = num > GSP_BufSize ? GSP_BufSize : num;
                                _marshalWrapper.StructureToPtr(responseGSP, pinnedMemory, false);
                                for (var i = 0; i < responseGSP.count; i++)
                                {
                                    var point = new MSG_SequencePoint();
                                    point.offset = origPoints[index].Offset;
                                    point.uniqueId = origPoints[index].UniqueSequencePoint;

                                    _marshalWrapper.StructureToPtr(point, pinnedMemory + writeSize, false);
                                    writeSize += chunk;
                                    index++;
                                }

                                if (responseGSP.more)
                                {
                                    chunkReady(writeSize, mcb);
                                    num -= GSP_BufSize;
                                }
                            } while (responseGSP.more);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("{0}:{1}", ex.GetType(), ex.Message);
                            responseGSP.more = false;
                            responseGSP.count = 0;
                            _marshalWrapper.StructureToPtr(responseGSP, pinnedMemory, false);
                        }
                    }
                    break;

                case MSG_Type.MSG_GetBranchPoints:
                    {
                        var responseGBP = new MSG_GetBranchPoints_Response();
                        try
                        {
                            var msgGBP = _marshalWrapper.PtrToStructure<MSG_GetBranchPoints_Request>(pinnedMemory);
                            BranchPoint[] origPoints;
                            _profilerCommunication.GetBranchPoints(msgGBP.modulePath, msgGBP.assemblyName,
                                msgGBP.functionToken, out origPoints);
                            var num = origPoints == null ? 0 : origPoints.Length;

                            var index = 0;
                            var chunk = Marshal.SizeOf(typeof (MSG_BranchPoint));
                            do
                            {
                                writeSize = Marshal.SizeOf(typeof (MSG_GetBranchPoints_Response));
                                responseGBP.more = num > GBP_BufSize;
                                responseGBP.count = num > GBP_BufSize ? GBP_BufSize : num;
                                _marshalWrapper.StructureToPtr(responseGBP, pinnedMemory, false);
                                for (var i = 0; i < responseGBP.count; i++)
                                {
                                    var point = new MSG_BranchPoint();
                                    point.offset = origPoints[index].Offset;
                                    point.uniqueId = origPoints[index].UniqueSequencePoint;
                                    point.path = origPoints[index].Path;

                                    _marshalWrapper.StructureToPtr(point, pinnedMemory + writeSize, false);
                                    writeSize += chunk;
                                    index++;
                                }

                                if (responseGBP.more)
                                {
                                    chunkReady(writeSize, mcb);
                                    num -= GBP_BufSize;
                                }
                            } while (responseGBP.more);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("{0}:{1}", ex.GetType(), ex.Message);
                            responseGBP.more = false;
                            responseGBP.count = 0;
                            _marshalWrapper.StructureToPtr(responseGBP, pinnedMemory, false);
                        }
                    }
                    break;

                case MSG_Type.MSG_TrackMethod:
                    {
                        var msgTM = _marshalWrapper.PtrToStructure<MSG_TrackMethod_Request>(pinnedMemory);
                        var responseTM = new MSG_TrackMethod_Response();
                        uint uniqueId;
                        responseTM.track = _profilerCommunication.TrackMethod(msgTM.modulePath,
                            msgTM.assemblyName, msgTM.functionToken, out uniqueId);
                        responseTM.uniqueId = uniqueId;
                        _marshalWrapper.StructureToPtr(responseTM, pinnedMemory, false);
                        writeSize = Marshal.SizeOf(typeof(MSG_TrackMethod_Response));
                    }
                    break;

                case MSG_Type.MSG_AllocateMemoryBuffer:
                    {
                        var msgAB = _marshalWrapper.PtrToStructure<MSG_AllocateBuffer_Request>(pinnedMemory);

                        var block = _memoryManager.AllocateMemoryBuffer(msgAB.bufferSize, _bufferId);

                        var responseAB = new MSG_AllocateBuffer_Response {allocated = true, bufferId = _bufferId };
                        _marshalWrapper.StructureToPtr(responseAB, pinnedMemory, false);
                        writeSize = Marshal.SizeOf(typeof(MSG_AllocateBuffer_Response));
                        _bufferId++;

                        offloadHandling(block);
                    }
                    break;

                case MSG_Type.MSG_CloseChannel:
                    {
                        var msgCC = _marshalWrapper.PtrToStructure<MSG_CloseChannel_Request>(pinnedMemory);
                        var bufferId = msgCC.bufferId;

                        var responseCC = new MSG_CloseChannel_Response { done = true };
                        _marshalWrapper.StructureToPtr(responseCC, pinnedMemory, false);
                        writeSize = Marshal.SizeOf(typeof(MSG_CloseChannel_Response));

                        _memoryManager.DeactivateMemoryBuffer(bufferId);
                    }
                    break;
            }
            return writeSize;
        }
Example #6
0
        // TODO: change pinnedMemory to an byte[], pass in mcb as well
        public int StandardMessage(MSG_Type msgType, IManagedCommunicationBlock mcb, Action <int, IManagedCommunicationBlock> chunkReady, Action <ManagedBufferBlock> offloadHandling)
        {
            IntPtr pinnedMemory = mcb.PinnedDataCommunication.AddrOfPinnedObject();
            var    writeSize    = 0;

            switch (msgType)
            {
            case MSG_Type.MSG_TrackAssembly:
            {
                var msgTA      = _marshalWrapper.PtrToStructure <MSG_TrackAssembly_Request>(pinnedMemory);
                var responseTA = new MSG_TrackAssembly_Response();
                responseTA.track = _profilerCommunication.TrackAssembly(msgTA.modulePath, msgTA.assemblyName);
                _marshalWrapper.StructureToPtr(responseTA, pinnedMemory, false);
                writeSize = Marshal.SizeOf(typeof(MSG_TrackAssembly_Response));
            }
            break;

            case MSG_Type.MSG_GetSequencePoints:
            {
                var responseGSP = new MSG_GetSequencePoints_Response();
                try
                {
                    var msgGSP = _marshalWrapper.PtrToStructure <MSG_GetSequencePoints_Request>(pinnedMemory);
                    InstrumentationPoint[] origPoints;
                    _profilerCommunication.GetSequencePoints(msgGSP.modulePath, msgGSP.assemblyName,
                                                             msgGSP.functionToken, out origPoints);
                    var num = origPoints == null ? 0 : origPoints.Length;

                    var index = 0;
                    var chunk = Marshal.SizeOf(typeof(MSG_SequencePoint));
                    do
                    {
                        writeSize         = Marshal.SizeOf(typeof(MSG_GetSequencePoints_Response));
                        responseGSP.more  = num > GSP_BufSize;
                        responseGSP.count = num > GSP_BufSize ? GSP_BufSize : num;
                        _marshalWrapper.StructureToPtr(responseGSP, pinnedMemory, false);
                        for (var i = 0; i < responseGSP.count; i++)
                        {
                            var point = new MSG_SequencePoint();
                            point.offset   = origPoints[index].Offset;
                            point.uniqueId = origPoints[index].UniqueSequencePoint;

                            _marshalWrapper.StructureToPtr(point, pinnedMemory + writeSize, false);
                            writeSize += chunk;
                            index++;
                        }

                        if (responseGSP.more)
                        {
                            chunkReady(writeSize, mcb);
                            num -= GSP_BufSize;
                        }
                    } while (responseGSP.more);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("{0}:{1}", ex.GetType(), ex.Message);
                    responseGSP.more  = false;
                    responseGSP.count = 0;
                    _marshalWrapper.StructureToPtr(responseGSP, pinnedMemory, false);
                }
            }
            break;

            case MSG_Type.MSG_GetBranchPoints:
            {
                var responseGBP = new MSG_GetBranchPoints_Response();
                try
                {
                    var           msgGBP = _marshalWrapper.PtrToStructure <MSG_GetBranchPoints_Request>(pinnedMemory);
                    BranchPoint[] origPoints;
                    _profilerCommunication.GetBranchPoints(msgGBP.modulePath, msgGBP.assemblyName,
                                                           msgGBP.functionToken, out origPoints);
                    var num = origPoints == null ? 0 : origPoints.Length;

                    var index = 0;
                    var chunk = Marshal.SizeOf(typeof(MSG_BranchPoint));
                    do
                    {
                        writeSize         = Marshal.SizeOf(typeof(MSG_GetBranchPoints_Response));
                        responseGBP.more  = num > GBP_BufSize;
                        responseGBP.count = num > GBP_BufSize ? GBP_BufSize : num;
                        _marshalWrapper.StructureToPtr(responseGBP, pinnedMemory, false);
                        for (var i = 0; i < responseGBP.count; i++)
                        {
                            var point = new MSG_BranchPoint();
                            point.offset   = origPoints[index].Offset;
                            point.uniqueId = origPoints[index].UniqueSequencePoint;
                            point.path     = origPoints[index].Path;

                            _marshalWrapper.StructureToPtr(point, pinnedMemory + writeSize, false);
                            writeSize += chunk;
                            index++;
                        }

                        if (responseGBP.more)
                        {
                            chunkReady(writeSize, mcb);
                            num -= GBP_BufSize;
                        }
                    } while (responseGBP.more);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("{0}:{1}", ex.GetType(), ex.Message);
                    responseGBP.more  = false;
                    responseGBP.count = 0;
                    _marshalWrapper.StructureToPtr(responseGBP, pinnedMemory, false);
                }
            }
            break;

            case MSG_Type.MSG_TrackMethod:
            {
                var  msgTM      = _marshalWrapper.PtrToStructure <MSG_TrackMethod_Request>(pinnedMemory);
                var  responseTM = new MSG_TrackMethod_Response();
                uint uniqueId;
                responseTM.track = _profilerCommunication.TrackMethod(msgTM.modulePath,
                                                                      msgTM.assemblyName, msgTM.functionToken, out uniqueId);
                responseTM.uniqueId = uniqueId;
                _marshalWrapper.StructureToPtr(responseTM, pinnedMemory, false);
                writeSize = Marshal.SizeOf(typeof(MSG_TrackMethod_Response));
            }
            break;

            case MSG_Type.MSG_AllocateMemoryBuffer:
            {
                var msgAB = _marshalWrapper.PtrToStructure <MSG_AllocateBuffer_Request>(pinnedMemory);

                var block = _memoryManager.AllocateMemoryBuffer(msgAB.bufferSize, _bufferId);

                var responseAB = new MSG_AllocateBuffer_Response {
                    allocated = true, bufferId = _bufferId
                };
                _marshalWrapper.StructureToPtr(responseAB, pinnedMemory, false);
                writeSize = Marshal.SizeOf(typeof(MSG_AllocateBuffer_Response));
                _bufferId++;

                offloadHandling(block);
            }
            break;

            case MSG_Type.MSG_CloseChannel:
            {
                var msgCC    = _marshalWrapper.PtrToStructure <MSG_CloseChannel_Request>(pinnedMemory);
                var bufferId = msgCC.bufferId;

                var responseCC = new MSG_CloseChannel_Response {
                    done = true
                };
                _marshalWrapper.StructureToPtr(responseCC, pinnedMemory, false);
                writeSize = Marshal.SizeOf(typeof(MSG_CloseChannel_Response));

                _memoryManager.DeactivateMemoryBuffer(bufferId);
            }
            break;
            }
            return(writeSize);
        }
Example #7
0
        // TODO: change pinnedMemory to an byte[], pass in mcb as well
        public int StandardMessage(MSG_Type msgType, IManagedCommunicationBlock mcb, Action<int, IManagedCommunicationBlock> chunkReady, Action<IManagedCommunicationBlock, IManagedMemoryBlock> offloadHandling)
        {
            IntPtr pinnedMemory = mcb.PinnedDataCommunication.AddrOfPinnedObject();
            var writeSize = 0;
            switch (msgType)
            {
                case MSG_Type.MSG_TrackAssembly:
                    {
                        var msgTA = _marshalWrapper.PtrToStructure<MSG_TrackAssembly_Request>(pinnedMemory);
                        if (!String.IsNullOrEmpty(msgTA.modulePath) && msgTA.modulePath.StartsWith("@"))
                        {
                            msgTA.modulePath = this._moduleLocator.LocateForAssembly(msgTA.assemblyName);
                        }
                        var responseTA = new MSG_TrackAssembly_Response();
                        responseTA.track = _profilerCommunication.TrackAssembly(msgTA.modulePath, msgTA.assemblyName);
                        _marshalWrapper.StructureToPtr(responseTA, pinnedMemory, false);
                        writeSize = Marshal.SizeOf(typeof (MSG_TrackAssembly_Response));
                    }
                    break;

                case MSG_Type.MSG_GetSequencePoints:
                    {
                        var msgGSP = _marshalWrapper.PtrToStructure<MSG_GetSequencePoints_Request>(pinnedMemory);
                        InstrumentationPoint[] origPoints;
                        if (!String.IsNullOrEmpty(msgGSP.modulePath) && msgGSP.modulePath.StartsWith("@"))
                        {
                            msgGSP.modulePath = this._moduleLocator.LocateForAssembly(msgGSP.assemblyName);
                        }
                        var responseCSP = new MSG_GetSequencePoints_Response();
                        _profilerCommunication.GetSequencePoints(msgGSP.modulePath, msgGSP.assemblyName,
                                                                 msgGSP.functionToken, out origPoints);
                        var num = origPoints == null ? 0 : origPoints.Length;

                        var index = 0;
                        var chunk = Marshal.SizeOf(typeof (MSG_SequencePoint));
                        do
                        {
                            writeSize = Marshal.SizeOf(typeof (MSG_GetSequencePoints_Response));
                            responseCSP.more = num > GSP_BufSize;
                            responseCSP.count = num > GSP_BufSize ? GSP_BufSize : num;
                            _marshalWrapper.StructureToPtr(responseCSP, pinnedMemory, false);
                            for (var i = 0; i < responseCSP.count; i++)
                            {
                                var point = new MSG_SequencePoint();
                                point.offset = origPoints[index].Offset;
                                point.uniqueId = origPoints[index].UniqueSequencePoint;

                                _marshalWrapper.StructureToPtr(point, pinnedMemory + writeSize, false);
                                writeSize += chunk;
                                index++;
                            }

                            if (responseCSP.more)
                            {
                                chunkReady(writeSize, mcb);
                                num -= GSP_BufSize;
                            }
                        } while (responseCSP.more);
                    }
                    break;

                case MSG_Type.MSG_GetBranchPoints:
                    {
                        var msgGBP = _marshalWrapper.PtrToStructure<MSG_GetBranchPoints_Request>(pinnedMemory);
                        if (!String.IsNullOrEmpty(msgGBP.modulePath) && msgGBP.modulePath.StartsWith("@"))
                        {
                            msgGBP.modulePath = this._moduleLocator.LocateForAssembly(msgGBP.assemblyName);
                        }

                        BranchPoint[] origPoints;
                        var responseCSP = new MSG_GetBranchPoints_Response();
                        _profilerCommunication.GetBranchPoints(msgGBP.modulePath, msgGBP.assemblyName,
                                                                 msgGBP.functionToken, out origPoints);
                        var num = origPoints == null ? 0 : origPoints.Length;

                        var index = 0;
                        var chunk = Marshal.SizeOf(typeof (MSG_BranchPoint));
                        do
                        {
                            writeSize = Marshal.SizeOf(typeof (MSG_GetBranchPoints_Response));
                            responseCSP.more = num > GBP_BufSize;
                            responseCSP.count = num > GBP_BufSize ? GBP_BufSize : num;
                            _marshalWrapper.StructureToPtr(responseCSP, pinnedMemory, false);
                            for (var i = 0; i < responseCSP.count; i++)
                            {
                                var point = new MSG_BranchPoint();
                                point.offset = origPoints[index].Offset;
                                point.uniqueId = origPoints[index].UniqueSequencePoint;
                                point.path = origPoints[index].Path;

                                _marshalWrapper.StructureToPtr(point, pinnedMemory + writeSize, false);
                                writeSize += chunk;
                                index++;
                            }

                            if (responseCSP.more)
                            {
                                chunkReady(writeSize, mcb);
                                num -= GBP_BufSize;
                            }
                        } while (responseCSP.more);
                    }
                    break;

                case MSG_Type.MSG_TrackMethod:
                    {
                        var msgTM = _marshalWrapper.PtrToStructure<MSG_TrackMethod_Request>(pinnedMemory);
                        var responseTM = new MSG_TrackMethod_Response();
                        uint uniqueId;
                        responseTM.track = _profilerCommunication.TrackMethod(msgTM.modulePath,
                            msgTM.assemblyName, msgTM.functionToken, out uniqueId);
                        responseTM.uniqueId = uniqueId;
                        _marshalWrapper.StructureToPtr(responseTM, pinnedMemory, false);
                        writeSize = Marshal.SizeOf(typeof(MSG_TrackMethod_Response));
                    }
                    break;

                case MSG_Type.MSG_AllocateMemoryBuffer:
                    {
                        var msgAB = _marshalWrapper.PtrToStructure<MSG_AllocateBuffer_Request>(pinnedMemory);

                        var block = _memoryManager.AllocateMemoryBuffer(msgAB.bufferSize, _bufferId);

                        var responseAB = new MSG_AllocateBuffer_Response {allocated = true, bufferId = _bufferId };
                        _marshalWrapper.StructureToPtr(responseAB, pinnedMemory, false);
                        writeSize = Marshal.SizeOf(typeof(MSG_AllocateBuffer_Response));
                        _bufferId++;

                        offloadHandling(block.Item1, block.Item2);
                    }
                    break;
            }
            return writeSize;
        }
Example #8
0
 public MSG(MSG_Type t, object param)
 {
     type      = t;
     parameter = param;
 }