新线程的默认堆栈大小嵌入在 .exe 文件中(请参阅下面转储输出中的“堆栈大小”字段)。创建线程时,应用程序可以指定自定义堆栈大小,但大多数应用程序只使用编译时指定的默认值。
>link.exe /dump /headers "c:\Program Files\Internet Explorer\iexplore.exe"
Microsoft (R) COFF/PE Dumper Version 11.00.50727.1 Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file c:\Program Files\Internet Explorer\iexplore.exe
PE signature found
File Type: EXECUTABLE IMAGE
...
OPTIONAL HEADER VALUES
20B magic # (PE32+)
10.00 linker version
4A00 size of code
B1C00 size of initialized data
0 size of uninitialized data
2CE8 entry point (0000000000402CE8) wWinMainCRTStartup
1000 base of code
400000 image base (0000000000400000 to 00000000004BAFFF)
1000 section alignment
200 file alignment
6.01 operating system version
6.01 image version
6.00 subsystem version
0 Win32 version
BB000 size of image
400 size of headers
C16C7 checksum
2 subsystem (Windows GUI)
8140 DLL characteristics
Dynamic base
NX compatible
Terminal Server Aware
100000 size of stack reserve
E000 size of stack commit
可以编辑这些,但您必须复制整个目录以避开一些安全限制。使用 Visual Studio 工具集,这将使堆栈大小加倍:
- 复制:“C:\Program Files\Internet Explorer”到“C:\Program Files\Internet Explorer Big”
- 运行:editbin.exe /STACK:0x200000,0xE000 "c:\Program Files\Internet Explorer Big\iexplore.exe"
作为参考,PE 文件格式规范可以在这里下载。