using System.Text; using static Vanara.PInvoke.Kernel32; namespace Vanara.PInvoke; public static partial class ClfsW32 { /// User defined callback deciphering the format of a log record buffer and dumping its content to the log stream. /// /// A pointer to an open output stream where the log records are placed. /// If this parameter is not specified, "stdout" is used as the default. /// /// The type of records to be read. /// The buffer of content to format. /// The length of pvBuffer. /// Unknown [UnmanagedFunctionPointer(CallingConvention.Winapi)] public delegate uint CLFS_PRINT_RECORD_ROUTINE([In] HFILE pstrmOut, [In] CLS_RECORD_TYPE fRecordType, [In] IntPtr pvBuffer, [In] uint cbBuffer); /// [UnmanagedFunctionPointer(CallingConvention.Winapi)] public delegate void PCLFS_COMPLETION_ROUTINE([In] IntPtr pvOverlapped, [In, Optional] uint ulReserved); /// /// /// Adds a container to the physical log that is associated with the log handle—if the calling process has write access to the .blf file /// and the ability to create files in the target directory of the container. /// /// /// This function is different from AddLogContainerSet, because it adds only one container. To add multiple containers, it is more /// efficient to use AddLogContainerSet, which allows you to add more than one container. Adding containers allows a client to /// increase the size of a log. /// /// /// /// The handle to an open log. /// /// The handle must be obtained from CreateLogFile with write access to the log. The client application must have write access to the /// .blf file, and the ability to create files in the target directory of a container. /// /// /// /// The optional parameter that specifies the size of the container, in bytes. /// The minimum size is 512 KB for normal logs and 1024 KB for multiplexed logs. The maximum size is approximately 4 gigabytes. /// /// This parameter is required if the containers are being added to a newly created log. If a container is already created, this /// parameter can be NULL, or some value that is at least as large as the size of the first container. /// /// /// Log container sizes are multiples of the log region size (512 KB). When you add a container to a new file, the AddLogContainer /// function rounds the size of the container up to the next 512 KB boundary, and returns that size in the value pointed to by pcbContainer. /// /// /// Similarly, if the log already has at least one container and the value of *pcbContainer is at least as large as the current /// container size, the function creates all containers with the current internal size and returns that size in *pcbContainer. /// /// /// /// A pointer to a null-terminated string that contains a valid path for the new container on a log volume. /// /// Reserved. Set pReserved to NULL. /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero. To get extended error information, call GetLastError. /// The following list identifies the possible error codes: /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-addlogcontainer CLFSUSER_API BOOL AddLogContainer( [in] HANDLE // hLog, [in, optional] PULONGLONG pcbContainer, [in] LPWSTR pwszContainerPath, [in, out, optional] LPVOID pReserved ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.AddLogContainer")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool AddLogContainer([In] HLOG hLog, in ulong pcbContainer, [MarshalAs(UnmanagedType.LPWStr)] string pwszContainerPath, [In, Out, Optional] IntPtr pReserved); /// /// /// Adds a container to the physical log that is associated with the log handle—if the calling process has write access to the .blf file /// and the ability to create files in the target directory of the container. /// /// /// This function is different from AddLogContainerSet, because it adds only one container. To add multiple containers, it is more /// efficient to use AddLogContainerSet, which allows you to add more than one container. Adding containers allows a client to /// increase the size of a log. /// /// /// /// The handle to an open log. /// /// The handle must be obtained from CreateLogFile with write access to the log. The client application must have write access to the /// .blf file, and the ability to create files in the target directory of a container. /// /// /// /// The optional parameter that specifies the size of the container, in bytes. /// The minimum size is 512 KB for normal logs and 1024 KB for multiplexed logs. The maximum size is approximately 4 gigabytes. /// /// This parameter is required if the containers are being added to a newly created log. If a container is already created, this /// parameter can be NULL, or some value that is at least as large as the size of the first container. /// /// /// Log container sizes are multiples of the log region size (512 KB). When you add a container to a new file, the AddLogContainer /// function rounds the size of the container up to the next 512 KB boundary, and returns that size in the value pointed to by pcbContainer. /// /// /// Similarly, if the log already has at least one container and the value of *pcbContainer is at least as large as the current /// container size, the function creates all containers with the current internal size and returns that size in *pcbContainer. /// /// /// /// A pointer to a null-terminated string that contains a valid path for the new container on a log volume. /// /// Reserved. Set pReserved to NULL. /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero. To get extended error information, call GetLastError. /// The following list identifies the possible error codes: /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-addlogcontainer CLFSUSER_API BOOL AddLogContainer( [in] HANDLE // hLog, [in, optional] PULONGLONG pcbContainer, [in] LPWSTR pwszContainerPath, [in, out, optional] LPVOID pReserved ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.AddLogContainer")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool AddLogContainer([In] HLOG hLog, [In, Optional] IntPtr pcbContainer, [MarshalAs(UnmanagedType.LPWStr)] string pwszContainerPath, [In, Out, Optional] IntPtr pReserved); /// /// Adds multiple log containers to the physical log that is associated with the log handle—if the calling process has access to the log /// handle. Adding containers allows a client to increase the size of a log. /// /// /// The handle to an open log that is obtained from CreateLogFile with permissions to add a log container. /// The file can be dedicated or multiplexed. /// /// /// The number of containers in the rgwszContainerPath array. /// This value must be nonzero. A log must have at least two containers before any I/O can be performed on it. /// /// /// The size of the container, in bytes. /// /// The minimum size is 512 KB for normal logs and 1024 KB for multiplexed logs. The maximum size is approximately 4 gigabytes (GB). /// /// /// This parameter is required if the containers are being added to a newly created log. If a container is already created, this /// parameter can be NULL, or some value that is at least as large as the size of the first container. /// /// /// Log container sizes are multiples of the log region size (512 KB). When you add a container to a new file, the AddLogContainer /// function rounds the size of the container up to the next 512 KB boundary, and returns that size in the value pointed to by pcbContainer. /// /// /// Similarly, if the log already has at least one container and the value of *pcbContainer is at least as large as the current /// container size, the function creates all containers with the current internal size and returns that size in *pcbContainer. /// /// /// /// An array of cContainer path names for containers. /// Each element in the array is a wide-character string that contains a valid path for the new container in the log volume. /// /// Reserved. Set Reserved to NULL. /// /// If the function succeeds, the return value is nonzero, which indicates that all containers are added successfully to the log. /// /// If the function fails, the return value is zero, which indicates that none of the containers are added. To get extended error /// information, call GetLastError. /// /// The following list identifies the possible error codes: /// /// /// /// The AddLogContainerSet function is not atomic. If the operation is interrupted, for example, by an invalid path name, the call /// to AddLogContainerSet returns a failure, but some containers may have been created. Your application must recover from this /// error, for example, by determining which containers were added. /// /// /// Because AddLogContainerSet adds more than one container, it is more efficient than making repeated calls to AddLogContainer, /// which only adds one container. /// /// Containers are created and opened in a noncompressed mode, and are initialized with 0 (zeros) when they are created. /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-addlogcontainerset CLFSUSER_API BOOL AddLogContainerSet( [in] // HANDLE hLog, [in] USHORT cContainer, [in, optional] PULONGLONG pcbContainer, [in] LPWSTR *rgwszContainerPath, [in, out, optional] // LPVOID pReserved ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.AddLogContainerSet")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool AddLogContainerSet([In] HLOG hLog, [In] ushort cContainer, in ulong pcbContainer, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 1)] string[] rgwszContainerPath, [In, Out, Optional] IntPtr pReserved); /// Advances the base log sequence number (LSN) of a log stream to the specified LSN. /// A pointer to the marshaling context that a successful call to CreateLogMarshallingArea returns. /// /// The new base LSN for the log that is specified in pvMarshal. /// This LSN must be in the range between the current base LSN and the last LSN of the log, inclusively. /// /// This parameter is not implemented at this time, and must be zero. /// /// A pointer to an OVERLAPPED structure that is required for asynchronous operation. /// If asynchronous operation is not used, this parameter can be NULL. /// /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero. To get extended error information, call GetLastError. /// The following list identifies the possible error codes: /// /// AdvanceLogBase might flush data and metadata when it is called. // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-advancelogbase CLFSUSER_API BOOL AdvanceLogBase( [in, out] PVOID // pvMarshal, [in] PCLFS_LSN plsnBase, [in] ULONG fFlags, [in, out, optional] LPOVERLAPPED pOverlapped ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.AdvanceLogBase")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool AdvanceLogBase([In, Out] IntPtr pvMarshal, in CLS_LSN plsnBase, [In, Optional] uint fFlags, ref NativeOverlapped pOverlapped); /// Advances the base log sequence number (LSN) of a log stream to the specified LSN. /// A pointer to the marshaling context that a successful call to CreateLogMarshallingArea returns. /// /// The new base LSN for the log that is specified in pvMarshal. /// This LSN must be in the range between the current base LSN and the last LSN of the log, inclusively. /// /// This parameter is not implemented at this time, and must be zero. /// /// A pointer to an OVERLAPPED structure that is required for asynchronous operation. /// If asynchronous operation is not used, this parameter can be NULL. /// /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero. To get extended error information, call GetLastError. /// The following list identifies the possible error codes: /// /// AdvanceLogBase might flush data and metadata when it is called. // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-advancelogbase CLFSUSER_API BOOL AdvanceLogBase( [in, out] PVOID // pvMarshal, [in] PCLFS_LSN plsnBase, [in] ULONG fFlags, [in, out, optional] LPOVERLAPPED pOverlapped ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.AdvanceLogBase")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool AdvanceLogBase([In, Out] IntPtr pvMarshal, in CLS_LSN plsnBase, [In, Optional] uint fFlags, [In, Optional] IntPtr pOverlapped); /// /// Calculates the sector-aligned reservation size for a set of reserved records. This value is then passed to AllocReservedLog to /// reserve a block of log space for a set of records. /// /// A pointer to the opaque marshaling context that is allocated by calling the CreateLogMarshallingArea function. /// The number of reserved records that are associated with the reservation adjustment. /// /// An array of space allocations to reserve in the log that is associated with the current marshaling context, in bytes. /// /// The number of allocations corresponds to the number of records that cReservedRecords specifies. Each allocation must be /// greater than zero (0) or the function fails with ERROR_INVALID_PARAMETER. /// /// /// /// /// A pointer to a variable in which the function returns the number of sector-aligned byte space to be reserved in the log—after being /// given the number of records that cRecords specifies and the size of reservations specified in the rgcbReservation array. /// /// /// The value returned in *pcbAlignReservation is used as input to AllocReservedLog. If AllocReservedLog succeeds, this /// value is always greater than zero (0). If AllocReservedLog fails, the value is zero (0). /// /// /// /// If the function succeeds, the return value is nonzero. /// /// If the function fails, the return value is zero (0). To get extended error information, call GetLastError. The following list /// identifies the possible error codes: /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-alignreservedlog CLFSUSER_API BOOL AlignReservedLog( [in, out] // PVOID pvMarshal, [in] ULONG cReservedRecords, [in] LONGLONG [] rgcbReservation, [out] PLONGLONG pcbAlignReservation ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.AlignReservedLog")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool AlignReservedLog([In, Out] IntPtr pvMarshal, [In] uint cReservedRecords, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] long[] rgcbReservation, out long pcbAlignReservation); /// /// Allocates sector-aligned space for a set of reserved records. The requested allocation must be the same size that AlignReservedLog returns. /// /// A pointer to the marshaling context that is allocated by calling the CreateLogMarshallingArea function. /// /// The number of reserved records that are associated with the reservation adjustment. /// This value must be greater than zero (0). /// /// /// /// The size of the sector-aligned space reservation that is associated with the number of records specified in cReservedRecords, /// in bytes. /// /// This parameter must be the aligned reservation size that AlignReservedLog returns in *pcbAlignReservation. /// /// /// If the function succeeds, the return value is nonzero. /// /// If the function fails, the return value is zero (0). To get extended error information, call GetLastError. The following list /// identifies the possible error codes: /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-allocreservedlog CLFSUSER_API BOOL AllocReservedLog( [in, out] // PVOID pvMarshal, [in] ULONG cReservedRecords, [in, out] PLONGLONG pcbAdjustment ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.AllocReservedLog")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool AllocReservedLog([In, Out] IntPtr pvMarshal, [In] uint cReservedRecords, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] long[] pcbAdjustment); /// /// Resets the log file and then shuts the log. This nullifies any client restart areas and resets the base log sequence number (LSN) for /// the log. You do not need to close a log stream handle after calling this function. /// /// /// A handle to a dedicated or multiplexed log. /// /// This handle is returned by a successful call to CreateLogFile. It is invalidated on successful completion of the call. No other /// operations that use this handle, or a derivative of this handle, can be called after this function has returned. /// /// /// /// If the function succeeds, the return value is nonzero. /// /// If the function fails, the return value is zero (0). To get extended error information, call GetLastError. The following list /// identifies the possible error codes: /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-closeandresetlogfile CLFSUSER_API BOOL CloseAndResetLogFile( // [in] HANDLE hLog ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.CloseAndResetLogFile")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool CloseAndResetLogFile([In] HLOG hLog); /// /// Creates a scan context to use with ScanLogContainers to enumerate all log containers that are associated with a log, and performs the /// first scan. /// /// /// A handle to the log that is obtained from CreateLogFile with permissions to scan the log containers. /// The file can be a dedicated or multiplexed log. /// /// /// The container where the scan is to be started. /// This parameter is an ordinal number relative to the number of containers in the log. /// /// /// The number of CLFS_CONTAINER_INFORMATION structures for CreateLogContainerScanContext to allocate. /// /// This number is the number of containers scanned with each scan call so the caller knows the scan is complete when the number of /// containers returned is less than this value. /// /// /// On exit, a pointer to the system-allocated array of CLFS_CONTAINER_INFORMATION structures is placed in the pinfoContainer /// member of the client-allocated CLFS_SCAN_CONTEXT structure. This member is pointed to by the pcxScan parameter (that is, /// "pcxScan->pinfoContainer[]"), and the actual number of structures in the array is placed in "pcxScan->cContainersReturned". /// /// /// The client must call ScanLogContainers with the eScanMode parameter set to CLFS_SCAN_CLOSE so that it can free this /// array; otherwise, memory leaks result. /// /// /// /// The mode to scan containers. /// Containers can be scanned in any one of the following modes. /// /// /// Value /// Meaning /// /// /// CLFS_SCAN_INIT /// /// Initializes or reinitializes a scan from the first container in the container list. This mode initializes the container context and /// returns the first set of container descriptors that cContainers specifies. /// /// /// /// CLFS_SCAN_FORWARD /// Returns the first set of containers that cContainers specifies. /// /// /// CLFS_SCAN_BACKWARD /// Returns the last set of containers that cContainers specifies. /// /// /// /// /// A pointer to a client-allocated CLFS_SCAN_CONTEXT structure that receives a scan context that can be passed to the ScanLogContainers /// function when a client scans the log containers of a dedicated log. /// /// /// A pointer to an OVERLAPPED structure that is required for asynchronous operation. /// This parameter can be NULL if an asynchronous operation is not used. /// /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero. To get extended error information, call GetLastError. /// The following list identifies the possible error codes: /// /// /// /// After completing a scan, the client must call ScanLogContainers again with the eScanMode parameter set to /// CLFS_SCAN_CLOSE so that it can free the system-allocated array of CLFS_CONTAINER_INFORMATION structures; otherwise, memory /// leaks result. /// /// Examples /// For an example that uses this function, see Enumerating Log Containers. /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-createlogcontainerscancontext CLFSUSER_API BOOL // CreateLogContainerScanContext( [in] HANDLE hLog, [in] ULONG cFromContainer, [in] ULONG cContainers, [in] CLFS_SCAN_MODE eScanMode, // [in, out] PCLFS_SCAN_CONTEXT pcxScan, [in, out, optional] LPOVERLAPPED pOverlapped ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.CreateLogContainerScanContext")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool CreateLogContainerScanContext([In] HLOG hLog, [In] uint cFromContainer, [In] uint cContainers, [In] CLFS_SCAN_MODE eScanMode, ref CLS_SCAN_CONTEXT pcxScan, ref NativeOverlapped pOverlapped); /// /// Creates a scan context to use with ScanLogContainers to enumerate all log containers that are associated with a log, and performs the /// first scan. /// /// /// A handle to the log that is obtained from CreateLogFile with permissions to scan the log containers. /// The file can be a dedicated or multiplexed log. /// /// /// The container where the scan is to be started. /// This parameter is an ordinal number relative to the number of containers in the log. /// /// /// The number of CLFS_CONTAINER_INFORMATION structures for CreateLogContainerScanContext to allocate. /// /// This number is the number of containers scanned with each scan call so the caller knows the scan is complete when the number of /// containers returned is less than this value. /// /// /// On exit, a pointer to the system-allocated array of CLFS_CONTAINER_INFORMATION structures is placed in the pinfoContainer /// member of the client-allocated CLFS_SCAN_CONTEXT structure. This member is pointed to by the pcxScan parameter (that is, /// "pcxScan->pinfoContainer[]"), and the actual number of structures in the array is placed in "pcxScan->cContainersReturned". /// /// /// The client must call ScanLogContainers with the eScanMode parameter set to CLFS_SCAN_CLOSE so that it can free this /// array; otherwise, memory leaks result. /// /// /// /// The mode to scan containers. /// Containers can be scanned in any one of the following modes. /// /// /// Value /// Meaning /// /// /// CLFS_SCAN_INIT /// /// Initializes or reinitializes a scan from the first container in the container list. This mode initializes the container context and /// returns the first set of container descriptors that cContainers specifies. /// /// /// /// CLFS_SCAN_FORWARD /// Returns the first set of containers that cContainers specifies. /// /// /// CLFS_SCAN_BACKWARD /// Returns the last set of containers that cContainers specifies. /// /// /// /// /// A pointer to a client-allocated CLFS_SCAN_CONTEXT structure that receives a scan context that can be passed to the ScanLogContainers /// function when a client scans the log containers of a dedicated log. /// /// /// A pointer to an OVERLAPPED structure that is required for asynchronous operation. /// This parameter can be NULL if an asynchronous operation is not used. /// /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero. To get extended error information, call GetLastError. /// The following list identifies the possible error codes: /// /// /// /// After completing a scan, the client must call ScanLogContainers again with the eScanMode parameter set to /// CLFS_SCAN_CLOSE so that it can free the system-allocated array of CLFS_CONTAINER_INFORMATION structures; otherwise, memory /// leaks result. /// /// Examples /// For an example that uses this function, see Enumerating Log Containers. /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-createlogcontainerscancontext CLFSUSER_API BOOL // CreateLogContainerScanContext( [in] HANDLE hLog, [in] ULONG cFromContainer, [in] ULONG cContainers, [in] CLFS_SCAN_MODE eScanMode, // [in, out] PCLFS_SCAN_CONTEXT pcxScan, [in, out, optional] LPOVERLAPPED pOverlapped ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.CreateLogContainerScanContext")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool CreateLogContainerScanContext([In] HLOG hLog, [In] uint cFromContainer, [In] uint cContainers, [In] CLFS_SCAN_MODE eScanMode, ref CLS_SCAN_CONTEXT pcxScan, [In, Optional] IntPtr pOverlapped); /// /// Creates or opens a log. The log can be dedicated or multiplexed, and that depends on the log name. Use the CloseHandle function to /// close the log. /// /// /// The name of the log. /// /// This name is specified when creating the log by using CreateLogFile. The following example identifies the format to use. /// /// log :<LogName>[::<LogStreamName>] /// /// For example: The path "LOG:c:\MyDirectory\MyLog" creates the file "c:\MyDirectory\MyLog.blf". The path /// "??\LOG:\HarddiskVolume1\MyDirectory\MyLog" creates the file "\.\HarddiskVolume1\MyDirectory\MyLog.blf", as does the path "\clfs\Device\HarddiskVolume1\MyDirectory\MyLog". /// /// /// < LogName> corresponds to a valid file path in the file system, and < LogStreamName> is the unique name of /// a log stream in the log. For more information, see Log Types. /// /// /// /// The type of access that the returned handle has to the log object. /// /// /// Value /// Meaning /// /// /// GENERIC_READ /// Specifies read access to the object. /// /// /// GENERIC_WRITE /// Specifies write access to the object. /// /// /// DELETE /// Specify log deletion access /// /// /// A bitwise OR of two or more of these flags allows combinations of read, write, and delete access to the object. /// Windows Server 2003 R2: /// This parameter must be set to /// GENERIC_WRITE /// . /// /// /// The sharing mode of a file. /// /// A client cannot request a sharing mode that conflicts with any mode that is specified in any previous open request that has an open handle. /// /// /// If this parameter is zero and the function succeeds, the object cannot be shared and cannot be opened again until the handle is closed. /// /// This parameter can be one or more of the following values. /// /// /// Value /// Meaning /// /// /// FILE_SHARE_DELETE /// /// Enables open operations on the object to request delete access. Without this value, other processes cannot open the object if delete /// access is requested. /// /// /// /// FILE_SHARE_READ /// /// Enables open operations on the object to request read access. Without this value, other processes cannot open the object if read /// access is requested. /// /// /// /// FILE_SHARE_WRITE /// /// Enables open operations on the object to request write access. Without this value, other processes cannot open the object if write /// access is requested. /// /// /// /// /// /// A pointer to a SECURITY_ATTRIBUTES structure that specifies the security attributes of a log. /// /// It determines whether the returned handle can be inherited by child processes. If this parameter is NULL, the handle cannot be inherited. /// /// /// The lpSecurityDescriptor member of SECURITY_ATTRIBUTES specifies a security descriptor for the new log handle. If /// psaLogFile is NULL, the object gets a default security descriptor. The access control lists (ACL) in the default /// security descriptor for a log come from the primary or impersonation token of the creator. /// /// /// /// An action to be taken. /// This parameter can be one of the following values. /// /// /// Value /// Meaning /// /// /// CREATE_NEW /// Creates a new file and fails if the file already exists. /// /// /// OPEN_EXISTING /// Opens an existing file and fails if the file does not exist. /// /// /// OPEN_ALWAYS /// Opens an existing file or creates the file if it does not exist. /// /// /// /// /// The file attributes and flags for the file. /// This parameter can take the following values. /// /// /// Value /// Meaning /// /// /// FILE_ATTRIBUTE_ARCHIVE /// /// This non-ephemeral log should be archived. If this flag is not supplied, the log does not need to be archived, and an archival tail /// is not maintained for recycling log containers. /// /// /// /// FILE_FLAG_OVERLAPPED /// /// If the FILE_FLAG_OVERLAPPED flag is set, all other flag values are ignored. Specifying FILE_FLAG_OVERLAPPED means that /// a file is opened for overlapped I/O, which enables more than one I/O operation to be performed on the log handle. If this flag is set /// when creating a log, all asynchronous I/O calls to that log must specify an overlapped structure and synchronize with the deferred /// completion of the call. /// /// /// /// /// /// If the function succeeds, the return value is a handle to the log. /// If the function fails, the return value is INVALID_HANDLE_VALUE. To get extended error information, call GetLastError. /// The following list identifies the possible error codes: /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-createlogfile CLFSUSER_API HANDLE CreateLogFile( [in] LPCWSTR // pszLogFileName, [in] ACCESS_MASK fDesiredAccess, [in] DWORD dwShareMode, [in, optional] LPSECURITY_ATTRIBUTES psaLogFile, [in] ULONG // fCreateDisposition, [in] ULONG fFlagsAndAttributes ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.CreateLogFile")] public static extern SafeHLOG CreateLogFile([MarshalAs(UnmanagedType.LPWStr)] string pszLogFileName, [In] ACCESS_MASK fDesiredAccess, [In] System.IO.FileShare dwShareMode, [In, Optional] SECURITY_ATTRIBUTES psaLogFile, [In] CreationOption fCreateDisposition, [In] FileFlagsAndAttributes fFlagsAndAttributes); /// /// /// Creates a marshaling area for a log, and when successful it returns a marshaling context. Before creating a marshaling area, the log /// must have at least one container. /// /// /// The marshaling context is used to append records to or read records from a log. Because records are always stored in log blocks, they /// must pass through the marshaling context. /// /// Log records are written by calling ReserveAndAppendLog. /// /// /// A handle to the log that is obtained from CreateLogFile. /// The log handle can refer to a dedicated or multiplexed log. /// /// /// The callback function that allocates memory for log blocks. /// /// If this parameter is NULL, the Common Log File System (CLFS) provides a default block allocation function. This parameter /// cannot be NULL if a block-freeing callback is specified by using the pfnFreeBuffer parameter. /// /// The following example identifies the syntax of the block allocation callback function: /// /// /// The callback function that frees log blocks allocated by pfnAllocBuffer. /// /// If this parameter is NULL, CLFS provides a default block deallocation function. This parameter cannot be NULL if a /// block allocation callback is specified by using the pfnAllocBuffer parameter. /// /// The following example identifies the syntax of the block-freeing callback function: /// /// /// /// A pointer to a buffer that is passed back as a user context to the block allocation and deallocation routines, if a buffer is specified. /// /// If pfnAllocBuffer is NULL, this parameter is ignored. /// /// /// /// The size, in bytes, of the individual log I/O blocks that will be used by the new marshaling area. This must be a multiple of the /// sector size on the stable storage medium. The sector size is the value returned in the lpBytesPerSector parameter of the /// GetDiskFreeSpace function. /// /// Records cannot be appended or read if they are longer than this value. /// /// /// The maximum number of blocks that can be allocated at any time for write operations. /// /// This value can affect the frequency of data flushes. If you do not need to specify a limit to control the frequency of the data flush /// cycle, specify INFINITE. /// /// /// /// The maximum number of blocks that can be allocated at any time for read operations. /// Read contexts use at least one read block. /// /// /// A pointer to the marshaling context that CLFS allocates when CreateLogMarshallingArea completes successfully. /// /// This context must be used with all read, append, write, and flush operations to log marshaling areas. All operations that access /// marshaling areas by using a marshaling context are thread-safe. This parameter is NULL if the operation is not successful. /// /// /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero. To get extended error information, call GetLastError. /// The following list identifies the possible error codes: /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-createlogmarshallingarea CLFSUSER_API BOOL // CreateLogMarshallingArea( [in] HANDLE hLog, [in, optional] CLFS_BLOCK_ALLOCATION pfnAllocBuffer, [in, optional] // CLFS_BLOCK_DEALLOCATION pfnFreeBuffer, [in, optional] PVOID pvBlockAllocContext, [in] ULONG cbMarshallingBuffer, [in] ULONG // cMaxWriteBuffers, [in] ULONG cMaxReadBuffers, [out] PVOID *ppvMarshal ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.CreateLogMarshallingArea")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool CreateLogMarshallingArea([In] HLOG hLog, [In, Optional] CLFS_BLOCK_ALLOCATION pfnAllocBuffer, [In, Optional] CLFS_BLOCK_DEALLOCATION pfnFreeBuffer, [In, Optional] IntPtr pvBlockAllocContext, [In] uint cbMarshallingBuffer, [In] uint cMaxWriteBuffers, [In] uint cMaxReadBuffers, out IntPtr ppvMarshal); /// /// /// Marks the specified log for deletion. The log is actually deleted when all handles, marshaling areas, and read contexts to the log /// are closed. If the log is a physical log, its underlying containers are deleted. /// /// When a log is marked for deletion, requests to open new client log streams fail. /// /// Note This function differs from DeleteLogFile, because it takes a valid open handle to the log object instead of the log name. /// /// /// /// A handle to an open log that is obtained by a successful call to CreateLogFile. The log must have been created with DELETE access or /// you cannot delete the log. /// /// /// If the function succeeds, the return value is nonzero. /// /// If the function fails, the return value is zero (0). To get extended error information, call GetLastError. The following list /// identifies the possible error codes: /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-deletelogbyhandle CLFSUSER_API BOOL DeleteLogByHandle( [in] // HANDLE hLog ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.DeleteLogByHandle")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool DeleteLogByHandle([In] HLOG hLog); /// /// /// Marks a log for deletion. The log is actually deleted when all handles, marshaling areas, and read contexts to the log are closed. If /// the log is a physical log, its underlying containers are deleted. /// /// When a log is marked for deletion, requests to open new client log streams fail. /// /// /// The name of the log. /// This name is specified when creating the log by using CreateLogFile. The following example identifies the format to use: /// log:<log name>[::<log stream name>] /// < log name> corresponds to a valid file path in the file system. /// < log stream name> is the unique name of a log stream in the log. /// For more information, see Log Types. /// /// This parameter is reserved and should be set to NULL. /// /// If the function succeeds, the return value is nonzero. /// /// If the function fails, the return value is zero (0). To get extended error information, call GetLastError. The following list /// identifies the possible error codes: /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-deletelogfile CLFSUSER_API BOOL DeleteLogFile( [in] LPCWSTR // pszLogFileName, [in, optional] PVOID pvReserved ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.DeleteLogFile")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool DeleteLogFile([MarshalAs(UnmanagedType.LPWStr)] string pszLogFileName, [In, Optional] IntPtr pvReserved); /// /// Deletes a marshaling area that is created by a successful call to CreateLogMarshallingArea. /// When you delete a marshaling area it does the following: /// /// /// Flushes the log to free pending log I/O blocks /// /// /// Deallocates all log I/O blocks and invalidates all read contexts /// /// /// /// The memory allocated by Common Log File System (CLFS) to create the marshaling context is reclaimed when all read contexts are terminated. /// /// Note Clients should not delete a marshaling area if there are pending operations on the marshaling area. /// /// A pointer to the opaque marshaling context allocated by using the CreateLogMarshallingArea function. /// /// If the function succeeds, the return value is nonzero. /// /// If the function fails, the return value is zero (0). To get extended error information, call GetLastError. The following list /// identifies the possible error codes: /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-deletelogmarshallingarea CLFSUSER_API BOOL // DeleteLogMarshallingArea( [in] PVOID pvMarshal ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.DeleteLogMarshallingArea")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool DeleteLogMarshallingArea([In] IntPtr pvMarshal); /// /// Scans a specified log; filters log records based on record type; and places the records in an output file stream that the caller opens. /// /// /// The name of the log stream. /// This name is specified when you create the log by using CreateLogFile. The following example identifies the format to use: /// log:<log name>[::<log stream name>] /// < log name> corresponds to a valid file path in the file system. /// < log stream name> is the unique name of a log stream in the log. /// For more information, see Log Types. /// /// /// The type of records to be read. /// This parameter can be one or more of the following CLFS_RECORD_TYPE Constants. /// /// /// Value /// Meaning /// /// /// ClfsNullRecord /// The default record type of ClfsDataRecord is used. /// /// /// ClfsDataRecord /// User data records are read. /// /// /// ClfsRestartRecord /// Restart records are read. /// /// /// ClfsClientRecord /// Both restart and data records are read. /// /// /// ClfsClientRecord /// Specifies a mask for all valid data or restart records. /// /// /// /// /// A pointer to a CLFS_LSN that specifies the starting log sequence number (LSN) for the log dump sequence. /// /// If this parameter is specified, the LSN must be the address of a valid log record in the active part of the log; otherwise, the call /// fails with status ERROR_INVALID_PARAMETER. /// /// If this parameter is not specified, the start of the dump sequence is the beginning of the active log. /// /// /// A pointer to a CLFS_LSN that specifies the LSN where the dump sequence should end. /// If this LSN is past the end of the LSN range, the function returns ERROR_HANDLE_EOF. /// /// Unlike plsnStart, this value does not have to be the LSN of a valid record in the active log, but can be any valid LSN. Only /// records with an LSN value less than or equal to plsnEnd are placed in the output stream. /// /// If this parameter is NULL, the dump function uses the last LSN in the active log (at the head of the log). /// /// /// A pointer to an open output stream where the log records are placed. /// If this parameter is not specified, "stdout" is used as the default. /// /// /// A user-defined callback routine that formats user-defined buffers and prints them to the output stream pstrmOut. /// /// The DumpLogRecords function natively outputs its internal record headers to pstrmOut, but depends on the user-defined /// callback to format the user buffers. /// /// If this parameter is NULL, DumpLogRecords places user record data in the output stream as hexadecimal digits. /// /// /// A callback function that allocates memory for log blocks. /// /// If this parameter is NULL, Common Log File System (CLFS) provides a default block allocation function. This parameter cannot /// be NULL if a block-freeing callback is specified by using the pfnFreeBuffer parameter. /// /// The following example identifies the syntax of the block allocation callback function: /// /// /// A callback function that frees log blocks allocated by pfnAllocBuffer. /// /// If this parameter is NULL, CLFS provides a default block deallocation function. This parameter cannot be NULL if a /// block allocation callback is specified by using the pfnAllocBuffer parameter. /// /// The following example identifies the syntax of the block-freeing callback function: /// /// /// A pointer to a buffer that is passed as a user context to the block allocation and deallocation routines, if a buffer is specified. /// If pfnAllocBuffer is NULL, this parameter is ignored. /// /// /// The size of the buffer that your records are marshaled into, in bytes. /// Records cannot be appended or read if they are longer than this value. /// /// /// The maximum number of blocks that can be allocated at any time for read operations. /// Read contexts use at least one read block. /// /// /// If the function succeeds, the return value is nonzero. /// /// If the function fails, the return value is zero (0). To get extended error information, call GetLastError. The following list /// identifies the possible error codes: /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-dumplogrecords CLFSUSER_API BOOL DumpLogRecords( [in] PWSTR // pwszLogFileName, [in] CLFS_RECORD_TYPE fRecordType, [in, optional] PCLFS_LSN plsnStart, [in, optional] PCLFS_LSN plsnEnd, [in, // optional] PFILE pstrmOut, [in, optional] CLFS_PRINT_RECORD_ROUTINE pfnPrintRecord, [in, optional] CLFS_BLOCK_ALLOCATION pfnAllocBlock, // [in, optional] CLFS_BLOCK_DEALLOCATION pfnFreeBlock, [in, optional] PVOID pvBlockAllocContext, [in] ULONG cbBlock, [in] ULONG // cMaxBlocks ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.DumpLogRecords")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool DumpLogRecords([MarshalAs(UnmanagedType.LPWStr)] string pwszLogFileName, [In] CLS_RECORD_TYPE fRecordType, in CLS_LSN plsnStart, in CLS_LSN plsnEnd, [In, Optional] HFILE pstrmOut, [In, Optional] CLFS_PRINT_RECORD_ROUTINE pfnPrintRecord, [In, Optional] CLFS_BLOCK_ALLOCATION pfnAllocBlock, [In, Optional] CLFS_BLOCK_DEALLOCATION pfnFreeBlock, [In, Optional] IntPtr pvBlockAllocContext, [In] uint cbBlock, [In] uint cMaxBlocks); /// /// Scans a specified log; filters log records based on record type; and places the records in an output file stream that the caller opens. /// /// /// The name of the log stream. /// This name is specified when you create the log by using CreateLogFile. The following example identifies the format to use: /// log:<log name>[::<log stream name>] /// < log name> corresponds to a valid file path in the file system. /// < log stream name> is the unique name of a log stream in the log. /// For more information, see Log Types. /// /// /// The type of records to be read. /// This parameter can be one or more of the following CLFS_RECORD_TYPE Constants. /// /// /// Value /// Meaning /// /// /// ClfsNullRecord /// The default record type of ClfsDataRecord is used. /// /// /// ClfsDataRecord /// User data records are read. /// /// /// ClfsRestartRecord /// Restart records are read. /// /// /// ClfsClientRecord /// Both restart and data records are read. /// /// /// ClfsClientRecord /// Specifies a mask for all valid data or restart records. /// /// /// /// /// A pointer to a CLFS_LSN that specifies the starting log sequence number (LSN) for the log dump sequence. /// /// If this parameter is specified, the LSN must be the address of a valid log record in the active part of the log; otherwise, the call /// fails with status ERROR_INVALID_PARAMETER. /// /// If this parameter is not specified, the start of the dump sequence is the beginning of the active log. /// /// /// A pointer to a CLFS_LSN that specifies the LSN where the dump sequence should end. /// If this LSN is past the end of the LSN range, the function returns ERROR_HANDLE_EOF. /// /// Unlike plsnStart, this value does not have to be the LSN of a valid record in the active log, but can be any valid LSN. Only /// records with an LSN value less than or equal to plsnEnd are placed in the output stream. /// /// If this parameter is NULL, the dump function uses the last LSN in the active log (at the head of the log). /// /// /// A pointer to an open output stream where the log records are placed. /// If this parameter is not specified, "stdout" is used as the default. /// /// /// A user-defined callback routine that formats user-defined buffers and prints them to the output stream pstrmOut. /// /// The DumpLogRecords function natively outputs its internal record headers to pstrmOut, but depends on the user-defined /// callback to format the user buffers. /// /// If this parameter is NULL, DumpLogRecords places user record data in the output stream as hexadecimal digits. /// /// /// A callback function that allocates memory for log blocks. /// /// If this parameter is NULL, Common Log File System (CLFS) provides a default block allocation function. This parameter cannot /// be NULL if a block-freeing callback is specified by using the pfnFreeBuffer parameter. /// /// The following example identifies the syntax of the block allocation callback function: /// /// /// A callback function that frees log blocks allocated by pfnAllocBuffer. /// /// If this parameter is NULL, CLFS provides a default block deallocation function. This parameter cannot be NULL if a /// block allocation callback is specified by using the pfnAllocBuffer parameter. /// /// The following example identifies the syntax of the block-freeing callback function: /// /// /// A pointer to a buffer that is passed as a user context to the block allocation and deallocation routines, if a buffer is specified. /// If pfnAllocBuffer is NULL, this parameter is ignored. /// /// /// The size of the buffer that your records are marshaled into, in bytes. /// Records cannot be appended or read if they are longer than this value. /// /// /// The maximum number of blocks that can be allocated at any time for read operations. /// Read contexts use at least one read block. /// /// /// If the function succeeds, the return value is nonzero. /// /// If the function fails, the return value is zero (0). To get extended error information, call GetLastError. The following list /// identifies the possible error codes: /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-dumplogrecords CLFSUSER_API BOOL DumpLogRecords( [in] PWSTR // pwszLogFileName, [in] CLFS_RECORD_TYPE fRecordType, [in, optional] PCLFS_LSN plsnStart, [in, optional] PCLFS_LSN plsnEnd, [in, // optional] PFILE pstrmOut, [in, optional] CLFS_PRINT_RECORD_ROUTINE pfnPrintRecord, [in, optional] CLFS_BLOCK_ALLOCATION pfnAllocBlock, // [in, optional] CLFS_BLOCK_DEALLOCATION pfnFreeBlock, [in, optional] PVOID pvBlockAllocContext, [in] ULONG cbBlock, [in] ULONG // cMaxBlocks ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.DumpLogRecords")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool DumpLogRecords([MarshalAs(UnmanagedType.LPWStr)] string pwszLogFileName, [In] CLS_RECORD_TYPE fRecordType, [In, Optional] IntPtr plsnStart, [In, Optional] IntPtr plsnEnd, [In, Optional] HFILE pstrmOut, [In, Optional] CLFS_PRINT_RECORD_ROUTINE pfnPrintRecord, [In, Optional] CLFS_BLOCK_ALLOCATION pfnAllocBlock, [In, Optional] CLFS_BLOCK_DEALLOCATION pfnFreeBlock, [In, Optional] IntPtr pvBlockAllocContext, [In] uint cbBlock, [In] uint cMaxBlocks); /// /// Forces all records appended to this marshaling area to be flushed to disk. This service is a special case of FlushLogToLsn with the /// target log sequence number (LSN) set to CLFS_LSN_NULL. /// /// A pointer to the marshaling context that is allocated by using the CreateLogMarshallingArea function. /// /// A pointer to an OVERLAPPED structure that is required for asynchronous operation. /// This parameter can be NULL if asynchronous operation is not used. /// /// /// If the function succeeds, the return value is nonzero. /// /// If the function fails, the return value is zero (0). To get extended error information, call GetLastError. The following list /// identifies the possible error codes: /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-flushlogbuffers CLFSUSER_API BOOL FlushLogBuffers( [in] PVOID // pvMarshal, [in, out, optional] LPOVERLAPPED pOverlapped ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.FlushLogBuffers")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool FlushLogBuffers([In] IntPtr pvMarshal, ref NativeOverlapped pOverlapped); /// /// Forces all records appended to this marshaling area to be flushed to disk. This service is a special case of FlushLogToLsn with the /// target log sequence number (LSN) set to CLFS_LSN_NULL. /// /// A pointer to the marshaling context that is allocated by using the CreateLogMarshallingArea function. /// /// A pointer to an OVERLAPPED structure that is required for asynchronous operation. /// This parameter can be NULL if asynchronous operation is not used. /// /// /// If the function succeeds, the return value is nonzero. /// /// If the function fails, the return value is zero (0). To get extended error information, call GetLastError. The following list /// identifies the possible error codes: /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-flushlogbuffers CLFSUSER_API BOOL FlushLogBuffers( [in] PVOID // pvMarshal, [in, out, optional] LPOVERLAPPED pOverlapped ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.FlushLogBuffers")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool FlushLogBuffers([In] IntPtr pvMarshal, [In, Optional] IntPtr pOverlapped); /// /// Forces all records appended to this marshaling area up to the record with the specified log sequence number (LSN) to be flushed to /// the disk. More records than specified may be flushed during this operation. /// /// A pointer to the marshaling context that is allocated by using the CreateLogMarshallingArea function. /// /// A pointer to a CLFS_LSN structure that specifies the LSN that is used to determine which records to flush. /// Specify CLFS_LSN_NULL to flush all records in the marshaling area. /// /// /// A pointer to a CLFS_LSN structure. /// /// The LSN returned is greater than the LSN of any record flushed. If the function succeeds, the value of the LSN is never less than /// plsnFlush. This value is meaningful only when the function succeeds. /// /// /// /// A pointer to an OVERLAPPED structure that is required for asynchronous operation. /// This parameter can be NULL except for an asynchronous operation. /// /// /// If the function succeeds, the return value is nonzero. /// /// If the function fails, the return value is zero (0). To get extended error information, call GetLastError. The following list /// identifies the possible error codes: /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-flushlogtolsn CLFSUSER_API BOOL FlushLogToLsn( [in] PVOID // pvMarshalContext, [in] PCLFS_LSN plsnFlush, [out, optional] PCLFS_LSN plsnLastFlushed, [in, out, optional] LPOVERLAPPED pOverlapped ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.FlushLogToLsn")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool FlushLogToLsn([In] IntPtr pvMarshalContext, in CLS_LSN plsnFlush, out CLS_LSN plsnLastFlushed, ref NativeOverlapped pOverlapped); /// /// Forces all records appended to this marshaling area up to the record with the specified log sequence number (LSN) to be flushed to /// the disk. More records than specified may be flushed during this operation. /// /// A pointer to the marshaling context that is allocated by using the CreateLogMarshallingArea function. /// /// A pointer to a CLFS_LSN structure that specifies the LSN that is used to determine which records to flush. /// Specify CLFS_LSN_NULL to flush all records in the marshaling area. /// /// /// A pointer to a CLFS_LSN structure. /// /// The LSN returned is greater than the LSN of any record flushed. If the function succeeds, the value of the LSN is never less than /// plsnFlush. This value is meaningful only when the function succeeds. /// /// /// /// A pointer to an OVERLAPPED structure that is required for asynchronous operation. /// This parameter can be NULL except for an asynchronous operation. /// /// /// If the function succeeds, the return value is nonzero. /// /// If the function fails, the return value is zero (0). To get extended error information, call GetLastError. The following list /// identifies the possible error codes: /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-flushlogtolsn CLFSUSER_API BOOL FlushLogToLsn( [in] PVOID // pvMarshalContext, [in] PCLFS_LSN plsnFlush, [out, optional] PCLFS_LSN plsnLastFlushed, [in, out, optional] LPOVERLAPPED pOverlapped ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.FlushLogToLsn")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool FlushLogToLsn([In] IntPtr pvMarshalContext, in CLS_LSN plsnFlush, out CLS_LSN plsnLastFlushed, [In, Optional] IntPtr pOverlapped); /// /// Reduces the number of reserved log records in a marshaling area made by calling ReserveAndAppendLog, ReserveAndAppendLogAligned, or /// AllocReservedLog. By using this function, clients can free an aggregate set of records and bytes that are reserved in the marshaling area. /// /// A pointer to the opaque marshaling context that is allocated by using the CreateLogMarshallingArea function. /// /// The number of reserved records to be freed. /// /// If the byte count of the adjustment in pcbAdjustment is positive, cReservedRecords is the total number of reserved /// records that are remaining after the adjustment. Otherwise, this parameter specifies the number of records to be subtracted from the /// current number of reserved records, but can never exceed the reserved count. /// /// /// /// The number of bytes of reservation space affected by the adjustment. /// /// On input, if this number is positive, it specifies the total remaining size of the reserved space after the adjustment. If this /// parameter is negative, its absolute value is the number of bytes to be freed. /// /// This value is usually an aggregate of the actual reserved space that is returned in a previous call to the following: /// /// /// ReserveAndAppendLog /// /// /// ReserveAndAppendLogAligned /// /// /// AllocReservedLog /// /// /// /// /// If the function succeeds, the return value is nonzero. /// /// If the function fails, the return value is zero. To get extended error information, call GetLastError. The following list identifies /// the possible error codes: /// /// /// When you reserve records, you reserve a specific size. When you free those records, you must free the same size. // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-freereservedlog CLFSUSER_API BOOL FreeReservedLog( [in, out] // PVOID pvMarshal, [in] ULONG cReservedRecords, [in, out] PLONGLONG pcbAdjustment ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.FreeReservedLog")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool FreeReservedLog([In, Out] IntPtr pvMarshal, [In] uint cReservedRecords, ref long pcbAdjustment); /// /// Retrieves the full path name of the specified container. This function is used mainly to obtain the full path name of a container /// referenced in the CLFS_CONTAINER_INFORMATION structure that is returned in calls to ScanLogContainers. /// /// /// A handle to the log that is obtained from a successful call to CreateLogFile. /// The log handle could refer to a log stream or a physical log. /// /// The unique identifier that is associated with a container. /// /// A pointer to a user-allocated buffer to receive the full path and name of the log container, in wide characters. /// /// The size of the buffer pointed to by pwstrContainerName, in characters. /// /// A pointer to a variable to receive the actual character count of the full container path name that is retrieved. /// /// If the function succeeds, the value of this parameter is less than or equal to cLenContainerName. If the buffer is not large /// enough to store the whole container path name, the function fails with ERROR_MORE_DATA and sets this parameter to the size /// that is required for the full path name. For other failures the value is not defined. /// /// /// /// If the function succeeds, the return value is nonzero. /// /// If the function fails, the return value is zero (0). To get extended error information, call GetLastError. The following list /// identifies the possible error codes: /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-getlogcontainername CLFSUSER_API BOOL GetLogContainerName( [in] // HANDLE hLog, [in] CLFS_CONTAINER_ID cidLogicalContainer, [in, out] LPCWSTR pwstrContainerName, [in] ULONG cLenContainerName, [in, out, // optional] PULONG pcActualLenContainerName ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.GetLogContainerName")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool GetLogContainerName([In] HLOG hLog, [In] CLFS_CONTAINER_ID cidLogicalContainer, [In, Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pwstrContainerName, [In] int cLenContainerName, out uint pcActualLenContainerName); /// /// /// Returns a buffer that contains metadata about a specified log and its current state, which is defined by the CLFS_INFORMATION structure. /// /// /// Data that is obtained reflects the state of the log only at the time when the call is made. Typically, a client can continue to cache /// and use fields from this structure until the next time that it appends records or writes its restart area. At that time, some of the /// information becomes stale. /// /// /// /// A handle to an open log that is obtained from a successful call to CreateLogFile. /// The log handle can refer to a dedicated or multiplexed log. /// /// A pointer to a user-allocated CLFS_INFORMATION structure that receives the log metadata. /// /// A pointer to a variable that on input specifies the size, in bytes, of the metadata buffer pointed to by pinfoBuffer. /// On output, it specifies the number of bytes that are actually copied into pinfoBuffer. /// /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero. To get extended error information, call GetLastError. /// The following list identifies the possible error codes: /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-getlogfileinformation CLFSUSER_API BOOL GetLogFileInformation( // [in] HANDLE hLog, [in, out] PCLFS_INFORMATION pinfoBuffer, [in, out] PULONG cbBuffer ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.GetLogFileInformation")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool GetLogFileInformation([In] HLOG hLog, ref CLS_INFORMATION pinfoBuffer, ref uint cbBuffer); /// /// Retrieves log I/O statistics for a dedicated or multiplexed log that is associated with the specified handle. This function queries /// Common Log File System (CLFS) for specific types of log I/O statistics. Calling this function on a multiplexed log only associates /// the statistics with the underlying log. /// /// /// A handle to an open log file that CreateLogFile gets. The log handle can refer to either a dedicated or multiplexed log file. /// /// /// A pointer to a buffer to receive the I/O statistics. /// This buffer must be at least as large as an I/O statistics packet header. For more information, see CLFS_IO_STATISTICS_HEADER. /// /// /// The size of the I/O statistics buffer pvStatsBuffer, in bytes. /// If the buffer is not large enough for the statistics packet, the function fails with ERROR_MORE_DATA. /// /// This parameter is not implemented at this time; it is reserved for future use. /// /// A pointer to a variable to receive the size of the I/O statistics packet that is written to pvStatsBuffer. /// This value is less than or equal to cbStatsBuffer. /// /// /// If the function succeeds, the return value is nonzero. /// /// If the function fails, the return value is zero (0). To get extended error information, call GetLastError. The following list /// identifies the possible error codes: /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-getlogiostatistics CLFSUSER_API BOOL GetLogIoStatistics( [in] // HANDLE hLog, [in, out] PVOID pvStatsBuffer, [in] ULONG cbStatsBuffer, [in] CLFS_IOSTATS_CLASS eStatsClass, [out, optional] PULONG // pcbStatsWritten ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.GetLogIoStatistics")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool GetLogIoStatistics([In] HLOG hLog, [In, Out] IntPtr pvStatsBuffer, [In] uint cbStatsBuffer, [In] CLFS_IOSTATS_CLASS eStatsClass, out uint pcbStatsWritten); /// Get the reservation information from a marshalling context /// A pointer to a marshaling context that is allocated by using the CreateLogMarshallingArea function. /// The record number. /// The user reservation. /// The commit reservation. /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero (0). To get extended error information, call GetLastError. /// [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool GetLogReservationInfo([In] IntPtr pvMarshal, out uint pcbRecordNumber, out long pcbUserReservation, out long pcbCommitReservation); /// /// Retrieves the next set of archive extents in a log archive context. The log archive context describes a contiguous set of file /// extents that span the snapshot of the active log captured by PrepareLogArchive captures. GetNextLogArchiveExtent maintains a /// cursor in the ordered set of log archive descriptors so that subsequent calls allow an application to iterate through the entire set. /// /// /// A pointer to an archive context that is obtained by a call to PrepareLogArchive. /// /// The context maintains the cursor state, which allows iteration through the set of file extents in the archive. The archive client is /// responsible for deallocating the context by using the TerminateLogArchive function. /// /// /// A client-allocated array of CLFS_ARCHIVE_DESCRIPTOR structures to be filled in by this function. /// /// The number of elements in the rgadExtent array. /// This value is the maximum number of archive descriptors that can be retrieved by this function. /// /// /// The number of descriptors in the rgadExtent array that are filled in by this function. /// /// If this value is less than cDescriptors, the set of descriptors is exhausted and the archive client can terminate iteration /// through the ordered descriptor set. Further calls to this function fail with ERROR_NO_MORE_ENTRIES. /// /// /// /// If the function succeeds, the return value is nonzero. /// /// If the function fails, the return value is zero (0). To get extended error information, call GetLastError. The following list /// identifies the possible error codes: /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-getnextlogarchiveextent CLFSUSER_API BOOL // GetNextLogArchiveExtent( [in] CLFS_LOG_ARCHIVE_CONTEXT pvArchiveContext, [in, out] CLFS_ARCHIVE_DESCRIPTOR [] rgadExtent, [in] ULONG // cDescriptors, [out] PULONG pcDescriptorsReturned ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.GetNextLogArchiveExtent")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool GetNextLogArchiveExtent([In] SafeArchiveContext pvArchiveContext, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] CLS_ARCHIVE_DESCRIPTOR[] rgadExtent, [In] int cDescriptors, out int pcDescriptorsReturned); /// Returns the sector-aligned block offset that is contained in the specified LSN. /// A pointer to a CLFS_LSN structure from which the block offset is to be retrieved. /// LsnBlockOffset returns the block offset that is contained in plsn. /// /// /// The block offset that is returned by this function is a multiple of the sector size on the stable storage medium. For example, if the /// sector size is 1024 bytes, the block offset is a multiple of 1024. /// /// Examples /// For an example that uses this function, see Enumerating Log Containers. /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-lsnblockoffset CLFSUSER_API ULONG LsnBlockOffset( [in] const // CLS_LSN *plsn ); [DllImport(Lib_Clfsw32, SetLastError = false, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.LsnBlockOffset")] public static extern uint LsnBlockOffset(in CLS_LSN plsn); /// Retrieves the logical container ID that is contained in a specified LSN. /// A pointer to a CLFS_LSN structure from which the container ID is to be retrieved. /// /// This function returns the logical container ID that is contained in plsn. The logical container ID is not necessarily the same /// as the ID of the physical container on stable storage. /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-lsncontainer CLFSUSER_API CLFS_CONTAINER_ID LsnContainer( [in] // const CLS_LSN *plsn ); [DllImport(Lib_Clfsw32, SetLastError = false, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.LsnContainer")] public static extern CLFS_CONTAINER_ID LsnContainer(in CLS_LSN plsn); /// Creates a log sequence number (LSN), given a container ID, a block offset, and a record sequence number. /// The container ID. This value must be an integer between 0x0 and 0xFFFFFFFF. /// The block offset. This value must be a multiple of 512. /// The record sequence number. This value must be an integer between 0 - 511. /// /// Returns a CLFS_LSN structure that represents the container ID, block offset, and record sequence number that is supplied by the caller. /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-lsncreate CLFSUSER_API CLS_LSN LsnCreate( [in] CLFS_CONTAINER_ID // cidContainer, [in] ULONG offBlock, [in] ULONG cRecord ); [DllImport(Lib_Clfsw32, SetLastError = false, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.LsnCreate")] public static extern CLS_LSN LsnCreate([In] CLFS_CONTAINER_ID cidContainer, [In] uint offBlock, [In] uint cRecord); /// Decrement and LSN by 1 /// LSN to be decremented. /// A valid LSN prior in sequence to the input LSN, if successful. Otherwise, this function returns CLFS_LSN_INVALID. [DllImport(Lib_Clfsw32, SetLastError = false, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.LsnDecrement")] public static extern CLS_LSN LsnDecrement(in CLS_LSN plsn); /// Increment and LSN by 1 /// LSN to be incremented. /// A valid LSN next in sequence to the input LSN, if successful. Otherwise, this function returns CLFS_LSN_INVALID. [DllImport(Lib_Clfsw32, SetLastError = false, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.LsnIncrement")] public static extern CLS_LSN LsnIncrement(in CLS_LSN plsn); /// Check whether or not an LSN is CLFS_LSN_INVALID. /// Reference to LSN tested against CLFS_LSN_INVALID. /// /// if and only if an LSN is equivalent to CLFS_LSN_INVALID. LSNs with the value CLFS_LSN_NULL will return . /// [DllImport(Lib_Clfsw32, SetLastError = false, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.LsnInvalid")] [return: MarshalAs(UnmanagedType.U1)] public static extern bool LsnInvalid(in CLS_LSN plsn); /// Retrieves the record sequence number that is contained in a specified LSN. /// A pointer to a CLFS_LSN structure from which the record sequence number is to be retrieved. /// The record sequence number that is contained in plsn. // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-lsnrecordsequence CLFSUSER_API ULONG LsnRecordSequence( [in] // const CLS_LSN *plsn ); [DllImport(Lib_Clfsw32, SetLastError = false, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.LsnRecordSequence")] public static extern uint LsnRecordSequence(in CLS_LSN plsn); /// /// /// Prepares a physical log for archival. The function takes a snapshot of the current active log, builds an ordered set of log archive /// descriptors for the active log extents, and returns a log archive context. /// /// /// By passing this log archive context to GetNextLogArchiveExtent, a client can iterate through the set of log archive extents to /// archive the log. You can also specify a range of records to archive. /// /// /// /// A handle to the log that is obtained by a successful call to CreateLogFile. /// This handle can be the handle to a dedicated or multiplexed log. /// /// /// A pointer to a user-allocated buffer to receive the fully qualified path of the base log. /// /// If the buffer is not large enough, it contains a truncated file path on exit, and the function fails with an /// ERROR_BUFFER_OVERFLOW status code. /// /// /// The length of the file path is returned in the variable pointed to by pcActualLength. The client can re-attempt a failed call /// with a name buffer that is large enough. /// /// /// The size of the pszBaseLogFileName buffer, in wide characters. /// /// /// A pointer to a CLFS_LSN structure that specifies the log sequence number (LSN) of the low end of the range of the active log where /// the log client needs log archival information. /// /// If this parameter is omitted, the low end of the range defaults to the LSN of the log archive tail. /// /// /// /// A pointer to a CLFS_LSN structure that specifies the LSN of the high end of the range of the active log where the log client needs /// log archival information. /// /// If this parameter is omitted, the high end of the range defaults to the next LSN to be written to the log. /// /// /// A pointer to a variable that receives the actual length of the name of the base log path, in characters. /// /// If this value is greater than cLen, the function returns an ERROR_BUFFER_OVERFLOW status with a truncated path that is stored /// in the pszBaseLogFileName buffer and all other out parameters that are not set to meaningful values. /// /// /// /// A pointer to a variable that receives the offset where the metadata begins in the base log. /// /// The contiguous extent in the base log pszBaseLogFileName represents the full contents of the log metadata—that is, from /// poffBaseLogFileData to pcbBaseLogFileLength. /// /// /// A pointer to a variable that specifies the exact length of the base log, in bytes. /// A pointer to a CLFS_LSN structure to receive the base log sequence number (LSN) of the active log. /// A pointer to a CLFS_LSN structure to receive the highest valid LSN in the active log. /// A pointer to a CLFS_LSN structure to receive the current LSN of the archive tail of the log. /// /// A pointer to the variable that receives a pointer to an archive context that the system allocates. /// /// The archive context maintains the cursor state of the archival iterator and the log handle context. The archival client is /// responsible for releasing the context by calling TerminateLogArchive. /// /// /// /// If the function succeeds, the return value is nonzero. /// /// If the function fails, the return value is zero. To get extended error information, call GetLastError. The following list identifies /// the possible error codes: /// /// /// /// You must call TerminateLogArchive to free the archive context, or memory leaks can occur. /// Until you call TerminateLogArchive, containers that are being archived cannot be recycled. /// You can only perform one archive operation at a time per handle that CreateLogFile returns. /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-preparelogarchive CLFSUSER_API BOOL PrepareLogArchive( [in] // HANDLE hLog, [in, out] PWSTR pszBaseLogFileName, [in] ULONG cLen, [in, optional] const PCLFS_LSN plsnLow, [in, optional] const // PCLFS_LSN plsnHigh, [out, optional] PULONG pcActualLength, [out] PULONGLONG poffBaseLogFileData, [out] PULONGLONG // pcbBaseLogFileLength, [out] PCLFS_LSN plsnBase, [out] PCLFS_LSN plsnLast, [out] PCLFS_LSN plsnCurrentArchiveTail, [out] // PCLFS_LOG_ARCHIVE_CONTEXT ppvArchiveContext ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.PrepareLogArchive")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool PrepareLogArchive([In] HLOG hLog, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszBaseLogFileName, [In] int cLen, in CLS_LSN plsnLow, in CLS_LSN plsnHigh, out uint pcActualLength, out ulong poffBaseLogFileData, out ulong pcbBaseLogFileLength, out CLS_LSN plsnBase, out CLS_LSN plsnLast, out CLS_LSN plsnCurrentArchiveTail, out SafeArchiveContext ppvArchiveContext); /// /// /// Prepares a physical log for archival. The function takes a snapshot of the current active log, builds an ordered set of log archive /// descriptors for the active log extents, and returns a log archive context. /// /// /// By passing this log archive context to GetNextLogArchiveExtent, a client can iterate through the set of log archive extents to /// archive the log. You can also specify a range of records to archive. /// /// /// /// A handle to the log that is obtained by a successful call to CreateLogFile. /// This handle can be the handle to a dedicated or multiplexed log. /// /// /// A pointer to a user-allocated buffer to receive the fully qualified path of the base log. /// /// If the buffer is not large enough, it contains a truncated file path on exit, and the function fails with an /// ERROR_BUFFER_OVERFLOW status code. /// /// /// The length of the file path is returned in the variable pointed to by pcActualLength. The client can re-attempt a failed call /// with a name buffer that is large enough. /// /// /// The size of the pszBaseLogFileName buffer, in wide characters. /// /// /// A pointer to a CLFS_LSN structure that specifies the log sequence number (LSN) of the low end of the range of the active log where /// the log client needs log archival information. /// /// If this parameter is omitted, the low end of the range defaults to the LSN of the log archive tail. /// /// /// /// A pointer to a CLFS_LSN structure that specifies the LSN of the high end of the range of the active log where the log client needs /// log archival information. /// /// If this parameter is omitted, the high end of the range defaults to the next LSN to be written to the log. /// /// /// A pointer to a variable that receives the actual length of the name of the base log path, in characters. /// /// If this value is greater than cLen, the function returns an ERROR_BUFFER_OVERFLOW status with a truncated path that is stored /// in the pszBaseLogFileName buffer and all other out parameters that are not set to meaningful values. /// /// /// /// A pointer to a variable that receives the offset where the metadata begins in the base log. /// /// The contiguous extent in the base log pszBaseLogFileName represents the full contents of the log metadata—that is, from /// poffBaseLogFileData to pcbBaseLogFileLength. /// /// /// A pointer to a variable that specifies the exact length of the base log, in bytes. /// A pointer to a CLFS_LSN structure to receive the base log sequence number (LSN) of the active log. /// A pointer to a CLFS_LSN structure to receive the highest valid LSN in the active log. /// A pointer to a CLFS_LSN structure to receive the current LSN of the archive tail of the log. /// /// A pointer to the variable that receives a pointer to an archive context that the system allocates. /// /// The archive context maintains the cursor state of the archival iterator and the log handle context. The archival client is /// responsible for releasing the context by calling TerminateLogArchive. /// /// /// /// If the function succeeds, the return value is nonzero. /// /// If the function fails, the return value is zero. To get extended error information, call GetLastError. The following list identifies /// the possible error codes: /// /// /// /// You must call TerminateLogArchive to free the archive context, or memory leaks can occur. /// Until you call TerminateLogArchive, containers that are being archived cannot be recycled. /// You can only perform one archive operation at a time per handle that CreateLogFile returns. /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-preparelogarchive CLFSUSER_API BOOL PrepareLogArchive( [in] // HANDLE hLog, [in, out] PWSTR pszBaseLogFileName, [in] ULONG cLen, [in, optional] const PCLFS_LSN plsnLow, [in, optional] const // PCLFS_LSN plsnHigh, [out, optional] PULONG pcActualLength, [out] PULONGLONG poffBaseLogFileData, [out] PULONGLONG // pcbBaseLogFileLength, [out] PCLFS_LSN plsnBase, [out] PCLFS_LSN plsnLast, [out] PCLFS_LSN plsnCurrentArchiveTail, [out] // PCLFS_LOG_ARCHIVE_CONTEXT ppvArchiveContext ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.PrepareLogArchive")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool PrepareLogArchive([In] HLOG hLog, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszBaseLogFileName, [In] int cLen, [In, Optional] IntPtr plsnLow, [In, Optional] IntPtr plsnHigh, out uint pcActualLength, out ulong poffBaseLogFileData, out ulong pcbBaseLogFileLength, out CLS_LSN plsnBase, out CLS_LSN plsnLast, out CLS_LSN plsnCurrentArchiveTail, out SafeArchiveContext ppvArchiveContext); /// Copies a range of the archive view of the metadata to the specified buffer. /// /// A pointer to an archive context that is obtained by a call to PrepareLogArchive. /// /// The context maintains the cursor state, which allows iteration through the set of file extents in the archive. The archive client is /// responsible for deallocating the context by using the TerminateLogArchive function. /// /// /// /// The offset in the metadata where data copying starts. /// On the first call to this function, specify zero (0). On subsequent calls, specify the value that is returned in pcbBytesRead. /// /// /// The number of bytes of the metadata snapshot should be copied into pbReadBuffer. /// This parameter cannot be zero (0). /// /// A pointer to the buffer where the metadata snapshot is copied. /// /// A pointer to a variable that receives the number of bytes that are copied to pbReadBuffer. /// The number of bytes is always between zero (0) and cbBytesToRead. /// /// /// If the function succeeds, the return value is nonzero. /// /// If the function fails, the return value is zero (0). To get extended error information, call GetLastError. The following list /// identifies the possible error codes: /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-readlogarchivemetadata CLFSUSER_API BOOL ReadLogArchiveMetadata( // [in] CLFS_LOG_ARCHIVE_CONTEXT pvArchiveContext, [in] ULONG cbOffset, [in] ULONG cbBytesToRead, [in, out] PBYTE pbReadBuffer, [out] // PULONG pcbBytesRead ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.ReadLogArchiveMetadata")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool ReadLogArchiveMetadata([In] SafeArchiveContext pvArchiveContext, [In] uint cbOffset, [In] uint cbBytesToRead, [In, Out] IntPtr pbReadBuffer, out uint pcbBytesRead); /// /// Initiates a sequence of reads from a specified log sequence number (LSN) in one of three modes, and returns the first of the /// specified log records and a read context. A client can read subsequent records in the designated mode by passing the read context to ReadNextLogRecord. /// /// A pointer to a marshaling context that is allocated by using the CreateLogMarshallingArea function. /// /// /// A pointer to a CLFS_LSN structure that specifies the log sequence number (LSN) of the record where the read operation should start. /// /// This value must be an LSN of a valid record in the active range of the log. /// /// /// The mode for the read context that is returned in *ppvReadContext. /// The following table identifies the three mutually exclusive read modes. /// /// /// Value /// Meaning /// /// /// ClfsContextPrevious /// Reads the record linked to by plsnPrevious. /// /// /// ClfsContextUndoNext /// Reads the record chain linked to by plsnUndoNext. /// /// /// ClfsContextForward /// Reads the record with the LSN that immediately follows the current LSN in the read context. /// /// /// /// A pointer to a variable that receives a pointer to the target record in the log I/O block. /// /// A pointer to a variable that receives the size of the data that is returned in *ppvReadBuffer, in bytes. /// /// /// A pointer to a variable that receives the type of record read. /// This parameter is one of the CLFS_RECORD_TYPE Constants. /// /// A pointer to a CLFS_LSN structure that receives the LSN of the next record in the undo record chain. /// A pointer to a CLFS_LSN structure that receives the LSN of the next record in the previous record chain. /// /// A pointer to a variable that receives a pointer to a system-allocated read context when a read is successful. /// /// If the function defers completion of an operation, it returns a valid read-context pointer and an error status of /// ERROR_IO_PENDING. On all other errors, the read-context pointer is NULL. For more information about handling deferred /// completion of the function, see the Remarks section of this topic. /// /// /// After obtaining all requested log records, the client must pass the read context to TerminateReadLog to free the associated memory. /// Failure to do so results in memory leakage. /// /// /// Note Common Log File System (CLFS) read contexts are not thread-safe. They should not be used by more than one thread at a /// time, or passed into more than one asynchronous read at a time. /// /// /// /// A pointer to an OVERLAPPED structure, which is required for asynchronous operation. /// This parameter can be NULL if asynchronous operation is not used. /// /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero. To get extended error information, call GetLastError. /// The following list identifies the possible error codes. /// /// /// /// The error message ERROR_LOG_BLOCK_INCOMPLETE is returned if the log block size specified by CreateLogMarshallingArea is not large /// enough to hold a complete log block. /// /// /// If ReadLogRecord is called with a valid pOverlapped structure and the log handle is created with the overlapped option, /// then if a call to this function fails with an error code of ERROR_IO_PENDING, a pointer to a valid read context is placed in /// the variable that is pointed to by the ppvReadContext parameter. /// /// /// If you attempt to open more read contexts than the number buffers specified in a previous call to CreateLogMarshallingArea, /// ERROR_LOG_BLOCK_EXHAUSTED is returned. /// /// /// To complete a log-record copy, the client should first synchronize its execution with deferred completion of the overlapped I/O /// operation by using GetOverlappedResult or one of the synchronization Wait Functions. For more information, see Synchronization and /// Overlapped Input and Output. /// /// /// After ReadLogRecord completes asynchronously, the requested record is read from the disk, but is not resolved to a pointer in *ppvReadBuffer. /// /// /// To complete the requested read and obtain a valid pointer to the log record, the client must call ReadNextLogRecord, which passes in /// the read-context pointer that ReadLogRecord returns. /// /// /// Note Common Log File System (CLFS) read contexts are not thread-safe. They should not be used by more than one thread at a time. /// /// CLFS read contexts should not be passed into more than one asynchronous read at a time, or the function fails with ERROR_BUSY. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-readlogrecord CLFSUSER_API BOOL ReadLogRecord( [in] PVOID // pvMarshal, [in] PCLFS_LSN plsnFirst, [in] CLFS_CONTEXT_MODE eContextMode, [out] PVOID *ppvReadBuffer, [out] PULONG pcbReadBuffer, // [out] PCLFS_RECORD_TYPE peRecordType, [out] PCLFS_LSN plsnUndoNext, [out] PCLFS_LSN plsnPrevious, [out] PVOID *ppvReadContext, [in, // out, optional] LPOVERLAPPED pOverlapped ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.ReadLogRecord")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool ReadLogRecord([In] IntPtr pvMarshal, in CLS_LSN plsnFirst, [In] CLFS_CONTEXT_MODE eContextMode, out IntPtr ppvReadBuffer, [Out] IntPtr pcbReadBuffer, out CLS_RECORD_TYPE peRecordType, out CLS_LSN plsnUndoNext, out CLS_LSN plsnPrevious, out IntPtr ppvReadContext, ref NativeOverlapped pOverlapped); /// /// Initiates a sequence of reads from a specified log sequence number (LSN) in one of three modes, and returns the first of the /// specified log records and a read context. A client can read subsequent records in the designated mode by passing the read context to ReadNextLogRecord. /// /// A pointer to a marshaling context that is allocated by using the CreateLogMarshallingArea function. /// /// /// A pointer to a CLFS_LSN structure that specifies the log sequence number (LSN) of the record where the read operation should start. /// /// This value must be an LSN of a valid record in the active range of the log. /// /// /// The mode for the read context that is returned in *ppvReadContext. /// The following table identifies the three mutually exclusive read modes. /// /// /// Value /// Meaning /// /// /// ClfsContextPrevious /// Reads the record linked to by plsnPrevious. /// /// /// ClfsContextUndoNext /// Reads the record chain linked to by plsnUndoNext. /// /// /// ClfsContextForward /// Reads the record with the LSN that immediately follows the current LSN in the read context. /// /// /// /// A pointer to a variable that receives a pointer to the target record in the log I/O block. /// /// A pointer to a variable that receives the size of the data that is returned in *ppvReadBuffer, in bytes. /// /// /// A pointer to a variable that receives the type of record read. /// This parameter is one of the CLFS_RECORD_TYPE Constants. /// /// A pointer to a CLFS_LSN structure that receives the LSN of the next record in the undo record chain. /// A pointer to a CLFS_LSN structure that receives the LSN of the next record in the previous record chain. /// /// A pointer to a variable that receives a pointer to a system-allocated read context when a read is successful. /// /// If the function defers completion of an operation, it returns a valid read-context pointer and an error status of /// ERROR_IO_PENDING. On all other errors, the read-context pointer is NULL. For more information about handling deferred /// completion of the function, see the Remarks section of this topic. /// /// /// After obtaining all requested log records, the client must pass the read context to TerminateReadLog to free the associated memory. /// Failure to do so results in memory leakage. /// /// /// Note Common Log File System (CLFS) read contexts are not thread-safe. They should not be used by more than one thread at a /// time, or passed into more than one asynchronous read at a time. /// /// /// /// A pointer to an OVERLAPPED structure, which is required for asynchronous operation. /// This parameter can be NULL if asynchronous operation is not used. /// /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero. To get extended error information, call GetLastError. /// The following list identifies the possible error codes. /// /// /// /// The error message ERROR_LOG_BLOCK_INCOMPLETE is returned if the log block size specified by CreateLogMarshallingArea is not large /// enough to hold a complete log block. /// /// /// If ReadLogRecord is called with a valid pOverlapped structure and the log handle is created with the overlapped option, /// then if a call to this function fails with an error code of ERROR_IO_PENDING, a pointer to a valid read context is placed in /// the variable that is pointed to by the ppvReadContext parameter. /// /// /// If you attempt to open more read contexts than the number buffers specified in a previous call to CreateLogMarshallingArea, /// ERROR_LOG_BLOCK_EXHAUSTED is returned. /// /// /// To complete a log-record copy, the client should first synchronize its execution with deferred completion of the overlapped I/O /// operation by using GetOverlappedResult or one of the synchronization Wait Functions. For more information, see Synchronization and /// Overlapped Input and Output. /// /// /// After ReadLogRecord completes asynchronously, the requested record is read from the disk, but is not resolved to a pointer in *ppvReadBuffer. /// /// /// To complete the requested read and obtain a valid pointer to the log record, the client must call ReadNextLogRecord, which passes in /// the read-context pointer that ReadLogRecord returns. /// /// /// Note Common Log File System (CLFS) read contexts are not thread-safe. They should not be used by more than one thread at a time. /// /// CLFS read contexts should not be passed into more than one asynchronous read at a time, or the function fails with ERROR_BUSY. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-readlogrecord CLFSUSER_API BOOL ReadLogRecord( [in] PVOID // pvMarshal, [in] PCLFS_LSN plsnFirst, [in] CLFS_CONTEXT_MODE eContextMode, [out] PVOID *ppvReadBuffer, [out] PULONG pcbReadBuffer, // [out] PCLFS_RECORD_TYPE peRecordType, [out] PCLFS_LSN plsnUndoNext, [out] PCLFS_LSN plsnPrevious, [out] PVOID *ppvReadContext, [in, // out, optional] LPOVERLAPPED pOverlapped ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.ReadLogRecord")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool ReadLogRecord([In] IntPtr pvMarshal, in CLS_LSN plsnFirst, [In] CLFS_CONTEXT_MODE eContextMode, out IntPtr ppvReadBuffer, [Out] IntPtr pcbReadBuffer, out CLS_RECORD_TYPE peRecordType, out CLS_LSN plsnUndoNext, out CLS_LSN plsnPrevious, out IntPtr ppvReadContext, [In, Optional] IntPtr pOverlapped); /// /// /// Returns the last restart area that is written successfully to the log associated with the marshaling area of WriteLogRestartArea. The /// function also returns a read context that allows the caller to cursor backward or forward through a log from the restart record. /// /// This read context is useful when scanning through previous restart areas prior to the current one by invoking ReadPreviousLogRestartArea. /// /// A pointer to a marshaling context that is allocated by using the CreateLogMarshallingArea function. /// A pointer to a variable that receives a pointer to the restart data in the log I/O block. /// A pointer to a variable that receives the amount of restart data. /// A pointer to a CLFS_LSN structure that receives the log sequence number (LSN) of the restart area. /// /// A pointer to a variable that receives a pointer to a system-allocated read context when a read is successful. /// /// If the function defers completion of an operation, it returns a valid read-context pointer and an error status of /// ERROR_IO_PENDING. On all other errors, the read-context pointer is NULL. For more information about handling deferred /// completion of the function, see the Remarks section of this topic. /// /// /// After obtaining all requested log records, the client must pass the read context to TerminateReadLog to free the associated memory. /// Failure to do so results in memory leakage. /// /// /// Note Common Log File System (CLFS) read contexts are not thread-safe. They should not be used by more than one thread at a /// time, or passed into more than one asynchronous read at a time. /// /// /// /// A pointer to an OVERLAPPED structure that is required for asynchronous operation. /// This parameter can be NULL if an asynchronous operation is not used. /// /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero. To get extended error information, call GetLastError. /// The following list identifies the possible error codes: /// /// /// /// The error message ERROR_LOG_BLOCK_INCOMPLETE is returned if the log block size specified by CreateLogMarshallingArea is not large /// enough to hold a complete log block. /// /// Typically, ReadLogRestartArea is used only during client restart, either after a crash or after a normal shutdown. /// If there is no restart area in the log, ReadLogRestartArea fails with the code ERROR_LOG_NO_RESTART. /// /// If ReadLogRestartArea fails with an error code of ERROR_IO_PENDING, a pointer to a valid read context is placed in the /// variable pointed to by the ppvReadContext parameter. /// /// /// To complete the log-record copy, the client should first synchronize its execution with deferred completion of the overlapped I/O /// operation by calling GetOverlappedResult, or one of the synchronization Wait Functions. For more information, see Synchronization and /// Overlapped Input and Output. /// /// /// After ReadLogRestartArea completes asynchronously, the requested restart area is read from the disk, but a valid pointer to it /// is not placed in *ppvRestartBuffer. /// /// /// To obtain a valid pointer, the client must call ReadPreviousLogRestartArea, which passes in the read-context pointer returned by ReadLogRestartArea. /// /// /// Note Common Log File System (CLFS) read contexts are not thread-safe. They should not be used by more than one thread at a time. /// /// CLFS read contexts should not be passed into more than one asynchronous read at a time, or the function fails with ERROR_BUSY. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-readlogrestartarea CLFSUSER_API BOOL ReadLogRestartArea( [in] // PVOID pvMarshal, [out] PVOID *ppvRestartBuffer, [out] PULONG pcbRestartBuffer, [out] PCLFS_LSN plsn, [out] PVOID *ppvContext, [in, // out, optional] LPOVERLAPPED pOverlapped ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.ReadLogRestartArea")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool ReadLogRestartArea([In] IntPtr pvMarshal, out IntPtr ppvRestartBuffer, [Out] IntPtr pcbRestartBuffer, out CLS_LSN plsn, out IntPtr ppvContext, ref NativeOverlapped pOverlapped); /// /// /// Returns the last restart area that is written successfully to the log associated with the marshaling area of WriteLogRestartArea. The /// function also returns a read context that allows the caller to cursor backward or forward through a log from the restart record. /// /// This read context is useful when scanning through previous restart areas prior to the current one by invoking ReadPreviousLogRestartArea. /// /// A pointer to a marshaling context that is allocated by using the CreateLogMarshallingArea function. /// A pointer to a variable that receives a pointer to the restart data in the log I/O block. /// A pointer to a variable that receives the amount of restart data. /// A pointer to a CLFS_LSN structure that receives the log sequence number (LSN) of the restart area. /// /// A pointer to a variable that receives a pointer to a system-allocated read context when a read is successful. /// /// If the function defers completion of an operation, it returns a valid read-context pointer and an error status of /// ERROR_IO_PENDING. On all other errors, the read-context pointer is NULL. For more information about handling deferred /// completion of the function, see the Remarks section of this topic. /// /// /// After obtaining all requested log records, the client must pass the read context to TerminateReadLog to free the associated memory. /// Failure to do so results in memory leakage. /// /// /// Note Common Log File System (CLFS) read contexts are not thread-safe. They should not be used by more than one thread at a /// time, or passed into more than one asynchronous read at a time. /// /// /// /// A pointer to an OVERLAPPED structure that is required for asynchronous operation. /// This parameter can be NULL if an asynchronous operation is not used. /// /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero. To get extended error information, call GetLastError. /// The following list identifies the possible error codes: /// /// /// /// The error message ERROR_LOG_BLOCK_INCOMPLETE is returned if the log block size specified by CreateLogMarshallingArea is not large /// enough to hold a complete log block. /// /// Typically, ReadLogRestartArea is used only during client restart, either after a crash or after a normal shutdown. /// If there is no restart area in the log, ReadLogRestartArea fails with the code ERROR_LOG_NO_RESTART. /// /// If ReadLogRestartArea fails with an error code of ERROR_IO_PENDING, a pointer to a valid read context is placed in the /// variable pointed to by the ppvReadContext parameter. /// /// /// To complete the log-record copy, the client should first synchronize its execution with deferred completion of the overlapped I/O /// operation by calling GetOverlappedResult, or one of the synchronization Wait Functions. For more information, see Synchronization and /// Overlapped Input and Output. /// /// /// After ReadLogRestartArea completes asynchronously, the requested restart area is read from the disk, but a valid pointer to it /// is not placed in *ppvRestartBuffer. /// /// /// To obtain a valid pointer, the client must call ReadPreviousLogRestartArea, which passes in the read-context pointer returned by ReadLogRestartArea. /// /// /// Note Common Log File System (CLFS) read contexts are not thread-safe. They should not be used by more than one thread at a time. /// /// CLFS read contexts should not be passed into more than one asynchronous read at a time, or the function fails with ERROR_BUSY. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-readlogrestartarea CLFSUSER_API BOOL ReadLogRestartArea( [in] // PVOID pvMarshal, [out] PVOID *ppvRestartBuffer, [out] PULONG pcbRestartBuffer, [out] PCLFS_LSN plsn, [out] PVOID *ppvContext, [in, // out, optional] LPOVERLAPPED pOverlapped ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.ReadLogRestartArea")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool ReadLogRestartArea([In] IntPtr pvMarshal, out IntPtr ppvRestartBuffer, [Out] IntPtr pcbRestartBuffer, out CLS_LSN plsn, out IntPtr ppvContext, [In, Optional] IntPtr pOverlapped); /// /// Reads the next record in a sequence that is initiated by a call to ReadLogRecord or ReadLogRestartArea. By using /// ReadNextLogRecord iteratively, a client can read all records of a specified type in a log. The direction of enumeration is /// determined by specifying the context mode when beginning the read sequence. /// /// /// A pointer to a read context that the system allocates and creates during a successful call to ReadLogRecord or ReadLogRestartArea. /// /// If the function defers completion of an operation, it returns a pointer to a valid read context and an error status of /// ERROR_IO_PENDING. For information about handling asynchronous completion, see the Remarks section of this topic. /// /// /// A pointer to a variable that receives a pointer to the read data. /// /// A pointer to a variable that receives the size of the read data that is returned in ppvReadBuffer, in bytes. /// /// /// /// A pointer that, on input, specifies the record type filter of the next record read, and on output specifies the record type that is returned. /// /// Clients can specify any of the following record types. /// /// /// Value /// Meaning /// /// /// ClfsDataRecord /// Only user-data records are read. /// /// /// ClfsRestartRecord /// Only restart records are read. /// /// /// ClfsClientRecord /// All restart and data records are read. /// /// /// /// /// /// A pointer to a CLFS_LSN structure that specifies the log client to read this log sequence number (LSN) as the next LSN instead of /// reading forward to the next record, reading the previous LSN, or reading the next undo LSN. /// /// /// This parameter gives log clients the ability to cursor through user-defined LSN chains in client buffers. The relationship of this /// parameter to the current LSN held by the read context must be consistent with the context mode, ecxMode, that is specified in /// the ReadLogRecord entry points; otherwise, an error code of ERROR_INVALID_PARAMETER is returned. /// /// /// A pointer to a CLFS_LSN structure that receives the LSN of the next record in an undo record chain. /// A pointer to a CLFS_LSN structure that receives the LSN of the next record in the previous record chain. /// A pointer to a CLFS_LSN structure that receives the LSN of the current record read into the read context. /// /// A pointer to an OVERLAPPED structure that is required for asynchronous operation. /// This parameter can be NULL if asynchronous operation is not used. /// /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero. To get extended error information, call GetLastError. /// The following list identifies the possible error codes: /// /// /// /// If ReadNextLogRecord returns with a status code of ERROR_IO_PENDING, the client should synchronize its execution with /// deferred completion of the overlapped I/O operation by using GetOverlappedResult, or one of the synchronization Wait Functions. For /// more information, see Synchronization and Overlapped Input and Output. /// /// /// After ReadNextLogRecord completes asynchronously, the requested record is read from the disk, but is not resolved to a pointer /// in *ppvReadBuffer. To obtain a valid pointer to the record, the client must call ReadNextLogRecord a second time. /// /// /// Note Common Log File System (CLFS) read contexts are not thread-safe. They should not be used by more than one thread at a time. /// /// CLFS read contexts should not be passed into more than one asynchronous read at a time, or the function fails with ERROR_READ. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-readnextlogrecord CLFSUSER_API BOOL ReadNextLogRecord( [in, out] // PVOID pvReadContext, [out] PVOID *ppvBuffer, [out] PULONG pcbBuffer, [in, out] PCLFS_RECORD_TYPE peRecordType, [in, optional] // PCLFS_LSN plsnUser, [out] PCLFS_LSN plsnUndoNext, [out] PCLFS_LSN plsnPrevious, [out] PCLFS_LSN plsnRecord, [in, out, optional] // LPOVERLAPPED pOverlapped ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.ReadNextLogRecord")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool ReadNextLogRecord([In, Out] IntPtr pvReadContext, out IntPtr ppvBuffer, [Out] IntPtr pcbBuffer, ref CLS_RECORD_TYPE peRecordType, in CLS_LSN plsnUser, out CLS_LSN plsnUndoNext, out CLS_LSN plsnPrevious, out CLS_LSN plsnRecord, ref NativeOverlapped pOverlapped); /// /// Reads the next record in a sequence that is initiated by a call to ReadLogRecord or ReadLogRestartArea. By using /// ReadNextLogRecord iteratively, a client can read all records of a specified type in a log. The direction of enumeration is /// determined by specifying the context mode when beginning the read sequence. /// /// /// A pointer to a read context that the system allocates and creates during a successful call to ReadLogRecord or ReadLogRestartArea. /// /// If the function defers completion of an operation, it returns a pointer to a valid read context and an error status of /// ERROR_IO_PENDING. For information about handling asynchronous completion, see the Remarks section of this topic. /// /// /// A pointer to a variable that receives a pointer to the read data. /// /// A pointer to a variable that receives the size of the read data that is returned in ppvReadBuffer, in bytes. /// /// /// /// A pointer that, on input, specifies the record type filter of the next record read, and on output specifies the record type that is returned. /// /// Clients can specify any of the following record types. /// /// /// Value /// Meaning /// /// /// ClfsDataRecord /// Only user-data records are read. /// /// /// ClfsRestartRecord /// Only restart records are read. /// /// /// ClfsClientRecord /// All restart and data records are read. /// /// /// /// /// /// A pointer to a CLFS_LSN structure that specifies the log client to read this log sequence number (LSN) as the next LSN instead of /// reading forward to the next record, reading the previous LSN, or reading the next undo LSN. /// /// /// This parameter gives log clients the ability to cursor through user-defined LSN chains in client buffers. The relationship of this /// parameter to the current LSN held by the read context must be consistent with the context mode, ecxMode, that is specified in /// the ReadLogRecord entry points; otherwise, an error code of ERROR_INVALID_PARAMETER is returned. /// /// /// A pointer to a CLFS_LSN structure that receives the LSN of the next record in an undo record chain. /// A pointer to a CLFS_LSN structure that receives the LSN of the next record in the previous record chain. /// A pointer to a CLFS_LSN structure that receives the LSN of the current record read into the read context. /// /// A pointer to an OVERLAPPED structure that is required for asynchronous operation. /// This parameter can be NULL if asynchronous operation is not used. /// /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero. To get extended error information, call GetLastError. /// The following list identifies the possible error codes: /// /// /// /// If ReadNextLogRecord returns with a status code of ERROR_IO_PENDING, the client should synchronize its execution with /// deferred completion of the overlapped I/O operation by using GetOverlappedResult, or one of the synchronization Wait Functions. For /// more information, see Synchronization and Overlapped Input and Output. /// /// /// After ReadNextLogRecord completes asynchronously, the requested record is read from the disk, but is not resolved to a pointer /// in *ppvReadBuffer. To obtain a valid pointer to the record, the client must call ReadNextLogRecord a second time. /// /// /// Note Common Log File System (CLFS) read contexts are not thread-safe. They should not be used by more than one thread at a time. /// /// CLFS read contexts should not be passed into more than one asynchronous read at a time, or the function fails with ERROR_READ. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-readnextlogrecord CLFSUSER_API BOOL ReadNextLogRecord( [in, out] // PVOID pvReadContext, [out] PVOID *ppvBuffer, [out] PULONG pcbBuffer, [in, out] PCLFS_RECORD_TYPE peRecordType, [in, optional] // PCLFS_LSN plsnUser, [out] PCLFS_LSN plsnUndoNext, [out] PCLFS_LSN plsnPrevious, [out] PCLFS_LSN plsnRecord, [in, out, optional] // LPOVERLAPPED pOverlapped ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.ReadNextLogRecord")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool ReadNextLogRecord([In, Out] IntPtr pvReadContext, out IntPtr ppvBuffer, [Out] IntPtr pcbBuffer, ref CLS_RECORD_TYPE peRecordType, [In, Optional] IntPtr plsnUser, out CLS_LSN plsnUndoNext, out CLS_LSN plsnPrevious, out CLS_LSN plsnRecord, [In, Optional] IntPtr pOverlapped); /// /// Reads the previous log restart area that is relative to the current restart record specified in the read context, /// pvReadContext. This read context is the one previously created by a call to ReadLogRestartArea. /// /// /// A pointer to a system-allocated read context that ReadLogRestartArea returns. /// /// Even when those functions return ERROR_IO_PENDING, they still return a pointer to a valid read context. For information about /// asynchronous completion, see the Remarks section of this topic. /// /// /// A pointer to a variable that receives a pointer to the restart data. /// /// A pointer to a variable that receives the size of the restart data at *ppvRestartBuffer, in bytes. /// /// /// A pointer to a CLFS_LSN structure that receives the log sequence number (LSN) of the restart area that this function returns. /// /// /// A pointer to an OVERLAPPED structure that is required for asynchronous operation. /// This parameter can be NULL if asynchronous operation is not used. /// /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero. To get extended error information, call GetLastError. /// The following list identifies the possible error codes: /// /// /// /// The error message ERROR_LOG_BLOCK_INCOMPLETE is returned if the log block size specified by CreateLogMarshallingArea is not large /// enough to hold a complete log block. /// /// /// If ReadPreviousLogRestartArea fails with an error code of ERROR_IO_PENDING, a pointer to a valid read context is placed /// in the variable that is pointed to by the ppvReadContext parameter. /// /// /// To complete the log-record copy, the client should first synchronize its execution with deferred completion of the overlapped I/O /// operation by using GetOverlappedResult or one of the synchronization Wait Functions. For more information, see Synchronization and /// Overlapped Input and Output. /// /// /// After ReadPreviousLogRestartArea completes asynchronously, the requested restart area is read from the disk, but a valid /// pointer to it is not placed in *ppvRestartBuffer. /// /// To obtain a valid pointer, the client must call ReadPreviousLogRestartArea a second time. /// /// Note Common Log File System (CLFS) read contexts are not thread-safe. They should not be used by more than one thread at a time. /// /// CLFS read contexts should not be passed into more than one asynchronous read at a time, or the function fails with ERROR_READ. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-readpreviouslogrestartarea CLFSUSER_API BOOL // ReadPreviousLogRestartArea( [in] PVOID pvReadContext, [out] PVOID *ppvRestartBuffer, [out] PULONG pcbRestartBuffer, [out] PCLFS_LSN // plsnRestart, [in, out, optional] LPOVERLAPPED pOverlapped ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.ReadPreviousLogRestartArea")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool ReadPreviousLogRestartArea([In] IntPtr pvReadContext, out IntPtr ppvRestartBuffer, [Out] IntPtr pcbRestartBuffer, out CLS_LSN plsnRestart, ref NativeOverlapped pOverlapped); /// /// Reads the previous log restart area that is relative to the current restart record specified in the read context, /// pvReadContext. This read context is the one previously created by a call to ReadLogRestartArea. /// /// /// A pointer to a system-allocated read context that ReadLogRestartArea returns. /// /// Even when those functions return ERROR_IO_PENDING, they still return a pointer to a valid read context. For information about /// asynchronous completion, see the Remarks section of this topic. /// /// /// A pointer to a variable that receives a pointer to the restart data. /// /// A pointer to a variable that receives the size of the restart data at *ppvRestartBuffer, in bytes. /// /// /// A pointer to a CLFS_LSN structure that receives the log sequence number (LSN) of the restart area that this function returns. /// /// /// A pointer to an OVERLAPPED structure that is required for asynchronous operation. /// This parameter can be NULL if asynchronous operation is not used. /// /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero. To get extended error information, call GetLastError. /// The following list identifies the possible error codes: /// /// /// /// The error message ERROR_LOG_BLOCK_INCOMPLETE is returned if the log block size specified by CreateLogMarshallingArea is not large /// enough to hold a complete log block. /// /// /// If ReadPreviousLogRestartArea fails with an error code of ERROR_IO_PENDING, a pointer to a valid read context is placed /// in the variable that is pointed to by the ppvReadContext parameter. /// /// /// To complete the log-record copy, the client should first synchronize its execution with deferred completion of the overlapped I/O /// operation by using GetOverlappedResult or one of the synchronization Wait Functions. For more information, see Synchronization and /// Overlapped Input and Output. /// /// /// After ReadPreviousLogRestartArea completes asynchronously, the requested restart area is read from the disk, but a valid /// pointer to it is not placed in *ppvRestartBuffer. /// /// To obtain a valid pointer, the client must call ReadPreviousLogRestartArea a second time. /// /// Note Common Log File System (CLFS) read contexts are not thread-safe. They should not be used by more than one thread at a time. /// /// CLFS read contexts should not be passed into more than one asynchronous read at a time, or the function fails with ERROR_READ. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-readpreviouslogrestartarea CLFSUSER_API BOOL // ReadPreviousLogRestartArea( [in] PVOID pvReadContext, [out] PVOID *ppvRestartBuffer, [out] PULONG pcbRestartBuffer, [out] PCLFS_LSN // plsnRestart, [in, out, optional] LPOVERLAPPED pOverlapped ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.ReadPreviousLogRestartArea")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool ReadPreviousLogRestartArea([In] IntPtr pvReadContext, out IntPtr ppvRestartBuffer, [Out] IntPtr pcbRestartBuffer, out CLS_LSN plsnRestart, [In, Optional] IntPtr pOverlapped); /// /// Removes one container from a log that is associated with a dedicated or multiplexed log handle. /// /// A client must have administrative privileges on the log handle to remove a container. To remove multiple containers, use the /// RemoveLogContainerSet function. /// /// /// A handle to the log that is obtained from CreateLogFile. /// /// A pointer to a wide character string that contains a path for a log container that is created by either AddLogContainer or AddLogContainerSet. /// /// /// The deletion flag that determines when and how a container is deleted. /// /// If fForce is TRUE, and the container is part of the active log region, the container is not deleted and an error /// ERROR_LOG_CANT_DELETE is returned. /// /// If FALSE, the container is deleted when the container is no longer a part of the active log region. /// /// This parameter is reserved and should be set to NULL. /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero. To get extended error information, call GetLastError. /// The following list identifies the possible error codes: /// /// /// /// By default, container deletion is lazy, which means that a container is deleted only if it is not part of an active log. If the /// container is part of the active log, it is marked for deletion. However, deletion does not occur until the end of the log exceeds the /// last sector of the container, or the container has a logical identifier that is greater than the logical identifier of the head of /// the active log. The log size reflects the container deletion only when the container is deleted physically. /// /// /// A log client can request a forced deletion on a container by setting the deletion flag to TRUE. This has the same effect as /// deleting a container that is not part of the active log. However, if the container is part of the active log, the call fails without /// marking the container for deletion. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-removelogcontainer CLFSUSER_API BOOL RemoveLogContainer( [in] // HANDLE hLog, [in] LPWSTR pwszContainerPath, [in] BOOL fForce, [in, out, optional] LPVOID pReserved ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.RemoveLogContainer")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool RemoveLogContainer([In] HLOG hLog, [MarshalAs(UnmanagedType.LPWStr)] string pwszContainerPath, [MarshalAs(UnmanagedType.Bool)] bool fForce, [In, Optional] IntPtr pReserved); /// /// Removes multiple containers from a log that is associated with a dedicated or multiplexed log handle. /// /// A client must have administrative privileges on the log handle to remove a container. The RemoveLogContainer function is a special /// case of this RemoveLogContainerSet function, because it removes only one container. To remove multiple containers, use the RemoveLogContainerSet. /// /// /// /// A handle to the log that is obtained from CreateLogFile. /// /// The log handle must have administrative permission to add a log container, and can refer to either a dedicated or multiplexed log. /// /// /// /// The number of container path names in an array that is pointed to by rgwszContainerPath. /// This value must be nonzero. /// /// /// An array of pointers to container path names that contain cContainers pointers. /// Each path name is a wide character string that identifies a container created by either AddLogContainer or AddLogContainerSet. /// /// /// The deletion flag that determines when and how a container is deleted. /// /// If fForce is TRUE, and the container is part of the active log region, the container is not deleted and an error /// ERROR_LOG_CANT_DELETE is returned. /// /// If FALSE, the container is deleted when the container is no longer a part of the active log region. /// /// Reserved. Set pReserved to NULL. /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero. To get extended error information, call GetLastError. /// The following list identifies the possible error codes: /// /// /// /// By default, container deletion is lazy, which means that a container is deleted only if it is not part of the active log. If the /// container is part of the active log it is marked for deletion. This deletion is deferred until the tail of the log exceeds the last /// sector of the container, or the container has a logical identifier that is greater than the logical identifier of the head of the /// active log. The log size reflects the container deletion only when the container is deleted physically. /// /// /// A log client can request a forced deletion on a container by setting the deletion flag to TRUE. This has the same effect as /// deleting a container that is not part of the active log. However, if a container is part of the active log, the call fails without /// marking the container for deletion. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-removelogcontainerset CLFSUSER_API BOOL RemoveLogContainerSet( // [in] HANDLE hLog, [in] USHORT cContainer, [in] LPWSTR *rgwszContainerPath, [in] BOOL fForce, [in, out, optional] LPVOID pReserved ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.RemoveLogContainerSet")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool RemoveLogContainerSet([In] HLOG hLog, [In] ushort cContainer, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 1)] string[] rgwszContainerPath, [MarshalAs(UnmanagedType.Bool)] bool fForce, [In, Optional] IntPtr pReserved); /// Reserves space for log buffers, or appends a log record to the log, or does both. The function is atomic. /// A pointer to a marshaling context that is allocated by using the CreateLogMarshallingArea function. /// /// A pointer to an array of CLFS_WRITE_ENTRY buffers to be marshaled into one record. /// This parameter is ignored if the cWriteEntries parameter is zero. /// /// /// The number of write entries in the rgWriteEntries array. /// If this value is nonzero, you must specify a buffer in the rgWriteEntries parameter. /// /// /// A pointer to a CLFS_LSN structure that specifies the log sequence number (LSN) of the next record in the undo-chain. /// /// A pointer to a CLFS_LSN structure that specifies the LSN of the previous record in the previous-chain. /// The number of record sizes in the rgcbReservation array. /// /// A pointer to an array of reservation sizes for each record that the cReserveRecords parameter specifies. /// /// This parameter is ignored if the cReserveRecords parameter is zero. If a reservation size is negative, a reservation of that /// size is released. /// /// /// The actual space that is reserved for each record, including required overhead, is returned in the individual array elements on /// successful completion. These values can be passed to the FreeReservedLog function to adjust space that is reserved in the marshaling area. /// /// /// /// The flags that specify the behavior of this function. /// One or more of the following values can be combined. /// /// /// Value /// Meaning /// /// /// CLFS_FLAG_FORCE_APPEND /// /// Assigns a physical location for all appended records in a log that have not been previously assigned a physical location. All these /// records are made available for reading from other marshaling contexts. /// /// /// /// CLFS_FLAG_FORCE_FLUSH /// /// Assigns a physical location for all appended records in a log that have not been previously assigned a physical location. All these /// records are made available for reading from other marshaling contexts. Then, the records are flushed to disk. /// /// /// /// CLFS_FLAG_NO_FLAGS /// Assigns no flags. /// /// /// CLFS_FLAG_USE_RESERVATION /// Appends the current record by using the space that is reserved in the marshaling area. /// /// /// /// A pointer to a CLFS_LSN structure that receives the LSN of the appended record. /// /// A pointer to an OVERLAPPED structure. /// This parameter can be NULL if asynchronous operation is not used. /// /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero. To get extended error information, call the GetLastError function. /// The following list identifies the possible error codes: /// /// /// /// The LSN that is returned by the ReserveAndAppendLog function is not necessarily the next LSN that is used. The LSN that is /// returned is an estimate of the next LSN, and it varies based on which flags are specified by the fFlags parameter. The LSN /// that is returned can be used when moving the base tail. This LSN is invalidated by the next call to this function. /// /// /// If the ReserveAndAppendLog function returns ERROR_LOG_FILE_FULL, there is no more space in the log. This can be /// resolved in one of the following ways: /// /// /// /// Free any unneeded reservations. /// /// /// Advance the base LSN or the log archive tail, or both, to recycle containers. /// /// /// Add containers to the log. /// /// /// The CLFS Management API also provides a way to handle scenarios involving full logs. /// /// If the ReserveAndAppendLog function is called with a valid pOverlapped structure and the log handle is created with the /// overlapped option, then if a call to this function fails with an error code of ERROR_IO_PENDING, a pointer to a valid read /// context is placed in the variable that is pointed to by the ppvReadContext parameter. /// /// /// To complete the log record copy, the client should first synchronize its execution with deferred completion of the overlapped I/O /// operation by using the GetOverlappedResult function, or one of the synchronization Wait Functions. For more information, see /// Synchronization and Overlapped Input and Output. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-reserveandappendlog CLFSUSER_API BOOL ReserveAndAppendLog( [in] // PVOID pvMarshal, [in, optional] PCLFS_WRITE_ENTRY rgWriteEntries, [in] ULONG cWriteEntries, [in, optional] PCLFS_LSN plsnUndoNext, // [in, optional] PCLFS_LSN plsnPrevious, [in] ULONG cReserveRecords, [in, out, optional] LONGLONG [] rgcbReservation, [in] ULONG fFlags, // [out, optional] PCLFS_LSN plsn, [in, out, optional] LPOVERLAPPED pOverlapped ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.ReserveAndAppendLog")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool ReserveAndAppendLog([In] IntPtr pvMarshal, [In, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] CLS_WRITE_ENTRY[] rgWriteEntries, [In] uint cWriteEntries, in CLS_LSN plsnUndoNext, in CLS_LSN plsnPrevious, [In] uint cReserveRecords, [In, Out, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] long[] rgcbReservation, [In] CLFS_FLAG fFlags, out CLS_LSN plsn, ref NativeOverlapped pOverlapped); /// Reserves space for log buffers, or appends a log record to the log, or does both. The function is atomic. /// A pointer to a marshaling context that is allocated by using the CreateLogMarshallingArea function. /// /// A pointer to an array of CLFS_WRITE_ENTRY buffers to be marshaled into one record. /// This parameter is ignored if the cWriteEntries parameter is zero. /// /// /// The number of write entries in the rgWriteEntries array. /// If this value is nonzero, you must specify a buffer in the rgWriteEntries parameter. /// /// /// A pointer to a CLFS_LSN structure that specifies the log sequence number (LSN) of the next record in the undo-chain. /// /// A pointer to a CLFS_LSN structure that specifies the LSN of the previous record in the previous-chain. /// The number of record sizes in the rgcbReservation array. /// /// A pointer to an array of reservation sizes for each record that the cReserveRecords parameter specifies. /// /// This parameter is ignored if the cReserveRecords parameter is zero. If a reservation size is negative, a reservation of that /// size is released. /// /// /// The actual space that is reserved for each record, including required overhead, is returned in the individual array elements on /// successful completion. These values can be passed to the FreeReservedLog function to adjust space that is reserved in the marshaling area. /// /// /// /// The flags that specify the behavior of this function. /// One or more of the following values can be combined. /// /// /// Value /// Meaning /// /// /// CLFS_FLAG_FORCE_APPEND /// /// Assigns a physical location for all appended records in a log that have not been previously assigned a physical location. All these /// records are made available for reading from other marshaling contexts. /// /// /// /// CLFS_FLAG_FORCE_FLUSH /// /// Assigns a physical location for all appended records in a log that have not been previously assigned a physical location. All these /// records are made available for reading from other marshaling contexts. Then, the records are flushed to disk. /// /// /// /// CLFS_FLAG_NO_FLAGS /// Assigns no flags. /// /// /// CLFS_FLAG_USE_RESERVATION /// Appends the current record by using the space that is reserved in the marshaling area. /// /// /// /// A pointer to a CLFS_LSN structure that receives the LSN of the appended record. /// /// A pointer to an OVERLAPPED structure. /// This parameter can be NULL if asynchronous operation is not used. /// /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero. To get extended error information, call the GetLastError function. /// The following list identifies the possible error codes: /// /// /// /// The LSN that is returned by the ReserveAndAppendLog function is not necessarily the next LSN that is used. The LSN that is /// returned is an estimate of the next LSN, and it varies based on which flags are specified by the fFlags parameter. The LSN /// that is returned can be used when moving the base tail. This LSN is invalidated by the next call to this function. /// /// /// If the ReserveAndAppendLog function returns ERROR_LOG_FILE_FULL, there is no more space in the log. This can be /// resolved in one of the following ways: /// /// /// /// Free any unneeded reservations. /// /// /// Advance the base LSN or the log archive tail, or both, to recycle containers. /// /// /// Add containers to the log. /// /// /// The CLFS Management API also provides a way to handle scenarios involving full logs. /// /// If the ReserveAndAppendLog function is called with a valid pOverlapped structure and the log handle is created with the /// overlapped option, then if a call to this function fails with an error code of ERROR_IO_PENDING, a pointer to a valid read /// context is placed in the variable that is pointed to by the ppvReadContext parameter. /// /// /// To complete the log record copy, the client should first synchronize its execution with deferred completion of the overlapped I/O /// operation by using the GetOverlappedResult function, or one of the synchronization Wait Functions. For more information, see /// Synchronization and Overlapped Input and Output. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-reserveandappendlog CLFSUSER_API BOOL ReserveAndAppendLog( [in] // PVOID pvMarshal, [in, optional] PCLFS_WRITE_ENTRY rgWriteEntries, [in] ULONG cWriteEntries, [in, optional] PCLFS_LSN plsnUndoNext, // [in, optional] PCLFS_LSN plsnPrevious, [in] ULONG cReserveRecords, [in, out, optional] LONGLONG [] rgcbReservation, [in] ULONG fFlags, // [out, optional] PCLFS_LSN plsn, [in, out, optional] LPOVERLAPPED pOverlapped ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.ReserveAndAppendLog")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool ReserveAndAppendLog([In] IntPtr pvMarshal, [In, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] CLS_WRITE_ENTRY[] rgWriteEntries, [In] uint cWriteEntries, [In, Optional] IntPtr plsnUndoNext, [In, Optional] IntPtr plsnPrevious, [In] uint cReserveRecords, [In, Out, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] long[] rgcbReservation, [In] CLFS_FLAG fFlags, out CLS_LSN plsn, [In, Optional] IntPtr pOverlapped); /// /// Reserves space for log buffers, or appends a log record to the log, or both. This function is like the ReserveAndAppendLog function, /// but ReserveAndAppendLogAligned aligns the write entries of the record to the specified byte alignment. /// /// A pointer to a marshaling context that is allocated by using the CreateLogMarshallingArea function. /// /// A pointer to an array of CLFS_WRITE_ENTRY buffers to be marshaled into one record. /// This parameter is ignored if the cWriteEntries parameter is zero. /// /// /// The number of write entries in the rgWriteEntries array. /// If this value is nonzero, you must specify a buffer in the rgWriteEntries parameter. /// /// /// The byte alignment for each write entry in the rgWriteEntries parameter. /// Specify 1 (one) for a simple concatenation. The cbWriteEntryAlignment parameter must be nonzero. /// /// /// A pointer to a CLFS_LSN structure that specifies the log sequence number (LSN) of the next record in the undo-chain. /// /// A pointer to a CLFS_LSN structure that specifies the LSN of the previous record in the previous-chain. /// The number of record sizes in the rgcbReservation array. /// /// A pointer to an array of reservation sizes for each record that the cReserveRecords parameter specifies. /// /// This parameter is ignored if the cReserveRecords parameter is zero. If a reservation size is negative, a reservation of that /// size is released. /// /// /// The actual space that is reserved for each record, including required overhead, is returned in the individual array elements on /// successful completion. These values can be passed to the FreeReservedLog function to adjust space that is reserved in the marshaling area. /// /// /// /// The flags that specify the behavior of this function. /// One or more of the following values can be combined. /// /// /// Value /// Meaning /// /// /// CLFS_FLAG_FORCE_APPEND /// /// Assigns a physical location for all appended records in the log that are not previously assigned a physical location. All these /// records are made available for reading from other marshaling contexts. /// /// /// /// CLFS_FLAG_FORCE_FLUSH /// /// Assigns a physical location for all appended records in the log that are not previously assigned a physical location. All these /// records are made available for reading from other marshaling contexts. Then, the records are flushed to disk. /// /// /// /// CLFS_FLAG_NO_FLAGS /// Assigns no flags. /// /// /// CLFS_FLAG_USE_RESERVATION /// Appends the current record by using the space that is reserved in the marshaling area. /// /// /// /// A pointer to a CLFS_LSN structure that receives the LSN of the appended record. /// /// A pointer to an OVERLAPPED structure. /// This parameter can be NULL if asynchronous operation is not used. /// /// /// If the function succeeds, the return value is nonzero. /// /// If the function fails, the return value is zero. To get extended error information, call the GetLastError function. The following /// list identifies the possible error codes: /// /// /// /// /// The LSN that is returned by the ReserveAndAppendLogAligned function is not necessarily the next LSN that is used. The LSN that /// is returned is an estimate of the next LSN, and it varies based on which flags are specified by the fFlags parameter. The LSN /// that is returned can be used when moving the base tail. This LSN is invalidated by the next call to this function. /// /// /// If the ReserveAndAppendLogAligned function returns ERROR_LOG_FILE_FULL, there is no more space in the log. This can be /// resolved in one of the following ways: /// /// /// /// Free any unneeded reservations. /// /// /// Advance the base LSN or the log archive tail, or both, to recycle containers. /// /// /// Add containers to the log. /// /// /// The CLFS Management API also provides a way to handle scenarios involving full logs. /// /// If the ReserveAndAppendLogAligned function is called with a valid overlapped structure and the log handle is created /// with the overlapped option, then if a call to this function fails with an error code of ERROR_IO_PENDING, a pointer to a valid /// read context is placed in the variable that is pointed to by the ppvReadContext parameter. /// /// /// To complete the log-record copy, the client should first synchronize its execution with deferred completion of the overlapped I/O /// operation by using the GetOverlappedResult function or one of the synchronization Wait Functions. For more information, see /// Synchronization and Overlapped Input and Output. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-reserveandappendlogaligned CLFSUSER_API BOOL // ReserveAndAppendLogAligned( [in] PVOID pvMarshal, [in, optional] PCLFS_WRITE_ENTRY rgWriteEntries, [in] ULONG cWriteEntries, [in] // ULONG cbEntryAlignment, [in, optional] PCLFS_LSN plsnUndoNext, [in, optional] PCLFS_LSN plsnPrevious, [in] ULONG cReserveRecords, [in, // out, optional] LONGLONG [] rgcbReservation, [in] ULONG fFlags, [out, optional] PCLFS_LSN plsn, [in, out, optional] LPOVERLAPPED // pOverlapped ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.ReserveAndAppendLogAligned")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool ReserveAndAppendLogAligned([In] IntPtr pvMarshal, [In, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] CLS_WRITE_ENTRY[] rgWriteEntries, [In] uint cWriteEntries, [In] uint cbEntryAlignment, in CLS_LSN plsnUndoNext, in CLS_LSN plsnPrevious, [In] uint cReserveRecords, [In, Out, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 6)] long[] rgcbReservation, [In] CLFS_FLAG fFlags, out CLS_LSN plsn, ref NativeOverlapped pOverlapped); /// /// Reserves space for log buffers, or appends a log record to the log, or both. This function is like the ReserveAndAppendLog function, /// but ReserveAndAppendLogAligned aligns the write entries of the record to the specified byte alignment. /// /// A pointer to a marshaling context that is allocated by using the CreateLogMarshallingArea function. /// /// A pointer to an array of CLFS_WRITE_ENTRY buffers to be marshaled into one record. /// This parameter is ignored if the cWriteEntries parameter is zero. /// /// /// The number of write entries in the rgWriteEntries array. /// If this value is nonzero, you must specify a buffer in the rgWriteEntries parameter. /// /// /// The byte alignment for each write entry in the rgWriteEntries parameter. /// Specify 1 (one) for a simple concatenation. The cbWriteEntryAlignment parameter must be nonzero. /// /// /// A pointer to a CLFS_LSN structure that specifies the log sequence number (LSN) of the next record in the undo-chain. /// /// A pointer to a CLFS_LSN structure that specifies the LSN of the previous record in the previous-chain. /// The number of record sizes in the rgcbReservation array. /// /// A pointer to an array of reservation sizes for each record that the cReserveRecords parameter specifies. /// /// This parameter is ignored if the cReserveRecords parameter is zero. If a reservation size is negative, a reservation of that /// size is released. /// /// /// The actual space that is reserved for each record, including required overhead, is returned in the individual array elements on /// successful completion. These values can be passed to the FreeReservedLog function to adjust space that is reserved in the marshaling area. /// /// /// /// The flags that specify the behavior of this function. /// One or more of the following values can be combined. /// /// /// Value /// Meaning /// /// /// CLFS_FLAG_FORCE_APPEND /// /// Assigns a physical location for all appended records in the log that are not previously assigned a physical location. All these /// records are made available for reading from other marshaling contexts. /// /// /// /// CLFS_FLAG_FORCE_FLUSH /// /// Assigns a physical location for all appended records in the log that are not previously assigned a physical location. All these /// records are made available for reading from other marshaling contexts. Then, the records are flushed to disk. /// /// /// /// CLFS_FLAG_NO_FLAGS /// Assigns no flags. /// /// /// CLFS_FLAG_USE_RESERVATION /// Appends the current record by using the space that is reserved in the marshaling area. /// /// /// /// A pointer to a CLFS_LSN structure that receives the LSN of the appended record. /// /// A pointer to an OVERLAPPED structure. /// This parameter can be NULL if asynchronous operation is not used. /// /// /// If the function succeeds, the return value is nonzero. /// /// If the function fails, the return value is zero. To get extended error information, call the GetLastError function. The following /// list identifies the possible error codes: /// /// /// /// /// The LSN that is returned by the ReserveAndAppendLogAligned function is not necessarily the next LSN that is used. The LSN that /// is returned is an estimate of the next LSN, and it varies based on which flags are specified by the fFlags parameter. The LSN /// that is returned can be used when moving the base tail. This LSN is invalidated by the next call to this function. /// /// /// If the ReserveAndAppendLogAligned function returns ERROR_LOG_FILE_FULL, there is no more space in the log. This can be /// resolved in one of the following ways: /// /// /// /// Free any unneeded reservations. /// /// /// Advance the base LSN or the log archive tail, or both, to recycle containers. /// /// /// Add containers to the log. /// /// /// The CLFS Management API also provides a way to handle scenarios involving full logs. /// /// If the ReserveAndAppendLogAligned function is called with a valid overlapped structure and the log handle is created /// with the overlapped option, then if a call to this function fails with an error code of ERROR_IO_PENDING, a pointer to a valid /// read context is placed in the variable that is pointed to by the ppvReadContext parameter. /// /// /// To complete the log-record copy, the client should first synchronize its execution with deferred completion of the overlapped I/O /// operation by using the GetOverlappedResult function or one of the synchronization Wait Functions. For more information, see /// Synchronization and Overlapped Input and Output. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-reserveandappendlogaligned CLFSUSER_API BOOL // ReserveAndAppendLogAligned( [in] PVOID pvMarshal, [in, optional] PCLFS_WRITE_ENTRY rgWriteEntries, [in] ULONG cWriteEntries, [in] // ULONG cbEntryAlignment, [in, optional] PCLFS_LSN plsnUndoNext, [in, optional] PCLFS_LSN plsnPrevious, [in] ULONG cReserveRecords, [in, // out, optional] LONGLONG [] rgcbReservation, [in] ULONG fFlags, [out, optional] PCLFS_LSN plsn, [in, out, optional] LPOVERLAPPED // pOverlapped ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.ReserveAndAppendLogAligned")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool ReserveAndAppendLogAligned([In] IntPtr pvMarshal, [In, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] CLS_WRITE_ENTRY[] rgWriteEntries, [In] uint cWriteEntries, [In] uint cbEntryAlignment, [In, Optional] IntPtr plsnUndoNext, [In, Optional] IntPtr plsnPrevious, [In] uint cReserveRecords, [In, Out, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 6)] long[] rgcbReservation, [In] CLFS_FLAG fFlags, out CLS_LSN plsn, [In, Optional] IntPtr pOverlapped); /// Enumerates log containers. Call this function repeatedly to iterate over all log containers. /// /// A pointer to a client-allocated CLFS_SCAN_CONTEXT structure that the CreateLogContainerScanContext function initializes. /// /// /// The mode for containers to be scanned. /// Containers can be scanned in any of the following CLFS_SCAN_MODE modes. /// /// /// Value /// Meaning /// /// /// CLFS_SCAN_INIT /// /// Reinitializes the scan context, but does not allocate associated storage. The initialization is destructive, because all data that is /// stored in the current scan context is lost. /// /// /// /// CLFS_SCAN_CLOSE /// Uninitializes the scan context, and deallocates system storage that is associated with a scan context. /// /// /// CLFS_SCAN_FORWARD /// /// Causes the next call to ScanLogContainers to proceed in a forward direction. Cannot be used if CLFS_SCAN_BACKWARD is specified. /// /// /// /// CLFS_SCAN_BACKWARD /// /// Causes the next call to ScanLogContainers to proceed in a backward direction. Cannot be used if CLFS_SCAN_FORWARD is specified. /// /// /// /// /// Reserved. Set pReserved to NULL. /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero. To get extended error information, call GetLastError. /// The following list identifies the possible error codes: /// /// /// The ID of a log container is returned in: pcxScan->pinfoContainer->LogicalContainerId. /// /// Note The Common Log File System (CLFS) scan contexts are not thread-safe. They should not be used by more than one thread at a /// time, or passed into more than one asynchronous scan at a time. /// /// Examples /// For an example that uses this function, see Enumerating Log Containers. /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-scanlogcontainers CLFSUSER_API BOOL ScanLogContainers( [in, out] // PCLFS_SCAN_CONTEXT pcxScan, [in] CLFS_SCAN_MODE eScanMode, [in, out, optional] LPVOID pReserved ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.ScanLogContainers")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool ScanLogContainers(ref CLS_SCAN_CONTEXT pcxScan, [In] CLFS_SCAN_MODE eScanMode, [In, Optional] IntPtr pReserved); /// This function has been deprecated. Use TruncateLog instead. /// /// A handle to the log that is obtained from CreateLogFile. /// The log handle must refer to a dedicated log. /// /// /// A pointer to a CLFS_LSN structure that specifies the new end of a log. /// The LSN must be between the base log sequence number (LSN) of the log and the last LSN of the log. /// /// Reserved. Set lpOverlapped to NULL. /// /// If the function succeeds, the return value is nonzero. /// /// If the function fails, the return value is zero. To get extended error information, call GetLastError. The following list identifies /// the possible error codes: /// /// /// /// /// The SetEndOfLog function truncates the log by setting the end of the log to the specified value. This operation only works on /// dedicated logs. /// /// SetEndOfLog can only be used to truncate a log. /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-setendoflog CLFSUSER_API BOOL SetEndOfLog( [in] HANDLE hLog, // [in] PCLFS_LSN plsnEnd, [in, out, optional] LPOVERLAPPED lpOverlapped ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.SetEndOfLog")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetEndOfLog([In] HLOG hLog, in CLS_LSN plsnEnd, [In, Optional] IntPtr lpOverlapped); /// Enables or disables log archive support for a specified log. /// A handle to the log that is obtained from CreateLogFile. /// /// Specifies whether to make the log ephemeral. This parameter can be one of the following values. /// /// /// Value /// Meaning /// /// /// ClfsLogArchiveEnabled /// Enable log archive (ephemeral logs) support. /// /// /// ClfsLogArchiveDisabled /// Disables ephemeral logs. /// /// /// /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero (0). To get extended error information, call GetLastError. /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-setlogarchivemode CLFSUSER_API BOOL SetLogArchiveMode( [in] // HANDLE hLog, [in] CLFS_LOG_ARCHIVE_MODE eMode ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.SetLogArchiveMode")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetLogArchiveMode([In] HLOG hLog, [In] CLFS_LOG_ARCHIVE_MODE eMode); /// Sets the last archived log sequence number (LSN) or archive tail of an archivable log. /// /// A handle to the log that is obtained from CreateLogFile. /// The log handle can refer to a dedicated or multiplexed log. /// /// /// A pointer to a CLFS_LSN structure that specifies a valid physical LSN in the log. /// /// Note For handles to both a physical log or a log stream, plsnArchiveTail is a physical LSN, because it refers to a /// record address in the physical log. /// /// /// This parameter is reserved and should be set to NULL. /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero. To get extended error information, call GetLastError. /// The following list identifies the possible error codes: /// /// /// If there are any archive contexts obtained from PrepareLogArchive that are not terminated with TerminateLogArchive, the change does /// not take effect until all archives are complete. While there are outstanding archive contexts, only the greatest archive tail is applied. /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-setlogarchivetail CLFSUSER_API BOOL SetLogArchiveTail( [in] // HANDLE hLog, [in] PCLFS_LSN plsnArchiveTail, [in, out, optional] LPVOID pReserved ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.SetLogArchiveTail")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetLogArchiveTail([In] HLOG hLog, in CLS_LSN plsnArchiveTail, [In, Optional] IntPtr pReserved); /// Deallocates system resources that are allocated originally for a log archive context by PrepareLogArchive. /// The archive context that is obtained from PrepareLogArchive. /// /// If the function succeeds, the return value is nonzero. /// /// If the function fails, the return value is zero. To get extended error information, call GetLastError. The following error code is possible: /// /// /// Failure to call this function after archiving completes results in a resource leak. // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-terminatelogarchive CLFSUSER_API BOOL TerminateLogArchive( [in] // CLFS_LOG_ARCHIVE_CONTEXT pvArchiveContext ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.TerminateLogArchive")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool TerminateLogArchive([In] IntPtr pvArchiveContext); /// /// Terminates a read context. This function frees system-allocated resources associated with the specified read context. Do not attempt /// to read log records after calling this function; you will receive indeterminate results. /// /// A pointer to a read context that is returned by ReadLogRecord or ReadLogRestartArea. /// /// If the function succeeds, the return value is nonzero. /// /// If the function fails, the return value is zero. To get extended error information, call GetLastError. The following list identifies /// the possible error codes: /// /// /// It is important to deallocate unused read contexts. Failure to call this function causes resource leaks. // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-terminatereadlog CLFSUSER_API BOOL TerminateReadLog( [in] PVOID // pvCursorContext ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.TerminateReadLog")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool TerminateReadLog([In] IntPtr pvCursorContext); /// Truncates the log. The function sets the end of the log to the specified value. /// A pointer to the opaque marshaling context that is allocated by calling the CreateLogMarshallingArea function. /// /// A pointer to a CLFS_LSN structure that specifies the new end of a log. /// The LSN must be between the base log sequence number (LSN) of the log and the last LSN of the log. /// /// Reserved. Set Reserved to NULL. /// /// If the function succeeds, the return value is nonzero. /// /// If the function fails, the return value is zero. To get extended error information, call GetLastError. The following list identifies /// the possible error codes: /// /// /// If the volume sector size is greater than 512 bytes, TruncateLog returns ERROR_NOT_SUPPORTED. // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-truncatelog CLFSUSER_API BOOL TruncateLog( [in] PVOID pvMarshal, // [in] PCLFS_LSN plsnEnd, [in, out, optional] LPOVERLAPPED lpOverlapped ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.TruncateLog")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool TruncateLog([In] IntPtr pvMarshal, in CLS_LSN plsnEnd, [In, Optional] IntPtr lpOverlapped); /// Validates the consistency of the log metadata and data before log archive and after log restore. /// /// The name of the log. /// The name is specified when creating the log by using CreateLogFile. The following example identifies the format to use: /// Log:<LogName>[::<LogStreamName>] /// <LogName> corresponds to a valid file path in the file system. /// <LogStreamName> is the unique name of a log stream in the dedicated log. /// For more information, see Log Types. /// /// /// A pointer to a SECURITY_ATTRIBUTES structure that specifies the security attributes of a log. /// This parameter can be NULL. /// /// A pointer to a CLFS_INFORMATION structure that receives log metadata. /// /// A pointer to a variable that, on input, specifies the size of the pinfoBuffer metadata buffer, in bytes. /// On output, it receives the amount of information that is copied to the buffer, in bytes. /// /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero. To get extended error information, call GetLastError. /// The following list identifies the possible error codes: /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-validatelog CLFSUSER_API BOOL ValidateLog( [in] LPCWSTR // pszLogFileName, [in, optional] LPSECURITY_ATTRIBUTES psaLogFile, [out, optional] PCLFS_INFORMATION pinfoBuffer, [in, out] PULONG // pcbBuffer ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.ValidateLog")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool ValidateLog([MarshalAs(UnmanagedType.LPWStr)] string pszLogFileName, [In, Optional] SECURITY_ATTRIBUTES psaLogFile, [Out] SafeCoTaskMemStruct pinfoBuffer, ref uint pcbBuffer); /// /// Appends a new client restart area to a log, and optionally advances the base log sequence number (LSN) of the log. /// /// After it is successfully written to a disk, the last LSN of the log is changed to the LSN of the appended restart record. Typically, /// WriteLogRestartArea is used by applications that regularly save a known good state, and the restart area contains the LSNs for /// existing log record chains. /// /// /// A pointer to the marshaling context that is allocated by using the CreateLogMarshallingArea function. /// A pointer to a buffer that contains restart data. /// The size of pvRestartBuffer, in bytes. /// /// A pointer to a CLFS_LSN structure that specifies the new base LSN of the log after successfully writing the restart area. /// /// This value cannot be outside the range of the active log. It must be at least the value of the current base LSN, and not greater than /// the LSN that was returned in the lastLSN parameter from the latest call to ReserveAndAppendLog. If you omit this optional /// parameter, the base LSN does not change. /// /// /// /// The flags that specify the behavior of this function. /// One or more of the following values can be combined. /// /// /// Value /// Meaning /// /// /// CLFS_FLAG_NO_FLAGS /// Assigns no flags. /// /// /// CLFS_FLAG_USE_RESERVATION /// Appends the current record by using the space that is reserved in the marshaling area. /// /// /// /// A pointer to a variable that receives the number of bytes that are written when an operation completes. /// A pointer to a CLFS_LSN structure that specifies the LSN of the restart area that is written. /// /// A pointer to an OVERLAPPED structure. /// This parameter can be NULL if an asynchronous operation is not used. /// /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero. To get extended error information, call GetLastError. /// The following list identifies the possible error codes: /// /// /// The WriteLogRestartArea causes both a flush of all current buffered log records and a flush of the log metadata. /// /// If a client calls WriteLogRestartArea on a log that is created to support asynchronous operations (for example, if the /// fFlagsAndAttributes parameter of CreateLogFile is set to FILE_FLAG_OVERLAPPED when the log is created), the client must /// supply a pointer to a valid OVERLAPPED structure in the pOverlapped parameter of WriteLogRestartArea. /// /// /// Then, if WriteLogRestartArea fails with an error of ERROR_IO_PENDING, a pointer to a valid read context is placed in /// the variable that is pointed to by the ppvReadContext parameter. /// /// /// To complete the call, the client should synchronize its execution with deferred completion of the overlapped I/O operation by using /// GetOverlappedResult or one of the synchronization Wait Functions. For more information, see Synchronization and Overlapped Input and Output. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-writelogrestartarea CLFSUSER_API BOOL WriteLogRestartArea( [in, // out] PVOID pvMarshal, [in] PVOID pvRestartBuffer, [in] ULONG cbRestartBuffer, [in, optional] PCLFS_LSN plsnBase, [in] ULONG fFlags, // [out, optional] PULONG pcbWritten, [out, optional] PCLFS_LSN plsnNext, [in, out, optional] LPOVERLAPPED pOverlapped ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.WriteLogRestartArea")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool WriteLogRestartArea([In, Out] IntPtr pvMarshal, [In] IntPtr pvRestartBuffer, [In] uint cbRestartBuffer, in CLS_LSN plsnBase, [In] CLFS_FLAG fFlags, out uint pcbWritten, out CLS_LSN plsnNext, ref NativeOverlapped pOverlapped); /// /// Appends a new client restart area to a log, and optionally advances the base log sequence number (LSN) of the log. /// /// After it is successfully written to a disk, the last LSN of the log is changed to the LSN of the appended restart record. Typically, /// WriteLogRestartArea is used by applications that regularly save a known good state, and the restart area contains the LSNs for /// existing log record chains. /// /// /// A pointer to the marshaling context that is allocated by using the CreateLogMarshallingArea function. /// A pointer to a buffer that contains restart data. /// The size of pvRestartBuffer, in bytes. /// /// A pointer to a CLFS_LSN structure that specifies the new base LSN of the log after successfully writing the restart area. /// /// This value cannot be outside the range of the active log. It must be at least the value of the current base LSN, and not greater than /// the LSN that was returned in the lastLSN parameter from the latest call to ReserveAndAppendLog. If you omit this optional /// parameter, the base LSN does not change. /// /// /// /// The flags that specify the behavior of this function. /// One or more of the following values can be combined. /// /// /// Value /// Meaning /// /// /// CLFS_FLAG_NO_FLAGS /// Assigns no flags. /// /// /// CLFS_FLAG_USE_RESERVATION /// Appends the current record by using the space that is reserved in the marshaling area. /// /// /// /// A pointer to a variable that receives the number of bytes that are written when an operation completes. /// A pointer to a CLFS_LSN structure that specifies the LSN of the restart area that is written. /// /// A pointer to an OVERLAPPED structure. /// This parameter can be NULL if an asynchronous operation is not used. /// /// /// If the function succeeds, the return value is nonzero. /// If the function fails, the return value is zero. To get extended error information, call GetLastError. /// The following list identifies the possible error codes: /// /// /// The WriteLogRestartArea causes both a flush of all current buffered log records and a flush of the log metadata. /// /// If a client calls WriteLogRestartArea on a log that is created to support asynchronous operations (for example, if the /// fFlagsAndAttributes parameter of CreateLogFile is set to FILE_FLAG_OVERLAPPED when the log is created), the client must /// supply a pointer to a valid OVERLAPPED structure in the pOverlapped parameter of WriteLogRestartArea. /// /// /// Then, if WriteLogRestartArea fails with an error of ERROR_IO_PENDING, a pointer to a valid read context is placed in /// the variable that is pointed to by the ppvReadContext parameter. /// /// /// To complete the call, the client should synchronize its execution with deferred completion of the overlapped I/O operation by using /// GetOverlappedResult or one of the synchronization Wait Functions. For more information, see Synchronization and Overlapped Input and Output. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/clfsw32/nf-clfsw32-writelogrestartarea CLFSUSER_API BOOL WriteLogRestartArea( [in, // out] PVOID pvMarshal, [in] PVOID pvRestartBuffer, [in] ULONG cbRestartBuffer, [in, optional] PCLFS_LSN plsnBase, [in] ULONG fFlags, // [out, optional] PULONG pcbWritten, [out, optional] PCLFS_LSN plsnNext, [in, out, optional] LPOVERLAPPED pOverlapped ); [DllImport(Lib_Clfsw32, SetLastError = true, ExactSpelling = true)] [PInvokeData("clfsw32.h", MSDNShortId = "NF:clfsw32.WriteLogRestartArea")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool WriteLogRestartArea([In, Out] IntPtr pvMarshal, [In] IntPtr pvRestartBuffer, [In] uint cbRestartBuffer, [In, Optional] IntPtr plsnBase, [In] CLFS_FLAG fFlags, out uint pcbWritten, out CLS_LSN plsnNext, [In, Optional] IntPtr pOverlapped); /// Provides a handle to a log file. [StructLayout(LayoutKind.Sequential)] public struct HLOG : IKernelHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HLOG(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HLOG NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Implements the operator !. /// The handle. /// The result of the operator. public static bool operator !(HLOG h1) => h1.IsNull; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HLOG h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HLOG(IntPtr h) => new(h); /// Performs an implicit conversion from to . /// The safe handle. /// The result of the conversion. public static implicit operator HLOG(Microsoft.Win32.SafeHandles.SafeFileHandle h) => new(h.DangerousGetHandle()); /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HLOG h1, HLOG h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HLOG h1, HLOG h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HLOG h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a for an archive context that is disposed using . public class SafeArchiveContext : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. /// /// to reliably release the handle during the finalization phase; otherwise, (not recommended). /// public SafeArchiveContext(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { } /// Initializes a new instance of the class. private SafeArchiveContext() : base() { } /// protected override bool InternalReleaseHandle() => TerminateLogArchive(handle); } /// Provides a for that is disposed using . public class SafeHLOG : SafeHANDLE, IKernelHandle { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. /// /// to reliably release the handle during the finalization phase; otherwise, (not recommended). /// public SafeHLOG(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { } /// Initializes a new instance of the class. private SafeHLOG() : base() { } /// Performs an implicit conversion from to . /// The safe handle instance. /// The result of the conversion. public static implicit operator HLOG(SafeHLOG h) => h.handle; /// protected override bool InternalReleaseHandle() => CloseHandle(handle); } }