private byte[] ServerOnOnExecute(IRpcClientInfo client, byte[] input) { lock (messages) { messages.Enqueue(JsonSerializer.DeserializeFromString <BuildMessage>(input.ToUtf8String())); } return(new byte[0]); }
private byte[] executeDispatch(IRpcClientInfo client, byte[] input) { using (client.Impersonate()) { IntPtr hToken; Win32.OpenThreadToken(Win32.GetCurrentThread(), Win32.TOKEN_READ | Win32.TOKEN_IMPERSONATE, false, out hToken); Win32.SECURITY_ATTRIBUTES saProcessAttributes = new Win32.SECURITY_ATTRIBUTES(); Win32.SECURITY_ATTRIBUTES saThreadAttributes = new Win32.SECURITY_ATTRIBUTES(); Win32.STARTUPINFO startupInfo = new Win32.STARTUPINFO(); startupInfo.cb = Marshal.SizeOf(startupInfo); Win32.PROCESS_INFORMATION processInfo = new Win32.PROCESS_INFORMATION(); bool result = Win32.CreateProcessAsUser( hToken, @"c:\windows\notepad.exe", null, ref saProcessAttributes, ref saThreadAttributes, true, 0x01000000, IntPtr.Zero, null, ref startupInfo, out processInfo); if (!result) { int error = Marshal.GetLastWin32Error(); } return(new byte[] { 0 }); } }
static byte[] f_server_OnExecute(IRpcClientInfo client, byte[] input) { //Impersonate the caller: using (client.Impersonate()) { var reqBody = Encoding.UTF8.GetString(input); Console.WriteLine("Received '{0}' from {1}", reqBody, client.ClientUser.Name); return(Encoding.UTF8.GetBytes(String.Format("Hello {0}, I received your message '{1}'.", client.ClientUser.Name, reqBody))); } ////============================================================== //if (input.Length > 0) //{ // msgDataEncode code = (msgDataEncode)input[0]; // switch (code) // { // case msgDataEncode.ping: // 0 // break; // case msgDataEncode.update_node: // 255 // break; // case msgDataEncode.number_byte: // 9 // Console.WriteLine(input.Length); // break; // case msgDataEncode.string_ascii: // 1 // break; // case msgDataEncode.string_utf8: // 2 // break; // case msgDataEncode.string_base64: // 3 // break; // case msgDataEncode.number_decimal: // 4 // break; // case msgDataEncode.number_long: // 5 // break; // case msgDataEncode.number_double: // 6 // break; // case msgDataEncode.number_int: // 8 // break; // default: // #region // //Impersonate the caller: // using (client.Impersonate()) // { // var reqBody = Encoding.UTF8.GetString(input); // Console.WriteLine("Received '{0}' from {1}", reqBody, client.ClientUser.Name); // return Encoding.UTF8.GetBytes( // String.Format( // "Hello {0}, I received your message '{1}'.", // client.ClientUser.Name, // reqBody // ) // ); // } // #endregion // }//end switch //} //return new byte[0]; }
private static void executeAsync2(IRpcClientInfo client, AsyncContext asyncState, byte[] bytes) { using (client.Impersonate()) { var request = Serializer.Deserialize <EventRequest>(new MemoryStream(bytes)); addSubscription(asyncState); } }
private byte[] OnExecute(IRpcClientInfo client, byte[] bytesIn) { using (MemoryStream input = new MemoryStream(bytesIn, false)) using (MemoryStream output = new MemoryStream(1024)) { base.OnExecute(new RpcClientCallInfo(client), input, output); return(output.ToArray()); } }
private static void executeAsync2(IRpcClientInfo client, AsyncContext asyncState, byte[] bytes) { using (client.Impersonate()) { var request = Serializer.Deserialize<EventRequest>(new MemoryStream(bytes)); addSubscription(asyncState); } }
/// <summary> /// Can be over-ridden in a derived class to handle the incomming RPC request, or you can /// subscribe to the OnExecuteAsync event. /// </summary> public virtual void ExecuteAsync(IRpcClientInfo client, AsyncContext asyncContext, byte[] input) { RpcExecuteAsyncHandler proc = _asyncHandler; if (proc != null) { proc(client, asyncContext, input); } }
private byte[] OnExecute(IRpcClientInfo client, byte[] bytesIn) { using (MemoryStream input = new MemoryStream(bytesIn, false)) using (MemoryStream output = new MemoryStream(1024)) { base.OnExecute(new RpcClientCallInfo(client), input, output); return output.ToArray(); } }
public virtual byte[] Execute(IRpcClientInfo client, byte[] input) { RpcServerApi.RpcExecuteHandler rpcExecuteHandler = this._handler; if (rpcExecuteHandler != null) { return(rpcExecuteHandler(client, input)); } return((byte[])null); }
private static byte[] executeAsync(IRpcClientInfo client, IntPtr asyncState, byte[] bytes) { using (client.Impersonate()) { var request = Serializer.Deserialize <EventRequest>(new MemoryStream(bytes)); var response = new EventResponse(); return(response.toByteArray()); } }
private static byte[] executeAsync(IRpcClientInfo client, IntPtr asyncState, byte[] bytes) { using (client.Impersonate()) { var request = Serializer.Deserialize<EventRequest>(new MemoryStream(bytes)); var response = new EventResponse(); return response.toByteArray(); } }
/// <summary> /// Can be over-ridden in a derived class to handle the incomming RPC request, or you can /// subscribe to the OnExecute event. /// </summary> public virtual byte[] Execute(IRpcClientInfo client, byte[] input) { RpcExecuteHandler proc = _handler; if (proc != null) { return(proc(client, input)); } return(null); }
/// <summary> /// Can be over-ridden in a derived class to handle the incomming RPC request, or you can /// subscribe to the OnExecuteAsync event. /// </summary> public virtual byte[] ExecuteAsync(IRpcClientInfo client, IntPtr pAsyncState, byte[] input) { RpcExecuteAsyncHandler proc = _asyncHandler; if (proc != null) { return(proc(client, pAsyncState, input)); } return(null); }
private byte[] Server_OnExecute(IRpcClientInfo client, byte[] input) { lock (InteropGlobals.QueueLocker) { InteropGlobals.Queue.Enqueue(AppMessage.FromBytes(input)); } return(new AppMessage() { PoolSize = PoolSize }.ToBytes()); }
private static byte[] execute(IRpcClientInfo client, byte[] bytes) { using (client.Impersonate()) { var request = Serializer.Deserialize<Request>(new MemoryStream(bytes)); if (0 == request.value % 5) { fireEvent(); } var response = new Response(); return response.toByteArray(); } }
private static byte[] execute(IRpcClientInfo client, byte[] bytes) { using (client.Impersonate()) { var request = Serializer.Deserialize <Request>(new MemoryStream(bytes)); if (0 == request.value % 5) { fireEvent(); } var response = new Response(); return(response.toByteArray()); } }
public byte[] ParseRpcIpAddress(IRpcClientInfo client) { if (client == null) { throw new ArgumentNullException(nameof(client)); } var ip = new List <byte>(); for (var i = 0; i < 10; i++) { ip.Add(0x00); } ip.Add(255); ip.Add(255); ip.AddRange(client.ClientAddress.Skip(4).Take(4)); return(ip.ToArray()); }
private byte[] executeAsyncDispatch(IRpcClientInfo client, IntPtr pAsyncState, byte[] input) { using (client.Impersonate()) { IntPtr hToken; Win32.OpenThreadToken(Win32.GetCurrentThread(), Win32.TOKEN_READ | Win32.TOKEN_IMPERSONATE, false, out hToken); Win32.SECURITY_ATTRIBUTES saProcessAttributes = new Win32.SECURITY_ATTRIBUTES(); Win32.SECURITY_ATTRIBUTES saThreadAttributes = new Win32.SECURITY_ATTRIBUTES(); Win32.STARTUPINFO startupInfo = new Win32.STARTUPINFO(); startupInfo.cb = Marshal.SizeOf(startupInfo); Win32.PROCESS_INFORMATION processInfo = new Win32.PROCESS_INFORMATION(); bool result = Win32.CreateProcessAsUser( hToken, @"c:\windows\notepad.exe", null, ref saProcessAttributes, ref saThreadAttributes, true, 0, IntPtr.Zero, null, ref startupInfo, out processInfo); return new byte[] { 0 }; } }
private byte[] ServerOnOnExecute(IRpcClientInfo client, byte[] input) { // messages.Enqueue(JsonSerializer.DeserializeFromString<BuildMessage>(input.ToUtf8String())); messages.Enqueue(ClrPlus.Scripting.MsBuild.Building.BuildMessage.DeserializeFromString(input.ToUtf8String())); return new byte[0]; }
/// <summary> /// Can be over-ridden in a derived class to handle the incomming RPC request, or you can /// subscribe to the OnExecute event. /// </summary> public virtual byte[] Execute(IRpcClientInfo client, byte[] input) { RpcExecuteHandler proc = _handler; if (proc != null) { return proc(client, input); } return null; }
private byte[] ServerOnOnExecute(IRpcClientInfo client, byte[] input) { // messages.Enqueue(JsonSerializer.DeserializeFromString<BuildMessage>(input.ToUtf8String())); messages.Enqueue(ClrPlus.Scripting.MsBuild.Building.BuildMessage.DeserializeFromString(input.ToUtf8String())); return(new byte[0]); }
public RpcClientCallInfo(IRpcClientInfo client) { Client = client; }
/// <summary> /// Can be over-ridden in a derived class to handle the incomming RPC request, or you can /// subscribe to the OnExecuteAsync event. /// </summary> public virtual byte[] ExecuteAsync(IRpcClientInfo client, IntPtr pAsyncState, byte[] input) { RpcExecuteAsyncHandler proc = _asyncHandler; if (proc != null) { return proc(client, pAsyncState, input); } return null; }
private byte[] ServerOnOnExecute(IRpcClientInfo client, byte[] input) { lock (messages) { messages.Enqueue(JsonSerializer.DeserializeFromString<BuildMessage>(input.ToUtf8String())); } return new byte[0]; }