Пример #1
0
        public SafeFunction()
        {
            Delegate @delegate = ToCallDelegate();

            MemoryAddress originalFuncPtr = @delegate.ToFunctionPtr();

            MemoryModule module = originalFuncPtr.GetMyModule();

            List <byte> bytes = new List <byte>();

            bytes.AddRange(originalFuncPtr.GetReturnToPtr());

            IMemoryAddress codeCave = module.FindCodeCaveInModule((uint)bytes.Count);

            codeCave.Write(bytes.ToArray());

            Type typeOfDelegate = @delegate.GetType();

            SafeFunctionDelegate = Marshal.GetDelegateForFunctionPointer(codeCave.Address, typeOfDelegate);
        }
Пример #2
0
        protected override void Execute(Injectable assembly)
        {
            IMemoryAddress allocatedMemory = Process.AllocateManagedMemory(assembly.PathToAssemblyFile.Length);

            allocatedMemory.Write(Encoding.Unicode.GetBytes(assembly.PathToAssemblyFile));
        }