- /*
- * Can't pull stack start from fs:4 or fs:8 or whatever,
- * because that's only what currently has memory behind
- * it from being used. Our basic options are to know,
- * a priori, what the stack size is (1 meg by default)
- * or to grub the default size out of the executable
- * header in memory by means of hardcoded addresses and
- * offsets.
- *
- * We'll just assume it's 1 megabyte. Easiest that way.
- */
- cur_stack_start = cur_stack_end - 0x100000;
-
- /*
- * We use top_exception_frame rather than cur_stack_end
- * to elide the last few (boring) stack entries at the
- * bottom of the backtrace.
- */
- thread->control_stack_start = cur_stack_start;
+ /* Can't pull stack start from fs:4 or fs:8 or whatever,
+ * because that's only what currently has memory behind
+ * it from being used, so do a quick VirtualQuery() and
+ * grab the AllocationBase. -AB 2006/11/25
+ */
+
+ if (!VirtualQuery(&stack_memory, &stack_memory, sizeof(stack_memory))) {
+ fprintf(stderr, "VirtualQuery: 0x%lx.\n", GetLastError());
+ lose("Could not query stack memory information.");
+ }
+ cur_stack_start = stack_memory.AllocationBase;
+
+ /* We use top_exception_frame rather than cur_stack_end to
+ * elide the last few (boring) stack entries at the bottom of
+ * the backtrace.
+ */
+ thread->control_stack_start = cur_stack_start;