Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

C# Remote Method Invoking

Hello HF!

This is my preview of my very basic and simple RemoteMethod class. It is currently able to invoke public static methods in public classes on the client (only works if the return value and the parameters are serializable), and return the return value to the server (via a encrypted tcp connection).

Thanks to DragonHunter for the Sync concept!

Video:
Spoiler (Click to View)

Sorry for my English im Dutch
Wouldn't this be much easier?
https://hackforums.net/showthread.php?tid=2338582

Code
public class WebLibrary
    {
  private Dictionary<string, byte[]> libCollection;
  private string webUrl;

  public WebLibrary(Uri webUri)
  {
    webUrl = webUri.ToString();
    libCollection = new Dictionary<string, byte[]>();
  }
  public WebLibrary(string webUrl)
  {
    this.webUrl = webUrl;
    libCollection = new Dictionary<string, byte[]>();
  }

  public void Add(string LibraryName)
  {
    WebClient wc = new WebClient();
    byte[] data = wc.DownloadData(webUrl.EndsWith("/") ? webUrl + LibraryName + ".dll" : webUrl + "/" + LibraryName + ".dll");
    libCollection.Add(LibraryName, data);
  }

  public void InvokeMethod(string LibraryName, string Class, string MethodName, object[] Parameters = null)
  {
    Assembly.Load(libCollection[LibraryName])
  .GetType(LibraryName + "." + Class).GetMethod(MethodName).Invoke(null, Parameters);
  }
    }
(Apr 21, 2012 04:17 AM)BaussHacker Wrote:  Wouldn't this be much easier?
https://hackforums.net/showthread.php?tid=2338582

Code
public class WebLibrary
    {
  private Dictionary<string, byte[]> libCollection;
  private string webUrl;

  public WebLibrary(Uri webUri)
  {
    webUrl = webUri.ToString();
    libCollection = new Dictionary<string, byte[]>();
  }
  public WebLibrary(string webUrl)
  {
    this.webUrl = webUrl;
    libCollection = new Dictionary<string, byte[]>();
  }

  public void Add(string LibraryName)
  {
    WebClient wc = new WebClient();
    byte[] data = wc.DownloadData(webUrl.EndsWith("/") ? webUrl + LibraryName + ".dll" : webUrl + "/" + LibraryName + ".dll");
    libCollection.Add(LibraryName, data);
  }

  public void InvokeMethod(string LibraryName, string Class, string MethodName, object[] Parameters = null)
  {
    Assembly.Load(libCollection[LibraryName])
  .GetType(LibraryName + "." + Class).GetMethod(MethodName).Invoke(null, Parameters);
  }
    }

RemoteMethod is more dynamic, because the server can call all the static methods on the client side just by running the class, without downloading a dll or something, just with a encrypted tcp connection between the two pc's.
Oh wait, I misunderstoof OP, nevermind, just ignore my post.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by YourAverageTurkDec 2, 2017 11:31 AM 3 149 Dec 2, 2017 11:31 AM
Last Post: YourAverageTurk
[.NET] by BarretFeb 24, 2017 07:28 AM 6 317 Feb 24, 2017 07:28 AM
Last Post: hfTP54
[.NET] by KrypteXApr 29, 2016 06:22 PM 15 556 Apr 29, 2016 06:22 PM
Last Post: Cecilia