Define NONAMELESS{STRUCT,UNION} explicitly in the files that need them.
[wine/wine-kai.git] / dlls / ole32 / stg_bigblockfile.c
bloba696f05584847cd8ec6e05b47820803d55331526
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 <stdio.h>
37 #include <string.h>
38 #include <limits.h>
40 #define NONAMELESSUNION
41 #define NONAMELESSSTRUCT
42 #include "winbase.h"
43 #include "winerror.h"
44 #include "objbase.h"
45 #include "ole2.h"
47 #include "storage32.h"
49 #include "wine/debug.h"
51 WINE_DEFAULT_DEBUG_CHANNEL(storage);
53 /***********************************************************
54 * Data structures used internally by the BigBlockFile
55 * class.
58 /* We map in PAGE_SIZE-sized chunks. Must be a multiple of 4096. */
59 #define PAGE_SIZE 131072
61 #define BLOCKS_PER_PAGE (PAGE_SIZE / BIG_BLOCK_SIZE)
63 /* We keep a list of recently-discarded pages. This controls the
64 * size of that list. */
65 #define MAX_VICTIM_PAGES 16
67 /* This structure provides one bit for each block in a page.
68 * Use BIGBLOCKFILE_{Test,Set,Clear}Bit to manipulate it. */
69 typedef struct
71 unsigned int bits[BLOCKS_PER_PAGE / (CHAR_BIT * sizeof(unsigned int))];
72 } BlockBits;
74 /***
75 * This structure identifies the paged that are mapped
76 * from the file and their position in memory. It is
77 * also used to hold a reference count to those pages.
79 * page_index identifies which PAGE_SIZE chunk from the
80 * file this mapping represents. (The mappings are always
81 * PAGE_SIZE-aligned.)
83 struct MappedPage
85 MappedPage *next;
86 MappedPage *prev;
88 DWORD page_index;
89 LPVOID lpBytes;
90 LONG refcnt;
92 BlockBits readable_blocks;
93 BlockBits writable_blocks;
96 /***********************************************************
97 * Prototypes for private methods
99 static void* BIGBLOCKFILE_GetMappedView(LPBIGBLOCKFILE This,
100 DWORD page_index);
101 static void BIGBLOCKFILE_ReleaseMappedPage(LPBIGBLOCKFILE This,
102 MappedPage *page);
103 static void BIGBLOCKFILE_FreeAllMappedPages(LPBIGBLOCKFILE This);
104 static void BIGBLOCKFILE_UnmapAllMappedPages(LPBIGBLOCKFILE This);
105 static void BIGBLOCKFILE_RemapAllMappedPages(LPBIGBLOCKFILE This);
106 static void* BIGBLOCKFILE_GetBigBlockPointer(LPBIGBLOCKFILE This,
107 ULONG index,
108 DWORD desired_access);
109 static MappedPage* BIGBLOCKFILE_GetPageFromPointer(LPBIGBLOCKFILE This,
110 void* pBlock);
111 static MappedPage* BIGBLOCKFILE_CreatePage(LPBIGBLOCKFILE This,
112 ULONG page_index);
113 static DWORD BIGBLOCKFILE_GetProtectMode(DWORD openFlags);
114 static BOOL BIGBLOCKFILE_FileInit(LPBIGBLOCKFILE This, HANDLE hFile);
115 static BOOL BIGBLOCKFILE_MemInit(LPBIGBLOCKFILE This, ILockBytes* plkbyt);
117 /* Note that this evaluates a and b multiple times, so don't
118 * pass expressions with side effects. */
119 #define ROUND_UP(a, b) ((((a) + (b) - 1)/(b))*(b))
121 /***********************************************************
122 * Blockbits functions.
124 static inline BOOL BIGBLOCKFILE_TestBit(const BlockBits *bb,
125 unsigned int index)
127 unsigned int array_index = index / (CHAR_BIT * sizeof(unsigned int));
128 unsigned int bit_index = index % (CHAR_BIT * sizeof(unsigned int));
130 return bb->bits[array_index] & (1 << bit_index);
133 static inline void BIGBLOCKFILE_SetBit(BlockBits *bb, unsigned int index)
135 unsigned int array_index = index / (CHAR_BIT * sizeof(unsigned int));
136 unsigned int bit_index = index % (CHAR_BIT * sizeof(unsigned int));
138 bb->bits[array_index] |= (1 << bit_index);
141 static inline void BIGBLOCKFILE_ClearBit(BlockBits *bb, unsigned int index)
143 unsigned int array_index = index / (CHAR_BIT * sizeof(unsigned int));
144 unsigned int bit_index = index % (CHAR_BIT * sizeof(unsigned int));
146 bb->bits[array_index] &= ~(1 << bit_index);
149 static inline void BIGBLOCKFILE_Zero(BlockBits *bb)
151 memset(bb->bits, 0, sizeof(bb->bits));
154 /******************************************************************************
155 * BIGBLOCKFILE_Construct
157 * Construct a big block file. Create the file mapping object.
158 * Create the read only mapped pages list, the writable mapped page list
159 * and the blocks in use list.
161 BigBlockFile * BIGBLOCKFILE_Construct(
162 HANDLE hFile,
163 ILockBytes* pLkByt,
164 DWORD openFlags,
165 ULONG blocksize,
166 BOOL fileBased)
168 LPBIGBLOCKFILE This;
170 This = (LPBIGBLOCKFILE)HeapAlloc(GetProcessHeap(), 0, sizeof(BigBlockFile));
172 if (This == NULL)
173 return NULL;
175 This->fileBased = fileBased;
177 This->flProtect = BIGBLOCKFILE_GetProtectMode(openFlags);
179 This->blocksize = blocksize;
181 This->maplist = NULL;
182 This->victimhead = NULL;
183 This->victimtail = NULL;
184 This->num_victim_pages = 0;
186 if (This->fileBased)
188 if (!BIGBLOCKFILE_FileInit(This, hFile))
190 HeapFree(GetProcessHeap(), 0, This);
191 return NULL;
194 else
196 if (!BIGBLOCKFILE_MemInit(This, pLkByt))
198 HeapFree(GetProcessHeap(), 0, This);
199 return NULL;
203 return This;
206 /******************************************************************************
207 * BIGBLOCKFILE_FileInit
209 * Initialize a big block object supported by a file.
211 static BOOL BIGBLOCKFILE_FileInit(LPBIGBLOCKFILE This, HANDLE hFile)
213 This->pLkbyt = NULL;
214 This->hbytearray = 0;
215 This->pbytearray = NULL;
217 This->hfile = hFile;
219 if (This->hfile == INVALID_HANDLE_VALUE)
220 return FALSE;
222 /* create the file mapping object
224 This->hfilemap = CreateFileMappingA(This->hfile,
225 NULL,
226 This->flProtect,
227 0, 0,
228 NULL);
230 if (!This->hfilemap)
232 CloseHandle(This->hfile);
233 return FALSE;
236 This->filesize.s.LowPart = GetFileSize(This->hfile,
237 &This->filesize.s.HighPart);
239 This->maplist = NULL;
241 TRACE("file len %lu\n", This->filesize.s.LowPart);
243 return TRUE;
246 /******************************************************************************
247 * BIGBLOCKFILE_MemInit
249 * Initialize a big block object supported by an ILockBytes on HGLOABL.
251 static BOOL BIGBLOCKFILE_MemInit(LPBIGBLOCKFILE This, ILockBytes* plkbyt)
253 This->hfile = 0;
254 This->hfilemap = 0;
257 * Retrieve the handle to the byte array from the LockByte object.
259 if (GetHGlobalFromILockBytes(plkbyt, &(This->hbytearray)) != S_OK)
261 FIXME("May not be an ILockBytes on HGLOBAL\n");
262 return FALSE;
265 This->pLkbyt = plkbyt;
268 * Increment the reference count of the ILockByte object since
269 * we're keeping a reference to it.
271 ILockBytes_AddRef(This->pLkbyt);
273 This->filesize.s.LowPart = GlobalSize(This->hbytearray);
274 This->filesize.s.HighPart = 0;
276 This->pbytearray = GlobalLock(This->hbytearray);
278 TRACE("mem on %p len %lu\n", This->pbytearray, This->filesize.s.LowPart);
280 return TRUE;
283 /******************************************************************************
284 * BIGBLOCKFILE_Destructor
286 * Destructor. Clean up, free memory.
288 void BIGBLOCKFILE_Destructor(
289 LPBIGBLOCKFILE This)
291 BIGBLOCKFILE_FreeAllMappedPages(This);
293 if (This->fileBased)
295 CloseHandle(This->hfilemap);
296 CloseHandle(This->hfile);
298 else
300 GlobalUnlock(This->hbytearray);
301 ILockBytes_Release(This->pLkbyt);
304 /* destroy this
306 HeapFree(GetProcessHeap(), 0, This);
309 /******************************************************************************
310 * BIGBLOCKFILE_GetROBigBlock
312 * Returns the specified block in read only mode.
313 * Will return NULL if the block doesn't exists.
315 void* BIGBLOCKFILE_GetROBigBlock(
316 LPBIGBLOCKFILE This,
317 ULONG index)
320 * block index starts at -1
321 * translate to zero based index
323 if (index == 0xffffffff)
324 index = 0;
325 else
326 index++;
329 * validate the block index
332 if (This->blocksize * (index + 1)
333 > ROUND_UP(This->filesize.s.LowPart, This->blocksize))
335 TRACE("out of range %lu vs %lu\n", This->blocksize * (index + 1),
336 This->filesize.s.LowPart);
337 return NULL;
340 return BIGBLOCKFILE_GetBigBlockPointer(This, index, FILE_MAP_READ);
343 /******************************************************************************
344 * BIGBLOCKFILE_GetBigBlock
346 * Returns the specified block.
347 * Will grow the file if necessary.
349 void* BIGBLOCKFILE_GetBigBlock(LPBIGBLOCKFILE This, ULONG index)
352 * block index starts at -1
353 * translate to zero based index
355 if (index == 0xffffffff)
356 index = 0;
357 else
358 index++;
361 * make sure that the block physically exists
363 if ((This->blocksize * (index + 1)) > This->filesize.s.LowPart)
365 ULARGE_INTEGER newSize;
367 newSize.s.HighPart = 0;
368 newSize.s.LowPart = This->blocksize * (index + 1);
370 BIGBLOCKFILE_SetSize(This, newSize);
373 return BIGBLOCKFILE_GetBigBlockPointer(This, index, FILE_MAP_WRITE);
376 /******************************************************************************
377 * BIGBLOCKFILE_ReleaseBigBlock
379 * Releases the specified block.
381 void BIGBLOCKFILE_ReleaseBigBlock(LPBIGBLOCKFILE This, void *pBlock)
383 MappedPage *page;
385 if (pBlock == NULL)
386 return;
388 page = BIGBLOCKFILE_GetPageFromPointer(This, pBlock);
390 if (page == NULL)
391 return;
393 BIGBLOCKFILE_ReleaseMappedPage(This, page);
396 /******************************************************************************
397 * BIGBLOCKFILE_SetSize
399 * Sets the size of the file.
402 void BIGBLOCKFILE_SetSize(LPBIGBLOCKFILE This, ULARGE_INTEGER newSize)
404 if (This->filesize.s.LowPart == newSize.s.LowPart)
405 return;
407 TRACE("from %lu to %lu\n", This->filesize.s.LowPart, newSize.s.LowPart);
409 * unmap all views, must be done before call to SetEndFile
411 BIGBLOCKFILE_UnmapAllMappedPages(This);
413 if (This->fileBased)
415 char buf[10];
418 * close file-mapping object, must be done before call to SetEndFile
420 CloseHandle(This->hfilemap);
421 This->hfilemap = 0;
424 * BEGIN HACK
425 * This fixes a bug when saving through smbfs.
426 * smbmount a Windows shared directory, save a structured storage file
427 * to that dir: crash.
429 * The problem is that the SetFilePointer-SetEndOfFile combo below
430 * doesn't always succeed. The file is not grown. It seems like the
431 * operation is cached. By doing the WriteFile, the file is actually
432 * grown on disk.
433 * This hack is only needed when saving to smbfs.
435 memset(buf, '0', 10);
436 SetFilePointer(This->hfile, newSize.s.LowPart, NULL, FILE_BEGIN);
437 WriteFile(This->hfile, buf, 10, NULL, NULL);
439 * END HACK
443 * set the new end of file
445 SetFilePointer(This->hfile, newSize.s.LowPart, NULL, FILE_BEGIN);
446 SetEndOfFile(This->hfile);
449 * re-create the file mapping object
451 This->hfilemap = CreateFileMappingA(This->hfile,
452 NULL,
453 This->flProtect,
454 0, 0,
455 NULL);
457 else
459 GlobalUnlock(This->hbytearray);
462 * Resize the byte array object.
464 ILockBytes_SetSize(This->pLkbyt, newSize);
467 * Re-acquire the handle, it may have changed.
469 GetHGlobalFromILockBytes(This->pLkbyt, &This->hbytearray);
470 This->pbytearray = GlobalLock(This->hbytearray);
473 This->filesize.s.LowPart = newSize.s.LowPart;
474 This->filesize.s.HighPart = newSize.s.HighPart;
476 BIGBLOCKFILE_RemapAllMappedPages(This);
479 /******************************************************************************
480 * BIGBLOCKFILE_GetSize
482 * Returns the size of the file.
485 ULARGE_INTEGER BIGBLOCKFILE_GetSize(LPBIGBLOCKFILE This)
487 return This->filesize;
490 /******************************************************************************
491 * BIGBLOCKFILE_AccessCheck [PRIVATE]
493 * block_index is the index within the page.
495 static BOOL BIGBLOCKFILE_AccessCheck(MappedPage *page, ULONG block_index,
496 DWORD desired_access)
498 assert(block_index < BLOCKS_PER_PAGE);
500 if (desired_access == FILE_MAP_READ)
502 if (BIGBLOCKFILE_TestBit(&page->writable_blocks, block_index))
503 return FALSE;
505 BIGBLOCKFILE_SetBit(&page->readable_blocks, block_index);
507 else
509 assert(desired_access == FILE_MAP_WRITE);
511 if (BIGBLOCKFILE_TestBit(&page->readable_blocks, block_index))
512 return FALSE;
514 BIGBLOCKFILE_SetBit(&page->writable_blocks, block_index);
517 return TRUE;
520 /******************************************************************************
521 * BIGBLOCKFILE_GetBigBlockPointer [PRIVATE]
523 * Returns a pointer to the specified block.
525 static void* BIGBLOCKFILE_GetBigBlockPointer(
526 LPBIGBLOCKFILE This,
527 ULONG block_index,
528 DWORD desired_access)
530 DWORD page_index = block_index / BLOCKS_PER_PAGE;
531 DWORD block_on_page = block_index % BLOCKS_PER_PAGE;
533 MappedPage *page = BIGBLOCKFILE_GetMappedView(This, page_index);
534 if (!page || !page->lpBytes) return NULL;
536 if (!BIGBLOCKFILE_AccessCheck(page, block_on_page, desired_access))
538 BIGBLOCKFILE_ReleaseMappedPage(This, page);
539 return NULL;
542 return (LPBYTE)page->lpBytes + (block_on_page * This->blocksize);
545 /******************************************************************************
546 * BIGBLOCKFILE_GetMappedPageFromPointer [PRIVATE]
548 * pBlock is a pointer to a block on a page.
549 * The page has to be on the in-use list. (As oppsed to the victim list.)
551 * Does not increment the usage count.
553 static MappedPage *BIGBLOCKFILE_GetPageFromPointer(LPBIGBLOCKFILE This,
554 void *pBlock)
556 MappedPage *page;
558 for (page = This->maplist; page != NULL; page = page->next)
560 if ((LPBYTE)pBlock >= (LPBYTE)page->lpBytes
561 && (LPBYTE)pBlock <= (LPBYTE)page->lpBytes + PAGE_SIZE)
562 break;
566 return page;
569 /******************************************************************************
570 * BIGBLOCKFILE_FindPageInList [PRIVATE]
573 static MappedPage *BIGBLOCKFILE_FindPageInList(MappedPage *head,
574 ULONG page_index)
576 for (; head != NULL; head = head->next)
578 if (head->page_index == page_index)
580 InterlockedIncrement(&head->refcnt);
581 break;
585 return head;
589 static void BIGBLOCKFILE_UnlinkPage(MappedPage *page)
591 if (page->next) page->next->prev = page->prev;
592 if (page->prev) page->prev->next = page->next;
595 static void BIGBLOCKFILE_LinkHeadPage(MappedPage **head, MappedPage *page)
597 if (*head) (*head)->prev = page;
598 page->next = *head;
599 page->prev = NULL;
600 *head = page;
603 /******************************************************************************
604 * BIGBLOCKFILE_GetMappedView [PRIVATE]
606 * Gets the page requested if it is already mapped.
607 * If it's not already mapped, this method will map it
609 static void * BIGBLOCKFILE_GetMappedView(
610 LPBIGBLOCKFILE This,
611 DWORD page_index)
613 MappedPage *page;
615 page = BIGBLOCKFILE_FindPageInList(This->maplist, page_index);
616 if (!page)
618 page = BIGBLOCKFILE_FindPageInList(This->victimhead, page_index);
619 if (page)
621 This->num_victim_pages--;
623 BIGBLOCKFILE_Zero(&page->readable_blocks);
624 BIGBLOCKFILE_Zero(&page->writable_blocks);
628 if (page)
630 /* If the page is not already at the head of the list, move
631 * it there. (Also moves pages from victim to main list.) */
632 if (This->maplist != page)
634 if (This->victimhead == page) This->victimhead = page->next;
635 if (This->victimtail == page) This->victimtail = page->prev;
637 BIGBLOCKFILE_UnlinkPage(page);
639 BIGBLOCKFILE_LinkHeadPage(&This->maplist, page);
642 return page;
645 page = BIGBLOCKFILE_CreatePage(This, page_index);
646 if (!page) return NULL;
648 BIGBLOCKFILE_LinkHeadPage(&This->maplist, page);
650 return page;
653 static BOOL BIGBLOCKFILE_MapPage(LPBIGBLOCKFILE This, MappedPage *page)
655 DWORD lowoffset = PAGE_SIZE * page->page_index;
657 if (This->fileBased)
659 DWORD numBytesToMap;
660 DWORD desired_access;
662 if (lowoffset + PAGE_SIZE > This->filesize.s.LowPart)
663 numBytesToMap = This->filesize.s.LowPart - lowoffset;
664 else
665 numBytesToMap = PAGE_SIZE;
667 if (This->flProtect == PAGE_READONLY)
668 desired_access = FILE_MAP_READ;
669 else
670 desired_access = FILE_MAP_WRITE;
672 page->lpBytes = MapViewOfFile(This->hfilemap, desired_access, 0,
673 lowoffset, numBytesToMap);
675 else
677 page->lpBytes = (LPBYTE)This->pbytearray + lowoffset;
680 TRACE("mapped page %lu to %p\n", page->page_index, page->lpBytes);
682 return page->lpBytes != NULL;
685 static MappedPage *BIGBLOCKFILE_CreatePage(LPBIGBLOCKFILE This,
686 ULONG page_index)
688 MappedPage *page;
690 page = HeapAlloc(GetProcessHeap(), 0, sizeof(MappedPage));
691 if (page == NULL)
692 return NULL;
694 page->page_index = page_index;
695 page->refcnt = 1;
697 page->next = NULL;
698 page->prev = NULL;
700 BIGBLOCKFILE_MapPage(This, page);
702 BIGBLOCKFILE_Zero(&page->readable_blocks);
703 BIGBLOCKFILE_Zero(&page->writable_blocks);
705 return page;
708 static void BIGBLOCKFILE_UnmapPage(LPBIGBLOCKFILE This, MappedPage *page)
710 TRACE("%ld at %p\n", page->page_index, page->lpBytes);
711 if (page->refcnt > 0)
712 ERR("unmapping inuse page %p\n", page->lpBytes);
714 if (This->fileBased && page->lpBytes)
715 UnmapViewOfFile(page->lpBytes);
717 page->lpBytes = NULL;
720 static void BIGBLOCKFILE_DeletePage(LPBIGBLOCKFILE This, MappedPage *page)
722 BIGBLOCKFILE_UnmapPage(This, page);
724 HeapFree(GetProcessHeap(), 0, page);
727 /******************************************************************************
728 * BIGBLOCKFILE_ReleaseMappedPage [PRIVATE]
730 * Decrements the reference count of the mapped page.
732 static void BIGBLOCKFILE_ReleaseMappedPage(
733 LPBIGBLOCKFILE This,
734 MappedPage *page)
736 assert(This != NULL);
737 assert(page != NULL);
739 /* If the page is no longer refenced, move it to the victim list.
740 * If the victim list is too long, kick somebody off. */
741 if (!InterlockedDecrement(&page->refcnt))
743 if (This->maplist == page) This->maplist = page->next;
745 BIGBLOCKFILE_UnlinkPage(page);
747 if (MAX_VICTIM_PAGES > 0)
749 if (This->num_victim_pages >= MAX_VICTIM_PAGES)
751 MappedPage *victim = This->victimtail;
752 if (victim)
754 This->victimtail = victim->prev;
755 if (This->victimhead == victim)
756 This->victimhead = victim->next;
758 BIGBLOCKFILE_UnlinkPage(victim);
759 BIGBLOCKFILE_DeletePage(This, victim);
762 else This->num_victim_pages++;
764 BIGBLOCKFILE_LinkHeadPage(&This->victimhead, page);
765 if (This->victimtail == NULL) This->victimtail = page;
767 else
768 BIGBLOCKFILE_DeletePage(This, page);
772 static void BIGBLOCKFILE_DeleteList(LPBIGBLOCKFILE This, MappedPage *list)
774 while (list != NULL)
776 MappedPage *next = list->next;
778 BIGBLOCKFILE_DeletePage(This, list);
780 list = next;
784 /******************************************************************************
785 * BIGBLOCKFILE_FreeAllMappedPages [PRIVATE]
787 * Unmap all currently mapped pages.
788 * Empty mapped pages list.
790 static void BIGBLOCKFILE_FreeAllMappedPages(
791 LPBIGBLOCKFILE This)
793 BIGBLOCKFILE_DeleteList(This, This->maplist);
794 BIGBLOCKFILE_DeleteList(This, This->victimhead);
796 This->maplist = NULL;
797 This->victimhead = NULL;
798 This->victimtail = NULL;
799 This->num_victim_pages = 0;
802 static void BIGBLOCKFILE_UnmapList(LPBIGBLOCKFILE This, MappedPage *list)
804 for (; list != NULL; list = list->next)
806 BIGBLOCKFILE_UnmapPage(This, list);
810 static void BIGBLOCKFILE_UnmapAllMappedPages(LPBIGBLOCKFILE This)
812 BIGBLOCKFILE_UnmapList(This, This->maplist);
813 BIGBLOCKFILE_UnmapList(This, This->victimhead);
816 static void BIGBLOCKFILE_RemapList(LPBIGBLOCKFILE This, MappedPage *list)
818 while (list != NULL)
820 MappedPage *next = list->next;
822 if (list->page_index * PAGE_SIZE > This->filesize.s.LowPart)
824 TRACE("discarding %lu\n", list->page_index);
826 /* page is entirely outside of the file, delete it */
827 BIGBLOCKFILE_UnlinkPage(list);
828 BIGBLOCKFILE_DeletePage(This, list);
830 else
832 /* otherwise, remap it */
833 BIGBLOCKFILE_MapPage(This, list);
836 list = next;
840 static void BIGBLOCKFILE_RemapAllMappedPages(LPBIGBLOCKFILE This)
842 BIGBLOCKFILE_RemapList(This, This->maplist);
843 BIGBLOCKFILE_RemapList(This, This->victimhead);
846 /****************************************************************************
847 * BIGBLOCKFILE_GetProtectMode
849 * This function will return a protection mode flag for a file-mapping object
850 * from the open flags of a file.
852 static DWORD BIGBLOCKFILE_GetProtectMode(DWORD openFlags)
854 if (openFlags & (STGM_WRITE | STGM_READWRITE))
855 return PAGE_READWRITE;
856 else
857 return PAGE_READONLY;