Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

ntfsexp.h

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1995 Microsoft Corporation 00004 00005 Module Name: 00006 00007 NtfsExp.h 00008 00009 Abstract: 00010 00011 This module defines the exports from NtOfs.SYS for use exclusively by 00012 Transactions and Encryption. 00013 00014 ********************************* 00015 *No other clients are supported.* 00016 ********************************* 00017 00018 Author: 00019 00020 Mark Zbikowski [MarkZ] 7-Dec-1995 00021 Jeff Havens [JHavens] 00022 Brian Andrew [BrianAn] 00023 Gary Kimura [GaryKi] 00024 Tom Miller [TomM] 00025 00026 Revision History: 00027 00028 00029 --*/ 00030 00031 #ifndef _NTFS_ 00032 00033 // 00034 // The MFT Segment Reference is an address in the MFT tagged with 00035 // a circularly reused sequence number set at the time that the MFT 00036 // Segment Reference was valid. Note that this format limits the 00037 // size of the Master File Table to 2**48 segments. So, for 00038 // example, with a 1KB segment size the maximum size of the master 00039 // file would be 2**58 bytes, or 2**28 gigabytes. 00040 // 00041 00042 typedef struct _FILE_REFERENCE { 00043 00044 // 00045 // First a 48 bit segment number. 00046 // 00047 00048 ULONG SegmentNumberLowPart; // offset = 0x000 00049 USHORT SegmentNumberHighPart; // offset = 0x004 00050 00051 // 00052 // Now a 16 bit nonzero sequence number. A value of 0 is 00053 // reserved to allow the possibility of a routine accepting 00054 // 0 as a sign that the sequence number check should be 00055 // repressed. 00056 // 00057 00058 USHORT SequenceNumber; // offset = 0x006 00059 00060 } FILE_REFERENCE, *PFILE_REFERENCE; // sizeof = 0x008 00061 00062 #endif 00063 00064 // 00065 // Big picture view of the interaction between extensions and NtOfs: 00066 // 00067 // NtOfs exports a number of interfaces that give abstract access to 00068 // on-disk structures and attempt to hide, as much as possible, the 00069 // implementation details. 00070 // 00071 // V/Q/X are implemented as DLL's that link to NtOfs.Sys. NtOfs can load 00072 // and function in absence of these DLL's. 00073 // 00074 // All communication between user-mode code and V/Q/X occurs via the 00075 // Nt Io API which is routed through NtOfs. Client code will open either 00076 // an NtOfs Volume, Directory, or File and will issue NtIo calls to the 00077 // resultant handle. 00078 // 00079 // NtOfs will create an IrpContext, decode the file object appropriately, 00080 // and call out to entry points in V/Q/X that are registered at load-time. 00081 // 00082 // V/Q/X will perform whatever actions are necessary utilizing NtOfs exports 00083 // and then return from the original call from NtOfs an NTSTATUS code. NtOfs 00084 // will perform the appropriate CompleteIrp calls, posting for STATUS_PENDING, 00085 // etc. 00086 // 00087 // No exceptions can be raised across the NtOfs export or NtOfs import 00088 // interfaces. All user-buffer access and validation will occur in the 00089 // code that uses it. Since user buffers may disappear at any time, any 00090 // client of these buffers must wrap access to the buffers in an exception 00091 // clause. 00092 // 00093 // V/Q/X may perform activities in threads separate from the original 00094 // requestor. For these cases, NtOfs will provide a means where calls separate 00095 // from a user-mode request can be accepted. Typically, this means "cloning" 00096 // an IrpContext. 00097 // 00098 00099 // 00100 // Opaque handle definitions. 00101 // 00102 00103 // 00104 // ISSUE: Most NtOfs internal routines rely on having an IrpContext passed in 00105 // along with FCB and SCB pointers. Rather than exposing FCB and IrpContext 00106 // as separate contexts, should we wrap these up into a separate structure and 00107 // pass it along? 00108 // 00109 00110 typedef struct _FCB *OBJECT_HANDLE; 00111 typedef struct _SCB *ATTRIBUTE_HANDLE; 00112 typedef struct _SCB *INDEX_HANDLE; 00113 typedef struct _READ_CONTEXT *PREAD_CONTEXT; 00114 typedef ULONG SECURITY_ID; 00115 typedef struct _CI_CALL_BACK CI_CALL_BACK, *PCI_CALL_BACK; 00116 typedef struct _VIEW_CALL_BACK VIEW_CALL_BACK, *PVIEW_CALL_BACK; 00117 typedef struct _IRP_CONTEXT *PIRP_CONTEXT; 00118 00119 // 00120 // Map Handle. This structure defines a byte range of the file which is mapped 00121 // or pinned, and stores the Bcb returned from the Cache Manager. 00122 // 00123 00124 typedef struct _MAP_HANDLE { 00125 00126 // 00127 // Range being mapped or pinned 00128 // 00129 00130 LONGLONG FileOffset; 00131 ULONG Length; 00132 00133 // 00134 // Virtual address corresponding to FileOffset 00135 // 00136 00137 PVOID Buffer; 00138 00139 // 00140 // Bcb pointer returned from Cache Manager 00141 // 00142 00143 PVOID Bcb; 00144 00145 } MAP_HANDLE, *PMAP_HANDLE; 00146 00147 // 00148 // Quick Index Hint. This is stream offset information returned by 00149 // NtOfsFindRecord, and taken as input to NtOfsUpdateRecord, to allow 00150 // quick updates to index records in the event that they have not 00151 // moved. This structure must always have the same size and alignment 00152 // as QUICK_INDEX in ntfsstru.h. 00153 // 00154 00155 typedef struct _QUICK_INDEX_HINT { 00156 LONGLONG HintData[3]; 00157 } QUICK_INDEX_HINT, *PQUICK_INDEX_HINT; 00158 00159 // 00160 // Index structures 00161 // 00162 00163 typedef struct { 00164 ULONG KeyLength; 00165 PVOID Key; 00166 } INDEX_KEY, *PINDEX_KEY; 00167 00168 typedef struct { 00169 ULONG DataLength; 00170 PVOID Data; 00171 } INDEX_DATA, *PINDEX_DATA; 00172 00173 typedef struct { 00174 INDEX_KEY KeyPart; 00175 INDEX_DATA DataPart; 00176 } INDEX_ROW, *PINDEX_ROW; 00177 00178 // 00179 // COLLATION_FUNCTION returns LessThan if Key1 precedes Key2 00180 // EqualTo if Key1 is identical to Key2 00181 // GreaterThan if Key1 follows Key2 00182 // 00183 00184 typedef FSRTL_COMPARISON_RESULT (*PCOLLATION_FUNCTION) ( 00185 IN PINDEX_KEY Key1, 00186 IN PINDEX_KEY Key2, 00187 IN PVOID CollationData 00188 ); 00189 00190 typedef struct _UPCASE_TABLE_AND_KEY { 00191 00192 // 00193 // Pointer to a table of upcased unicode characters indexed by character to 00194 // be upcased. 00195 // 00196 00197 PWCH UpcaseTable; 00198 00199 // 00200 // Size of UpcaseTable in unicode characters 00201 // 00202 00203 ULONG UpcaseTableSize; 00204 00205 // 00206 // Optional addtional pointer. 00207 // 00208 00209 INDEX_KEY Key; 00210 00211 } UPCASE_TABLE_AND_KEY, *PUPCASE_TABLE_AND_KEY; 00212 00213 // 00214 // Wait for new length block used to synchronize a thread with FileSize 00215 // exceeding the specified Length. 00216 // 00217 00218 typedef struct _WAIT_FOR_NEW_LENGTH { 00219 00220 // 00221 // Link words for multiple waiters on the Scb. 00222 // 00223 00224 LIST_ENTRY WaitList; 00225 00226 // 00227 // Set event when FileSize exceeds this length. 00228 // 00229 00230 LONGLONG Length; 00231 00232 // 00233 // Event to set when new length achieved. 00234 // 00235 00236 KEVENT Event; 00237 00238 // 00239 // Irp to complete when new length achieved. (If Irp present, Event is 00240 // ignored.) 00241 // 00242 00243 PIRP Irp; 00244 00245 // 00246 // Stream we are waiting on. 00247 // 00248 00249 ATTRIBUTE_HANDLE Stream; 00250 00251 // 00252 // Status code for operation that caused the new length to be satisfied. 00253 // It may be STATUS_CANCELLED, STATUS_TIMEOUT or STATUS_SUCCESS 00254 // or a request specific status. 00255 // 00256 00257 NTSTATUS Status; 00258 00259 // 00260 // Flags. 00261 // 00262 00263 ULONG Flags; 00264 00265 } WAIT_FOR_NEW_LENGTH, *PWAIT_FOR_NEW_LENGTH; 00266 00267 #define NTFS_WAIT_FLAG_ASYNC (0x00000001) 00268 00269 // 00270 // Standard collation functions for simple indices 00271 // 00272 00273 FSRTL_COMPARISON_RESULT 00274 NtOfsCollateUlong ( // Both must be single Ulong 00275 IN PINDEX_KEY Key1, 00276 IN PINDEX_KEY Key2, 00277 IN PVOID CollationData // Don't care, may be NULL 00278 ); 00279 00280 FSRTL_COMPARISON_RESULT 00281 NtOfsCollateUlongs ( // Lengths do not have to be equal 00282 IN PINDEX_KEY Key1, 00283 IN PINDEX_KEY Key2, 00284 IN PVOID CollationData // Don't care, may be NULL 00285 ); 00286 00287 FSRTL_COMPARISON_RESULT 00288 NtOfsCollateSid ( 00289 IN PINDEX_KEY Key1, 00290 IN PINDEX_KEY Key2, 00291 IN PVOID CollationData // Don't care, may be NULL 00292 ); 00293 00294 FSRTL_COMPARISON_RESULT 00295 NtOfsCollateUnicode ( 00296 IN PINDEX_KEY Key1, 00297 IN PINDEX_KEY Key2, 00298 IN PVOID CollationData // PUPCASE_TABLE_AND_KEY (with no key) 00299 ); 00300 00301 // 00302 // Standard match functions for simple indices 00303 // 00304 00305 NTSTATUS 00306 NtOfsMatchAll ( 00307 IN PINDEX_ROW IndexRow, 00308 IN OUT PVOID MatchData // Don't care, may be NULL 00309 ); 00310 00311 NTSTATUS 00312 NtOfsMatchUlongExact ( 00313 IN PINDEX_ROW IndexRow, // Both must be single Ulong 00314 IN OUT PVOID MatchData // PINDEX_KEY describing Ulong 00315 ); 00316 00317 NTSTATUS 00318 NtOfsMatchUlongsExact ( // Lengths do not have to be equal 00319 IN PINDEX_ROW IndexRow, 00320 IN OUT PVOID MatchData // PINDEX_KEY describing Ulongs 00321 ); 00322 00323 NTSTATUS 00324 NtOfsMatchUnicodeExpression ( 00325 IN PINDEX_ROW IndexRow, 00326 IN OUT PVOID MatchData // PUPCASE_TABLE_AND_KEY with Uni expression (must have wildcards) 00327 ); 00328 00329 NTSTATUS 00330 NtOfsMatchUnicodeString ( 00331 IN PINDEX_ROW IndexRow, 00332 IN OUT PVOID MatchData // PUPCASE_TABLE_AND_KEY with Uni string (no wildcards) 00333 ); 00334 00335 // 00336 // MATCH_FUNCTION returns 00337 // STATUS_SUCCESS if the IndexRow matches 00338 // STATUS_NO_MATCH if the IndexRow does not match, but the enumeration should 00339 // continue 00340 // STATUS_NO_MORE_MATCHES if the IndexRow does not match, and the enumeration 00341 // should terminate 00342 // 00343 00344 typedef NTSTATUS (*PMATCH_FUNCTION) (IN PINDEX_ROW IndexRow, IN OUT PVOID MatchData); 00345 00346 // 00347 // CREATE_OPTIONS - common flags governing creation/opening of objects 00348 // 00349 00350 typedef enum _CREATE_OPTIONS 00351 { 00352 CREATE_NEW = 0, 00353 CREATE_OR_OPEN = 1, 00354 OPEN_EXISTING = 2 00355 } CREATE_OPTIONS; 00356 00357 00358 // 00359 // EXCLUSION - Form of exclusion desired when opening an object 00360 // 00361 00362 typedef enum _EXCLUSION 00363 { 00364 SHARED = 0, 00365 EXCLUSIVE 00366 } EXCLUSION; 00367 00368 00369 00370 // 00371 // Additional Dos Attribute indicating Content Index status of an object. 00372 // If this is set on a document, it suppresses indexing. It is inherited 00373 // from a parent directory at create time. This is stored in the 00374 // DUPLICATED_INFORMATION structure. 00375 // 00376 00377 #define SUPPRESS_CONTENT_INDEX (0x20000000) 00378 00379 // 00380 // Define the size of the index buffer/bucket for view indexes, in bytes. 00381 // 00382 00383 #define NTOFS_VIEW_INDEX_BUFFER_SIZE (0x1000) 00384 00385 // 00386 // Exported constants. 00387 // 00388 00389 // 00390 // NtOfsContentIndexSystemFile is the repository for all CI related data on the 00391 // disk. 00392 00393 extern FILE_REFERENCE NtOfsContentIndexSystemFile; 00394 00395 #if defined(_NTFSPROC_) 00396 00397 #define NTFSAPI 00398 00399 #else 00400 00401 #define NTFSAPI DECLSPEC_IMPORT 00402 00403 #endif 00404 00405 00406 00407 // 00408 // Index API - These encapsulate the NtOfs BTree mechanisms. 00409 // 00410 00411 // 00412 // NtOfsCreateIndex creates or opens a named index attribute in an object. The 00413 // ObjectHandle has been acquired exclusive and the returned handle is not 00414 // acquired. The collation data is interpreted only by the CollationFunction. 00415 // 00416 // IndexHandles retain a "seek" position where enumerations (NtOfsReadRecords) 00417 // may continue. This seek position may be updated by the routines as described 00418 // below. 00419 // 00420 // If DeleteCollationData is 1, ExFreePool will be called on CollationData, either 00421 // immediately if the index already exists, or when the index is deleted some time 00422 // after the final close. If NtOfsCreateIndex returns an error, then CollationData 00423 // must be deleted by the caller. If specified as 0, then ColloationData will not 00424 // be deleted. 00425 // 00426 00427 NTFSAPI 00428 NTSTATUS 00429 NtOfsCreateIndex ( 00430 IN PIRP_CONTEXT IrpContext, 00431 IN OBJECT_HANDLE ObjectHandle, 00432 IN UNICODE_STRING Name, 00433 IN CREATE_OPTIONS CreateOptions, 00434 IN ULONG DeleteCollationData, 00435 IN ULONG CollationRule, 00436 IN PCOLLATION_FUNCTION CollationFunction, 00437 IN PVOID CollationData OPTIONAL, 00438 OUT INDEX_HANDLE *IndexHandle 00439 ); 00440 00441 00442 // 00443 // NtOfsFindRecord finds a single record in an index stream for read-only access 00444 // or in preparation for calling NtOfsUpdateRecord. 00445 // 00446 00447 NTFSAPI 00448 NTSTATUS 00449 NtOfsFindRecord ( 00450 IN PIRP_CONTEXT IrpContext, 00451 IN INDEX_HANDLE IndexHandle, 00452 IN PINDEX_KEY IndexKey, 00453 OUT PINDEX_ROW IndexRow, 00454 OUT PMAP_HANDLE MapHandle, 00455 IN OUT PQUICK_INDEX_HINT QuickIndexHint OPTIONAL 00456 ); 00457 00458 // 00459 // NtOfsFindRecord finds a single record in an index stream for read-only access 00460 // or in preparation for calling NtOfsUpdateRecord. 00461 // 00462 00463 NTFSAPI 00464 NTSTATUS 00465 NtOfsFindLastRecord ( 00466 IN PIRP_CONTEXT IrpContext, 00467 IN INDEX_HANDLE IndexHandle, 00468 IN PINDEX_KEY MaxIndexKey, 00469 OUT PINDEX_ROW IndexRow, 00470 OUT PMAP_HANDLE MapHandle 00471 ); 00472 00473 // 00474 // NtOfsAddRecords performs bulk, logged inserts into an index. The index will 00475 // be acquired exclusive for this call. Each record added must have a unique 00476 // (with regards to the collation function) key. No maps are currently 00477 // outstanding on this index. If SequentialInsertMode is nonzero, this is a hint 00478 // to the index package to keep all BTree buffers as full as possible, by splitting 00479 // as close to the end of the buffer as possible. If specified as zero, random 00480 // inserts are assumed, and buffers are always split in the middle for better balance. 00481 // 00482 // This call may update the IndexHandle seek position 00483 // 00484 00485 NTFSAPI 00486 VOID 00487 NtOfsAddRecords ( 00488 IN PIRP_CONTEXT IrpContext, 00489 IN INDEX_HANDLE IndexHandle, 00490 IN ULONG Count, 00491 IN PINDEX_ROW IndexRow, 00492 IN ULONG SequentialInsertMode 00493 ); 00494 00495 // 00496 // NtOfsDeleteRecords performs bulk, logged deletion from an index. The index 00497 // will be acquired exclusive for this call. No maps are currently outstanding 00498 // on this index. 00499 // 00500 // This call may update the IndexHandle seek position 00501 // 00502 00503 NTFSAPI 00504 VOID 00505 NtOfsDeleteRecords ( 00506 IN PIRP_CONTEXT IrpContext, 00507 IN INDEX_HANDLE IndexHandle, 00508 IN ULONG Count, 00509 IN PINDEX_KEY IndexKey 00510 ); 00511 00512 // 00513 // NtOfsReadRecords applies a match function to a block of contiguous records in 00514 // the BTree starting either at a given IndexKey or beginning where it last left 00515 // off. 00516 // 00517 // IndexKey is an optional point at which to begin the enumeration. The 00518 // seek position of IndexHandle is set to return the next logical record 00519 // on the next NtOfsReadRecords call. 00520 // 00521 // NtOfsReadRecords will seek to the appropriate point in the BTree (as defined 00522 // by the IndexKey or saved position and the CollateFunction) and begin calling 00523 // MatchFunction for each record. It continues doing this while MatchFunction 00524 // returns STATUS_SUCCESS. If MatchFunction returns STATUS_NO_MORE_MATCHES, 00525 // NtOfsReadRecords will cache this result and not call MatchFunction again until 00526 // called with a non-NULL IndexKey. 00527 // 00528 // NtOfsReadRecords returns the last status code returned by MatchFunction. 00529 // 00530 // The IndexHandle does not have to be acquired as it is acquired shared for the 00531 // duration of the call. NtOfsReadRecords may 00532 // return with STATUS_SUCCESS without filling the output buffer (say, every 10 00533 // index pages) to reduce lock contention. 00534 // 00535 // NtOfsReadRecords will read up to Count rows, comprising up to BufferLength 00536 // bytes in total and will fill in the Rows[] array for each row returned. 00537 // 00538 // Note that this call is self-synchronized, such that successive calls to 00539 // the routine are guaranteed to make progress through the index and to return 00540 // items in Collation order, in spite of Add and Delete record calls being 00541 // interspersed with Read records calls. 00542 // 00543 00544 NTFSAPI 00545 NTSTATUS 00546 NtOfsReadRecords ( 00547 IN PIRP_CONTEXT IrpContext, 00548 IN INDEX_HANDLE IndexHandle, 00549 IN OUT PREAD_CONTEXT *ReadContext, 00550 IN OPTIONAL PINDEX_KEY IndexKey, 00551 IN PMATCH_FUNCTION MatchFunction, 00552 IN PVOID MatchData, 00553 IN OUT ULONG *Count, 00554 OUT PINDEX_ROW Rows, 00555 IN ULONG BufferLength, 00556 OUT PVOID Buffer 00557 ); 00558 00559 NTFSAPI 00560 VOID 00561 NtOfsFreeReadContext ( 00562 IN PREAD_CONTEXT ReadContext 00563 ); 00564 00565 // 00566 // NtOfsUpdateRecord updates a single record in place. It is guaranteed that the 00567 // length of the data/key portion of the record does not change. The index will 00568 // be acquired exclusive for this call. 00569 // 00570 // This call may update the IndexHandle seek position 00571 // 00572 00573 NTFSAPI 00574 VOID 00575 NtOfsUpdateRecord ( 00576 IN PIRP_CONTEXT IrpContext, 00577 IN INDEX_HANDLE IndexHandle, 00578 IN ULONG Count, 00579 IN PINDEX_ROW IndexRow, 00580 IN OUT PQUICK_INDEX_HINT QuickIndexHint OPTIONAL, 00581 IN OUT PMAP_HANDLE MapHandle OPTIONAL 00582 ); 00583 00584 // 00585 // NtOfsCloseIndex closes an index handle. The index must not be acquired for this 00586 // call. No outstanding maps are allowed. 00587 // 00588 00589 NTFSAPI 00590 VOID 00591 NtOfsCloseIndex ( 00592 IN PIRP_CONTEXT IrpContext, 00593 IN INDEX_HANDLE IndexHandle 00594 ); 00595 00596 // 00597 // NtOfsDeleteIndex removes an index attribute from an object. The object will be 00598 // acquired exclusive for this call. 00599 // 00600 00601 NTFSAPI 00602 VOID 00603 NtOfsDeleteIndex ( 00604 IN PIRP_CONTEXT IrpContext, 00605 IN OBJECT_HANDLE ObjectHandle, 00606 IN INDEX_HANDLE IndexHandle 00607 ); 00608 00609 00610 00611 // 00612 // Map API - These encapsulate the NtOfs/Cache manager interactions 00613 // 00614 00615 // 00616 // NtOfsInitializeMapHandle initializes a map handle so it can be safely 00617 // released at any time. 00618 // 00619 // NTFSAPI 00620 // VOID 00621 // NtOfsInitializeMapHandle ( 00622 // IN PMAP_HANDLE Map 00623 // ); 00624 // 00625 00626 #define NtOfsInitializeMapHandle( M ) { (M)->Bcb = NULL; } 00627 00628 // 00629 // NtOfsMapAttribute maps a portion of the specified attribute and returns a pointer 00630 // to the memory. The memory mapped may not span a mapping window. Multiple maps 00631 // are allowed through different handles in different threads. The data is not 00632 // preread nor is the memory pinned. 00633 // 00634 00635 00636 #ifndef _NTFSPROC_ 00637 NTFSAPI 00638 VOID 00639 NtOfsMapAttribute ( 00640 IN PIRP_CONTEXT IrpContext, 00641 IN ATTRIBUTE_HANDLE Attribute, 00642 IN LONGLONG Offset, 00643 IN ULONG Length, 00644 OUT PVOID *Buffer, 00645 OUT PMAP_HANDLE MapHandle 00646 ); 00647 00648 #else 00649 #ifdef MAPCOUNT_DBG 00650 #define NtOfsMapAttribute(I,S,O,L,B,M) ( \ 00651 CcMapData((S)->FileObject, (PLARGE_INTEGER)&(O), (L), TRUE, &(M)->Bcb, (B)), \ 00652 (I)->MapCount++, \ 00653 (M)->FileOffset = (O), \ 00654 (M)->Length = (L), \ 00655 (M)->Buffer = *(PVOID *)(B) \ 00656 ) 00657 #else 00658 #define NtOfsMapAttribute(I,S,O,L,B,M) ( \ 00659 CcMapData((S)->FileObject, (PLARGE_INTEGER)&(O), (L), TRUE, &(M)->Bcb, (B)), \ 00660 (M)->FileOffset = (O), \ 00661 (M)->Length = (L), \ 00662 (M)->Buffer = *(PVOID *)(B) \ 00663 ) 00664 #endif 00665 #endif 00666 00667 // 00668 // NtOfsPreparePinWrite maps and pins a portion of the specified attribute and 00669 // returns a pointer to the memory. This is equivalent to doing a NtOfsMapAttribute 00670 // followed by NtOfsPinRead and NtOfsDirty but is more efficient. 00671 // 00672 00673 #ifndef _NTFSPROC_ 00674 NTFSAPI 00675 VOID 00676 NtOfsPreparePinWrite ( 00677 IN PIRP_CONTEXT IrpContext, 00678 IN ATTRIBUTE_HANDLE Attribute, 00679 IN LONGLONG Offset, 00680 IN ULONG Length, 00681 OUT PVOID *Buffer, 00682 OUT PMAP_HANDLE MapHandle 00683 ); 00684 00685 #else 00686 #ifdef MAPCOUNT_DBG 00687 #define NtOfsPreparePinWrite(I,S,O,L,B,M) { \ 00688 if (((O) + (L)) > (S)->Header.AllocationSize.QuadPart) { \ 00689 ExRaiseStatus(STATUS_END_OF_FILE); \ 00690 } \ 00691 CcPreparePinWrite((S)->FileObject, (PLARGE_INTEGER)&(O), (L), FALSE, TRUE, &(M)->Bcb, (B)); \ 00692 (I)->MapCount++; \ 00693 (M)->FileOffset = (O); \ 00694 (M)->Length = (L); \ 00695 (M)->Buffer = (B); \ 00696 } 00697 #else 00698 #define NtOfsPreparePinWrite(I,S,O,L,B,M) { \ 00699 if (((O) + (L)) > (S)->Header.AllocationSize.QuadPart) { \ 00700 ExRaiseStatus(STATUS_END_OF_FILE); \ 00701 } \ 00702 CcPreparePinWrite((S)->FileObject, (PLARGE_INTEGER)&(O), (L), FALSE, TRUE, &(M)->Bcb, (B)); \ 00703 (M)->FileOffset = (O); \ 00704 (M)->Length = (L); \ 00705 (M)->Buffer = (B); \ 00706 } 00707 #endif 00708 #endif 00709 00710 // 00711 // NtOfsPinRead pins a section of a map and read in all pages from the mapped 00712 // attribute. Offset and Length must describe a byte range which is equal to 00713 // or included by the original mapped range. 00714 // 00715 00716 #ifndef _NTFSPROC_ 00717 NTFSAPI 00718 VOID 00719 NtOfsPinRead( 00720 IN PIRP_CONTEXT IrpContext, 00721 IN ATTRIBUTE_HANDLE Attribute, 00722 IN LONGLONG Offset, 00723 IN ULONG Length, 00724 OUT PMAP_HANDLE MapHandle 00725 ); 00726 00727 #else 00728 #ifdef MAPCOUNT_DBG 00729 #define NtOfsPinRead(I,S,O,L,M) { \ 00730 ASSERT((M)->Bcb != NULL); \ 00731 ASSERT(((O) >= (M)->FileOffset) && (((O) + (L)) <= ((M)->FileOffset + (M)->Length))); \ 00732 CcPinMappedData((S)->FileObject, (PLARGE_INTEGER)&(O), (L), TRUE, &(M)->Bcb); \ 00733 (I)->MapCount++; \ 00734 (M)->FileOffset = (O); \ 00735 (M)->Length = (L); \ 00736 } 00737 #else 00738 #define NtOfsPinRead(I,S,O,L,M) { \ 00739 ASSERT((M)->Bcb != NULL); \ 00740 ASSERT(((O) >= (M)->FileOffset) && (((O) + (L)) <= ((M)->FileOffset + (M)->Length))); \ 00741 CcPinMappedData((S)->FileObject, (PLARGE_INTEGER)&(O), (L), TRUE, &(M)->Bcb); \ 00742 (M)->FileOffset = (O); \ 00743 (M)->Length = (L); \ 00744 } 00745 #endif 00746 #endif 00747 00748 // 00749 // NtOfsDirty marks a map as being dirty (eligible for lazy writer access) and 00750 // marks the pages with an optional LSN for coordination with LFS. This call 00751 // is invalid unless the map has been pinned. 00752 // 00753 00754 // NTFSAPI 00755 // NtOfsDirty ( 00756 // IN PIRP_CONTEXT IrpContext, 00757 // IN PMAP_HANDLE MapHandle, 00758 // PLSN Lsn OPTIONAL 00759 // ); 00760 00761 #define NtOfsDirty(I,M,L) {CcSetDirtyPinnedData((M)->Bcb,(L));} 00762 00763 // 00764 // NtOfsReleaseMap unmaps/unpins a mapped portion of an attribute. 00765 // 00766 00767 00768 #ifndef _NTFSPROC_ 00769 NTFSAPI 00770 VOID 00771 NtOfsReleaseMap ( 00772 IN PIRP_CONTEXT IrpContext, 00773 IN PMAP_HANDLE MapHandle 00774 ); 00775 00776 #else 00777 00778 #ifdef MAPCOUNT_DBG 00779 #define NtOfsReleaseMap(IC,M) { \ 00780 if ((M)->Bcb != NULL) { \ 00781 CcUnpinData((M)->Bcb); \ 00782 (IC)->MapCount--; \ 00783 (M)->Bcb = NULL; \ 00784 } \ 00785 } 00786 #else 00787 #define NtOfsReleaseMap(IC,M) { \ 00788 if ((M)->Bcb != NULL) { \ 00789 CcUnpinData((M)->Bcb); \ 00790 (M)->Bcb = NULL; \ 00791 } \ 00792 } 00793 #endif 00794 #endif 00795 00796 // 00797 // NtOfsPutData writes data into an attribute in a recoverable fashion. The 00798 // caller must have opened the attribute with LogNonresidentToo. 00799 // 00800 // NtOfsPutData will write the data atomically and update the mapped image, 00801 // subject to the normal lazy commit of the transaction. 00802 // 00803 00804 NTFSAPI 00805 VOID 00806 NtOfsPutData ( 00807 IN PIRP_CONTEXT IrpContext, 00808 IN ATTRIBUTE_HANDLE Attribute, 00809 IN LONGLONG Offset, 00810 IN ULONG Length, 00811 IN PVOID Data OPTIONAL 00812 ); 00813 00814 00815 00816 00817 // 00818 // Attribute API - These encapsulate access to attributes on files/directories 00819 // and summary catalogs 00820 // 00821 00822 // 00823 // NtOfsCreateAttribute will create or open a data attribute and return a handle 00824 // that will allow mapping operations. 00825 // 00826 // For attributes that wish to have logging behavior, LogNonresidentToo must be 00827 // set to true. See the discussion on NtOfsPutData (in the mapping section 00828 // above). 00829 // 00830 00831 NTFSAPI 00832 NTSTATUS 00833 NtOfsCreateAttribute ( 00834 IN PIRP_CONTEXT IrpContext, 00835 IN OBJECT_HANDLE ObjectHandle, 00836 IN UNICODE_STRING Name, 00837 IN CREATE_OPTIONS CreateOptions, 00838 IN ULONG LogNonresidentToo, 00839 OUT ATTRIBUTE_HANDLE *AttributeHandle 00840 ); 00841 00842 // 00843 // NtOfsCreateAttributeEx will create or open an attribute and return a handle 00844 // that will allow mapping operations. If a standard data attribute is to be 00845 // used, call NtOfsCreateAttribute instead. This function is here for callers 00846 // who need to use a different attribute type code. 00847 // 00848 // For attributes that wish to have logging behavior, LogNonresidentToo must be 00849 // set to true. See the discussion on NtOfsPutData (in the mapping section 00850 // above). 00851 // 00852 00853 NTFSAPI 00854 NTSTATUS 00855 NtOfsCreateAttributeEx ( 00856 IN PIRP_CONTEXT IrpContext, 00857 IN OBJECT_HANDLE ObjectHandle, 00858 IN UNICODE_STRING Name, 00859 IN ULONG AttributeTypeCode, 00860 IN CREATE_OPTIONS CreateOptions, 00861 IN ULONG LogNonresidentToo, 00862 OUT ATTRIBUTE_HANDLE *AttributeHandle 00863 ); 00864 00865 // 00866 // Valid AttributeTypeCode values for NtOfsCreateAttributeEx: 00867 // 00868 00869 #define $LOGGED_UTILITY_STREAM (0x100) 00870 00871 00872 // 00873 // NtOfsCloseAttribute releases the attribute. The attribute is not acquired. No 00874 // outstanding maps are active. 00875 // 00876 00877 NTFSAPI 00878 VOID 00879 NtOfsCloseAttribute ( 00880 IN PIRP_CONTEXT IrpContext, 00881 IN ATTRIBUTE_HANDLE AttributeHandle 00882 ); 00883 00884 // 00885 // NtOfsDeleteAttribute releases all storage associated with the attribute. The 00886 // object will be acquired exclusive. The attribute will be acquired exclusive. 00887 // No outstanding maps are active. 00888 // 00889 00890 NTFSAPI 00891 VOID 00892 NtOfsDeleteAttribute ( 00893 IN PIRP_CONTEXT IrpContext, 00894 IN OBJECT_HANDLE ObjectHandle, 00895 IN ATTRIBUTE_HANDLE AttributeHandle 00896 ); 00897 00898 // 00899 // NtOfsQueryLength returns the current length of user data within the attribute. 00900 // The attribute may be mapped. The attribute may be acquired. 00901 // 00902 00903 NTFSAPI 00904 LONGLONG 00905 NtOfsQueryLength ( 00906 IN ATTRIBUTE_HANDLE AttributeHandle 00907 ); 00908 00909 // 00910 // NtOfsSetLength sets the current EOF on the given attribute. The attribute 00911 // may not be mapped to the view containing Length, or any subsequent view. 00912 // The attribute will be acquired exclusive. 00913 // 00914 00915 NTFSAPI 00916 VOID 00917 NtOfsSetLength ( 00918 IN PIRP_CONTEXT IrpContext, 00919 IN ATTRIBUTE_HANDLE Attribute, 00920 IN LONGLONG Length 00921 ); 00922 // 00923 // NtOfsWaitForNewLength allows the caller to wait for the specified length to 00924 // be exceeded, or optionally timeout, if the specified Irp has not been cancelled. 00925 // 00926 00927 NTFSAPI 00928 NTSTATUS 00929 NtOfsWaitForNewLength ( 00930 IN ATTRIBUTE_HANDLE Attribute, 00931 IN LONGLONG Length, 00932 IN ULONG Async, 00933 IN PIRP Irp, 00934 IN PDRIVER_CANCEL CancelRoutine, 00935 IN PLARGE_INTEGER Timeout OPTIONAL 00936 ); 00937 00938 // 00939 // This routine may be called any time FileSize has changed to wake any threads 00940 // waiting for a particular FileSize change. Or specify WakeAll to unconditionally 00941 // wake all waiters. 00942 // 00943 00944 VOID 00945 NtOfsPostNewLength ( 00946 IN PIRP_CONTEXT IrpContext OPTIONAL, 00947 IN ATTRIBUTE_HANDLE Attribute, 00948 IN BOOLEAN WakeAll 00949 ); 00950 00951 // 00952 // NtOfsDecommit releases storage associated with a range of the attribute. It does 00953 // not change the EOF marker nor does it change the logical position of data within 00954 // the attribute. The range of the attribute being released may be mapped or 00955 // pinned. 00956 // 00957 // Reads from decommitted ranges should return zero (although Query will never read 00958 // from these ranges). 00959 // 00960 // Writes to decommitted pages should fail or be nooped (although Query will never 00961 // write to these ranges). 00962 // 00963 // This call will purge, so none of the views overlapping the specified range may 00964 // be mapped. 00965 // 00966 00967 NTFSAPI 00968 VOID 00969 NtOfsDecommit ( 00970 IN PIRP_CONTEXT IrpContext, 00971 IN ATTRIBUTE_HANDLE Attribute, 00972 IN LONGLONG Offset, 00973 IN LONGLONG Length 00974 ); 00975 00976 // 00977 // NtOfsFlushAttribute flushes all cached data to the disk and returns upon 00978 // completion. If the attribute is LogNonresidentToo, then only the log file 00979 // is flushed. Optionally, the range may be purged as well. If the attribute 00980 // is purged, then there can be no mapped views. 00981 // 00982 00983 NTFSAPI 00984 VOID 00985 NtOfsFlushAttribute ( 00986 IN PIRP_CONTEXT IrpContext, 00987 IN ATTRIBUTE_HANDLE Attribute, 00988 IN ULONG Purge 00989 ); 00990 00991 // 00992 // NtOfsQueryAttributeSecurityId returns the security ID for the attribute if 00993 // present. 00994 // 00995 00996 NTFSAPI 00997 VOID 00998 NtOfsQueryAttributeSecurityId ( 00999 IN PIRP_CONTEXT IrpContext, 01000 IN ATTRIBUTE_HANDLE Attribute, 01001 OUT SECURITY_ID *SecurityId 01002 ); 01003 01004 01005 01006 // 01007 // Concurrency control API 01008 // 01009 // As a rule, these routines are not required. All NtOfs routines are 01010 // self-synchronized as atomic actions, or as parts of a top-level action when 01011 // called within a top-level action routine. 01012 // 01013 // ISSUE: In particular, supporting the exclusive access call is an implementation 01014 // problem for Ntfs. Wrapping top-level actions is the best way to preserve 01015 // exclusive access across calls. 01016 // 01017 01018 VOID 01019 NtOfsAcquireObjectShared ( 01020 HANDLE ObjectHandle 01021 ); 01022 01023 // VOID 01024 // NtOfsAcquireObjectExclusive ( 01025 // HANDLE ObjectHandle 01026 // ); 01027 01028 VOID 01029 NtOfsReleaseObject ( 01030 HANDLE ObjectHandle 01031 ); 01032 01033 // Debugging routines 01034 BOOLEAN 01035 NtOfsIsObjectAcquiredExclusive ( 01036 HANDLE ObjectHandle 01037 ); 01038 01039 BOOLEAN 01040 NtOfsIsObjectAcquiredShared ( 01041 HANDLE ObjectHandle 01042 ); 01043 01044 01045 01046 01047 // 01048 // File/Directory/Etc API 01049 // 01050 01051 // 01052 // NtOfsOpenByFileReference opens an object given a file reference. The file is 01053 // assumed to exist; this call cannot be used to create a file. The returned 01054 // handle is acquired according to the input exclusion. 01055 // 01056 01057 NTFSAPI 01058 NTSTATUS 01059 NtOfsOpenByFileReference ( 01060 IN PIRP_CONTEXT IrpContext, 01061 IN FILE_REFERENCE FileReference, 01062 IN EXCLUSION Exclusion, 01063 OUT OBJECT_HANDLE *ObjectHandle 01064 ); 01065 01066 // 01067 // NtOfsCreateRelativeObject opens or creates an object relative to a specified 01068 // parent object. The parent will be acquired exclusive. The child is opened 01069 // acquired according to the input exclusion. 01070 // 01071 // ISSUE: When creating an object, is the transaction committed before this 01072 // call returns? 01073 // 01074 01075 NTFSAPI 01076 NTSTATUS 01077 NtOfsCreateRelativeObject ( 01078 IN PIRP_CONTEXT IrpContext, 01079 IN OBJECT_HANDLE ParentObjectHandle, 01080 IN UNICODE_STRING Name, 01081 IN CREATE_OPTIONS CreateOptions, 01082 IN EXCLUSION Exclusion, 01083 OUT OBJECT_HANDLE *ObjectHandle 01084 ); 01085 01086 // 01087 // NtOfsCloseObject releases the object handle. 01088 // 01089 01090 NTFSAPI 01091 NTSTATUS 01092 NtOfsCloseObject ( 01093 IN PIRP_CONTEXT IrpContext, 01094 IN OBJECT_HANDLE ObjectHandle 01095 ); 01096 01097 // 01098 // NtOfsDeleteObject deletes the object. No user-mode handle is attached to 01099 // the object. No attributes are currently open. The object is acquired 01100 // exclusive. 01101 // 01102 01103 NTFSAPI 01104 NTSTATUS 01105 NtOfsDeleteObject ( 01106 IN PIRP_CONTEXT IrpContext, 01107 IN OBJECT_HANDLE ObjectHandle 01108 ); 01109 01110 // 01111 // NtOfsDeleteAllAttributes deletes all attributes of the object. No attribute 01112 // is open. The object is acquired exclusive. 01113 // 01114 01115 NTFSAPI 01116 NTSTATUS 01117 NtOfsDeleteAllAttributes ( 01118 IN PIRP_CONTEXT IrpContext, 01119 IN OBJECT_HANDLE ObjectHandle 01120 ); 01121 01122 // 01123 // NtOfsQueryPathFromRoot returns *A* path from the root to a node. In the 01124 // presence of hard links, several paths may exist, however, only one needs 01125 // to be returned. Memory for the file name is provided by the caller. 01126 // 01127 01128 NTFSAPI 01129 NTSTATUS 01130 NtOfsQueryPathFromRoot ( 01131 IN PIRP_CONTEXT IrpContext, 01132 IN FILE_REFERENCE FileReference, 01133 OUT UNICODE_STRING *PathName 01134 ); 01135 01136 // 01137 // NtOfsQueryFileName returns the final component in the path name into a 01138 // caller-supplied buffer. In the presence of hard links, several names 01139 // may exist, however, only one needs to be returned. 01140 // 01141 01142 NTFSAPI 01143 NTSTATUS 01144 NtOfsQueryFileName ( 01145 IN PIRP_CONTEXT IrpContext, 01146 IN FILE_REFERENCE FileReference, 01147 OUT UNICODE_STRING *FileName 01148 ); 01149 01150 // 01151 // NtOfsQueryFileReferenceFromName returns the file reference named by the path 01152 // 01153 01154 NTFSAPI 01155 NTSTATUS 01156 NtOfsQueryFileReferenceFromName ( 01157 IN PIRP_CONTEXT IrpContext, 01158 IN UNICODE_STRING Name, 01159 OUT FILE_REFERENCE *FileReference 01160 ); 01161 01162 // 01163 // This call must be very fast; it is a very common call made by CI/Query. 01164 // 01165 01166 NTFSAPI 01167 NTSTATUS 01168 NtOfsQueryFileReferenceFromHandle ( 01169 IN OBJECT_HANDLE Object, 01170 OUT FILE_REFERENCE *FileReference 01171 ); 01172 01173 // 01174 // NtOfsQueryObjectSecurityId returns the security Id associated with an object. 01175 // The object is acquired shared or exclusive. This call must be very fast 01176 // 01177 01178 NTFSAPI 01179 NTSTATUS 01180 NtOfsQueryObjectSecurityId ( 01181 IN PIRP_CONTEXT IrpContext, 01182 IN OBJECT_HANDLE ObjectHandle, 01183 OUT SECURITY_ID *SecurityId 01184 ); 01185 01186 01187 01188 01189 // 01190 // Scope API 01191 // 01192 01193 // 01194 // NtOfsIsAncestorOf must quickly tell if one file is an ancestor of the given 01195 // child. In the presence of hard links, we may pick a "preferred" path (i.e. 01196 // we don't have to travel to all ancestors). This call must be reasonably fast 01197 // since this is a very frequent call from Query. 01198 // 01199 01200 NTFSAPI 01201 NTSTATUS 01202 NtOfsIsAncestorOf ( 01203 IN PIRP_CONTEXT IrpContext, 01204 IN FILE_REFERENCE Ancestor, 01205 IN FILE_REFERENCE Child 01206 ); 01207 01208 // 01209 // NtOfsGetParentFileReferenceFromHandle is used to retrieve the FileReference 01210 // of the parent of the named object. With hard links the "first" parent may 01211 // be chosen. This call needs to be reasonably efficient. 01212 // 01213 01214 NTFSAPI 01215 NTSTATUS 01216 NtOfsGetParentFileReferenceFromHandle ( 01217 IN PIRP_CONTEXT IrpContext, 01218 IN OBJECT_HANDLE ChildObject, 01219 OUT FILE_REFERENCE *ParentFileReference 01220 ); 01221 01222 01223 01224 01225 // 01226 // Security API 01227 // 01228 // NtOfs maintains a "per-IrpContext" cache that speeds up security validation. 01229 // Clients clear the cache (at the beginning of a query, say) and then do 01230 // successive probes which may populate the cache. 01231 // 01232 01233 // 01234 // NtOfsClearSecurityCache clears the cache. 01235 // 01236 01237 NTFSAPI 01238 NTSTATUS 01239 NtOfsClearSecurityCache ( 01240 IN PIRP_CONTEXT IrpContext 01241 ); 01242 01243 // 01244 // NtOfsIsAccessGranted uses the Se routines to validate access and caches the 01245 // result for the specified SecurityId and DesiredAccess. The cache is first 01246 // probed to see if the access can be granted immediately. If the SecurityId is 01247 // not found, the corresponding ACL is retrieved and tested with the supplied 01248 // access state and DesiredAccess. The result of this test is cached and 01249 // returned. 01250 // 01251 01252 NTFSAPI 01253 NTSTATUS 01254 NtOfsIsAccessGranted ( 01255 IN PIRP_CONTEXT IrpContext, 01256 IN SECURITY_ID SecurityId, 01257 IN ACCESS_MASK DesiredAccess, 01258 IN ACCESS_STATE *SecurityAccessState 01259 ); 01260 01261 01262 01263 01264 // 01265 // Worker thread stuff. Worker threads are needed for building new indexes 01266 // 01267 01268 01269 01270 01271 // 01272 // Miscellaneous information query/set 01273 // 01274 01275 // 01276 // Content Index may need to mark the volume as dirty to allow garbage collection 01277 // of orphan objects by CHKDSK. 01278 // 01279 01280 NTFSAPI 01281 NTSTATUS 01282 NtOfsMarkVolumeCorrupt ( 01283 IN PIRP_CONTEXT IrpContext, 01284 IN ULONG NewState, 01285 IN ULONG StateMask, 01286 OUT ULONG *OldState 01287 ); 01288 01289 // 01290 // NtOfsQueryVolumeStatistics returns the current capacity and free space on a 01291 // volume. Ci uses this for heuristics to decide on when to trigger master merge, 01292 // when to suppress master merge, etc. 01293 // 01294 01295 NTFSAPI 01296 NTSTATUS 01297 NtOfsQueryVolumeStatistics ( 01298 IN PIRP_CONTEXT IrpContext, 01299 OUT LONGLONG *TotalClusters, 01300 OUT LONGLONG *FreeClusters 01301 ); 01302 01303 // 01304 // Query needs to retain some state in the NtOfs Ccb. 01305 // 01306 01307 NTFSAPI 01308 NTSTATUS 01309 NtOfsQueryHandleState ( 01310 IN PIRP_CONTEXT IrpContext, 01311 OUT VOID *OldData 01312 ); 01313 01314 NTFSAPI 01315 NTSTATUS 01316 NtOfsSetHandleState ( 01317 IN PIRP_CONTEXT IrpContext, 01318 IN VOID *Data 01319 ); 01320 01321 // 01322 // Generic unwrapping routines that get access to SCB/IRPC and FCB/IRPC 01323 // pairs. 01324 // 01325 01326 NTFSAPI 01327 NTSTATUS 01328 NtOfsQueryAttributeHandle ( 01329 IN PIRP_CONTEXT IrpContext, 01330 OUT ATTRIBUTE_HANDLE *AttributeHandle 01331 ); 01332 01333 NTFSAPI 01334 NTSTATUS 01335 NtOfsQueryObjectHandle ( 01336 IN PIRP_CONTEXT IrpContext, 01337 OUT OBJECT_HANDLE *ObjectHandle 01338 ); 01339 01340 // 01341 // Create a context in which the caller can perform I/O in separate. 01342 // threads. This means creating an IRP/IRP_CONTEXT. Each IrpContext corresponds 01343 // to one I/O activity at a time. Multiple IrpContexts may be active in a thread 01344 // at a single time. 01345 // 01346 01347 NTFSAPI 01348 NTSTATUS 01349 NtOfsCloneIrpContext ( 01350 IN PIRP_CONTEXT IrpContext, 01351 OUT PIRP_CONTEXT *NewIrpContext 01352 ); 01353 01354 // 01355 // NtOfsCompleteRequest completes an IrpContext that has been previously cloned. 01356 // All other FsCtl Irps are completed by Ntfs. 01357 // 01358 01359 NTFSAPI 01360 NTSTATUS 01361 NtOfsCompleteRequest ( 01362 IN PIRP_CONTEXT IrpContext, 01363 NTSTATUS Status 01364 ); 01365 01366 01367 01368 01369 // 01370 // Iterators. While each iterator is created through a separate API, each one 01371 // must support two operations: 01372 // Next - this fills a buffer with as many records as possible 01373 // Close - this releases the iterator. 01374 // 01375 01376 typedef struct _BASE_FILE_SEGMENT_ITERATOR BASE_FILE_SEGMENT_ITERATOR; 01377 01378 typedef struct _USN_ITERATOR USN_ITERATOR; 01379 01380 // 01381 // The types of iterators are: 01382 // 01383 // Scope iterate over a directory (optionally RECURSIVE) 01384 // (implemented in Query) 01385 // View iterate over the rows in a view with a partial key match 01386 // (implemented in View) 01387 // BaseFileSegment iterate over all base file record segments 01388 // (implemented in NtOfs) 01389 // SummaryCatalog iterate over all rows in a summary catalog 01390 // Usn iterate over all objects with Usn's in a specific range 01391 // (implmented in NtOfs) 01392 // 01393 // Each iteration is passed a buffer which is filled (as much as possible) with 01394 // a packed array of: 01395 // FILE_REFERENCE 01396 // DUPLICATED_INFORMATION 01397 // STAT_INFORMATION 01398 // for each enumerated object. The output length is the length in bytes that 01399 // was filled in with the enumeration request. 01400 01401 NTFSAPI 01402 NTSTATUS 01403 NtOfsCreateBaseFileSegmentIterator ( 01404 IN PIRP_CONTEXT IrpContext, 01405 OUT BASE_FILE_SEGMENT_ITERATOR *Iterator 01406 ); 01407 01408 NTFSAPI 01409 NTSTATUS 01410 NtOfsNextBaseFileSegmentIteration ( 01411 IN PIRP_CONTEXT IrpContext, 01412 IN BASE_FILE_SEGMENT_ITERATOR *Iterator, 01413 IN OUT ULONG *BufferLength, 01414 IN OUT PVOID Buffer 01415 ); 01416 01417 NTFSAPI 01418 NTSTATUS 01419 NtOfsCloseBaseFileSegmentIterator ( 01420 IN PIRP_CONTEXT IrpContext, 01421 IN BASE_FILE_SEGMENT_ITERATOR *Iterator 01422 ); 01423 01424 NTFSAPI 01425 NTSTATUS 01426 NtOfsCreateUsnIterator ( 01427 IN PIRP_CONTEXT IrpContext, 01428 IN USN BeginningUsn, 01429 IN USN EndingUsn, 01430 OUT USN_ITERATOR *Iterator 01431 ); 01432 01433 NTFSAPI 01434 NTSTATUS 01435 NtOfsNextUsnIteration ( 01436 IN PIRP_CONTEXT IrpContext, 01437 IN USN_ITERATOR *Iterator, 01438 IN OUT ULONG *BufferLength, 01439 IN OUT PVOID Buffer 01440 ); 01441 01442 NTFSAPI 01443 NTSTATUS 01444 NtOfsCloseUsnIterator ( 01445 IN PIRP_CONTEXT IrpContext, 01446 IN USN_ITERATOR *Iterator 01447 ); 01448 01449 01450 01451 01452 // 01453 // Infrastructure support. 01454 // 01455 // V/C/X register callbacks with NtOfs when they are loaded. Until they are loaded 01456 // NtOfs will call default routines (that do nothing). 01457 // 01458 01459 typedef enum _NTFS_ADDON_TYPES { 01460 Encryption = 3 01461 } NTFS_ADDON_TYPES; 01462 01463 01464 01465 01466 // 01467 // Encryption 01468 // 01469 01470 // 01471 // Stream Create Status for FileDirFlag 01472 // 01473 01474 #define STREAM_NEW_OR_EXIST_MASK 0x000f0000 01475 #define FILE_DIR_TYPE_MASK 0x000000ff 01476 01477 #define FILE_NEW 0x00000001 01478 #define FILE_EXISTING 0x00000002 01479 #define DIRECTORY_NEW 0x00000004 01480 #define DIRECTORY_EXISTING 0x00000008 01481 #define EXISTING_FILE_ENCRYPTED 0x00000010 01482 #define STREAM_NEW 0x00010000 01483 #define STREAM_EXISTING 0x00020000 01484 01485 // 01486 // Encryption flag for EncryptionFlag 01487 // 01488 01489 #define STREAM_ENCRYPTED 0x00000001 01490 #define FILE_ENCRYPTED 0x00000002 01491 01492 // 01493 // Access flags 01494 // 01495 // NB -- These values are NOT arbitrary. Notice also that they are not 01496 // in value order, they are grouped according to their meaning. 01497 // Their values correspond to FILE_READ_DATA, etc. and 01498 // TOKEN_HAS_BACKUP_PRIVILEGE, etc. 01499 // 01500 01501 #define READ_DATA_ACCESS 0x01 01502 #define WRITE_DATA_ACCESS 0x02 01503 #define APPEND_DATA_ACCESS 0x04 01504 #define EXECUTE_ACCESS 0x20 01505 01506 #define BACKUP_ACCESS 0x08 01507 #define RESTORE_ACCESS 0x10 01508 #define TRAVERSE_ACCESS 0x40 01509 01510 typedef NTSTATUS 01511 (*ENCRYPTED_FILE_CREATE) ( 01512 IN OBJECT_HANDLE FileHdl, 01513 IN OBJECT_HANDLE ParentDir OPTIONAL, 01514 IN PIO_STACK_LOCATION IrpSp, 01515 IN ULONG FileDirFlag, 01516 IN PIRP_CONTEXT IrpContext, 01517 IN PDEVICE_OBJECT VolDo, 01518 IN PVOID FileKeyContext, 01519 IN OUT PVOID *PKeyContext, 01520 IN OUT ULONG *ContextLength, 01521 IN OUT PVOID *PCreateContext, 01522 IN OUT PBOOLEAN Reserved 01523 ); 01524 01525 typedef NTSTATUS 01526 (*ENCRYPTED_FILE_PRE_CREATE) ( 01527 IN PDEVICE_OBJECT VolDo, 01528 IN PIRP Irp, 01529 IN PFILE_OBJECT FileObject 01530 ); 01531 01532 typedef NTSTATUS 01533 (*ENCRYPTED_FILE_POST_CREATE) ( 01534 IN PDEVICE_OBJECT VolDo, 01535 IN PIRP Irp, 01536 IN PFILE_OBJECT FileObject, 01537 IN NTSTATUS Status, 01538 IN OUT PVOID *PCreateContext 01539 ); 01540 01541 typedef NTSTATUS 01542 (*ENCRYPTED_FILE_SYSTEM_CONTROL) ( 01543 IN PVOID PInputBuffer OPTIONAL, 01544 IN ULONG InputDataLength, 01545 OUT PVOID OutputBuffer OPTIONAL, 01546 IN OUT ULONG *OutputBufferLength OPTIONAL, 01547 IN ULONG EncryptionFlag, 01548 IN ULONG AccessFlag, 01549 IN ULONG FsControlCode, 01550 IN OBJECT_HANDLE FileHdl, 01551 IN PIRP_CONTEXT IrpContext, 01552 IN PDEVICE_OBJECT VolDo, 01553 IN ATTRIBUTE_HANDLE Attribute, 01554 IN OUT PVOID *PContext OPTIONAL, 01555 IN OUT ULONG *ContextLength OPTIONAL 01556 ); 01557 01558 typedef NTSTATUS 01559 (*ENCRYPTED_FILE_PRE_FILE_SYSTEM_CONTROL) ( 01560 IN PDEVICE_OBJECT VolDo, 01561 IN PIRP Irp, 01562 IN PFILE_OBJECT FileObject 01563 ); 01564 01565 typedef NTSTATUS 01566 (*ENCRYPTED_FILE_READ)( 01567 IN OUT PUCHAR InOutBuffer, 01568 IN PLARGE_INTEGER Offset, 01569 IN ULONG BufferSize, 01570 IN PVOID Context 01571 ); 01572 01573 typedef NTSTATUS 01574 (*ENCRYPTED_FILE_WRITE)( 01575 IN PUCHAR InBuffer, 01576 OUT PUCHAR OutBuffer, 01577 IN PLARGE_INTEGER Offset, 01578 IN ULONG BufferSize, 01579 IN PUCHAR Context 01580 ); 01581 01582 typedef VOID 01583 (*ENCRYPTED_FILE_CLEANUP)( 01584 IN OUT PVOID *Context 01585 ); 01586 01587 #define ENCRYPTION_CURRENT_INTERFACE_VERSION 3 01588 01589 #define ENCRYPTION_ALL_STREAMS 0x00000001 01590 #define ENCRYPTION_ALLOW_COMPRESSION 0x00000002 01591 01592 typedef struct _ENCRYPTION_CALL_BACK { 01593 ULONG InterfaceVersion; 01594 ULONG ImplementationFlags; 01595 ENCRYPTED_FILE_CREATE FileCreate; 01596 ENCRYPTED_FILE_PRE_CREATE PreCreate; 01597 ENCRYPTED_FILE_POST_CREATE PostCreate; 01598 ENCRYPTED_FILE_SYSTEM_CONTROL FileSystemControl_1; 01599 ENCRYPTED_FILE_SYSTEM_CONTROL FileSystemControl_2; 01600 ENCRYPTED_FILE_PRE_FILE_SYSTEM_CONTROL PreFileSystemControl; 01601 ENCRYPTED_FILE_READ AfterReadProcess; 01602 ENCRYPTED_FILE_WRITE BeforeWriteProcess; 01603 ENCRYPTED_FILE_CLEANUP CleanUp; 01604 } ENCRYPTION_CALL_BACK, *PENCRYPTION_CALL_BACK; 01605 01606 // 01607 // NtOfsRegisterCallBacks supplies a call table to NtOfs. Each table has an 01608 // interface version number. If the interface version does not exactly match 01609 // what NtOfs expects, the call will fail. 01610 // 01611 01612 NTFSAPI 01613 NTSTATUS 01614 NtOfsRegisterCallBacks ( 01615 NTFS_ADDON_TYPES NtfsAddonType, 01616 PVOID CallBackTable 01617 ); 01618

Generated on Sat May 15 19:41:00 2004 for test by doxygen 1.3.7