关键词不能为空

当前您在: 主页 > 英语 >

驱动中清除文件缓存

作者:高考题库网
来源:https://www.bjmy2z.cn/gaokao
2021-02-19 14:54
tags:

-

2021年2月19日发(作者:forgotten)



参考


1




void


PurgeFileSystemBuffers< /p>


(


PFILE_OBJECT FileObject


)



{



KeEnterCritical Region


();



if

< p>
(


ExAcquireResourceExclusiveLite


(



((


PFSR TL_COMMON_FCB_HEADER


)


FileO


bject


->


FsContext


)->


Resource


,

< br>


FALSE


))



{




if


(


FileObject


->


SectionObjectPointer


)



{



IoSetTopLevelIrp


(



(


PIRP


)


FSRTL_FSP_ TOP_LEVEL_IRP


);



CcFlushCache


(


FileObject


->


SectionObjectPointer


,



NULL


,


0


,



NULL



);




if


(


FileObject


->


SectionObjectPointer


->


ImageSectionObject


)




{



MmFlushImageSection


(



FileObject


->


SectionObjectPointer


,



MmFlushForWrite


//MmFlushForDelete//




)



;




}




if


(


FileObject


->


SectionObje ctPointer


->


DataSectionObject


)




{



CcPurgeCacheSection


(


FileObj ect


->


SectionObjectPointer


,




NULL


,



0


,




TRUE



);



//



TRUE


,会强迫所有的


FileOb ject


重新初始化


Cache




}






if


(


FileObject


->


PrivateCacheMap


)




{



CcUninitializeCacheMap

< p>
(


FileObject


,



NULL


,



NULL


);;




}




if


(


FileObject


->


SectionObje ctPointer


->


DataSectionObject


)




{




//rt


=


DELAY_ONE_MILLISECOND


*


500;//500ms




//KeDelayExecutionThread(KernelMode, FALSE, &Interval);



MmForceSectionClosed


(


FileOb ject


->


SectionObjectPointer


,



< /p>


TRUE


//


改为


TRUE,


彻底刷新缓存


!!!




);




}



IoSetT opLevelIrp


(


NULL


);




}



ExReleaseResourceLite


(


< p>
((


PFSRTL_COMMON_FCB_HEADER


)


FileObject


->


F


sContext


)->


Resou rce


);



}



KeLeaveCritica lRegion


();



}




参考


2




void


ManageFileCache


(


PFILE_OBJECT pFileObject


)




{




PFSRTL_COMMON_FCB_HEADER pFcb


;





LARGE_INTEGER liInterval


;




//BOOLEAN bNeedReleaseResource = FALSE;




//BOOLEAN bNeedReleasePagingIoResource = FALSE;



KIRQL irql


;



BOOLEAN bLockedResource


=


FALSE


;



BOOLEAN bLockedPagingIoResource


=


FALSE


;



BOOLEAN bReleaseResource

=


FALSE


;



BOOLEAN bReleasePagingIoResource< /p>


=


FALSE


;






pFcb


=



(


PFSRTL_COMMON_FCB_HEADER


)


pFileObject


->


FsContext


;




if


(


pFcb


==



NULL


)




{




return


;




}




irql


=


KeGetCurrentIrql


();




if



(


irql


>=


DISPATCH_LEVEL


)




{




return


;




}



liInterval


.


QuadPart


=



-


1


*



(


LON GLONG


)


50


;

< br>




//KeEnterCriticalRegion();



bLockedPagingIoResource


=



-


-


-


-


-


-


-


-



本文更新与2021-02-19 14:54,由作者提供,不代表本网站立场,转载请注明出处:https://www.bjmy2z.cn/gaokao/668017.html

驱动中清除文件缓存的相关文章