Fixed header dependencies to be fully compatible with the Windows
[wine/multimedia.git] / dlls / ole32 / stg_bigblockfile.c
blob22e5d7b564ef3de4a7fe4479d367b7b928732211
1 /******************************************************************************
3 * BigBlockFile
5 * This is the implementation of a file that consists of blocks of
6 * a predetermined size.
7 * This class is used in the Compound File implementation of the
8 * IStorage and IStream interfaces. It provides the functionality
9 * to read and write any blocks in the file as well as setting and
10 * obtaining the size of the file.
11 * The blocks are indexed sequentially from the start of the file
12 * starting with -1.
14 * TODO:
15 * - Support for a transacted mode
17 * Copyright 1999 Thuy Nguyen
19 * This library is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU Lesser General Public
21 * License as published by the Free Software Foundation; either
22 * version 2.1 of the License, or (at your option) any later version.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 #include <assert.h>
35 #include <stdlib.h>
36 #include <stdarg.h>
37 #include <stdio.h>
38 #include <string.h>
39 #include <limits.h>
41 #define NONAMELESSUNION
42 #define NONAMELESSSTRUCT
43 #include "windef.h"
44 #include "winbase.h"
45 #include "winerror.h"
46 #include "objbase.h"
47 #include "ole2.h"
49 #include "storage32.h"
51 #include "wine/debug.h"
53 WINE_DEFAULT_DEBUG_CHANNEL(storage);
55 /***********************************************************
56 * Data structures used internally by the BigBlockFile
57 * class.
60 /* We map in PAGE_SIZE-sized chunks. Must be a multiple of 4096. */
61 #define PAGE_SIZE 131072
63 #define BLOCKS_PER_PAGE (PAGE_SIZE / BIG_BLOCK_SIZE)
65 /* We keep a list of recently-discarded pages. This controls the
66 * size of that list. */
67 #define MAX_VICTIM_PAGES 16
69 /* This structure provides one bit for each block in a page.
70 * Use BIGBLOCKFILE_{Test,Set,Clear}Bit to manipulate it. */
71 typedef struct
73 unsigned int bits[BLOCKS_PER_PAGE / (CHAR_BIT * sizeof(unsigned int))];
74 } BlockBits;
76 /***
77 * This structure identifies the paged that are mapped
78 * from the file and their position in memory. It is
79 * also used to hold a reference count to those pages.
81 * page_index identifies which PAGE_SIZE chunk from the
82 * file this mapping represents. (The mappings are always
83 * PAGE_SIZE-aligned.)
85 struct MappedPage
87 MappedPage *next;
88 MappedPage *prev;
90 DWORD page_index;
91 LPVOID lpBytes;
92 LONG refcnt;
94 BlockBits readable_blocks;
95 BlockBits writable_blocks;
98 /***********************************************************
99 * Prototypes for private methods
101 static void* BIGBLOCKFILE_GetMappedView(LPBIGBLOCKFILE This,
102 DWORD page_index);
103 static void BIGBLOCKFILE_ReleaseMappedPage(LPBIGBLOCKFILE This,
104 MappedPage *page);
105 static void BIGBLOCKFILE_FreeAllMappedPages(LPBIGBLOCKFILE This);
106 static void BIGBLOCKFILE_UnmapAllMappedPages(LPBIGBLOCKFILE This);
107 static void BIGBLOCKFILE_RemapAllMappedPages(LPBIGBLOCKFILE This);
108 static void* BIGBLOCKFILE_GetBigBlockPointer(LPBIGBLOCKFILE This,
109 ULONG index,
110 DWORD desired_access);
111 static MappedPage* BIGBLOCKFILE_GetPageFromPointer(LPBIGBLOCKFILE This,
112 void* pBlock);
113 static MappedPage* BIGBLOCKFILE_CreatePage(LPBIGBLOCKFILE This,
114 ULONG page_index);
115 static DWORD BIGBLOCKFILE_GetProtectMode(DWORD openFlags);
116 static BOOL BIGBLOCKFILE_FileInit(LPBIGBLOCKFILE This, HANDLE hFile);
117 static BOOL BIGBLOCKFILE_MemInit(LPBIGBLOCKFILE This, ILockBytes* plkbyt);
119 /* Note that this evaluates a and b multiple times, so don't
120 * pass expressions with side effects. */
121 #define ROUND_UP(a, b) ((((a) + (b) - 1)/(b))*(b))
123 /***********************************************************
124 * Blockbits functions.
126 static inline BOOL BIGBLOCKFILE_TestBit(const BlockBits *bb,
127 unsigned int index)
129 unsigned int array_index = index / (CHAR_BIT * sizeof(unsigned int));
130 unsigned int bit_index = index % (CHAR_BIT * sizeof(unsigned int));
132 return bb->bits[array_index] & (1 << bit_index);
135 static inline void BIGBLOCKFILE_SetBit(BlockBits *bb, unsigned int index)
137 unsigned int array_index = index / (CHAR_BIT * sizeof(unsigned int));
138 unsigned int bit_index = index % (CHAR_BIT * sizeof(unsigned int));
140 bb->bits[array_index] |= (1 << bit_index);
143 static inline void BIGBLOCKFILE_ClearBit(BlockBits *bb, unsigned int index)
145 unsigned int array_index = index / (CHAR_BIT * sizeof(unsigned int));
146 unsigned int bit_index = index % (CHAR_BIT * sizeof(unsigned int));
148 bb->bits[array_index] &= ~(1 << bit_index);
151 static inline void BIGBLOCKFILE_Zero(BlockBits *bb)
153 memset(bb->bits, 0, sizeof(bb->bits));
156 /******************************************************************************
157 * BIGBLOCKFILE_Construct
159 * Construct a big block file. Create the file mapping object.
160 * Create the read only mapped pages list, the writable mapped page list
161 * and the blocks in use list.
163 BigBlockFile * BIGBLOCKFILE_Construct(
164 HANDLE hFile,
165 ILockBytes* pLkByt,
166 DWORD openFlags,
167 ULONG blocksize,
168 BOOL fileBased)
170 LPBIGBLOCKFILE This;
172 This = (LPBIGBLOCKFILE)HeapAlloc(GetProcessHeap(), 0, sizeof(BigBlockFile));
174 if (This == NULL)
175 return NULL;
177 This->fileBased = fileBased;
179 This->flProtect = BIGBLOCKFILE_GetProtectMode(openFlags);
181 This->blocksize = blocksize;
183 This->maplist = NULL;
184 This->victimhead = NULL;
185 This->victimtail = NULL;
186 This->num_victim_pages = 0;
188 if (This->fileBased)
190 if (!BIGBLOCKFILE_FileInit(This, hFile))
192 HeapFree(GetProcessHeap(), 0, This);
193 return NULL;
196 else
198 if (!BIGBLOCKFILE_MemInit(This, pLkByt))
200 HeapFree(GetProcessHeap(), 0, This);
201 return NULL;
205 return This;
208 /******************************************************************************
209 * BIGBLOCKFILE_FileInit
211 * Initialize a big block object supported by a file.
213 static BOOL BIGBLOCKFILE_FileInit(LPBIGBLOCKFILE This, HANDLE hFile)
215 This->pLkbyt = NULL;
216 This->hbytearray = 0;
217 This->pbytearray = NULL;
219 This->hfile = hFile;
221 if (This->hfile == INVALID_HANDLE_VALUE)
222 return FALSE;
224 /* create the file mapping object
226 This->hfilemap = CreateFileMappingA(This->hfile,
227 NULL,
228 This->flProtect,
229 0, 0,
230 NULL);
232 if (!This->hfilemap)
234 CloseHandle(This->hfile);
235 return FALSE;
238 This->filesize.s.LowPart = GetFileSize(This->hfile,
239 &This->filesize.s.HighPart);
241 This->maplist = NULL;
243 TRACE("file len %lu\n", This->filesize.s.LowPart);
245 return TRUE;
248 /******************************************************************************
249 * BIGBLOCKFILE_MemInit
251 * Initialize a big block object supported by an ILockBytes on HGLOABL.
253 static BOOL BIGBLOCKFILE_MemInit(LPBIGBLOCKFILE This, ILockBytes* plkbyt)
255 This->hfile = 0;
256 This->hfilemap = 0;
259 * Retrieve the handle to the byte array from the LockByte object.
261 if (GetHGlobalFromILockBytes(plkbyt, &(This->hbytearray)) != S_OK)
263 FIXME("May not be an ILockBytes on HGLOBAL\n");
264 return FALSE;
267 This->pLkbyt = plkbyt;
270 * Increment the reference count of the ILockByte object since
271 * we're keeping a reference to it.
273 ILockBytes_AddRef(This->pLkbyt);
275 This->filesize.s.LowPart = GlobalSize(This->hbytearray);
276 This->filesize.s.HighPart = 0;
278 This->pbytearray = GlobalLock(This->hbytearray);
280 TRACE("mem on %p len %lu\n", This->pbytearray, This->filesize.s.LowPart);
282 return TRUE;
285 /******************************************************************************
286 * BIGBLOCKFILE_Destructor
288 * Destructor. Clean up, free memory.
290 void BIGBLOCKFILE_Destructor(
291 LPBIGBLOCKFILE This)
293 BIGBLOCKFILE_FreeAllMappedPages(This);
295 if (This->fileBased)
297 CloseHandle(This->hfilemap);
298 CloseHandle(This->hfile);
300 else
302 GlobalUnlock(This->hbytearray);
303 ILockBytes_Release(This->pLkbyt);
306 /* destroy this
308 HeapFree(GetProcessHeap(), 0, This);
311 /******************************************************************************
312 * BIGBLOCKFILE_GetROBigBlock
314 * Returns the specified block in read only mode.
315 * Will return NULL if the block doesn't exists.
317 void* BIGBLOCKFILE_GetROBigBlock(
318 LPBIGBLOCKFILE This,
319 ULONG index)
322 * block index starts at -1
323 * translate to zero based index
325 if (index == 0xffffffff)
326 index = 0;
327 else
328 index++;
331 * validate the block index
334 if (This->blocksize * (index + 1)
335 > ROUND_UP(This->filesize.s.LowPart, This->blocksize))
337 TRACE("out of range %lu vs %lu\n", This->blocksize * (index + 1),
338 This->filesize.s.LowPart);
339 return NULL;
342 return BIGBLOCKFILE_GetBigBlockPointer(This, index, FILE_MAP_READ);
345 /******************************************************************************
346 * BIGBLOCKFILE_GetBigBlock
348 * Returns the specified block.
349 * Will grow the file if necessary.
351 void* BIGBLOCKFILE_GetBigBlock(LPBIGBLOCKFILE This, ULONG index)
354 * block index starts at -1
355 * translate to zero based index
357 if (index == 0xffffffff)
358 index = 0;
359 else
360 index++;
363 * make sure that the block physically exists
365 if ((This->blocksize * (index + 1)) > This->filesize.s.LowPart)
367 ULARGE_INTEGER newSize;
369 newSize.s.HighPart = 0;
370 newSize.s.LowPart = This->blocksize * (index + 1);
372 BIGBLOCKFILE_SetSize(This, newSize);
375 return BIGBLOCKFILE_GetBigBlockPointer(This, index, FILE_MAP_WRITE);
378 /******************************************************************************
379 * BIGBLOCKFILE_ReleaseBigBlock
381 * Releases the specified block.
383 void BIGBLOCKFILE_ReleaseBigBlock(LPBIGBLOCKFILE This, void *pBlock)
385 MappedPage *page;
387 if (pBlock == NULL)
388 return;
390 page = BIGBLOCKFILE_GetPageFromPointer(This, pBlock);
392 if (page == NULL)
393 return;
395 BIGBLOCKFILE_ReleaseMappedPage(This, page);
398 /******************************************************************************
399 * BIGBLOCKFILE_SetSize
401 * Sets the size of the file.
404 void BIGBLOCKFILE_SetSize(LPBIGBLOCKFILE This, ULARGE_INTEGER newSize)
406 if (This->filesize.s.LowPart == newSize.s.LowPart)
407 return;
409 TRACE("from %lu to %lu\n", This->filesize.s.LowPart, newSize.s.LowPart);
411 * unmap all views, must be done before call to SetEndFile
413 BIGBLOCKFILE_UnmapAllMappedPages(This);
415 if (This->fileBased)
417 char buf[10];
420 * close file-mapping object, must be done before call to SetEndFile
422 CloseHandle(This->hfilemap);
423 This->hfilemap = 0;
426 * BEGIN HACK
427 * This fixes a bug when saving through smbfs.
428 * smbmount a Windows shared directory, save a structured storage file
429 * to that dir: crash.
431 * The problem is that the SetFilePointer-SetEndOfFile combo below
432 * doesn't always succeed. The file is not grown. It seems like the
433 * operation is cached. By doing the WriteFile, the file is actually
434 * grown on disk.
435 * This hack is only needed when saving to smbfs.
437 memset(buf, '0', 10);
438 SetFilePointer(This->hfile, newSize.s.LowPart, NULL, FILE_BEGIN);
439 WriteFile(This->hfile, buf, 10, NULL, NULL);
441 * END HACK
445 * set the new end of file
447 SetFilePointer(This->hfile, newSize.s.LowPart, NULL, FILE_BEGIN);
448 SetEndOfFile(This->hfile);
451 * re-create the file mapping object
453 This->hfilemap = CreateFileMappingA(This->hfile,
454 NULL,
455 This->flProtect,
456 0, 0,
457 NULL);
459 else
461 GlobalUnlock(This->hbytearray);
464 * Resize the byte array object.
466 ILockBytes_SetSize(This->pLkbyt, newSize);
469 * Re-acquire the handle, it may have changed.
471 GetHGlobalFromILockBytes(This->pLkbyt, &This->hbytearray);
472 This->pbytearray = GlobalLock(This->hbytearray);
475 This->filesize.s.LowPart = newSize.s.LowPart;
476 This->filesize.s.HighPart = newSize.s.HighPart;
478 BIGBLOCKFILE_RemapAllMappedPages(This);
481 /******************************************************************************
482 * BIGBLOCKFILE_GetSize
484 * Returns the size of the file.
487 ULARGE_INTEGER BIGBLOCKFILE_GetSize(LPBIGBLOCKFILE This)
489 return This->filesize;
492 /******************************************************************************
493 * BIGBLOCKFILE_AccessCheck [PRIVATE]
495 * block_index is the index within the page.
497 static BOOL BIGBLOCKFILE_AccessCheck(MappedPage *page, ULONG block_index,
498 DWORD desired_access)
500 assert(block_index < BLOCKS_PER_PAGE);
502 if (desired_access == FILE_MAP_READ)
504 if (BIGBLOCKFILE_TestBit(&page->writable_blocks, block_index))
505 return FALSE;
507 BIGBLOCKFILE_SetBit(&page->readable_blocks, block_index);
509 else
511 assert(desired_access == FILE_MAP_WRITE);
513 if (BIGBLOCKFILE_TestBit(&page->readable_blocks, block_index))
514 return FALSE;
516 BIGBLOCKFILE_SetBit(&page->writable_blocks, block_index);
519 return TRUE;
522 /******************************************************************************
523 * BIGBLOCKFILE_GetBigBlockPointer [PRIVATE]
525 * Returns a pointer to the specified block.
527 static void* BIGBLOCKFILE_GetBigBlockPointer(
528 LPBIGBLOCKFILE This,
529 ULONG block_index,
530 DWORD desired_access)
532 DWORD page_index = block_index / BLOCKS_PER_PAGE;
533 DWORD block_on_page = block_index % BLOCKS_PER_PAGE;
535 MappedPage *page = BIGBLOCKFILE_GetMappedView(This, page_index);
536 if (!page || !page->lpBytes) return NULL;
538 if (!BIGBLOCKFILE_AccessCheck(page, block_on_page, desired_access))
540 BIGBLOCKFILE_ReleaseMappedPage(This, page);
541 return NULL;
544 return (LPBYTE)page->lpBytes + (block_on_page * This->blocksize);
547 /******************************************************************************
548 * BIGBLOCKFILE_GetMappedPageFromPointer [PRIVATE]
550 * pBlock is a pointer to a block on a page.
551 * The page has to be on the in-use list. (As oppsed to the victim list.)
553 * Does not increment the usage count.
555 static MappedPage *BIGBLOCKFILE_GetPageFromPointer(LPBIGBLOCKFILE This,
556 void *pBlock)
558 MappedPage *page;
560 for (page = This->maplist; page != NULL; page = page->next)
562 if ((LPBYTE)pBlock >= (LPBYTE)page->lpBytes
563 && (LPBYTE)pBlock <= (LPBYTE)page->lpBytes + PAGE_SIZE)
564 break;
568 return page;
571 /******************************************************************************
572 * BIGBLOCKFILE_FindPageInList [PRIVATE]
575 static MappedPage *BIGBLOCKFILE_FindPageInList(MappedPage *head,
576 ULONG page_index)
578 for (; head != NULL; head = head->next)
580 if (head->page_index == page_index)
582 InterlockedIncrement(&head->refcnt);
583 break;
587 return head;
591 static void BIGBLOCKFILE_UnlinkPage(MappedPage *page)
593 if (page->next) page->next->prev = page->prev;
594 if (page->prev) page->prev->next = page->next;
597 static void BIGBLOCKFILE_LinkHeadPage(MappedPage **head, MappedPage *page)
599 if (*head) (*head)->prev = page;
600 page->next = *head;
601 page->prev = NULL;
602 *head = page;
605 /******************************************************************************
606 * BIGBLOCKFILE_GetMappedView [PRIVATE]
608 * Gets the page requested if it is already mapped.
609 * If it's not already mapped, this method will map it
611 static void * BIGBLOCKFILE_GetMappedView(
612 LPBIGBLOCKFILE This,
613 DWORD page_index)
615 MappedPage *page;
617 page = BIGBLOCKFILE_FindPageInList(This->maplist, page_index);
618 if (!page)
620 page = BIGBLOCKFILE_FindPageInList(This->victimhead, page_index);
621 if (page)
623 This->num_victim_pages--;
625 BIGBLOCKFILE_Zero(&page->readable_blocks);
626 BIGBLOCKFILE_Zero(&page->writable_blocks);
630 if (page)
632 /* If the page is not already at the head of the list, move
633 * it there. (Also moves pages from victim to main list.) */
634 if (This->maplist != page)
636 if (This->victimhead == page) This->victimhead = page->next;
637 if (This->victimtail == page) This->victimtail = page->prev;
639 BIGBLOCKFILE_UnlinkPage(page);
641 BIGBLOCKFILE_LinkHeadPage(&This->maplist, page);
644 return page;
647 page = BIGBLOCKFILE_CreatePage(This, page_index);
648 if (!page) return NULL;
650 BIGBLOCKFILE_LinkHeadPage(&This->maplist, page);
652 return page;
655 static BOOL BIGBLOCKFILE_MapPage(LPBIGBLOCKFILE This, MappedPage *page)
657 DWORD lowoffset = PAGE_SIZE * page->page_index;
659 if (This->fileBased)
661 DWORD numBytesToMap;
662 DWORD desired_access;
664 if (lowoffset + PAGE_SIZE > This->filesize.s.LowPart)
665 numBytesToMap = This->filesize.s.LowPart - lowoffset;
666 else
667 numBytesToMap = PAGE_SIZE;
669 if (This->flProtect == PAGE_READONLY)
670 desired_access = FILE_MAP_READ;
671 else
672 desired_access = FILE_MAP_WRITE;
674 page->lpBytes = MapViewOfFile(This->hfilemap, desired_access, 0,
675 lowoffset, numBytesToMap);
677 else
679 page->lpBytes = (LPBYTE)This->pbytearray + lowoffset;
682 TRACE("mapped page %lu to %p\n", page->page_index, page->lpBytes);
684 return page->lpBytes != NULL;
687 static MappedPage *BIGBLOCKFILE_CreatePage(LPBIGBLOCKFILE This,
688 ULONG page_index)
690 MappedPage *page;
692 page = HeapAlloc(GetProcessHeap(), 0, sizeof(MappedPage));
693 if (page == NULL)
694 return NULL;
696 page->page_index = page_index;
697 page->refcnt = 1;
699 page->next = NULL;
700 page->prev = NULL;
702 BIGBLOCKFILE_MapPage(This, page);
704 BIGBLOCKFILE_Zero(&page->readable_blocks);
705 BIGBLOCKFILE_Zero(&page->writable_blocks);
707 return page;
710 static void BIGBLOCKFILE_UnmapPage(LPBIGBLOCKFILE This, MappedPage *page)
712 TRACE("%ld at %p\n", page->page_index, page->lpBytes);
713 if (page->refcnt > 0)
714 ERR("unmapping inuse page %p\n", page->lpBytes);
716 if (This->fileBased && page->lpBytes)
717 UnmapViewOfFile(page->lpBytes);
719 page->lpBytes = NULL;
722 static void BIGBLOCKFILE_DeletePage(LPBIGBLOCKFILE This, MappedPage *page)
724 BIGBLOCKFILE_UnmapPage(This, page);
726 HeapFree(GetProcessHeap(), 0, page);
729 /******************************************************************************
730 * BIGBLOCKFILE_ReleaseMappedPage [PRIVATE]
732 * Decrements the reference count of the mapped page.
734 static void BIGBLOCKFILE_ReleaseMappedPage(
735 LPBIGBLOCKFILE This,
736 MappedPage *page)
738 assert(This != NULL);
739 assert(page != NULL);
741 /* If the page is no longer refenced, move it to the victim list.
742 * If the victim list is too long, kick somebody off. */
743 if (!InterlockedDecrement(&page->refcnt))
745 if (This->maplist == page) This->maplist = page->next;
747 BIGBLOCKFILE_UnlinkPage(page);
749 if (MAX_VICTIM_PAGES > 0)
751 if (This->num_victim_pages >= MAX_VICTIM_PAGES)
753 MappedPage *victim = This->victimtail;
754 if (victim)
756 This->victimtail = victim->prev;
757 if (This->victimhead == victim)
758 This->victimhead = victim->next;
760 BIGBLOCKFILE_UnlinkPage(victim);
761 BIGBLOCKFILE_DeletePage(This, victim);
764 else This->num_victim_pages++;
766 BIGBLOCKFILE_LinkHeadPage(&This->victimhead, page);
767 if (This->victimtail == NULL) This->victimtail = page;
769 else
770 BIGBLOCKFILE_DeletePage(This, page);
774 static void BIGBLOCKFILE_DeleteList(LPBIGBLOCKFILE This, MappedPage *list)
776 while (list != NULL)
778 MappedPage *next = list->next;
780 BIGBLOCKFILE_DeletePage(This, list);
782 list = next;
786 /******************************************************************************
787 * BIGBLOCKFILE_FreeAllMappedPages [PRIVATE]
789 * Unmap all currently mapped pages.
790 * Empty mapped pages list.
792 static void BIGBLOCKFILE_FreeAllMappedPages(
793 LPBIGBLOCKFILE This)
795 BIGBLOCKFILE_DeleteList(This, This->maplist);
796 BIGBLOCKFILE_DeleteList(This, This->victimhead);
798 This->maplist = NULL;
799 This->victimhead = NULL;
800 This->victimtail = NULL;
801 This->num_victim_pages = 0;
804 static void BIGBLOCKFILE_UnmapList(LPBIGBLOCKFILE This, MappedPage *list)
806 for (; list != NULL; list = list->next)
808 BIGBLOCKFILE_UnmapPage(This, list);
812 static void BIGBLOCKFILE_UnmapAllMappedPages(LPBIGBLOCKFILE This)
814 BIGBLOCKFILE_UnmapList(This, This->maplist);
815 BIGBLOCKFILE_UnmapList(This, This->victimhead);
818 static void BIGBLOCKFILE_RemapList(LPBIGBLOCKFILE This, MappedPage *list)
820 while (list != NULL)
822 MappedPage *next = list->next;
824 if (list->page_index * PAGE_SIZE > This->filesize.s.LowPart)
826 TRACE("discarding %lu\n", list->page_index);
828 /* page is entirely outside of the file, delete it */
829 BIGBLOCKFILE_UnlinkPage(list);
830 BIGBLOCKFILE_DeletePage(This, list);
832 else
834 /* otherwise, remap it */
835 BIGBLOCKFILE_MapPage(This, list);
838 list = next;
842 static void BIGBLOCKFILE_RemapAllMappedPages(LPBIGBLOCKFILE This)
844 BIGBLOCKFILE_RemapList(This, This->maplist);
845 BIGBLOCKFILE_RemapList(This, This->victimhead);
848 /****************************************************************************
849 * BIGBLOCKFILE_GetProtectMode
851 * This function will return a protection mode flag for a file-mapping object
852 * from the open flags of a file.
854 static DWORD BIGBLOCKFILE_GetProtectMode(DWORD openFlags)
856 if (openFlags & (STGM_WRITE | STGM_READWRITE))
857 return PAGE_READWRITE;
858 else
859 return PAGE_READONLY;