public static extern NtStatus NtSetCachedSigningLevel2(
     int Flags,
     SigningLevel SigningLevel,
     [In] IntPtr[] SourceFiles,
     int SourceFileCount,
     SafeKernelObjectHandle TargetFile,
     CachedSigningLevelInformation Information
     );
Exemplo n.º 2
0
        /// <summary>
        /// Set the cached signing level for a file.
        /// </summary>
        /// <param name="handle">The handle to the file to set the cache on.</param>
        /// <param name="flags">Flags to set for the cache.</param>
        /// <param name="signing_level">The signing level to cache</param>
        /// <param name="source_files">A list of source file for the cache.</param>
        /// <param name="catalog_path">Optional directory path to look for catalog files.</param>
        public static void SetCachedSigningLevel(SafeKernelObjectHandle handle,
                                                 int flags, SigningLevel signing_level,
                                                 IEnumerable <SafeKernelObjectHandle> source_files,
                                                 string catalog_path)
        {
            IntPtr[] handles       = source_files?.Select(f => f.DangerousGetHandle()).ToArray();
            int      handles_count = handles == null ? 0 : handles.Length;

            if (catalog_path != null)
            {
                CachedSigningLevelInformation info = new CachedSigningLevelInformation(catalog_path);
                NtSystemCalls.NtSetCachedSigningLevel2(flags, signing_level, handles, handles_count, handle, info).ToNtException();
            }
            else
            {
                NtSystemCalls.NtSetCachedSigningLevel(flags, signing_level, handles, handles_count, handle).ToNtException();
            }
        }