Esempio n. 1
0
        public static DllInjector GetCurrentProcess()
        {
            if (CurrentProcess == null || CurrentProcess.Disposed)
            {
                CurrentProcess = new DllInjector(Process.GetCurrentProcess());
            }

            return(CurrentProcess);
        }
Esempio n. 2
0
        private static int __CLR_CALLFUNCTION__(string pwzArgument)
        {
            IntPtr ParamaterPtr = new IntPtr(Convert.ToInt64(pwzArgument, 16));

            using (DllInjector Injector = DllInjector.GetCurrentProcess())
            {
                Injector.AcquireProcessHandle();

                CLRCallFunctionParam P = new CLRCallFunctionParam();

                try
                {
                    byte[] Bytes = Injector.ReadPrefixedBytes(Injector.ReadIntPtr(ParamaterPtr));

                    using (MemoryStream MS = new MemoryStream(Bytes))
                        P = (CLRCallFunctionParam)__CLR_SERIALIZER__.Deserialize(MS);

                    Type[] ParamaterTypes = new Type[P.ParamaterAssemblies.Length];

                    for (int i = 0; i < ParamaterTypes.Length; i++)
                    {
                        ParamaterTypes[i] = LoadAssemblySerializationBinder.Default.BindToType(P.ParamaterAssemblies[i], P.ParamaterDeclaringTypes[i]);
                    }

                    P.ReturnValue = LoadAssemblySerializationBinder
                                    .Default
                                    .BindToType(P.Assembly, P.DeclaringType)
                                    .GetMethod(P.Function,
                                               BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static,
                                               null,
                                               ParamaterTypes,
                                               null)
                                    .Invoke(null, P.Paramaters);
                }
                catch (Exception ex)
                {
                    P.Exception = ex;
                }

                using (MemoryStream MS = new MemoryStream())
                {
                    __CLR_SERIALIZER__.Serialize(MS, P);
                    Injector.WriteIntPtr(ParamaterPtr, Injector.WritePrefixedBytes(MS.ToArray()));
                }
            }

            return((int)Win32.ERROR_SUCCESS);
        }
Esempio n. 3
0
 internal protected MemoryHandle(DllInjector Injector, IntPtr hRemoteMem)
 {
     this.Injector   = Injector;
     this.hRemoteMem = hRemoteMem;
 }
Esempio n. 4
0
 internal protected ModuleHandle(DllInjector Injector, IntPtr hModule)
 {
     this.Injector = Injector;
     this.hModule  = hModule;
 }