200{
203 BOOLEAN WriteToEof, AcquiredShared, FileSizeChanged, Ret;
205
207
208
211
212
214 {
216 }
217
218
220 {
222 }
223
224
226 {
228 }
229
230
233
234
236 {
238 }
239
240 AcquiredShared =
FALSE;
241 FileSizeChanged =
FALSE;
243
245
246
247 if (!
Wait || (
Fcb->AllocationSize.HighPart != 0))
248 {
249
251 {
253 {
256 }
257 }
258
259 else
260 {
262 {
265 }
266
267 AcquiredShared =
TRUE;
268 }
269
270
271 if (WriteToEof)
272 {
275 }
276 else
277 {
280 }
281
282
285 {
288
290 }
291
292
293
294
295 if ((
Fcb->ValidDataLength.QuadPart + 0x2000 <=
WriteOffset.QuadPart) ||
297 (
Fcb->AllocationSize.QuadPart < LastOffset.
QuadPart))
298 {
301
303 }
304
305
306 if (AcquiredShared && LastOffset.
QuadPart >
Fcb->ValidDataLength.QuadPart)
307 {
308
311 {
314 }
315
316
317 if (WriteToEof)
318 {
321 }
322
323
326 {
329
331 }
332
333
334 if (
Fcb->AllocationSize.QuadPart < LastOffset.
QuadPart)
335 {
338
340 }
341 }
342
343
345 {
348
350 FastIoDispatch = RelatedDeviceObject->DriverObject->FastIoDispatch;
353
357 FALSE, &LocalIoStatus,
358 RelatedDeviceObject))
359 {
362
364 }
365 }
366
367
368
369
371 {
372 FileSizeChanged =
TRUE;
374 InitialValidDataLength.
QuadPart =
Fcb->ValidDataLength.QuadPart;
375
376 if (LastOffset.
HighPart !=
Fcb->FileSize.HighPart &&
378 {
382 }
383 else
384 {
386 }
387 }
388
389
391
393
394
396 {
397
398 if (LastOffset.
QuadPart >
Fcb->ValidDataLength.QuadPart)
399 {
402 }
403
404
405 if (Ret)
406 {
409 }
410 }
414 {
416 }
418
419
421
422
423 if (Ret)
424 {
425
426 if (LastOffset.
QuadPart >
Fcb->ValidDataLength.QuadPart)
427 {
428 if (LastOffset.
HighPart !=
Fcb->ValidDataLength.HighPart &&
430 {
432 Fcb->ValidDataLength.QuadPart = LastOffset.
QuadPart;
434 }
435 else
436 {
437 Fcb->ValidDataLength.QuadPart = LastOffset.
QuadPart;
438 }
439 }
440
441
443
444
445 if (FileSizeChanged)
446 {
449 }
450
451
453 }
454 else
455 {
456
457 if (FileSizeChanged)
458 {
460 {
463 Fcb->ValidDataLength.QuadPart = InitialValidDataLength.
QuadPart;
465 }
466 else
467 {
469 Fcb->ValidDataLength.QuadPart = InitialValidDataLength.
QuadPart;
470 }
471 }
472 }
473 }
474 else
475 {
477
480
481
482
483
485 {
487 }
488
489 else
490 {
492 AcquiredShared =
TRUE;
493 }
494
495
496
497
498
499 if (WriteToEof)
500 {
503 AboveFour = (LastOffset.
LowPart <
Fcb->FileSize.LowPart);
504 }
505 else
506 {
511 }
512
513
516 {
519
521 }
522
523
524
525
526
527 if ((
Fcb->AllocationSize.LowPart < LastOffset.
LowPart) ||
529 AboveFour)
530 {
533
535 }
536
537
538 if (AcquiredShared && LastOffset.
LowPart >
Fcb->ValidDataLength.LowPart)
539 {
540
543
544
545
546
547 if (WriteToEof)
548 {
551 AboveFour = (LastOffset.
LowPart <
Fcb->FileSize.LowPart);
552 }
553
554
557 {
560
562 }
563
564
565
566
567 if ((
Fcb->AllocationSize.LowPart < LastOffset.
LowPart) ||
568 (
Fcb->AllocationSize.HighPart != 0) || AboveFour)
569 {
572
574 }
575 }
576
577
579 {
582
584 FastIoDispatch = RelatedDeviceObject->DriverObject->FastIoDispatch;
587
591 FALSE, &LocalIoStatus,
592 RelatedDeviceObject))
593 {
596
598 }
599 }
600
601
602
603
604 if (LastOffset.
LowPart >
Fcb->FileSize.LowPart)
605 {
606 FileSizeChanged =
TRUE;
607 InitialFileSize.
LowPart =
Fcb->FileSize.LowPart;
608 InitialValidDataLength.
LowPart =
Fcb->ValidDataLength.LowPart;
610 }
611
612
614
616
617
619 {
620
621
622
623 if (LastOffset.
LowPart >
Fcb->ValidDataLength.LowPart)
624 {
626 }
627
628
630 }
634 {
636 }
638
639
641
642
643 if (Ret)
644 {
645
646 if (LastOffset.
LowPart >
Fcb->ValidDataLength.LowPart)
647 {
648 Fcb->ValidDataLength.LowPart = LastOffset.
LowPart;
649 }
650
651
653
654
655 if (FileSizeChanged)
656 {
659 }
660
661
664 }
665 else
666 {
667
668 if (FileSizeChanged)
669 {
671 {
673 Fcb->FileSize.LowPart = InitialFileSize.
LowPart;
674 Fcb->ValidDataLength.LowPart = InitialValidDataLength.
LowPart;
676 }
677 else
678 {
679 Fcb->FileSize.LowPart = InitialFileSize.
LowPart;
680 Fcb->ValidDataLength.LowPart = InitialValidDataLength.
LowPart;
681 }
682 }
683 }
684 }
685
686
688
690
691 return Ret;
692}
NTKERNELAPI BOOLEAN NTAPI CcCopyWriteWontFlush(_In_ PFILE_OBJECT FileObject, _In_ PLARGE_INTEGER FileOffset, _In_ ULONG Length)
#define CcGetFileSizePointer(FO)
#define ExAcquireResourceExclusiveLite(res, wait)
#define FILE_WRITE_TO_END_OF_FILE
#define BooleanFlagOn(F, SF)
BOOLEAN NTAPI CcZeroData(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER StartOffset, IN PLARGE_INTEGER EndOffset, IN BOOLEAN Wait)
VOID NTAPI CcFastCopyWrite(IN PFILE_OBJECT FileObject, IN ULONG FileOffset, IN ULONG Length, IN PVOID Buffer)
BOOLEAN NTAPI CcCopyWrite(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN PVOID Buffer)
BOOLEAN NTAPI CcCanIWrite(IN PFILE_OBJECT FileObject, IN ULONG BytesToWrite, IN BOOLEAN Wait, IN UCHAR Retrying)
ERESOURCE PagingIoResource
_Must_inspect_result_ _In_ WDFUSBPIPE _In_ WDFREQUEST _In_opt_ WDFMEMORY _In_opt_ PWDFMEMORY_OFFSET WriteOffset
#define FO_FILE_SIZE_CHANGED