Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8822309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:04:32+00:00 2026-06-14T06:04:32+00:00

How can both the IPC client and IPC server call the shared remoting interface

  • 0

How can both the IPC client and IPC server call the shared remoting interface (the class inheriting MarshalByRefObject) to communicate, without having to put the interface class inside in the injecting application? For example, if I put the interface class in the injected library project that gets injected into my target process, my injecting application cannot reference that interface.

Edit: I have answered the question below.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:04:33+00:00Added an answer on June 14, 2026 at 6:04 am

    As of EasyHook Commit 66751 (tied to EasyHook 2.7 alpha), it doesn’t seem possible to get the instance of the remoting interface in both the client (that process that initiated injection of your DLL) and the server (the injected process running your injected DLL).

    What do I mean?

    Well, in the FileMon and ProcessMonitor examples, notice how the shared remoting interfaces (FileMonInterface, embedded in Program.cs, for Filemon, and DemoInterface, in its own file, for ProcessMonitor) are placed in the injecting assembly. FileMonInterface is in the FileMon project. DemoInterface is in the ProcessMonitor project.

    Why not the other round? Why not put FileMonInterface in the project FileMonInject, and put DemoInterface in ProcMonInject? Because then the interfaces will no longer be accessible to the calling applications (FileMon and ProcessMonitor).

    The reason is because EasyHook internally uses:

    RemotingConfiguration.RegisterWellKnownServiceType(
                    typeof(TRemoteObject),
                    ChannelName,
                    InObjectMode);
    

    This remoting call allows clients to call your (server) interface, but the server itself (you, the application) cannot call it.

    The Solution

    Instead, use:

    // Get the instance by simply calling `new RemotingInterface()` beforehand somewhere
    RemotingServices.Marshal(instanceOfYourRemotingInterfaceHere, ChannelName);
    

    What I did was add an overload to EasyHook’s RemoteHook.IpcCreateServer() to accept my new “way” of doing .NET remoting.

    It’s ugly, but it works:

    The Code

    Replace the entire IpcCreateServer method (from brace to brace) with the following code. There are two methods shown here. One is the more detailed overload. The second is the “original” method calling our overload.

    public static IpcServerChannel IpcCreateServer<TRemoteObject>(
            ref String RefChannelName,
            WellKnownObjectMode InObjectMode,
            TRemoteObject ipcInterface, String ipcUri, bool useNewMethod,
            params WellKnownSidType[] InAllowedClientSIDs) where TRemoteObject : MarshalByRefObject
        {
            String ChannelName = RefChannelName ?? GenerateName();
    
            ///////////////////////////////////////////////////////////////////
            // create security descriptor for IpcChannel...
            System.Collections.IDictionary Properties = new System.Collections.Hashtable();
    
            Properties["name"] = ChannelName;
            Properties["portName"] = ChannelName;
    
            DiscretionaryAcl DACL = new DiscretionaryAcl(false, false, 1);
    
            if (InAllowedClientSIDs.Length == 0)
            {
                if (RefChannelName != null)
                    throw new System.Security.HostProtectionException("If no random channel name is being used, you shall specify all allowed SIDs.");
    
                // allow access from all users... Channel is protected by random path name!
                DACL.AddAccess(
                    AccessControlType.Allow,
                    new SecurityIdentifier(
                        WellKnownSidType.WorldSid,
                        null),
                    -1,
                    InheritanceFlags.None,
                    PropagationFlags.None);
            }
            else
            {
                for (int i = 0; i < InAllowedClientSIDs.Length; i++)
                {
                    DACL.AddAccess(
                        AccessControlType.Allow,
                        new SecurityIdentifier(
                            InAllowedClientSIDs[i],
                            null),
                        -1,
                        InheritanceFlags.None,
                        PropagationFlags.None);
                }
            }
    
            CommonSecurityDescriptor SecDescr = new CommonSecurityDescriptor(false, false,
                ControlFlags.GroupDefaulted |
                ControlFlags.OwnerDefaulted |
                ControlFlags.DiscretionaryAclPresent,
                null, null, null,
                DACL);
    
            //////////////////////////////////////////////////////////
            // create IpcChannel...
            BinaryServerFormatterSinkProvider BinaryProv = new BinaryServerFormatterSinkProvider();
            BinaryProv.TypeFilterLevel = TypeFilterLevel.Full;
    
            IpcServerChannel Result = new IpcServerChannel(Properties, BinaryProv, SecDescr);
    
            if (!useNewMethod)
            {
                ChannelServices.RegisterChannel(Result, false);
    
                RemotingConfiguration.RegisterWellKnownServiceType(
                    typeof(TRemoteObject),
                    ChannelName,
                    InObjectMode);
            }
            else
            {
                ChannelServices.RegisterChannel(Result, false);
    
                ObjRef refGreeter = RemotingServices.Marshal(ipcInterface, ipcUri);
            }
    
            RefChannelName = ChannelName;
    
            return Result;
        }
    
        /// <summary>
        /// Creates a globally reachable, managed IPC-Port.
        /// </summary>
        /// <remarks>
        /// Because it is something tricky to get a port working for any constellation of
        /// target processes, I decided to write a proper wrapper method. Just keep the returned
        /// <see cref="IpcChannel"/> alive, by adding it to a global list or static variable,
        /// as long as you want to have the IPC port open.
        /// </remarks>
        /// <typeparam name="TRemoteObject">
        /// A class derived from <see cref="MarshalByRefObject"/> which provides the
        /// method implementations this server should expose.
        /// </typeparam>
        /// <param name="InObjectMode">
        /// <see cref="WellKnownObjectMode.SingleCall"/> if you want to handle each call in an new
        /// object instance, <see cref="WellKnownObjectMode.Singleton"/> otherwise. The latter will implicitly
        /// allow you to use "static" remote variables.
        /// </param>
        /// <param name="RefChannelName">
        /// Either <c>null</c> to let the method generate a random channel name to be passed to 
        /// <see cref="IpcConnectClient{TRemoteObject}"/> or a predefined one. If you pass a value unequal to 
        /// <c>null</c>, you shall also specify all SIDs that are allowed to connect to your channel!
        /// </param>
        /// <param name="InAllowedClientSIDs">
        /// If no SID is specified, all authenticated users will be allowed to access the server
        /// channel by default. You must specify an SID if <paramref name="RefChannelName"/> is unequal to <c>null</c>.
        /// </param>
        /// <returns>
        /// An <see cref="IpcChannel"/> that shall be keept alive until the server is not needed anymore.
        /// </returns>
        /// <exception cref="System.Security.HostProtectionException">
        /// If a predefined channel name is being used, you are required to specify a list of well known SIDs
        /// which are allowed to access the newly created server.
        /// </exception>
        /// <exception cref="RemotingException">
        /// The given channel name is already in use.
        /// </exception>
        public static IpcServerChannel IpcCreateServer<TRemoteObject>(
            ref String RefChannelName,
            WellKnownObjectMode InObjectMode,
            params WellKnownSidType[] InAllowedClientSIDs) where TRemoteObject : MarshalByRefObject
        {
            return IpcCreateServer<TRemoteObject>(ref RefChannelName, InObjectMode, null, null, false, InAllowedClientSIDs);
        }
    

    That’s it. That’s all you need to change. You don’t have to change IpcCreateClient().

    Using the Code

    Here’s how you would use the new overloaded method:

    Say you have

    public class IpcInterface : MarshalByRefObject { /* ... */ }
    

    as your shared remoting interface.

    Create a new instance of it, and store its reference. You’ll be using this to communicate with your client.

    var myIpcInterface = new IpcInterface(); // Keep this reference to communicate!
    

    Here’s how you would have created that remoting channel before:

            ipcServer = RemoteHooking.IpcCreateServer<IpcInterface>(ref IpcChannelName, WellKnownObjectMode.Singleton, WellKnownSidType.WorldSid);
    

    Here’s how you would create that remoting channel now:

            ipcServer = RemoteHooking.IpcCreateServer<IpcInterface>(ref IpcChannelName, WellKnownObjectMode.Singleton, myIpcInterface, IpcChannelName, true, WellKnownSidType.WorldSid);
    

    Don’t forget to…

    I got this solution from this StackOverflow post. Please be sure to do as he says and override InitializeLifetimeService to return null:

    public override object InitializeLifetimeService()
    {
        // Live "forever"
        return null;
    }
    

    I think this is supposed to keep the client from losing the remoting interface.

    Uses

    Now, instead of being forced to place your remoting interface file in the same directory as your injecting project, you can create a library specifically for your interface file.

    This solution may have been common knowledge to those having had experience with .NET remoting, but I know nothing about it (might have used the word interface wrong in this post).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Input/Output stream to pass objects between my client and server. I can both
From what I learned, a MySQL MASTER server is one that can both read
As far as I understand, the IDeserializationCallback interface and the OnDeserialized event can both
How can I reserve and allocate shared memory without the backing of a file?
Trying to create a class in JavaScript that can both have a function at
It seems that Rails and Django can both start up the server binding to
I have two view controllers in a tabbar which can both edit data. Therefore,
I'm writing an app where a user can both create their own pages for
I can implement both variants - it's easy. But I'm interested: what approach is
It seems both can be overloaded, but somebody said not..... What's the case?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.