Exemplo n.º 1
0
        public static void InstallFunctionTableHandler(IntPtr codeCachePointer, uint codeCacheLength, IntPtr workBufferPtr)
        {
            const uint codeCacheLengthMax = 2047 * 1024 * 1024;

            ulong codeCachePtr = (ulong)codeCachePointer.ToInt64();

            _sizeOfRuntimeFunction = Marshal.SizeOf <RuntimeFunction>();

            bool result;

            unsafe
            {
                _runtimeFunction = (RuntimeFunction *)workBufferPtr;

                _unwindInfo = (UnwindInfo *)(workBufferPtr + _sizeOfRuntimeFunction);

                _getRuntimeFunctionCallback = new GetRuntimeFunctionCallback(FunctionTableHandler);

                result = RtlInstallFunctionTableCallback(
                    codeCachePtr | 3,
                    codeCachePtr,
                    Math.Min(codeCacheLength, codeCacheLengthMax),
                    _getRuntimeFunctionCallback,
                    codeCachePointer,
                    null);
            }

            if (!result)
            {
                throw new InvalidOperationException("Failure installing function table callback.");
            }
        }
Exemplo n.º 2
0
 private static unsafe extern bool RtlInstallFunctionTableCallback(
     ulong tableIdentifier,
     ulong baseAddress,
     uint length,
     GetRuntimeFunctionCallback callback,
     IntPtr context,
     string outOfProcessCallbackDll);
Exemplo n.º 3
0
 public static extern bool RtlInstallFunctionTableCallback(ulong TableIdentifier, ulong BaseAddress, uint Length, GetRuntimeFunctionCallback Callback, IntPtr Context = default, [MarshalAs(UnmanagedType.LPWStr)] string OutOfProcessCallbackDll = null);