Added hack to call CreateFileW through a pointer so that we don't need
[wine/multimedia.git] / dlls / ole32 / stg_bigblockfile.c
blobd76602926d21b93c680f5b5883c44e9ae83567ae
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 "winuser.h"
46 #include "winerror.h"
47 #include "objbase.h"
48 #include "ole2.h"
50 #include "storage32.h"
52 #include "wine/debug.h"
54 WINE_DEFAULT_DEBUG_CHANNEL(storage);
56 /***********************************************************
57 * Data structures used internally by the BigBlockFile
58 * class.
61 /* We map in PAGE_SIZE-sized chunks. Must be a multiple of 4096. */
62 #define PAGE_SIZE 131072
64 #define BLOCKS_PER_PAGE (PAGE_SIZE / BIG_BLOCK_SIZE)
66 /* We keep a list of recently-discarded pages. This controls the
67 * size of that list. */
68 #define MAX_VICTIM_PAGES 16
70 /* This structure provides one bit for each block in a page.
71 * Use BIGBLOCKFILE_{Test,Set,Clear}Bit to manipulate it. */
72 typedef struct
74 unsigned int bits[BLOCKS_PER_PAGE / (CHAR_BIT * sizeof(unsigned int))];
75 } BlockBits;
77 /***
78 * This structure identifies the paged that are mapped
79 * from the file and their position in memory. It is
80 * also used to hold a reference count to those pages.
82 * page_index identifies which PAGE_SIZE chunk from the
83 * file this mapping represents. (The mappings are always
84 * PAGE_SIZE-aligned.)
86 struct MappedPage
88 MappedPage *next;
89 MappedPage *prev;
91 DWORD page_index;
92 LPVOID lpBytes;
93 LONG refcnt;
95 BlockBits readable_blocks;
96 BlockBits writable_blocks;
99 /***********************************************************
100 * Prototypes for private methods
102 static void* BIGBLOCKFILE_GetMappedView(LPBIGBLOCKFILE This,
103 DWORD page_index);
104 static void BIGBLOCKFILE_ReleaseMappedPage(LPBIGBLOCKFILE This,
105 MappedPage *page);
106 static void BIGBLOCKFILE_FreeAllMappedPages(LPBIGBLOCKFILE This);
107 static void BIGBLOCKFILE_UnmapAllMappedPages(LPBIGBLOCKFILE This);
108 static void BIGBLOCKFILE_RemapAllMappedPages(LPBIGBLOCKFILE This);
109 static void* BIGBLOCKFILE_GetBigBlockPointer(LPBIGBLOCKFILE This,
110 ULONG index,
111 DWORD desired_access);
112 static MappedPage* BIGBLOCKFILE_GetPageFromPointer(LPBIGBLOCKFILE This,
113 void* pBlock);
114 static MappedPage* BIGBLOCKFILE_CreatePage(LPBIGBLOCKFILE This,
115 ULONG page_index);
116 static DWORD BIGBLOCKFILE_GetProtectMode(DWORD openFlags);
117 static BOOL BIGBLOCKFILE_FileInit(LPBIGBLOCKFILE This, HANDLE hFile);
118 static BOOL BIGBLOCKFILE_MemInit(LPBIGBLOCKFILE This, ILockBytes* plkbyt);
120 /* Note that this evaluates a and b multiple times, so don't
121 * pass expressions with side effects. */
122 #define ROUND_UP(a, b) ((((a) + (b) - 1)/(b))*(b))
124 /***********************************************************
125 * Blockbits functions.
127 static inline BOOL BIGBLOCKFILE_TestBit(const BlockBits *bb,
128 unsigned int index)
130 unsigned int array_index = index / (CHAR_BIT * sizeof(unsigned int));
131 unsigned int bit_index = index % (CHAR_BIT * sizeof(unsigned int));
133 return bb->bits[array_index] & (1 << bit_index);
136 static inline void BIGBLOCKFILE_SetBit(BlockBits *bb, unsigned int index)
138 unsigned int array_index = index / (CHAR_BIT * sizeof(unsigned int));
139 unsigned int bit_index = index % (CHAR_BIT * sizeof(unsigned int));
141 bb->bits[array_index] |= (1 << bit_index);
144 static inline void BIGBLOCKFILE_ClearBit(BlockBits *bb, unsigned int index)
146 unsigned int array_index = index / (CHAR_BIT * sizeof(unsigned int));
147 unsigned int bit_index = index % (CHAR_BIT * sizeof(unsigned int));
149 bb->bits[array_index] &= ~(1 << bit_index);
152 static inline void BIGBLOCKFILE_Zero(BlockBits *bb)
154 memset(bb->bits, 0, sizeof(bb->bits));
157 /******************************************************************************
158 * BIGBLOCKFILE_Construct
160 * Construct a big block file. Create the file mapping object.
161 * Create the read only mapped pages list, the writable mapped page list
162 * and the blocks in use list.
164 BigBlockFile * BIGBLOCKFILE_Construct(
165 HANDLE hFile,
166 ILockBytes* pLkByt,
167 DWORD openFlags,
168 ULONG blocksize,
169 BOOL fileBased)
171 LPBIGBLOCKFILE This;
173 This = (LPBIGBLOCKFILE)HeapAlloc(GetProcessHeap(), 0, sizeof(BigBlockFile));
175 if (This == NULL)
176 return NULL;
178 This->fileBased = fileBased;
180 This->flProtect = BIGBLOCKFILE_GetProtectMode(openFlags);
182 This->blocksize = blocksize;
184 This->maplist = NULL;
185 This->victimhead = NULL;
186 This->victimtail = NULL;
187 This->num_victim_pages = 0;
189 if (This->fileBased)
191 if (!BIGBLOCKFILE_FileInit(This, hFile))
193 HeapFree(GetProcessHeap(), 0, This);
194 return NULL;
197 else
199 if (!BIGBLOCKFILE_MemInit(This, pLkByt))
201 HeapFree(GetProcessHeap(), 0, This);
202 return NULL;
206 return This;
209 /******************************************************************************
210 * BIGBLOCKFILE_FileInit
212 * Initialize a big block object supported by a file.
214 static BOOL BIGBLOCKFILE_FileInit(LPBIGBLOCKFILE This, HANDLE hFile)
216 This->pLkbyt = NULL;
217 This->hbytearray = 0;
218 This->pbytearray = NULL;
220 This->hfile = hFile;
222 if (This->hfile == INVALID_HANDLE_VALUE)
223 return FALSE;
225 /* create the file mapping object
227 This->hfilemap = CreateFileMappingA(This->hfile,
228 NULL,
229 This->flProtect,
230 0, 0,
231 NULL);
233 if (!This->hfilemap)
235 CloseHandle(This->hfile);
236 return FALSE;
239 This->filesize.s.LowPart = GetFileSize(This->hfile,
240 &This->filesize.s.HighPart);
242 This->maplist = NULL;
244 TRACE("file len %lu\n", This->filesize.s.LowPart);
246 return TRUE;
249 /******************************************************************************
250 * BIGBLOCKFILE_MemInit
252 * Initialize a big block object supported by an ILockBytes on HGLOABL.
254 static BOOL BIGBLOCKFILE_MemInit(LPBIGBLOCKFILE This, ILockBytes* plkbyt)
256 This->hfile = 0;
257 This->hfilemap = 0;
260 * Retrieve the handle to the byte array from the LockByte object.
262 if (GetHGlobalFromILockBytes(plkbyt, &(This->hbytearray)) != S_OK)
264 FIXME("May not be an ILockBytes on HGLOBAL\n");
265 return FALSE;
268 This->pLkbyt = plkbyt;
271 * Increment the reference count of the ILockByte object since
272 * we're keeping a reference to it.
274 ILockBytes_AddRef(This->pLkbyt);
276 This->filesize.s.LowPart = GlobalSize(This->hbytearray);
277 This->filesize.s.HighPart = 0;
279 This->pbytearray = GlobalLock(This->hbytearray);
281 TRACE("mem on %p len %lu\n", This->pbytearray, This->filesize.s.LowPart);
283 return TRUE;
286 /******************************************************************************
287 * BIGBLOCKFILE_Destructor
289 * Destructor. Clean up, free memory.
291 void BIGBLOCKFILE_Destructor(
292 LPBIGBLOCKFILE This)
294 BIGBLOCKFILE_FreeAllMappedPages(This);
296 if (This->fileBased)
298 CloseHandle(This->hfilemap);
299 CloseHandle(This->hfile);
301 else
303 GlobalUnlock(This->hbytearray);
304 ILockBytes_Release(This->pLkbyt);
307 /* destroy this
309 HeapFree(GetProcessHeap(), 0, This);
312 /******************************************************************************
313 * BIGBLOCKFILE_GetROBigBlock
315 * Returns the specified block in read only mode.
316 * Will return NULL if the block doesn't exists.
318 void* BIGBLOCKFILE_GetROBigBlock(
319 LPBIGBLOCKFILE This,
320 ULONG index)
323 * block index starts at -1
324 * translate to zero based index
326 if (index == 0xffffffff)
327 index = 0;
328 else
329 index++;
332 * validate the block index
335 if (This->blocksize * (index + 1)
336 > ROUND_UP(This->filesize.s.LowPart, This->blocksize))
338 TRACE("out of range %lu vs %lu\n", This->blocksize * (index + 1),
339 This->filesize.s.LowPart);
340 return NULL;
343 return BIGBLOCKFILE_GetBigBlockPointer(This, index, FILE_MAP_READ);
346 /******************************************************************************
347 * BIGBLOCKFILE_GetBigBlock
349 * Returns the specified block.
350 * Will grow the file if necessary.
352 void* BIGBLOCKFILE_GetBigBlock(LPBIGBLOCKFILE This, ULONG index)
355 * block index starts at -1
356 * translate to zero based index
358 if (index == 0xffffffff)
359 index = 0;
360 else
361 index++;
364 * make sure that the block physically exists
366 if ((This->blocksize * (index + 1)) > This->filesize.s.LowPart)
368 ULARGE_INTEGER newSize;
370 newSize.s.HighPart = 0;
371 newSize.s.LowPart = This->blocksize * (index + 1);
373 BIGBLOCKFILE_SetSize(This, newSize);
376 return BIGBLOCKFILE_GetBigBlockPointer(This, index, FILE_MAP_WRITE);
379 /******************************************************************************
380 * BIGBLOCKFILE_ReleaseBigBlock
382 * Releases the specified block.
384 void BIGBLOCKFILE_ReleaseBigBlock(LPBIGBLOCKFILE This, void *pBlock)
386 MappedPage *page;
388 if (pBlock == NULL)
389 return;
391 page = BIGBLOCKFILE_GetPageFromPointer(This, pBlock);
393 if (page == NULL)
394 return;
396 BIGBLOCKFILE_ReleaseMappedPage(This, page);
399 /******************************************************************************
400 * BIGBLOCKFILE_SetSize
402 * Sets the size of the file.
405 void BIGBLOCKFILE_SetSize(LPBIGBLOCKFILE This, ULARGE_INTEGER newSize)
407 if (This->filesize.s.LowPart == newSize.s.LowPart)
408 return;
410 TRACE("from %lu to %lu\n", This->filesize.s.LowPart, newSize.s.LowPart);
412 * unmap all views, must be done before call to SetEndFile
414 BIGBLOCKFILE_UnmapAllMappedPages(This);
416 if (This->fileBased)
418 char buf[10];
421 * close file-mapping object, must be done before call to SetEndFile
423 CloseHandle(This->hfilemap);
424 This->hfilemap = 0;
427 * BEGIN HACK
428 * This fixes a bug when saving through smbfs.
429 * smbmount a Windows shared directory, save a structured storage file
430 * to that dir: crash.
432 * The problem is that the SetFilePointer-SetEndOfFile combo below
433 * doesn't always succeed. The file is not grown. It seems like the
434 * operation is cached. By doing the WriteFile, the file is actually
435 * grown on disk.
436 * This hack is only needed when saving to smbfs.
438 memset(buf, '0', 10);
439 SetFilePointer(This->hfile, newSize.s.LowPart, NULL, FILE_BEGIN);
440 WriteFile(This->hfile, buf, 10, NULL, NULL);
442 * END HACK
446 * set the new end of file
448 SetFilePointer(This->hfile, newSize.s.LowPart, NULL, FILE_BEGIN);
449 SetEndOfFile(This->hfile);
452 * re-create the file mapping object
454 This->hfilemap = CreateFileMappingA(This->hfile,
455 NULL,
456 This->flProtect,
457 0, 0,
458 NULL);
460 else
462 GlobalUnlock(This->hbytearray);
465 * Resize the byte array object.
467 ILockBytes_SetSize(This->pLkbyt, newSize);
470 * Re-acquire the handle, it may have changed.
472 GetHGlobalFromILockBytes(This->pLkbyt, &This->hbytearray);
473 This->pbytearray = GlobalLock(This->hbytearray);
476 This->filesize.s.LowPart = newSize.s.LowPart;
477 This->filesize.s.HighPart = newSize.s.HighPart;
479 BIGBLOCKFILE_RemapAllMappedPages(This);
482 /******************************************************************************
483 * BIGBLOCKFILE_GetSize
485 * Returns the size of the file.
488 ULARGE_INTEGER BIGBLOCKFILE_GetSize(LPBIGBLOCKFILE This)
490 return This->filesize;
493 /******************************************************************************
494 * BIGBLOCKFILE_AccessCheck [PRIVATE]
496 * block_index is the index within the page.
498 static BOOL BIGBLOCKFILE_AccessCheck(MappedPage *page, ULONG block_index,
499 DWORD desired_access)
501 assert(block_index < BLOCKS_PER_PAGE);
503 if (desired_access == FILE_MAP_READ)
505 if (BIGBLOCKFILE_TestBit(&page->writable_blocks, block_index))
506 return FALSE;
508 BIGBLOCKFILE_SetBit(&page->readable_blocks, block_index);
510 else
512 assert(desired_access == FILE_MAP_WRITE);
514 if (BIGBLOCKFILE_TestBit(&page->readable_blocks, block_index))
515 return FALSE;
517 BIGBLOCKFILE_SetBit(&page->writable_blocks, block_index);
520 return TRUE;
523 /******************************************************************************
524 * BIGBLOCKFILE_GetBigBlockPointer [PRIVATE]
526 * Returns a pointer to the specified block.
528 static void* BIGBLOCKFILE_GetBigBlockPointer(
529 LPBIGBLOCKFILE This,
530 ULONG block_index,
531 DWORD desired_access)
533 DWORD page_index = block_index / BLOCKS_PER_PAGE;
534 DWORD block_on_page = block_index % BLOCKS_PER_PAGE;
536 MappedPage *page = BIGBLOCKFILE_GetMappedView(This, page_index);
537 if (!page || !page->lpBytes) return NULL;
539 if (!BIGBLOCKFILE_AccessCheck(page, block_on_page, desired_access))
541 BIGBLOCKFILE_ReleaseMappedPage(This, page);
542 return NULL;
545 return (LPBYTE)page->lpBytes + (block_on_page * This->blocksize);
548 /******************************************************************************
549 * BIGBLOCKFILE_GetMappedPageFromPointer [PRIVATE]
551 * pBlock is a pointer to a block on a page.
552 * The page has to be on the in-use list. (As oppsed to the victim list.)
554 * Does not increment the usage count.
556 static MappedPage *BIGBLOCKFILE_GetPageFromPointer(LPBIGBLOCKFILE This,
557 void *pBlock)
559 MappedPage *page;
561 for (page = This->maplist; page != NULL; page = page->next)
563 if ((LPBYTE)pBlock >= (LPBYTE)page->lpBytes
564 && (LPBYTE)pBlock <= (LPBYTE)page->lpBytes + PAGE_SIZE)
565 break;
569 return page;
572 /******************************************************************************
573 * BIGBLOCKFILE_FindPageInList [PRIVATE]
576 static MappedPage *BIGBLOCKFILE_FindPageInList(MappedPage *head,
577 ULONG page_index)
579 for (; head != NULL; head = head->next)
581 if (head->page_index == page_index)
583 InterlockedIncrement(&head->refcnt);
584 break;
588 return head;
592 static void BIGBLOCKFILE_UnlinkPage(MappedPage *page)
594 if (page->next) page->next->prev = page->prev;
595 if (page->prev) page->prev->next = page->next;
598 static void BIGBLOCKFILE_LinkHeadPage(MappedPage **head, MappedPage *page)
600 if (*head) (*head)->prev = page;
601 page->next = *head;
602 page->prev = NULL;
603 *head = page;
606 /******************************************************************************
607 * BIGBLOCKFILE_GetMappedView [PRIVATE]
609 * Gets the page requested if it is already mapped.
610 * If it's not already mapped, this method will map it
612 static void * BIGBLOCKFILE_GetMappedView(
613 LPBIGBLOCKFILE This,
614 DWORD page_index)
616 MappedPage *page;
618 page = BIGBLOCKFILE_FindPageInList(This->maplist, page_index);
619 if (!page)
621 page = BIGBLOCKFILE_FindPageInList(This->victimhead, page_index);
622 if (page)
624 This->num_victim_pages--;
626 BIGBLOCKFILE_Zero(&page->readable_blocks);
627 BIGBLOCKFILE_Zero(&page->writable_blocks);
631 if (page)
633 /* If the page is not already at the head of the list, move
634 * it there. (Also moves pages from victim to main list.) */
635 if (This->maplist != page)
637 if (This->victimhead == page) This->victimhead = page->next;
638 if (This->victimtail == page) This->victimtail = page->prev;
640 BIGBLOCKFILE_UnlinkPage(page);
642 BIGBLOCKFILE_LinkHeadPage(&This->maplist, page);
645 return page;
648 page = BIGBLOCKFILE_CreatePage(This, page_index);
649 if (!page) return NULL;
651 BIGBLOCKFILE_LinkHeadPage(&This->maplist, page);
653 return page;
656 static BOOL BIGBLOCKFILE_MapPage(LPBIGBLOCKFILE This, MappedPage *page)
658 DWORD lowoffset = PAGE_SIZE * page->page_index;
660 if (This->fileBased)
662 DWORD numBytesToMap;
663 DWORD desired_access;
665 if (lowoffset + PAGE_SIZE > This->filesize.s.LowPart)
666 numBytesToMap = This->filesize.s.LowPart - lowoffset;
667 else
668 numBytesToMap = PAGE_SIZE;
670 if (This->flProtect == PAGE_READONLY)
671 desired_access = FILE_MAP_READ;
672 else
673 desired_access = FILE_MAP_WRITE;
675 page->lpBytes = MapViewOfFile(This->hfilemap, desired_access, 0,
676 lowoffset, numBytesToMap);
678 else
680 page->lpBytes = (LPBYTE)This->pbytearray + lowoffset;
683 TRACE("mapped page %lu to %p\n", page->page_index, page->lpBytes);
685 return page->lpBytes != NULL;
688 static MappedPage *BIGBLOCKFILE_CreatePage(LPBIGBLOCKFILE This,
689 ULONG page_index)
691 MappedPage *page;
693 page = HeapAlloc(GetProcessHeap(), 0, sizeof(MappedPage));
694 if (page == NULL)
695 return NULL;
697 page->page_index = page_index;
698 page->refcnt = 1;
700 page->next = NULL;
701 page->prev = NULL;
703 BIGBLOCKFILE_MapPage(This, page);
705 BIGBLOCKFILE_Zero(&page->readable_blocks);
706 BIGBLOCKFILE_Zero(&page->writable_blocks);
708 return page;
711 static void BIGBLOCKFILE_UnmapPage(LPBIGBLOCKFILE This, MappedPage *page)
713 TRACE("%ld at %p\n", page->page_index, page->lpBytes);
714 if (page->refcnt > 0)
715 ERR("unmapping inuse page %p\n", page->lpBytes);
717 if (This->fileBased && page->lpBytes)
718 UnmapViewOfFile(page->lpBytes);
720 page->lpBytes = NULL;
723 static void BIGBLOCKFILE_DeletePage(LPBIGBLOCKFILE This, MappedPage *page)
725 BIGBLOCKFILE_UnmapPage(This, page);
727 HeapFree(GetProcessHeap(), 0, page);
730 /******************************************************************************
731 * BIGBLOCKFILE_ReleaseMappedPage [PRIVATE]
733 * Decrements the reference count of the mapped page.
735 static void BIGBLOCKFILE_ReleaseMappedPage(
736 LPBIGBLOCKFILE This,
737 MappedPage *page)
739 assert(This != NULL);
740 assert(page != NULL);
742 /* If the page is no longer refenced, move it to the victim list.
743 * If the victim list is too long, kick somebody off. */
744 if (!InterlockedDecrement(&page->refcnt))
746 if (This->maplist == page) This->maplist = page->next;
748 BIGBLOCKFILE_UnlinkPage(page);
750 if (MAX_VICTIM_PAGES > 0)
752 if (This->num_victim_pages >= MAX_VICTIM_PAGES)
754 MappedPage *victim = This->victimtail;
755 if (victim)
757 This->victimtail = victim->prev;
758 if (This->victimhead == victim)
759 This->victimhead = victim->next;
761 BIGBLOCKFILE_UnlinkPage(victim);
762 BIGBLOCKFILE_DeletePage(This, victim);
765 else This->num_victim_pages++;
767 BIGBLOCKFILE_LinkHeadPage(&This->victimhead, page);
768 if (This->victimtail == NULL) This->victimtail = page;
770 else
771 BIGBLOCKFILE_DeletePage(This, page);
775 static void BIGBLOCKFILE_DeleteList(LPBIGBLOCKFILE This, MappedPage *list)
777 while (list != NULL)
779 MappedPage *next = list->next;
781 BIGBLOCKFILE_DeletePage(This, list);
783 list = next;
787 /******************************************************************************
788 * BIGBLOCKFILE_FreeAllMappedPages [PRIVATE]
790 * Unmap all currently mapped pages.
791 * Empty mapped pages list.
793 static void BIGBLOCKFILE_FreeAllMappedPages(
794 LPBIGBLOCKFILE This)
796 BIGBLOCKFILE_DeleteList(This, This->maplist);
797 BIGBLOCKFILE_DeleteList(This, This->victimhead);
799 This->maplist = NULL;
800 This->victimhead = NULL;
801 This->victimtail = NULL;
802 This->num_victim_pages = 0;
805 static void BIGBLOCKFILE_UnmapList(LPBIGBLOCKFILE This, MappedPage *list)
807 for (; list != NULL; list = list->next)
809 BIGBLOCKFILE_UnmapPage(This, list);
813 static void BIGBLOCKFILE_UnmapAllMappedPages(LPBIGBLOCKFILE This)
815 BIGBLOCKFILE_UnmapList(This, This->maplist);
816 BIGBLOCKFILE_UnmapList(This, This->victimhead);
819 static void BIGBLOCKFILE_RemapList(LPBIGBLOCKFILE This, MappedPage *list)
821 while (list != NULL)
823 MappedPage *next = list->next;
825 if (list->page_index * PAGE_SIZE > This->filesize.s.LowPart)
827 TRACE("discarding %lu\n", list->page_index);
829 /* page is entirely outside of the file, delete it */
830 BIGBLOCKFILE_UnlinkPage(list);
831 BIGBLOCKFILE_DeletePage(This, list);
833 else
835 /* otherwise, remap it */
836 BIGBLOCKFILE_MapPage(This, list);
839 list = next;
843 static void BIGBLOCKFILE_RemapAllMappedPages(LPBIGBLOCKFILE This)
845 BIGBLOCKFILE_RemapList(This, This->maplist);
846 BIGBLOCKFILE_RemapList(This, This->victimhead);
849 /****************************************************************************
850 * BIGBLOCKFILE_GetProtectMode
852 * This function will return a protection mode flag for a file-mapping object
853 * from the open flags of a file.
855 static DWORD BIGBLOCKFILE_GetProtectMode(DWORD openFlags)
857 if (openFlags & (STGM_WRITE | STGM_READWRITE))
858 return PAGE_READWRITE;
859 else
860 return PAGE_READONLY;