Ejemplo n.º 1
0
        protected RPCManager(string localName)
        {
            this.localName = localName;

            Assembly loadingAssembly = Assembly.GetCallingAssembly(); //load types from assembly that invoked the rpc creation

            Type[] types = loadingAssembly.GetTypes();                //get all types in the loaded assembly

            foreach (Type type in types)
            {
                MethodInfo[] methods = type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
                foreach (MethodInfo method in methods)
                {
                    if (method.IsDefined(typeof(NativeRPC)))
                    {
                        NativeRPC     info       = method.GetCustomAttribute <NativeRPC>();
                        RPCNativeCall nativeCode = Delegate.CreateDelegate(typeof(RPCNativeCall), method) as RPCNativeCall;
                        if (!AddRPCCall(method.Name, nativeCode, info.SecurityLevel))
                        {
                            HookRPCCall(method.Name, nativeCode);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public bool HookRPCCall(string hookName, RPCNativeCall nativeCode)
        {
            if (!cmdTable.ContainsKey(hookName))
            {
                return(false);
            }

            cmdTable[hookName].NativeCode += nativeCode;

            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Add an RPC call to the manager
        /// </summary>
        /// <param name="callName">What the name of the call should be, this is the name that will be parsed out of the command line.</param>
        /// <param name="nativeCode">The native code to execute when this RPC command is executed.</param>
        /// <param name="securityLevel">The security level of this call.</param>
        /// <returns>True if the new call could be added.</returns>
        public bool AddRPCCall(string callName, RPCNativeCall nativeCode, RPCSecurityLevel securityLevel)
        {
            if (cmdTable.ContainsKey(callName))
            {
                return(false);
            }

            cmdTable.Add(callName, new RPCTableEntry(nativeCode, securityLevel));

            return(true);
        }
Ejemplo n.º 4
0
 public RPCTableEntry(RPCNativeCall nativeCall, RPCSecurityLevel securityLevel)
 {
     this.securityLevel = securityLevel;
     this.NativeCode   += nativeCall;
 }