Exemplo n.º 1
0
        public SbError SetModuleLoadAddress(SbModule module, long sectionsOffset)
        {
            SetModuleLoadAddressResponse response = null;

            if (connection.InvokeRpc(() =>
            {
                response = client.SetModuleLoadAddress(
                    new SetModuleLoadAddressRequest
                {
                    Target = grpcSbTarget,
                    Module = new GrpcSbModule {
                        Id = module.GetId()
                    },
                    SectionsOffset = sectionsOffset,
                });
            }))
            {
                return(errorFactory.Create(response.Error));
            }
            var grpcSbError = new GrpcSbError
            {
                Success = false,
                Error   = "Rpc error while calling SetModuleLoadAddress."
            };

            return(errorFactory.Create(grpcSbError));
        }
Exemplo n.º 2
0
        public SbProcess AttachToProcessWithID(SbListener listener, ulong pid, out SbError error)
        {
            var request = new AttachToProcessWithIDRequest()
            {
                Target   = grpcSbTarget,
                Listener = new GrpcSbListener()
                {
                    Id = listener.GetId()
                },
                Pid = pid,
            };
            AttachToProcessWithIDResponse response = null;

            if (connection.InvokeRpc(() =>
            {
                response = client.AttachToProcessWithID(request);
            }))
            {
                error = errorFactory.Create(response.Error);
                if (response.Process == null)
                {
                    return(null);
                }
                return(processFactory.Create(connection, response.Process));
            }
            var grpcError = new GrpcSbError
            {
                Success = false,
                Error   = "Rpc error while calling AttachToProcessWithId."
            };

            error = errorFactory.Create(grpcError);
            return(null);
        }
Exemplo n.º 3
0
        public ulong WriteMemory(ulong address, byte[] buffer, ulong size, out SbError error)
        {
            WriteMemoryResponse response = null;

            if (connection.InvokeRpc(() =>
            {
                response = client.WriteMemory(
                    new WriteMemoryRequest
                {
                    Process = grpcSbProcess,
                    Address = address,
                    Buffer = ByteString.CopyFrom(buffer, 0, (int)size),
                    Size = size
                });
            }))
            {
                error = errorFactory.Create(response.Error);
                return(response.Size);
            }
            var grpcError = new GrpcSbError
            {
                Success = false,
                Error   = "Rpc error while calling WriteMemory."
            };

            error = errorFactory.Create(grpcError);
            return(0);
        }
Exemplo n.º 4
0
        public SbWatchpoint WatchAddress(long address, ulong size, bool read, bool write,
                                         out SbError error)
        {
            WatchAddressResponse response = null;

            error = null;
            if (connection.InvokeRpc(() =>
            {
                response = client.WatchAddress(
                    new WatchAddressRequest
                {
                    Target = grpcSbTarget,
                    Address = address,
                    Size = size,
                    Read = read,
                    Write = write
                });
            }))
            {
                error = errorFactory.Create(response.Error);
                if (response.Watchpoint != null && response.Watchpoint.Id != 0)
                {
                    return(watchpointFactory.Create(connection, response.Watchpoint));
                }
                return(null);
            }
            var grpcError = new GrpcSbError
            {
                Success = false,
                Error   = "Rpc error while calling WatchAddress."
            };

            error = errorFactory.Create(grpcError);
            return(null);
        }
Exemplo n.º 5
0
        public ulong ReadMemory(ulong address, byte[] memory, ulong size, out SbError error)
        {
            ReadMemoryResponse response = null;

            if (connection.InvokeRpc(() =>
            {
                response = client.ReadMemory(
                    new ReadMemoryRequest
                {
                    Process = grpcSbProcess,
                    Address = address,
                    Size = size
                });
            }))
            {
                error = errorFactory.Create(response.Error);
                var responseArray = response.Memory.ToByteArray();
                int startingIndex = 0;
                if (responseArray.Length > memory.Length)
                {
                    Trace.WriteLine("Error: buffer is not large enough for the output.");
                    startingIndex = responseArray.Length - memory.Length;
                }
                response.Memory.ToByteArray().CopyTo(memory, startingIndex);
                return(response.Size);
            }
            var grpcError = new GrpcSbError
            {
                Success = false,
                Error   = "Rpc error while calling ReadMemory."
            };

            error = errorFactory.Create(grpcError);
            return(0);
        }
Exemplo n.º 6
0
        public SbError ConnectRemote(SbPlatformConnectOptions connectOptions)
        {
            var grpcSbPlatformConnectOptions = new GrpcSbPlatformConnectOptions
            {
                Url = connectOptions.GetUrl()
            };
            var request = new ConnectRemoteRequest
            {
                ConnectOptions = grpcSbPlatformConnectOptions
            };
            ConnectRemoteResponse response = null;

            if (connection.InvokeRpc(() =>
            {
                response = client.ConnectRemote(request);
            }))
            {
                return(sbErrorFactory.Create(response.Error));
            }
            var grpcSbError = new GrpcSbError
            {
                Success = false,
                Error   = "Rpc error while calling ConnectRemote.  Inspect the logs for more " +
                          "information."
            };

            return(sbErrorFactory.Create(grpcSbError));
        }
Exemplo n.º 7
0
        public SbError Run(SbPlatformShellCommand command)
        {
            var grpcSbPlatformShellCommand = new GrpcSbPlatformShellCommand
            {
                Command = command.GetCommand()
            };
            var request = new RunRequest {
                ShellCommand = grpcSbPlatformShellCommand
            };
            RunResponse response = null;

            if (connection.InvokeRpc(() =>
            {
                response = client.Run(request);
            }))
            {
                command.SetOutput(response.Output);
                command.SetSignal(response.Signal);
                command.SetStatus(response.Status);
                return(sbErrorFactory.Create(response.Error));
            }
            var grpcSbError = new GrpcSbError
            {
                Success = false,
                Error   = "Rpc error while calling Run.  Inspect the logs for more information."
            };

            return(sbErrorFactory.Create(grpcSbError));
        }
Exemplo n.º 8
0
        public SbError Create(GrpcSbError grpcSbError)
        {
            if (grpcSbError == null)
            {
                throw new ArgumentNullException(nameof(grpcSbError));
            }

            return(new SbErrorImpl(grpcSbError));
        }
        public override Task <SetModuleLoadAddressResponse> SetModuleLoadAddress(
            SetModuleLoadAddressRequest request, ServerCallContext context)
        {
            RemoteTarget target    = GrpcLookupUtils.GetTarget(request.Target, _targetStore);
            SbModule     module    = _moduleStore.GetObject(request.Module.Id);
            SbError      error     = target.SetModuleLoadAddress(module, request.SectionsOffset);
            var          grpcError =
                new GrpcSbError {
                Success = error.Success(), Error = error.GetCString()
            };

            return(Task.FromResult(new SetModuleLoadAddressResponse {
                Error = grpcError
            }));
        }
Exemplo n.º 10
0
        // Connect to a LLDB server.
        public override Task <ConnectRemoteResponse> ConnectRemote(ConnectRemoteRequest request,
                                                                   ServerCallContext context)
        {
            PreconditionCheck();
            var connectOptions = sbPlatformConnectOptionsFactory.Create(request.ConnectOptions.Url);
            var error          = sbPlatform.ConnectRemote(connectOptions);
            var grpcError      = new GrpcSbError
            {
                Success = error.Success(),
                Error   = error.GetCString()
            };

            return(Task.FromResult(new ConnectRemoteResponse {
                Error = grpcError
            }));
        }
Exemplo n.º 11
0
        // Run the specified command.
        public override Task <RunResponse> Run(RunRequest request, ServerCallContext context)
        {
            PreconditionCheck();
            var shellCommand = sbPlatformShellCommandFactory.Create(request.ShellCommand.Command);
            var error        = sbPlatform.Run(shellCommand);
            var grpcError    = new GrpcSbError
            {
                Success = error.Success(),
                Error   = error.GetCString()
            };
            var response = new RunResponse
            {
                Error  = grpcError,
                Output = shellCommand.GetOutput(),
                Signal = shellCommand.GetSignal(),
                Status = shellCommand.GetStatus()
            };

            return(Task.FromResult(response));
        }
Exemplo n.º 12
0
 internal SbErrorImpl(GrpcSbError grpcSbError)
 {
     this.grpcSbError = grpcSbError;
 }