94#define TAG_MAP_SEC TAG('C', 'c', 'S', 'x')
95#define TAG_MAP_READ TAG('M', 'c', 'p', 'y')
96#define TAG_MAP_BCB TAG('B', 'c', 'b', ' ')
143 PROS_SECTION_OBJECT *
Result)
228 ToUnmap =
Bcb->BaseAddress;
229 BaseOffset =
Bcb->FileOffset;
230 MappedSize =
Bcb->Map->FileSizes.ValidDataLength;
236 DPRINT(
"Firing work item for %x\n",
Bcb->BaseAddress);
248 PROS_SECTION_OBJECT ToDeref =
Bcb->SectionObject;
252 Bcb->FileOffset.QuadPart = 0;
272 WorkItem->AcquireForLazyWrite =
Bcb->Map->Callbacks.AcquireForLazyWrite;
273 WorkItem->ReleaseFromLazyWrite =
Bcb->Map->Callbacks.ReleaseFromLazyWrite;
283 Bcb->FileOffset.QuadPart = 0;
327 DPRINT(
"Allocating Cache Section\n");
334 DPRINT(
"Setting up Bcb #%x\n",
i);
340 if (
Bcb->RefCount > 0)
352 DPRINT1(
"Somebody stoeled BCB #%x\n",
i);
361 DPRINT1(
"Failed to allocate cache segment\n");
383 Bcb->ExclusiveWaiter++;
410 Bcb->ExclusiveWaiter--;
485 DPRINT1(
"File object was not mapped\n");
489 DPRINT(
"CcMapData(F->%x, %I64x:%d)\n",
512 DPRINT(
"Bcb #%x Buffer maps (%I64x) At %x Length %x (Getting %p:%x) %wZ\n",
514 Bcb->FileOffset.QuadPart,
525 DPRINT(
"File size %I64x\n",
543 DPRINT(
"Allocating a cache stripe at %x:%d\n",
544 Target.LowPart, SectionSize);
595 DPRINT(
"BcbHead #%x (final)\n", BcbHead);
605 DPRINT(
"Selected BCB #%x\n", BcbHead);
648 DPRINT(
"Bcb #%x Buffer maps (%I64x) At %x Length %x (Getting %p:%lx) %wZ\n",
650 Bcb->FileOffset.QuadPart,
657 EndInterval.
QuadPart =
Bcb->FileOffset.QuadPart +
Bcb->Length - 1;
671 DPRINT(
"Faulting in pages at this point: file %wZ %I64x:%x\n",
673 Bcb->FileOffset.QuadPart,
754 DPRINT(
"Requesting #%x Exclusive\n", BcbHead);
759 DPRINT(
"Reference #%x\n", BcbHead);
868 DPRINT(
"Zero fill #%x %I64x:%x Buffer %x %wZ\n",
913 if (RealBcb->RefCount <= 2)
915 RealBcb->Exclusive =
FALSE;
916 if (RealBcb->ExclusiveWaiter)
918 DPRINT(
"Triggering exclusive waiter\n");
923 if (RealBcb->RefCount == 2 && !ReleaseBit)
925 if (RealBcb->RefCount > 1)
931 if (RealBcb->RefCount == 1)
964 DPRINT(
"CcUnpinData Bcb #%x (RefCount %d)\n", Selected, RealBcb->
RefCount);
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
_In_ PFCB _In_ LONGLONG FileOffset
#define RtlFindClearBitsAndSet
#define NT_SUCCESS(StatCode)
static void cleanup(void)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
#define RemoveEntryList(Entry)
#define InsertTailList(ListHead, Entry)
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
#define KeSetEvent(pEvt, foo, foo2)
#define KeGetCurrentIrql()
#define ROUND_UP(n, align)
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
IN PVCB IN VBO IN ULONG OUT PBCB OUT PVOID IN BOOLEAN IN BOOLEAN Zero
#define ExAllocatePool(type, size)
_Must_inspect_result_ _Outptr_ PVOID * SectionObject
__in PWDFDEVICE_INIT __in BOOLEAN Exclusive
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
VOID FASTCALL ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
VOID FASTCALL ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
#define CACHE_ROUND_DOWN(x)
struct _NOCC_BCB * PNOCC_BCB
struct _NOCC_CACHE_MAP * PNOCC_CACHE_MAP
#define CACHE_NUM_SECTIONS
NTSTATUS NTAPI MmMapCacheViewInSystemSpaceAtOffset(IN PMM_SECTION_SEGMENT Segment, OUT PVOID *MappedBase, IN PLARGE_INTEGER ViewOffset, IN OUT PULONG ViewSize)
NTSTATUS NTAPI MmUnmapCacheViewInSystemSpace(PVOID Address)
#define MiFlushMappedSection(A, O, S, D)
#define STANDARD_RIGHTS_REQUIRED
_In_ ULONG _In_ ULONG _In_ ULONG Length
NTSTATUS NTAPI MiProtectVirtualMemory(IN PEPROCESS Process, IN OUT PVOID *BaseAddress, IN OUT PSIZE_T NumberOfBytesToProtect, IN ULONG NewAccessProtection, OUT PULONG OldAccessProtection OPTIONAL)
BOOLEAN NTAPI CcpMapData(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG Flags, OUT PVOID *BcbResult, OUT PVOID *Buffer)
struct _WORK_QUEUE_WITH_CONTEXT * PWORK_QUEUE_WITH_CONTEXT
VOID CcpReferenceCacheExclusive(ULONG Start)
VOID NTAPI CcUnpinData(IN PVOID Bcb)
NTSTATUS CcpAllocateSection(PFILE_OBJECT FileObject, ULONG Length, ULONG Protect, PROS_SECTION_OBJECT *Result)
NOCC_BCB CcCacheSections[CACHE_NUM_SECTIONS]
struct _WORK_QUEUE_WITH_CONTEXT WORK_QUEUE_WITH_CONTEXT
VOID NTAPI CcSetBcbOwnerPointer(IN PVOID Bcb, IN PVOID OwnerPointer)
ULONG CcpAllocateCacheSections(PFILE_OBJECT FileObject, PROS_SECTION_OBJECT SectionObject)
BOOLEAN NTAPI CcpPinMappedData(IN PNOCC_CACHE_MAP Map, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG Flags, IN OUT PVOID *Bcb)
VOID _CcpLock(const char *file, int line)
PDEVICE_OBJECT NTAPI MmGetDeviceObjectForFile(IN PFILE_OBJECT FileObject)
VOID CcpDereferenceCache(ULONG Start, BOOLEAN Immediate)
LONG CcOutstandingDeletes
VOID CcpMarkForExclusive(ULONG Start)
VOID NTAPI CcUnpinDataForThread(IN PVOID Bcb, IN ERESOURCE_THREAD ResourceThreadId)
PRTL_BITMAP CcCacheBitmap
BOOLEAN NTAPI CcPreparePinWrite(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Zero, IN ULONG Flags, OUT PVOID *Bcb, OUT PVOID *Buffer)
BOOLEAN NTAPI CcPinMappedData(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG Flags, IN OUT PVOID *Bcb)
ULONG CcpFindMatchingMap(PLIST_ENTRY Head, PLARGE_INTEGER FileOffset, ULONG Length)
CHAR CcpBitmapBuffer[sizeof(RTL_BITMAP)+ROUND_UP((CACHE_NUM_SECTIONS), 32)/8]
VOID CcpUnmapCache(PVOID Context)
BOOLEAN NTAPI CcPinRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG Flags, OUT PVOID *Bcb, OUT PVOID *Buffer)
BOOLEAN NTAPI CcMapData(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG Flags, OUT PVOID *BcbResult, OUT PVOID *Buffer)
VOID CcpReferenceCache(ULONG Start)
BOOLEAN NTAPI CcpUnpinData(IN PNOCC_BCB RealBcb, BOOLEAN ReleaseBit)
VOID _CcpUnlock(const char *file, int line)
NTSTATUS NTAPI MmCreateSection(OUT PVOID *Section, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN PLARGE_INTEGER MaximumSize, IN ULONG SectionPageProtection, IN ULONG AllocationAttributes, IN HANDLE FileHandle OPTIONAL, IN PFILE_OBJECT FileObject OPTIONAL)
base of all file and directory entries
LARGE_INTEGER ValidDataLength
struct _LIST_ENTRY * Flink
PACQUIRE_FOR_LAZY_WRITE AcquireForLazyWrite
PROS_SECTION_OBJECT ToDeref
PRELEASE_FROM_LAZY_WRITE ReleaseFromLazyWrite
#define RtlZeroMemory(Destination, Length)
#define CONTAINING_RECORD(address, type, field)
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
_Must_inspect_result_ _In_ PWDF_WORKITEM_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWORKITEM * WorkItem
VOID NTAPI ExQueueWorkItem(IN PWORK_QUEUE_ITEM WorkItem, IN WORK_QUEUE_TYPE QueueType)
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
_Must_inspect_result_ _In_ ULONG Flags
VOID(NTAPI * PRELEASE_FROM_LAZY_WRITE)(_In_ PVOID Context)
BOOLEAN(NTAPI * PACQUIRE_FOR_LAZY_WRITE)(_In_ PVOID Context, _In_ BOOLEAN Wait)
_In_ ERESOURCE_THREAD ResourceThreadId
#define ExInitializeWorkItem(Item, Routine, Context)
WORKER_THREAD_ROUTINE * PWORKER_THREAD_ROUTINE
ULONG_PTR ERESOURCE_THREAD
#define IO_DISK_INCREMENT
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Inout_ PLARGE_INTEGER NumberOfBytes
#define ObDereferenceObject
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T _In_ SECTION_INHERIT _In_ ULONG _In_ ULONG Protect