- unsigned char *tmp;
-
- /* First reserve the upper part of our heap. (We reserve first
- because there have been problems in the past where doing the
- mapping first has loaded DLLs into the VA space of our heap.) */
- tmp = VirtualAlloc ((void *) get_heap_end (),
- get_reserved_heap_size () - get_committed_heap_size (),
- MEM_RESERVE,
- PAGE_NOACCESS);
- if (!tmp)
- exit (1);
-
- /* We read in the data for the .bss section from the executable
- first and map in the heap from the executable second to prevent
- any funny interactions between file I/O and file mapping. */
- read_in_bss (executable_path);
- map_in_heap (executable_path);
+ PIMAGE_DOS_HEADER dos_header;
+ PIMAGE_NT_HEADERS nt_header;
+
+ dos_header = (PIMAGE_DOS_HEADER) RVA_TO_PTR (0);
+ nt_header = (PIMAGE_NT_HEADERS) (((unsigned long) dos_header) +
+ dos_header->e_lfanew);
+ preload_heap_section = find_section ("EMHEAP", nt_header);
+
+ if (using_dynamic_heap)
+ {
+ data_region_base = allocate_heap ();
+ if (!data_region_base)
+ {
+ printf ("Error: Could not reserve dynamic heap area.\n");
+ exit (1);
+ }
+
+#if !defined (USE_LISP_UNION_TYPE) && !defined (USE_LSB_TAG)
+ /* Ensure that the addresses don't use the upper tag bits since
+ the Lisp type goes there. */
+ if (((unsigned long) data_region_base & ~VALMASK) != 0)
+ {
+ printf ("Error: The heap was allocated in upper memory.\n");
+ exit (1);
+ }
+#endif
+ data_region_end = data_region_base;
+ real_data_region_end = data_region_end;
+ }
+ else
+ {
+ data_region_base = RVA_TO_PTR (preload_heap_section->VirtualAddress);
+ data_region_end = data_region_base;
+ real_data_region_end = data_region_end;
+ reserved_heap_size = preload_heap_section->Misc.VirtualSize;
+ }
+
+ /* Update system version information to match current system. */
+ cache_system_info ();