extern static bool _ScanLogContainers(ref CLFS_SCAN_CONTEXT pcxScan,
                                       CLFS_SCAN_MODE eScanMode,
                                       IntPtr pReserved);
        public static bool ScanLogContainersSyncClose(
            ref CLFS_SCAN_CONTEXT pcxScan)
        {
#pragma warning suppress 56523
            bool ret = _ScanLogContainers(ref pcxScan,
                                          CLFS_SCAN_MODE.CLFS_SCAN_CLOSE,
                                          IntPtr.Zero);
            if (!ret)
            {
                // The CLFS API was called in close handle mode. If it fails, either CLFS has a bug or IO.Log does
                // Either way, it is not safe to continue processing.
                DiagnosticUtility.FailFast("Closing scan context cannot fail");
            }

            return true;
        }
 extern static bool _CreateLogContainerScanContext(
     SafeFileHandle hLog,
     uint cFromContainer,
     uint cContainers,
     CLFS_SCAN_MODE eScanMode,
     ref CLFS_SCAN_CONTEXT pcxScan,
     NativeOverlapped* pOverlapped);
        public static void CreateLogContainerScanContextSync(
            SafeFileHandle hLog,
            uint cFromContainer,
            uint cContainers,
            CLFS_SCAN_MODE eScanMode,
            ref CLFS_SCAN_CONTEXT pcxScan)
        {
            if (!_CreateLogContainerScanContext(hLog,
                                                cFromContainer,
                                                cContainers,
                                                eScanMode,
                                                ref pcxScan,
                                                null))
            {
                uint errorCode = (uint)Marshal.GetLastWin32Error();
                if (errorCode == Error.ERROR_IO_PENDING)
                {
                    // The CLFS API was called with a NULL overlapped, so the operation should not be asynchronous.
                    // This means that CLFS has a bug, so it is not safe to continue processing.
                    DiagnosticUtility.FailFast("No async in CreateLCScanSync");
                }
                switch (errorCode)
                {
                    case Error.ERROR_INVALID_HANDLE:
                    case Error.ERROR_OUTOFMEMORY:
                    case Error.ERROR_ACCESS_DENIED:
                    case Error.ERROR_INVALID_PARAMETER:
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ExceptionForKnownCode(errorCode));

                    default:
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ExceptionForUnknownCode(errorCode));
                }
            }
        }