Ejemplo n.º 1
0
        public DkmCustomMessage SendLower(DkmCustomMessage message)
        {
            object result;

            byte[]       bytes;
            MessageCodes messageCode = (MessageCodes)message.MessageCode;

            try
            {
                bytes  = (byte[])message.Parameter1;
                result = ProcessMessage(messageCode, bytes);
            }
            catch (Exception e)
            {
                result      = e.ToString();
                messageCode = MessageCodes.Exception;
            }

            bytes = MessageSerializer.Serialize(result);
            return(DkmCustomMessage.Create(message.Connection, message.Process, Guid.Empty, (int)messageCode, bytes, null));
        }
Ejemplo n.º 2
0
        private object ProcessMessage(MessageCodes messageCode, byte[] bytes)
        {
            switch (messageCode)
            {
            case MessageCodes.ClearCache:
                return(ClearCache(MessageSerializer.Deserialize <bool>(bytes)));

            case MessageCodes.GetClrRuntimes:
                return(GetClrRuntimes(MessageSerializer.Deserialize <uint>(bytes)));

            case MessageCodes.ClrRuntime_GetThreads:
                return(GetClrRuntimeThreads(MessageSerializer.Deserialize <int>(bytes)));

            case MessageCodes.ClrRuntime_GetModules:
                return(GetClrRuntimeModules(MessageSerializer.Deserialize <int>(bytes)));

            case MessageCodes.ClrRuntime_GetAppDomains:
                return(GetClrRuntimeAppDomains(MessageSerializer.Deserialize <int>(bytes)));

            case MessageCodes.ClrRuntime_GetSharedAppDomain:
                return(GetClrRuntimeSharedAppDomain(MessageSerializer.Deserialize <int>(bytes)));

            case MessageCodes.ClrRuntime_GetSystemAppDomain:
                return(GetClrRuntimeSystemAppDomain(MessageSerializer.Deserialize <int>(bytes)));

            case MessageCodes.ClrRuntime_GetHeapCount:
                return(GetClrRuntimeHeapCount(MessageSerializer.Deserialize <int>(bytes)));

            case MessageCodes.ClrRuntime_GetServerGC:
                return(GetClrRuntimeServerGC(MessageSerializer.Deserialize <int>(bytes)));

            case MessageCodes.ClrRuntime_ReadFunctionNameAndDisplacement:
                return(ReadClrRuntimeFunctionNameAndDisplacement(MessageSerializer.Deserialize <Tuple <int, ulong> >(bytes)));

            case MessageCodes.ClrRuntime_GetInstructionPointerInfo:
                return(GetClrRuntimeInstructionPointerInfo(MessageSerializer.Deserialize <Tuple <int, ulong> >(bytes)));

            case MessageCodes.ClrAppDomain_GetModules:
                return(GetClrAppDomainModules(MessageSerializer.Deserialize <Tuple <int, int> >(bytes)));

            case MessageCodes.ClrHeap_GetCanWalkHeap:
                return(GetClrHeapCanWalkHeap(MessageSerializer.Deserialize <int>(bytes)));

            case MessageCodes.ClrHeap_GetTotalHeapSize:
                return(GetClrHeapTotalHeapSize(MessageSerializer.Deserialize <int>(bytes)));

            case MessageCodes.ClrHeap_GetObjectType:
                return(GetClrHeapObjectType(MessageSerializer.Deserialize <Tuple <int, ulong> >(bytes)));

            case MessageCodes.ClrHeap_EnumerateObjects:
                return(EnumerateClrHeapObjects(MessageSerializer.Deserialize <Tuple <int, int> >(bytes)));

            case MessageCodes.ClrHeap_GetSizeByGeneration:
                return(GetClrHeapSizeByGeneration(MessageSerializer.Deserialize <Tuple <int, int> >(bytes)));

            case MessageCodes.ClrThread_GetFrames:
                return(GetClrThreadFrames(MessageSerializer.Deserialize <Tuple <int, uint> >(bytes)));

            case MessageCodes.ClrThread_GetLastException:
                return(GetClrThreadLastException(MessageSerializer.Deserialize <Tuple <int, uint> >(bytes)));

            case MessageCodes.ClrThread_EnumerateStackObjects:
                return(EnumerateClrThreadStackObjects(MessageSerializer.Deserialize <Tuple <int, uint, int> >(bytes)));

            case MessageCodes.ClrStackFrame_GetLocals:
                return(GetClrStackFrameLocals(MessageSerializer.Deserialize <Tuple <int, uint, int> >(bytes)));

            case MessageCodes.ClrStackFrame_GetArguments:
                return(GetClrStackFrameArguments(MessageSerializer.Deserialize <Tuple <int, uint, int> >(bytes)));

            case MessageCodes.ClrModule_GetTypeByName:
                return(GetClrModuleTypeByName(MessageSerializer.Deserialize <Tuple <int, ulong, string> >(bytes)));

            case MessageCodes.ClrType_GetModule:
                return(GetClrTypeModule(MessageSerializer.Deserialize <int>(bytes)));

            case MessageCodes.ClrType_GetSimpleData:
                return(GetClrTypeSimpleData(MessageSerializer.Deserialize <int>(bytes)));

            case MessageCodes.ClrType_GetFields:
                return(GetClrTypeFields(MessageSerializer.Deserialize <int>(bytes)));

            case MessageCodes.ClrType_GetArrayElementAddress:
                return(GetClrTypeArrayElementAddress(MessageSerializer.Deserialize <Tuple <int, ulong, int> >(bytes)));

            case MessageCodes.ClrType_GetArrayLength:
                return(GetClrTypeArrayLength(MessageSerializer.Deserialize <Tuple <int, ulong> >(bytes)));

            case MessageCodes.ClrType_GetStaticField:
                return(GetClrTypeStaticField(MessageSerializer.Deserialize <Tuple <int, string> >(bytes)));

            case MessageCodes.ClrStaticField_GetAddress:
                return(GetClrStaticFieldAddress(MessageSerializer.Deserialize <Tuple <int, string, int> >(bytes)));

            case MessageCodes.VariableEnumerator_GetNextBatch:
                return(GetVariableEnumeratorNextBatch(MessageSerializer.Deserialize <Tuple <int, int> >(bytes)));

            case MessageCodes.VariableEnumerator_Dispose:
                return(DisposeVariableEnumerator(MessageSerializer.Deserialize <int>(bytes)));

            default:
                throw new Exception($"Unknown message code: {messageCode}");
            }
        }