xref: /reactos/sdk/include/xdk/ccfuncs.h (revision 50cf16b3)
1 $if (_NTIFS_)
2 /* Common Cache Functions */
3 
4 #define CcIsFileCached(FO) (                                                         \
5     ((FO)->SectionObjectPointer != NULL) &&                                          \
6     (((PSECTION_OBJECT_POINTERS)(FO)->SectionObjectPointer)->SharedCacheMap != NULL) \
7 )
8 
9 extern NTKERNELAPI ULONG CcFastMdlReadWait;
10 
11 #if (NTDDI_VERSION >= NTDDI_WIN2K)
12 
13 NTKERNELAPI
14 VOID
15 NTAPI
16 CcInitializeCacheMap(
17   _In_ PFILE_OBJECT FileObject,
18   _In_ PCC_FILE_SIZES FileSizes,
19   _In_ BOOLEAN PinAccess,
20   _In_ PCACHE_MANAGER_CALLBACKS Callbacks,
21   _In_ PVOID LazyWriteContext);
22 
23 NTKERNELAPI
24 BOOLEAN
25 NTAPI
26 CcUninitializeCacheMap(
27   _In_ PFILE_OBJECT FileObject,
28   _In_opt_ PLARGE_INTEGER TruncateSize,
29   _In_opt_ PCACHE_UNINITIALIZE_EVENT UninitializeCompleteEvent);
30 
31 NTKERNELAPI
32 VOID
33 NTAPI
34 CcSetFileSizes(
35   IN PFILE_OBJECT FileObject,
36   IN PCC_FILE_SIZES FileSizes);
37 
38 NTKERNELAPI
39 VOID
40 NTAPI
41 CcSetDirtyPageThreshold(
42   _In_ PFILE_OBJECT FileObject,
43   _In_ ULONG DirtyPageThreshold);
44 
45 NTKERNELAPI
46 VOID
47 NTAPI
48 CcFlushCache(
49   _In_ PSECTION_OBJECT_POINTERS SectionObjectPointer,
50   _In_opt_ PLARGE_INTEGER FileOffset,
51   _In_ ULONG Length,
52   _Out_opt_ PIO_STATUS_BLOCK IoStatus);
53 
54 NTKERNELAPI
55 LARGE_INTEGER
56 NTAPI
57 CcGetFlushedValidData(
58   _In_ PSECTION_OBJECT_POINTERS SectionObjectPointer,
59   _In_ BOOLEAN BcbListHeld);
60 
61 NTKERNELAPI
62 BOOLEAN
63 NTAPI
64 CcZeroData(
65   _In_ PFILE_OBJECT FileObject,
66   _In_ PLARGE_INTEGER StartOffset,
67   _In_ PLARGE_INTEGER EndOffset,
68   _In_ BOOLEAN Wait);
69 
70 NTKERNELAPI
71 PVOID
72 NTAPI
73 CcRemapBcb(
74   _In_ PVOID Bcb);
75 
76 NTKERNELAPI
77 VOID
78 NTAPI
79 CcRepinBcb(
80   _In_ PVOID Bcb);
81 
82 NTKERNELAPI
83 VOID
84 NTAPI
85 CcUnpinRepinnedBcb(
86   _In_ PVOID Bcb,
87   _In_ BOOLEAN WriteThrough,
88   _Out_ PIO_STATUS_BLOCK IoStatus);
89 
90 NTKERNELAPI
91 PFILE_OBJECT
92 NTAPI
93 CcGetFileObjectFromSectionPtrs(
94   _In_ PSECTION_OBJECT_POINTERS SectionObjectPointer);
95 
96 NTKERNELAPI
97 PFILE_OBJECT
98 NTAPI
99 CcGetFileObjectFromBcb(
100   _In_ PVOID Bcb);
101 
102 NTKERNELAPI
103 BOOLEAN
104 NTAPI
105 CcCanIWrite(
106   _In_opt_ PFILE_OBJECT FileObject,
107   _In_ ULONG BytesToWrite,
108   _In_ BOOLEAN Wait,
109   _In_ BOOLEAN Retrying);
110 
111 NTKERNELAPI
112 VOID
113 NTAPI
114 CcDeferWrite(
115   _In_ PFILE_OBJECT FileObject,
116   _In_ PCC_POST_DEFERRED_WRITE PostRoutine,
117   _In_ PVOID Context1,
118   _In_ PVOID Context2,
119   _In_ ULONG BytesToWrite,
120   _In_ BOOLEAN Retrying);
121 
122 NTKERNELAPI
123 BOOLEAN
124 NTAPI
125 CcCopyRead(
126   _In_ PFILE_OBJECT FileObject,
127   _In_ PLARGE_INTEGER FileOffset,
128   _In_ ULONG Length,
129   _In_ BOOLEAN Wait,
130   _Out_writes_bytes_(Length) PVOID Buffer,
131   _Out_ PIO_STATUS_BLOCK IoStatus);
132 
133 NTKERNELAPI
134 VOID
135 NTAPI
136 CcFastCopyRead(
137   _In_ PFILE_OBJECT FileObject,
138   _In_ ULONG FileOffset,
139   _In_ ULONG Length,
140   _In_ ULONG PageCount,
141   _Out_writes_bytes_(Length) PVOID Buffer,
142   _Out_ PIO_STATUS_BLOCK IoStatus);
143 
144 NTKERNELAPI
145 BOOLEAN
146 NTAPI
147 CcCopyWrite(
148   _In_ PFILE_OBJECT FileObject,
149   _In_ PLARGE_INTEGER FileOffset,
150   _In_ ULONG Length,
151   _In_ BOOLEAN Wait,
152   _In_reads_bytes_(Length) PVOID Buffer);
153 
154 NTKERNELAPI
155 VOID
156 NTAPI
157 CcFastCopyWrite(
158   _In_ PFILE_OBJECT FileObject,
159   _In_ ULONG FileOffset,
160   _In_ ULONG Length,
161   _In_reads_bytes_(Length) PVOID Buffer);
162 
163 NTKERNELAPI
164 VOID
165 NTAPI
166 CcMdlRead(
167   _In_ PFILE_OBJECT FileObject,
168   _In_ PLARGE_INTEGER FileOffset,
169   _In_ ULONG Length,
170   _Out_ PMDL *MdlChain,
171   _Out_ PIO_STATUS_BLOCK IoStatus);
172 
173 NTKERNELAPI
174 VOID
175 NTAPI
176 CcMdlReadComplete(
177   _In_ PFILE_OBJECT FileObject,
178   _In_ PMDL MdlChain);
179 
180 NTKERNELAPI
181 VOID
182 NTAPI
183 CcPrepareMdlWrite(
184   _In_ PFILE_OBJECT FileObject,
185   _In_ PLARGE_INTEGER FileOffset,
186   _In_ ULONG Length,
187   _Out_ PMDL *MdlChain,
188   _Out_ PIO_STATUS_BLOCK IoStatus);
189 
190 NTKERNELAPI
191 VOID
192 NTAPI
193 CcMdlWriteComplete(
194   _In_ PFILE_OBJECT FileObject,
195   _In_ PLARGE_INTEGER FileOffset,
196   _In_ PMDL MdlChain);
197 
198 NTKERNELAPI
199 VOID
200 NTAPI
201 CcScheduleReadAhead(
202   _In_ PFILE_OBJECT FileObject,
203   _In_ PLARGE_INTEGER FileOffset,
204   _In_ ULONG Length);
205 
206 NTKERNELAPI
207 NTSTATUS
208 NTAPI
209 CcWaitForCurrentLazyWriterActivity(VOID);
210 
211 NTKERNELAPI
212 VOID
213 NTAPI
214 CcSetReadAheadGranularity(
215   _In_ PFILE_OBJECT FileObject,
216   _In_ ULONG Granularity);
217 
218 NTKERNELAPI
219 BOOLEAN
220 NTAPI
221 CcPinRead(
222   _In_ PFILE_OBJECT FileObject,
223   _In_ PLARGE_INTEGER FileOffset,
224   _In_ ULONG Length,
225   _In_ ULONG Flags,
226   _Outptr_ PVOID *Bcb,
227   _Outptr_result_bytebuffer_(Length) PVOID *Buffer);
228 
229 NTKERNELAPI
230 BOOLEAN
231 NTAPI
232 CcPinMappedData(
233   _In_ PFILE_OBJECT FileObject,
234   _In_ PLARGE_INTEGER FileOffset,
235   _In_ ULONG Length,
236   _In_ ULONG Flags,
237   _Inout_ PVOID *Bcb);
238 
239 NTKERNELAPI
240 BOOLEAN
241 NTAPI
242 CcPreparePinWrite(
243   _In_ PFILE_OBJECT FileObject,
244   _In_ PLARGE_INTEGER FileOffset,
245   _In_ ULONG Length,
246   _In_ BOOLEAN Zero,
247   _In_ ULONG Flags,
248   _Outptr_ PVOID *Bcb,
249   _Outptr_result_bytebuffer_(Length) PVOID *Buffer);
250 
251 NTKERNELAPI
252 VOID
253 NTAPI
254 CcSetDirtyPinnedData(
255   _In_ PVOID BcbVoid,
256   _In_opt_ PLARGE_INTEGER Lsn);
257 
258 NTKERNELAPI
259 VOID
260 NTAPI
261 CcUnpinData(
262   _In_ PVOID Bcb);
263 
264 NTKERNELAPI
265 VOID
266 NTAPI
267 CcSetBcbOwnerPointer(
268   _In_ PVOID Bcb,
269   _In_ PVOID OwnerPointer);
270 
271 NTKERNELAPI
272 VOID
273 NTAPI
274 CcUnpinDataForThread(
275   _In_ PVOID Bcb,
276   _In_ ERESOURCE_THREAD ResourceThreadId);
277 
278 NTKERNELAPI
279 VOID
280 NTAPI
281 CcSetAdditionalCacheAttributes(
282   _In_ PFILE_OBJECT FileObject,
283   _In_ BOOLEAN DisableReadAhead,
284   _In_ BOOLEAN DisableWriteBehind);
285 
286 NTKERNELAPI
287 BOOLEAN
288 NTAPI
289 CcIsThereDirtyData(
290   _In_ PVPB Vpb);
291 
292 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
293 
294 #if (NTDDI_VERSION >= NTDDI_WINXP)
295 
296 NTKERNELAPI
297 VOID
298 NTAPI
299 CcMdlWriteAbort(
300   _In_ PFILE_OBJECT FileObject,
301   _In_ PMDL MdlChain);
302 
303 NTKERNELAPI
304 VOID
305 NTAPI
306 CcSetLogHandleForFile(
307   _In_ PFILE_OBJECT FileObject,
308   _In_ PVOID LogHandle,
309   _In_ PFLUSH_TO_LSN FlushToLsnRoutine);
310 
311 NTKERNELAPI
312 LARGE_INTEGER
313 NTAPI
314 CcGetDirtyPages(
315   _In_ PVOID LogHandle,
316   _In_ PDIRTY_PAGE_ROUTINE DirtyPageRoutine,
317   _In_ PVOID Context1,
318   _In_ PVOID Context2);
319 
320 #endif
321 
322 #if (NTDDI_VERSION >= NTDDI_WINXP)
323 _Success_(return!=FALSE)
324 NTKERNELAPI
325 BOOLEAN
326 NTAPI
327 CcMapData(
328   _In_ PFILE_OBJECT FileObject,
329   _In_ PLARGE_INTEGER FileOffset,
330   _In_ ULONG Length,
331   _In_ ULONG Flags,
332   _Outptr_ PVOID *Bcb,
333   _Outptr_result_bytebuffer_(Length) PVOID *Buffer);
334 #elif (NTDDI_VERSION >= NTDDI_WIN2K)
335 NTKERNELAPI
336 BOOLEAN
337 NTAPI
338 CcMapData(
339   _In_ PFILE_OBJECT FileObject,
340   _In_ PLARGE_INTEGER FileOffset,
341   _In_ ULONG Length,
342   _In_ BOOLEAN Wait,
343   _Outptr_ PVOID *Bcb,
344   _Outptr_result_bytebuffer_(Length) PVOID *Buffer);
345 #endif
346 
347 #if (NTDDI_VERSION >= NTDDI_VISTA)
348 
349 NTKERNELAPI
350 NTSTATUS
351 NTAPI
352 CcSetFileSizesEx(
353   _In_ PFILE_OBJECT FileObject,
354   _In_ PCC_FILE_SIZES FileSizes);
355 
356 NTKERNELAPI
357 PFILE_OBJECT
358 NTAPI
359 CcGetFileObjectFromSectionPtrsRef(
360   _In_ PSECTION_OBJECT_POINTERS SectionObjectPointer);
361 
362 NTKERNELAPI
363 VOID
364 NTAPI
365 CcSetParallelFlushFile(
366   _In_ PFILE_OBJECT FileObject,
367   _In_ BOOLEAN EnableParallelFlush);
368 
369 NTKERNELAPI
370 BOOLEAN
371 CcIsThereDirtyDataEx(
372   _In_ PVPB Vpb,
373   _In_opt_ PULONG NumberOfDirtyPages);
374 
375 #endif
376 
377 #if (NTDDI_VERSION >= NTDDI_WIN7)
378 NTKERNELAPI
379 VOID
380 NTAPI
381 CcCoherencyFlushAndPurgeCache(
382   _In_ PSECTION_OBJECT_POINTERS SectionObjectPointer,
383   _In_opt_ PLARGE_INTEGER FileOffset,
384   _In_ ULONG Length,
385   _Out_ PIO_STATUS_BLOCK IoStatus,
386   _In_opt_ ULONG Flags);
387 #endif
388 
389 #define CcGetFileSizePointer(FO) (                                     \
390     ((PLARGE_INTEGER)((FO)->SectionObjectPointer->SharedCacheMap) + 1) \
391 )
392 
393 #if (NTDDI_VERSION >= NTDDI_VISTA)
394 NTKERNELAPI
395 BOOLEAN
396 NTAPI
397 CcPurgeCacheSection(
398   _In_ PSECTION_OBJECT_POINTERS SectionObjectPointer,
399   _In_opt_ PLARGE_INTEGER FileOffset,
400   _In_ ULONG Length,
401   _In_ ULONG Flags);
402 #elif (NTDDI_VERSION >= NTDDI_WIN2K)
403 NTKERNELAPI
404 BOOLEAN
405 NTAPI
406 CcPurgeCacheSection(
407   _In_ PSECTION_OBJECT_POINTERS SectionObjectPointer,
408   _In_opt_ PLARGE_INTEGER FileOffset,
409   _In_ ULONG Length,
410   _In_ BOOLEAN UninitializeCacheMaps);
411 #endif
412 
413 #if (NTDDI_VERSION >= NTDDI_WIN7)
414 NTKERNELAPI
415 BOOLEAN
416 NTAPI
417 CcCopyWriteWontFlush(
418   _In_ PFILE_OBJECT FileObject,
419   _In_ PLARGE_INTEGER FileOffset,
420   _In_ ULONG Length);
421 #else
422 #define CcCopyWriteWontFlush(FO, FOFF, LEN) ((LEN) <= 0x10000)
423 #endif
424 
425 #define CcReadAhead(FO, FOFF, LEN) (                \
426     if ((LEN) >= 256) {                             \
427         CcScheduleReadAhead((FO), (FOFF), (LEN));   \
428     }                                               \
429 )
430 $endif (_NTIFS_)
431