5a8a25d4d05426575047bf292c07fd7dcdd65037
[reactos.git] / reactos / boot / freeldr / freeldr / mm / meminit.c
1 /*
2 * FreeLoader
3 * Copyright (C) 2006-2008 Aleksey Bragin <aleksey@reactos.org>
4 * Copyright (C) 2006-2009 Hervé Poussineau <hpoussin@reactos.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #include <freeldr.h>
22 #include <debug.h>
23
24 DBG_DEFAULT_CHANNEL(MEMORY);
25
26 #if DBG
27 typedef struct
28 {
29 TYPE_OF_MEMORY Type;
30 PCSTR TypeString;
31 } FREELDR_MEMORY_TYPE, *PFREELDR_MEMORY_TYPE;
32
33 FREELDR_MEMORY_TYPE MemoryTypeArray[] =
34 {
35 { LoaderMaximum, "Unknown memory" },
36 { LoaderFree, "Free memory" },
37 { LoaderBad, "Bad memory" },
38 { LoaderLoadedProgram, "LoadedProgram" },
39 { LoaderFirmwareTemporary, "FirmwareTemporary" },
40 { LoaderFirmwarePermanent, "FirmwarePermanent" },
41 { LoaderOsloaderHeap, "OsloaderHeap" },
42 { LoaderOsloaderStack, "OsloaderStack" },
43 { LoaderSystemCode, "SystemCode" },
44 { LoaderHalCode, "HalCode" },
45 { LoaderBootDriver, "BootDriver" },
46 { LoaderRegistryData, "RegistryData" },
47 { LoaderMemoryData, "MemoryData" },
48 { LoaderNlsData, "NlsData" },
49 { LoaderSpecialMemory, "SpecialMemory" },
50 { LoaderReserve, "Reserve" },
51 };
52 ULONG MemoryTypeCount = sizeof(MemoryTypeArray) / sizeof(MemoryTypeArray[0]);
53 #endif
54
55 PVOID PageLookupTableAddress = NULL;
56 PFN_NUMBER TotalPagesInLookupTable = 0;
57 PFN_NUMBER FreePagesInLookupTable = 0;
58 PFN_NUMBER LastFreePageHint = 0;
59 PFN_NUMBER MmLowestPhysicalPage = 0xFFFFFFFF;
60 PFN_NUMBER MmHighestPhysicalPage = 0;
61
62 PFREELDR_MEMORY_DESCRIPTOR BiosMemoryMap;
63 ULONG BiosMemoryMapEntryCount;
64
65 extern ULONG_PTR MmHeapPointer;
66 extern ULONG_PTR MmHeapStart;
67
68 ULONG
69 AddMemoryDescriptor(
70 IN OUT PFREELDR_MEMORY_DESCRIPTOR List,
71 IN ULONG MaxCount,
72 IN PFN_NUMBER BasePage,
73 IN PFN_NUMBER PageCount,
74 IN TYPE_OF_MEMORY MemoryType)
75 {
76 ULONG i, c;
77 PFN_NUMBER NextBase;
78 TRACE("AddMemoryDescriptor(0x%lx-0x%lx [0x%lx pages])\n",
79 BasePage, BasePage + PageCount, PageCount);
80
81 /* Scan through all existing descriptors */
82 for (i = 0, c = 0; (c < MaxCount) && (List[c].PageCount != 0); c++)
83 {
84 /* Count entries completely below the new range */
85 if (List[i].BasePage + List[i].PageCount <= BasePage) i++;
86 }
87
88 /* Check if the list is full */
89 if (c >= MaxCount) return c;
90
91 /* Is there an existing descriptor starting before the new range */
92 while ((i < c) && (List[i].BasePage <= BasePage))
93 {
94 /* The end of the existing one is the minimum for the new range */
95 NextBase = List[i].BasePage + List[i].PageCount;
96
97 /* Bail out, if everything is trimmed away */
98 if ((BasePage + PageCount) <= NextBase) return c;
99
100 /* Trim the naew range at the lower end */
101 PageCount -= (NextBase - BasePage);
102 BasePage = NextBase;
103
104 /* Go to the next entry and repeat */
105 i++;
106 }
107
108 ASSERT(PageCount > 0);
109
110 /* Are there still entries above? */
111 if (i < c)
112 {
113 /* Shift the following entries one up */
114 RtlMoveMemory(&List[i+1], &List[i], (c - i) * sizeof(List[0]));
115
116 /* Insert the new range */
117 List[i].BasePage = BasePage;
118 List[i].PageCount = min(PageCount, List[i+1].BasePage - BasePage);
119 List[i].MemoryType = MemoryType;
120 c++;
121
122 TRACE("Inserting at i=%ld: (0x%lx:0x%lx)\n",
123 i, List[i].BasePage, List[i].PageCount);
124
125 /* Check if the range was trimmed */
126 if (PageCount > List[i].PageCount)
127 {
128 /* Recursively process the trimmed part */
129 c = AddMemoryDescriptor(List,
130 MaxCount,
131 BasePage + List[i].PageCount,
132 PageCount - List[i].PageCount,
133 MemoryType);
134 }
135 }
136 else
137 {
138 /* We can simply add the range here */
139 TRACE("Adding i=%ld: (0x%lx:0x%lx)\n", i, BasePage, PageCount);
140 List[i].BasePage = BasePage;
141 List[i].PageCount = PageCount;
142 List[i].MemoryType = MemoryType;
143 c++;
144 }
145
146 /* Return the new count */
147 return c;
148 }
149
150 const FREELDR_MEMORY_DESCRIPTOR*
151 ArcGetMemoryDescriptor(const FREELDR_MEMORY_DESCRIPTOR* Current)
152 {
153 if (Current == NULL)
154 {
155 return BiosMemoryMap;
156 }
157 else
158 {
159 Current++;
160 if (Current->PageCount == 0) return NULL;
161 return Current;
162 }
163 }
164
165
166 BOOLEAN
167 MmCheckFreeldrImageFile()
168 {
169 PIMAGE_NT_HEADERS NtHeaders;
170 PIMAGE_FILE_HEADER FileHeader;
171 PIMAGE_OPTIONAL_HEADER OptionalHeader;
172
173 /* Get the NT headers */
174 NtHeaders = RtlImageNtHeader(&__ImageBase);
175 if (!NtHeaders)
176 {
177 ERR("Coult not get NtHeaders!\n");
178 return FALSE;
179 }
180
181 /* Check the file header */
182 FileHeader = &NtHeaders->FileHeader;
183 if ((FileHeader->Machine != IMAGE_FILE_MACHINE_NATIVE) ||
184 (FileHeader->NumberOfSections != FREELDR_SECTION_COUNT) ||
185 (FileHeader->PointerToSymbolTable != 0) ||
186 (FileHeader->NumberOfSymbols != 0) ||
187 (FileHeader->NumberOfSymbols != 0) ||
188 (FileHeader->SizeOfOptionalHeader != 0xE0))
189 {
190 return FALSE;
191 }
192
193 /* Check the optional header */
194 OptionalHeader = &NtHeaders->OptionalHeader;
195 if ((OptionalHeader->Magic != IMAGE_NT_OPTIONAL_HDR_MAGIC) ||
196 (OptionalHeader->Subsystem != 1) || // native
197 (OptionalHeader->ImageBase != FREELDR_PE_BASE) ||
198 (OptionalHeader->SizeOfImage > MAX_FREELDR_PE_SIZE) ||
199 (OptionalHeader->SectionAlignment != OptionalHeader->FileAlignment))
200 {
201 return FALSE;
202 }
203
204 return TRUE;
205 }
206
207 BOOLEAN MmInitializeMemoryManager(VOID)
208 {
209 #if DBG
210 const FREELDR_MEMORY_DESCRIPTOR* MemoryDescriptor = NULL;
211 #endif
212
213 TRACE("Initializing Memory Manager.\n");
214
215 /* Check the freeldr binary */
216 if (!MmCheckFreeldrImageFile())
217 {
218 FrLdrBugCheck(FREELDR_IMAGE_CORRUPTION);
219 }
220
221 BiosMemoryMap = MachVtbl.GetMemoryMap(&BiosMemoryMapEntryCount);
222
223 #if DBG
224 // Dump the system memory map
225 TRACE("System Memory Map (Base Address, Length, Type):\n");
226 while ((MemoryDescriptor = ArcGetMemoryDescriptor(MemoryDescriptor)) != NULL)
227 {
228 TRACE("%x\t %x\t %s\n",
229 MemoryDescriptor->BasePage * MM_PAGE_SIZE,
230 MemoryDescriptor->PageCount * MM_PAGE_SIZE,
231 MmGetSystemMemoryMapTypeString(MemoryDescriptor->MemoryType));
232 }
233 #endif
234
235 // Find address for the page lookup table
236 TotalPagesInLookupTable = MmGetAddressablePageCountIncludingHoles();
237 PageLookupTableAddress = MmFindLocationForPageLookupTable(TotalPagesInLookupTable);
238 LastFreePageHint = MmHighestPhysicalPage;
239
240 if (PageLookupTableAddress == 0)
241 {
242 // If we get here then we probably couldn't
243 // find a contiguous chunk of memory big
244 // enough to hold the page lookup table
245 printf("Error initializing memory manager!\n");
246 return FALSE;
247 }
248
249 // Initialize the page lookup table
250 MmInitPageLookupTable(PageLookupTableAddress, TotalPagesInLookupTable);
251
252 MmUpdateLastFreePageHint(PageLookupTableAddress, TotalPagesInLookupTable);
253
254 FreePagesInLookupTable = MmCountFreePagesInLookupTable(PageLookupTableAddress,
255 TotalPagesInLookupTable);
256
257 MmInitializeHeap(PageLookupTableAddress);
258
259 TRACE("Memory Manager initialized. 0x%x pages available.\n", FreePagesInLookupTable);
260
261
262 return TRUE;
263 }
264
265 #if DBG
266 PCSTR MmGetSystemMemoryMapTypeString(TYPE_OF_MEMORY Type)
267 {
268 ULONG Index;
269
270 for (Index=1; Index<MemoryTypeCount; Index++)
271 {
272 if (MemoryTypeArray[Index].Type == Type)
273 {
274 return MemoryTypeArray[Index].TypeString;
275 }
276 }
277
278 return MemoryTypeArray[0].TypeString;
279 }
280 #endif
281
282 PFN_NUMBER MmGetPageNumberFromAddress(PVOID Address)
283 {
284 return ((ULONG_PTR)Address) / MM_PAGE_SIZE;
285 }
286
287 PFN_NUMBER MmGetAddressablePageCountIncludingHoles(VOID)
288 {
289 const FREELDR_MEMORY_DESCRIPTOR* MemoryDescriptor = NULL;
290 PFN_NUMBER PageCount;
291
292 //
293 // Go through the whole memory map to get max address
294 //
295 while ((MemoryDescriptor = ArcGetMemoryDescriptor(MemoryDescriptor)) != NULL)
296 {
297 //
298 // Check if we got a higher end page address
299 //
300 if (MemoryDescriptor->BasePage + MemoryDescriptor->PageCount > MmHighestPhysicalPage)
301 {
302 //
303 // Yes, remember it if this is real memory
304 //
305 if (MemoryDescriptor->MemoryType == LoaderFree)
306 MmHighestPhysicalPage = MemoryDescriptor->BasePage + MemoryDescriptor->PageCount;
307 }
308
309 //
310 // Check if we got a higher (usable) start page address
311 //
312 if (MemoryDescriptor->BasePage < MmLowestPhysicalPage)
313 {
314 //
315 // Yes, remember it if this is real memory
316 //
317 MmLowestPhysicalPage = MemoryDescriptor->BasePage;
318 }
319 }
320
321 TRACE("lo/hi %lx %lx\n", MmLowestPhysicalPage, MmHighestPhysicalPage);
322 PageCount = MmHighestPhysicalPage - MmLowestPhysicalPage;
323 TRACE("MmGetAddressablePageCountIncludingHoles() returning 0x%x\n", PageCount);
324 return PageCount;
325 }
326
327 PVOID MmFindLocationForPageLookupTable(PFN_NUMBER TotalPageCount)
328 {
329 const FREELDR_MEMORY_DESCRIPTOR* MemoryDescriptor = NULL;
330 SIZE_T PageLookupTableSize;
331 PFN_NUMBER PageLookupTablePages;
332 PFN_NUMBER PageLookupTableStartPage = 0;
333 PVOID PageLookupTableMemAddress = NULL;
334
335 // Calculate how much pages we need to keep the page lookup table
336 PageLookupTableSize = TotalPageCount * sizeof(PAGE_LOOKUP_TABLE_ITEM);
337 PageLookupTablePages = PageLookupTableSize / MM_PAGE_SIZE;
338
339 // Search the highest memory block big enough to contain lookup table
340 while ((MemoryDescriptor = ArcGetMemoryDescriptor(MemoryDescriptor)) != NULL)
341 {
342 // Continue, if memory is not free
343 if (MemoryDescriptor->MemoryType != LoaderFree) continue;
344
345 // Continue, if the block is not big enough?
346 if (MemoryDescriptor->PageCount < PageLookupTablePages) continue;
347
348 // Continue, if it is not at a higher address than previous address
349 if (MemoryDescriptor->BasePage < PageLookupTableStartPage) continue;
350
351 // Continue, if the address is too high
352 if (MemoryDescriptor->BasePage >= MM_MAX_PAGE) continue;
353
354 // Memory block is more suitable than the previous one
355 PageLookupTableStartPage = MemoryDescriptor->BasePage;
356 PageLookupTableMemAddress = (PVOID)((ULONG_PTR)
357 (MemoryDescriptor->BasePage + MemoryDescriptor->PageCount) * MM_PAGE_SIZE
358 - PageLookupTableSize);
359 }
360
361 TRACE("MmFindLocationForPageLookupTable() returning 0x%x\n", PageLookupTableMemAddress);
362
363 return PageLookupTableMemAddress;
364 }
365
366 VOID MmInitPageLookupTable(PVOID PageLookupTable, PFN_NUMBER TotalPageCount)
367 {
368 const FREELDR_MEMORY_DESCRIPTOR* MemoryDescriptor = NULL;
369 PFN_NUMBER PageLookupTableStartPage;
370 PFN_NUMBER PageLookupTablePageCount;
371
372 TRACE("MmInitPageLookupTable()\n");
373
374 // Mark every page as allocated initially
375 // We will go through and mark pages again according to the memory map
376 // But this will mark any holes not described in the map as allocated
377 MmMarkPagesInLookupTable(PageLookupTable, MmLowestPhysicalPage, TotalPageCount, LoaderFirmwarePermanent);
378
379 // Parse the whole memory map
380 while ((MemoryDescriptor = ArcGetMemoryDescriptor(MemoryDescriptor)) != NULL)
381 {
382 // Mark used pages in the lookup table
383
384 if (MemoryDescriptor->BasePage + MemoryDescriptor->PageCount <= TotalPageCount)
385 {
386 TRACE("Marking pages 0x%lx-0x%lx as type %s\n",
387 MemoryDescriptor->BasePage,
388 MemoryDescriptor->BasePage + MemoryDescriptor->PageCount,
389 MmGetSystemMemoryMapTypeString(MemoryDescriptor->MemoryType));
390 MmMarkPagesInLookupTable(PageLookupTable,
391 MemoryDescriptor->BasePage,
392 MemoryDescriptor->PageCount,
393 MemoryDescriptor->MemoryType);
394 }
395 else
396 TRACE("Ignoring pages 0x%lx-0x%lx (%s)\n",
397 MemoryDescriptor->BasePage,
398 MemoryDescriptor->BasePage + MemoryDescriptor->PageCount,
399 MmGetSystemMemoryMapTypeString(MemoryDescriptor->MemoryType));
400 }
401
402 // Mark the pages that the lookup table occupies as reserved
403 PageLookupTableStartPage = MmGetPageNumberFromAddress(PageLookupTable);
404 PageLookupTablePageCount = MmGetPageNumberFromAddress((PVOID)((ULONG_PTR)PageLookupTable + ROUND_UP(TotalPageCount * sizeof(PAGE_LOOKUP_TABLE_ITEM), MM_PAGE_SIZE))) - PageLookupTableStartPage;
405 TRACE("Marking the page lookup table pages as reserved StartPage: 0x%x PageCount: 0x%x\n", PageLookupTableStartPage, PageLookupTablePageCount);
406 MmMarkPagesInLookupTable(PageLookupTable, PageLookupTableStartPage, PageLookupTablePageCount, LoaderFirmwareTemporary);
407 }
408
409 VOID MmMarkPagesInLookupTable(PVOID PageLookupTable, PFN_NUMBER StartPage, PFN_NUMBER PageCount, TYPE_OF_MEMORY PageAllocated)
410 {
411 PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable;
412 PFN_NUMBER Index;
413 TRACE("MmMarkPagesInLookupTable()\n");
414
415 /* Validate the range */
416 if ((StartPage < MmLowestPhysicalPage) ||
417 ((StartPage + PageCount - 1) > MmHighestPhysicalPage))
418 {
419 ERR("Memory (0x%lx:0x%lx) outside of lookup table! Valid range: 0x%lx-0x%lx.\n",
420 StartPage, PageCount, MmLowestPhysicalPage, MmHighestPhysicalPage);
421 return;
422 }
423
424 StartPage -= MmLowestPhysicalPage;
425 for (Index=StartPage; Index<(StartPage+PageCount); Index++)
426 {
427 #if 0
428 if ((Index <= (StartPage + 16)) || (Index >= (StartPage+PageCount-16)))
429 {
430 TRACE("Index = 0x%x StartPage = 0x%x PageCount = 0x%x\n", Index, StartPage, PageCount);
431 }
432 #endif
433 RealPageLookupTable[Index].PageAllocated = PageAllocated;
434 RealPageLookupTable[Index].PageAllocationLength = (PageAllocated != LoaderFree) ? 1 : 0;
435 }
436 TRACE("MmMarkPagesInLookupTable() Done\n");
437 }
438
439 VOID MmAllocatePagesInLookupTable(PVOID PageLookupTable, PFN_NUMBER StartPage, PFN_NUMBER PageCount, TYPE_OF_MEMORY MemoryType)
440 {
441 PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable;
442 PFN_NUMBER Index;
443
444 StartPage -= MmLowestPhysicalPage;
445 for (Index=StartPage; Index<(StartPage+PageCount); Index++)
446 {
447 RealPageLookupTable[Index].PageAllocated = MemoryType;
448 RealPageLookupTable[Index].PageAllocationLength = (Index == StartPage) ? PageCount : 0;
449 }
450 }
451
452 PFN_NUMBER MmCountFreePagesInLookupTable(PVOID PageLookupTable, PFN_NUMBER TotalPageCount)
453 {
454 PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable;
455 PFN_NUMBER Index;
456 PFN_NUMBER FreePageCount;
457
458 FreePageCount = 0;
459 for (Index=0; Index<TotalPageCount; Index++)
460 {
461 if (RealPageLookupTable[Index].PageAllocated == LoaderFree)
462 {
463 FreePageCount++;
464 }
465 }
466
467 return FreePageCount;
468 }
469
470 PFN_NUMBER MmFindAvailablePages(PVOID PageLookupTable, PFN_NUMBER TotalPageCount, PFN_NUMBER PagesNeeded, BOOLEAN FromEnd)
471 {
472 PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable;
473 PFN_NUMBER AvailablePagesSoFar;
474 PFN_NUMBER Index;
475
476 if (LastFreePageHint > TotalPageCount)
477 {
478 LastFreePageHint = TotalPageCount;
479 }
480
481 AvailablePagesSoFar = 0;
482 if (FromEnd)
483 {
484 /* Allocate "high" (from end) pages */
485 for (Index=LastFreePageHint-1; Index>0; Index--)
486 {
487 if (RealPageLookupTable[Index].PageAllocated != LoaderFree)
488 {
489 AvailablePagesSoFar = 0;
490 continue;
491 }
492 else
493 {
494 AvailablePagesSoFar++;
495 }
496
497 if (AvailablePagesSoFar >= PagesNeeded)
498 {
499 return Index + MmLowestPhysicalPage;
500 }
501 }
502 }
503 else
504 {
505 TRACE("Alloc low memory, LastFreePageHint 0x%x, TPC 0x%x\n", LastFreePageHint, TotalPageCount);
506 /* Allocate "low" pages */
507 for (Index=1; Index < LastFreePageHint; Index++)
508 {
509 if (RealPageLookupTable[Index].PageAllocated != LoaderFree)
510 {
511 AvailablePagesSoFar = 0;
512 continue;
513 }
514 else
515 {
516 AvailablePagesSoFar++;
517 }
518
519 if (AvailablePagesSoFar >= PagesNeeded)
520 {
521 return Index - AvailablePagesSoFar + 1 + MmLowestPhysicalPage;
522 }
523 }
524 }
525
526 return 0;
527 }
528
529 PFN_NUMBER MmFindAvailablePagesBeforePage(PVOID PageLookupTable, PFN_NUMBER TotalPageCount, PFN_NUMBER PagesNeeded, PFN_NUMBER LastPage)
530 {
531 PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable;
532 PFN_NUMBER AvailablePagesSoFar;
533 PFN_NUMBER Index;
534
535 if (LastPage > TotalPageCount)
536 {
537 return MmFindAvailablePages(PageLookupTable, TotalPageCount, PagesNeeded, TRUE);
538 }
539
540 AvailablePagesSoFar = 0;
541 for (Index=LastPage-1; Index>0; Index--)
542 {
543 if (RealPageLookupTable[Index].PageAllocated != LoaderFree)
544 {
545 AvailablePagesSoFar = 0;
546 continue;
547 }
548 else
549 {
550 AvailablePagesSoFar++;
551 }
552
553 if (AvailablePagesSoFar >= PagesNeeded)
554 {
555 return Index + MmLowestPhysicalPage;
556 }
557 }
558
559 return 0;
560 }
561
562 VOID MmUpdateLastFreePageHint(PVOID PageLookupTable, PFN_NUMBER TotalPageCount)
563 {
564 PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable;
565 PFN_NUMBER Index;
566
567 for (Index=TotalPageCount-1; Index>0; Index--)
568 {
569 if (RealPageLookupTable[Index].PageAllocated == LoaderFree)
570 {
571 LastFreePageHint = Index + 1 + MmLowestPhysicalPage;
572 break;
573 }
574 }
575 }
576
577 BOOLEAN MmAreMemoryPagesAvailable(PVOID PageLookupTable, PFN_NUMBER TotalPageCount, PVOID PageAddress, PFN_NUMBER PageCount)
578 {
579 PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable;
580 PFN_NUMBER StartPage;
581 PFN_NUMBER Index;
582
583 StartPage = MmGetPageNumberFromAddress(PageAddress);
584
585 if (StartPage < MmLowestPhysicalPage) return FALSE;
586
587 StartPage -= MmLowestPhysicalPage;
588
589 // Make sure they aren't trying to go past the
590 // end of availabe memory
591 if ((StartPage + PageCount) > TotalPageCount)
592 {
593 return FALSE;
594 }
595
596 for (Index = StartPage; Index < (StartPage + PageCount); Index++)
597 {
598 // If this page is allocated then there obviously isn't
599 // memory availabe so return FALSE
600 if (RealPageLookupTable[Index].PageAllocated != LoaderFree)
601 {
602 return FALSE;
603 }
604 }
605
606 return TRUE;
607 }