CiValidateFileObject - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
// ntfill.h

// rev
typedef // routine: CiValidateFileObject
_Function_class_(CI_VALIDATE_FILE_OBJECT)
NTSTATUS
NTAPI
CI_VALIDATE_FILE_OBJECT(
    _In_ PFILE_OBJECT FileObject,
    _In_ ULONG PolicyFlags,
    _In_ SE_SIGNING_LEVEL LevelCheck,
    _Inout_ PMINCRYPT_POLICY_INFO PolicyInfo,
    _Inout_ PMINCRYPT_POLICY_INFO TimeStampPolicyInfo,
    _Out_ PLARGE_INTEGER SigningTime,
    _Out_writes_bytes_to_(*ThumbprintSize, *ThumbprintSize) PUCHAR Thumbprint,
    _Inout_ PULONG ThumbprintSize,
    _Out_ PULONG ThumbprintAlgorithm
    );

View code on GitHub

NtDoc

Verifies the signature of a file object and returns the policy info along with the timestamp and signing time. The routine maps the file into system address space, computes the Authenticode digest, and verifies the signature. The computed digest is returned to the caller through the Thumbprint output parameters.

Parameters

Remarks

This function is exported from ci.dll. Unlike CiCheckSignedFile, it performs the mapping and hashing of the image itself. It also applies a stricter policy than CiCheckSignedFile, which means that some images that CiCheckSignedFile would accept can be rejected here.

In practice, several contributors have reported that with a zero PolicyFlags the function rejects images signed with non-Microsoft root certificates unless test-signing mode is enabled, and that setting CI_POLICY_ACCEPT_ANY_ROOT_CERTIFICATE (0x20) in PolicyFlags makes verification succeed on production systems. Reproduced on Windows 10 builds 19041 and 19045; see CiDllDemo issue #5.

In the same thread, contributors also report that the function returns STATUS_INVALID_IMAGE_HASH for PE images signed using ECDSA. An OSR forum analysis linked from the thread attributes this to a MinCrypt_DisableEcdsa routine invoked from CipInitialize during Code Integrity startup.

For more details, see Code Integrity in the Kernel: A Look Into ci.dll by Liron Zuarets and Ido Moshe.

See also