00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
#include "cc.h"
00023
00024
00025
00026
00027
00028 #define me 0x00000008
00029
00030
#if LIST_DBG
00031
00032
#define SetCallersAddress(BCB) { \
00033
RtlGetCallersAddress( &(BCB)->CallerAddress, \
00034
&(BCB)->CallersCallerAddress ); \
00035
}
00036
00037
#endif
00038
00039
00040
00041
00042
00043
POBCB
00044
CcAllocateObcb (
00045 IN PLARGE_INTEGER FileOffset,
00046 IN ULONG Length,
00047 IN
PBCB FirstBcb
00048 );
00049
00050
00051 BOOLEAN
00052 CcMapData (
00053 IN
PFILE_OBJECT FileObject,
00054 IN PLARGE_INTEGER FileOffset,
00055 IN ULONG Length,
00056 IN BOOLEAN Wait,
00057 OUT PVOID *Bcb,
00058 OUT PVOID *Buffer
00059 )
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129 {
00130
PSHARED_CACHE_MAP SharedCacheMap;
00131 LARGE_INTEGER BeyondLastByte;
00132 ULONG ReceivedLength;
00133 ULONG SavedState;
00134
volatile UCHAR ch;
00135 ULONG PageCount =
COMPUTE_PAGES_SPANNED((ULongToPtr(FileOffset->LowPart)), Length);
00136
PETHREAD Thread =
PsGetCurrentThread();
00137
00138
DebugTrace(+1,
me,
"CcMapData\n", 0 );
00139
00140
MmSavePageFaultReadAhead( Thread, &SavedState );
00141
00142
00143
00144
00145
00146
if (Wait) {
00147
00148
CcMapDataWait += 1;
00149
00150
00151
00152
00153
00154
CcMissCounter = &
CcMapDataWaitMiss;
00155
00156 }
else {
00157
CcMapDataNoWait += 1;
00158 }
00159
00160
00161
00162
00163
00164 SharedCacheMap = *(
PSHARED_CACHE_MAP *)((PCHAR)FileObject->SectionObjectPointer
00165 +
sizeof(PVOID));
00166
00167
00168
00169
00170
00171
00172
if (Wait) {
00173
00174 *
Buffer =
CcGetVirtualAddress( SharedCacheMap,
00175 *FileOffset,
00176 (
PVACB *)Bcb,
00177 &ReceivedLength );
00178
00179
ASSERT( ReceivedLength >= Length );
00180
00181 }
else if (!
CcPinFileData( FileObject,
00182 FileOffset,
00183 Length,
00184
TRUE,
00185
FALSE,
00186 Wait,
00187 (
PBCB *)Bcb,
00188
Buffer,
00189 &BeyondLastByte )) {
00190
00191
DebugTrace(-1,
me,
"CcMapData -> FALSE\n", 0 );
00192
00193
CcMapDataNoWaitMiss += 1;
00194
00195
return FALSE;
00196
00197 }
else {
00198
00199
ASSERT( (BeyondLastByte.QuadPart - FileOffset->QuadPart) >= Length );
00200
00201
#if LIST_DBG
00202
{
00203 KIRQL OldIrql;
00204
PBCB BcbTemp = (
PBCB)*Bcb;
00205
00206 ExAcquireSpinLock( &
CcBcbSpinLock, &OldIrql );
00207
00208
if (BcbTemp->CcBcbLinks.Flink ==
NULL) {
00209
00210 InsertTailList( &CcBcbList, &BcbTemp->CcBcbLinks );
00211 CcBcbCount += 1;
00212 ExReleaseSpinLock( &
CcBcbSpinLock, OldIrql );
00213 SetCallersAddress( BcbTemp );
00214
00215 }
else {
00216 ExReleaseSpinLock( &
CcBcbSpinLock, OldIrql );
00217 }
00218
00219 }
00220
#endif
00221
00222 }
00223
00224
00225
00226
00227
00228
try {
00229
00230
00231
00232
00233
00234 BeyondLastByte.LowPart = 0;
00235
00236
while (PageCount != 0) {
00237
00238
MmSetPageFaultReadAhead( Thread, PageCount - 1 );
00239
00240 ch = *((
volatile UCHAR *)(*Buffer) + BeyondLastByte.LowPart);
00241
00242 BeyondLastByte.LowPart +=
PAGE_SIZE;
00243 PageCount -= 1;
00244 }
00245
00246 } finally {
00247
00248
MmResetPageFaultReadAhead( Thread, SavedState );
00249
00250
if (AbnormalTermination() && (*Bcb !=
NULL)) {
00251
CcUnpinFileData( (
PBCB)*Bcb,
TRUE,
UNPIN );
00252 *Bcb =
NULL;
00253 }
00254 }
00255
00256
CcMissCounter = &
CcThrowAway;
00257
00258
00259
00260
00261
00262 *(PCHAR *)Bcb += 1;
00263
00264
DebugTrace(-1,
me,
"CcMapData -> TRUE\n", 0 );
00265
00266
return TRUE;
00267 }
00268
00269
00270 BOOLEAN
00271 CcPinMappedData (
00272 IN
PFILE_OBJECT FileObject,
00273 IN PLARGE_INTEGER FileOffset,
00274 IN ULONG Length,
00275 IN ULONG Flags,
00276 IN OUT PVOID *Bcb
00277 )
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340 {
00341 PVOID
Buffer;
00342 LARGE_INTEGER BeyondLastByte;
00343
PSHARED_CACHE_MAP SharedCacheMap;
00344 LARGE_INTEGER LocalFileOffset = *FileOffset;
00345
POBCB MyBcb =
NULL;
00346
PBCB *CurrentBcbPtr = (
PBCB *)&MyBcb;
00347 BOOLEAN Result =
FALSE;
00348
00349
DebugTrace(+1,
me,
"CcPinMappedData\n", 0 );
00350
00351
00352
00353
00354
00355
if ((*(PULONG)Bcb & 1) == 0) {
00356
return TRUE;
00357 }
00358
00359
00360
00361
00362
00363 *(PCHAR *)Bcb -= 1;
00364
00365
00366
00367
00368
00369 SharedCacheMap = *(
PSHARED_CACHE_MAP *)((PCHAR)FileObject->SectionObjectPointer
00370 +
sizeof(PVOID));
00371
00372
00373
00374
00375
00376
00377
CcPinMappedDataCount += 1;
00378
00379
00380
00381
00382
00383
try {
00384
00385
if (((
PBCB)*Bcb)->NodeTypeCode !=
CACHE_NTC_BCB) {
00386
00387
00388
00389
00390
00391
do {
00392
00393
00394
00395
00396
00397
00398
if (MyBcb !=
NULL) {
00399
00400
00401
00402
00403
00404
00405
if (CurrentBcbPtr == (
PBCB *)&MyBcb) {
00406
00407 MyBcb =
CcAllocateObcb( FileOffset, Length, (
PBCB)MyBcb );
00408
00409
00410
00411
00412
00413
00414
00415 CurrentBcbPtr = &MyBcb->Bcbs[0];
00416 }
00417
00418 Length -= (ULONG)(BeyondLastByte.QuadPart - LocalFileOffset.QuadPart);
00419 LocalFileOffset.QuadPart = BeyondLastByte.QuadPart;
00420 CurrentBcbPtr += 1;
00421 }
00422
00423
00424
00425
00426
00427
00428
if (!
CcPinFileData( FileObject,
00429 &LocalFileOffset,
00430 Length,
00431 (BOOLEAN)!
FlagOn(SharedCacheMap->
Flags,
MODIFIED_WRITE_DISABLED),
00432
FALSE,
00433 Flags,
00434 CurrentBcbPtr,
00435 &
Buffer,
00436 &BeyondLastByte )) {
00437
00438
try_return( Result =
FALSE );
00439 }
00440
00441
00442
00443
00444
00445 }
while((BeyondLastByte.QuadPart - LocalFileOffset.QuadPart) < Length);
00446
00447
00448
00449
00450
00451
CcFreeVirtualAddress( (
PVACB)*Bcb );
00452
00453 *Bcb = MyBcb;
00454
00455
00456
00457
00458
00459
#if LIST_DBG
00460
{
00461 KIRQL OldIrql;
00462
PBCB BcbTemp = (
PBCB)*Bcb;
00463
00464 ExAcquireSpinLock( &
CcBcbSpinLock, &OldIrql );
00465
00466
if (BcbTemp->CcBcbLinks.Flink ==
NULL) {
00467
00468 InsertTailList( &CcBcbList, &BcbTemp->CcBcbLinks );
00469 CcBcbCount += 1;
00470 ExReleaseSpinLock( &
CcBcbSpinLock, OldIrql );
00471 SetCallersAddress( BcbTemp );
00472
00473 }
else {
00474 ExReleaseSpinLock( &
CcBcbSpinLock, OldIrql );
00475 }
00476
00477 }
00478
#endif
00479
}
00480
00481
00482
00483
00484
00485
00486
else {
00487
00488
if (!
ExAcquireSharedStarveExclusive( &((
PBCB)*Bcb)->
Resource,
BooleanFlagOn(Flags,
PIN_WAIT))) {
00489
00490
try_return( Result =
FALSE );
00491 }
00492 }
00493
00494 Result =
TRUE;
00495
00496 try_exit: NOTHING;
00497 }
00498 finally {
00499
00500
if (!Result) {
00501
00502
00503
00504
00505
00506 *(PCHAR *)Bcb += 1;
00507
00508
00509
00510
00511
00512
if (MyBcb !=
NULL) {
00513
CcUnpinData( MyBcb );
00514 }
00515 }
00516
00517
DebugTrace(-1,
me,
"CcPinMappedData -> %02lx\n", Result );
00518 }
00519
return Result;
00520 }
00521
00522
00523 BOOLEAN
00524 CcPinRead (
00525 IN
PFILE_OBJECT FileObject,
00526 IN PLARGE_INTEGER FileOffset,
00527 IN ULONG Length,
00528 IN ULONG Flags,
00529 OUT PVOID *Bcb,
00530 OUT PVOID *Buffer
00531 )
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596 {
00597
PSHARED_CACHE_MAP SharedCacheMap;
00598 PVOID LocalBuffer;
00599 LARGE_INTEGER BeyondLastByte;
00600 LARGE_INTEGER LocalFileOffset = *FileOffset;
00601
POBCB MyBcb =
NULL;
00602
PBCB *CurrentBcbPtr = (
PBCB *)&MyBcb;
00603 BOOLEAN Result =
FALSE;
00604
00605
DebugTrace(+1,
me,
"CcPinRead\n", 0 );
00606
00607
00608
00609
00610
00611
if (
FlagOn(Flags,
PIN_WAIT)) {
00612
00613
CcPinReadWait += 1;
00614
00615
00616
00617
00618
00619
CcMissCounter = &
CcPinReadWaitMiss;
00620
00621 }
else {
00622
CcPinReadNoWait += 1;
00623 }
00624
00625
00626
00627
00628
00629 SharedCacheMap = *(
PSHARED_CACHE_MAP *)((PCHAR)FileObject->SectionObjectPointer
00630 +
sizeof(PVOID));
00631
00632
try {
00633
00634
00635
00636
00637
00638
do {
00639
00640
00641
00642
00643
00644
00645
if (MyBcb !=
NULL) {
00646
00647
00648
00649
00650
00651
00652
if (CurrentBcbPtr == (
PBCB *)&MyBcb) {
00653
00654 MyBcb =
CcAllocateObcb( FileOffset, Length, (
PBCB)MyBcb );
00655
00656
00657
00658
00659
00660
00661
00662 CurrentBcbPtr = &MyBcb->Bcbs[0];
00663
00664
00665
00666
00667
00668 *
Buffer = LocalBuffer;
00669 }
00670
00671 Length -= (ULONG)(BeyondLastByte.QuadPart - LocalFileOffset.QuadPart);
00672 LocalFileOffset.QuadPart = BeyondLastByte.QuadPart;
00673 CurrentBcbPtr += 1;
00674 }
00675
00676
00677
00678
00679
00680
00681
if (!
CcPinFileData( FileObject,
00682 &LocalFileOffset,
00683 Length,
00684 (BOOLEAN)!
FlagOn(SharedCacheMap->
Flags,
MODIFIED_WRITE_DISABLED),
00685
FALSE,
00686 Flags,
00687 CurrentBcbPtr,
00688 &LocalBuffer,
00689 &BeyondLastByte )) {
00690
00691
CcPinReadNoWaitMiss += 1;
00692
00693
try_return( Result =
FALSE );
00694 }
00695
00696
00697
00698
00699
00700 }
while((BeyondLastByte.QuadPart - LocalFileOffset.QuadPart) < Length);
00701
00702 *Bcb = MyBcb;
00703
00704
00705
00706
00707
00708
#if LIST_DBG
00709
00710 {
00711 KIRQL OldIrql;
00712
PBCB BcbTemp = (
PBCB)*Bcb;
00713
00714 ExAcquireSpinLock( &
CcBcbSpinLock, &OldIrql );
00715
00716
if (BcbTemp->CcBcbLinks.Flink ==
NULL) {
00717
00718 InsertTailList( &CcBcbList, &BcbTemp->CcBcbLinks );
00719 CcBcbCount += 1;
00720 ExReleaseSpinLock( &
CcBcbSpinLock, OldIrql );
00721 SetCallersAddress( BcbTemp );
00722
00723 }
else {
00724 ExReleaseSpinLock( &
CcBcbSpinLock, OldIrql );
00725 }
00726
00727 }
00728
00729
#endif
00730
00731
00732
00733
00734
00735
00736
if (CurrentBcbPtr == (
PBCB *)&MyBcb) {
00737 *
Buffer = LocalBuffer;
00738 }
00739
00740 Result =
TRUE;
00741
00742 try_exit: NOTHING;
00743 }
00744 finally {
00745
00746
CcMissCounter = &
CcThrowAway;
00747
00748
if (!Result) {
00749
00750
00751
00752
00753
00754
if (MyBcb !=
NULL) {
00755
CcUnpinData( MyBcb );
00756 }
00757 }
00758
00759
DebugTrace(-1,
me,
"CcPinRead -> %02lx\n", Result );
00760 }
00761
00762
return Result;
00763 }
00764
00765
00766 BOOLEAN
00767 CcPreparePinWrite (
00768 IN
PFILE_OBJECT FileObject,
00769 IN PLARGE_INTEGER FileOffset,
00770 IN ULONG Length,
00771 IN BOOLEAN Zero,
00772 IN ULONG Flags,
00773 OUT PVOID *Bcb,
00774 OUT PVOID *Buffer
00775 )
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842 {
00843
PSHARED_CACHE_MAP SharedCacheMap;
00844 PVOID LocalBuffer;
00845 LARGE_INTEGER BeyondLastByte;
00846 LARGE_INTEGER LocalFileOffset = *FileOffset;
00847
POBCB MyBcb =
NULL;
00848
PBCB *CurrentBcbPtr = (
PBCB *)&MyBcb;
00849 ULONG OriginalLength = Length;
00850 BOOLEAN Result =
FALSE;
00851
00852
DebugTrace(+1,
me,
"CcPreparePinWrite\n", 0 );
00853
00854
00855
00856
00857
00858 SharedCacheMap = *(
PSHARED_CACHE_MAP *)((PCHAR)FileObject->SectionObjectPointer
00859 +
sizeof(PVOID));
00860
00861
try {
00862
00863
00864
00865
00866
00867
do {
00868
00869
00870
00871
00872
00873
00874
if (MyBcb !=
NULL) {
00875
00876
00877
00878
00879
00880
00881
if (CurrentBcbPtr == (
PBCB *)&MyBcb) {
00882
00883 MyBcb =
CcAllocateObcb( FileOffset, Length, (
PBCB)MyBcb );
00884
00885
00886
00887
00888
00889
00890
00891 CurrentBcbPtr = &MyBcb->Bcbs[0];
00892
00893
00894
00895
00896
00897 *
Buffer = LocalBuffer;
00898 }
00899
00900 Length -= (ULONG)(BeyondLastByte.QuadPart - LocalFileOffset.QuadPart);
00901 LocalFileOffset.QuadPart = BeyondLastByte.QuadPart;
00902 CurrentBcbPtr += 1;
00903 }
00904
00905
00906
00907
00908
00909
00910
if (!
CcPinFileData( FileObject,
00911 &LocalFileOffset,
00912 Length,
00913
FALSE,
00914
TRUE,
00915 Flags,
00916 CurrentBcbPtr,
00917 &LocalBuffer,
00918 &BeyondLastByte )) {
00919
00920
try_return( Result =
FALSE );
00921 }
00922
00923
00924
00925
00926
00927 }
while((BeyondLastByte.QuadPart - LocalFileOffset.QuadPart) < Length);
00928
00929 *Bcb = MyBcb;
00930
00931
00932
00933
00934
00935
#if LIST_DBG
00936
00937 {
00938 KIRQL OldIrql;
00939
PBCB BcbTemp = (
PBCB)*Bcb;
00940
00941 ExAcquireSpinLock( &
CcBcbSpinLock, &OldIrql );
00942
00943
if (BcbTemp->CcBcbLinks.Flink ==
NULL) {
00944
00945 InsertTailList( &CcBcbList, &BcbTemp->CcBcbLinks );
00946 CcBcbCount += 1;
00947 ExReleaseSpinLock( &
CcBcbSpinLock, OldIrql );
00948 SetCallersAddress( BcbTemp );
00949
00950 }
else {
00951 ExReleaseSpinLock( &
CcBcbSpinLock, OldIrql );
00952 }
00953
00954 }
00955
00956
#endif
00957
00958
00959
00960
00961
00962
00963
if (CurrentBcbPtr == (
PBCB *)&MyBcb) {
00964 *
Buffer = LocalBuffer;
00965 }
00966
00967
if (
Zero) {
00968 RtlZeroMemory( *
Buffer, OriginalLength );
00969 }
00970
00971
CcSetDirtyPinnedData( MyBcb,
NULL );
00972
00973 Result =
TRUE;
00974
00975 try_exit: NOTHING;
00976 }
00977 finally {
00978
00979
CcMissCounter = &
CcThrowAway;
00980
00981
if (!Result) {
00982
00983
00984
00985
00986
00987
if (MyBcb !=
NULL) {
00988
CcUnpinData( MyBcb );
00989 }
00990 }
00991
00992
DebugTrace(-1,
me,
"CcPreparePinWrite -> %02lx\n", Result );
00993 }
00994
00995
return Result;
00996 }
00997
00998
00999
VOID
01000 CcUnpinData (
01001 IN PVOID Bcb
01002 )
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021 {
01022
DebugTrace(+1,
me,
"CcUnpinData:\n", 0 );
01023
DebugTrace( 0,
me,
" >Bcb = %08lx\n", Bcb );
01024
01025
01026
01027
01028
01029
if (((ULONG_PTR)Bcb & 1) != 0) {
01030
01031
01032
01033
01034
01035 (PCHAR)Bcb -= 1;
01036
01037
CcUnpinFileData( (
PBCB)Bcb,
TRUE,
UNPIN );
01038
01039 }
else {
01040
01041
01042
01043
01044
01045
if (((
POBCB)Bcb)->NodeTypeCode ==
CACHE_NTC_OBCB) {
01046
01047
PBCB *BcbPtrPtr = &((
POBCB)Bcb)->Bcbs[0];
01048
01049
01050
01051
01052
01053
01054
while (*BcbPtrPtr !=
NULL) {
01055
CcUnpinData(*(BcbPtrPtr++));
01056 }
01057
01058
01059
01060
01061
01062
ExFreePool( Bcb );
01063
01064
01065
01066
01067
01068 }
else {
01069
CcUnpinFileData( (
PBCB)Bcb,
FALSE,
UNPIN );
01070 }
01071 }
01072
01073
DebugTrace(-1,
me,
"CcUnPinData -> VOID\n", 0 );
01074 }
01075
01076
01077
VOID
01078 CcSetBcbOwnerPointer (
01079 IN PVOID Bcb,
01080 IN PVOID OwnerPointer
01081 )
01082
01083
01084
01085
01086
01087
01088
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100
01101
01102
01103
01104
01105
01106 {
01107
ASSERT(((ULONG_PTR)Bcb & 1) == 0);
01108
01109
01110
01111
01112
01113
if (((
POBCB)Bcb)->NodeTypeCode ==
CACHE_NTC_OBCB) {
01114
01115
PBCB *BcbPtrPtr = &((
POBCB)Bcb)->Bcbs[0];
01116
01117
01118
01119
01120
01121
while (*BcbPtrPtr !=
NULL) {
01122
ExSetResourceOwnerPointer( &(*BcbPtrPtr)->Resource, OwnerPointer );
01123 BcbPtrPtr++;
01124 }
01125
01126
01127
01128
01129
01130 }
else {
01131
01132
01133
01134
01135
01136
ExSetResourceOwnerPointer( &((
PBCB)Bcb)->
Resource, OwnerPointer );
01137 }
01138 }
01139
01140
01141
VOID
01142 CcUnpinDataForThread (
01143 IN PVOID Bcb,
01144 IN ERESOURCE_THREAD ResourceThreadId
01145 )
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159
01160
01161
01162
01163
01164
01165 {
01166
DebugTrace(+1,
me,
"CcUnpinDataForThread:\n", 0 );
01167
DebugTrace( 0,
me,
" >Bcb = %08lx\n", Bcb );
01168
DebugTrace( 0,
me,
" >ResoureceThreadId = %08lx\n", ResoureceThreadId );
01169
01170
01171
01172
01173
01174
if (((ULONG_PTR)Bcb & 1) != 0) {
01175
01176
01177
01178
01179
01180 (PCHAR)Bcb -= 1;
01181
01182
CcUnpinFileData( (
PBCB)Bcb,
TRUE,
UNPIN );
01183
01184 }
else {
01185
01186
01187
01188
01189
01190
if (((
POBCB)Bcb)->NodeTypeCode ==
CACHE_NTC_OBCB) {
01191
01192
PBCB *BcbPtrPtr = &((
POBCB)Bcb)->Bcbs[0];
01193
01194
01195
01196
01197
01198
01199
while (*BcbPtrPtr !=
NULL) {
01200
CcUnpinDataForThread( *(BcbPtrPtr++), ResourceThreadId );
01201 }
01202
01203
01204
01205
01206
01207
ExFreePool( Bcb );
01208
01209
01210
01211
01212
01213 }
else {
01214
01215
01216
01217
01218
01219
01220
01221
ExReleaseResourceForThread( &((
PBCB)Bcb)->
Resource, ResourceThreadId );
01222
CcUnpinFileData( (
PBCB)Bcb,
TRUE,
UNPIN );
01223 }
01224 }
01225
DebugTrace(-1,
me,
"CcUnpinDataForThread -> VOID\n", 0 );
01226 }
01227
01228
01229
POBCB
01230 CcAllocateObcb (
01231 IN PLARGE_INTEGER FileOffset,
01232 IN ULONG Length,
01233 IN
PBCB FirstBcb
01234 )
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247
01248
01249
01250
01251
01252
01253
01254
01255
01256
01257
01258
01259 {
01260 ULONG LengthToAllocate;
01261
POBCB Obcb;
01262
PBCB Bcb = (
PBCB)((ULONG_PTR)FirstBcb & ~1);
01263
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274
01275
01276 LengthToAllocate = FIELD_OFFSET(
OBCB, Bcbs) + (2 *
sizeof(
PBCB)) +
01277 ((Length -
01278 (Bcb->
ByteLength -
01279 (FileOffset->HighPart?
01280 (ULONG)(FileOffset->QuadPart - Bcb->
FileOffset.QuadPart) :
01281 FileOffset->LowPart - Bcb->
FileOffset.LowPart)) +
01282
PAGE_SIZE - 1) /
PAGE_SIZE) *
sizeof(
PBCB);
01283
01284 Obcb =
FsRtlAllocatePoolWithTag(
NonPagedPool, LengthToAllocate, 'bOcC' );
01285 RtlZeroMemory( Obcb, LengthToAllocate );
01286 Obcb->
NodeTypeCode =
CACHE_NTC_OBCB;
01287 Obcb->
NodeByteSize = (
USHORT)LengthToAllocate;
01288 Obcb->
ByteLength = Length;
01289 Obcb->
FileOffset = *FileOffset;
01290 Obcb->
Bcbs[0] = FirstBcb;
01291
01292
return Obcb;
01293 }