/* CONFIG: */
#define CAPTIVE_PUBLIC_BCB_NODETYPECODE 0xDE45 /* FIXME: unknown, undocumented */
+/* Prepare linear mapped space by CcInitializeCacheMap()?
+ * NT-5.1sp will map the same pages of a file to the same memory location
+ * either by CcMap*() or CcPin*().
+ * We do a separate mapping for each Bcb protected by bounding unmapped pages
+ * with IPC shm shared pages if a file page is mapped multiple times.
+ * I am not aware how they can reserve enough virtual memory space during
+ * client with mapping requests of increasing range tendency.
+ * This define will try to pre-map the file as one linear are during
+ * CcInitializeCacheMap() according to its (CC_FILE_SIZES *)FileSizes
+ * but TODO the range is currently left unused in further mapping functions.
+ */
+/* #define CAPTIVE_FILE_INITIALIZED_CACHE_IS_LINEAR 1 */
/* Flush all the buffers directly on the fly.
gboolean captive_cc_unmounting=FALSE;
-/* map: (FILE_OBJECT *)FileObject -> (FILE_OBJECT *)FileObject */
+/* map: (FILE_OBJECT *)FileObject -> (struct fileobject_cached *) */
static GHashTable *fileobject_cached_hash;
struct fileobject_cached {
CACHE_MANAGER_CALLBACKS CallBacks;
VOID *LazyWriterContext;
+#ifdef CAPTIVE_FILE_INITIALIZED_CACHE_IS_LINEAR
PVOID Bcb;
+#endif
};
static void fileobject_cached_hash_value_destroy_func(struct fileobject_cached *value)
IN PCC_FILE_SIZES FileSizes,IN BOOLEAN PinAccess,IN PCACHE_MANAGER_CALLBACKS CallBacks,IN PVOID LazyWriterContext)
{
struct fileobject_cached *fileobject_cached;
-#if 0
+#ifdef CAPTIVE_FILE_INITIALIZED_CACHE_IS_LINEAR
guint64 size64;
LARGE_INTEGER FileOffset0;
PVOID Buffer_trash;
FileObject, /* key */
fileobject_cached); /* value */
-#if 0
+#if CAPTIVE_FILE_INITIALIZED_CACHE_IS_LINEAR
size64=MAX(MAX(FileSizes->AllocationSize.QuadPart,FileSizes->FileSize.QuadPart),
(FileSizes->ValidDataLength.QuadPart==G_MAXINT64 ? 0 : FileSizes->ValidDataLength.QuadPart));
g_assert(((ULONG)size64)==size64);
if (!FileObject || !(fileobject_cached=g_hash_table_lookup(fileobject_cached_hash,FileObject)))
r=FALSE;
else {
-#if 0
+#ifdef CAPTIVE_FILE_INITIALIZED_CACHE_IS_LINEAR
CcUnpinData(fileobject_cached->Bcb);
#endif
g_hash_table_remove(fileobject_cached_hash,FileObject);